@blundergoat/gruff-ts 0.5.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 +82 -0
- package/CONTRIBUTING.md +32 -25
- package/README.md +49 -50
- package/SECURITY.md +18 -31
- package/UPGRADING.md +101 -0
- package/bin/gruff-ts +3 -0
- package/docs/README.md +11 -10
- package/docs/agent-hook.md +32 -35
- package/docs/ci-integration.md +38 -24
- package/docs/configuration.md +160 -89
- 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 -172
- package/docs/rules.md +126 -98
- package/package.json +10 -8
- package/src/analyser.ts +817 -323
- 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 +62 -68
- package/src/blocks.ts +512 -336
- package/src/changed-regions.ts +380 -79
- package/src/check-ignore.ts +28 -13
- package/src/class-rules.ts +445 -436
- package/src/cli-program.ts +915 -172
- package/src/cli.ts +9 -3
- package/src/comment-rules.ts +236 -418
- package/src/comment-scanner.ts +339 -47
- package/src/complexity-metrics.ts +111 -35
- 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 +751 -223
- package/src/constants.ts +7 -6
- package/src/context-doc-rules.ts +182 -54
- package/src/dashboard.ts +88 -23
- package/src/dead-code-rules.ts +153 -74
- package/src/discovery.ts +493 -140
- package/src/doc-rules.ts +602 -126
- package/src/duplicate-test-group-rules.ts +359 -0
- package/src/findings-helpers.ts +134 -109
- package/src/findings.ts +47 -27
- package/src/fixture-purpose-rules.ts +194 -50
- package/src/github-actions-event-guards.ts +331 -0
- package/src/github-actions-rules.ts +328 -121
- package/src/hook-contract.ts +681 -255
- package/src/init-config.ts +163 -118
- package/src/inline-suppressions.ts +340 -0
- package/src/limit-band.ts +56 -0
- package/src/line-rules.ts +331 -468
- package/src/migrate-config.ts +670 -0
- package/src/naming-pushers.ts +32 -127
- package/src/parsed-script.ts +868 -314
- package/src/pillar-summary.ts +56 -40
- package/src/profiles.ts +86 -74
- package/src/project-config-rules.ts +324 -140
- package/src/project-rules.ts +237 -115
- package/src/public-exports.ts +102 -38
- package/src/report-html.ts +217 -85
- package/src/report-renderers.ts +821 -203
- package/src/rule-list.ts +166 -46
- package/src/rules.ts +100 -104
- package/src/safety-rules.ts +191 -132
- package/src/scoring.ts +249 -55
- package/src/security-flow-rules.ts +791 -115
- package/src/selectors.ts +169 -0
- package/src/sensitive-data-rules.ts +460 -387
- package/src/sensitive-exclusions.ts +435 -0
- package/src/source-text.ts +378 -104
- package/src/static-analysis-redundant-rules.ts +298 -41
- package/src/test-block-rules.ts +343 -253
- package/src/text-scans.ts +62 -11
- package/src/types.ts +220 -71
- package/tsconfig.json +2 -1
- package/src/process-exec-metadata.ts +0 -163
- package/src/test-fixtures.ts +0 -671
package/docs/configuration.md
CHANGED
|
@@ -6,7 +6,7 @@ thresholds that need tuning.
|
|
|
6
6
|
|
|
7
7
|
## Discovery Order
|
|
8
8
|
|
|
9
|
-
`analyse` auto-
|
|
9
|
+
`analyse`, `summary`, `report`, and `hook` auto-load the first supported config file in the project root:
|
|
10
10
|
|
|
11
11
|
1. `.gruff-ts.yaml`
|
|
12
12
|
2. `.gruff.json`
|
|
@@ -29,41 +29,50 @@ gruff-ts analyse . --no-config
|
|
|
29
29
|
|
|
30
30
|
Every `.gruff-ts.yaml` must declare `schemaVersion: gruff-ts.config.v0.1` at the
|
|
31
31
|
top. Loading throws if the field is missing or carries a different value. The
|
|
32
|
-
field is in a different namespace from the output schemas (`gruff.analysis.
|
|
33
|
-
`gruff.summary.
|
|
32
|
+
field is in a different namespace from the output schemas (`gruff.analysis.v3`,
|
|
33
|
+
`gruff.summary.v3`, etc.) - the config-input version travels independently of
|
|
34
34
|
the output-payload versions. See ADR-004.
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## failOn (per-command gating defaults)
|
|
37
37
|
|
|
38
|
-
A top-level `
|
|
39
|
-
|
|
38
|
+
A top-level `failOn:` block sets the default `--fail-on` value per command.
|
|
39
|
+
The precedence chain is **CLI flag > config > binary default**.
|
|
40
40
|
|
|
41
41
|
```yaml
|
|
42
42
|
schemaVersion: gruff-ts.config.v0.1
|
|
43
|
-
|
|
43
|
+
failOn:
|
|
44
44
|
analyse: advisory
|
|
45
|
-
summary:
|
|
45
|
+
summary: none
|
|
46
46
|
report: none
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Valid values: `advisory | warning | error | none
|
|
50
|
-
|
|
51
|
-
off-switch before the family converged on `none`).
|
|
49
|
+
Valid values: `advisory | warning | error | none`; anything else, `never`
|
|
50
|
+
included, is rejected.
|
|
52
51
|
|
|
53
|
-
`dashboard` is
|
|
54
|
-
|
|
55
|
-
would be a silent no-op CI footgun, so the validator rejects it with a clear
|
|
56
|
-
error.
|
|
52
|
+
`dashboard` is not a valid key. It has no `--fail-on` flag, so
|
|
53
|
+
`failOn.dashboard:` fails validation instead of being silently ignored.
|
|
57
54
|
|
|
58
|
-
Binary defaults are `analyse: advisory`, `summary:
|
|
55
|
+
Binary defaults are `analyse: advisory`, `summary: none`, `report: none`.
|
|
56
|
+
|
|
57
|
+
Across the Gruff family only `analyse` and `report` are accepted by every port, so a
|
|
58
|
+
polyglot repository that shares one `failOn` block should write only those two keys.
|
|
59
|
+
`summary` is accepted by gruff-go and gruff-ts, and `dashboard` by gruff-go, gruff-php
|
|
60
|
+
and gruff-py; each other port refuses the key with exit 2 rather than ignoring it,
|
|
61
|
+
because it ships no gate for that command.
|
|
62
|
+
|
|
63
|
+
`minimumSeverity:` is a different setting: one severity - `advisory`,
|
|
64
|
+
`warning`, or `error` - that hides quieter findings from the report without
|
|
65
|
+
changing the score or the exit code. A `minimumSeverity:` carrying the
|
|
66
|
+
per-command map above is refused at config load rather than read as a floor, so
|
|
67
|
+
an existing 0.5 config cannot quietly change what it gates.
|
|
59
68
|
|
|
60
69
|
## Shape
|
|
61
70
|
|
|
62
71
|
```yaml
|
|
63
72
|
schemaVersion: gruff-ts.config.v0.1
|
|
64
|
-
|
|
73
|
+
failOn:
|
|
65
74
|
analyse: advisory
|
|
66
|
-
summary:
|
|
75
|
+
summary: none
|
|
67
76
|
report: none
|
|
68
77
|
|
|
69
78
|
paths:
|
|
@@ -74,17 +83,15 @@ allowlists:
|
|
|
74
83
|
acceptedAbbreviations:
|
|
75
84
|
- api
|
|
76
85
|
- cli
|
|
77
|
-
secretPreviews: []
|
|
78
|
-
bannedGenericNames: [process, handle, doit, run, execute, manage]
|
|
79
|
-
acceptedBooleanNames: [all, apply, check, dev, enabled, force, fresh, harness, json, ok, verbose, yes]
|
|
80
|
-
booleanPrefixes: [is, has, can, should, does, did, was, will, may, in, scan, supports, requires, allow, check, enable, exclude, include, omit, skip, with, without]
|
|
81
|
-
hungarianPrefixes: [str, obj, arr, bool, int, num]
|
|
82
86
|
placeholderNames: [foo, bar, baz, tmp, temp, thing, stuff, data, value, item]
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
|
|
88
|
+
sensitiveExclusions:
|
|
89
|
+
- rule: sensitive-data.aws-access-key
|
|
90
|
+
path: tests/fixtures/aws-sample.env
|
|
91
|
+
reason: Synthetic key used by the loader fixture; not a live credential.
|
|
85
92
|
|
|
86
93
|
rules:
|
|
87
|
-
|
|
94
|
+
complexity.cyclomatic:
|
|
88
95
|
enabled: true
|
|
89
96
|
threshold: 10
|
|
90
97
|
severity: warning
|
|
@@ -108,22 +115,37 @@ paths:
|
|
|
108
115
|
- "src/generated-client.ts"
|
|
109
116
|
```
|
|
110
117
|
|
|
111
|
-
|
|
118
|
+
VCS internals are always blocked at any depth:
|
|
112
119
|
|
|
113
120
|
```text
|
|
114
|
-
.git, .hg, .svn
|
|
115
|
-
generated, node_modules, target, tmp, vendor
|
|
121
|
+
.git, .hg, .svn
|
|
116
122
|
```
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
Third-party copies, build output and minified files are skipped at any depth and
|
|
125
|
+
in any letter case, even when a `.gitignore` exists: directories named `vendor`,
|
|
126
|
+
`vendors`, `third_party`, `third-party` or `bower_components` (reason
|
|
127
|
+
`dependency`) or `dist` (reason `build-output`), and files with `.min.` directly
|
|
128
|
+
before the final extension, such as `jquery.min.js` (reason `generated`).
|
|
129
|
+
|
|
130
|
+
When no `.gitignore` exists from the project root through a candidate's parent,
|
|
131
|
+
the family fallback also skips `.fleet`, `.idea`, `.vscode`, `build`, `coverage`,
|
|
132
|
+
and `node_modules` at any depth. Once a `.gitignore` exists in that chain, it
|
|
133
|
+
owns those names for the subtree. Committed control metadata such
|
|
134
|
+
as `.agents`, `.claude`, `.codex`, `.github`, and `.goat-flow` stays scannable
|
|
135
|
+
unless Git or config excludes it.
|
|
136
|
+
|
|
137
|
+
Use `--include-ignored` when you intentionally want to scan third-party,
|
|
138
|
+
fallback and Git-ignored paths. An explicit supported file also bypasses those
|
|
139
|
+
three layers.
|
|
140
|
+
Neither form overrides configured `paths.ignore` or the VCS boundary. Lockfile
|
|
141
|
+
names add no exclusion; eligible forms such as `package-lock.json` are scanned.
|
|
121
142
|
|
|
122
143
|
`paths.ignore` is authoritative in every invocation mode (ADR-007): a matching
|
|
123
144
|
path is excluded and produces no findings whether it is reached by a directory
|
|
124
145
|
walk, passed as an explicit file operand (`gruff-ts analyse src/generated-client.ts`),
|
|
125
146
|
or touched by a diff/changed-region run. Excluded paths appear in the report's
|
|
126
|
-
`paths.
|
|
147
|
+
`paths.details` array with their `source` (`config` / `gitignore` / `default`) and, for
|
|
148
|
+
`config` entries only,
|
|
127
149
|
the matching `pattern`. Query a path without scanning via `check-ignore`, which
|
|
128
150
|
shares the same engine and mirrors `git check-ignore` exit codes (0 = at least
|
|
129
151
|
one ignored, 1 = none, 2 = error):
|
|
@@ -135,8 +157,9 @@ gruff-ts check-ignore src/generated-client.ts --format json
|
|
|
135
157
|
|
|
136
158
|
## Generated Markers
|
|
137
159
|
|
|
138
|
-
|
|
139
|
-
|
|
160
|
+
Vendored directories, `dist` and `.min.` files are already skipped (see above).
|
|
161
|
+
Use `paths.ignore` when any other generated or vendored surface should not be
|
|
162
|
+
scanned at all. If the file should stay in the scan, gruff treats a source file as generated
|
|
140
163
|
only when one of these explicit markers appears in the first 10 lines:
|
|
141
164
|
`AUTO-GENERATED`, `@generated`, `GENERATED FILE`, `Code generated`,
|
|
142
165
|
`Generated by`, `DO NOT EDIT`, or `Copied from`.
|
|
@@ -144,9 +167,10 @@ only when one of these explicit markers appears in the first 10 lines:
|
|
|
144
167
|
Generated files skip documentation and naming findings only. Security,
|
|
145
168
|
sensitive-data, size, complexity, maintainability, modernisation, and
|
|
146
169
|
test-quality checks still run, so a generated file can still report a leaked
|
|
147
|
-
credential, unsafe execution, or a file-size finding.
|
|
148
|
-
|
|
149
|
-
|
|
170
|
+
credential, unsafe execution, or a file-size finding. Directory names alone never
|
|
171
|
+
trigger this generated-file skip (separately, security and sensitive-data rules
|
|
172
|
+
skip test, fixture, and example paths with counted audit rows - see Sensitive
|
|
173
|
+
Exclusions below).
|
|
150
174
|
|
|
151
175
|
## Allowlists
|
|
152
176
|
|
|
@@ -161,60 +185,48 @@ allowlists:
|
|
|
161
185
|
- env
|
|
162
186
|
```
|
|
163
187
|
|
|
164
|
-
`allowlists.secretPreviews`
|
|
165
|
-
|
|
188
|
+
The `0.5` key `allowlists.secretPreviews` is removed because reports now use
|
|
189
|
+
fixed category markers unconditionally, without matched characters or
|
|
190
|
+
secret-derived lengths. `gruff-ts init` no longer writes it, configs containing
|
|
191
|
+
it (even as an empty list) fail with exit `2`, and `gruff-ts migrate-config`
|
|
192
|
+
deletes it. To silence a reviewed sample secret, use `sensitiveExclusions:`
|
|
193
|
+
below rather than preview matching.
|
|
166
194
|
|
|
167
|
-
|
|
168
|
-
allowlists:
|
|
169
|
-
secretPreviews:
|
|
170
|
-
- "abcd...wxyz (redacted, 32 chars)"
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Only previews for values of at least 24 characters can be allowlisted. Shorter
|
|
174
|
-
previews are fully masked and identify only the value length, so gruff continues
|
|
175
|
-
to report them even if the same mask appears in `secretPreviews`. This prevents
|
|
176
|
-
one entry from hiding unrelated secrets of the same length.
|
|
177
|
-
|
|
178
|
-
Prefer fixing false positives with a narrow config entry instead of disabling an
|
|
179
|
-
entire sensitive-data rule.
|
|
180
|
-
|
|
181
|
-
Naming allowlists tune the 0.2.0 naming pack without changing rule ids or
|
|
195
|
+
Naming allowlists tune the naming rules without changing rule IDs or
|
|
182
196
|
fingerprints:
|
|
183
197
|
|
|
184
198
|
| Key | Used by | Default behavior |
|
|
185
199
|
| --- | --- | --- |
|
|
186
200
|
| `acceptedAbbreviations` | `naming.short-variable` | Adds short names that should not be flagged. |
|
|
187
|
-
| `acceptedBooleanNames` | `naming.boolean-prefix` | Replaces the complete set of exact interface/type contract-field names, such as `verbose`, `enabled`, `ok`, and `force`. |
|
|
188
201
|
| `acceptedClassFilePairs` | `naming.class-file-mismatch` | Replaces the exact case-insensitive `fileBase:ClassName` pairs that may use feature-file and class-role naming. Defaults to empty. |
|
|
189
|
-
| `
|
|
190
|
-
| `bannedGenericNames` | `naming.generic-function` | Replaces the built-in generic function-name denylist. |
|
|
191
|
-
| `booleanPrefixes` | `naming.boolean-prefix` | Replaces the accepted boolean-name prefixes such as `is`, `has`, `should`, `may`, `supports`, and `requires`. |
|
|
192
|
-
| `hungarianPrefixes` | `naming.hungarian-notation` | Replaces type-style prefixes to flag. |
|
|
193
|
-
| `placeholderNames` | `naming.identifier-quality`, `naming.generic-parameter` | Replaces placeholder words; numbered suffix checks stay active. |
|
|
194
|
-
| `negativeBooleanAllowed` | `naming.negative-boolean` | Replaces domain terms allowed to start with `no`. |
|
|
195
|
-
| `knownAcronyms` | `naming.acronym-case` | Replaces acronyms checked for mixed casing. |
|
|
202
|
+
| `placeholderNames` | `naming.identifier-quality` | Replaces placeholder words; numbered suffix checks stay active. |
|
|
196
203
|
|
|
197
204
|
For replace-style allowlists, use an empty list (`[]`) when you intentionally
|
|
198
205
|
want no entries.
|
|
199
206
|
|
|
200
|
-
|
|
201
|
-
defaults the project still needs into the configured list before adding the
|
|
202
|
-
external key - the configured list replaces defaults rather than extending
|
|
203
|
-
them. If renaming a JSON, CLI, or DTO key would break consumers, keep a clearer
|
|
204
|
-
internal field and map the external key explicitly at the serialization boundary.
|
|
205
|
-
|
|
206
|
-
Use exact pair allowlists when both names must coexist:
|
|
207
|
+
Use an exact pair allowlist when a class and its file must keep different names:
|
|
207
208
|
|
|
208
209
|
```yaml
|
|
209
210
|
allowlists:
|
|
210
211
|
acceptedClassFilePairs: ["focusModeTranscript:TranscriptFocusController"]
|
|
211
|
-
acceptedCasingPairs: ["note_id:noteId"]
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
The
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
The entry uses the extensionless file base before the colon. The list is
|
|
215
|
+
case-insensitive, replaces the complete configured list, and suppresses only the
|
|
216
|
+
exact pair rather than every name sharing the same canonical form.
|
|
217
|
+
|
|
218
|
+
`allowlists.trackingTokens` lists a project's own tracking references as regular
|
|
219
|
+
expressions. `docs.todo-without-tracking` treats a marker comment that matches
|
|
220
|
+
one as tracked, and `modernisation.ts-comment-without-rationale` and
|
|
221
|
+
`waste.swallowed-catch` accept a match as a rationale. gruff-ts ships no
|
|
222
|
+
project-specific token; to accept a reference style such as `ADR-004`, list a
|
|
223
|
+
pattern for it:
|
|
224
|
+
|
|
225
|
+
```yaml
|
|
226
|
+
allowlists:
|
|
227
|
+
trackingTokens:
|
|
228
|
+
- "ADR-[0-9]+"
|
|
229
|
+
```
|
|
218
230
|
|
|
219
231
|
## Rule Controls
|
|
220
232
|
|
|
@@ -226,11 +238,14 @@ rules:
|
|
|
226
238
|
enabled: false
|
|
227
239
|
```
|
|
228
240
|
|
|
229
|
-
Set one threshold and one emitted severity for a metric rule
|
|
241
|
+
Set one threshold and one emitted severity for a metric rule. A rule that is
|
|
242
|
+
off by default, such as `complexity.cyclomatic`, also needs `enabled: true`; a
|
|
243
|
+
threshold alone does not turn it on:
|
|
230
244
|
|
|
231
245
|
```yaml
|
|
232
246
|
rules:
|
|
233
247
|
complexity.cyclomatic:
|
|
248
|
+
enabled: true
|
|
234
249
|
threshold: 10
|
|
235
250
|
severity: warning
|
|
236
251
|
size.file-length:
|
|
@@ -251,6 +266,9 @@ rules:
|
|
|
251
266
|
minLines: 80
|
|
252
267
|
```
|
|
253
268
|
|
|
269
|
+
Any other key inside a rule block, a sibling port's `thresholds` map included, fails the config load
|
|
270
|
+
and names the key and the keys the block accepts.
|
|
271
|
+
|
|
254
272
|
List supported thresholds and options:
|
|
255
273
|
|
|
256
274
|
```bash
|
|
@@ -260,6 +278,71 @@ gruff-ts list-rules --format=json
|
|
|
260
278
|
|
|
261
279
|
See [Rules](./rules.md) for the full rule catalogue grouped by pillar.
|
|
262
280
|
|
|
281
|
+
## Sensitive Exclusions
|
|
282
|
+
|
|
283
|
+
`sensitiveExclusions:` is the only setting that suppresses a sensitive-data finding. It
|
|
284
|
+
is a separate top-level section, not part of `rules:` or `paths.ignore`, because
|
|
285
|
+
it is the one surface that can hide a detected secret.
|
|
286
|
+
|
|
287
|
+
One built-in skip also hides findings, and counts each one in `suppressions`:
|
|
288
|
+
every sensitive-data and security rule in test, fixture and example files.
|
|
289
|
+
A configured entry applies first, so a finding it claims is counted under the entry.
|
|
290
|
+
|
|
291
|
+
You write every entry by hand. Gruff never converts a detected value, a preview,
|
|
292
|
+
or a finding message into an exclusion, and no key on an entry matches against
|
|
293
|
+
finding text.
|
|
294
|
+
|
|
295
|
+
```yaml
|
|
296
|
+
sensitiveExclusions:
|
|
297
|
+
- rule: sensitive-data.aws-access-key
|
|
298
|
+
path: tests/fixtures/aws-sample.env
|
|
299
|
+
reason: Synthetic key used by the loader fixture; not a live credential.
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
An entry suppresses a finding only when all of the following match:
|
|
303
|
+
|
|
304
|
+
- `rule` equals the finding's rule id exactly. One rule id per entry, from the
|
|
305
|
+
`sensitive-data` pillar only.
|
|
306
|
+
- `path` equals the finding's project-relative path exactly. One file per entry.
|
|
307
|
+
- `symbol`, when present, equals the finding's symbol exactly. It narrows the
|
|
308
|
+
scope. No sensitive-data rule stamps a symbol today, so an entry carrying one
|
|
309
|
+
currently matches nothing - that is the declared scope working, not a bug.
|
|
310
|
+
|
|
311
|
+
Nothing else is suppressed: the same rule in another file, and a different rule
|
|
312
|
+
in the same file, both keep reporting.
|
|
313
|
+
|
|
314
|
+
`reason` is required and must be non-empty. Loading fails with exit code 2 and
|
|
315
|
+
names the entry index plus the offending key when an entry:
|
|
316
|
+
|
|
317
|
+
- omits `rule`, or gives a wildcard, glob, regular-expression character, pillar
|
|
318
|
+
name, unknown rule id, or a rule outside the `sensitive-data` pillar;
|
|
319
|
+
- omits `path`, or gives an absolute path, a `..` traversal, or a glob;
|
|
320
|
+
- carries any key outside `rule`, `path`, `symbol`, and `reason` - including
|
|
321
|
+
`message_contains`, `messageContains`, `value`, and `preview`;
|
|
322
|
+
- omits `reason` or supplies only whitespace;
|
|
323
|
+
- repeats a `rule` + `path` + `symbol` scope an earlier entry already claims.
|
|
324
|
+
|
|
325
|
+
An entry that matches no finding is not an error. It reports `suppressed: 0`, so
|
|
326
|
+
fixing the underlying problem never breaks a build.
|
|
327
|
+
|
|
328
|
+
Every entry is counted. The `suppressions` array in the `gruff.analysis.v3`
|
|
329
|
+
report carries one row per entry in declaration order:
|
|
330
|
+
|
|
331
|
+
```json
|
|
332
|
+
{ "index": 0, "rule": "sensitive-data.aws-access-key", "paths": ["tests/fixtures/aws-sample.env"], "reason": "Synthetic key used by the loader fixture; not a live credential.", "suppressed": 2 }
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Text output prints the total when it is non-zero:
|
|
336
|
+
|
|
337
|
+
```text
|
|
338
|
+
Suppressed findings: 2 via sensitiveExclusions[0] sensitive-data.aws-access-key: 2 (Synthetic key used by the loader fixture; not a live credential.)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
A suppressed finding leaves the finding list, the score, and the `--fail-on`
|
|
342
|
+
exit code, but it is never invisible: its count is always reported. Only the
|
|
343
|
+
configured rule id, path, and reason appear in output - never any part of the
|
|
344
|
+
detected value.
|
|
345
|
+
|
|
263
346
|
## Example Project Config
|
|
264
347
|
|
|
265
348
|
A complete file. The shorter snippets above omit `schemaVersion` because they
|
|
@@ -279,24 +362,12 @@ allowlists:
|
|
|
279
362
|
- cli
|
|
280
363
|
- env
|
|
281
364
|
- id
|
|
282
|
-
acceptedBooleanNames:
|
|
283
|
-
- verbose
|
|
284
|
-
- enabled
|
|
285
|
-
secretPreviews: []
|
|
286
365
|
|
|
287
366
|
rules:
|
|
288
|
-
complexity.cognitive:
|
|
289
|
-
threshold: 15
|
|
290
|
-
severity: warning
|
|
291
367
|
complexity.cyclomatic:
|
|
368
|
+
enabled: true
|
|
292
369
|
threshold: 10
|
|
293
370
|
severity: warning
|
|
294
|
-
design.deep-relative-import:
|
|
295
|
-
threshold: 2
|
|
296
|
-
severity: advisory
|
|
297
|
-
sensitive-data.high-entropy-string:
|
|
298
|
-
threshold: 32
|
|
299
|
-
severity: error
|
|
300
371
|
size.function-length:
|
|
301
372
|
threshold: 30
|
|
302
373
|
severity: warning
|
package/docs/dashboard.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Dashboard
|
|
2
2
|
|
|
3
|
-
`gruff-ts dashboard`
|
|
3
|
+
`gruff-ts dashboard` starts a local web UI for running and inspecting scans interactively.
|
|
4
4
|
|
|
5
5
|
## Start
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
|
|
8
|
+
npx gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Options
|
|
@@ -16,21 +16,20 @@
|
|
|
16
16
|
| `--port` | `8767` | Bind port. |
|
|
17
17
|
| `--project-root` | current directory | Initial project root. |
|
|
18
18
|
|
|
19
|
+
## Routes
|
|
20
|
+
|
|
21
|
+
- `/` - iframe shell and controls panel.
|
|
22
|
+
- `/health` - plain `ok`.
|
|
23
|
+
- `/scan?projectRoot=<path>&path=<path>` - report HTML for the selected scan.
|
|
24
|
+
|
|
19
25
|
## Safety
|
|
20
26
|
|
|
21
|
-
The dashboard has no authentication
|
|
22
|
-
network is trusted. The `/scan` endpoint analyses filesystem paths from request
|
|
23
|
-
parameters, so the bind address is the safety boundary.
|
|
27
|
+
The dashboard has no authentication. Keep it bound to `127.0.0.1` unless you trust every machine on the network: its `/scan` endpoint reads filesystem paths from request parameters, so loopback binding is the main safety boundary.
|
|
24
28
|
|
|
25
|
-
## Gating
|
|
29
|
+
## No Gating Threshold
|
|
26
30
|
|
|
27
|
-
`dashboard` has no `--fail-on` flag and
|
|
28
|
-
`minimumSeverity:` config block - setting `minimumSeverity.dashboard:` in
|
|
29
|
-
`.gruff-ts.yaml` is rejected at config load. Whether the dashboard should gate
|
|
30
|
-
is a deferred design question; raise it as an issue if your workflow needs it.
|
|
31
|
+
`dashboard` has no `--fail-on` flag and cannot appear under `failOn:` in `.gruff-ts.yaml` (setting `failOn.dashboard:` fails config validation with exit `2`).
|
|
31
32
|
|
|
32
33
|
## Polyglot Repos
|
|
33
34
|
|
|
34
|
-
`gruff-ts` defaults to port `8767`, `gruff-rs`
|
|
35
|
-
`gruff-go`, `gruff-php`, and `gruff-py` default to `8765`. Use `--port` when
|
|
36
|
-
running multiple dashboards at once.
|
|
35
|
+
`gruff-ts` defaults to port `8767`, `gruff-rs` to `8766`, and `gruff-go`, `gruff-php`, and `gruff-py` to `8765`. Pass `--port` if you run several dashboards side by side.
|
package/docs/output-formats.md
CHANGED
|
@@ -1,46 +1,113 @@
|
|
|
1
1
|
# Output Formats
|
|
2
2
|
|
|
3
|
-
`gruff-ts analyse --format <format>` renders the same
|
|
4
|
-
|
|
5
|
-
[Reports And CI](reports-and-ci.md).
|
|
3
|
+
`gruff-ts analyse --format <format>` renders the same scan results for different
|
|
4
|
+
consumers.
|
|
6
5
|
|
|
7
6
|
## Text
|
|
8
7
|
|
|
9
8
|
Use `text` for local terminal scans:
|
|
10
9
|
|
|
11
10
|
```sh
|
|
12
|
-
|
|
11
|
+
npx gruff-ts analyse src --format text --fail-on=warning
|
|
13
12
|
```
|
|
14
13
|
|
|
15
14
|
## JSON
|
|
16
15
|
|
|
17
|
-
Use `json` for automation.
|
|
16
|
+
Use `json` for automation. Analysis reports emit `gruff.analysis.v3`:
|
|
18
17
|
|
|
19
18
|
```sh
|
|
20
|
-
|
|
19
|
+
npx gruff-ts analyse src --format=json --fail-on=none > gruff-ts.json
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
Version 3 is a coordinated family contract and a hard break from the `0.5.x` v2
|
|
23
|
+
envelope. Paths are project-relative POSIX strings, `run.projectRoot` is `.`,
|
|
24
|
+
and volatile generation timestamps are omitted. Update consumers for these field
|
|
25
|
+
changes:
|
|
26
|
+
|
|
27
|
+
| v2 | v3 |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `findings[].filePath` and `findings[].file` | `findings[].file` |
|
|
30
|
+
| `score.composite` plus `score.grade` | `score.composite.score` plus `score.composite.grade` |
|
|
31
|
+
| `score.topOffenders[].filePath` | `score.topOffenders[].file` |
|
|
32
|
+
| `paths.skipped` | `paths.details` |
|
|
33
|
+
| top-level `notes` | `extensions.ts.topLevel.notes` |
|
|
34
|
+
| `baseline.suppressed` | `baseline.suppressedFindings` |
|
|
35
|
+
| top-level `suppressedCount` | `diff.filteredFindings` and `summary.suppressedFindings` |
|
|
36
|
+
| `generatedAt` | omitted |
|
|
37
|
+
|
|
38
|
+
Optional `column`, `endLine`, and `symbol` fields are omitted when unavailable
|
|
39
|
+
rather than set to `null`. Finding metadata sets `locationPrecision` to
|
|
40
|
+
`scanner-pinpointed` or `line-only`. Baseline identities follow the line-free v3
|
|
41
|
+
contract introduced in `0.6.0` (see [Upgrading](../UPGRADING.md)) and stay
|
|
42
|
+
stable across output formats and ordinary edits.
|
|
43
|
+
|
|
44
|
+
### Suppressions audit
|
|
45
|
+
|
|
46
|
+
The `suppressions` array is always present (empty when nothing was configured or
|
|
47
|
+
suppressed) and groups audit rows in three ordered sections:
|
|
48
|
+
|
|
49
|
+
1. **Configured exclusions** - one row per `sensitiveExclusions:` entry in
|
|
50
|
+
declaration order (`{index, rule, paths, symbol?, reason, suppressed}`). See
|
|
51
|
+
[Configuration](./configuration.md).
|
|
52
|
+
2. **Built-in test-path skips** - rows marked `source: "built-in"` (numbered
|
|
53
|
+
from `0` among themselves), one per file and rule skipped because security
|
|
54
|
+
and sensitive-data rules skip test, fixture, and example paths. Text output
|
|
55
|
+
labels them `builtInTestPath[<path>]`.
|
|
56
|
+
3. **Inline tool directives and duplicate merges** - rows continuing that
|
|
57
|
+
numbering with `source: "inline"` or `source: "duplicate"`:
|
|
58
|
+
- Supported inline comments on the reported line or alone on the line above
|
|
59
|
+
suppress the matching gruff finding: ESLint `no-eval` and `no-new-func`
|
|
60
|
+
(or a bare per-line ESLint disable covering both); Biome
|
|
61
|
+
`lint/security/noGlobalEval`, `lint/correctness/noUnusedImports`, or a
|
|
62
|
+
parent group such as `lint/security`; and zizmor `ignore[unpinned-uses]`
|
|
63
|
+
and `ignore[dangerous-triggers]`. Type-checker comments (`@ts-expect-error`)
|
|
64
|
+
and file-wide directives are not honoured.
|
|
65
|
+
- An `eval` call flagged by both `security.eval-call` and
|
|
66
|
+
`security.unsafe-deserialization` reports once under `security.eval-call`
|
|
67
|
+
and records the merged duplicate as `source: "duplicate"`.
|
|
68
|
+
- Text output prints `Suppressed findings: N via ...` with `inline[<path>]`
|
|
69
|
+
and `duplicate[<path>]` labels, and SARIF keeps each removed finding as a
|
|
70
|
+
suppressed result (`"suppressions": [{"kind": "inSource", "justification": <reason>}]`).
|
|
71
|
+
|
|
72
|
+
`paths.details` lists every excluded path with a canonical `reason` and its
|
|
73
|
+
`source` (`config`, `gitignore`, or `default`). Only `config` entries include the
|
|
74
|
+
matching `pattern`. `paths.ignoredPaths` is the ordered path projection of those
|
|
75
|
+
detail rows.
|
|
76
|
+
|
|
77
|
+
### Notes and the deep-scan budget
|
|
78
|
+
|
|
79
|
+
Notes explain scan-surface limits without changing the exit code. They sit at
|
|
80
|
+
`extensions.ts.topLevel.notes`, print in a `Notes:` block in text output, and are
|
|
81
|
+
left out of JSON when there are none:
|
|
82
|
+
|
|
83
|
+
- `no-analysable-files` - a requested path existed but contributed no supported
|
|
84
|
+
files, usually because ignore rules excluded everything under it.
|
|
85
|
+
- `non-text-file` - a file contained invalid UTF-8 or NUL bytes, so it was
|
|
86
|
+
skipped before parsing.
|
|
87
|
+
|
|
88
|
+
`bounded-deep-scan` is a non-fatal diagnostic rather than a note: a script file
|
|
89
|
+
went over the deep-scan budget of 20,000 lines or 2,000,000 UTF-8 bytes,
|
|
90
|
+
whichever comes first. The file still counts as analysed and text-level rules
|
|
91
|
+
still run, but deep TypeScript passes, parse diagnostics, and project-graph
|
|
92
|
+
retention are skipped for it. `--deep-scan-budget <lines:bytes|off>` changes or
|
|
93
|
+
turns off the budget. A non-fatal diagnostic like this leaves the exit code
|
|
94
|
+
alone; a fatal one exits `2`.
|
|
95
|
+
|
|
96
|
+
Score math clusters correlated `complexity.cyclomatic` and `size.function-length`
|
|
97
|
+
findings once per function symbol. The `findings` array still lists each finding;
|
|
98
|
+
only pillar penalties and offender scores are deduplicated.
|
|
32
99
|
|
|
33
100
|
## HTML
|
|
34
101
|
|
|
35
|
-
Use `html` for archived human review or dashboard
|
|
102
|
+
Use `html` for archived human review or dashboard output:
|
|
36
103
|
|
|
37
104
|
```sh
|
|
38
|
-
|
|
105
|
+
npx gruff-ts report src --format=html --output gruff-ts.html
|
|
39
106
|
```
|
|
40
107
|
|
|
41
108
|
## Markdown
|
|
42
109
|
|
|
43
|
-
Use `markdown` for pull request comments and
|
|
110
|
+
Use `markdown` for pull request comments and summaries.
|
|
44
111
|
|
|
45
112
|
## GitHub
|
|
46
113
|
|
|
@@ -48,28 +115,36 @@ Use `github` inside GitHub Actions to emit workflow annotations.
|
|
|
48
115
|
|
|
49
116
|
## Hotspot
|
|
50
117
|
|
|
51
|
-
Use `hotspot` for compact score and offender
|
|
118
|
+
Use `hotspot` for the compact score and file-offender list. Its `diagnostics`
|
|
119
|
+
array carries the same scan diagnostics as `json`, such as a
|
|
120
|
+
`bounded-deep-scan` notice.
|
|
52
121
|
|
|
53
122
|
## SARIF
|
|
54
123
|
|
|
55
124
|
Use `sarif` for GitHub code scanning or other SARIF consumers:
|
|
56
125
|
|
|
57
126
|
```sh
|
|
58
|
-
|
|
127
|
+
npx gruff-ts analyse src --format=sarif --fail-on=none > gruff-ts.sarif
|
|
59
128
|
```
|
|
60
129
|
|
|
130
|
+
SARIF stays on version 2.1.0, and `runs[0].properties.gruffSchemaVersion`
|
|
131
|
+
matches `gruff.analysis.v3`.
|
|
132
|
+
|
|
61
133
|
## Summary
|
|
62
134
|
|
|
63
|
-
|
|
135
|
+
JSON summary is the analysis v3 envelope with only the top-level `findings`
|
|
136
|
+
array removed and `schemaVersion` set to `gruff.summary.v3`:
|
|
64
137
|
|
|
65
138
|
```sh
|
|
66
|
-
|
|
139
|
+
npx gruff-ts summary src --format=json --fail-on=none
|
|
67
140
|
```
|
|
68
141
|
|
|
69
|
-
|
|
70
|
-
|
|
142
|
+
The same inputs and flags produce identical `run`, counts, scores, diagnostics,
|
|
143
|
+
paths, suppressions, baseline, diff, and extensions fields. `--top` affects text
|
|
144
|
+
output only. Analysis flags such as `--diff`, `--baseline`, and
|
|
145
|
+
`--generate-baseline` work on `summary` as well.
|
|
71
146
|
|
|
72
147
|
## Exit Codes
|
|
73
148
|
|
|
74
|
-
`analyse` exits `1` when at least one finding meets `--fail-on`.
|
|
149
|
+
`analyse` exits `1` when at least one finding meets `--fail-on`. Pass
|
|
75
150
|
`--fail-on none` for report-only jobs.
|
package/docs/philosophy.md
CHANGED
|
@@ -12,10 +12,10 @@ Used as a hook on an agent's output, gruff-ts is a forcing function, not advice.
|
|
|
12
12
|
|
|
13
13
|
- **Verifiable.** The change can be checked by reading, not by re-deriving what the agent was thinking. The complexity, size, naming, and documentation pillars push toward code whose intent is visible on its face.
|
|
14
14
|
- **Secure where the eye slips.** Human review reliably misses a known set of unsafe patterns - disabled TLS verification, `eval` and dynamic `Function` construction, injection-shaped string building, committed secrets. The security and sensitive-data pillars catch those mechanically so the reviewer does not have to.
|
|
15
|
-
- **Honestly tested.** A test suite should raise confidence, not just coverage. The test-quality pillar flags
|
|
15
|
+
- **Honestly tested.** A test suite should raise confidence, not just coverage. 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 satisfy a "write tests" instruction with padding.
|
|
16
16
|
|
|
17
17
|
## Why documentation is mandatory, even on a private one-liner
|
|
18
18
|
|
|
19
19
|
Coding agents routinely produce code that superficially works while misunderstanding the requirement. The implementation can be plausible and still solve the wrong problem, and that failure is invisible to a reviewer reading only the code.
|
|
20
20
|
|
|
21
|
-
Forcing the agent to state intent, usage, contract, and failure behaviour in prose gives the reviewer something to check the implementation against. The doc comment is a second, independent statement of what the code is meant to do, and a mismatch between that prose and the code is itself a signal that the change needs a deeper look. That is worth the friction even on a one-line private helper, because the cost of a confidently
|
|
21
|
+
Forcing the agent to state intent, usage, contract, and failure behaviour in prose gives the reviewer something to check the implementation against. The doc comment is a second, independent statement of what the code is meant to do, and a mismatch between that prose and the code is itself a signal that the change needs a deeper look. That is worth the friction even on a one-line private helper, because the cost of a confidently wrong agent change is paid by the human who trusted it.
|