putitoutthere 0.1.43 → 0.1.45
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 +115 -0
- package/MIGRATIONS.md +632 -0
- package/README.md +342 -94
- package/action.yml +5 -5
- package/dist/action.js +2 -2
- package/dist/action.js.map +1 -1
- package/dist/cascade.d.ts +1 -1
- package/dist/cascade.js +2 -2
- package/dist/cli.d.ts +9 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -426
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +13 -61
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -45
- package/dist/config.js.map +1 -1
- package/dist/git.js +1 -1
- package/dist/git.js.map +1 -1
- package/dist/handlers/npm-platform.d.ts.map +1 -1
- package/dist/handlers/npm-platform.js +5 -1
- package/dist/handlers/npm-platform.js.map +1 -1
- package/dist/handlers/pypi.d.ts.map +1 -1
- package/dist/handlers/pypi.js +29 -6
- package/dist/handlers/pypi.js.map +1 -1
- package/dist/plan.d.ts +0 -1
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +19 -18
- package/dist/plan.js.map +1 -1
- package/dist/preflight.js +1 -1
- package/dist/preflight.js.map +1 -1
- package/dist/publish.d.ts +0 -10
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +6 -52
- package/dist/publish.js.map +1 -1
- package/dist/types.d.ts +1 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -3
- package/dist/auth.d.ts +0 -68
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -285
- package/dist/auth.js.map +0 -1
- package/dist/doctor.d.ts +0 -115
- package/dist/doctor.d.ts.map +0 -1
- package/dist/doctor.js +0 -292
- package/dist/doctor.js.map +0 -1
- package/dist/init.d.ts +0 -59
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -181
- package/dist/init.js.map +0 -1
- package/dist/keyring.d.ts +0 -35
- package/dist/keyring.d.ts.map +0 -1
- package/dist/keyring.js +0 -88
- package/dist/keyring.js.map +0 -1
- package/dist/oidc-policy.d.ts +0 -145
- package/dist/oidc-policy.d.ts.map +0 -1
- package/dist/oidc-policy.js +0 -383
- package/dist/oidc-policy.js.map +0 -1
- package/dist/preflight-run.d.ts +0 -47
- package/dist/preflight-run.d.ts.map +0 -1
- package/dist/preflight-run.js +0 -197
- package/dist/preflight-run.js.map +0 -1
- package/dist/registries/crates-trust.d.ts +0 -69
- package/dist/registries/crates-trust.d.ts.map +0 -1
- package/dist/registries/crates-trust.js +0 -95
- package/dist/registries/crates-trust.js.map +0 -1
- package/dist/release.d.ts +0 -36
- package/dist/release.d.ts.map +0 -1
- package/dist/release.js +0 -102
- package/dist/release.js.map +0 -1
- package/dist/templates.d.ts +0 -43
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -310
- package/dist/templates.js.map +0 -1
- package/dist/token-scope.d.ts +0 -65
- package/dist/token-scope.d.ts.map +0 -1
- package/dist/token-scope.js +0 -163
- package/dist/token-scope.js.map +0 -1
- package/dist/token.d.ts +0 -211
- package/dist/token.d.ts.map +0 -1
- package/dist/token.js +0 -719
- package/dist/token.js.map +0 -1
package/dist/keyring.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Keyring — persistent storage for the user access token obtained
|
|
3
|
-
* through `auth login`.
|
|
4
|
-
*
|
|
5
|
-
* Ships with a file-backed implementation (chmod 0600 in an XDG-
|
|
6
|
-
* compliant config dir). The `Keyring` interface is the seam for
|
|
7
|
-
* swapping in an OS keychain binding (e.g. `keytar`) later; see #105.
|
|
8
|
-
*
|
|
9
|
-
* Token values are never logged. Callers pass the whole `StoredAuth`
|
|
10
|
-
* in and out; this module does not expose a "read just the access
|
|
11
|
-
* token" affordance that could encourage stringification.
|
|
12
|
-
*/
|
|
13
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
14
|
-
import { homedir } from 'node:os';
|
|
15
|
-
import { join } from 'node:path';
|
|
16
|
-
export function fileKeyring(opts = {}) {
|
|
17
|
-
const dir = opts.dir ?? defaultConfigDir();
|
|
18
|
-
const path = join(dir, 'auth.json');
|
|
19
|
-
return {
|
|
20
|
-
get() {
|
|
21
|
-
if (!existsSync(path))
|
|
22
|
-
return Promise.resolve(null);
|
|
23
|
-
const raw = readFileSync(path, 'utf8');
|
|
24
|
-
return Promise.resolve(tryParse(raw));
|
|
25
|
-
},
|
|
26
|
-
set(auth) {
|
|
27
|
-
if (!existsSync(dir)) {
|
|
28
|
-
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// Best-effort tighten; harmless if we don't own the dir.
|
|
32
|
-
/* v8 ignore next -- catch only fires when another process owns the dir; not reachable in unit tests. */
|
|
33
|
-
try {
|
|
34
|
-
chmodSync(dir, 0o700);
|
|
35
|
-
}
|
|
36
|
-
catch { /* ignore */ }
|
|
37
|
-
}
|
|
38
|
-
writeFileSync(path, JSON.stringify(auth, null, 2) + '\n', { mode: 0o600 });
|
|
39
|
-
// writeFileSync honors `mode` only on create. Re-chmod to catch
|
|
40
|
-
// the overwrite-an-existing-file case where the old mode sticks.
|
|
41
|
-
chmodSync(path, 0o600);
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
},
|
|
44
|
-
delete() {
|
|
45
|
-
if (existsSync(path))
|
|
46
|
-
rmSync(path);
|
|
47
|
-
return Promise.resolve();
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/** Returned for production callers. */
|
|
52
|
-
export function defaultKeyring() {
|
|
53
|
-
return fileKeyring();
|
|
54
|
-
}
|
|
55
|
-
/* v8 ignore next 5 -- resolves the user's config dir; tests inject `dir` directly so this branch is only taken in production. */
|
|
56
|
-
function defaultConfigDir() {
|
|
57
|
-
const xdg = process.env.XDG_CONFIG_HOME;
|
|
58
|
-
if (xdg && xdg.length > 0)
|
|
59
|
-
return join(xdg, 'putitoutthere');
|
|
60
|
-
return join(homedir(), '.config', 'putitoutthere');
|
|
61
|
-
}
|
|
62
|
-
function tryParse(raw) {
|
|
63
|
-
let v;
|
|
64
|
-
try {
|
|
65
|
-
v = JSON.parse(raw);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
if (!v || typeof v !== 'object')
|
|
71
|
-
return null;
|
|
72
|
-
const o = v;
|
|
73
|
-
if (typeof o.account !== 'string' ||
|
|
74
|
-
typeof o.access_token !== 'string' ||
|
|
75
|
-
typeof o.refresh_token !== 'string' ||
|
|
76
|
-
typeof o.access_token_expires_at !== 'number' ||
|
|
77
|
-
typeof o.refresh_token_expires_at !== 'number') {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
account: o.account,
|
|
82
|
-
access_token: o.access_token,
|
|
83
|
-
refresh_token: o.refresh_token,
|
|
84
|
-
access_token_expires_at: o.access_token_expires_at,
|
|
85
|
-
refresh_token_expires_at: o.refresh_token_expires_at,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=keyring.js.map
|
package/dist/keyring.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyring.js","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAwBjC,MAAM,UAAU,WAAW,CAAC,OAA2B,EAAE;IACvD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAC;IA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` uses this module to check the locally-knowable structural
|
|
5
|
-
* prerequisites of OIDC trusted publishing:
|
|
6
|
-
*
|
|
7
|
-
* 1. At least one `.github/workflows/*.yml` file invokes either
|
|
8
|
-
* `putitoutthere publish` (as a `run:` command) or the composite
|
|
9
|
-
* action `thekevinscott/put-it-out-there@...` with a `command:`
|
|
10
|
-
* input that implies publishing.
|
|
11
|
-
* 2. That workflow's publishing job has `permissions: id-token: write`
|
|
12
|
-
* and `contents: write` (either job-level or workflow-level).
|
|
13
|
-
* 3. The publishing job has an `environment:` key set. We cannot
|
|
14
|
-
* validate the *value* against the registry's trust policy — that
|
|
15
|
-
* requires a registry-policy-read API per registry, which is
|
|
16
|
-
* deferred (Option C, see follow-up to #162).
|
|
17
|
-
* 4. A clearly-identifiable publish step exists — defends against
|
|
18
|
-
* edge cases like commented-out steps slipping past (1).
|
|
19
|
-
*
|
|
20
|
-
* The parser is intentionally regex/line-based rather than a full YAML
|
|
21
|
-
* parse: the four checks above all reduce to substring/indentation
|
|
22
|
-
* matches within a single jobs block. Adding a YAML dependency would
|
|
23
|
-
* buy us very little here. If the check set grows beyond this (e.g.
|
|
24
|
-
* "validate the environment value against a registry's trust policy"),
|
|
25
|
-
* revisit.
|
|
26
|
-
*
|
|
27
|
-
* Issue #162 — Option D (locally-knowable checks only).
|
|
28
|
-
*/
|
|
29
|
-
export interface WorkflowFile {
|
|
30
|
-
/** Absolute path to the workflow file on disk. */
|
|
31
|
-
path: string;
|
|
32
|
-
/** Basename, e.g. `release.yml`. */
|
|
33
|
-
filename: string;
|
|
34
|
-
/** Full file contents. */
|
|
35
|
-
source: string;
|
|
36
|
-
/** Parsed jobs (best-effort; top-level job keys + their raw bodies). */
|
|
37
|
-
jobs: WorkflowJob[];
|
|
38
|
-
/** Workflow-level `permissions:` block contents (empty if none). */
|
|
39
|
-
workflowPermissions: string;
|
|
40
|
-
}
|
|
41
|
-
export interface WorkflowJob {
|
|
42
|
-
/** Job key, e.g. `publish`. */
|
|
43
|
-
name: string;
|
|
44
|
-
/** Raw source of just that job block (everything indented under it). */
|
|
45
|
-
source: string;
|
|
46
|
-
}
|
|
47
|
-
export interface PermissionIssue {
|
|
48
|
-
kind: 'missing-permission';
|
|
49
|
-
workflow: string;
|
|
50
|
-
job: string;
|
|
51
|
-
permission: 'id-token: write' | 'contents: write';
|
|
52
|
-
}
|
|
53
|
-
export interface EnvironmentIssue {
|
|
54
|
-
kind: 'missing-environment';
|
|
55
|
-
workflow: string;
|
|
56
|
-
job: string;
|
|
57
|
-
}
|
|
58
|
-
export interface InvocationIssue {
|
|
59
|
-
kind: 'no-publish-step';
|
|
60
|
-
workflow: string;
|
|
61
|
-
}
|
|
62
|
-
/** Issue: declared `trust_policy.workflow` does not match the workflow we found. */
|
|
63
|
-
export interface WorkflowFilenameMismatch {
|
|
64
|
-
kind: 'workflow-filename-mismatch';
|
|
65
|
-
declared: string;
|
|
66
|
-
actual: string;
|
|
67
|
-
/** Where `actual` came from — used to refine the error message. */
|
|
68
|
-
source: 'local-workflow' | 'github-workflow-ref';
|
|
69
|
-
}
|
|
70
|
-
/** Issue: declared `trust_policy.environment` does not match the workflow. */
|
|
71
|
-
export interface EnvironmentMismatch {
|
|
72
|
-
kind: 'environment-mismatch';
|
|
73
|
-
workflow: string;
|
|
74
|
-
declared: string;
|
|
75
|
-
actual: string | null;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Scan `.github/workflows/*.yml` and `*.yaml` for workflows that invoke
|
|
79
|
-
* `putitoutthere publish` or the composite action in a publish mode.
|
|
80
|
-
*
|
|
81
|
-
* Permissive by design: if a workflow *mentions* piot in any way that
|
|
82
|
-
* looks like publishing, include it. Downstream checks then report
|
|
83
|
-
* specifically. The cost of a false-positive is a spurious pass/fail
|
|
84
|
-
* line in `doctor`; the cost of a false-negative is silently missing
|
|
85
|
-
* the user's real publish workflow.
|
|
86
|
-
*/
|
|
87
|
-
export declare function findPublishWorkflows(repoRoot: string): WorkflowFile[];
|
|
88
|
-
/**
|
|
89
|
-
* Best-effort jobs parser. Finds the top-level `jobs:` block and
|
|
90
|
-
* extracts each direct-child key + its body. We use the two-space
|
|
91
|
-
* indent convention GitHub Actions workflows follow. Workflows that
|
|
92
|
-
* deviate (tabs, four-space) would miss — but `init` emits two-space,
|
|
93
|
-
* which is what we're validating.
|
|
94
|
-
*/
|
|
95
|
-
export declare function parseJobs(source: string): WorkflowJob[];
|
|
96
|
-
/**
|
|
97
|
-
* Check that the publishing job has (or inherits) the two permissions
|
|
98
|
-
* that OIDC trusted publishing requires. The permissions may be set at
|
|
99
|
-
* workflow level (top-level `permissions:`) and/or job level; this
|
|
100
|
-
* function reports a missing permission only if *neither* scope
|
|
101
|
-
* declares it. `write-all` satisfies both.
|
|
102
|
-
*/
|
|
103
|
-
export declare function checkPermissions(workflow: WorkflowFile): PermissionIssue[];
|
|
104
|
-
/**
|
|
105
|
-
* Return `{ kind: 'missing' }` when the publish job lacks an
|
|
106
|
-
* `environment:` key. Does NOT inspect the value — diff-vs-registry is
|
|
107
|
-
* Option C.
|
|
108
|
-
*/
|
|
109
|
-
export declare function checkEnvironment(workflow: WorkflowFile): EnvironmentIssue | null;
|
|
110
|
-
/**
|
|
111
|
-
* Sanity check: confirm the workflow has at least one clearly-
|
|
112
|
-
* identifiable publish step. `findPublishWorkflows` already filters,
|
|
113
|
-
* but this catches weird states like a `run:` that's been edited into
|
|
114
|
-
* a comment while the composite-action `uses:` line still matches.
|
|
115
|
-
*/
|
|
116
|
-
export declare function checkPublishInvocation(workflow: WorkflowFile): InvocationIssue | null;
|
|
117
|
-
/**
|
|
118
|
-
* Compare `trust_policy.workflow` against the filename of the workflow
|
|
119
|
-
* that `findPublishWorkflows` identified. The declaration is always a
|
|
120
|
-
* bare filename (Zod enforces that at parse time); the comparison is
|
|
121
|
-
* case-sensitive. Returns `null` on match.
|
|
122
|
-
*/
|
|
123
|
-
export declare function diffWorkflowFilename(declared: string, workflowFilename: string): WorkflowFilenameMismatch | null;
|
|
124
|
-
/**
|
|
125
|
-
* Compare `trust_policy.environment` against the workflow's job-level
|
|
126
|
-
* `environment:` value. Absence of a declared environment is not an
|
|
127
|
-
* error — the caller decides whether to invoke this. Returns `null` on
|
|
128
|
-
* match.
|
|
129
|
-
*/
|
|
130
|
-
export declare function diffEnvironment(declared: string, workflow: WorkflowFile): EnvironmentMismatch | null;
|
|
131
|
-
/**
|
|
132
|
-
* Read `process.env.GITHUB_WORKFLOW_REF` (populated by GitHub Actions)
|
|
133
|
-
* and parse out the workflow filename. Shape:
|
|
134
|
-
*
|
|
135
|
-
* `owner/repo/.github/workflows/release.yml@refs/heads/main`
|
|
136
|
-
*
|
|
137
|
-
* Returns `null` when the env var is absent (we're not running inside
|
|
138
|
-
* Actions) OR when the value doesn't parse — we'd rather neutral-skip
|
|
139
|
-
* the check than false-positive on an unexpected shape.
|
|
140
|
-
*/
|
|
141
|
-
export declare function inferFromGithubWorkflowRef(env?: NodeJS.ProcessEnv): {
|
|
142
|
-
workflow: string;
|
|
143
|
-
repository: string;
|
|
144
|
-
} | null;
|
|
145
|
-
//# sourceMappingURL=oidc-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-policy.d.ts","sourceRoot":"","sources":["../src/oidc-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED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BrF;AAeD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,GACvB,wBAAwB,GAAG,IAAI,CASjC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,YAAY,GACrB,mBAAmB,GAAG,IAAI,CAS5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUjD"}
|
package/dist/oidc-policy.js
DELETED
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OIDC trust-policy local validation.
|
|
3
|
-
*
|
|
4
|
-
* `doctor` uses this module to check the locally-knowable structural
|
|
5
|
-
* prerequisites of OIDC trusted publishing:
|
|
6
|
-
*
|
|
7
|
-
* 1. At least one `.github/workflows/*.yml` file invokes either
|
|
8
|
-
* `putitoutthere publish` (as a `run:` command) or the composite
|
|
9
|
-
* action `thekevinscott/put-it-out-there@...` with a `command:`
|
|
10
|
-
* input that implies publishing.
|
|
11
|
-
* 2. That workflow's publishing job has `permissions: id-token: write`
|
|
12
|
-
* and `contents: write` (either job-level or workflow-level).
|
|
13
|
-
* 3. The publishing job has an `environment:` key set. We cannot
|
|
14
|
-
* validate the *value* against the registry's trust policy — that
|
|
15
|
-
* requires a registry-policy-read API per registry, which is
|
|
16
|
-
* deferred (Option C, see follow-up to #162).
|
|
17
|
-
* 4. A clearly-identifiable publish step exists — defends against
|
|
18
|
-
* edge cases like commented-out steps slipping past (1).
|
|
19
|
-
*
|
|
20
|
-
* The parser is intentionally regex/line-based rather than a full YAML
|
|
21
|
-
* parse: the four checks above all reduce to substring/indentation
|
|
22
|
-
* matches within a single jobs block. Adding a YAML dependency would
|
|
23
|
-
* buy us very little here. If the check set grows beyond this (e.g.
|
|
24
|
-
* "validate the environment value against a registry's trust policy"),
|
|
25
|
-
* revisit.
|
|
26
|
-
*
|
|
27
|
-
* Issue #162 — Option D (locally-knowable checks only).
|
|
28
|
-
*/
|
|
29
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
30
|
-
import { join } from 'node:path';
|
|
31
|
-
/**
|
|
32
|
-
* Scan `.github/workflows/*.yml` and `*.yaml` for workflows that invoke
|
|
33
|
-
* `putitoutthere publish` or the composite action in a publish mode.
|
|
34
|
-
*
|
|
35
|
-
* Permissive by design: if a workflow *mentions* piot in any way that
|
|
36
|
-
* looks like publishing, include it. Downstream checks then report
|
|
37
|
-
* specifically. The cost of a false-positive is a spurious pass/fail
|
|
38
|
-
* line in `doctor`; the cost of a false-negative is silently missing
|
|
39
|
-
* the user's real publish workflow.
|
|
40
|
-
*/
|
|
41
|
-
export function findPublishWorkflows(repoRoot) {
|
|
42
|
-
const dir = join(repoRoot, '.github', 'workflows');
|
|
43
|
-
let entries;
|
|
44
|
-
try {
|
|
45
|
-
entries = readdirSync(dir);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
const workflows = [];
|
|
51
|
-
for (const entry of entries) {
|
|
52
|
-
if (!/\.ya?ml$/i.test(entry))
|
|
53
|
-
continue;
|
|
54
|
-
const path = join(dir, entry);
|
|
55
|
-
let source;
|
|
56
|
-
try {
|
|
57
|
-
source = readFileSync(path, 'utf8');
|
|
58
|
-
/* v8 ignore next 3 -- defensive fallback for an unreadable workflow file (permissions, TOCTOU); can't produce in tests without mocking the fs module. */
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (!looksLikePublishWorkflow(source))
|
|
64
|
-
continue;
|
|
65
|
-
workflows.push({
|
|
66
|
-
path,
|
|
67
|
-
filename: entry,
|
|
68
|
-
source,
|
|
69
|
-
jobs: parseJobs(source),
|
|
70
|
-
workflowPermissions: extractTopLevelBlock(source, 'permissions') ?? '',
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return workflows;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Heuristic filter. Matches:
|
|
77
|
-
* - a `run:` step that contains `putitoutthere publish`
|
|
78
|
-
* - `uses: thekevinscott/put-it-out-there@...` combined with
|
|
79
|
-
* `command: publish` somewhere in the file (the composite action
|
|
80
|
-
* defaults to `plan`, so we only flag explicit `publish`)
|
|
81
|
-
*/
|
|
82
|
-
function looksLikePublishWorkflow(source) {
|
|
83
|
-
if (/\bputitoutthere\s+publish\b/.test(source))
|
|
84
|
-
return true;
|
|
85
|
-
const usesPiot = /uses:\s*thekevinscott\/put-it-out-there@/.test(source);
|
|
86
|
-
const commandPublish = /command:\s*['"]?publish['"]?/.test(source);
|
|
87
|
-
return usesPiot && commandPublish;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Best-effort jobs parser. Finds the top-level `jobs:` block and
|
|
91
|
-
* extracts each direct-child key + its body. We use the two-space
|
|
92
|
-
* indent convention GitHub Actions workflows follow. Workflows that
|
|
93
|
-
* deviate (tabs, four-space) would miss — but `init` emits two-space,
|
|
94
|
-
* which is what we're validating.
|
|
95
|
-
*/
|
|
96
|
-
export function parseJobs(source) {
|
|
97
|
-
const lines = source.split('\n');
|
|
98
|
-
// Find the `jobs:` top-level key (unindented).
|
|
99
|
-
let jobsStart = -1;
|
|
100
|
-
for (let i = 0; i < lines.length; i++) {
|
|
101
|
-
if (/^jobs\s*:\s*$/.test(lines[i])) {
|
|
102
|
-
jobsStart = i + 1;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (jobsStart === -1)
|
|
107
|
-
return [];
|
|
108
|
-
const jobs = [];
|
|
109
|
-
let current = null;
|
|
110
|
-
for (let i = jobsStart; i < lines.length; i++) {
|
|
111
|
-
const line = lines[i];
|
|
112
|
-
// Another top-level key ends the jobs block.
|
|
113
|
-
if (/^\S/.test(line) && line.trim().length > 0)
|
|
114
|
-
break;
|
|
115
|
-
// A direct child job key: exactly 2-space indent + `name:`.
|
|
116
|
-
const match = /^ {2}([A-Za-z_][\w-]*)\s*:\s*$/.exec(line);
|
|
117
|
-
if (match) {
|
|
118
|
-
if (current)
|
|
119
|
-
jobs.push({ name: current.name, source: current.lines.join('\n') });
|
|
120
|
-
current = { name: match[1], lines: [] };
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (current)
|
|
124
|
-
current.lines.push(line);
|
|
125
|
-
}
|
|
126
|
-
if (current)
|
|
127
|
-
jobs.push({ name: current.name, source: current.lines.join('\n') });
|
|
128
|
-
return jobs;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Extract a top-level block's body (everything indented beneath a
|
|
132
|
-
* given unindented key up to the next top-level key). Returns the
|
|
133
|
-
* concatenated indented body, or `null` if the key is absent.
|
|
134
|
-
*/
|
|
135
|
-
function extractTopLevelBlock(source, key) {
|
|
136
|
-
const lines = source.split('\n');
|
|
137
|
-
const re = new RegExp(`^${key}\\s*:\\s*(.*)$`);
|
|
138
|
-
for (let i = 0; i < lines.length; i++) {
|
|
139
|
-
const m = re.exec(lines[i]);
|
|
140
|
-
if (!m)
|
|
141
|
-
continue;
|
|
142
|
-
// Inline form: `permissions: read-all`. Return the inline value.
|
|
143
|
-
if (m[1] && m[1].trim().length > 0)
|
|
144
|
-
return m[1].trim();
|
|
145
|
-
const body = [];
|
|
146
|
-
for (let j = i + 1; j < lines.length; j++) {
|
|
147
|
-
const line = lines[j];
|
|
148
|
-
if (/^\S/.test(line) && line.trim().length > 0)
|
|
149
|
-
break;
|
|
150
|
-
body.push(line);
|
|
151
|
-
}
|
|
152
|
-
return body.join('\n');
|
|
153
|
-
}
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Check that the publishing job has (or inherits) the two permissions
|
|
158
|
-
* that OIDC trusted publishing requires. The permissions may be set at
|
|
159
|
-
* workflow level (top-level `permissions:`) and/or job level; this
|
|
160
|
-
* function reports a missing permission only if *neither* scope
|
|
161
|
-
* declares it. `write-all` satisfies both.
|
|
162
|
-
*/
|
|
163
|
-
export function checkPermissions(workflow) {
|
|
164
|
-
const publishJob = findPublishJob(workflow);
|
|
165
|
-
if (publishJob === null)
|
|
166
|
-
return [];
|
|
167
|
-
const jobPerms = extractBlockFromJob(publishJob.source, 'permissions') ?? '';
|
|
168
|
-
const combined = `${workflow.workflowPermissions}\n${jobPerms}`;
|
|
169
|
-
const issues = [];
|
|
170
|
-
if (!hasPermission(combined, 'id-token', 'write')) {
|
|
171
|
-
issues.push({
|
|
172
|
-
kind: 'missing-permission',
|
|
173
|
-
workflow: workflow.filename,
|
|
174
|
-
job: publishJob.name,
|
|
175
|
-
permission: 'id-token: write',
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
if (!hasPermission(combined, 'contents', 'write')) {
|
|
179
|
-
issues.push({
|
|
180
|
-
kind: 'missing-permission',
|
|
181
|
-
workflow: workflow.filename,
|
|
182
|
-
job: publishJob.name,
|
|
183
|
-
permission: 'contents: write',
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return issues;
|
|
187
|
-
}
|
|
188
|
-
function hasPermission(block, name, level) {
|
|
189
|
-
// `write-all` shortcut: every scope is `write`.
|
|
190
|
-
if (/\bwrite-all\b/.test(block))
|
|
191
|
-
return true;
|
|
192
|
-
const re = new RegExp(`\\b${name}\\s*:\\s*${level}\\b`);
|
|
193
|
-
return re.test(block);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Return `{ kind: 'missing' }` when the publish job lacks an
|
|
197
|
-
* `environment:` key. Does NOT inspect the value — diff-vs-registry is
|
|
198
|
-
* Option C.
|
|
199
|
-
*/
|
|
200
|
-
export function checkEnvironment(workflow) {
|
|
201
|
-
const publishJob = findPublishJob(workflow);
|
|
202
|
-
if (publishJob === null)
|
|
203
|
-
return null;
|
|
204
|
-
if (hasKeyAtJobLevel(publishJob.source, 'environment'))
|
|
205
|
-
return null;
|
|
206
|
-
return {
|
|
207
|
-
kind: 'missing-environment',
|
|
208
|
-
workflow: workflow.filename,
|
|
209
|
-
job: publishJob.name,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Sanity check: confirm the workflow has at least one clearly-
|
|
214
|
-
* identifiable publish step. `findPublishWorkflows` already filters,
|
|
215
|
-
* but this catches weird states like a `run:` that's been edited into
|
|
216
|
-
* a comment while the composite-action `uses:` line still matches.
|
|
217
|
-
*/
|
|
218
|
-
export function checkPublishInvocation(workflow) {
|
|
219
|
-
// Strip comment-only lines and blank lines before matching. A
|
|
220
|
-
// commented-out `run: putitoutthere publish` step shouldn't count.
|
|
221
|
-
const uncommented = workflow.source
|
|
222
|
-
.split('\n')
|
|
223
|
-
.filter((l) => !/^\s*#/.test(l))
|
|
224
|
-
.join('\n');
|
|
225
|
-
const hasRunCmd = /\bputitoutthere\s+publish\b/.test(uncommented);
|
|
226
|
-
if (hasRunCmd)
|
|
227
|
-
return null;
|
|
228
|
-
// Composite-action form with `command: publish` explicitly.
|
|
229
|
-
const usesPiot = /uses:\s*thekevinscott\/put-it-out-there@/.test(uncommented);
|
|
230
|
-
const commandPublish = /command:\s*['"]?publish['"]?/.test(uncommented);
|
|
231
|
-
if (usesPiot && commandPublish)
|
|
232
|
-
return null;
|
|
233
|
-
return { kind: 'no-publish-step', workflow: workflow.filename };
|
|
234
|
-
}
|
|
235
|
-
/* ---------------------- #189: declared diff ---------------------- */
|
|
236
|
-
/**
|
|
237
|
-
* Extract the basename (no directory) from a bare or path-shaped string.
|
|
238
|
-
* Normalizes both slash styles so a caller feeding in a
|
|
239
|
-
* `.github/workflows/release.yml` still gets `release.yml` back.
|
|
240
|
-
*/
|
|
241
|
-
function basename(p) {
|
|
242
|
-
const normalized = p.replace(/\\/g, '/');
|
|
243
|
-
const idx = normalized.lastIndexOf('/');
|
|
244
|
-
return idx === -1 ? normalized : normalized.slice(idx + 1);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Compare `trust_policy.workflow` against the filename of the workflow
|
|
248
|
-
* that `findPublishWorkflows` identified. The declaration is always a
|
|
249
|
-
* bare filename (Zod enforces that at parse time); the comparison is
|
|
250
|
-
* case-sensitive. Returns `null` on match.
|
|
251
|
-
*/
|
|
252
|
-
export function diffWorkflowFilename(declared, workflowFilename) {
|
|
253
|
-
const actual = basename(workflowFilename);
|
|
254
|
-
if (declared === actual)
|
|
255
|
-
return null;
|
|
256
|
-
return {
|
|
257
|
-
kind: 'workflow-filename-mismatch',
|
|
258
|
-
declared,
|
|
259
|
-
actual,
|
|
260
|
-
source: 'local-workflow',
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Compare `trust_policy.environment` against the workflow's job-level
|
|
265
|
-
* `environment:` value. Absence of a declared environment is not an
|
|
266
|
-
* error — the caller decides whether to invoke this. Returns `null` on
|
|
267
|
-
* match.
|
|
268
|
-
*/
|
|
269
|
-
export function diffEnvironment(declared, workflow) {
|
|
270
|
-
const actual = extractJobEnvironment(workflow);
|
|
271
|
-
if (actual === declared)
|
|
272
|
-
return null;
|
|
273
|
-
return {
|
|
274
|
-
kind: 'environment-mismatch',
|
|
275
|
-
workflow: workflow.filename,
|
|
276
|
-
declared,
|
|
277
|
-
actual,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Read `process.env.GITHUB_WORKFLOW_REF` (populated by GitHub Actions)
|
|
282
|
-
* and parse out the workflow filename. Shape:
|
|
283
|
-
*
|
|
284
|
-
* `owner/repo/.github/workflows/release.yml@refs/heads/main`
|
|
285
|
-
*
|
|
286
|
-
* Returns `null` when the env var is absent (we're not running inside
|
|
287
|
-
* Actions) OR when the value doesn't parse — we'd rather neutral-skip
|
|
288
|
-
* the check than false-positive on an unexpected shape.
|
|
289
|
-
*/
|
|
290
|
-
export function inferFromGithubWorkflowRef(env = process.env) {
|
|
291
|
-
const ref = env.GITHUB_WORKFLOW_REF;
|
|
292
|
-
if (ref === undefined || ref.length === 0)
|
|
293
|
-
return null;
|
|
294
|
-
// Strip the `@ref` suffix, then match
|
|
295
|
-
// `<owner>/<repo>/.github/workflows/<file>`.
|
|
296
|
-
const atIdx = ref.indexOf('@');
|
|
297
|
-
const pathPart = atIdx === -1 ? ref : ref.slice(0, atIdx);
|
|
298
|
-
const m = /^([^/\s]+\/[^/\s]+)\/\.github\/workflows\/(.+)$/.exec(pathPart);
|
|
299
|
-
if (!m)
|
|
300
|
-
return null;
|
|
301
|
-
return { repository: m[1], workflow: m[2] };
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Extract the job-level `environment:` value from a workflow's publish
|
|
305
|
-
* job. Supports the inline form (`environment: release`) and the nested
|
|
306
|
-
* form (`environment:\n name: release`). Returns `null` when no
|
|
307
|
-
* environment is declared (or no publish job is found).
|
|
308
|
-
*/
|
|
309
|
-
function extractJobEnvironment(workflow) {
|
|
310
|
-
const publishJob = findPublishJob(workflow);
|
|
311
|
-
/* v8 ignore next -- caller only invokes this for workflows that have a publish job */
|
|
312
|
-
if (publishJob === null)
|
|
313
|
-
return null;
|
|
314
|
-
const raw = extractBlockFromJob(publishJob.source, 'environment');
|
|
315
|
-
if (raw === null)
|
|
316
|
-
return null;
|
|
317
|
-
const trimmed = raw.trim();
|
|
318
|
-
// Inline form: `environment: release`. Nested form: `environment:\n name: release`.
|
|
319
|
-
// The inline regex matches when the value is a single line; for nested
|
|
320
|
-
// blocks, look for the `name:` key inside the body. When neither
|
|
321
|
-
// matches the block is structurally malformed — null propagates.
|
|
322
|
-
if (!trimmed.includes('\n')) {
|
|
323
|
-
const inline = /^['"]?([^'"\n]+?)['"]?$/.exec(trimmed);
|
|
324
|
-
return inline ? inline[1].trim() : null;
|
|
325
|
-
}
|
|
326
|
-
const nested = /^\s*name\s*:\s*['"]?([^'"\n]+?)['"]?\s*$/m.exec(trimmed);
|
|
327
|
-
return nested ? nested[1].trim() : null;
|
|
328
|
-
}
|
|
329
|
-
/* ---------------------------- helpers ---------------------------- */
|
|
330
|
-
/**
|
|
331
|
-
* Pick the job within a workflow that runs publish. If only one job
|
|
332
|
-
* matches, return it. If multiple match, prefer the one whose name
|
|
333
|
-
* contains `publish`; otherwise return the first.
|
|
334
|
-
*/
|
|
335
|
-
function findPublishJob(workflow) {
|
|
336
|
-
const matches = workflow.jobs.filter((j) => jobRunsPublish(j));
|
|
337
|
-
if (matches.length === 0)
|
|
338
|
-
return null;
|
|
339
|
-
const named = matches.find((j) => /publish/i.test(j.name));
|
|
340
|
-
return named ?? matches[0];
|
|
341
|
-
}
|
|
342
|
-
function jobRunsPublish(job) {
|
|
343
|
-
if (/\bputitoutthere\s+publish\b/.test(job.source))
|
|
344
|
-
return true;
|
|
345
|
-
const usesPiot = /uses:\s*thekevinscott\/put-it-out-there@/.test(job.source);
|
|
346
|
-
const commandPublish = /command:\s*['"]?publish['"]?/.test(job.source);
|
|
347
|
-
return usesPiot && commandPublish;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Whether the given job's source declares the key at the job scope
|
|
351
|
-
* (exactly 4-space indent, matching the 2-space job indent + one level
|
|
352
|
-
* further). Inline or block form both accepted.
|
|
353
|
-
*/
|
|
354
|
-
function hasKeyAtJobLevel(jobSource, key) {
|
|
355
|
-
const re = new RegExp(`^ {4}${key}\\s*:`, 'm');
|
|
356
|
-
return re.test(jobSource);
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Extract a nested block from inside a job source — `permissions:` or
|
|
360
|
-
* `environment:` below the 4-space indent.
|
|
361
|
-
*/
|
|
362
|
-
function extractBlockFromJob(jobSource, key) {
|
|
363
|
-
const lines = jobSource.split('\n');
|
|
364
|
-
const headRe = new RegExp(`^ {4}${key}\\s*:\\s*(.*)$`);
|
|
365
|
-
for (let i = 0; i < lines.length; i++) {
|
|
366
|
-
const m = headRe.exec(lines[i]);
|
|
367
|
-
if (!m)
|
|
368
|
-
continue;
|
|
369
|
-
if (m[1] && m[1].trim().length > 0)
|
|
370
|
-
return m[1].trim();
|
|
371
|
-
const body = [];
|
|
372
|
-
for (let j = i + 1; j < lines.length; j++) {
|
|
373
|
-
const line = lines[j];
|
|
374
|
-
// Any line indented 4 spaces or less (and non-empty) ends the block.
|
|
375
|
-
if (line.trim().length > 0 && /^ {0,4}\S/.test(line))
|
|
376
|
-
break;
|
|
377
|
-
body.push(line);
|
|
378
|
-
}
|
|
379
|
-
return body.join('\n');
|
|
380
|
-
}
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
//# sourceMappingURL=oidc-policy.js.map
|
package/dist/oidc-policy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-policy.js","sourceRoot":"","sources":["../src/oidc-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAyDjC;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IACnD,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,SAAS;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK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