actions-warden 0.3.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.
Files changed (78) hide show
  1. package/AGENTS.md +60 -12
  2. package/CONTRIBUTING.md +6 -2
  3. package/README.md +180 -58
  4. package/RELEASING.md +3 -2
  5. package/SECURITY.md +23 -8
  6. package/docs/AI-AGENTS.md +125 -29
  7. package/docs/CLI.md +346 -69
  8. package/docs/CONFIGURATION.md +34 -11
  9. package/docs/DEVELOPMENT.md +114 -18
  10. package/docs/GITHUB-ACTION.md +163 -29
  11. package/docs/JAVASCRIPT-API.md +177 -11
  12. package/docs/OUTPUTS.md +408 -40
  13. package/docs/README.md +1 -1
  14. package/examples/README.md +21 -0
  15. package/examples/baseline-adoption/README.md +79 -0
  16. package/examples/baseline-adoption/github-actions.yml +56 -0
  17. package/examples/baseline-adoption/policy.yml +7 -0
  18. package/examples/ci-violation-reporting/README.md +82 -0
  19. package/examples/ci-violation-reporting/github-actions.yml +55 -0
  20. package/examples/ci-violation-reporting/policy.yml +7 -0
  21. package/examples/ci-violation-reporting/violating-workflow.yml +17 -0
  22. package/examples/csv-reporting/README.md +50 -0
  23. package/examples/csv-reporting/github-actions.yml +59 -0
  24. package/examples/html-organization-report/README.md +35 -0
  25. package/examples/html-organization-report/github-actions.yml +61 -0
  26. package/examples/notifications/README.md +67 -0
  27. package/examples/notifications/github-actions.yml +163 -0
  28. package/examples/org-scan.yml +24 -5
  29. package/examples/sarif-code-scanning/README.md +42 -0
  30. package/examples/sarif-code-scanning/github-actions.yml +66 -0
  31. package/examples/upgrade-pr.yml +1 -1
  32. package/llms.txt +14 -5
  33. package/package.json +8 -4
  34. package/skills/actions-warden/SKILL.md +91 -39
  35. package/src/action.js +353 -187
  36. package/src/cli.js +416 -209
  37. package/src/commands/audit.js +17 -30
  38. package/src/commands/org-scan.js +452 -286
  39. package/src/commands/pin.js +9 -5
  40. package/src/commands/report.js +7 -2
  41. package/src/commands/upgrade.js +9 -5
  42. package/src/commands/verify.js +24 -4
  43. package/src/index.js +5 -1
  44. package/src/lib/action-summary.js +656 -0
  45. package/src/lib/annotations.js +4 -6
  46. package/src/lib/baseline.js +11 -1
  47. package/src/lib/config.js +10 -5
  48. package/src/lib/destination.js +98 -0
  49. package/src/lib/execution.js +5 -1
  50. package/src/lib/formats/csv.js +125 -0
  51. package/src/lib/formats/html.js +394 -0
  52. package/src/lib/formats/json.js +17 -0
  53. package/src/lib/formats/sarif.js +229 -0
  54. package/src/lib/formats/text.js +30 -0
  55. package/src/lib/formats/toon.js +50 -0
  56. package/src/lib/formatter.js +25 -192
  57. package/src/lib/github-org.js +208 -102
  58. package/src/lib/org-artifacts.js +211 -0
  59. package/src/lib/org-checkpoint.js +159 -35
  60. package/src/lib/org-progress.js +182 -4
  61. package/src/lib/org-report-comparison.js +505 -0
  62. package/src/lib/org-report-directory.js +251 -0
  63. package/src/lib/org-report.js +223 -0
  64. package/src/lib/org-run.js +305 -0
  65. package/src/lib/org-schema.js +89 -0
  66. package/src/lib/org-source-links.js +39 -0
  67. package/src/lib/parser.js +5 -0
  68. package/src/lib/path-equality.js +30 -0
  69. package/src/lib/paths.js +18 -1
  70. package/src/lib/redact.js +58 -7
  71. package/src/lib/resolver.js +66 -9
  72. package/src/lib/types.js +137 -0
  73. package/src/lib/writer.js +3 -0
  74. package/src/rules/pull-request-target-checkout.js +5 -0
  75. package/src/rules/unpinned-action.js +2 -3
  76. package/src/rules/workflow-structure.js +2 -4
  77. package/src/version.js +1 -1
  78. package/src/lib/agent-mode.js +0 -175
@@ -16,20 +16,11 @@ import { format, summarize, SEVERITY_ORDER } from '../lib/formatter.js';
16
16
  import { parseIgnoreDirectives, isIgnored } from '../lib/ignore.js';
17
17
  import { canonicalPath, occurrenceId, pinOccurrenceId } from '../lib/identity.js';
