@blundergoat/gruff-ts 0.3.1 → 0.4.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +20 -5
  4. package/SECURITY.md +1 -1
  5. package/docs/README.md +0 -1
  6. package/docs/agent-hook.md +14 -2
  7. package/docs/configuration.md +15 -0
  8. package/docs/reports-and-ci.md +21 -0
  9. package/docs/rules.md +22 -12
  10. package/package.json +17 -2
  11. package/src/analyser.ts +410 -122
  12. package/src/baseline-options.ts +90 -0
  13. package/src/blocks.ts +56 -9
  14. package/src/changed-regions.ts +46 -17
  15. package/src/cli-program.ts +103 -4
  16. package/src/cli.ts +3 -2
  17. package/src/constants.ts +1 -1
  18. package/src/dashboard.ts +1 -1
  19. package/src/dead-code-rules.ts +10 -3
  20. package/src/discovery.ts +27 -3
  21. package/src/findings.ts +2 -0
  22. package/src/hook-contract.ts +457 -0
  23. package/src/line-rules.ts +126 -19
  24. package/src/process-exec-metadata.ts +153 -0
  25. package/src/project-config-rules.ts +21 -8
  26. package/src/project-rules.ts +159 -42
  27. package/src/report-renderers.ts +3 -0
  28. package/src/rule-list.ts +1 -0
  29. package/src/rules.ts +5 -5
  30. package/src/sensitive-data-rules.ts +134 -12
  31. package/src/source-text.ts +47 -22
  32. package/src/static-analysis-redundant-rules.ts +46 -2
  33. package/src/types.ts +16 -1
  34. package/docs/releasing.md +0 -106
  35. package/fixtures/sample.ts +0 -21
  36. package/scripts/bump-version.sh +0 -210
  37. package/scripts/check.sh +0 -4
  38. package/scripts/dependency-install.sh +0 -96
  39. package/scripts/dependency-update.sh +0 -177
  40. package/scripts/npm-publish.sh +0 -258
  41. package/scripts/preflight-checks.sh +0 -395
  42. package/scripts/start-dev.sh +0 -8
  43. package/scripts/test-performance.sh +0 -695
  44. package/src/fixtures/rule-catalogue-security-doctrine.ts +0 -160
