Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/vast-pandas-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"layne": patch
---

fix: $global scanner config (semgrep, trufflehog, claude, piAgent) is now correctly inherited by per-repo entries
19 changes: 19 additions & 0 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,24 @@ describe('loadScanConfig()', () => {

// --- piAgent defaults ---

it('inherits $global semgrep config when the repo has no semgrep block', async () => {
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify({
'$global': { semgrep: { extraArgs: ['--config', 'p/owasp-top-ten'] } },
'acme/frontend': { mode: 'diff_only' },
}));
const config = await loadScanConfig({ owner: 'acme', repo: 'frontend' });
expect((config.semgrep as { extraArgs: string[] }).extraArgs).toEqual(['--config', 'p/owasp-top-ten']);
});

it('per-repo semgrep overrides $global semgrep at the key level', async () => {
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify({
'$global': { semgrep: { extraArgs: ['--config', 'p/owasp-top-ten'] } },
'acme/payments': { semgrep: { extraArgs: ['--config', 'p/python'] } },
}));
const config = await loadScanConfig({ owner: 'acme', repo: 'payments' });
expect((config.semgrep as { extraArgs: string[] }).extraArgs).toEqual(['--config', 'p/python']);
});

it('DEFAULT_CONFIG.piAgent has timeoutMinutes 10', () => {
expect((DEFAULT_CONFIG.piAgent as Record<string, unknown>).timeoutMinutes).toBe(10);
});
Expand Down Expand Up @@ -437,3 +455,4 @@ describe('loadScanConfig()', () => {
expect((config.piAgent as Record<string, unknown>).timeoutMinutes).toBe(15);
});
});

8 changes: 4 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ export async function loadScanConfig({ owner, repo }: { owner: string; repo: str
mode: repoOverrides.mode ?? globalConfig.mode ?? DEFAULT_CONFIG.mode,
contextLines: repoOverrides.contextLines ?? globalConfig.contextLines ?? DEFAULT_CONFIG.contextLines,
timeoutMinutes: repoOverrides.timeoutMinutes ?? globalConfig.timeoutMinutes ?? DEFAULT_CONFIG.timeoutMinutes,
semgrep: { ...DEFAULT_CONFIG.semgrep, ...(repoOverrides.semgrep ?? {}) },
trufflehog: { ...DEFAULT_CONFIG.trufflehog, ...(repoOverrides.trufflehog ?? {}) },
claude: { ...DEFAULT_CONFIG.claude, ...(repoOverrides.claude ?? {}) },
piAgent: { ...DEFAULT_CONFIG.piAgent, ...(repoOverrides.piAgent ?? {}) },
semgrep: { ...DEFAULT_CONFIG.semgrep, ...(globalConfig.semgrep ?? {}), ...(repoOverrides.semgrep ?? {}) },
trufflehog:{ ...DEFAULT_CONFIG.trufflehog, ...(globalConfig.trufflehog ?? {}), ...(repoOverrides.trufflehog ?? {}) },
claude: { ...DEFAULT_CONFIG.claude, ...(globalConfig.claude ?? {}), ...(repoOverrides.claude ?? {}) },
piAgent: { ...DEFAULT_CONFIG.piAgent, ...(globalConfig.piAgent ?? {}), ...(repoOverrides.piAgent ?? {}) },
notifications: { ...globalNotifications, ...repoNotifications },
labels: { ...globalLabels, ...repoLabels },
trigger: { ...DEFAULT_CONFIG.trigger, ...globalTrigger, ...(repoOverrides.trigger ?? {}) },
Expand Down
Loading