18
18
  import { resolveTargets } from '../lib/targets.js';
19
- import { assignBaselineFingerprints, loadBaseline } from '../lib/baseline.js';
19
+ import { assignBaselineFingerprints, emptyBaseline, loadBaseline } from '../lib/baseline.js';
20
20
  import { DEFAULT_CONFIG, filterIgnoredPaths, loadConfig } from '../lib/config.js';
21
21
  import { RULES } from '../rules/index.js';
22
22
 
23
- /**
24
- * @typedef {object} Finding
25
- * @property {string} id - unique id (sha1 short)
26
- * @property {string} ruleId
27
- * @property {string} severity
28
- * @property {string} file
29
- * @property {number} line
30
- * @property {Record<string, unknown>} fields
31
- * @property {string} explain
32
- */
23
+ /** @typedef {import('../lib/types.js').Finding} Finding */
33
24
 
34
25
  /**
35
26
  * @param {object} opts
@@ -227,20 +218,12 @@ async function resolveBaselineData({ baseline, cwd }) {
227
218
  : emptyBaseline();
228
219
  }
229
220
 
230
- function emptyBaseline() {
231
- return { path: null, ids: new Set(), fingerprints: new Set() };
232
- }
233
-
234
221
  function stripExplain(f) {
235
222
  const copy = { ...f };
236
223
  delete copy.explain;
237
224
  return copy;
238
225
  }
239
226
 
240
- /**
241
- * @param {string[]|undefined} workflows
242
- * @param {string} cwd
243
- */
244
227
  /**
245
228
  * @param {Finding[]} findings
246
229
  * @param {string|undefined} min
@@ -255,15 +238,12 @@ function filterBySeverity(findings, min) {
255
238
  ));
256
239
  }
257
240
 
258
- function relPath(p, cwd) {
259
- return canonicalPath(p, cwd);
260
- }
261
-
262
241
  /**
263
242
  * Render an audit result to the chosen format.
264
243
  *
265
244
  * @param {Awaited<ReturnType<typeof audit>>} result
266
- * @param {{format: 'toon'|'json'|'text', explain?: boolean, cwd?: string}} opts
245
+ * @param {{format: 'toon'|'json'|'text'|'csv'|'sarif'|'html', explain?: boolean,
246
+ * cwd?: string}} opts
267
247
  */
268
248
  export function renderAudit(result, opts) {
269
249
  const cwd = opts.cwd ?? process.cwd();
@@ -272,14 +252,14 @@ export function renderAudit(result, opts) {
272
252
  status: result.status,
273
253
  json: {
274
254
  schemaVersion: '1.0',
275
- files: result.files.map(f => relPath(f, cwd)),
276
- findings: result.findings.map(f => ({ ...f, file: relPath(f.file, cwd) })),
255
+ files: result.files.map(f => canonicalPath(f, cwd)),
256
+ findings: result.findings.map(f => ({ ...f, file: canonicalPath(f.file, cwd) })),
277
257
  summary: result.summary,
278
258
  baseline: {
279
259
  ...result.baseline,
280
- path: result.baseline.path ? relPath(result.baseline.path, cwd) : null,
260
+ path: result.baseline.path ? canonicalPath(result.baseline.path, cwd) : null,
281
261
  },
282
- configPath: result.configPath ? relPath(result.configPath, cwd) : null,
262
+ configPath: result.configPath ? canonicalPath(result.configPath, cwd) : null,
283
263
  status: result.status,
284
264
  },
285
265
  });
@@ -299,7 +279,7 @@ export function renderAudit(result, opts) {
299
279
  }
300
280
  }
301
281
  for (const f of result.files) {
302
- records.push({ label: 'SCAN', fields: { file: relPath(f, opts.cwd ?? process.cwd()) } });
282
+ records.push({ label: 'SCAN', fields: { file: canonicalPath(f, opts.cwd ?? process.cwd()) } });
303
283
  }
304
284
  for (const finding of result.findings) {
305
285
  const fields = { id: finding.id, ...finding.fields, line: finding.line };
@@ -310,5 +290,12 @@ export function renderAudit(result, opts) {
310
290
  records.push({ label: 'FINDING', fields });
311
291
  }
312
292
  records.push({ label: 'SUMMARY', fields: result.summary });
313
- return format(opts.format, records, { status: result.status });
293
+ return format(opts.format, records, {
294
+ status: result.status,
295
+ title: 'Workflow security audit',
296
+ metadata: {
297
+ config: result.configPath ? canonicalPath(result.configPath, cwd) : 'built-in defaults',
298
+ baseline: result.baseline.path ? canonicalPath(result.baseline.path, cwd) : 'none',
299
+ },
300
+ });
314
301
  }