@@ -1,160 +0,0 @@
1
- // Fixture data covers security rule-quality doctrine added by the M40/M42 scanner expansion.
2
- export const SECURITY_EXPANSION_RISKY_RULE_IDS = [
3
- "security.dynamic-regexp",
4
- "security.github-actions-broad-permissions",
5
- "security.github-actions-pull-request-target",
6
- "security.github-actions-remote-shell",
7
- "security.github-actions-secrets-in-pr",
8
- "security.github-actions-unpinned-action",
9
- "security.open-redirect-candidate",
10
- "security.path-traversal-candidate",
11
- "security.ssrf-candidate",
12
- "security.unsafe-deserialization",
13
- "security.xxe-candidate",
14
- ] as const;
15
-
16
- export const SECURITY_EXPANSION_RULE_QUALITY_DOCTRINE = [
17
- {
18
- ruleId: "security.dynamic-regexp",
19
- signalSource: "same-line source-to-sink scan for external input inside RegExp constructors",
20
- expectedPillar: "security",
21
- expectedSeverity: "warning",
22
- expectedConfidence: "medium",
23
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
24
- invalidFixture: "process.argv or request input passed directly to new RegExp or RegExp",
25
- noisyValidFixture: "fixed literal regular expressions plus prose strings mentioning risky examples",
26
- missingInvalidFixture: "external regular expression construction remains reported when safe literal patterns are nearby",
27
- falsePositiveEscapeHatch: "require an external-input token inside the same constructor call segment",
28
- fingerprintStability: "anchor to the constructor line and keep raw pattern text out of metadata",
29
- },
30
- {
31
- ruleId: "security.github-actions-broad-permissions",
32
- signalSource: "path-gated GitHub Actions workflow scan for permissions: write-all and selected write scopes",
33
- expectedPillar: "security",
34
- expectedSeverity: "warning",
35
- expectedConfidence: "medium",
36
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
37
- invalidFixture: "workflow permissions block granting write-all or repository write scopes",
38
- noisyValidFixture: "read-only permissions, non-workflow YAML examples, and ordinary prose mentioning write access",
39
- missingInvalidFixture: "broad workflow write permissions remain reported beside read-only workflow permissions",
40
- falsePositiveEscapeHatch: "run only on .github/workflows YAML and require a permissions key or scoped write line",
41
- fingerprintStability: "anchor to the permission line with the scope symbol",
42
- },
43
- {
44
- ruleId: "security.github-actions-pull-request-target",
45
- signalSource: "path-gated GitHub Actions workflow scan for pull_request_target plus risky execution context",
46
- expectedPillar: "security",
47
- expectedSeverity: "warning",
48
- expectedConfidence: "medium",
49
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
50
- invalidFixture: "pull_request_target workflow paired with checkout, run, secrets, or write permissions",
51
- noisyValidFixture: "pull_request_target event alone, pull_request workflows, and non-workflow YAML examples",
52
- missingInvalidFixture: "risky pull_request_target context remains reported when safe event-only workflows are nearby",
53
- falsePositiveEscapeHatch: "do not report the event unless a bounded risky context token is also present",
54
- fingerprintStability: "anchor to the pull_request_target event line with sorted riskContext metadata",
55
- },
56
- {
57
- ruleId: "security.github-actions-remote-shell",
58
- signalSource: "path-gated GitHub Actions workflow scan for run steps that pipe curl or wget to a shell",
59
- expectedPillar: "security",
60
- expectedSeverity: "warning",
61
- expectedConfidence: "medium",
62
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
63
- invalidFixture: "workflow run step containing curl or wget from HTTPS piped to sh, bash, or zsh",
64
- noisyValidFixture: "download-only curl commands, package script examples, and prose snippets outside workflow paths",
65
- missingInvalidFixture: "remote shell workflow command remains reported beside safe download-only commands",
66
- falsePositiveEscapeHatch: "require workflow path plus run-step context before matching remote shell text",
67
- fingerprintStability: "anchor to the run command line without including the full downloaded URL",
68
- },
69
- {
70
- ruleId: "security.github-actions-secrets-in-pr",
71
- signalSource: "path-gated GitHub Actions workflow scan for pull request events with secrets references",
72
- expectedPillar: "security",
73
- expectedSeverity: "warning",
74
- expectedConfidence: "medium",
75
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
76
- invalidFixture: "pull_request or pull_request_target workflow referencing secrets.NAME",
77
- noisyValidFixture: "push-only workflows with secrets and pull request workflows without secrets",
78
- missingInvalidFixture: "pull request secret reference remains reported when push-only secret usage is nearby",
79
- falsePositiveEscapeHatch: "require both a pull request style event and a concrete secrets.NAME reference",
80
- fingerprintStability: "anchor to the secret reference line and use the secret name as symbol",
81
- },
82
- {
83
- ruleId: "security.github-actions-unpinned-action",
84
- signalSource: "path-gated GitHub Actions workflow scan for third-party uses entries without 40-character SHA refs",
85
- expectedPillar: "security",
86
- expectedSeverity: "warning",
87
- expectedConfidence: "medium",
88
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
89
- invalidFixture: "third-party workflow action pinned to a tag or branch instead of a full commit SHA",
90
- noisyValidFixture: "GitHub-owned actions, local reusable actions, and third-party actions pinned to a full SHA",
91
- missingInvalidFixture: "third-party tag reference remains reported when official and SHA-pinned actions are nearby",
92
- falsePositiveEscapeHatch: "exclude actions and github owners plus local action paths before checking the ref",
93
- fingerprintStability: "anchor to the uses line with action owner and ref metadata",
94
- },
95
- {
96
- ruleId: "security.open-redirect-candidate",
97
- signalSource: "same-line source-to-sink scan for external input inside redirect or navigation sinks",
98
- expectedPillar: "security",
99
- expectedSeverity: "warning",
100
- expectedConfidence: "medium",
101
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
102
- invalidFixture: "request query or body value passed directly to redirect or location navigation",
103
- noisyValidFixture: "relative redirect literals, fixed navigation targets, and prose strings with redirect examples",
104
- missingInvalidFixture: "external redirect target remains reported when safe relative redirects are nearby",
105
- falsePositiveEscapeHatch: "require an external-input token inside the same redirect or navigation expression",
106
- fingerprintStability: "anchor to the redirect expression line with source and sink kinds only in metadata",
107
- },
108
- {
109
- ruleId: "security.path-traversal-candidate",
110
- signalSource: "same-line source-to-sink scan for external input inside filesystem path APIs",
111
- expectedPillar: "security",
112
- expectedSeverity: "warning",
113
- expectedConfidence: "medium",
114
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
115
- invalidFixture: "request, argv, or environment value passed directly to readFile or writeFile style path sink",
116
- noisyValidFixture: "fixed local paths, predeclared safe path variables, and prose strings with filesystem examples",
117
- missingInvalidFixture: "external filesystem path remains reported when fixed local path calls are nearby",
118
- falsePositiveEscapeHatch: "require an external-input token inside the same filesystem call segment",
119
- fingerprintStability: "anchor to the filesystem call line with source and sink kinds only in metadata",
120
- },
121
- {
122
- ruleId: "security.ssrf-candidate",
123
- signalSource: "same-line source-to-sink scan for external input inside network request APIs",
124
- expectedPillar: "security",
125
- expectedSeverity: "warning",
126
- expectedConfidence: "medium",
127
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
128
- invalidFixture: "request query or body value passed directly to fetch, axios, http.request, or https.request",
129
- noisyValidFixture: "fixed URL literals, safe health-check calls, and prose strings mentioning fetch examples",
130
- missingInvalidFixture: "external network destination remains reported when fixed URL requests are nearby",
131
- falsePositiveEscapeHatch: "require an external-input token inside the same network request call segment",
132
- fingerprintStability: "anchor to the request call line with source and sink kinds only in metadata",
133
- },
134
- {
135
- ruleId: "security.unsafe-deserialization",
136
- signalSource: "syntax-only AST flow scan for external input reaching unsafe deserialization and dynamic code-loading sinks",
137
- expectedPillar: "security",
138
- expectedSeverity: "warning",
139
- expectedConfidence: "medium",
140
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
141
- invalidFixture: "request body, argv, or environment input passed to unserialize, yaml.load, vm execution, eval, or Function",
142
- noisyValidFixture: "safe schema-bound YAML loads, fixed literals, and prose strings with deserialization examples",
143
- missingInvalidFixture: "external serialized data remains reported when safe YAML and fixed literal loads are nearby",
144
- falsePositiveEscapeHatch: "require local external-input flow and accept explicit safe YAML schema evidence",
145
- fingerprintStability: "anchor to the unsafe sink line with source and sink kinds only in metadata",
146
- },
147
- {
148
- ruleId: "security.xxe-candidate",
149
- signalSource: "syntax-only AST flow scan for external XML reaching parsers with entity expansion enabled",
150
- expectedPillar: "security",
151
- expectedSeverity: "warning",
152
- expectedConfidence: "medium",
153
- fixtureCategories: ["valid", "invalid", "noisy-valid", "missing-invalid"],
154
- invalidFixture: "request XML passed to libxmljs or fast-xml-parser calls with entity expansion enabled",
155
- noisyValidFixture: "XML parser calls with entity expansion disabled and prose strings with XML examples",
156
- missingInvalidFixture: "entity-expanding XML parse remains reported when non-expanding parser calls are nearby",
157
- falsePositiveEscapeHatch: "require both external XML flow and local parser options that enable entity expansion",
158
- fingerprintStability: "anchor to the XML parse line with source and sink kinds only in metadata",
159
- },
160
- ] as const;