@blundergoat/gruff-ts 0.4.0 → 0.6.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/CHANGELOG.md +123 -1
- package/CONTRIBUTING.md +32 -25
- package/README.md +55 -46
- package/SECURITY.md +18 -30
- package/UPGRADING.md +101 -0
- package/bin/gruff-ts +3 -0
- package/docs/README.md +11 -13
- package/docs/agent-hook.md +33 -24
- package/docs/ci-integration.md +38 -24
- package/docs/configuration.md +173 -71
- package/docs/dashboard.md +12 -13
- package/docs/output-formats.md +100 -25
- package/docs/philosophy.md +2 -2
- package/docs/reports-and-ci.md +14 -157
- package/docs/rules.md +140 -106
- package/package.json +10 -8
- package/src/analyser.ts +886 -282
- package/src/baseline-file.ts +867 -0
- package/src/baseline-identity.ts +463 -0
- package/src/baseline-options.ts +139 -34
- package/src/baseline.ts +85 -55
- package/src/blocks.ts +579 -364
- package/src/changed-regions.ts +414 -65
- package/src/check-ignore.ts +28 -13
- package/src/class-rules.ts +461 -302
- package/src/cli-program.ts +956 -166
- package/src/cli.ts +9 -2
- package/src/comment-rules.ts +277 -414
- package/src/comment-scanner.ts +363 -44
- package/src/complexity-metrics.ts +320 -0
- package/src/config-load-error.ts +17 -8
- package/src/config-parse.ts +291 -98
- package/src/config-preservation.ts +81 -26
- package/src/config.ts +778 -210
- package/src/constants.ts +7 -6
- package/src/context-doc-rules.ts +188 -61
- package/src/dashboard.ts +88 -23
- package/src/dead-code-rules.ts +153 -74
- package/src/discovery.ts +521 -148
- package/src/doc-rules.ts +592 -147
- package/src/duplicate-test-group-rules.ts +359 -0
- package/src/findings-helpers.ts +240 -89
- package/src/findings.ts +48 -24
- package/src/fixture-purpose-rules.ts +226 -48
- package/src/github-actions-event-guards.ts +331 -0
- package/src/github-actions-rules.ts +336 -106
- package/src/hook-contract.ts +708 -211
- package/src/init-config.ts +169 -114
- package/src/inline-suppressions.ts +340 -0
- package/src/limit-band.ts +56 -0
- package/src/line-rules.ts +331 -419
- package/src/migrate-config.ts +670 -0
- package/src/naming-pushers.ts +33 -107
- package/src/parsed-script.ts +1206 -0
- package/src/pillar-summary.ts +56 -40
- package/src/profiles.ts +97 -71
- package/src/project-config-rules.ts +335 -146
- package/src/project-rules.ts +237 -115
- package/src/public-exports.ts +284 -0
- package/src/report-html.ts +217 -85
- package/src/report-renderers.ts +864 -195
- package/src/rule-list.ts +166 -46
- package/src/rules.ts +100 -104
- package/src/safety-rules.ts +191 -132
- package/src/scoring.ts +255 -52
- package/src/security-flow-rules.ts +930 -109
- package/src/selectors.ts +169 -0
- package/src/sensitive-data-rules.ts +502 -375
- package/src/sensitive-exclusions.ts +435 -0
- package/src/source-text.ts +380 -148
- package/src/static-analysis-redundant-rules.ts +298 -41
- package/src/test-block-rules.ts +422 -228
- package/src/text-scans.ts +67 -9
- package/src/types.ts +222 -71
- package/tsconfig.json +2 -1
- package/src/process-exec-metadata.ts +0 -153
- package/src/test-fixtures.ts +0 -668
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,127 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.6.0 - 2026-11-29
|
|
4
|
+
|
|
5
|
+
A coordinated family release on Node 22.12+: all five gruff ports share JSON, SARIF, baseline, hook, and scoring contracts, the catalogue drops from 120 to 81 rules across 11 pillars, and 10,000+ file monorepos scan within the default heap. Every machine-readable contract changes; [UPGRADING.md](UPGRADING.md) has the migration and rollback steps.
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- **BREAKING: Node.js 22.12 or newer is required** - The argument parser moves to Commander 15, which needs it; update within the 22 line or move to 24 or 26.
|
|
10
|
+
- **BREAKING: JSON moves to family v3 and `hook` to `gruff.hook.v2`, with no deprecation window** - `analyse` and `report --format=json` emit `gruff.analysis.v3`; `summary --format=json` emits `gruff.summary.v3`, the same envelope without `findings`, so `--top` affects text only.
|
|
11
|
+
- Gate on `schemaVersion`; read `file` (not `filePath`), `score.composite.{score,grade}`, and `paths.details` (not `paths.skipped`); absent `column`, `endLine`, and `symbol` are omitted, not `null`. Field table: [Output Formats](docs/output-formats.md).
|
|
12
|
+
- `hook` adds `run` and `suppressions` and exits `0` (passed), `1` (a requested `--fail-on`, `--fail-on-new`, or `--fail-on-diagnostics` gate tripped; `--fail-on-diagnostics` used to exit `2`), or `2` (fatal error).
|
|
13
|
+
- **BREAKING: baselines move to `gruff.baseline.v3`, and secrets cannot be baselined** - Rows store a line-free SHA-256 identity and an accepted count, so moved code keeps its review and same-named declarations stay distinct.
|
|
14
|
+
- SARIF `partialFingerprints.gruffFingerprint` uses the same identity, so code-scanning alerts close and reopen once.
|
|
15
|
+
- Sensitive-data findings get no baseline row and no `partialFingerprints`; suppress reviewed samples with `sensitiveExclusions:`.
|
|
16
|
+
- `0.5` baselines exit `2`; migrate them with `gruff-ts analyse --migrate-baseline <old> --generate-baseline <new>`.
|
|
17
|
+
- **BREAKING: 40 low-precision rules and 7 allowlist keys are removed (ADR-021)** - Each was right less than half the time in the 0.6.0 precision measurement:
|
|
18
|
+
- Complexity and design: `complexity.cognitive`, `design.deep-relative-import`.
|
|
19
|
+
- Documentation: `docs.magic-threshold-without-rationale`, `docs.stale-comment`, `docs.useless-docblock`.
|
|
20
|
+
- Modernisation: `modernisation.loose-equality`, `modernisation.nullish-coalescing-candidate`, `modernisation.object-spread-candidate`, `modernisation.optional-chaining-candidate`, `modernisation.public-property`.
|
|
21
|
+
- Naming: `naming.acronym-case`, `naming.boolean-prefix`, `naming.generic-function`, `naming.generic-parameter`, `naming.hungarian-notation`, `naming.inconsistent-casing`, `naming.negative-boolean`.
|
|
22
|
+
- Security and sensitive data: `security.floating-promise`, `security.github-actions-broad-permissions`, `security.insecure-random`, `security.process-exec`, `security.proto-access`, `security.risky-lifecycle-script`, `sensitive-data.hardcoded-env-value`, `sensitive-data.high-entropy-string`.
|
|
23
|
+
- Test quality: `test-quality.conditional-logic`, `test-quality.exception-type-only`, `test-quality.magic-number-assertion`, `test-quality.mock-only-test`, `test-quality.no-assertions`, `test-quality.no-throw-only-test`, `test-quality.only-skip`, `test-quality.sleep-in-test`, `test-quality.snapshot-only-test`.
|
|
24
|
+
- Maintainability (`waste.*`): `waste.commented-out-code`, `waste.console-log`, `waste.empty-function`, `waste.redundant-boolean-cast`, `waste.redundant-variable`, `waste.unused-parameter`.
|
|
25
|
+
- Allowlist keys: `acceptedBooleanNames`, `acceptedCasingPairs`, `bannedGenericNames`, `booleanPrefixes`, `hungarianPrefixes`, `knownAcronyms`, `negativeBooleanAllowed`.
|
|
26
|
+
- A config, `sensitiveExclusions:` entry, `--include-rule`/`--exclude-rule`, or `--show-rule`/`--hide-rule` naming a retired ID exits `2`; `gruff-ts migrate-config --config <old> --output <new>` prunes them and keeps surviving overrides.
|
|
27
|
+
- Baseline rows for retired rules load and report as resolved; `docs.missing-why-for-complex-code` keeps a fixed cognitive-complexity trigger of 15; ESLint `no-console`, `eqeqeq`, and `no-unused-vars` comments no longer suppress anything.
|
|
28
|
+
- **BREAKING: 12 rules are off by default (ADR-021)** - Turn one back on with `rules.<id>.enabled: true`:
|
|
29
|
+
- `complexity.cyclomatic`, `docs.missing-invariant-doc`, `docs.missing-side-effect-doc`, `security.inner-html`, `security.open-redirect-candidate`, `security.path-traversal-candidate`, `security.unsafe-deserialization`, `sensitive-data.aws-access-key`, `sensitive-data.database-url-password`, `sensitive-data.jwt-token`, `waste.swallowed-catch`, `waste.useless-return`.
|
|
30
|
+
- Configs from earlier `init` runs already set `enabled: true`; `gruff.strict` no longer enables or tightens `complexity.cyclomatic`; narrowing `--include-rule` to disabled rules exits `2`.
|
|
31
|
+
- **BREAKING: `sensitive-data.*` rules default to `warning`** - All 8 move down from `error`, so `--fail-on=error` no longer fails on secrets; use `--fail-on=warning` or set `severity: error` per rule.
|
|
32
|
+
- **BREAKING: exit gates move from `minimumSeverity:` to `failOn:`** - `minimumSeverity:` is now one display floor (`advisory`, `warning`, or `error`) that changes neither scores nor exit codes; a `0.5` per-command map under it exits `2` until `gruff-ts migrate-config` converts it.
|
|
33
|
+
- **BREAKING: `allowlists.secretPreviews` is removed and unknown rule keys exit `2`** - Secret reports always use fixed category markers, and a `rules.<id>` key other than `enabled`, `severity`, `threshold`, or `options` fails config loading.
|
|
34
|
+
- **BREAKING: scores are normalised and confidence-weighted** - Pillar scores scale by evaluated script count, so duplicating a project keeps its grade.
|
|
35
|
+
- Each pillar scores `floor + (100 - floor) / (1 + density / densityScale)` (`floor = 50`, `densityScale = 0.1`); error weight rises from `8` to `12`, advisory drops from `1.5` to `1`, and findings weigh by confidence (`0.5` low, `0.75` medium, `1.0` high).
|
|
36
|
+
- Seven rules change confidence: `docs.missing-why-for-complex-code`, `docs.suppression-without-rationale`, and `naming.identifier-quality` (medium to low); `docs.todo-without-tracking`, `size.parameter-count`, and `waste.any-type` (high to medium); `security.sql-concatenation` (high to low). Findings now always take catalogue confidence, so `docs.missing-exported-function-doc` and `docs.missing-internal-function-doc` emit at medium and `size.function-length` at high.
|
|
37
|
+
- `score.pillars[]` lists every rule-backed pillar with `applicable` and `grade`; with zero scripts evaluated, `score.composite.{score,grade}` is `null` (`Composite: n/a (nothing evaluated)`).
|
|
38
|
+
- **BREAKING: JSDoc tag rules cover every non-test callable** - `docs.missing-param-tag` and `docs.missing-return-tag` turn on `everyCallable`; set `everyCallable: false` on both to restore export-only scope.
|
|
39
|
+
- Test files are skipped and fixture directories are not; only `/** ... */` blocks with described tags count, not `//` or `/* */`; `docs.missing-return-tag` wants a described `@returns` even for `void`, `Promise<void>`, `asserts`, `never`, and `undefined`, but not for constructors or setters.
|
|
40
|
+
- Undocumented public methods of exported classes report as `docs.missing-exported-function-doc` (`warning`); private functions stay `docs.missing-internal-function-doc` (`advisory`).
|
|
41
|
+
- **BREAKING: `summary` defaults to `--fail-on none`** - It exits `0` unless `--fail-on` or `failOn.summary` is set.
|
|
42
|
+
- **BREAKING: `report --no-baseline` is removed** - `report` never applied baselines, so the flag now exits `2` as an unknown option.
|
|
43
|
+
- **BREAKING: bad `--changed-ranges` and `--baseline` inputs exit `2`** - An empty or malformed `--changed-ranges` gives one fatal `changed-region` diagnostic and no findings; a missing, malformed, or `0.5` `--baseline` gives one fatal `baseline-error` diagnostic and still shows findings.
|
|
44
|
+
- **BREAKING: `list-rules --format=json` uses the family rule record** - Rules carry `id` (was `ruleId`), `defaultSeverity` (was `severity`), and a `thresholds` map (was scalar `threshold`), and `list-rules <id> --format=json` nests one under `rule`; findings keep `ruleId`.
|
|
45
|
+
- **BREAKING: default discovery follows the family fallback policy** - `vendor`, `vendors`, `third_party`, `third-party`, `bower_components`, `dist` (any depth and case), and `*.min.*` are skipped even under a `.gitignore`, with reasons in `paths.details`; `--include-ignored` or naming the file still scans them.
|
|
46
|
+
- Other non-VCS fallbacks defer to any governing `.gitignore` and match at any depth, and `cache`, `generated`, `target`, and `tmp` are no longer skipped by default, so add them to `paths.ignore` when Git does not ignore them.
|
|
47
|
+
- Committed control folders stay scannable, explicit file arguments bypass Git and fallback exclusions, and VCS internals stay blocked even under `--include-ignored`.
|
|
48
|
+
- **BREAKING: custom tracking tokens move to `allowlists.trackingTokens`** - References such as ADR IDs or task paths no longer count automatically; list regexes there for `docs.todo-without-tracking`, `modernisation.ts-comment-without-rationale`, and `waste.swallowed-catch`.
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- **`gruff-ts migrate-config`** - Converts a `0.5` config into a separate file: renames per-command `minimumSeverity:` to `failOn:`, prunes retired rules, allowlist keys, `allowlists.secretPreviews`, and retired `sensitiveExclusions:`, logs each change, and checks the result loads before writing it.
|
|
53
|
+
- **`analyse --migrate-baseline <old> --generate-baseline <new>`** - Carries reviews from a `0.5` baseline into `gruff.baseline.v3` and leaves the original alone; it refuses to write over its input or read an ambiguous multi-container file, and overwriting a non-v3 `gruff-baseline.json` needs `--force`.
|
|
54
|
+
- **`sensitiveExclusions:` config section** - Suppresses reviewed sensitive-data findings by exact `rule`, project-relative `path`, optional `symbol`, and required `reason`, counted in `suppressions` and text output without printing the secret; value- or message-matching keys exit `2`.
|
|
55
|
+
- **Rule and pillar selectors** - `--include-rule`, `--exclude-rule`, `--include-pillar`, and `--exclude-pillar` change which rules run and score (not allowed with `--history-file`); `--show-rule`, `--hide-rule`, `--show-pillar`, `--hide-pillar`, and `--min-severity` filter output without changing scores or exit codes.
|
|
56
|
+
- **Confidence, new-debt, diff-base, and deep-scan flags** - `--min-confidence <low|medium|high>` and `--fail-on-new` gate `analyse` and `hook`; `--diff-base <ref>` (or `-` for stdin) names the Git base and overrides `--diff`; `--deep-scan-budget <lines:bytes|off>` changes or turns off deep-scan bounds on `analyse`, `summary`, `report`, `hook`, and `dashboard`.
|
|
57
|
+
- **`test-quality.duplicate-test-body`, on by default** - Flags 3+ tests of 3+ statements in one block with matching normalized bodies and suggests a table-driven test; disable with `rules.test-quality.duplicate-test-body.enabled: false`.
|
|
58
|
+
- **Inline tool suppressions and `eval` deduplication** - ESLint (`no-eval`, `no-new-func`), Biome (`lint/security/noGlobalEval`, `lint/correctness/noUnusedImports`), and zizmor (`ignore[unpinned-uses]`, `ignore[dangerous-triggers]`) comments on or alone directly above the reported line suppress the matching finding, and an `eval` flagged by both `security.eval-call` and `security.unsafe-deserialization` reports once under `security.eval-call`; each removal is counted in `suppressions` (`inline` or `duplicate`) and kept in SARIF.
|
|
59
|
+
- **False-positive guidance** - All 50 medium- and low-confidence rules publish `falsePositiveShapes` in `list-rules <id>` and `list-rules --format=json`; the 31 high-confidence rules do not.
|
|
60
|
+
- **Two-band size and complexity findings** - `size.*` and `complexity.*` findings under 1.5x their threshold report as `advisory` (`metadata.limitBand: "lower"`) and advise not growing the unit; at 1.5x or more they keep their configured severity (`"upper"`) and advise splitting or simplifying.
|
|
61
|
+
- **AWS `ASIA` session keys** - `sensitive-data.aws-access-key` flags temporary `ASIA` keys as well as long-term `AKIA` keys.
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- **Large monorepos fit Node's 4 GB heap** - Full scans of `openclaw` (17,296 files) and `vscode` (12,867 files) exit `0` instead of running out of memory.
|
|
66
|
+
- **Security and sensitive-data rules skip test, fixture, and example paths** - Paths under `test`, `tests`, `__tests__`, `spec`, `testdata`, `fixtures`, or `examples` (any case) and test filenames (`*.test.*`, `*.spec.*`, `*_test.go`, `test_*.py`, `*_test.py`, `*Test.php`) are skipped with counted `source: "built-in"` audit rows.
|
|
67
|
+
- **Trade-off:** a real secret or unsafe call committed under those paths is no longer reported.
|
|
68
|
+
- Twenty vendor-documented sample values (AWS example keys, the jwt.io token, Google's reCAPTCHA test site key, 14 test card numbers) and stock local database logins (`postgres:postgres`, `root:root`, `scott:tiger` on loopback or single-label hosts) stay quiet.
|
|
69
|
+
- **Stricter, consolidated documentation checks** - `docs.missing-param-tag` and `docs.stale-param-tag` report every missing or stale parameter in one finding; `docs.missing-exported-function-doc` and `docs.missing-internal-function-doc` list uncovered parameters, return values, or throws; `docs.missing-error-behavior-doc` needs an explicit `@throws`; file overviews and `// ----` dividers no longer count as function docs; and `docs.suppression-without-rationale` and `modernisation.ts-comment-without-rationale` accept a rationale in `//` lines directly above the directive.
|
|
70
|
+
- **Line counts and callable measurements** - `size.file-length` measures JS/TS only; code-line metrics (`size.function-length`, `size.file-length`, `design.large-module-concentration`, context-doc length) skip blank, comment-only, and decorator-only lines; `size.function-length`, `size.parameter-count`, and `complexity.cyclomatic` also measure object-literal `key: function` methods, member-assigned functions, `var` function expressions, and IIFEs; and `complexity.cyclomatic` counts a `switch` as one decision.
|
|
71
|
+
- **Clearer reports and diagnostics** - `analyse` text prints baseline and suppression totals and `summary` prints suppression totals; JSON adds `score.evaluatedFiles`, `score.scoredPillars`, per-file `penalty`, and zeroed baseline movement counts on generate and migrate runs; baseline collisions become non-fatal `baseline-collision` diagnostics instead of hiding findings; 11 line-pattern rules carry remediation text in JSON; and metric remediations stop advising higher thresholds.
|
|
72
|
+
- **Hotspot output carries diagnostics** - `--format=hotspot` adds the same `diagnostics` array as `--format=json`, so a `bounded-deep-scan` notice shows in every format.
|
|
73
|
+
- **Published tarball drops `src/test-fixtures.ts`** - Test fixtures and their synthetic credential strings no longer ship.
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
- **TypeScript false positives** - `waste.unused-import` handles inline `type` modifiers and `$` names (`$`, `$state`, `events$`) (14 to 2 findings on goat-flow, 126 to 78 on opencode); `docs.stale-param-tag` accepts destructured and dotted-key `@param` tags on all non-test `everyCallable` targets; `naming.short-variable` allows `t` typed as `TestContext` or in test files; `docs.missing-why-for-complex-code` skips `it`/`test` callbacks and accepts constraint words (`must`, `never`, `only`, `instead`) outside the function name; and `design.package-bin-missing` reports unbuilt `dist/`, `build/`, or `lib/` bins as `advisory` when `package.json` has a `build` script.
|
|
78
|
+
- **Security false positives** - `security.eval-call` and `security.inner-html` skip fixed strings and static templates; `security.javascript-url` skips equality comparisons; `security.weak-crypto` skips `createHmac("sha1", ...)`; `security.unsafe-deserialization` no longer treats Node `fs` reads as tainted; `security.disabled-tls-verification` skips test assertion expectations; `security.github-actions-secrets-in-pr` checks `on:` for `pull_request_target`, skips `secrets.GITHUB_TOKEN`, and honours exact `github.event_name` guards; `security.url-dependency` anchors on the dependency entry, not an `overrides` key; and callback-local `req`/`request`/`ctx` parameters no longer taint enclosing values.
|
|
79
|
+
- **Other false positives** - `modernisation.readonly-property-candidate` reports only `private` fields assigned solely in their own constructor; `sensitive-data.aws-access-key` treats only 16-`X` bodies as masked; `sensitive-data.database-url-password` skips TypeScript template literal types; `docs.missing-side-effect-doc` ignores `RegExp.exec`; `waste.unreachable-code` recognises braced `case`/`default` labels; `waste.swallowed-catch` accepts explained empty catches; and `waste.useless-return` skips a lone `return;` in `catch`.
|
|
80
|
+
- **Test-quality scanning** - `void it(...)` and `void test(...)` callbacks count as tests, and `test-quality.loop-in-test` accepts wrapped per-case messages and loop-derived expected values.
|
|
81
|
+
- **Launch-directory paths and failure envelopes** - Relative targets, `--config`, `--profile`, `--baseline`, `--generate-baseline`, `--migrate-baseline`, and `--history-file` resolve from the launch directory, not the project root; config and baseline errors print paths as typed, not host-absolute; only real config-load errors (not flag conflicts) emit a `config-error` envelope; and `summary --format=json` emits `gruff.summary.v3` on config and target refusals.
|
|
82
|
+
- **Diff refs, nested templates, hook duplicates, and the installed launcher** - `--diff-base` and `--since` pass explicit Git refs through without matching mode keywords such as `staged`; nested `${...}` template literals no longer desynchronise masking; `hook --diff` keeps newly added duplicate findings visible; and the installed `@blundergoat/gruff-ts` binary finds hoisted `tsx` from any working directory.
|
|
83
|
+
- **Staged diffs, unreadable hook inputs, and VCS directories** - `--diff staged` on `analyse` and `hook` keeps findings on staged lines that unstaged edits above have moved and leaves out lines that exist only in the working tree, newly staged files included; `hook` exits `2` with a fatal `read-error` when it cannot read a named input, instead of exiting `0` unscanned; and a target inside `.git`, `.hg`, or `.svn` stays unscanned when named from outside the repository.
|
|
84
|
+
|
|
85
|
+
## v0.5.0 - 2026-08-16
|
|
86
|
+
|
|
87
|
+
120 rules across 11 pillars on Node 22+. Every script rule now reads one shared syntax-only AST parse instead of walking lines, scoring changes shape, config and CLI validation fail instead of coercing, and the release gains gates that fail the build when a documented count or the scan surface drifts from the source.
|
|
88
|
+
|
|
89
|
+
**Analysis.** Complexity, naming, docblock, and redirect rules read the shared parse, so generic, multi-line, and parenless-arrow declarations are analysed for the first time and complexity findings carry a per-kind `breakdown`. Findings narrow to real evidence: name-only `redirect` helpers, lockfile integrity digests, and bodyless overload signatures stop reporting, while tainted input reaching a response sink and a credential in a `resolved` URL still do. A false-positive sweep took the analyser's own scan to zero findings, which CI now enforces.
|
|
90
|
+
**Scoring.** The composite averages all 11 rule-backed pillars and counts a clean pillar as 100 (ADR-019), so fixing a pillar's last finding cannot lower the score. It stays volume-sensitive and is not yet a cross-project grade: vulnerable nodejs-goof scores 77.9 against clean zod at 18.8.
|
|
91
|
+
**Guardrails and release.** The Claude, Codex, and Copilot agent surfaces move to goat-flow 1.15.1, and three deny-hook bypasses are fixed locally ahead of the upstream template. Packaging is gated by a tarball smoke test that installs the pack fresh and runs the binary, with read-only CI across Node 22, 24, and 26.
|
|
92
|
+
**Needs action before upgrading.** Outside-root scans emit absolute paths, so regenerate any baseline built from a different working directory. `cb` and `fn` now trigger `naming.short-variable` unless listed in `allowlists.acceptedAbbreviations`. `size.file-length` is an error at 1000 substantive lines, which moves `--fail-on` exit codes.
|
|
93
|
+
|
|
94
|
+
- **BREAKING: External finding paths** - outside-root scans emit absolute paths; regenerate baselines made from a different working directory.
|
|
95
|
+
- **BREAKING: Family abbreviations** - `cb`/`fn` now trigger `naming.short-variable`; add them to `allowlists.acceptedAbbreviations` to retain them.
|
|
96
|
+
- **file-length raised to error at 1000 (family ratification)** - only the threshold and severity moved; `--fail-on` consumers see exit-code changes.
|
|
97
|
+
- **Shared AST discovery (one parse per script)** - generics, multi-line, and parenless arrows analysed; anchors and fingerprints preserved.
|
|
98
|
+
- **Complexity follows control flow** - syntax nodes drive cyclomatic/cognitive; findings gain a `breakdown`; thresholds and identities unchanged.
|
|
99
|
+
- **Docblock rules require the shared parse** - AST signatures only, so paren types cannot fake stale @param tags; bounded files skip the pack.
|
|
100
|
+
- **Composite counts clean pillars as 100** - the mean spans all 11 pillars; fixing a pillar's last finding cannot lower it (ADR-019).
|
|
101
|
+
- **Known scoring limitation** - composite scores remain volume-sensitive: vulnerable nodejs-goof scores 77.9 (C), NodeGoat 52.2 and clean zod 18.8.
|
|
102
|
+
- **Casing consistency follows owners** - variants compare within one module/function/interface owner; DTO vs UI fields no longer conflict.
|
|
103
|
+
- **Re-opened namespaces are one contract** - the merge scope keys on the namespace path, so casing drift between `namespace Api` blocks now reports.
|
|
104
|
+
- **Open-redirect needs a real sink** - name-only `redirect` helpers stay quiet; tainted input to response/location sinks still reports.
|
|
105
|
+
- **React Router redirects are open-redirect sinks** - `react-router` and `react-router-dom` join next/navigation and remix; local helpers stay quiet.
|
|
106
|
+
- **A method named after a redirect import cannot hide it** - only declarations and named function expressions shadow by name; a method name is a key.
|
|
107
|
+
- **process-exec severity follows evidence** - warning only for shell-enabled dynamic commands; fixed vectors advisory; ids churn once (ADR-018).
|
|
108
|
+
- **Lockfiles drop only the entropy detector** - integrity digests stop reporting (NodeGoat 1,292 to 0); a credential in `resolved` still errors.
|
|
109
|
+
- **Short secret previews masked** - under 24 chars shows mask+length; an allowlist cannot hide a same-length secret; hook ids churn once (ADR-017).
|
|
110
|
+
- **Quoted env secrets keep embedded hashes** - quoted values read whole so `#` cannot truncate a credential; unquoted still stop at `#`.
|
|
111
|
+
- **Same-line secrets stay distinct** - column discriminates same-line findings and ships in the hook payload (ADR-017); fingerprints unchanged.
|
|
112
|
+
- **Markdown reports escape repo text** - fenced labels/paths and escaped messages block injection into PR comments. (`src/report-renderers.ts`)
|
|
113
|
+
- **Actions write-permission scopes match GitHub's 2026-07-12 table** - `discussions` and `pages` count as write; `id-token` mints tokens, not writes.
|
|
114
|
+
- **Config validation fails loudly** - unknown rules, non-boolean enabled, bad option keys exit 2 naming accepted forms; compat tightening.
|
|
115
|
+
- **Invalid CLI values fail fast** - format/fail-on/changed-scope validated at parse as usage errors; compat tightening. (`src/cli-program.ts`)
|
|
116
|
+
- **Severity overrides reach every scanner** - one central pass applies rules.<id>.severity everywhere; fingerprints stay severity-free.
|
|
117
|
+
- **Filtered scans cannot record history** - `--history-file` with diff/since/ranges exits 2 before any write; full scans still append.
|
|
118
|
+
- **Diff scoping works from nested directories** - relative-path git diffs; nested runs cannot match siblings; root runs byte-identical.
|
|
119
|
+
- **Parser errors collapse per file** - reports retain the first message plus raw count; angular drops 1,854 diagnostics to 476 affected files.
|
|
120
|
+
- **Non-text scripts skip parsing** - invalid UTF-8 or NUL-bearing files produce a non-fatal `non-text-file` note instead of a parse error.
|
|
121
|
+
- **Guardrail hooks deliberately diverge from the goat-flow template** - `install`/`hooks sync` reverts them; re-apply after any upgrade.
|
|
122
|
+
- **Naming and size false positives cut** - aliased class exports, parameter defaults, short locals, acronym pairs, and bodyless signatures go quiet.
|
|
123
|
+
- **Docs and test false positives cut** - decorator comments, stacked fixture-purpose headers, quoted task markers, and labeled data loops stay quiet.
|
|
124
|
+
|
|
3
125
|
## v0.4.0 - 2026-06-11
|
|
4
126
|
|
|
5
127
|
- **Circular imports group by SCC** - `design.circular-import` reports one finding per strongly connected component (member list in `metadata.files`); circular-import fingerprints and hook identities intentionally churn (ADR-015). OpenUI dropped from 108 findings to 3.
|
|
@@ -15,7 +137,7 @@
|
|
|
15
137
|
|
|
16
138
|
## v0.3.2 - 2026-06-09
|
|
17
139
|
|
|
18
|
-
- **Agent-hook contract v1** - adds `gruff-ts hook` and `gruff-ts hook --capabilities --format=json`, advertising `gruff.hook.v1` with `flagOrder:"any"`. Hook JSON uses the cross-
|
|
140
|
+
- **Agent-hook contract v1** - adds `gruff-ts hook` and `gruff-ts hook --capabilities --format=json`, advertising `gruff.hook.v1` with `flagOrder:"any"`. Hook JSON uses the cross-analyser contract fields (`file`, `scope`, `suppressed.count`, `ignored.paths`, `config.error`) with non-null remediation, stable hook identities, and machine-readable threshold metadata. Hook mode exits `0` when analysis runs, omits file/project-scope findings under changed-region attribution, and uses stable identity for baseline/diff new-only filtering (`--diff unstaged` compares against the index, `suppressed.count` never double-counts a re-emitted finding, and distinct project-scope findings such as separate import cycles anchored to one file keep distinct identities so baselining one never suppresses another). Operational failures (missing/malformed baseline, `--diff`/`--since` outside a git repo) report in-band as `config.error` with exit `2` rather than crashing. The conformance tests cover capabilities, scopes/enums, remediation, threshold metadata, stable identity across line/value changes (including multiple same-rule findings in one file and distinct import cycles sharing an anchor file), baseline and diff new-only, operational-failure JSON, flag ordering, advisory exit, ignored paths, and config-error JSON. Existing `analyse` / `summary` / `report` schema versions and exit semantics are unchanged. (`src/hook-contract.ts`, `src/cli-program.ts`, `src/hook-contract.test.ts`)
|
|
19
141
|
- **Changed-region symbol scope drops inherited file-wide findings** - `--changed-scope symbol` now suppresses file-wide and file-aggregate findings when the changed range does not touch their anchor/span, so inherited debt such as `size.file-length` is counted in `suppressedCount` instead of reported on unrelated edits. Use `--changed-scope file` for CI workflows that intentionally want every finding from a touched file, including deletion-only edits. Full scans still report every file-wide finding. No severity, threshold, rule-id, or pillar change. (`src/changed-regions.ts`, `src/changed-region-scope.test.ts`, `src/changed-region-contract.test.ts`)
|
|
20
142
|
- **Threshold findings expose reviewable measurements** - `size.file-length`, `size.function-length`, `size.parameter-count`, `complexity.cyclomatic`, `complexity.cognitive`, `sensitive-data.high-entropy-string`, and `sensitive-data.hardcoded-env-value` now carry additive `measured`/`threshold` measurement metadata, and block-anchored findings carry `endLine` spans so hook output can attribute symbol-scope findings without message parsing. `size.file-length` also gets finding-level remediation from the descriptor text. Existing fingerprints stay stable. (`src/analyser.ts`, `src/blocks.ts`, `src/findings.ts`, `src/sensitive-data-rules.ts`)
|
|
21
143
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -18,49 +18,51 @@ npm test
|
|
|
18
18
|
npm run start-dev
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
CI runs the
|
|
22
|
-
`./bin/gruff-ts analyse . --fail-on=advisory`.
|
|
21
|
+
CI runs `npm run check` followed by `./bin/gruff-ts analyse . --fail-on=advisory`. You can run the full local gate (including docs-drift checks and shellcheck) with `bash scripts/preflight-checks.sh`.
|
|
23
22
|
|
|
24
|
-
## Project
|
|
23
|
+
## Project Layout
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
Runtime code lives under `src/`:
|
|
27
26
|
|
|
28
27
|
- `src/cli.ts` - thin bootstrap and public re-export shell.
|
|
29
|
-
- `src/cli-program.ts` - Commander
|
|
28
|
+
- `src/cli-program.ts` - Commander wiring and option normalization.
|
|
30
29
|
- `src/analyser.ts` - scan orchestration and per-file/project rule fanout.
|
|
31
|
-
- `src/discovery.ts` -
|
|
30
|
+
- `src/discovery.ts` - file discovery, `.gitignore`, and ignore classification.
|
|
31
|
+
- `src/parsed-script.ts` - shared syntax-only TypeScript AST helpers.
|
|
32
32
|
- `src/rules.ts` - canonical rule descriptor catalogue.
|
|
33
33
|
- `src/blocks.ts`, `src/line-rules.ts`, `src/class-rules.ts`,
|
|
34
34
|
`src/dead-code-rules.ts`, `src/doc-rules.ts`, `src/comment-rules.ts`,
|
|
35
35
|
`src/context-doc-rules.ts`, `src/fixture-purpose-rules.ts`,
|
|
36
|
-
`src/test-block-rules.ts`, `src/
|
|
37
|
-
`src/
|
|
38
|
-
packs.
|
|
39
|
-
- `src/sensitive-data-rules.ts` - sensitive-data
|
|
40
|
-
detectors.
|
|
41
|
-
- `src/project-config-rules.ts` - package
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
`src/
|
|
45
|
-
`src/
|
|
36
|
+
`src/test-block-rules.ts`, `src/duplicate-test-group-rules.ts`,
|
|
37
|
+
`src/security-flow-rules.ts`, `src/github-actions-rules.ts`, and
|
|
38
|
+
`src/safety-rules.ts` - focused rule packs.
|
|
39
|
+
- `src/sensitive-data-rules.ts` and `src/sensitive-exclusions.ts` - sensitive-data
|
|
40
|
+
detectors, exclusions, and built-in test-path skips.
|
|
41
|
+
- `src/project-config-rules.ts` and `src/project-rules.ts` - package, tsconfig,
|
|
42
|
+
and cross-file architecture rules.
|
|
43
|
+
- `src/baseline.ts`, `src/baseline-identity.ts`, `src/config.ts`,
|
|
44
|
+
`src/migrate-config.ts`, `src/profiles.ts`, `src/inline-suppressions.ts`,
|
|
45
|
+
`src/dashboard.ts`, `src/findings.ts`, `src/rule-list.ts`, `src/scoring.ts`,
|
|
46
|
+
`src/source-text.ts`, `src/text-scans.ts`, `src/report-renderers.ts`,
|
|
47
|
+
`src/constants.ts`, `src/types.ts` - shared helpers, contracts, and renderers.
|
|
46
48
|
- `src/*.test.ts` - Node test runner coverage for scanner behavior, rule
|
|
47
49
|
packs, fixtures, reports, and CLI surfaces.
|
|
48
50
|
|
|
49
51
|
Keep changes small and local. Do not add runtime dependencies beyond
|
|
50
|
-
`commander`, `tsx`, and `typescript` unless
|
|
52
|
+
`commander`, `tsx`, and `typescript` unless explicitly approved first.
|
|
51
53
|
|
|
52
|
-
##
|
|
54
|
+
## Making Rule Changes
|
|
53
55
|
|
|
54
56
|
When adding or changing a rule:
|
|
55
57
|
|
|
56
|
-
- Add or update
|
|
57
|
-
-
|
|
58
|
-
- Preserve the public `Finding` shape
|
|
59
|
-
|
|
58
|
+
- Add or update its `RuleDescriptor` in `src/rules.ts`.
|
|
59
|
+
- Add focused noisy and clean fixtures.
|
|
60
|
+
- Preserve the public `Finding` shape and fingerprint inputs unless a breaking
|
|
61
|
+
schema bump is planned.
|
|
60
62
|
- Add config threshold coverage when the rule has thresholds.
|
|
61
|
-
- Run `npm run check`.
|
|
63
|
+
- Run `npm run check` and `./bin/gruff-ts analyse . --fail-on=advisory`.
|
|
62
64
|
|
|
63
|
-
Every finding
|
|
65
|
+
Every finding needs a stable baseline identity. Baseline matching and SARIF alert grouping both read that identity rather than `fingerprint`.
|
|
64
66
|
|
|
65
67
|
## Documentation Changes
|
|
66
68
|
|
|
@@ -69,8 +71,13 @@ Update docs when behavior changes:
|
|
|
69
71
|
- `README.md` for user-facing workflow changes.
|
|
70
72
|
- `CHANGELOG.md` for release-visible changes.
|
|
71
73
|
- `docs/configuration.md` for config shape or threshold changes.
|
|
72
|
-
- `docs/
|
|
74
|
+
- `docs/output-formats.md` for output-format, schema, or exit-code changes.
|
|
75
|
+
- `docs/ci-integration.md` for CI and baseline changes.
|
|
76
|
+
- `docs/dashboard.md` for dashboard changes.
|
|
77
|
+
- `UPGRADING.md` for a change that breaks an existing project.
|
|
73
78
|
- `docs/releasing.md` for release process changes.
|
|
79
|
+
- `docs/reports-and-ci.md` is a retained compatibility page: point it at the owned pages above
|
|
80
|
+
rather than restating them there.
|
|
74
81
|
|
|
75
82
|
## Pull Request Checklist
|
|
76
83
|
|
package/README.md
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
# gruff-ts
|
|
2
2
|
|
|
3
|
-
`gruff-ts` governs AI-generated code. Wired in as a coding-agent hook, it
|
|
3
|
+
`gruff-ts` governs AI-generated code. Wired in as a coding-agent hook, it pushes an agent to produce changes a human who did not write them can sign off on: readable enough to verify by eye, guarded against unsafe patterns reviewers easily miss, and backed by tests that check real behavior instead of padding coverage.
|
|
4
|
+
|
|
5
|
+
Under the hood it is a lightweight static analyser for TypeScript and JavaScript. It scans source, tests, package metadata, and config files, then outputs reports for terminals, CI annotations, SARIF code scanning, static HTML, and a local dashboard. Because it relies on static heuristics, run it alongside `tsc`, ESLint, tests, dependency scanners, and code review rather than instead of them.
|
|
4
6
|
|
|
5
7
|
## Why gruff-ts Exists
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
When AI writes the code, the reviewer is never the author. The agent holds full context while editing; the human asked to approve the diff does not. Conventional linters assume an author who already understands the code and just wants it tidy. `gruff-ts` optimises for the person reviewing code they did not write.
|
|
8
10
|
|
|
9
|
-
That
|
|
11
|
+
That breaks into three goals:
|
|
10
12
|
|
|
11
|
-
- **Verifiable.** A reviewer
|
|
12
|
-
- **Secure where the eye slips.** Human
|
|
13
|
-
- **Honestly tested.**
|
|
13
|
+
- **Verifiable.** A reviewer should be able to confirm what a change does by reading it, without reconstructing what the agent had in mind. Complexity, size, naming, and documentation rules push code toward plain intent.
|
|
14
|
+
- **Secure where the eye slips.** Human reviewers routinely skim past disabled TLS verification, `eval` and `new Function`, injection-shaped string building, and committed secrets. Security and sensitive-data rules catch those mechanically.
|
|
15
|
+
- **Honestly tested.** Tests should buy confidence, not line count. The test-quality pillar flags tautological assertions, shape-only checks that duplicate TypeScript, unused mocks, unlabelled assertion loops, global state mutation, and copy-pasted test bodies so an agent cannot clear a "write tests" step with padding.
|
|
14
16
|
|
|
15
|
-
Documentation rules
|
|
17
|
+
Documentation rules are strict on purpose, even on a private one-liner. Coding agents often write code that looks plausible while misunderstanding the requirement. Requiring a doc comment stating intent, parameters, return behavior, and error conditions gives the reviewer an independent claim to check against the implementation - a mismatch between the comment and the code is an immediate warning sign.
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
Run as a hook on agent edits, `gruff-ts` acts as a forcing function rather than passive advice: findings stay in the agent's way until it fixes them, so what reaches a human is already shaped for review. See [Philosophy](docs/philosophy.md) for more background.
|
|
18
20
|
|
|
19
21
|
## Status At A Glance
|
|
20
22
|
|
|
21
23
|
| Field | Value |
|
|
22
24
|
| --- | --- |
|
|
23
|
-
| Release line |
|
|
24
|
-
| Runtime | Node.js `22
|
|
25
|
+
| Release line | `0.6.0` |
|
|
26
|
+
| Runtime | Node.js `22.12+`; release CI covers 22, 24, and 26 |
|
|
27
|
+
| Runtime dependencies | `commander`, `tsx`, and `typescript` |
|
|
25
28
|
| Package | `@blundergoat/gruff-ts` |
|
|
26
29
|
| Binary | `gruff-ts` |
|
|
27
|
-
| Rule catalogue |
|
|
30
|
+
| Rule catalogue | 81 rules across 11 pillars |
|
|
28
31
|
| Primary config | `.gruff-ts.yaml`; `.gruff.json`, `.gruff.yaml`, and `.gruff.yml` are fallback files |
|
|
29
|
-
| Analysis schema | `gruff.analysis.
|
|
30
|
-
|
|
|
32
|
+
| Analysis schema | `gruff.analysis.v3` |
|
|
33
|
+
| Summary schema | `gruff.summary.v3` |
|
|
34
|
+
| Baseline schema | `gruff.baseline.v3` |
|
|
35
|
+
| Hotspot schema | `gruff.hotspot.v1` |
|
|
36
|
+
| Agent-hook schema | `gruff.hook.v2` |
|
|
37
|
+
| Config schema | `gruff-ts.config.v0.1` |
|
|
31
38
|
| Severity gate | `--fail-on` with `none`, `advisory`, `warning`, `error` |
|
|
32
39
|
| Dashboard | `127.0.0.1:8767` by default |
|
|
33
40
|
|
|
@@ -35,7 +42,7 @@ Scanned file types include TypeScript, JavaScript, JSON, YAML, TOML, INI, XML, a
|
|
|
35
42
|
|
|
36
43
|
## Requirements
|
|
37
44
|
|
|
38
|
-
- Node.js `22+`, matching [`package.json`](package.json).
|
|
45
|
+
- Node.js `22.12+`, matching [`package.json`](package.json).
|
|
39
46
|
- npm for source-checkout development.
|
|
40
47
|
- Git only for diff modes.
|
|
41
48
|
|
|
@@ -91,12 +98,14 @@ Open `http://127.0.0.1:8767/` for the dashboard.
|
|
|
91
98
|
| `summary [paths...]` | Print compact score, pillar, rule, and file summaries. |
|
|
92
99
|
| `report [paths...]` | Render an HTML or JSON report to stdout or `--output`. |
|
|
93
100
|
| `init` | Write the default `.gruff-ts.yaml` to the current directory (`--force` to overwrite). |
|
|
101
|
+
| `migrate-config` | Rewrite a 0.5 config for 0.6 (pruning retired rules, allowlists, and exclusions and validating output), writing to a different file. |
|
|
94
102
|
| `list-rules` | Print rule metadata as text or JSON. |
|
|
95
103
|
| `list-profiles` | Print the built-in profiles (`gruff.minimal`, `gruff.recommended`, `gruff.strict`) with their rule-count summary, as text or JSON. |
|
|
96
104
|
| `check-ignore <paths...>` | Report whether each path is ignored (config, gitignore, or default) with the matching source and pattern; runs no analysis. |
|
|
105
|
+
| `hook [paths...]` | Emit the `gruff.hook.v2` coding-agent contract and capability metadata. |
|
|
97
106
|
| `dashboard` | Serve the local browser dashboard. |
|
|
98
107
|
| `completion [shell]` | Print a shell completion script for `bash`, `zsh`, or `fish`. |
|
|
99
|
-
| `list`, `help` | Show command
|
|
108
|
+
| `list`, `help` | Show the registered command catalogue, and per-command help. Use `--help` on the root or a command for the same detail. |
|
|
100
109
|
|
|
101
110
|
Global console options match the broader gruff CLI surface: `--silent`, `--quiet`, `--ansi` / `--no-ansi`, `--no-interaction`, and `-v` / `-vv` / `-vvv`.
|
|
102
111
|
|
|
@@ -107,7 +116,7 @@ Global console options match the broader gruff CLI surface: `--silent`, `--quiet
|
|
|
107
116
|
| Format | Use it for |
|
|
108
117
|
| --- | --- |
|
|
109
118
|
| `text` | Human terminal output. |
|
|
110
|
-
| `json` | Full `gruff.analysis.
|
|
119
|
+
| `json` | Full `gruff.analysis.v3` report. |
|
|
111
120
|
| `html` | Self-contained inspection report. |
|
|
112
121
|
| `markdown` | Pull-request or issue comment summary. |
|
|
113
122
|
| `github` | GitHub Actions workflow annotations. |
|
|
@@ -124,7 +133,7 @@ Global console options match the broader gruff CLI surface: `--silent`, `--quiet
|
|
|
124
133
|
| `1` | At least one finding met `--fail-on`. |
|
|
125
134
|
| `2` | Fatal diagnostic such as missing input, parse error, config error, diff failure, baseline failure, or invalid input. |
|
|
126
135
|
|
|
127
|
-
`analyse`
|
|
136
|
+
`analyse` defaults to `--fail-on advisory`, while `summary`, `report`, and `hook` default to `--fail-on none` so an initial `summary` prints findings and exits `0`. The table above covers `analyse`, `summary`, and `report`; `hook` gates only when the caller asks and has [its own exit codes](docs/agent-hook.md#the-model). You can override defaults per project with `failOn:` in `.gruff-ts.yaml` (precedence: CLI flag > config > binary default; see ADR-004 and [Configuration](docs/configuration.md)).
|
|
128
137
|
|
|
129
138
|
## CI Usage
|
|
130
139
|
|
|
@@ -140,15 +149,15 @@ SARIF jobs can write an artifact for code scanning:
|
|
|
140
149
|
npx gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
|
|
141
150
|
```
|
|
142
151
|
|
|
143
|
-
|
|
152
|
+
A security gate can skip the adoption baseline and run only the security and sensitive-data pillars. Secret findings report at `warning`, so gate at `warning`:
|
|
144
153
|
|
|
145
154
|
```bash
|
|
146
|
-
npx gruff-ts analyse . --no-baseline --fail-on=
|
|
155
|
+
npx gruff-ts analyse . --no-baseline --include-pillar security,sensitive-data --fail-on=warning
|
|
147
156
|
```
|
|
148
157
|
|
|
149
158
|
## Configuration
|
|
150
159
|
|
|
151
|
-
`analyse` auto-
|
|
160
|
+
`analyse`, `summary`, `report`, and `hook` auto-load the first supported config file in the project root:
|
|
152
161
|
|
|
153
162
|
1. `.gruff-ts.yaml`
|
|
154
163
|
2. `.gruff.json`
|
|
@@ -158,6 +167,8 @@ npx gruff-ts analyse . --no-baseline --fail-on=error
|
|
|
158
167
|
Use `--config <path>` for an explicit file or `--no-config` to skip config loading. Recursive scans respect root and nested `.gitignore` files; `--include-ignored` includes default and Git-ignored paths for one run, but `paths.ignore` entries still apply as project policy.
|
|
159
168
|
|
|
160
169
|
```yaml
|
|
170
|
+
schemaVersion: gruff-ts.config.v0.1
|
|
171
|
+
|
|
161
172
|
paths:
|
|
162
173
|
ignore:
|
|
163
174
|
- "generated/**"
|
|
@@ -166,13 +177,10 @@ allowlists:
|
|
|
166
177
|
acceptedAbbreviations:
|
|
167
178
|
- api
|
|
168
179
|
- cli
|
|
169
|
-
acceptedBooleanNames:
|
|
170
|
-
- verbose
|
|
171
|
-
- enabled
|
|
172
|
-
secretPreviews: []
|
|
173
180
|
|
|
174
181
|
rules:
|
|
175
182
|
complexity.cyclomatic:
|
|
183
|
+
enabled: true # off by default; a threshold alone does not turn it on
|
|
176
184
|
threshold: 10
|
|
177
185
|
severity: warning
|
|
178
186
|
size.file-length:
|
|
@@ -190,7 +198,7 @@ A `profile:` selects a named bundle of rules instead of enumerating every rule b
|
|
|
190
198
|
| --- | --- |
|
|
191
199
|
| `gruff.minimal` | Security and sensitive-data rules only - the smallest sanity gate for incremental adoption. |
|
|
192
200
|
| `gruff.recommended` | Every pillar at its default threshold and severity - identical to gruff's zero-config behaviour. |
|
|
193
|
-
| `gruff.strict` | Every pillar enabled with tightened size
|
|
201
|
+
| `gruff.strict` | Every pillar enabled with tightened size and design thresholds for high-bar repositories. |
|
|
194
202
|
|
|
195
203
|
`gruff-ts list-profiles` prints them with their enabled-rule counts. Select one in config or on the CLI:
|
|
196
204
|
|
|
@@ -205,6 +213,7 @@ profile:
|
|
|
205
213
|
extends: gruff.recommended # a built-in name OR a relative path like ./team-profile.yaml
|
|
206
214
|
rules:
|
|
207
215
|
complexity.cyclomatic:
|
|
216
|
+
enabled: true
|
|
208
217
|
threshold: 12
|
|
209
218
|
docs.missing-public-doc:
|
|
210
219
|
enabled: false
|
|
@@ -223,39 +232,35 @@ Semantics:
|
|
|
223
232
|
|
|
224
233
|
## Rules And Pillars
|
|
225
234
|
|
|
226
|
-
The current catalogue contains
|
|
235
|
+
The current catalogue contains 81 rules:
|
|
227
236
|
|
|
228
237
|
| Pillar | Rules |
|
|
229
238
|
| --- | ---: |
|
|
230
|
-
| `complexity` |
|
|
239
|
+
| `complexity` | 1 |
|
|
231
240
|
| `dead-code` | 1 |
|
|
232
|
-
| `design` |
|
|
233
|
-
| `documentation` |
|
|
234
|
-
| `maintainability` |
|
|
235
|
-
| `modernisation` |
|
|
236
|
-
| `naming` |
|
|
237
|
-
| `security` |
|
|
238
|
-
| `sensitive-data` |
|
|
241
|
+
| `design` | 4 |
|
|
242
|
+
| `documentation` | 15 |
|
|
243
|
+
| `maintainability` | 8 |
|
|
244
|
+
| `modernisation` | 9 |
|
|
245
|
+
| `naming` | 3 |
|
|
246
|
+
| `security` | 23 |
|
|
247
|
+
| `sensitive-data` | 8 |
|
|
239
248
|
| `size` | 3 |
|
|
240
|
-
| `test-quality` |
|
|
249
|
+
| `test-quality` | 6 |
|
|
241
250
|
|
|
242
251
|
Use `npx gruff-ts list-rules --format=json` for exact rule IDs, severities, confidence levels, remediation text, thresholds, and options.
|
|
243
252
|
|
|
244
253
|
## Baselines And Changed-Code Scans
|
|
245
254
|
|
|
246
|
-
For editor and coding-agent feedback,
|
|
255
|
+
For editor and coding-agent feedback, use `hook`. It emits `gruff.hook.v2` JSON and is advisory by default (`--fail-on none`): it publishes findings and exits `0`. It exits `1` only when a gate you asked for trips (`--fail-on`, `--fail-on-new`, or `--fail-on-diagnostics`), and `2` when the run could not happen. [Using gruff-ts As A Coding-Agent Hook](docs/agent-hook.md) covers the envelope, wiring, gate levels, and CI use:
|
|
247
256
|
|
|
248
257
|
```bash
|
|
249
258
|
npx gruff-ts hook --format=json --changed-ranges "3-3,8-10" src/foo.ts
|
|
250
259
|
npx gruff-ts hook --capabilities --format=json
|
|
251
260
|
```
|
|
252
261
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
advisory: findings exit `0`; operational failures such as invalid config exit `2` and are reported
|
|
256
|
-
in `config.error`.
|
|
257
|
-
|
|
258
|
-
Baselines suppress reviewed findings by stable fingerprint:
|
|
262
|
+
Baselines suppress reviewed findings by a line-free identity and the count each row accepts, so an
|
|
263
|
+
unrelated edit that shifts line numbers does not re-open reviewed debt:
|
|
259
264
|
|
|
260
265
|
```bash
|
|
261
266
|
npx gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
|
|
@@ -284,7 +289,7 @@ Use `--changed-scope file` when a CI workflow intentionally wants every finding
|
|
|
284
289
|
files, including file-wide metrics such as `size.file-length`. The default `symbol` scope keeps
|
|
285
290
|
the coding-agent feedback focused on the changed line or enclosing declaration.
|
|
286
291
|
|
|
287
|
-
JSON output keeps the normal `findings` array and
|
|
292
|
+
JSON output keeps the normal `findings` array and reports the filtered count as `diff.filteredFindings` and `summary.suppressedFindings` when changed-region filtering is active.
|
|
288
293
|
|
|
289
294
|
## Dashboard
|
|
290
295
|
|
|
@@ -298,11 +303,13 @@ In polyglot repositories, `gruff-ts` defaults to port `8767`, `gruff-rs` default
|
|
|
298
303
|
|
|
299
304
|
## Trust Boundary
|
|
300
305
|
|
|
301
|
-
Default scans
|
|
306
|
+
Default scans read local source, config, and package metadata files only. `gruff-ts` does not execute target application code, run tests, type-check or emit through `tsc`, query package registries, or fetch vulnerability feeds. The runtime `typescript` dependency is used for syntax parsing only, `tsx` runs the shipped TypeScript source, and `commander` owns CLI parsing. Git runs only when you pass a diff mode. Sensitive-data findings print fixed category markers rather than matched secret characters or lengths across terminal, JSON, SARIF, GitHub, Markdown, hotspot, and HTML output.
|
|
302
307
|
|
|
303
308
|
## Stability Contract
|
|
304
309
|
|
|
305
|
-
|
|
310
|
+
`gruff-ts` treats rule IDs, finding fingerprints, baseline identities, `gruff.analysis.v3`, `gruff.summary.v3`, `gruff.baseline.v3`, `gruff.hotspot.v1`, `gruff.hook.v2`, `gruff-ts.config.v0.1`, SARIF output, and CLI exit codes as compatibility-sensitive. The three `v3` schemas arrive in `0.6.0` (replacing `gruff.analysis.v2`, `gruff.summary.v2`, and `gruff.baseline.v1` from `0.5.x`); see [Upgrading](UPGRADING.md) for every breaking change and migration step. Future breaking changes land only in coordinated releases and are documented in [CHANGELOG.md](CHANGELOG.md).
|
|
311
|
+
|
|
312
|
+
Analysis JSON uses `file` for findings and top offenders (the legacy `filePath` alias was removed in `0.6.0`). See [Output formats](docs/output-formats.md) for the v2-to-v3 field mapping.
|
|
306
313
|
|
|
307
314
|
## How It Compares
|
|
308
315
|
|
|
@@ -328,10 +335,12 @@ Source lives under `src/`: `src/cli.ts` is the bootstrap, `src/cli-program.ts` o
|
|
|
328
335
|
|
|
329
336
|
## Documentation
|
|
330
337
|
|
|
338
|
+
- [Docs index](docs/README.md)
|
|
339
|
+
- [Output formats](docs/output-formats.md)
|
|
340
|
+
- [Upgrading](UPGRADING.md)
|
|
331
341
|
- [Changelog](CHANGELOG.md)
|
|
332
342
|
- [Configuration](docs/configuration.md)
|
|
333
343
|
- [Rules catalogue](docs/rules.md)
|
|
334
|
-
- [Reports and CI](docs/reports-and-ci.md)
|
|
335
344
|
- [Contributing](CONTRIBUTING.md)
|
|
336
345
|
- [Security](SECURITY.md)
|
|
337
346
|
|
package/SECURITY.md
CHANGED
|
@@ -4,42 +4,30 @@
|
|
|
4
4
|
|
|
5
5
|
| Version | Supported |
|
|
6
6
|
| --- | --- |
|
|
7
|
-
| 0.
|
|
7
|
+
| 0.6.x | Yes |
|
|
8
|
+
| 0.5.x and earlier | No |
|
|
8
9
|
|
|
9
10
|
## Reporting A Vulnerability
|
|
10
11
|
|
|
11
|
-
Do not
|
|
12
|
-
paths, or sensitive scan output.
|
|
12
|
+
Do not open a public issue containing exploit details, secrets, tokens, private paths, or sensitive scan output.
|
|
13
13
|
|
|
14
|
-
Use
|
|
15
|
-
the public repository. If private reporting is not available yet, contact the
|
|
16
|
-
maintainer through the preferred private channel before posting details
|
|
17
|
-
publicly.
|
|
14
|
+
Use GitHub's private vulnerability reporting on this repository if it is enabled. Otherwise, reach out to the maintainer privately before posting details publicly.
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
Include what helps reproduce and scope the report:
|
|
20
17
|
|
|
21
|
-
- A short description of the issue.
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- Whether
|
|
25
|
-
logs.
|
|
26
|
-
- Whether a baseline, SARIF upload, GitHub annotation output, or dashboard scan
|
|
27
|
-
endpoint is involved.
|
|
18
|
+
- A short description of the issue and a minimal reproduction, if you have one.
|
|
19
|
+
- The command or output format affected.
|
|
20
|
+
- Whether sensitive data leaked into findings, reports, dashboard output, or logs.
|
|
21
|
+
- Whether a baseline, SARIF upload, GitHub annotation output, or the dashboard `/scan` endpoint is involved.
|
|
28
22
|
|
|
29
23
|
## Security Boundaries
|
|
30
24
|
|
|
31
|
-
- The dashboard is a local
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## Disclosure Expectations
|
|
42
|
-
|
|
43
|
-
The maintainer should acknowledge valid private reports, assess impact, and
|
|
44
|
-
coordinate a fix before public disclosure. Public advisories should include the
|
|
45
|
-
affected versions, fixed version, and mitigation.
|
|
25
|
+
- The dashboard is a local tool that binds to `127.0.0.1` by default. Binding it to `0.0.0.0` exposes filesystem scanning to the network without authentication.
|
|
26
|
+
- Sensitive-data findings print fixed category markers rather than matched secret characters or secret-derived lengths.
|
|
27
|
+
- HTML output is built without a template engine, so every interpolated value must be HTML-escaped.
|
|
28
|
+
- `gruff-ts` runs static heuristics; it is not a vulnerability scanner or dependency advisory database.
|
|
29
|
+
- Baselines suppress reviewed findings by line-free identity and count, and sensitive-data findings can never be baselined. For a security gate that ignores adoption baselines, run `gruff-ts analyse . --no-baseline --fail-on=warning` (all `sensitive-data.*` rules default to `warning`, so `--fail-on=error` alone will not fail on them).
|
|
30
|
+
|
|
31
|
+
## Disclosure Process
|
|
32
|
+
|
|
33
|
+
Valid private reports are acknowledged, triaged for impact, and patched before public disclosure. Public advisories list affected versions, the fixed version, and mitigation steps.
|