ghagga-core 2.9.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/acp/adapter.d.ts.map +1 -1
- package/dist/acp/adapter.js +1 -1
- package/dist/acp/adapter.js.map +1 -1
- package/dist/acp/index.d.ts +1 -1
- package/dist/acp/index.d.ts.map +1 -1
- package/dist/acp/index.js.map +1 -1
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/agents/consensus.d.ts.map +1 -1
- package/dist/agents/consensus.js +7 -2
- package/dist/agents/consensus.js.map +1 -1
- package/dist/agents/diagnostic.d.ts.map +1 -1
- package/dist/agents/diagnostic.js +7 -2
- package/dist/agents/diagnostic.js.map +1 -1
- package/dist/agents/fan-out-lenses.d.ts.map +1 -1
- package/dist/agents/fan-out-lenses.js +7 -2
- package/dist/agents/fan-out-lenses.js.map +1 -1
- package/dist/agents/prompts.d.ts +49 -1
- package/dist/agents/prompts.d.ts.map +1 -1
- package/dist/agents/prompts.js +133 -5
- package/dist/agents/prompts.js.map +1 -1
- package/dist/agents/simple.d.ts +1 -1
- package/dist/agents/simple.d.ts.map +1 -1
- package/dist/agents/simple.js +6 -4
- package/dist/agents/simple.js.map +1 -1
- package/dist/agents/workflow.d.ts.map +1 -1
- package/dist/agents/workflow.js +13 -4
- package/dist/agents/workflow.js.map +1 -1
- package/dist/critique/critique.d.ts.map +1 -1
- package/dist/critique/critique.js +14 -6
- package/dist/critique/critique.js.map +1 -1
- package/dist/critique/cross-model.d.ts.map +1 -1
- package/dist/critique/cross-model.js +1 -3
- package/dist/critique/cross-model.js.map +1 -1
- package/dist/critique/index.d.ts +1 -2
- package/dist/critique/index.d.ts.map +1 -1
- package/dist/critique/index.js +1 -2
- package/dist/critique/index.js.map +1 -1
- package/dist/diff/index.d.ts +12 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +11 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/diff/parse.d.ts +41 -0
- package/dist/diff/parse.d.ts.map +1 -0
- package/dist/diff/parse.js +303 -0
- package/dist/diff/parse.js.map +1 -0
- package/dist/diff/types.d.ts +106 -0
- package/dist/diff/types.d.ts.map +1 -0
- package/dist/diff/types.js +23 -0
- package/dist/diff/types.js.map +1 -0
- package/dist/embed.d.ts +5 -2
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +7 -3
- package/dist/embed.js.map +1 -1
- package/dist/enhance/prompt.d.ts +5 -1
- package/dist/enhance/prompt.d.ts.map +1 -1
- package/dist/enhance/prompt.js +9 -2
- package/dist/enhance/prompt.js.map +1 -1
- package/dist/format.d.ts +31 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +256 -15
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/dist/memory/pageindex/chunker.d.ts +1 -1
- package/dist/memory/pageindex/chunker.d.ts.map +1 -1
- package/dist/memory/pageindex/chunker.js +5 -5
- package/dist/memory/pageindex/chunker.js.map +1 -1
- package/dist/memory/pageindex/example.d.ts +1 -1
- package/dist/memory/pageindex/example.d.ts.map +1 -1
- package/dist/memory/pageindex/example.js +1 -2
- package/dist/memory/pageindex/example.js.map +1 -1
- package/dist/memory/pageindex/index.d.ts +3 -3
- package/dist/memory/pageindex/index.d.ts.map +1 -1
- package/dist/memory/pageindex/index.js +1 -1
- package/dist/memory/pageindex/index.js.map +1 -1
- package/dist/memory/pageindex/service.d.ts +11 -2
- package/dist/memory/pageindex/service.d.ts.map +1 -1
- package/dist/memory/pageindex/service.js +12 -11
- package/dist/memory/pageindex/service.js.map +1 -1
- package/dist/memory/persist.d.ts.map +1 -1
- package/dist/memory/persist.js +10 -3
- package/dist/memory/persist.js.map +1 -1
- package/dist/memory/privacy.d.ts.map +1 -1
- package/dist/memory/privacy.js +45 -6
- package/dist/memory/privacy.js.map +1 -1
- package/dist/memory/sqlite.d.ts +1 -13
- package/dist/memory/sqlite.d.ts.map +1 -1
- package/dist/memory/sqlite.js +45 -27
- package/dist/memory/sqlite.js.map +1 -1
- package/dist/memory/taxonomy.d.ts.map +1 -1
- package/dist/memory/taxonomy.js +6 -1
- package/dist/memory/taxonomy.js.map +1 -1
- package/dist/pipeline/degrade.d.ts +61 -0
- package/dist/pipeline/degrade.d.ts.map +1 -0
- package/dist/pipeline/degrade.js +58 -0
- package/dist/pipeline/degrade.js.map +1 -0
- package/dist/pipeline/enrich.d.ts +29 -0
- package/dist/pipeline/enrich.d.ts.map +1 -0
- package/dist/pipeline/enrich.js +271 -0
- package/dist/pipeline/enrich.js.map +1 -0
- package/dist/pipeline/execute.d.ts +22 -0
- package/dist/pipeline/execute.d.ts.map +1 -0
- package/dist/pipeline/execute.js +250 -0
- package/dist/pipeline/execute.js.map +1 -0
- package/dist/pipeline/finalize.d.ts +26 -0
- package/dist/pipeline/finalize.d.ts.map +1 -0
- package/dist/pipeline/finalize.js +52 -0
- package/dist/pipeline/finalize.js.map +1 -0
- package/dist/pipeline/gather-context.d.ts +25 -0
- package/dist/pipeline/gather-context.d.ts.map +1 -0
- package/dist/pipeline/gather-context.js +169 -0
- package/dist/pipeline/gather-context.js.map +1 -0
- package/dist/pipeline/gather-safe.d.ts +39 -0
- package/dist/pipeline/gather-safe.d.ts.map +1 -0
- package/dist/pipeline/gather-safe.js +127 -0
- package/dist/pipeline/gather-safe.js.map +1 -0
- package/dist/pipeline/prepare-graph.d.ts +54 -0
- package/dist/pipeline/prepare-graph.d.ts.map +1 -0
- package/dist/pipeline/prepare-graph.js +174 -0
- package/dist/pipeline/prepare-graph.js.map +1 -0
- package/dist/pipeline/prepare.d.ts +40 -0
- package/dist/pipeline/prepare.d.ts.map +1 -0
- package/dist/pipeline/prepare.js +233 -0
- package/dist/pipeline/prepare.js.map +1 -0
- package/dist/pipeline/providers.d.ts +54 -0
- package/dist/pipeline/providers.d.ts.map +1 -0
- package/dist/pipeline/providers.js +163 -0
- package/dist/pipeline/providers.js.map +1 -0
- package/dist/pipeline/results.d.ts +35 -0
- package/dist/pipeline/results.d.ts.map +1 -0
- package/dist/pipeline/results.js +122 -0
- package/dist/pipeline/results.js.map +1 -0
- package/dist/pipeline/state.d.ts +92 -0
- package/dist/pipeline/state.d.ts.map +1 -0
- package/dist/pipeline/state.js +13 -0
- package/dist/pipeline/state.js.map +1 -0
- package/dist/pipeline.d.ts +10 -9
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +36 -1213
- package/dist/pipeline.js.map +1 -1
- package/dist/providers/gateway.d.ts.map +1 -1
- package/dist/providers/gateway.js +8 -0
- package/dist/providers/gateway.js.map +1 -1
- package/dist/recursive/index.d.ts +1 -0
- package/dist/recursive/index.d.ts.map +1 -1
- package/dist/recursive/index.js +7 -3
- package/dist/recursive/index.js.map +1 -1
- package/dist/recursive/patch-extractor.d.ts +58 -6
- package/dist/recursive/patch-extractor.d.ts.map +1 -1
- package/dist/recursive/patch-extractor.js +207 -26
- package/dist/recursive/patch-extractor.js.map +1 -1
- package/dist/sanitize.d.ts +51 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +90 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/scope/diff-mapper.d.ts +12 -0
- package/dist/scope/diff-mapper.d.ts.map +1 -1
- package/dist/scope/diff-mapper.js +25 -18
- package/dist/scope/diff-mapper.js.map +1 -1
- package/dist/scope/entity-diff.d.ts +21 -4
- package/dist/scope/entity-diff.d.ts.map +1 -1
- package/dist/scope/entity-diff.js +132 -34
- package/dist/scope/entity-diff.js.map +1 -1
- package/dist/scope/types.d.ts +10 -0
- package/dist/scope/types.d.ts.map +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js.map +1 -1
- package/dist/search/indexer.d.ts.map +1 -1
- package/dist/search/indexer.js +33 -4
- package/dist/search/indexer.js.map +1 -1
- package/dist/search/searcher.d.ts.map +1 -1
- package/dist/search/searcher.js.map +1 -1
- package/dist/semantic-diff/index.d.ts +25 -2
- package/dist/semantic-diff/index.d.ts.map +1 -1
- package/dist/semantic-diff/index.js +147 -53
- package/dist/semantic-diff/index.js.map +1 -1
- package/dist/tools/gitleaks-config.toml +35 -0
- package/dist/tools/plugins/gitleaks.d.ts +10 -0
- package/dist/tools/plugins/gitleaks.d.ts.map +1 -1
- package/dist/tools/plugins/gitleaks.js +29 -2
- package/dist/tools/plugins/gitleaks.js.map +1 -1
- package/dist/tools/plugins/semgrep.d.ts +11 -0
- package/dist/tools/plugins/semgrep.d.ts.map +1 -1
- package/dist/tools/plugins/semgrep.js +30 -1
- package/dist/tools/plugins/semgrep.js.map +1 -1
- package/dist/tools/semgrep-rules.yml +305 -0
- package/dist/types.d.ts +51 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/diff.d.ts +22 -2
- package/dist/utils/diff.d.ts.map +1 -1
- package/dist/utils/diff.js +36 -40
- package/dist/utils/diff.js.map +1 -1
- package/package.json +21 -22
- package/dist/providers/fallback.d.ts +0 -54
- package/dist/providers/fallback.d.ts.map +0 -1
- package/dist/providers/fallback.js +0 -102
- package/dist/providers/fallback.js.map +0 -1
- package/dist/providers/index.d.ts +0 -49
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -146
- package/dist/providers/index.js.map +0 -1
package/dist/search/indexer.js
CHANGED
|
@@ -11,10 +11,39 @@
|
|
|
11
11
|
* Keeps the index lean and improves search relevance.
|
|
12
12
|
*/
|
|
13
13
|
export const STOP_WORDS = new Set([
|
|
14
|
-
'a',
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
14
|
+
'a',
|
|
15
|
+
'an',
|
|
16
|
+
'and',
|
|
17
|
+
'are',
|
|
18
|
+
'as',
|
|
19
|
+
'at',
|
|
20
|
+
'be',
|
|
21
|
+
'but',
|
|
22
|
+
'by',
|
|
23
|
+
'for',
|
|
24
|
+
'if',
|
|
25
|
+
'in',
|
|
26
|
+
'into',
|
|
27
|
+
'is',
|
|
28
|
+
'it',
|
|
29
|
+
'no',
|
|
30
|
+
'not',
|
|
31
|
+
'of',
|
|
32
|
+
'on',
|
|
33
|
+
'or',
|
|
34
|
+
'such',
|
|
35
|
+
'that',
|
|
36
|
+
'the',
|
|
37
|
+
'their',
|
|
38
|
+
'then',
|
|
39
|
+
'there',
|
|
40
|
+
'these',
|
|
41
|
+
'they',
|
|
42
|
+
'this',
|
|
43
|
+
'to',
|
|
44
|
+
'was',
|
|
45
|
+
'will',
|
|
46
|
+
'with',
|
|
18
47
|
]);
|
|
19
48
|
/** Minimum token length to index. */
|
|
20
49
|
const MIN_TOKEN_LENGTH = 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/search/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,kEAAkE;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IAChC,GAAG,
|
|
1
|
+
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/search/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,kEAAkE;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IAChC,GAAG;IACH,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;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d.ts","sourceRoot":"","sources":["../../src/search/searcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS1E,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,CAAC,CAAS;gBAEN,OAAO,EAAE,aAAa,EAAE,MAAM,GAAE,UAAe;IAM3D;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,YAAY,EAAE;CAsEnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searcher.js","sourceRoot":"","sources":["../../src/search/searcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"searcher.js","sourceRoot":"","sources":["../../src/search/searcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,iEAAiE;AAEjE,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,kEAAkE;AAElE,MAAM,OAAO,YAAY;IACf,OAAO,CAAgB;IACvB,EAAE,CAAS;IACX,CAAC,CAAS;IAElB,YAAY,OAAsB,EAAE,SAAqB,EAAE;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,UAAU,CAAC;QAClC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,SAAS,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAa,EAAE,UAAy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SAAS,CAAC,GAAG,KAAK;gBAAE,OAAO,SAAS,CAAC;YAClD,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -4,9 +4,29 @@
|
|
|
4
4
|
* Instead of raw line diffs, extracts WHAT changed at the entity level:
|
|
5
5
|
* function renamed, class added, method signature changed, etc.
|
|
6
6
|
*
|
|
7
|
-
* Implementation is regex-based — no tree-sitter required.
|
|
7
|
+
* Implementation is regex-based — no tree-sitter required. File sectioning
|
|
8
|
+
* is delegated to the unified diff parser (`src/diff/parse.ts`); declaration
|
|
9
|
+
* detection stays local.
|
|
10
|
+
*
|
|
11
|
+
* WIRED TO PRODUCTION (SDD wire-semantic-diff, 2026-06-13).
|
|
12
|
+
* `extractSemanticDiff` runs in the enrich phase (`pipeline/enrich.ts`),
|
|
13
|
+
* its result lands on `ReviewResult.semanticDiff`, and that feeds the
|
|
14
|
+
* "What changed" section of the PR comment via `formatSemanticDiffSection`
|
|
15
|
+
* (`format.ts`). This is no longer an unwired re-export.
|
|
16
|
+
*
|
|
17
|
+
* Known limitations (real, by design — the extractor is regex-based, not a
|
|
18
|
+
* parser, and matches single-line declarations only; all pinned in
|
|
19
|
+
* `index.test.ts`):
|
|
20
|
+
* - a multiline arrow whose `=>` lands on the next line is not detected;
|
|
21
|
+
* - a generic constraint CONTAINING parens (`<T extends () => void>`) is
|
|
22
|
+
* not detected (the `[^(]*` guard that keeps comparisons out excludes it);
|
|
23
|
+
* - declarations spanning multiple lines are matched only by their first
|
|
24
|
+
* line.
|
|
25
|
+
* The presentation layer (`format.ts`) drops `method_*` noise and gates to
|
|
26
|
+
* TS/JS files, so these misses degrade the cosmetic comment section only —
|
|
27
|
+
* never the review verdict.
|
|
8
28
|
*/
|
|
9
|
-
export type EntityChangeKind = 'function_added' | 'function_removed' | 'function_modified' | 'class_added' | 'class_removed' | 'method_added' | 'method_removed' | 'method_modified' | 'import_added' | 'import_removed' | 'export_added' | 'export_removed' | 'type_added' | 'type_removed' | 'type_modified';
|
|
29
|
+
export type EntityChangeKind = 'function_added' | 'function_removed' | 'function_modified' | 'class_added' | 'class_removed' | 'class_modified' | 'method_added' | 'method_removed' | 'method_modified' | 'import_added' | 'import_removed' | 'import_modified' | 'export_added' | 'export_removed' | 'export_modified' | 'type_added' | 'type_removed' | 'type_modified';
|
|
10
30
|
export interface EntityChange {
|
|
11
31
|
kind: EntityChangeKind;
|
|
12
32
|
name: string;
|
|
@@ -26,6 +46,9 @@ export interface SemanticDiff {
|
|
|
26
46
|
*
|
|
27
47
|
* Returns a SemanticDiff with individual EntityChange items and a
|
|
28
48
|
* human-readable summary string.
|
|
49
|
+
*
|
|
50
|
+
* Wired into the review pipeline (enrich phase → `ReviewResult.semanticDiff`
|
|
51
|
+
* → "What changed" PR comment section). See the module header.
|
|
29
52
|
*/
|
|
30
53
|
export declare function extractSemanticDiff(unifiedDiff: string): SemanticDiff;
|
|
31
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic-diff/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/semantic-diff/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,GACjB,YAAY,GACZ,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;CACjB;AA+MD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAiCrE"}
|
|
@@ -4,25 +4,48 @@
|
|
|
4
4
|
* Instead of raw line diffs, extracts WHAT changed at the entity level:
|
|
5
5
|
* function renamed, class added, method signature changed, etc.
|
|
6
6
|
*
|
|
7
|
-
* Implementation is regex-based — no tree-sitter required.
|
|
7
|
+
* Implementation is regex-based — no tree-sitter required. File sectioning
|
|
8
|
+
* is delegated to the unified diff parser (`src/diff/parse.ts`); declaration
|
|
9
|
+
* detection stays local.
|
|
10
|
+
*
|
|
11
|
+
* WIRED TO PRODUCTION (SDD wire-semantic-diff, 2026-06-13).
|
|
12
|
+
* `extractSemanticDiff` runs in the enrich phase (`pipeline/enrich.ts`),
|
|
13
|
+
* its result lands on `ReviewResult.semanticDiff`, and that feeds the
|
|
14
|
+
* "What changed" section of the PR comment via `formatSemanticDiffSection`
|
|
15
|
+
* (`format.ts`). This is no longer an unwired re-export.
|
|
16
|
+
*
|
|
17
|
+
* Known limitations (real, by design — the extractor is regex-based, not a
|
|
18
|
+
* parser, and matches single-line declarations only; all pinned in
|
|
19
|
+
* `index.test.ts`):
|
|
20
|
+
* - a multiline arrow whose `=>` lands on the next line is not detected;
|
|
21
|
+
* - a generic constraint CONTAINING parens (`<T extends () => void>`) is
|
|
22
|
+
* not detected (the `[^(]*` guard that keeps comparisons out excludes it);
|
|
23
|
+
* - declarations spanning multiple lines are matched only by their first
|
|
24
|
+
* line.
|
|
25
|
+
* The presentation layer (`format.ts`) drops `method_*` noise and gates to
|
|
26
|
+
* TS/JS files, so these misses degrade the cosmetic comment section only —
|
|
27
|
+
* never the review verdict.
|
|
8
28
|
*/
|
|
29
|
+
import { parseUnifiedDiff } from '../diff/index.js';
|
|
9
30
|
// ─── Regex Patterns ──────────────────────────────────────────────
|
|
10
31
|
/**
|
|
11
32
|
* Patterns that match declaration lines.
|
|
12
33
|
* Each entry includes the entity category for grouping (function|class|method|import|export|type).
|
|
13
34
|
*/
|
|
14
35
|
const DECLARATION_PATTERNS = [
|
|
36
|
+
// NOTE: ORDER MATTERS. The generic "export <name>" pattern is intentionally
|
|
37
|
+
// listed LAST so that more specific declarations — `export function foo`,
|
|
38
|
+
// `export class Foo`, `export const fn = () => …`, `export type Foo` — are
|
|
39
|
+
// classified by their real entity kind (function/class/type) instead of being
|
|
40
|
+
// swallowed by a catch-all `export` rule. Only plain value re-exports
|
|
41
|
+
// (e.g. `export const VERSION = '1.0'`, `export default expr`) fall through
|
|
42
|
+
// to the `export` kind.
|
|
15
43
|
// import statements — match before export/function to avoid conflicts
|
|
16
44
|
{
|
|
17
45
|
kind: 'import',
|
|
18
46
|
pattern: /^\s*import\s+(?:type\s+)?(?:\{[^}]*\}|[\w*]+(?:\s+as\s+\w+)?)\s+from\s+['"][^'"]+['"]/,
|
|
19
47
|
},
|
|
20
|
-
// export
|
|
21
|
-
{
|
|
22
|
-
kind: 'export',
|
|
23
|
-
pattern: /^\s*export\s+(?:default\s+)?(?:const|let|var|function\*?|async\s+function\*?)\s+(\w+)/,
|
|
24
|
-
},
|
|
25
|
-
// export type / interface
|
|
48
|
+
// export type / interface / enum (before the generic export rule)
|
|
26
49
|
{
|
|
27
50
|
kind: 'type',
|
|
28
51
|
pattern: /^\s*export\s+(?:type|interface|enum)\s+(\w+)/,
|
|
@@ -32,30 +55,47 @@ const DECLARATION_PATTERNS = [
|
|
|
32
55
|
kind: 'type',
|
|
33
56
|
pattern: /^\s*(?:type|interface|enum)\s+(\w+)/,
|
|
34
57
|
},
|
|
35
|
-
// class declaration
|
|
58
|
+
// class declaration (handles `export class` and `export abstract class`)
|
|
36
59
|
{
|
|
37
60
|
kind: 'class',
|
|
38
|
-
pattern: /^\s*(?:export\s+)?(?:abstract\s+)?class\s+(\w+)/,
|
|
61
|
+
pattern: /^\s*(?:export\s+)?(?:default\s+)?(?:abstract\s+)?class\s+(\w+)/,
|
|
39
62
|
},
|
|
40
|
-
//
|
|
63
|
+
// top-level function declaration (handles `export function` / `export async function`)
|
|
41
64
|
{
|
|
42
|
-
kind: '
|
|
43
|
-
pattern:
|
|
65
|
+
kind: 'function',
|
|
66
|
+
pattern: /^\s*(?:export\s+)?(?:default\s+)?(?:async\s+)?function\*?\s+(\w+)\s*\(/,
|
|
44
67
|
},
|
|
45
|
-
//
|
|
68
|
+
// arrow / function-expression assigned to const/let/var (handles `export const fn = () =>`,
|
|
69
|
+
// optionally typed: `export const fn: Foo = async () =>`).
|
|
70
|
+
// The RHS must be a real function: `function` keyword, or arrow params
|
|
71
|
+
// (paren-params — with an optional generic prefix `<T>` / `<T extends X>` —
|
|
72
|
+
// bare single param, optional return-type annotation) followed by `=>`
|
|
73
|
+
// ON THE SAME LINE. A bare `(` is NOT enough — that misclassified
|
|
74
|
+
// parenthesized non-function initializers (e.g.
|
|
75
|
+
// `const x = (row.metadata as Foo).bar`) as function_added.
|
|
76
|
+
// The generic prefix `<[^(]*>` is anchored to paren-params only (a bare
|
|
77
|
+
// param after a generic is not valid TS) and cannot contain `(` — so a
|
|
78
|
+
// `<` comparison initializer (`const a = x < y`) never enters this branch,
|
|
79
|
+
// and the cast false positive stays closed. Nested generics without parens
|
|
80
|
+
// (`<T extends Record<string, K>>`) resolve via the greedy last-`>`.
|
|
81
|
+
// Known limitations (accepted, pinned in index.test.ts):
|
|
82
|
+
// - a multiline arrow whose `=>` lands on the next line is not detected;
|
|
83
|
+
// - a generic constraint CONTAINING parens (`<T extends () => void>`)
|
|
84
|
+
// is not detected (the `[^(]*` guard that keeps comparisons out
|
|
85
|
+
// excludes it).
|
|
46
86
|
{
|
|
47
87
|
kind: 'function',
|
|
48
|
-
pattern: /^\s*(?:export\s+)?(?:async\s+)?function
|
|
88
|
+
pattern: /^\s*(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*[\w<>,\s|[\]]+?)?\s*=\s*(?:async\s+)?(?:function\b|(?:(?:<[^(]*>\s*)?\([^)]*\)|[\w$]+)\s*(?::[^=]*)?=>)/,
|
|
49
89
|
},
|
|
50
|
-
//
|
|
90
|
+
// method inside class (indented + no leading "function" keyword, has "()")
|
|
51
91
|
{
|
|
52
|
-
kind: '
|
|
53
|
-
pattern:
|
|
92
|
+
kind: 'method',
|
|
93
|
+
pattern: /^[ \t]+(?:(?:public|private|protected|static|async|override|readonly)\s+)*(\w+)\s*\(/,
|
|
54
94
|
},
|
|
55
|
-
//
|
|
95
|
+
// generic export of a plain value — LAST so the rules above win first
|
|
56
96
|
{
|
|
57
|
-
kind: '
|
|
58
|
-
pattern: /^\s*(?:
|
|
97
|
+
kind: 'export',
|
|
98
|
+
pattern: /^\s*export\s+(?:default\s+)?(?:const|let|var)\s+(\w+)/,
|
|
59
99
|
},
|
|
60
100
|
];
|
|
61
101
|
/**
|
|
@@ -80,37 +120,75 @@ function extractDeclaration(line) {
|
|
|
80
120
|
return null;
|
|
81
121
|
}
|
|
82
122
|
/**
|
|
83
|
-
*
|
|
123
|
+
* FROZEN LEGACY BEHAVIOR — path resolution for the pre-header
|
|
124
|
+
* pseudo-section. The historical splitter (`split(/^diff --git /m)`) kept
|
|
125
|
+
* everything before the first file header as a section of its own and
|
|
126
|
+
* resolved its "path" by running this tail regex over the FIRST line
|
|
127
|
+
* (almost always yielding `unknown`). Reachable via arbitrary ACP input
|
|
128
|
+
* and bare diff fragments, so it is preserved verbatim. This is NOT a
|
|
129
|
+
* file-header or hunk-header regex (spec R8 keeps those solely in
|
|
130
|
+
* `src/diff/`): it matches the tail of an already-isolated line.
|
|
84
131
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const content = line.slice(1);
|
|
97
|
-
const decl = extractDeclaration(content);
|
|
98
|
-
if (decl) {
|
|
99
|
-
added.set(decl.name, { name: decl.name, signature: content.trim(), kind: decl.kind });
|
|
100
|
-
}
|
|
132
|
+
const LEGACY_SECTION_PATH_RE = /a\/.+ b\/(.+)$/;
|
|
133
|
+
/** Scan a section's raw lines for added/removed declaration lines. */
|
|
134
|
+
function scanSection(lines, filePath) {
|
|
135
|
+
const added = new Map();
|
|
136
|
+
const removed = new Map();
|
|
137
|
+
for (const line of lines) {
|
|
138
|
+
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
139
|
+
const content = line.slice(1);
|
|
140
|
+
const decl = extractDeclaration(content);
|
|
141
|
+
if (decl) {
|
|
142
|
+
added.set(decl.name, { name: decl.name, signature: content.trim(), kind: decl.kind });
|
|
101
143
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
144
|
+
}
|
|
145
|
+
else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
146
|
+
const content = line.slice(1);
|
|
147
|
+
const decl = extractDeclaration(content);
|
|
148
|
+
if (decl) {
|
|
149
|
+
removed.set(decl.name, { name: decl.name, signature: content.trim(), kind: decl.kind });
|
|
108
150
|
}
|
|
109
151
|
}
|
|
110
|
-
result.push({ filePath, added, removed });
|
|
111
152
|
}
|
|
112
|
-
|
|
113
|
-
|
|
153
|
+
return { filePath, added, removed };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Split added/removed declaration lines per file.
|
|
157
|
+
*
|
|
158
|
+
* Thin adapter over the unified parser (`src/diff/parse.ts`) — replaces the
|
|
159
|
+
* historical local `parseHunks` that re-split the diff with its own
|
|
160
|
+
* `/^diff --git /m` regex. Sections scan `rawLines` (NOT the structured
|
|
161
|
+
* `hunk.lines`): the historical scanner looked at EVERY section line with
|
|
162
|
+
* the +/- prefix checks, including metadata regions and orphan +/- tails
|
|
163
|
+
* after a genuine empty line mid-hunk, which structured hunks do not carry.
|
|
164
|
+
*
|
|
165
|
+
* Path authority per file = the b-side of the `diff --git` header itself
|
|
166
|
+
* (`headerNewPath`), which equals the historical regex capture for every
|
|
167
|
+
* plain header (last ` b/` boundary included). Documented deltas vs the
|
|
168
|
+
* historical splitter, pinned in
|
|
169
|
+
* `src/diff/__tests__/parity-extract-semantic-diff.test.ts`:
|
|
170
|
+
* - quoted headers (CORE-M6 umbrella): historically the section existed
|
|
171
|
+
* but its path never matched the legacy regex → `unknown`; now the real
|
|
172
|
+
* unescaped path is resolved.
|
|
173
|
+
* - synthetic-only malformed headers (`diff --git <garbage>` mid-diff,
|
|
174
|
+
* mixed-quoted forms): the historical splitter opened a new section at
|
|
175
|
+
* ANY line starting with `diff --git `; the model only does so for
|
|
176
|
+
* parseable headers, so declarations after a garbage header line stay
|
|
177
|
+
* attributed to the previous file. Unreachable in git/GitHub/truncateDiff
|
|
178
|
+
* output.
|
|
179
|
+
*/
|
|
180
|
+
function collectHunkSets(unifiedDiff) {
|
|
181
|
+
const { preamble, files } = parseUnifiedDiff(unifiedDiff);
|
|
182
|
+
const result = [];
|
|
183
|
+
// Legacy pre-header pseudo-section (see LEGACY_SECTION_PATH_RE). The
|
|
184
|
+
// historical splitter dropped it only when empty (`filter(Boolean)`).
|
|
185
|
+
if (preamble.length > 0 && preamble.join('\n') !== '') {
|
|
186
|
+
const pathMatch = LEGACY_SECTION_PATH_RE.exec(preamble[0] ?? '');
|
|
187
|
+
result.push(scanSection(preamble, pathMatch?.[1] ?? 'unknown'));
|
|
188
|
+
}
|
|
189
|
+
for (const file of files) {
|
|
190
|
+
result.push(scanSection(file.rawLines, file.headerNewPath || 'unknown'));
|
|
191
|
+
}
|
|
114
192
|
return result;
|
|
115
193
|
}
|
|
116
194
|
// ─── Main Export ─────────────────────────────────────────────────
|
|
@@ -119,9 +197,12 @@ function parseHunks(unifiedDiff) {
|
|
|
119
197
|
*
|
|
120
198
|
* Returns a SemanticDiff with individual EntityChange items and a
|
|
121
199
|
* human-readable summary string.
|
|
200
|
+
*
|
|
201
|
+
* Wired into the review pipeline (enrich phase → `ReviewResult.semanticDiff`
|
|
202
|
+
* → "What changed" PR comment section). See the module header.
|
|
122
203
|
*/
|
|
123
204
|
export function extractSemanticDiff(unifiedDiff) {
|
|
124
|
-
const hunkSets =
|
|
205
|
+
const hunkSets = collectHunkSets(unifiedDiff);
|
|
125
206
|
const changes = [];
|
|
126
207
|
for (const { filePath, added, removed } of hunkSets) {
|
|
127
208
|
// Entities in both added and removed → modified
|
|
@@ -166,17 +247,30 @@ function mapToChangeKind(category, direction) {
|
|
|
166
247
|
? 'class_added'
|
|
167
248
|
: direction === 'removed'
|
|
168
249
|
? 'class_removed'
|
|
169
|
-
: '
|
|
250
|
+
: 'class_modified';
|
|
170
251
|
case 'method':
|
|
171
252
|
return direction === 'added'
|
|
172
253
|
? 'method_added'
|
|
173
254
|
: direction === 'removed'
|
|
174
255
|
? 'method_removed'
|
|
175
256
|
: 'method_modified';
|
|
257
|
+
// Modified imports/exports ARE reachable: a declaration whose name (for
|
|
258
|
+
// imports, the from-module) appears on both the +/- sides of a section is
|
|
259
|
+
// derived with direction 'modified'. Historically these fell into the
|
|
260
|
+
// false branch of a two-way ternary and were misreported as
|
|
261
|
+
// import_removed/export_removed (with both signatures set).
|
|
176
262
|
case 'import':
|
|
177
|
-
return direction === 'added'
|
|
263
|
+
return direction === 'added'
|
|
264
|
+
? 'import_added'
|
|
265
|
+
: direction === 'removed'
|
|
266
|
+
? 'import_removed'
|
|
267
|
+
: 'import_modified';
|
|
178
268
|
case 'export':
|
|
179
|
-
return direction === 'added'
|
|
269
|
+
return direction === 'added'
|
|
270
|
+
? 'export_added'
|
|
271
|
+
: direction === 'removed'
|
|
272
|
+
? 'export_removed'
|
|
273
|
+
: 'export_modified';
|
|
180
274
|
case 'type':
|
|
181
275
|
return direction === 'added'
|
|
182
276
|
? 'type_added'
|
|
@@ -203,10 +297,10 @@ function buildSummary(changes) {
|
|
|
203
297
|
parts.push(`${modified} ${label} modified`);
|
|
204
298
|
};
|
|
205
299
|
groupSummary('function_added', 'function_removed', 'function_modified', 'function');
|
|
206
|
-
groupSummary('class_added', 'class_removed', '
|
|
300
|
+
groupSummary('class_added', 'class_removed', 'class_modified', 'class');
|
|
207
301
|
groupSummary('method_added', 'method_removed', 'method_modified', 'method');
|
|
208
|
-
groupSummary('import_added', 'import_removed', '
|
|
209
|
-
groupSummary('export_added', 'export_removed', '
|
|
302
|
+
groupSummary('import_added', 'import_removed', 'import_modified', 'import');
|
|
303
|
+
groupSummary('export_added', 'export_removed', 'export_modified', 'export');
|
|
210
304
|
groupSummary('type_added', 'type_removed', 'type_modified', 'type');
|
|
211
305
|
if (parts.length === 0)
|
|
212
306
|
return 'no entity-level changes detected';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/semantic-diff/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/semantic-diff/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAwCpD,oEAAoE;AAEpE;;;GAGG;AACH,MAAM,oBAAoB,GAGrB;IACH,4EAA4E;IAC5E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,sEAAsE;IACtE,4EAA4E;IAC5E,wBAAwB;IAExB,sEAAsE;IACtE;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,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BAAgB,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAC5E,YAAY,CAAC,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAC5E,YAAY,CAAC,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;IAEpE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,kCAAkC,CAAC;IAClE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# GHAGGA bundled Gitleaks configuration
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Extends the gitleaks built-in default ruleset and adds a conservative
|
|
5
|
+
# path-based allowlist for test files / fixtures.
|
|
6
|
+
#
|
|
7
|
+
# Tradeoff (accepted by maintainer): this reduces noise from fake tokens in
|
|
8
|
+
# test fixtures at the cost of potentially missing a REAL secret that is
|
|
9
|
+
# hardcoded inside a test/fixture file. Production source is unaffected.
|
|
10
|
+
#
|
|
11
|
+
# NOTE: pinned gitleaks version is 8.21.2 (< 8.25.0), which uses the singular
|
|
12
|
+
# `[allowlist]` table with `paths = [...]` regexes. Do NOT switch to the
|
|
13
|
+
# `[[allowlists]]` array form unless the pinned version is bumped to >= 8.25.0.
|
|
14
|
+
# =============================================================================
|
|
15
|
+
|
|
16
|
+
title = "GHAGGA Gitleaks configuration"
|
|
17
|
+
|
|
18
|
+
[extend]
|
|
19
|
+
# Keep all of gitleaks' built-in default rules.
|
|
20
|
+
useDefault = true
|
|
21
|
+
|
|
22
|
+
[allowlist]
|
|
23
|
+
description = "Ignore secrets found in test files and fixtures (conservative)"
|
|
24
|
+
# Go (RE2) regexes matched against the file path. A finding whose path matches
|
|
25
|
+
# ANY of these is suppressed.
|
|
26
|
+
paths = [
|
|
27
|
+
'''.*\.test\.[tj]sx?$''',
|
|
28
|
+
'''.*\.spec\.[tj]sx?$''',
|
|
29
|
+
'''.*_test\.(py|go)$''',
|
|
30
|
+
'''.*test_.*\.py$''',
|
|
31
|
+
'''.*/__tests__/.*''',
|
|
32
|
+
'''.*/tests?/.*''',
|
|
33
|
+
'''.*/fixtures?/.*''',
|
|
34
|
+
'''.*/testdata/.*''',
|
|
35
|
+
]
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ReviewFinding } from '../../types.js';
|
|
10
10
|
import type { RawToolOutput, ToolDefinition } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the bundled gitleaks config (extends defaults + test-file allowlist).
|
|
13
|
+
*
|
|
14
|
+
* Works in BOTH dev (src/tools/plugins/gitleaks.ts -> src/tools/gitleaks-config.toml)
|
|
15
|
+
* and the published build (dist/tools/plugins/gitleaks.js -> dist/tools/gitleaks-config.toml),
|
|
16
|
+
* provided the build copies the .toml into dist/tools/ (see package.json `build` script).
|
|
17
|
+
*
|
|
18
|
+
* Returns undefined if missing so the plugin degrades gracefully to default rules.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveGitleaksConfigPath(): string | undefined;
|
|
11
21
|
/**
|
|
12
22
|
* Parse Gitleaks JSON output into ReviewFinding[].
|
|
13
23
|
* Gitleaks writes results to a report file; we read from stdout or the report.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitleaks.d.ts","sourceRoot":"","sources":["../../../src/tools/plugins/gitleaks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"gitleaks.d.ts","sourceRoot":"","sources":["../../../src/tools/plugins/gitleaks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAoB,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKnF;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,GAAG,SAAS,CAI9D;AAUD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAiBxF;AAED,eAAO,MAAM,cAAc,EAAE,cAuE5B,CAAC"}
|
|
@@ -6,8 +6,25 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Uses ExecutionContext for DI instead of direct child_process.
|
|
8
8
|
*/
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
9
12
|
const GITLEAKS_VERSION = '8.21.2';
|
|
10
13
|
const GITLEAKS_BIN = '/usr/local/bin/gitleaks';
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the bundled gitleaks config (extends defaults + test-file allowlist).
|
|
16
|
+
*
|
|
17
|
+
* Works in BOTH dev (src/tools/plugins/gitleaks.ts -> src/tools/gitleaks-config.toml)
|
|
18
|
+
* and the published build (dist/tools/plugins/gitleaks.js -> dist/tools/gitleaks-config.toml),
|
|
19
|
+
* provided the build copies the .toml into dist/tools/ (see package.json `build` script).
|
|
20
|
+
*
|
|
21
|
+
* Returns undefined if missing so the plugin degrades gracefully to default rules.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveGitleaksConfigPath() {
|
|
24
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
25
|
+
const configPath = join(here, '..', 'gitleaks-config.toml');
|
|
26
|
+
return existsSync(configPath) ? configPath : undefined;
|
|
27
|
+
}
|
|
11
28
|
/**
|
|
12
29
|
* Parse Gitleaks JSON output into ReviewFinding[].
|
|
13
30
|
* Gitleaks writes results to a report file; we read from stdout or the report.
|
|
@@ -60,14 +77,24 @@ export const gitleaksPlugin = {
|
|
|
60
77
|
},
|
|
61
78
|
async run(ctx, repoDir, _files, timeout) {
|
|
62
79
|
const reportPath = '/tmp/gitleaks-result.json';
|
|
63
|
-
|
|
80
|
+
const detectArgs = [
|
|
64
81
|
'detect',
|
|
65
82
|
`--source=${repoDir}`,
|
|
66
83
|
'--report-format=json',
|
|
67
84
|
`--report-path=${reportPath}`,
|
|
68
85
|
'--no-git',
|
|
69
86
|
'--exit-code=0',
|
|
70
|
-
]
|
|
87
|
+
];
|
|
88
|
+
// Apply ghagga's bundled config (default rules + test-file allowlist) when
|
|
89
|
+
// available. Degrade gracefully to gitleaks' built-in defaults if missing.
|
|
90
|
+
const configPath = resolveGitleaksConfigPath();
|
|
91
|
+
if (configPath) {
|
|
92
|
+
detectArgs.push(`--config=${configPath}`);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
ctx.log('warn', 'gitleaks: bundled gitleaks-config.toml not found, using default rules only');
|
|
96
|
+
}
|
|
97
|
+
await ctx.exec('gitleaks', detectArgs, {
|
|
71
98
|
timeoutMs: timeout,
|
|
72
99
|
});
|
|
73
100
|
// Read the report file and return it as stdout
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitleaks.js","sourceRoot":"","sources":["../../../src/tools/plugins/gitleaks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"gitleaks.js","sourceRoot":"","sources":["../../../src/tools/plugins/gitleaks.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,IAAI,CAA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,+CAA+C;QAC/C,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE;YACnC,SAAS,EAAE,MAAM;YACjB,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,mCAAmC;SACzD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,EAAE,mBAAmB;CAC3B,CAAC"}
|
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { FindingSeverity, ReviewFinding } from '../../types.js';
|
|
11
11
|
import type { RawToolOutput, ToolDefinition } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the bundled curated ruleset path relative to this plugin's location.
|
|
14
|
+
*
|
|
15
|
+
* Works in BOTH dev (src/tools/plugins/semgrep.ts -> src/tools/semgrep-rules.yml)
|
|
16
|
+
* and the published build (dist/tools/plugins/semgrep.js -> dist/tools/semgrep-rules.yml),
|
|
17
|
+
* provided the build copies the .yml into dist/tools/ (see package.json `build` script).
|
|
18
|
+
*
|
|
19
|
+
* Returns undefined if the file is not present so the plugin degrades gracefully
|
|
20
|
+
* to `--config auto` only.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveSemgrepRulesPath(): string | undefined;
|
|
12
23
|
/**
|
|
13
24
|
* Map Semgrep severity to GHAGGA FindingSeverity.
|
|
14
25
|
* ERROR -> high, WARNING -> medium, INFO -> info, default -> low
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semgrep.d.ts","sourceRoot":"","sources":["../../../src/tools/plugins/semgrep.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"semgrep.d.ts","sourceRoot":"","sources":["../../../src/tools/plugins/semgrep.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAoB,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAInF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAI5D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,GAAG,eAAe,CAW3E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAuBvF;AAED,eAAO,MAAM,aAAa,EAAE,cAmD3B,CAAC"}
|