@openai/codex-security 0.1.20 → 0.1.21
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/README.md +578 -871
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/schemas/patch-risk-assessment.schema.json +243 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +92 -11
- package/_bundled_plugin/scripts/launch_codex_security_mcp +0 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +88 -0
- package/_bundled_plugin/skills/assess-patch-risk/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/assess-patch-risk/references/risk-rubric.md +76 -0
- package/_bundled_plugin/skills/assess-patch-risk/scripts/validate_patch_risk_assessment.py +163 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +16 -48
- package/dist/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +14 -18
- package/dist/api.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +6 -24
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/cli.d.ts +24 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +401 -38
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts +5 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +307 -9
- package/dist/cloud-publish.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +5 -1
- package/dist/component-plan.js.map +1 -1
- package/dist/github.d.ts +161 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +158 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/publish.d.ts +10 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +29 -5
- package/dist/publish.js.map +1 -1
- package/dist/runtime.d.ts +0 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +258 -185
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts +3 -0
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +6 -1
- package/dist/scan-comparison.js.map +1 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +1 -0
- package/dist/targets.js.map +1 -1
- package/dist/thread-source.d.ts +8 -0
- package/dist/thread-source.d.ts.map +1 -0
- package/dist/thread-source.js +7 -0
- package/dist/thread-source.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +8 -5
package/dist/github.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/core";
|
|
2
|
+
type GitHubAlert = Awaited<ReturnType<typeof fetchGitHubAlert>>;
|
|
3
|
+
export declare const GITHUB_ALERT_STATES: readonly ["open", "closed", "dismissed", "fixed", "all"];
|
|
4
|
+
export interface GitHubCodeScanningImportOptions {
|
|
5
|
+
/** GitHub repository in OWNER/REPO form. */
|
|
6
|
+
repository: string;
|
|
7
|
+
/** Exact alert numbers, regardless of state. Omit to list matching alerts. */
|
|
8
|
+
alertNumbers?: readonly number[];
|
|
9
|
+
/** State used when listing alerts (default: open). */
|
|
10
|
+
state?: (typeof GITHUB_ALERT_STATES)[number];
|
|
11
|
+
/** Git reference to inspect; omitted lists the default branch. */
|
|
12
|
+
ref?: string;
|
|
13
|
+
/** Defaults to GH_HOST or github.com. */
|
|
14
|
+
githubHost?: string;
|
|
15
|
+
/** Omit to use the authenticated GitHub CLI, including its token environment. */
|
|
16
|
+
githubToken?: string;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
export interface ImportedGitHubCodeScanningAlert {
|
|
20
|
+
source: "github-code-scanning";
|
|
21
|
+
repository: string;
|
|
22
|
+
number: number;
|
|
23
|
+
url: string;
|
|
24
|
+
/** Upstream evidence, not a validated or sealed Codex Security finding. */
|
|
25
|
+
alert: GitHubAlert;
|
|
26
|
+
}
|
|
27
|
+
interface GitHubImportDependencies {
|
|
28
|
+
environment?: NodeJS.ProcessEnv;
|
|
29
|
+
currentDirectory?: string;
|
|
30
|
+
createGitHub?: (host: string, signal?: AbortSignal) => Promise<Octokit>;
|
|
31
|
+
}
|
|
32
|
+
export declare function createAuthenticatedGitHub(host: string, options?: {
|
|
33
|
+
environment?: NodeJS.ProcessEnv;
|
|
34
|
+
currentDirectory?: string;
|
|
35
|
+
token?: string;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<Octokit>;
|
|
38
|
+
export declare function importGitHubCodeScanningAlerts(options: GitHubCodeScanningImportOptions, dependencies?: GitHubImportDependencies): Promise<ImportedGitHubCodeScanningAlert[]>;
|
|
39
|
+
declare function fetchGitHubAlert(github: Octokit, owner: string, repo: string, alertNumber: number, signal?: AbortSignal): Promise<{
|
|
40
|
+
number: number;
|
|
41
|
+
created_at: string;
|
|
42
|
+
updated_at?: string;
|
|
43
|
+
url: string;
|
|
44
|
+
html_url: string;
|
|
45
|
+
instances_url: string;
|
|
46
|
+
state: "fixed" | "open" | "dismissed" | null;
|
|
47
|
+
fixed_at?: string | null;
|
|
48
|
+
dismissed_by: {
|
|
49
|
+
name?: string | null;
|
|
50
|
+
email?: string | null;
|
|
51
|
+
login: string;
|
|
52
|
+
id: number;
|
|
53
|
+
node_id: string;
|
|
54
|
+
avatar_url: string;
|
|
55
|
+
gravatar_id: string | null;
|
|
56
|
+
url: string;
|
|
57
|
+
html_url: string;
|
|
58
|
+
followers_url: string;
|
|
59
|
+
following_url: string;
|
|
60
|
+
gists_url: string;
|
|
61
|
+
starred_url: string;
|
|
62
|
+
subscriptions_url: string;
|
|
63
|
+
organizations_url: string;
|
|
64
|
+
repos_url: string;
|
|
65
|
+
events_url: string;
|
|
66
|
+
received_events_url: string;
|
|
67
|
+
type: string;
|
|
68
|
+
site_admin: boolean;
|
|
69
|
+
starred_at?: string;
|
|
70
|
+
user_view_type?: string;
|
|
71
|
+
} | null;
|
|
72
|
+
dismissed_at: string | null;
|
|
73
|
+
dismissed_reason: "false positive" | "won't fix" | "used in tests" | null;
|
|
74
|
+
dismissed_comment?: string | null;
|
|
75
|
+
rule: {
|
|
76
|
+
id?: string | null;
|
|
77
|
+
name?: string;
|
|
78
|
+
severity?: "none" | "note" | "warning" | "error" | null;
|
|
79
|
+
security_severity_level?: "low" | "medium" | "high" | "critical" | null;
|
|
80
|
+
description?: string;
|
|
81
|
+
full_description?: string;
|
|
82
|
+
tags?: string[] | null;
|
|
83
|
+
help?: string | null;
|
|
84
|
+
help_uri?: string | null;
|
|
85
|
+
};
|
|
86
|
+
tool: {
|
|
87
|
+
name?: string;
|
|
88
|
+
version?: string | null;
|
|
89
|
+
guid?: string | null;
|
|
90
|
+
};
|
|
91
|
+
most_recent_instance: {
|
|
92
|
+
ref?: string;
|
|
93
|
+
analysis_key?: string;
|
|
94
|
+
environment?: string;
|
|
95
|
+
category?: string;
|
|
96
|
+
state?: "fixed" | "open" | "dismissed" | null;
|
|
97
|
+
commit_sha?: string;
|
|
98
|
+
message?: {
|
|
99
|
+
text?: string;
|
|
100
|
+
};
|
|
101
|
+
location?: {
|
|
102
|
+
path?: string;
|
|
103
|
+
start_line?: number;
|
|
104
|
+
end_line?: number;
|
|
105
|
+
start_column?: number;
|
|
106
|
+
end_column?: number;
|
|
107
|
+
};
|
|
108
|
+
html_url?: string;
|
|
109
|
+
classifications?: ("source" | "generated" | "test" | "library" | null)[];
|
|
110
|
+
};
|
|
111
|
+
dismissal_approved_by?: {
|
|
112
|
+
name?: string | null;
|
|
113
|
+
email?: string | null;
|
|
114
|
+
login: string;
|
|
115
|
+
id: number;
|
|
116
|
+
node_id: string;
|
|
117
|
+
avatar_url: string;
|
|
118
|
+
gravatar_id: string | null;
|
|
119
|
+
url: string;
|
|
120
|
+
html_url: string;
|
|
121
|
+
followers_url: string;
|
|
122
|
+
following_url: string;
|
|
123
|
+
gists_url: string;
|
|
124
|
+
starred_url: string;
|
|
125
|
+
subscriptions_url: string;
|
|
126
|
+
organizations_url: string;
|
|
127
|
+
repos_url: string;
|
|
128
|
+
events_url: string;
|
|
129
|
+
received_events_url: string;
|
|
130
|
+
type: string;
|
|
131
|
+
site_admin: boolean;
|
|
132
|
+
starred_at?: string;
|
|
133
|
+
user_view_type?: string;
|
|
134
|
+
} | null;
|
|
135
|
+
assignees?: {
|
|
136
|
+
name?: string | null;
|
|
137
|
+
email?: string | null;
|
|
138
|
+
login: string;
|
|
139
|
+
id: number;
|
|
140
|
+
node_id: string;
|
|
141
|
+
avatar_url: string;
|
|
142
|
+
gravatar_id: string | null;
|
|
143
|
+
url: string;
|
|
144
|
+
html_url: string;
|
|
145
|
+
followers_url: string;
|
|
146
|
+
following_url: string;
|
|
147
|
+
gists_url: string;
|
|
148
|
+
starred_url: string;
|
|
149
|
+
subscriptions_url: string;
|
|
150
|
+
organizations_url: string;
|
|
151
|
+
repos_url: string;
|
|
152
|
+
events_url: string;
|
|
153
|
+
received_events_url: string;
|
|
154
|
+
type: string;
|
|
155
|
+
site_admin: boolean;
|
|
156
|
+
starred_at?: string;
|
|
157
|
+
user_view_type?: string;
|
|
158
|
+
}[];
|
|
159
|
+
}>;
|
|
160
|
+
export {};
|
|
161
|
+
//# sourceMappingURL=github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKxC,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC;AAEhE,eAAO,MAAM,mBAAmB,0DAMtB,CAAC;AAEX,MA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iBAAe,gBAAgB,CAC7B,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAasvi1B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAD5wi1B"}
|
package/dist/github.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { execFile as execFileCallback } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { Octokit } from "@octokit/core";
|
|
4
|
+
import { CodexSecurityError } from "./errors.js";
|
|
5
|
+
import { resolveTrustedExecutable } from "./trusted-executable.js";
|
|
6
|
+
const execFile = promisify(execFileCallback);
|
|
7
|
+
export const GITHUB_ALERT_STATES = [
|
|
8
|
+
"open",
|
|
9
|
+
"closed",
|
|
10
|
+
"dismissed",
|
|
11
|
+
"fixed",
|
|
12
|
+
"all",
|
|
13
|
+
];
|
|
14
|
+
export async function createAuthenticatedGitHub(host, options = {}) {
|
|
15
|
+
options.signal?.throwIfAborted();
|
|
16
|
+
let token = options.token;
|
|
17
|
+
if (token === undefined) {
|
|
18
|
+
const trusted = await resolveTrustedExecutable("gh", options.environment ?? process.env, options.currentDirectory ?? process.cwd());
|
|
19
|
+
if (trusted === null) {
|
|
20
|
+
throw new CodexSecurityError("GitHub CLI is required. Install gh and sign in first.");
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const { stdout } = await execFile(trusted.executable, ["auth", "token", "--hostname", host], { env: trusted.environment, signal: options.signal });
|
|
24
|
+
token = stdout.trim();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
options.signal?.throwIfAborted();
|
|
28
|
+
throw new CodexSecurityError("GitHub sign-in is required. Run 'gh auth login' first.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (token.trim().length === 0) {
|
|
32
|
+
throw new CodexSecurityError("GitHub access token must not be empty.");
|
|
33
|
+
}
|
|
34
|
+
return new Octokit({
|
|
35
|
+
auth: token,
|
|
36
|
+
...(host === "github.com" ? {} : { baseUrl: `https://${host}/api/v3` }),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export async function importGitHubCodeScanningAlerts(options, dependencies = {}) {
|
|
40
|
+
options.signal?.throwIfAborted();
|
|
41
|
+
const repository = options.repository.trim();
|
|
42
|
+
const parts = /^([a-z0-9_.-]+)\/([a-z0-9_.-]+)$/iu.exec(repository);
|
|
43
|
+
if (parts === null ||
|
|
44
|
+
parts.slice(1).some((part) => /^\.{1,2}$/u.test(part))) {
|
|
45
|
+
throw new CodexSecurityError("GitHub repository must be OWNER/REPO.");
|
|
46
|
+
}
|
|
47
|
+
const owner = parts[1];
|
|
48
|
+
const repo = parts[2];
|
|
49
|
+
const numbers = [...new Set(options.alertNumbers ?? [])];
|
|
50
|
+
if (numbers.some((number) => !Number.isSafeInteger(number) || number < 1)) {
|
|
51
|
+
throw new CodexSecurityError("GitHub alert numbers must be positive integers.");
|
|
52
|
+
}
|
|
53
|
+
const state = options.state ?? "open";
|
|
54
|
+
if (!GITHUB_ALERT_STATES.includes(state)) {
|
|
55
|
+
throw new CodexSecurityError("GitHub alert state is invalid.");
|
|
56
|
+
}
|
|
57
|
+
if (numbers.length > 0 && state !== "open") {
|
|
58
|
+
throw new CodexSecurityError("--github-state only filters lists; use it without --github-alert.");
|
|
59
|
+
}
|
|
60
|
+
const ref = options.ref?.trim();
|
|
61
|
+
if (ref === "") {
|
|
62
|
+
throw new CodexSecurityError("GitHub reference must not be empty.");
|
|
63
|
+
}
|
|
64
|
+
const environment = dependencies.environment ?? process.env;
|
|
65
|
+
const host = options.githubHost?.trim() ??
|
|
66
|
+
(environment["GH_HOST"]?.trim() || "github.com");
|
|
67
|
+
if (host.length === 0) {
|
|
68
|
+
throw new CodexSecurityError("GitHub host must not be empty.");
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const github = dependencies.createGitHub
|
|
72
|
+
? await dependencies.createGitHub(host, options.signal)
|
|
73
|
+
: await createAuthenticatedGitHub(host, {
|
|
74
|
+
token: options.githubToken,
|
|
75
|
+
environment,
|
|
76
|
+
currentDirectory: dependencies.currentDirectory,
|
|
77
|
+
signal: options.signal,
|
|
78
|
+
});
|
|
79
|
+
const selected = new Map();
|
|
80
|
+
if (numbers.length === 0 || ref !== undefined) {
|
|
81
|
+
let page = 1;
|
|
82
|
+
while (true) {
|
|
83
|
+
options.signal?.throwIfAborted();
|
|
84
|
+
// Octokit's list route omits GitHub's "closed" state.
|
|
85
|
+
const response = await github.request({
|
|
86
|
+
method: "GET",
|
|
87
|
+
url: "/repos/{owner}/{repo}/code-scanning/alerts",
|
|
88
|
+
owner,
|
|
89
|
+
repo,
|
|
90
|
+
per_page: 100,
|
|
91
|
+
page,
|
|
92
|
+
ref,
|
|
93
|
+
state: numbers.length > 0 || state === "all" ? undefined : state,
|
|
94
|
+
request: { signal: options.signal, redirect: "error" },
|
|
95
|
+
});
|
|
96
|
+
for (const alert of response.data) {
|
|
97
|
+
if (numbers.length === 0 || numbers.includes(alert.number)) {
|
|
98
|
+
selected.set(alert.number, alert.most_recent_instance);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!response.headers.link?.includes('rel="next"') ||
|
|
102
|
+
(numbers.length > 0 && selected.size === numbers.length))
|
|
103
|
+
break;
|
|
104
|
+
page += 1;
|
|
105
|
+
}
|
|
106
|
+
if (numbers.some((number) => !selected.has(number))) {
|
|
107
|
+
throw new CodexSecurityError("One or more selected GitHub alerts were not found on the requested reference.");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const alerts = [];
|
|
111
|
+
for (const number of numbers.length > 0 ? numbers : selected.keys()) {
|
|
112
|
+
options.signal?.throwIfAborted();
|
|
113
|
+
const alert = await fetchGitHubAlert(github, owner, repo, number, options.signal);
|
|
114
|
+
// Detail requests use the default branch; retain the listed ref's evidence.
|
|
115
|
+
const instance = selected.get(number);
|
|
116
|
+
alerts.push({
|
|
117
|
+
source: "github-code-scanning",
|
|
118
|
+
repository,
|
|
119
|
+
number,
|
|
120
|
+
url: alert.html_url,
|
|
121
|
+
alert: instance === undefined
|
|
122
|
+
? alert
|
|
123
|
+
: { ...alert, most_recent_instance: instance },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return alerts;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
options.signal?.throwIfAborted();
|
|
130
|
+
if (error instanceof CodexSecurityError)
|
|
131
|
+
throw error;
|
|
132
|
+
const status = typeof error === "object" && error !== null && "status" in error
|
|
133
|
+
? error.status
|
|
134
|
+
: undefined;
|
|
135
|
+
if (status === 401)
|
|
136
|
+
throw new CodexSecurityError("GitHub authentication failed.");
|
|
137
|
+
if (status === 403) {
|
|
138
|
+
throw new CodexSecurityError("GitHub denied code scanning access. Check repository permissions, code scanning availability, and API rate limits.");
|
|
139
|
+
}
|
|
140
|
+
if (status === 404) {
|
|
141
|
+
throw new CodexSecurityError("GitHub repository or code scanning alert was not found or is not accessible.");
|
|
142
|
+
}
|
|
143
|
+
if (status === 429)
|
|
144
|
+
throw new CodexSecurityError("GitHub request was rate limited. Wait and retry.");
|
|
145
|
+
// Octokit errors can contain credential-bearing request headers.
|
|
146
|
+
throw new CodexSecurityError(`GitHub code scanning request failed${typeof status === "number" ? ` (HTTP ${status})` : ""}.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function fetchGitHubAlert(github, owner, repo, alertNumber, signal) {
|
|
150
|
+
const response = await github.request("GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}", {
|
|
151
|
+
owner,
|
|
152
|
+
repo,
|
|
153
|
+
alert_number: alertNumber,
|
|
154
|
+
request: { signal, redirect: "error" },
|
|
155
|
+
});
|
|
156
|
+
return response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E,CAAC;QACjC,IAAI,KAAK,YAAY,kBAAkB;YAAE,MAAM,KAAK,CAAC;QACrD,MAAM,MAAM,GACV,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK;YAC9D,CAAC,CAAC,KAAK,CAAC,MAAM;YACd,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,MAAM,KAAK,GAAG;YAChB,MAAM,IAAI,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;QAChE,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,kBAAkB,CAC1B,oHAAoH,CACrH,CAAC;QACJ,CAAC;QACD,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,kBAAkB,CAC1B,8EAA8E,CAC/E,CAAC;QACJ,CAAC;QACD,IAAI,MAAM,KAAK,GAAG;YAChB,MAAM,IAAI,kBAAkB,CAC1B,kDAAkD,CACnD,CAAC;QACJ,iEAAiE;QACjE,MAAM,IAAI,kBAAkB,CAC1B,sCAAsC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,MAAe,EACf,KAAa,EACb,IAAY,EACZ,WAAmB,EACnB,MAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,+DAA+D,EAC/D;QACE,KAAK;QACL,IAAI;QACJ,YAAY,EAAE,WAAW;QACzB,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE;KACvC,CACF,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { execFile as execFileCallback } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { Octokit } from \"@octokit/core\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\n\nconst execFile = promisify(execFileCallback);\ntype GitHubAlert = Awaited<ReturnType<typeof fetchGitHubAlert>>;\n\nexport const GITHUB_ALERT_STATES = [\n \"open\",\n \"closed\",\n \"dismissed\",\n \"fixed\",\n \"all\",\n] as const;\n\nexport interface GitHubCodeScanningImportOptions {\n /** GitHub repository in OWNER/REPO form. */\n repository: string;\n /** Exact alert numbers, regardless of state. Omit to list matching alerts. */\n alertNumbers?: readonly number[];\n /** State used when listing alerts (default: open). */\n state?: (typeof GITHUB_ALERT_STATES)[number];\n /** Git reference to inspect; omitted lists the default branch. */\n ref?: string;\n /** Defaults to GH_HOST or github.com. */\n githubHost?: string;\n /** Omit to use the authenticated GitHub CLI, including its token environment. */\n githubToken?: string;\n signal?: AbortSignal;\n}\n\nexport interface ImportedGitHubCodeScanningAlert {\n source: \"github-code-scanning\";\n repository: string;\n number: number;\n url: string;\n /** Upstream evidence, not a validated or sealed Codex Security finding. */\n alert: GitHubAlert;\n}\n\ninterface GitHubImportDependencies {\n environment?: NodeJS.ProcessEnv;\n currentDirectory?: string;\n createGitHub?: (host: string, signal?: AbortSignal) => Promise<Octokit>;\n}\n\nexport async function createAuthenticatedGitHub(\n host: string,\n options: {\n environment?: NodeJS.ProcessEnv;\n currentDirectory?: string;\n token?: string;\n signal?: AbortSignal;\n } = {},\n): Promise<Octokit> {\n options.signal?.throwIfAborted();\n let token = options.token;\n if (token === undefined) {\n const trusted = await resolveTrustedExecutable(\n \"gh\",\n options.environment ?? process.env,\n options.currentDirectory ?? process.cwd(),\n );\n if (trusted === null) {\n throw new CodexSecurityError(\n \"GitHub CLI is required. Install gh and sign in first.\",\n );\n }\n try {\n const { stdout } = await execFile(\n trusted.executable,\n [\"auth\", \"token\", \"--hostname\", host],\n { env: trusted.environment, signal: options.signal },\n );\n token = stdout.trim();\n } catch {\n options.signal?.throwIfAborted();\n throw new CodexSecurityError(\n \"GitHub sign-in is required. Run 'gh auth login' first.\",\n );\n }\n }\n if (token.trim().length === 0) {\n throw new CodexSecurityError(\"GitHub access token must not be empty.\");\n }\n return new Octokit({\n auth: token,\n ...(host === \"github.com\" ? {} : { baseUrl: `https://${host}/api/v3` }),\n });\n}\n\nexport async function importGitHubCodeScanningAlerts(\n options: GitHubCodeScanningImportOptions,\n dependencies: GitHubImportDependencies = {},\n): Promise<ImportedGitHubCodeScanningAlert[]> {\n options.signal?.throwIfAborted();\n const repository = options.repository.trim();\n const parts = /^([a-z0-9_.-]+)\\/([a-z0-9_.-]+)$/iu.exec(repository);\n if (\n parts === null ||\n parts.slice(1).some((part) => /^\\.{1,2}$/u.test(part))\n ) {\n throw new CodexSecurityError(\"GitHub repository must be OWNER/REPO.\");\n }\n const owner = parts[1]!;\n const repo = parts[2]!;\n const numbers = [...new Set(options.alertNumbers ?? [])];\n if (numbers.some((number) => !Number.isSafeInteger(number) || number < 1)) {\n throw new CodexSecurityError(\n \"GitHub alert numbers must be positive integers.\",\n );\n }\n const state = options.state ?? \"open\";\n if (!GITHUB_ALERT_STATES.includes(state)) {\n throw new CodexSecurityError(\"GitHub alert state is invalid.\");\n }\n if (numbers.length > 0 && state !== \"open\") {\n throw new CodexSecurityError(\n \"--github-state only filters lists; use it without --github-alert.\",\n );\n }\n const ref = options.ref?.trim();\n if (ref === \"\") {\n throw new CodexSecurityError(\"GitHub reference must not be empty.\");\n }\n const environment = dependencies.environment ?? process.env;\n const host =\n options.githubHost?.trim() ??\n (environment[\"GH_HOST\"]?.trim() || \"github.com\");\n if (host.length === 0) {\n throw new CodexSecurityError(\"GitHub host must not be empty.\");\n }\n\n try {\n const github = dependencies.createGitHub\n ? await dependencies.createGitHub(host, options.signal)\n : await createAuthenticatedGitHub(host, {\n token: options.githubToken,\n environment,\n currentDirectory: dependencies.currentDirectory,\n signal: options.signal,\n });\n const selected = new Map<number, GitHubAlert[\"most_recent_instance\"]>();\n if (numbers.length === 0 || ref !== undefined) {\n let page = 1;\n while (true) {\n options.signal?.throwIfAborted();\n // Octokit's list route omits GitHub's \"closed\" state.\n const response = await github.request<\n Pick<GitHubAlert, \"number\" | \"most_recent_instance\">[]\n >({\n method: \"GET\",\n url: \"/repos/{owner}/{repo}/code-scanning/alerts\",\n owner,\n repo,\n per_page: 100,\n page,\n ref,\n state: numbers.length > 0 || state === \"all\" ? undefined : state,\n request: { signal: options.signal, redirect: \"error\" },\n });\n for (const alert of response.data) {\n if (numbers.length === 0 || numbers.includes(alert.number)) {\n selected.set(alert.number, alert.most_recent_instance);\n }\n }\n if (\n !response.headers.link?.includes('rel=\"next\"') ||\n (numbers.length > 0 && selected.size === numbers.length)\n )\n break;\n page += 1;\n }\n if (numbers.some((number) => !selected.has(number))) {\n throw new CodexSecurityError(\n \"One or more selected GitHub alerts were not found on the requested reference.\",\n );\n }\n }\n const alerts: ImportedGitHubCodeScanningAlert[] = [];\n for (const number of numbers.length > 0 ? numbers : selected.keys()) {\n options.signal?.throwIfAborted();\n const alert = await fetchGitHubAlert(\n github,\n owner,\n repo,\n number,\n options.signal,\n );\n // Detail requests use the default branch; retain the listed ref's evidence.\n const instance = selected.get(number);\n alerts.push({\n source: \"github-code-scanning\",\n repository,\n number,\n url: alert.html_url,\n alert:\n instance === undefined\n ? alert\n : { ...alert, most_recent_instance: instance },\n });\n }\n return alerts;\n } catch (error) {\n options.signal?.throwIfAborted();\n if (error instanceof CodexSecurityError) throw error;\n const status =\n typeof error === \"object\" && error !== null && \"status\" in error\n ? error.status\n : undefined;\n if (status === 401)\n throw new CodexSecurityError(\"GitHub authentication failed.\");\n if (status === 403) {\n throw new CodexSecurityError(\n \"GitHub denied code scanning access. Check repository permissions, code scanning availability, and API rate limits.\",\n );\n }\n if (status === 404) {\n throw new CodexSecurityError(\n \"GitHub repository or code scanning alert was not found or is not accessible.\",\n );\n }\n if (status === 429)\n throw new CodexSecurityError(\n \"GitHub request was rate limited. Wait and retry.\",\n );\n // Octokit errors can contain credential-bearing request headers.\n throw new CodexSecurityError(\n `GitHub code scanning request failed${typeof status === \"number\" ? ` (HTTP ${status})` : \"\"}.`,\n );\n }\n}\n\nasync function fetchGitHubAlert(\n github: Octokit,\n owner: string,\n repo: string,\n alertNumber: number,\n signal?: AbortSignal,\n) {\n const response = await github.request(\n \"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}\",\n {\n owner,\n repo,\n alert_number: alertNumber,\n request: { signal, redirect: \"error\" },\n },\n );\n return response.data;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export { loadContract, requireScanFile } from "./contract.js";
|
|
|
19
19
|
export type { LoadedContract, ScanExpectation } from "./contract.js";
|
|
20
20
|
export type * from "./models.js";
|
|
21
21
|
export { checkScanPublication, publishScan } from "./publish.js";
|
|
22
|
+
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
23
|
+
export type { GitHubCodeScanningImportOptions, ImportedGitHubCodeScanningAlert, } from "./github.js";
|
|
22
24
|
export type { CheckScanPublicationOptions, CheckScanPublicationResult, PublishScanOptions, PublishScanProgress, PublishScanResult, } from "./publish.js";
|
|
23
25
|
export { ScanResult } from "./result.js";
|
|
24
26
|
export type { RepositoryFinding, ScanResultOptions, TurnResultMetadata, } from "./result.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC7E,YAAY,EACV,aAAa,EACb,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;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CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, Co
|
|
|
7
7
|
export { DEFAULT_CODEX_CONFIG, mergedCodexConfig, writeCodexConfig, } from "./config.js";
|
|
8
8
|
export { loadContract, requireScanFile } from "./contract.js";
|
|
9
9
|
export { checkScanPublication, publishScan } from "./publish.js";
|
|
10
|
+
export { importGitHubCodeScanningAlerts } from "./github.js";
|
|
10
11
|
export { ScanResult } from "./result.js";
|
|
11
12
|
export { bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, createIsolatedHome, createMarketplace, extractPluginZip, importAmbientAuth, MARKETPLACE_NAME, pluginExecutionEnvironment, pluginMetadata, PLUGIN_NAME, prepareOutputDir, resolveCodexCommand, resolvePluginPath, resolvePluginPython, validateOutputDir, } from "./runtime.js";
|
|
12
13
|
export { DiffTarget, normalizeRepository, normalizeTarget, repositoryRevision, validateMode, } from "./targets.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAuB7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","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,OAAO,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { CodexSecurity, createSecurity } from \"./api.js\";\nexport { runComponentScans } from \"./component-scan.js\";\nexport type {\n ComponentDeduplicationSummary,\n ComponentReceipt,\n ComponentScanOptions,\n ComponentScanEvent,\n ComponentScanResult,\n} from \"./component-scan.js\";\nexport { normalizeComponentPlan, planComponents } from \"./component-plan.js\";\nexport type {\n ComponentPlan,\n ComponentPlanningOptions,\n} from \"./component-plan.js\";\nexport { estimateScanCost } from \"./cost.js\";\nexport type { ScanCost, ScanSessionEvent } from \"./cost.js\";\nexport type { CustomValidationResult } from \"./custom-validation.js\";\nexport type { ScanActivity, ScanActivityStatus } from \"./scan-activity.js\";\nexport type {\n CodexSecurityMetadata,\n DeepScanOptions,\n ScanAuthMode,\n ScanAuthentication,\n ScanOptions,\n ScanPreflight,\n ScanReconnectDetails,\n ScanTrustedAccessStatus,\n ScanWarningDetails,\n ValidationOptions,\n ValidationResult,\n} from \"./api.js\";\nexport type {\n ScanPhase,\n ScanProgress,\n ScanWorkerPhase,\n ScanWorkerStatus,\n} from \"./worker-progress.js\";\nexport { CodexLoginHandle } from \"./auth.js\";\nexport type { AccountStatus, LoginResult } from \"./auth.js\";\n\nexport {\n AuthenticationRequiredError,\n CodexSecurityError,\n ConfigurationError,\n ContractValidationError,\n IncompleteScanError,\n InvalidTargetError,\n OutputDirectoryError,\n OutputDirectoryNotEmptyError,\n OutputInsideProtectedRootError,\n PluginBootstrapError,\n PluginPythonUnavailableError,\n ScanCostLimitExceededError,\n ScanInterruptedError,\n} from \"./errors.js\";\nexport type { ProtectedScanPathKind } from \"./errors.js\";\nexport {\n DEFAULT_CODEX_CONFIG,\n mergedCodexConfig,\n writeCodexConfig,\n} from \"./config.js\";\nexport type { CodexSecurityConfig, JsonObject, JsonValue } from \"./config.js\";\nexport { loadContract, requireScanFile } from \"./contract.js\";\nexport type { LoadedContract, ScanExpectation } from \"./contract.js\";\nexport type * from \"./models.js\";\nexport { checkScanPublication, publishScan } from \"./publish.js\";\nexport { importGitHubCodeScanningAlerts } from \"./github.js\";\nexport type {\n GitHubCodeScanningImportOptions,\n ImportedGitHubCodeScanningAlert,\n} from \"./github.js\";\nexport type {\n CheckScanPublicationOptions,\n CheckScanPublicationResult,\n PublishScanOptions,\n PublishScanProgress,\n PublishScanResult,\n} from \"./publish.js\";\nexport { ScanResult } from \"./result.js\";\nexport type {\n RepositoryFinding,\n ScanResultOptions,\n TurnResultMetadata,\n} from \"./result.js\";\nexport {\n bootstrapPlugin,\n bundledPluginRoot,\n cleanupSdkDirectory,\n createIsolatedHome,\n createMarketplace,\n extractPluginZip,\n importAmbientAuth,\n MARKETPLACE_NAME,\n pluginExecutionEnvironment,\n pluginMetadata,\n PLUGIN_NAME,\n prepareOutputDir,\n resolveCodexCommand,\n resolvePluginPath,\n resolvePluginPython,\n validateOutputDir,\n} from \"./runtime.js\";\nexport type {\n CodexCommand,\n PluginInstall,\n PluginPythonOptions,\n ProcessEnvironment,\n} from \"./runtime.js\";\nexport {\n DiffTarget,\n normalizeRepository,\n normalizeTarget,\n repositoryRevision,\n validateMode,\n} from \"./targets.js\";\nexport type { NormalizedTarget, ScanMode, ScanTarget } from \"./targets.js\";\nexport { BUNDLED_PLUGIN_VERSION, VERSION } from \"./version.js\";\n"]}
|
package/dist/publish.d.ts
CHANGED
|
@@ -114,4 +114,14 @@ export declare function publishScan(scanDirectory: string, options: PublishScanO
|
|
|
114
114
|
export declare function publishScanInternal(scanDirectory: string, options: PublishScanOptions, dependencies?: PublishScanDependencies): Promise<PublishScanResult>;
|
|
115
115
|
export declare function checkScanPublication(scanDirectory: string, options: CheckScanPublicationOptions): Promise<CheckScanPublicationResult>;
|
|
116
116
|
export declare function checkScanPublicationInternal(scanDirectory: string, options: CheckScanPublicationOptions, dependencies?: CheckScanPublicationDependencies): Promise<CheckScanPublicationResult>;
|
|
117
|
+
interface ForceTerminationDependencies {
|
|
118
|
+
platform?: NodeJS.Platform;
|
|
119
|
+
systemRoot?: string;
|
|
120
|
+
runTaskkill?: (command: string, args: readonly string[]) => {
|
|
121
|
+
error?: Error;
|
|
122
|
+
status: number | null;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export declare function forceTerminatePublicationProcesses(dependencies?: ForceTerminationDependencies): void;
|
|
126
|
+
export {};
|
|
117
127
|
//# sourceMappingURL=publish.d.ts.map
|
package/dist/publish.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":"AA8BA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,sBAAsB,EACtB,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAE9B,MAAM,kBAAkB,CAAC;AAY1B,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,QAAQ,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAA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5B;AAED,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,0BAA0B,CAAC,CAErC;AAED,wBAAsB,4BAA4B,CAChD,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,2BAA2B,EACpC,YAAY,GAAE,gCAAqC,GAClD,OAAO,CAAC,0BAA0B,CAAC,CA2GrC;AA8yBD,UAAU,4BAA4B;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,CACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,KACpB;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC/C;AAED,wBAAgB,kCAAkC,CAChD,YAAY,GAAE,4BAAiC,GAC9C,IAAI,CAIN"}
|
package/dist/publish.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
1
|
+
import { spawn, spawnSync, } from "node:child_process";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { appendFile, mkdir, mkdtemp, open, readFile, rm, writeFile, } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
4
|
+
import { join, win32 } from "node:path";
|
|
5
5
|
import { InternalLinearError, NetworkLinearError, UnknownLinearError, } from "@linear/sdk";
|
|
6
6
|
import { CodexSecurityError, ConfigurationError, errorMessage, safeErrorMessage, } from "./errors.js";
|
|
7
7
|
import { createLinearClient, resolveLinearApiKey, } from "./linear.js";
|
|
@@ -935,6 +935,12 @@ function codexFailureMessage(stderr, exitCode) {
|
|
|
935
935
|
? `Codex could not publish through the connected Linear app: ${diagnostic}`
|
|
936
936
|
: `Codex exited with status ${exitCode}; sign in to Codex and connect the Linear app before publishing.`;
|
|
937
937
|
}
|
|
938
|
+
const activePublicationProcesses = new Set();
|
|
939
|
+
export function forceTerminatePublicationProcesses(dependencies = {}) {
|
|
940
|
+
for (const child of activePublicationProcesses) {
|
|
941
|
+
forceTerminatePublicationProcess(child, dependencies);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
938
944
|
async function runPublicationCodex(command, args, input, environment, onEvent, signal) {
|
|
939
945
|
signal?.throwIfAborted();
|
|
940
946
|
return new Promise((resolve, reject) => {
|
|
@@ -942,8 +948,10 @@ async function runPublicationCodex(command, args, input, environment, onEvent, s
|
|
|
942
948
|
env: environment,
|
|
943
949
|
stdio: ["pipe", "pipe", "pipe"],
|
|
944
950
|
windowsHide: true,
|
|
945
|
-
detached: process.platform !== "win32",
|
|
951
|
+
detached: process.platform !== "win32" && signal !== undefined,
|
|
946
952
|
});
|
|
953
|
+
if (signal !== undefined)
|
|
954
|
+
activePublicationProcesses.add(child);
|
|
947
955
|
let stdout = "";
|
|
948
956
|
let stderr = "";
|
|
949
957
|
let partialLine = "";
|
|
@@ -962,8 +970,11 @@ async function runPublicationCodex(command, args, input, environment, onEvent, s
|
|
|
962
970
|
};
|
|
963
971
|
const cleanup = () => {
|
|
964
972
|
signal?.removeEventListener("abort", onAbort);
|
|
965
|
-
|
|
973
|
+
activePublicationProcesses.delete(child);
|
|
974
|
+
if (forcedTermination !== undefined) {
|
|
966
975
|
clearTimeout(forcedTermination);
|
|
976
|
+
forcedTermination = undefined;
|
|
977
|
+
}
|
|
967
978
|
};
|
|
968
979
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
969
980
|
if (signal?.aborted === true)
|
|
@@ -1023,7 +1034,7 @@ function terminatePublicationProcess(child, signal) {
|
|
|
1023
1034
|
return Promise.resolve();
|
|
1024
1035
|
}
|
|
1025
1036
|
return new Promise((resolve) => {
|
|
1026
|
-
const command = join(process.env["SystemRoot"] ?? "C:\\Windows", "System32", "taskkill.exe");
|
|
1037
|
+
const command = win32.join(process.env["SystemRoot"] ?? "C:\\Windows", "System32", "taskkill.exe");
|
|
1027
1038
|
const taskkill = spawn(command, ["/PID", String(child.pid), "/T", "/F"], {
|
|
1028
1039
|
stdio: "ignore",
|
|
1029
1040
|
windowsHide: true,
|
|
@@ -1039,6 +1050,19 @@ function terminatePublicationProcess(child, signal) {
|
|
|
1039
1050
|
});
|
|
1040
1051
|
});
|
|
1041
1052
|
}
|
|
1053
|
+
function forceTerminatePublicationProcess(child, dependencies) {
|
|
1054
|
+
if (child.pid === undefined)
|
|
1055
|
+
return;
|
|
1056
|
+
if ((dependencies.platform ?? process.platform) === "win32") {
|
|
1057
|
+
const command = win32.join(dependencies.systemRoot ?? process.env["SystemRoot"] ?? "C:\\Windows", "System32", "taskkill.exe");
|
|
1058
|
+
const args = ["/PID", String(child.pid), "/T", "/F"];
|
|
1059
|
+
const taskkill = dependencies.runTaskkill?.(command, args) ??
|
|
1060
|
+
spawnSync(command, args, { stdio: "ignore", windowsHide: true });
|
|
1061
|
+
if (taskkill.error === undefined && taskkill.status === 0)
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
terminatePublicationProcessGroup(child, "SIGKILL");
|
|
1065
|
+
}
|
|
1042
1066
|
function terminatePublicationProcessGroup(child, signal) {
|
|
1043
1067
|
if (child.pid === undefined)
|
|
1044
1068
|
return;
|