@otwld/workflow-cli 0.1.31 → 0.1.32
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/package.json +1 -1
- package/src/audit-github.d.ts +37 -96
- package/src/audit-github.js +91 -294
- package/src/audit-github.js.map +1 -1
- package/src/audit-policy.d.ts +0 -24
- package/src/audit-policy.js +0 -73
- package/src/audit-policy.js.map +1 -1
- package/src/audit-prompt.d.ts +2 -2
- package/src/audit-prompt.js +34 -19
- package/src/audit-prompt.js.map +1 -1
- package/src/audit.d.ts +7 -43
- package/src/audit.js +69 -203
- package/src/audit.js.map +1 -1
- package/src/automation.js +2 -8
- package/src/automation.js.map +1 -1
- package/src/codex-pool.js +15 -4
- package/src/codex-pool.js.map +1 -1
- package/src/codex.js +0 -2
- package/src/codex.js.map +1 -1
package/package.json
CHANGED
package/src/audit-github.d.ts
CHANGED
|
@@ -1,105 +1,46 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
1
|
+
/** Marker shared by the mission and its diagnostic fallback. */
|
|
2
|
+
export declare const auditMarker = "<!-- otwld:pnpm-audit -->";
|
|
3
|
+
/** Human-controlled opt-out, honored before the mission and fallback. */
|
|
4
|
+
export declare const auditPauseLabel = "automation-paused";
|
|
5
|
+
/** Minimal PR metadata needed to route a mission or its fallback. */
|
|
6
|
+
export interface AuditPull {
|
|
7
|
+
/** GitHub PR number. */
|
|
4
8
|
number: number;
|
|
5
|
-
|
|
6
|
-
body: string
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ref: string;
|
|
17
|
-
repo: {
|
|
18
|
-
full_name: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
base: {
|
|
22
|
-
ref: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
9
|
+
/** Markdown description, including the automation marker. */
|
|
10
|
+
body: string;
|
|
11
|
+
/** Current source branch, preserved across retries. */
|
|
12
|
+
headRefName: string;
|
|
13
|
+
/** Whether the source belongs to another repository. */
|
|
14
|
+
isCrossRepository: boolean;
|
|
15
|
+
/** Labels used for explicit human suspension. */
|
|
16
|
+
labels: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
25
20
|
/**
|
|
26
|
-
*
|
|
21
|
+
* Execute the runner's existing GitHub CLI with the workflow credentials.
|
|
22
|
+
* @param args - Structured gh arguments, never a shell command.
|
|
23
|
+
* @param env - Workflow environment including its dedicated PAT.
|
|
24
|
+
* @param body - Optional JSON API request body sent over stdin.
|
|
25
|
+
* @returns The command output.
|
|
27
26
|
*/
|
|
28
|
-
export declare
|
|
29
|
-
readonly env: NodeJS.ProcessEnv;
|
|
30
|
-
/**
|
|
31
|
-
* The repository value used by the workflow contract.
|
|
32
|
-
*/
|
|
33
|
-
readonly repository: string;
|
|
34
|
-
/**
|
|
35
|
-
* The token value used by the workflow contract.
|
|
36
|
-
*/
|
|
37
|
-
readonly token: string;
|
|
38
|
-
/**
|
|
39
|
-
* The api value used by the workflow contract.
|
|
40
|
-
*/
|
|
41
|
-
readonly api: string;
|
|
42
|
-
/**
|
|
43
|
-
* Bind API access to the supplied workflow environment.
|
|
44
|
-
* @param env - Workflow environment and operation-specific inputs.
|
|
45
|
-
*/
|
|
46
|
-
constructor(env: NodeJS.ProcessEnv);
|
|
47
|
-
/**
|
|
48
|
-
* Execute Git with the runner toolchain.
|
|
49
|
-
* @param args - Git arguments supplied by workflow-cli.
|
|
50
|
-
* @returns The validated operation result.
|
|
51
|
-
*/
|
|
52
|
-
git(...args: string[]): string;
|
|
53
|
-
/**
|
|
54
|
-
* Call the repository API with the workflow token.
|
|
55
|
-
* @param path - Repository-relative path to check.
|
|
56
|
-
* @param method - HTTP method.
|
|
57
|
-
* @param body - JSON request or diagnostic contents.
|
|
58
|
-
* @returns The asynchronous operation result.
|
|
59
|
-
* @throws If the input or external operation fails validation.
|
|
60
|
-
*/
|
|
61
|
-
request<T>(path: string, method?: string, body?: unknown): Promise<T>;
|
|
62
|
-
/**
|
|
63
|
-
* Read all pages of a repository API collection.
|
|
64
|
-
* @param path - Repository-relative path to check.
|
|
65
|
-
* @returns The asynchronous operation result.
|
|
66
|
-
*/
|
|
67
|
-
pages<T>(path: string): Promise<T[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Read open pull requests in the consumer repository.
|
|
70
|
-
* @returns The asynchronous operation result.
|
|
71
|
-
*/
|
|
72
|
-
pulls(): Promise<Pull[]>;
|
|
73
|
-
/**
|
|
74
|
-
* Create or update the single bot-owned audit diagnostic.
|
|
75
|
-
* @param body - JSON request or diagnostic contents.
|
|
76
|
-
* @param login - Expected GitHub Actions bot login.
|
|
77
|
-
* @returns The asynchronous operation result.
|
|
78
|
-
*/
|
|
79
|
-
issue(body: string, login: string): Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* Close resolved bot-owned audit diagnostics.
|
|
82
|
-
* @param login - Expected GitHub Actions bot login.
|
|
83
|
-
* @returns The asynchronous operation result.
|
|
84
|
-
*/
|
|
85
|
-
closeIssues(login: string): Promise<void>;
|
|
86
|
-
}
|
|
27
|
+
export declare function github(args: string[], env: NodeJS.ProcessEnv, body?: unknown): string;
|
|
87
28
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param env -
|
|
90
|
-
* @returns
|
|
91
|
-
* @throws If the run identity is invalid.
|
|
29
|
+
* Locate the single open audit PR, including PRs created before this migration.
|
|
30
|
+
* @param env - Consumer repository and credentials.
|
|
31
|
+
* @returns Existing same-repository audit PR, when present.
|
|
92
32
|
*/
|
|
93
|
-
export declare function
|
|
33
|
+
export declare function auditPull(env: NodeJS.ProcessEnv): AuditPull | undefined;
|
|
94
34
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
35
|
+
* Report only when the agent has not already communicated in this execution.
|
|
36
|
+
* @param env - Consumer repository, credentials and workflow run identity.
|
|
37
|
+
* @param diagnosis - Preserved mission response or execution failure details.
|
|
98
38
|
*/
|
|
99
|
-
export declare function
|
|
39
|
+
export declare function ensureAuditDiagnostic(env: NodeJS.ProcessEnv, diagnosis: string): void;
|
|
100
40
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param env -
|
|
41
|
+
* Link the exact attempt so the mission and fallback can avoid duplicate reports.
|
|
42
|
+
* @param env - GitHub Actions run identity.
|
|
43
|
+
* @returns Run URL, including the attempt when available.
|
|
44
|
+
* @throws If GitHub Actions did not supply its run ID.
|
|
103
45
|
*/
|
|
104
|
-
export declare function
|
|
105
|
-
export {};
|
|
46
|
+
export declare function auditRunUrl(env: NodeJS.ProcessEnv): string;
|
package/src/audit-github.js
CHANGED
|
@@ -1,314 +1,111 @@
|
|
|
1
|
-
import { executable } from './executable.js';
|
|
2
1
|
import { execFileSync } from 'node:child_process';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
/** Namespace reserved for audit candidates; every run gets a fresh branch. */
|
|
9
|
-
export const auditBranch = 'automation/pnpm-audit';
|
|
2
|
+
import { executable } from './executable.js';
|
|
3
|
+
/** Marker shared by the mission and its diagnostic fallback. */
|
|
4
|
+
export const auditMarker = '<!-- otwld:pnpm-audit -->';
|
|
5
|
+
/** Human-controlled opt-out, honored before the mission and fallback. */
|
|
6
|
+
export const auditPauseLabel = 'automation-paused';
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
8
|
+
* Execute the runner's existing GitHub CLI with the workflow credentials.
|
|
9
|
+
* @param args - Structured gh arguments, never a shell command.
|
|
10
|
+
* @param env - Workflow environment including its dedicated PAT.
|
|
11
|
+
* @param body - Optional JSON API request body sent over stdin.
|
|
12
|
+
* @returns The command output.
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* The token value used by the workflow contract.
|
|
21
|
-
*/
|
|
22
|
-
token;
|
|
23
|
-
/**
|
|
24
|
-
* The api value used by the workflow contract.
|
|
25
|
-
*/
|
|
26
|
-
api;
|
|
27
|
-
/**
|
|
28
|
-
* Bind API access to the supplied workflow environment.
|
|
29
|
-
* @param env - Workflow environment and operation-specific inputs.
|
|
30
|
-
*/
|
|
31
|
-
constructor(env) {
|
|
32
|
-
this.env = env;
|
|
33
|
-
this.repository = required(env, 'GITHUB_REPOSITORY');
|
|
34
|
-
this.token = env['GH_TOKEN'] || required(env, 'GITHUB_TOKEN');
|
|
35
|
-
this.api = env['GITHUB_API_URL'] || 'https://api.github.com';
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Execute Git with the runner toolchain.
|
|
39
|
-
* @param args - Git arguments supplied by workflow-cli.
|
|
40
|
-
* @returns The validated operation result.
|
|
41
|
-
*/
|
|
42
|
-
git(...args) {
|
|
43
|
-
return execFileSync(executable('git'), args, {
|
|
44
|
-
encoding: 'utf8',
|
|
45
|
-
maxBuffer: 32 * 1024 * 1024,
|
|
46
|
-
env: {
|
|
47
|
-
...this.env,
|
|
48
|
-
GIT_CONFIG_COUNT: '1',
|
|
49
|
-
GIT_CONFIG_KEY_0: `http.${this.env['GITHUB_SERVER_URL'] || 'https://github.com'}/.extraheader`,
|
|
50
|
-
GIT_CONFIG_VALUE_0: `AUTHORIZATION: basic ${Buffer.from('x-access-token:' + this.token).toString('base64')}`,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Call the repository API with the workflow token.
|
|
56
|
-
* @param path - Repository-relative path to check.
|
|
57
|
-
* @param method - HTTP method.
|
|
58
|
-
* @param body - JSON request or diagnostic contents.
|
|
59
|
-
* @returns The asynchronous operation result.
|
|
60
|
-
* @throws If the input or external operation fails validation.
|
|
61
|
-
*/
|
|
62
|
-
async request(path, method = 'GET', body) {
|
|
63
|
-
const url = `${this.api}/repos/${this.repository}${path}`;
|
|
64
|
-
const response = await fetch(url, {
|
|
65
|
-
method,
|
|
66
|
-
headers: {
|
|
67
|
-
Authorization: `Bearer ${this.token}`,
|
|
68
|
-
Accept: 'application/vnd.github+json',
|
|
69
|
-
'X-GitHub-Api-Version': '2022-11-28',
|
|
70
|
-
'Content-Type': 'application/json',
|
|
71
|
-
},
|
|
72
|
-
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
73
|
-
});
|
|
74
|
-
if (!response.ok) {
|
|
75
|
-
throw new Error(`GitHub ${method} ${path}: ${response.status}`);
|
|
76
|
-
}
|
|
77
|
-
return (response.status === 204 ? undefined : await response.json());
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Read all pages of a repository API collection.
|
|
81
|
-
* @param path - Repository-relative path to check.
|
|
82
|
-
* @returns The asynchronous operation result.
|
|
83
|
-
*/
|
|
84
|
-
async pages(path) {
|
|
85
|
-
const all = [];
|
|
86
|
-
for (let page = 1;; page++) {
|
|
87
|
-
const batch = await this.request(`${path}${path.includes('?') ? '&' : '?'}per_page=100&page=${page}`);
|
|
88
|
-
all.push(...batch);
|
|
89
|
-
if (batch.length < 100) {
|
|
90
|
-
return all;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Read open pull requests in the consumer repository.
|
|
96
|
-
* @returns The asynchronous operation result.
|
|
97
|
-
*/
|
|
98
|
-
pulls() {
|
|
99
|
-
return this.pages('/pulls?state=open');
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Create or update the single bot-owned audit diagnostic.
|
|
103
|
-
* @param body - JSON request or diagnostic contents.
|
|
104
|
-
* @param login - Expected GitHub Actions bot login.
|
|
105
|
-
* @returns The asynchronous operation result.
|
|
106
|
-
*/
|
|
107
|
-
async issue(body, login) {
|
|
108
|
-
const issues = await this.pages('/issues?state=open');
|
|
109
|
-
const issue = issues.find((item) => !item.pull_request &&
|
|
110
|
-
item.user.login === login &&
|
|
111
|
-
item.body?.includes(marker));
|
|
112
|
-
const contents = {
|
|
113
|
-
title: 'Security: pnpm audit requires attention',
|
|
114
|
-
body: `${marker}\n${body}`,
|
|
115
|
-
};
|
|
116
|
-
if (issue) {
|
|
117
|
-
await this.request(`/issues/${issue.number}`, 'PATCH', contents);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
await this.request('/issues', 'POST', {
|
|
121
|
-
...contents,
|
|
122
|
-
labels: ['needs-triage'],
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Close resolved bot-owned audit diagnostics.
|
|
128
|
-
* @param login - Expected GitHub Actions bot login.
|
|
129
|
-
* @returns The asynchronous operation result.
|
|
130
|
-
*/
|
|
131
|
-
async closeIssues(login) {
|
|
132
|
-
for (const issue of await this.pages('/issues?state=open')) {
|
|
133
|
-
if (!issue.pull_request &&
|
|
134
|
-
issue.user.login === login &&
|
|
135
|
-
issue.body?.includes(marker)) {
|
|
136
|
-
await this.request(`/issues/${issue.number}`, 'PATCH', {
|
|
137
|
-
state: 'closed',
|
|
138
|
-
state_reason: 'completed',
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
14
|
+
export function github(args, env, body) {
|
|
15
|
+
return execFileSync(executable('gh'), args, {
|
|
16
|
+
env: { ...process.env, ...env, GH_REPO: repository(env) },
|
|
17
|
+
input: body === undefined ? undefined : JSON.stringify(body),
|
|
18
|
+
encoding: 'utf8',
|
|
19
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
20
|
+
});
|
|
143
21
|
}
|
|
144
22
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @param env -
|
|
147
|
-
* @returns
|
|
148
|
-
* @throws If the run identity is invalid.
|
|
23
|
+
* Locate the single open audit PR, including PRs created before this migration.
|
|
24
|
+
* @param env - Consumer repository and credentials.
|
|
25
|
+
* @returns Existing same-repository audit PR, when present.
|
|
149
26
|
*/
|
|
150
|
-
export function
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
27
|
+
export function auditPull(env) {
|
|
28
|
+
const pulls = JSON.parse(github([
|
|
29
|
+
'pr',
|
|
30
|
+
'list',
|
|
31
|
+
'--state',
|
|
32
|
+
'open',
|
|
33
|
+
'--limit',
|
|
34
|
+
'100',
|
|
35
|
+
'--json',
|
|
36
|
+
'number,body,headRefName,isCrossRepository,labels',
|
|
37
|
+
], env));
|
|
38
|
+
return pulls.find((pull) => !pull.isCrossRepository &&
|
|
39
|
+
(pull.body.includes(auditMarker) ||
|
|
40
|
+
pull.headRefName === 'automation/pnpm-audit' ||
|
|
41
|
+
pull.headRefName.startsWith('automation/pnpm-audit-')));
|
|
157
42
|
}
|
|
158
43
|
/**
|
|
159
|
-
*
|
|
160
|
-
* @param
|
|
161
|
-
* @param
|
|
44
|
+
* Report only when the agent has not already communicated in this execution.
|
|
45
|
+
* @param env - Consumer repository, credentials and workflow run identity.
|
|
46
|
+
* @param diagnosis - Preserved mission response or execution failure details.
|
|
162
47
|
*/
|
|
163
|
-
export
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const base = readFileSync(join(directory, 'base.txt'), 'utf8').trim();
|
|
167
|
-
const run = runUrl(github, env);
|
|
168
|
-
if (env['AUDIT_STATUS'] === 'clean') {
|
|
169
|
-
await github.closeIssues(botLogin);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (await reportRenovate(directory, github, run)) {
|
|
48
|
+
export function ensureAuditDiagnostic(env, diagnosis) {
|
|
49
|
+
const pull = auditPull(env);
|
|
50
|
+
if (pull?.labels.some((label) => label.name === auditPauseLabel)) {
|
|
173
51
|
return;
|
|
174
52
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
git('config', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com');
|
|
200
|
-
git('checkout', '-b', branch);
|
|
201
|
-
git('add', '.');
|
|
202
|
-
git('commit', '-m', 'fix(deps): remediate pnpm audit findings');
|
|
203
|
-
// An empty lease only permits creation, even if a human creates the ref meanwhile.
|
|
204
|
-
github.git('push', `--force-with-lease=refs/heads/${branch}:`, 'origin', `HEAD:refs/heads/${branch}`);
|
|
205
|
-
const sha = git('rev-parse', 'HEAD').trim();
|
|
206
|
-
const candidate = existsSync(join(directory, 'candidate.json'))
|
|
207
|
-
? JSON.parse(readFileSync(join(directory, 'candidate.json'), 'utf8'))
|
|
208
|
-
: {};
|
|
209
|
-
await validationStatus(github, sha, 'pending', run);
|
|
210
|
-
output('source-sha', sha);
|
|
211
|
-
output('candidate-branch', branch);
|
|
212
|
-
output('base-sha', base);
|
|
213
|
-
output('eligible', String(candidate.verified === true));
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Create a review PR only after successful CI on the exact, untouched candidate.
|
|
217
|
-
* @param env - Trusted validation result and candidate identity.
|
|
218
|
-
*/
|
|
219
|
-
export async function finishAudit(env) {
|
|
220
|
-
const github = new GitHub(env);
|
|
221
|
-
const sha = required(env, 'SOURCE_SHA');
|
|
222
|
-
const base = required(env, 'AUDIT_BASE_SHA');
|
|
223
|
-
const branch = required(env, 'AUDIT_CANDIDATE_BRANCH');
|
|
224
|
-
const baseBranch = required(env, 'DEFAULT_BRANCH');
|
|
225
|
-
const result = required(env, 'AUDIT_VALIDATION_RESULT');
|
|
226
|
-
if (!/^[0-9a-f]{40}$/i.test(sha) ||
|
|
227
|
-
!/^[0-9a-f]{40}$/i.test(base) ||
|
|
228
|
-
branch !== candidateBranch(env)) {
|
|
229
|
-
throw new Error('Invalid audit candidate identity');
|
|
230
|
-
}
|
|
231
|
-
if (!['success', 'failure', 'cancelled', 'skipped'].includes(result)) {
|
|
232
|
-
throw new Error('Invalid reusable validation result');
|
|
233
|
-
}
|
|
234
|
-
const run = runUrl(github, env);
|
|
235
|
-
const state = validationState(result);
|
|
236
|
-
await validationStatus(github, sha, state, run);
|
|
237
|
-
const directory = env['AUDIT_DIRECTORY'];
|
|
238
|
-
const diagnosis = directory
|
|
239
|
-
? readDiagnosis(directory)
|
|
240
|
-
: 'Inspect the correction artifacts and CI logs.';
|
|
241
|
-
const compare = `${env['GITHUB_SERVER_URL'] || 'https://github.com'}/${github.repository}/compare/${encodeURIComponent(baseBranch)}...${encodeURIComponent(branch)}`;
|
|
242
|
-
const diagnostic = (reason) => github.issue(`${reason} No PR was created.\n\nCandidate for developer handoff: ${compare}\nCommit: ${sha}\nExecution and CI: ${run}\n\n${diagnosis}`, botLogin);
|
|
243
|
-
if (result !== 'success' || env['AUDIT_ELIGIBLE'] !== 'true') {
|
|
244
|
-
await diagnostic(`Validation: ${result}. Completed mission with clean audit: ${env['AUDIT_ELIGIBLE'] === 'true'}.`);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
const current = await github.request(`/branches/${encodeURIComponent(branch)}`);
|
|
248
|
-
const currentBase = await github.request(`/branches/${encodeURIComponent(baseBranch)}`);
|
|
249
|
-
if (current.commit.sha !== sha || currentBase.commit.sha !== base) {
|
|
250
|
-
await diagnostic('Candidate or default branch changed after verification; developer work was preserved.');
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const existing = (await github.pulls()).find(isAuditPull);
|
|
254
|
-
if (existing) {
|
|
255
|
-
if (sameValidatedPull(existing, branch, sha)) {
|
|
256
|
-
output('pull-request', String(existing.number));
|
|
53
|
+
const issues = pull
|
|
54
|
+
? []
|
|
55
|
+
: JSON.parse(github([
|
|
56
|
+
'issue',
|
|
57
|
+
'list',
|
|
58
|
+
'--state',
|
|
59
|
+
'open',
|
|
60
|
+
'--limit',
|
|
61
|
+
'100',
|
|
62
|
+
'--json',
|
|
63
|
+
'number,body',
|
|
64
|
+
], env));
|
|
65
|
+
const target = pull || issues.find((issue) => issue.body.includes(auditMarker));
|
|
66
|
+
const run = auditRunUrl(env);
|
|
67
|
+
const path = `repos/${repository(env)}/issues`;
|
|
68
|
+
if (target) {
|
|
69
|
+
const comments = github([
|
|
70
|
+
'api',
|
|
71
|
+
'--paginate',
|
|
72
|
+
`${path}/${target.number}/comments`,
|
|
73
|
+
'--jq',
|
|
74
|
+
'.[].body',
|
|
75
|
+
], env);
|
|
76
|
+
if (target.body.includes(run) || comments.includes(run)) {
|
|
257
77
|
return;
|
|
258
78
|
}
|
|
259
|
-
await diagnostic(`An existing audit PR awaits developer review: ${existing.html_url}.`);
|
|
260
|
-
return;
|
|
261
79
|
}
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
80
|
+
const body = `${auditMarker}\n\nAudit execution: ${run}\n\n${diagnosis}`;
|
|
81
|
+
github([
|
|
82
|
+
'api',
|
|
83
|
+
target ? `${path}/${target.number}/comments` : path,
|
|
84
|
+
'--method',
|
|
85
|
+
'POST',
|
|
86
|
+
'--input',
|
|
87
|
+
'-',
|
|
88
|
+
], env, target
|
|
89
|
+
? { body }
|
|
90
|
+
: { title: 'Dependency audit: developer diagnosis', body });
|
|
271
91
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Link the exact attempt so the mission and fallback can avoid duplicate reports.
|
|
94
|
+
* @param env - GitHub Actions run identity.
|
|
95
|
+
* @returns Run URL, including the attempt when available.
|
|
96
|
+
* @throws If GitHub Actions did not supply its run ID.
|
|
97
|
+
*/
|
|
98
|
+
export function auditRunUrl(env) {
|
|
99
|
+
if (!env.GITHUB_RUN_ID) {
|
|
100
|
+
throw new Error('Missing GITHUB_RUN_ID');
|
|
275
101
|
}
|
|
276
|
-
return
|
|
277
|
-
}
|
|
278
|
-
function sameValidatedPull(pr, branch, sha) {
|
|
279
|
-
return (pr.head.ref === branch &&
|
|
280
|
-
pr.head.sha === sha &&
|
|
281
|
-
pr.user.login === botLogin &&
|
|
282
|
-
Boolean(pr.body?.includes(marker)));
|
|
283
|
-
}
|
|
284
|
-
function isAuditPull(pr) {
|
|
285
|
-
return (pr.head.ref === auditBranch || pr.head.ref.startsWith(auditBranch + '-'));
|
|
102
|
+
return `${env.GITHUB_SERVER_URL || 'https://github.com'}/${repository(env)}/actions/runs/${env.GITHUB_RUN_ID}/attempts/${env.GITHUB_RUN_ATTEMPT || '1'}`;
|
|
286
103
|
}
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
await github.request(`/statuses/${sha}`, 'POST', {
|
|
292
|
-
context: 'audit/validation',
|
|
293
|
-
state,
|
|
294
|
-
target_url: run,
|
|
295
|
-
description: 'Existing reusable validation for this audit candidate',
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
async function reportRenovate(directory, github, run) {
|
|
299
|
-
for (const name of ['renovate.json', 'overlap.json', 'existing.json']) {
|
|
300
|
-
if (existsSync(join(directory, name))) {
|
|
301
|
-
const other = JSON.parse(readFileSync(join(directory, name), 'utf8'));
|
|
302
|
-
await github.issue(`An existing correction awaits review: ${other.url}. No branch was overwritten.\n\nAudit: ${run}`, botLogin);
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
104
|
+
function repository(env) {
|
|
105
|
+
const value = env.GITHUB_REPOSITORY;
|
|
106
|
+
if (!value || !/^[\w.-]+\/[\w.-]+$/.test(value)) {
|
|
107
|
+
throw new Error('Missing or invalid GITHUB_REPOSITORY');
|
|
305
108
|
}
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
function readDiagnosis(directory) {
|
|
309
|
-
const file = join(directory, 'diagnosis.md');
|
|
310
|
-
return existsSync(file)
|
|
311
|
-
? readFileSync(file, 'utf8').slice(0, 12000)
|
|
312
|
-
: 'Inspect the setup, correction and verification logs in the linked run.';
|
|
109
|
+
return value;
|
|
313
110
|
}
|
|
314
111
|
//# sourceMappingURL=audit-github.js.map
|
package/src/audit-github.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-github.js","sourceRoot":"","sources":["../../../../apps/workflow-cli/src/audit-github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAC3C,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AACvC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAmBnD;;GAEG;AACH,MAAM,OAAO,MAAM;IAiBI;IAhBrB;;OAEG;IACM,UAAU,CAAS;IAC5B;;OAEG;IACM,KAAK,CAAS;IACvB;;OAEG;IACM,GAAG,CAAS;IACrB;;;OAGG;IACH,YAAqB,GAAsB;QAAtB,QAAG,GAAH,GAAG,CAAmB;QACzC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,gBAAgB,CAA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EAAE,CAAC;AAC3J,CAAC;AAED,SAAS,UAAU,CAAC,GAAsB;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC;IACpC,IAAI,CAAC,KAAK,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/src/audit-policy.d.ts
CHANGED
|
@@ -13,28 +13,4 @@ export declare function record(value: unknown): Json;
|
|
|
13
13
|
* @returns The validated operation result.
|
|
14
14
|
*/
|
|
15
15
|
export declare function classifyAudit(code: number | null, value: unknown): 'clean' | 'vulnerable' | 'technical-error';
|
|
16
|
-
/**
|
|
17
|
-
* Accept repository files needed for remediation without exposing Git metadata.
|
|
18
|
-
* @param path - Repository-relative correction path.
|
|
19
|
-
* @returns Whether the path remains inside the checkout.
|
|
20
|
-
*/
|
|
21
|
-
export declare function allowedAuditPath(path: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Permit package replacement, new majors and migration scripts while preserving audit settings.
|
|
24
|
-
* @param before - Original package manifest.
|
|
25
|
-
* @param after - Corrected package manifest.
|
|
26
|
-
*/
|
|
27
|
-
export declare function assertManifest(before: unknown, after: unknown): void;
|
|
28
|
-
/**
|
|
29
|
-
* Allow workspace migrations without adding audit exceptions or weakening its threshold.
|
|
30
|
-
* @param before - Original workspace YAML.
|
|
31
|
-
* @param after - Corrected workspace YAML.
|
|
32
|
-
*/
|
|
33
|
-
export declare function assertWorkspace(before: string, after: string): void;
|
|
34
|
-
/**
|
|
35
|
-
* Read the package names affected by the audit report.
|
|
36
|
-
* @param value - External value to validate.
|
|
37
|
-
* @returns The validated operation result.
|
|
38
|
-
*/
|
|
39
|
-
export declare function auditPackages(value: unknown): string[];
|
|
40
16
|
export {};
|