actions-warden 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/AGENTS.md +46 -8
- package/CONTRIBUTING.md +6 -2
- package/README.md +171 -61
- package/RELEASING.md +3 -2
- package/SECURITY.md +15 -5
- package/docs/AI-AGENTS.md +109 -29
- package/docs/CLI.md +284 -60
- package/docs/CONFIGURATION.md +34 -11
- package/docs/DEVELOPMENT.md +97 -24
- package/docs/GITHUB-ACTION.md +157 -27
- package/docs/JAVASCRIPT-API.md +172 -8
- package/docs/OUTPUTS.md +399 -36
- package/docs/README.md +1 -1
- package/examples/README.md +21 -0
- package/examples/baseline-adoption/README.md +79 -0
- package/examples/baseline-adoption/github-actions.yml +56 -0
- package/examples/baseline-adoption/policy.yml +7 -0
- package/examples/ci-violation-reporting/README.md +82 -0
- package/examples/ci-violation-reporting/github-actions.yml +55 -0
- package/examples/ci-violation-reporting/policy.yml +7 -0
- package/examples/ci-violation-reporting/violating-workflow.yml +17 -0
- package/examples/csv-reporting/README.md +50 -0
- package/examples/csv-reporting/github-actions.yml +59 -0
- package/examples/html-organization-report/README.md +35 -0
- package/examples/html-organization-report/github-actions.yml +61 -0
- package/examples/notifications/README.md +67 -0
- package/examples/notifications/github-actions.yml +163 -0
- package/examples/org-scan.yml +24 -5
- package/examples/sarif-code-scanning/README.md +42 -0
- package/examples/sarif-code-scanning/github-actions.yml +66 -0
- package/examples/upgrade-pr.yml +1 -1
- package/llms.txt +14 -5
- package/package.json +8 -4
- package/skills/actions-warden/SKILL.md +78 -35
- package/src/action.js +351 -174
- package/src/cli.js +191 -177
- package/src/commands/audit.js +17 -30
- package/src/commands/org-scan.js +451 -280
- package/src/commands/pin.js +9 -5
- package/src/commands/report.js +7 -2
- package/src/commands/upgrade.js +9 -5
- package/src/commands/verify.js +24 -4
- package/src/index.js +5 -1
- package/src/lib/action-summary.js +656 -0
- package/src/lib/annotations.js +4 -6
- package/src/lib/baseline.js +11 -1
- package/src/lib/config.js +10 -5
- package/src/lib/destination.js +98 -0
- package/src/lib/execution.js +5 -1
- package/src/lib/formats/csv.js +125 -0
- package/src/lib/formats/html.js +394 -0
- package/src/lib/formats/json.js +17 -0
- package/src/lib/formats/sarif.js +229 -0
- package/src/lib/formats/text.js +30 -0
- package/src/lib/formats/toon.js +50 -0
- package/src/lib/formatter.js +25 -192
- package/src/lib/github-org.js +208 -102
- package/src/lib/org-artifacts.js +211 -0
- package/src/lib/org-checkpoint.js +137 -96
- package/src/lib/org-progress.js +182 -4
- package/src/lib/org-report-comparison.js +505 -0
- package/src/lib/org-report-directory.js +251 -0
- package/src/lib/org-report.js +223 -0
- package/src/lib/org-run.js +305 -0
- package/src/lib/org-schema.js +89 -0
- package/src/lib/org-source-links.js +39 -0
- package/src/lib/parser.js +5 -0
- package/src/lib/paths.js +18 -1
- package/src/lib/redact.js +58 -7
- package/src/lib/resolver.js +66 -9
- package/src/lib/types.js +137 -0
- package/src/rules/pull-request-target-checkout.js +5 -0
- package/src/rules/unpinned-action.js +2 -3
- package/src/rules/workflow-structure.js +2 -4
- package/src/version.js +1 -1
- package/src/lib/agent-mode.js +0 -174
package/src/commands/pin.js
CHANGED
|
@@ -17,8 +17,7 @@ import { pinOccurrenceId, canonicalPath } from '../lib/identity.js';
|
|
|
17
17
|
import { applyPatches, planUsesPatches } from '../lib/patcher.js';
|
|
18
18
|
import { resolveTargets } from '../lib/targets.js';
|
|
19
19
|
import { mapLimit } from '../lib/concurrency.js';
|
|
20
|
-
|
|
21
|
-
const SHA_RE = /^[0-9a-f]{40}$/i;
|
|
20
|
+
import { GIT_SHA_RE } from '../lib/org-schema.js';
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* @typedef {object} PinChange
|
|
@@ -69,7 +68,7 @@ export async function pin({ cwd = process.cwd(), workflows, dryRun = true, token
|
|
|
69
68
|
const ignore = parseIgnoreDirectives(source);
|
|
70
69
|
for (const { ref } of collectUses(doc)) {
|
|
71
70
|
if (ref.kind !== 'external' && ref.kind !== 'reusable-workflow') continue;
|
|
72
|
-
if (!ref.ref ||
|
|
71
|
+
if (!ref.ref || GIT_SHA_RE.test(ref.ref)) continue;
|
|
73
72
|
if (isIgnored(ignore, ref.line, 'unpinned-action')) continue;
|
|
74
73
|
const id = pinOccurrenceId({ file, cwd, ref });
|
|
75
74
|
if (fix && fix !== id) continue;
|
|
@@ -155,7 +154,8 @@ export function rewriteUses(source, ref, sha) {
|
|
|
155
154
|
|
|
156
155
|
/**
|
|
157
156
|
* @param {Awaited<ReturnType<typeof pin>>} result
|
|
158
|
-
* @param {{format: 'toon'|'json'|'text', dryRun: boolean,
|
|
157
|
+
* @param {{format: 'toon'|'json'|'text'|'csv'|'sarif'|'html', dryRun: boolean,
|
|
158
|
+
* cwd?: string}} opts
|
|
159
159
|
*/
|
|
160
160
|
export function renderPin(result, opts) {
|
|
161
161
|
const cwd = opts.cwd ?? process.cwd();
|
|
@@ -194,7 +194,11 @@ export function renderPin(result, opts) {
|
|
|
194
194
|
records.push({ label: 'ERROR', fields: { file: rel(e.file ?? '', cwd), action: e.action ?? '', msg: e.error } });
|
|
195
195
|
}
|
|
196
196
|
records.push({ label: 'SUMMARY', fields: { changes: result.changes.length, errors: result.errors.length, dry_run: opts.dryRun } });
|
|
197
|
-
return format(opts.format, records, {
|
|
197
|
+
return format(opts.format, records, {
|
|
198
|
+
status: result.status,
|
|
199
|
+
title: opts.dryRun ? 'Action pin plan' : 'Applied action pins',
|
|
200
|
+
metadata: { mode: opts.dryRun ? 'dry run' : 'write' },
|
|
201
|
+
});
|
|
198
202
|
}
|
|
199
203
|
|
|
200
204
|
function rel(p, cwd) {
|
package/src/commands/report.js
CHANGED
|
@@ -79,7 +79,8 @@ export async function report({
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* @param {Awaited<ReturnType<typeof report>>} result
|
|
82
|
-
* @param {{format: 'toon'|'json'|'text', mode: string,
|
|
82
|
+
* @param {{format: 'toon'|'json'|'text'|'csv'|'sarif'|'html', mode: string,
|
|
83
|
+
* cwd?: string}} opts
|
|
83
84
|
*/
|
|
84
85
|
export function renderReport(result, opts) {
|
|
85
86
|
const cwd = opts.cwd ?? process.cwd();
|
|
@@ -197,7 +198,11 @@ export function renderReport(result, opts) {
|
|
|
197
198
|
offline: result.offline,
|
|
198
199
|
},
|
|
199
200
|
});
|
|
200
|
-
return format(opts.format, records, {
|
|
201
|
+
return format(opts.format, records, {
|
|
202
|
+
status: result.status,
|
|
203
|
+
title: 'Security and dependency report',
|
|
204
|
+
metadata: { upgradeMode: opts.mode, offline: result.offline },
|
|
205
|
+
});
|
|
201
206
|
}
|
|
202
207
|
|
|
203
208
|
function rel(p, cwd) {
|
package/src/commands/upgrade.js
CHANGED
|
@@ -24,10 +24,9 @@ import { parseIgnoreDirectives, isIgnored } from '../lib/ignore.js';
|
|
|
24
24
|
import { format } from '../lib/formatter.js';
|
|
25
25
|
import { occurrenceId, canonicalPath } from '../lib/identity.js';
|
|
26
26
|
import { applyPatches, planUsesPatches, readVersionComment } from '../lib/patcher.js';
|
|
27
|
+
import { GIT_SHA_RE } from '../lib/org-schema.js';
|
|
27
28
|
import { resolveTargets } from '../lib/targets.js';
|
|
28
29
|
|
|
29
|
-
const SHA_RE = /^[0-9a-f]{40}$/i;
|
|
30
|
-
|
|
31
30
|
/**
|
|
32
31
|
* @typedef {object} UpgradeChange
|
|
33
32
|
* @property {string} id
|
|
@@ -93,7 +92,7 @@ export async function upgrade({
|
|
|
93
92
|
if (ref.kind !== 'external' && ref.kind !== 'reusable-workflow') continue;
|
|
94
93
|
if (isIgnored(ignore, ref.line, 'unpinned-action')) continue;
|
|
95
94
|
const inlineVersion = readVersionComment(source, ref);
|
|
96
|
-
const currentVersion = ref.ref &&
|
|
95
|
+
const currentVersion = ref.ref && GIT_SHA_RE.test(ref.ref) ? inlineVersion : ref.ref;
|
|
97
96
|
if (!currentVersion) continue;
|
|
98
97
|
const id = occurrenceId({
|
|
99
98
|
kind: 'upgrade',
|
|
@@ -258,7 +257,8 @@ function bumpLevel(from, to) {
|
|
|
258
257
|
|
|
259
258
|
/**
|
|
260
259
|
* @param {Awaited<ReturnType<typeof upgrade>>} result
|
|
261
|
-
* @param {{format: 'toon'|'json'|'text', dryRun: boolean,
|
|
260
|
+
* @param {{format: 'toon'|'json'|'text'|'csv'|'sarif'|'html', dryRun: boolean,
|
|
261
|
+
* mode: string, cwd?: string}} opts
|
|
262
262
|
*/
|
|
263
263
|
export function renderUpgrade(result, opts) {
|
|
264
264
|
const cwd = opts.cwd ?? process.cwd();
|
|
@@ -313,7 +313,11 @@ export function renderUpgrade(result, opts) {
|
|
|
313
313
|
records.push({ label: 'ERROR', fields: { file: rel(e.file ?? '', cwd), action: e.action ?? '', msg: e.error } });
|
|
314
314
|
}
|
|
315
315
|
records.push({ label: 'SUMMARY', fields: { changes: result.changes.length, skipped: (result.skipped ?? []).length, errors: result.errors.length, mode: opts.mode, dry_run: opts.dryRun } });
|
|
316
|
-
return format(opts.format, records, {
|
|
316
|
+
return format(opts.format, records, {
|
|
317
|
+
status: result.status,
|
|
318
|
+
title: opts.dryRun ? 'Action upgrade plan' : 'Applied action upgrades',
|
|
319
|
+
metadata: { mode: opts.mode, operation: opts.dryRun ? 'dry run' : 'write' },
|
|
320
|
+
});
|
|
317
321
|
}
|
|
318
322
|
|
|
319
323
|
function rel(p, cwd) {
|
package/src/commands/verify.js
CHANGED
|
@@ -10,9 +10,19 @@ import { readVersionComment } from '../lib/patcher.js';
|
|
|
10
10
|
import { occurrenceId, canonicalPath } from '../lib/identity.js';
|
|
11
11
|
import { format } from '../lib/formatter.js';
|
|
12
12
|
import { mapLimit } from '../lib/concurrency.js';
|
|
13
|
+
import { GIT_SHA_RE } from '../lib/org-schema.js';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Verify that external action references are full repository-owned commit
|
|
17
|
+
* SHAs and that optional actions-warden version metadata resolves to the same
|
|
18
|
+
* commit.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} [options]
|
|
21
|
+
* @param {string} [options.cwd]
|
|
22
|
+
* @param {string[]} [options.workflows]
|
|
23
|
+
* @param {string} [options.token]
|
|
24
|
+
* @returns {Promise<{files: string[], checks: object[], warnings: object[], errors: object[], status: 'OK'|'FAIL'}>}
|
|
25
|
+
*/
|
|
16
26
|
export async function verify({ cwd = process.cwd(), workflows, token } = {}) {
|
|
17
27
|
const files = await resolveTargets({ workflows, cwd });
|
|
18
28
|
const resolvedToken = resolveToken(token);
|
|
@@ -43,7 +53,7 @@ export async function verify({ cwd = process.cwd(), workflows, token } = {}) {
|
|
|
43
53
|
start: ref.start,
|
|
44
54
|
subject: ref.raw,
|
|
45
55
|
});
|
|
46
|
-
if (!ref.ref || !
|
|
56
|
+
if (!ref.ref || !GIT_SHA_RE.test(ref.ref)) {
|
|
47
57
|
return { type: 'error', value: {
|
|
48
58
|
id,
|
|
49
59
|
file,
|
|
@@ -123,6 +133,13 @@ export async function verify({ cwd = process.cwd(), workflows, token } = {}) {
|
|
|
123
133
|
};
|
|
124
134
|
}
|
|
125
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Render a verification result in a supported public output format.
|
|
138
|
+
*
|
|
139
|
+
* @param {Awaited<ReturnType<typeof verify>>} result
|
|
140
|
+
* @param {{format: 'toon'|'json'|'text'|'csv'|'sarif'|'html', cwd?: string}} options
|
|
141
|
+
* @returns {string}
|
|
142
|
+
*/
|
|
126
143
|
export function renderVerify(result, { format: outputFormat, cwd = process.cwd() }) {
|
|
127
144
|
if (outputFormat === 'json') {
|
|
128
145
|
return format('json', [], {
|
|
@@ -189,5 +206,8 @@ export function renderVerify(result, { format: outputFormat, cwd = process.cwd()
|
|
|
189
206
|
errors: result.errors.length,
|
|
190
207
|
},
|
|
191
208
|
});
|
|
192
|
-
return format(outputFormat, records, {
|
|
209
|
+
return format(outputFormat, records, {
|
|
210
|
+
status: result.status,
|
|
211
|
+
title: 'Pinned action verification',
|
|
212
|
+
});
|
|
193
213
|
}
|
package/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export { verify, renderVerify } from './commands/verify.js';
|
|
|
15
15
|
export { scanOrganization, renderOrganizationScan } from './commands/org-scan.js';
|
|
16
16
|
export { listRules } from './rules/index.js';
|
|
17
17
|
export { parseWorkflowFile, parseWorkflowSource, collectUses, collectImages, parseActionRef } from './lib/parser.js';
|
|
18
|
-
export { format, renderToon, renderJson, renderText, renderSarif, summarize, SEVERITY_ORDER } from './lib/formatter.js';
|
|
18
|
+
export { format, renderToon, renderJson, renderText, renderCsv, renderSarif, renderHtml, summarize, SEVERITY_ORDER } from './lib/formatter.js';
|
|
19
19
|
export { discoverWorkflows } from './lib/paths.js';
|
|
20
20
|
export { redact } from './lib/redact.js';
|
|
21
21
|
export { parseIgnoreDirectives, isIgnored } from './lib/ignore.js';
|
|
@@ -34,3 +34,7 @@ export {
|
|
|
34
34
|
loadBaseline,
|
|
35
35
|
serializeBaseline,
|
|
36
36
|
} from './lib/baseline.js';
|
|
37
|
+
export {
|
|
38
|
+
compareOrganizationReports,
|
|
39
|
+
loadOrganizationReport,
|
|
40
|
+
} from './lib/org-report-comparison.js';
|