@openai/codex-security 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -2
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +2 -0
- package/_bundled_plugin/shared/workbench-migrations.json +16 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +16 -8
- package/_bundled_plugin/skills/publish-findings/SKILL.md +130 -0
- package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +6 -0
- package/_bundled_plugin/skills/verify-fix/SKILL.md +4 -2
- package/dist/api.d.ts +3 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +76 -38
- package/dist/api.js.map +1 -1
- package/dist/classify-severity-records.d.ts +5 -2
- package/dist/classify-severity-records.d.ts.map +1 -1
- package/dist/classify-severity-records.js +40 -34
- package/dist/classify-severity-records.js.map +1 -1
- package/dist/classify-severity.d.ts +5 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +20 -30
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +1 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +412 -14
- package/dist/cli.js.map +1 -1
- package/dist/cloud-endpoint.d.ts +6 -0
- package/dist/cloud-endpoint.d.ts.map +1 -0
- package/dist/cloud-endpoint.js +51 -0
- package/dist/cloud-endpoint.js.map +1 -0
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +7 -5
- package/dist/cloud-publish.js.map +1 -1
- package/dist/default-severity-rubric.d.ts +3 -0
- package/dist/default-severity-rubric.d.ts.map +1 -0
- package/dist/default-severity-rubric.js +67 -0
- package/dist/default-severity-rubric.js.map +1 -0
- package/dist/endor-findings.d.ts +7 -0
- package/dist/endor-findings.d.ts.map +1 -0
- package/dist/endor-findings.js +233 -0
- package/dist/endor-findings.js.map +1 -0
- package/dist/external-findings-import.d.ts +5 -0
- package/dist/external-findings-import.d.ts.map +1 -0
- package/dist/external-findings-import.js +38 -0
- package/dist/external-findings-import.js.map +1 -0
- package/dist/external-findings-local.d.ts +63 -0
- package/dist/external-findings-local.d.ts.map +1 -0
- package/dist/external-findings-local.js +337 -0
- package/dist/external-findings-local.js.map +1 -0
- package/dist/external-findings-publish.d.ts +73 -0
- package/dist/external-findings-publish.d.ts.map +1 -0
- package/dist/external-findings-publish.js +713 -0
- package/dist/external-findings-publish.js.map +1 -0
- package/dist/external-findings-read.d.ts +6 -0
- package/dist/external-findings-read.d.ts.map +1 -0
- package/dist/external-findings-read.js +88 -0
- package/dist/external-findings-read.js.map +1 -0
- package/dist/external-findings.d.ts +21 -0
- package/dist/external-findings.d.ts.map +1 -0
- package/dist/external-findings.js +2 -0
- package/dist/external-findings.js.map +1 -0
- package/dist/external-import-contract.d.ts +13 -0
- package/dist/external-import-contract.d.ts.map +1 -0
- package/dist/external-import-contract.js +254 -0
- package/dist/external-import-contract.js.map +1 -0
- package/dist/external-import-models.d.ts +362 -0
- package/dist/external-import-models.d.ts.map +1 -0
- package/dist/external-import-models.js +3 -0
- package/dist/external-import-models.js.map +1 -0
- package/dist/finding-workflow.d.ts +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +2 -1
- package/dist/finding-workflow.js.map +1 -1
- package/dist/github-advisories.d.ts +386 -0
- package/dist/github-advisories.d.ts.map +1 -0
- package/dist/github-advisories.js +131 -0
- package/dist/github-advisories.js.map +1 -0
- package/dist/github-findings.d.ts +10 -0
- package/dist/github-findings.d.ts.map +1 -0
- package/dist/github-findings.js +256 -0
- package/dist/github-findings.js.map +1 -0
- package/dist/hosted-remediation-protocol.d.ts +2 -1
- package/dist/hosted-remediation-protocol.d.ts.map +1 -1
- package/dist/hosted-remediation-protocol.js +17 -11
- package/dist/hosted-remediation-protocol.js.map +1 -1
- package/dist/hosted-remediation.d.ts +4 -0
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +3 -1
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/hosted-scan.d.ts +16 -0
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +14 -2
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -0
- package/dist/project-config.js.map +1 -1
- package/dist/remediation.d.ts +6 -0
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +16 -5
- package/dist/remediation.js.map +1 -1
- package/dist/result.d.ts +4 -0
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +10 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +3 -1
- package/dist/runtime.js.map +1 -1
- package/dist/scan-owner-suggestions.d.ts +8 -0
- package/dist/scan-owner-suggestions.d.ts.map +1 -0
- package/dist/scan-owner-suggestions.js +33 -0
- package/dist/scan-owner-suggestions.js.map +1 -0
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/scanner-import.d.ts +20 -0
- package/dist/scanner-import.d.ts.map +1 -0
- package/dist/scanner-import.js +204 -0
- package/dist/scanner-import.js.map +1 -0
- package/dist/security-policy-diff.d.ts +2 -0
- package/dist/security-policy-diff.d.ts.map +1 -0
- package/dist/security-policy-diff.js +197 -0
- package/dist/security-policy-diff.js.map +1 -0
- package/dist/security-policy.d.ts +7 -3
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +10 -56
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +9 -0
- package/dist/semgrep-findings.d.ts.map +1 -0
- package/dist/semgrep-findings.js +293 -0
- package/dist/semgrep-findings.js.map +1 -0
- package/dist/severity-review.d.ts +3 -0
- package/dist/severity-review.d.ts.map +1 -1
- package/dist/severity-review.js +19 -0
- package/dist/severity-review.js.map +1 -1
- package/dist/severity-store.js +7 -2
- package/dist/severity-store.js.map +1 -1
- package/dist/snyk-findings.d.ts +9 -0
- package/dist/snyk-findings.d.ts.map +1 -0
- package/dist/snyk-findings.js +349 -0
- package/dist/snyk-findings.js.map +1 -0
- package/dist/targets.d.ts +2 -2
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +12 -2
- package/dist/targets.js.map +1 -1
- package/dist/wiz-csv.d.ts +8 -0
- package/dist/wiz-csv.d.ts.map +1 -0
- package/dist/wiz-csv.js +116 -0
- package/dist/wiz-csv.js.map +1 -0
- package/dist/wiz-findings.d.ts +4 -0
- package/dist/wiz-findings.d.ts.map +1 -0
- package/dist/wiz-findings.js +460 -0
- package/dist/wiz-findings.js.map +1 -0
- package/docs/classify-severity-records.md +28 -10
- package/docs/cli.md +702 -31
- package/docs/hosted-remediation.md +24 -7
- package/docs/hosted-scans.md +12 -0
- package/package.json +6 -4
- package/schemas/external-findings.schema.json +1421 -0
- package/schemas/project-config.schema.json +4 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import type { Octokit } from "@octokit/core";
|
|
2
|
+
export declare const GITHUB_ADVISORY_STATES: readonly ["published", "draft", "triage", "closed"];
|
|
3
|
+
export interface GitHubAdvisoryImportOptions {
|
|
4
|
+
/** Source repository, or the selected target for explicit global advisory IDs. */
|
|
5
|
+
repository: string;
|
|
6
|
+
/** Exact GHSA IDs. Required for the global advisory API. */
|
|
7
|
+
advisoryIds?: readonly string[];
|
|
8
|
+
/** Repository advisories by default; global never enumerates the database. */
|
|
9
|
+
source?: "repository" | "global";
|
|
10
|
+
/** Repository list state (default: published). Exact IDs ignore state. */
|
|
11
|
+
state?: (typeof GITHUB_ADVISORY_STATES)[number];
|
|
12
|
+
/** Defaults to GH_HOST or github.com. */
|
|
13
|
+
githubHost?: string;
|
|
14
|
+
/** Omit to use the authenticated GitHub CLI. */
|
|
15
|
+
githubToken?: string;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
type RepositoryAdvisory = Awaited<ReturnType<typeof fetchRepositoryAdvisory>>;
|
|
19
|
+
type GlobalAdvisory = Awaited<ReturnType<typeof fetchGlobalAdvisory>>;
|
|
20
|
+
export interface ImportedGitHubAdvisory {
|
|
21
|
+
source: "github-security-advisory";
|
|
22
|
+
selection: "repository" | "global";
|
|
23
|
+
repository: string;
|
|
24
|
+
githubHost: string;
|
|
25
|
+
ghsaId: string;
|
|
26
|
+
url: string;
|
|
27
|
+
/** Upstream disclosure, not proof that the selected repository is affected. */
|
|
28
|
+
advisory: RepositoryAdvisory | GlobalAdvisory;
|
|
29
|
+
}
|
|
30
|
+
interface GitHubAdvisoryImportDependencies {
|
|
31
|
+
environment?: NodeJS.ProcessEnv;
|
|
32
|
+
currentDirectory?: string;
|
|
33
|
+
createGitHub?: (host: string, signal?: AbortSignal) => Promise<Octokit>;
|
|
34
|
+
}
|
|
35
|
+
/** Read repository disclosures or explicitly selected public GHSA records. */
|
|
36
|
+
export declare function importGitHubAdvisories(options: GitHubAdvisoryImportOptions, dependencies?: GitHubAdvisoryImportDependencies): Promise<ImportedGitHubAdvisory[]>;
|
|
37
|
+
declare function fetchRepositoryAdvisory(github: Octokit, owner: string, repo: string, id: string, signal?: AbortSignal): Promise<{
|
|
38
|
+
ghsa_id: string;
|
|
39
|
+
cve_id: string | null;
|
|
40
|
+
url: string;
|
|
41
|
+
html_url: string;
|
|
42
|
+
summary: string;
|
|
43
|
+
description: string | null;
|
|
44
|
+
severity: "critical" | "high" | "medium" | "low" | null;
|
|
45
|
+
author: {
|
|
46
|
+
name?: string | null;
|
|
47
|
+
email?: string | null;
|
|
48
|
+
login: string;
|
|
49
|
+
id: number | bigint;
|
|
50
|
+
node_id: string;
|
|
51
|
+
avatar_url: string;
|
|
52
|
+
gravatar_id: string | null;
|
|
53
|
+
url: string;
|
|
54
|
+
html_url: string;
|
|
55
|
+
followers_url: string;
|
|
56
|
+
following_url: string;
|
|
57
|
+
gists_url: string;
|
|
58
|
+
starred_url: string;
|
|
59
|
+
subscriptions_url: string;
|
|
60
|
+
organizations_url: string;
|
|
61
|
+
repos_url: string;
|
|
62
|
+
events_url: string;
|
|
63
|
+
received_events_url: string;
|
|
64
|
+
type: string;
|
|
65
|
+
site_admin: boolean;
|
|
66
|
+
starred_at?: string;
|
|
67
|
+
user_view_type?: string;
|
|
68
|
+
} | null;
|
|
69
|
+
publisher: {
|
|
70
|
+
name?: string | null;
|
|
71
|
+
email?: string | null;
|
|
72
|
+
login: string;
|
|
73
|
+
id: number | bigint;
|
|
74
|
+
node_id: string;
|
|
75
|
+
avatar_url: string;
|
|
76
|
+
gravatar_id: string | null;
|
|
77
|
+
url: string;
|
|
78
|
+
html_url: string;
|
|
79
|
+
followers_url: string;
|
|
80
|
+
following_url: string;
|
|
81
|
+
gists_url: string;
|
|
82
|
+
starred_url: string;
|
|
83
|
+
subscriptions_url: string;
|
|
84
|
+
organizations_url: string;
|
|
85
|
+
repos_url: string;
|
|
86
|
+
events_url: string;
|
|
87
|
+
received_events_url: string;
|
|
88
|
+
type: string;
|
|
89
|
+
site_admin: boolean;
|
|
90
|
+
starred_at?: string;
|
|
91
|
+
user_view_type?: string;
|
|
92
|
+
} | null;
|
|
93
|
+
identifiers: readonly {
|
|
94
|
+
type: "CVE" | "GHSA";
|
|
95
|
+
value: string;
|
|
96
|
+
}[];
|
|
97
|
+
state: "published" | "closed" | "withdrawn" | "draft" | "triage";
|
|
98
|
+
created_at: string | null;
|
|
99
|
+
updated_at: string | null;
|
|
100
|
+
published_at: string | null;
|
|
101
|
+
closed_at: string | null;
|
|
102
|
+
withdrawn_at: string | null;
|
|
103
|
+
submission: {
|
|
104
|
+
readonly accepted: boolean;
|
|
105
|
+
} | null;
|
|
106
|
+
vulnerabilities: {
|
|
107
|
+
package: {
|
|
108
|
+
ecosystem: "actions" | "composer" | "erlang" | "go" | "maven" | "npm" | "nuget" | "other" | "pip" | "pub" | "rubygems" | "rust" | "swift";
|
|
109
|
+
name: string | null;
|
|
110
|
+
} | null;
|
|
111
|
+
vulnerable_version_range: string | null;
|
|
112
|
+
patched_versions: string | null;
|
|
113
|
+
vulnerable_functions: string[] | null;
|
|
114
|
+
}[] | null;
|
|
115
|
+
cvss: {
|
|
116
|
+
vector_string: string | null;
|
|
117
|
+
score: number | null;
|
|
118
|
+
} | null;
|
|
119
|
+
cvss_severities?: {
|
|
120
|
+
cvss_v3?: {
|
|
121
|
+
vector_string: string | null;
|
|
122
|
+
score: number | null;
|
|
123
|
+
} | null;
|
|
124
|
+
cvss_v4?: {
|
|
125
|
+
vector_string: string | null;
|
|
126
|
+
score: number | null;
|
|
127
|
+
} | null;
|
|
128
|
+
} | null;
|
|
129
|
+
cwes: readonly {
|
|
130
|
+
cwe_id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
}[] | null;
|
|
133
|
+
cwe_ids: string[] | null;
|
|
134
|
+
credits: {
|
|
135
|
+
login?: string;
|
|
136
|
+
type?: "analyst" | "coordinator" | "finder" | "other" | "remediation_developer" | "remediation_reviewer" | "remediation_verifier" | "reporter" | "sponsor" | "tool";
|
|
137
|
+
}[] | null;
|
|
138
|
+
credits_detailed: readonly {
|
|
139
|
+
user: {
|
|
140
|
+
name?: string | null;
|
|
141
|
+
email?: string | null;
|
|
142
|
+
login: string;
|
|
143
|
+
id: number | bigint;
|
|
144
|
+
node_id: string;
|
|
145
|
+
avatar_url: string;
|
|
146
|
+
gravatar_id: string | null;
|
|
147
|
+
url: string;
|
|
148
|
+
html_url: string;
|
|
149
|
+
followers_url: string;
|
|
150
|
+
following_url: string;
|
|
151
|
+
gists_url: string;
|
|
152
|
+
starred_url: string;
|
|
153
|
+
subscriptions_url: string;
|
|
154
|
+
organizations_url: string;
|
|
155
|
+
repos_url: string;
|
|
156
|
+
events_url: string;
|
|
157
|
+
received_events_url: string;
|
|
158
|
+
type: string;
|
|
159
|
+
site_admin: boolean;
|
|
160
|
+
starred_at?: string;
|
|
161
|
+
user_view_type?: string;
|
|
162
|
+
};
|
|
163
|
+
type: "analyst" | "coordinator" | "finder" | "other" | "remediation_developer" | "remediation_reviewer" | "remediation_verifier" | "reporter" | "sponsor" | "tool";
|
|
164
|
+
state: "accepted" | "declined" | "pending";
|
|
165
|
+
}[] | null;
|
|
166
|
+
collaborating_users: {
|
|
167
|
+
name?: string | null;
|
|
168
|
+
email?: string | null;
|
|
169
|
+
login: string;
|
|
170
|
+
id: number | bigint;
|
|
171
|
+
node_id: string;
|
|
172
|
+
avatar_url: string;
|
|
173
|
+
gravatar_id: string | null;
|
|
174
|
+
url: string;
|
|
175
|
+
html_url: string;
|
|
176
|
+
followers_url: string;
|
|
177
|
+
following_url: string;
|
|
178
|
+
gists_url: string;
|
|
179
|
+
starred_url: string;
|
|
180
|
+
subscriptions_url: string;
|
|
181
|
+
organizations_url: string;
|
|
182
|
+
repos_url: string;
|
|
183
|
+
events_url: string;
|
|
184
|
+
received_events_url: string;
|
|
185
|
+
type: string;
|
|
186
|
+
site_admin: boolean;
|
|
187
|
+
starred_at?: string;
|
|
188
|
+
user_view_type?: string;
|
|
189
|
+
}[] | null;
|
|
190
|
+
collaborating_teams: {
|
|
191
|
+
id: number;
|
|
192
|
+
node_id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
slug: string;
|
|
195
|
+
description: string | null;
|
|
196
|
+
privacy?: string;
|
|
197
|
+
notification_setting?: string;
|
|
198
|
+
permission: string;
|
|
199
|
+
permissions?: {
|
|
200
|
+
pull: boolean;
|
|
201
|
+
triage: boolean;
|
|
202
|
+
push: boolean;
|
|
203
|
+
maintain: boolean;
|
|
204
|
+
admin: boolean;
|
|
205
|
+
};
|
|
206
|
+
url: string;
|
|
207
|
+
html_url: string;
|
|
208
|
+
members_url: string;
|
|
209
|
+
repositories_url: string;
|
|
210
|
+
type: "enterprise" | "organization";
|
|
211
|
+
access_source?: "direct" | "organization" | "enterprise";
|
|
212
|
+
organization_id?: number;
|
|
213
|
+
enterprise_id?: number;
|
|
214
|
+
parent: {
|
|
215
|
+
id: number;
|
|
216
|
+
node_id: string;
|
|
217
|
+
url: string;
|
|
218
|
+
members_url: string;
|
|
219
|
+
name: string;
|
|
220
|
+
description: string | null;
|
|
221
|
+
permission: string;
|
|
222
|
+
privacy?: string;
|
|
223
|
+
notification_setting?: string;
|
|
224
|
+
html_url: string;
|
|
225
|
+
repositories_url: string;
|
|
226
|
+
slug: string;
|
|
227
|
+
ldap_dn?: string;
|
|
228
|
+
type: "enterprise" | "organization";
|
|
229
|
+
organization_id?: number;
|
|
230
|
+
enterprise_id?: number;
|
|
231
|
+
} | null;
|
|
232
|
+
}[] | null;
|
|
233
|
+
private_fork: {
|
|
234
|
+
id: number | bigint;
|
|
235
|
+
node_id: string;
|
|
236
|
+
name: string;
|
|
237
|
+
full_name: string;
|
|
238
|
+
owner: {
|
|
239
|
+
name?: string | null;
|
|
240
|
+
email?: string | null;
|
|
241
|
+
login: string;
|
|
242
|
+
id: number | bigint;
|
|
243
|
+
node_id: string;
|
|
244
|
+
avatar_url: string;
|
|
245
|
+
gravatar_id: string | null;
|
|
246
|
+
url: string;
|
|
247
|
+
html_url: string;
|
|
248
|
+
followers_url: string;
|
|
249
|
+
following_url: string;
|
|
250
|
+
gists_url: string;
|
|
251
|
+
starred_url: string;
|
|
252
|
+
subscriptions_url: string;
|
|
253
|
+
organizations_url: string;
|
|
254
|
+
repos_url: string;
|
|
255
|
+
events_url: string;
|
|
256
|
+
received_events_url: string;
|
|
257
|
+
type: string;
|
|
258
|
+
site_admin: boolean;
|
|
259
|
+
starred_at?: string;
|
|
260
|
+
user_view_type?: string;
|
|
261
|
+
};
|
|
262
|
+
private: boolean;
|
|
263
|
+
html_url: string;
|
|
264
|
+
description: string | null;
|
|
265
|
+
fork: boolean;
|
|
266
|
+
url: string;
|
|
267
|
+
archive_url: string;
|
|
268
|
+
assignees_url: string;
|
|
269
|
+
blobs_url: string;
|
|
270
|
+
branches_url: string;
|
|
271
|
+
collaborators_url: string;
|
|
272
|
+
comments_url: string;
|
|
273
|
+
commits_url: string;
|
|
274
|
+
compare_url: string;
|
|
275
|
+
contents_url: string;
|
|
276
|
+
contributors_url: string;
|
|
277
|
+
deployments_url: string;
|
|
278
|
+
downloads_url: string;
|
|
279
|
+
events_url: string;
|
|
280
|
+
forks_url: string;
|
|
281
|
+
git_commits_url: string;
|
|
282
|
+
git_refs_url: string;
|
|
283
|
+
git_tags_url: string;
|
|
284
|
+
issue_comment_url: string;
|
|
285
|
+
issue_events_url: string;
|
|
286
|
+
issues_url: string;
|
|
287
|
+
keys_url: string;
|
|
288
|
+
labels_url: string;
|
|
289
|
+
languages_url: string;
|
|
290
|
+
merges_url: string;
|
|
291
|
+
milestones_url: string;
|
|
292
|
+
notifications_url: string;
|
|
293
|
+
pulls_url: string;
|
|
294
|
+
releases_url: string;
|
|
295
|
+
stargazers_url: string;
|
|
296
|
+
statuses_url: string;
|
|
297
|
+
subscribers_url: string;
|
|
298
|
+
subscription_url: string;
|
|
299
|
+
tags_url: string;
|
|
300
|
+
teams_url: string;
|
|
301
|
+
trees_url: string;
|
|
302
|
+
hooks_url: string;
|
|
303
|
+
} | null;
|
|
304
|
+
}>;
|
|
305
|
+
declare function fetchGlobalAdvisory(github: Octokit, id: string, signal?: AbortSignal): Promise<{
|
|
306
|
+
ghsa_id: string;
|
|
307
|
+
cve_id: string | null;
|
|
308
|
+
url: string;
|
|
309
|
+
html_url: string;
|
|
310
|
+
repository_advisory_url: string | null;
|
|
311
|
+
summary: string;
|
|
312
|
+
description: string | null;
|
|
313
|
+
type: "reviewed" | "unreviewed" | "malware";
|
|
314
|
+
severity: "critical" | "high" | "medium" | "low" | "unknown";
|
|
315
|
+
source_code_location: string | null;
|
|
316
|
+
identifiers: readonly {
|
|
317
|
+
type: "CVE" | "GHSA";
|
|
318
|
+
value: string;
|
|
319
|
+
}[] | null;
|
|
320
|
+
references: string[] | null;
|
|
321
|
+
published_at: string;
|
|
322
|
+
updated_at: string;
|
|
323
|
+
github_reviewed_at: string | null;
|
|
324
|
+
nvd_published_at: string | null;
|
|
325
|
+
withdrawn_at: string | null;
|
|
326
|
+
vulnerabilities: {
|
|
327
|
+
package: {
|
|
328
|
+
ecosystem: "actions" | "composer" | "erlang" | "go" | "maven" | "npm" | "nuget" | "other" | "pip" | "pub" | "rubygems" | "rust" | "swift";
|
|
329
|
+
name: string | null;
|
|
330
|
+
} | null;
|
|
331
|
+
vulnerable_version_range: string | null;
|
|
332
|
+
first_patched_version: string | null;
|
|
333
|
+
vulnerable_functions: readonly string[] | null;
|
|
334
|
+
}[] | null;
|
|
335
|
+
cvss: {
|
|
336
|
+
vector_string: string | null;
|
|
337
|
+
score: number | null;
|
|
338
|
+
} | null;
|
|
339
|
+
cvss_severities?: {
|
|
340
|
+
cvss_v3?: {
|
|
341
|
+
vector_string: string | null;
|
|
342
|
+
score: number | null;
|
|
343
|
+
} | null;
|
|
344
|
+
cvss_v4?: {
|
|
345
|
+
vector_string: string | null;
|
|
346
|
+
score: number | null;
|
|
347
|
+
} | null;
|
|
348
|
+
} | null;
|
|
349
|
+
epss?: {
|
|
350
|
+
readonly percentage?: number;
|
|
351
|
+
readonly percentile?: number;
|
|
352
|
+
} | null;
|
|
353
|
+
cwes: {
|
|
354
|
+
cwe_id: string;
|
|
355
|
+
name: string;
|
|
356
|
+
}[] | null;
|
|
357
|
+
credits: readonly {
|
|
358
|
+
user: {
|
|
359
|
+
name?: string | null;
|
|
360
|
+
email?: string | null;
|
|
361
|
+
login: string;
|
|
362
|
+
id: number | bigint;
|
|
363
|
+
node_id: string;
|
|
364
|
+
avatar_url: string;
|
|
365
|
+
gravatar_id: string | null;
|
|
366
|
+
url: string;
|
|
367
|
+
html_url: string;
|
|
368
|
+
followers_url: string;
|
|
369
|
+
following_url: string;
|
|
370
|
+
gists_url: string;
|
|
371
|
+
starred_url: string;
|
|
372
|
+
subscriptions_url: string;
|
|
373
|
+
organizations_url: string;
|
|
374
|
+
repos_url: string;
|
|
375
|
+
events_url: string;
|
|
376
|
+
received_events_url: string;
|
|
377
|
+
type: string;
|
|
378
|
+
site_admin: boolean;
|
|
379
|
+
starred_at?: string;
|
|
380
|
+
user_view_type?: string;
|
|
381
|
+
};
|
|
382
|
+
type: "analyst" | "coordinator" | "finder" | "other" | "remediation_developer" | "remediation_reviewer" | "remediation_verifier" | "reporter" | "sponsor" | "tool";
|
|
383
|
+
}[] | null;
|
|
384
|
+
}>;
|
|
385
|
+
export {};
|
|
386
|
+
//# sourceMappingURL=github-advisories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-advisories.d.ts","sourceRoot":"","sources":["../src/github-advisories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C,eAAO,MAAM,sBAAsB,YACjC,WAAW,EACX,OAAO,EACP,QAAQ,EACR,QAAQ,CACA,CAAC;AAEX,MAAM,WAAW,2BAA2B;IAC1C,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYrB;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,OAAO,EACf,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAOrB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CodexSecurityError, errorMessage } from "./errors.js";
|
|
2
|
+
import { createAuthenticatedGitHub } from "./github.js";
|
|
3
|
+
export const GITHUB_ADVISORY_STATES = [
|
|
4
|
+
"published",
|
|
5
|
+
"draft",
|
|
6
|
+
"triage",
|
|
7
|
+
"closed",
|
|
8
|
+
];
|
|
9
|
+
/** Read repository disclosures or explicitly selected public GHSA records. */
|
|
10
|
+
export async function importGitHubAdvisories(options, dependencies = {}) {
|
|
11
|
+
options.signal?.throwIfAborted();
|
|
12
|
+
const repository = options.repository.trim();
|
|
13
|
+
const parts = /^([a-z0-9_.-]+)\/([a-z0-9_.-]+)$/iu.exec(repository);
|
|
14
|
+
if (!parts || parts.slice(1).some((part) => /^\.{1,2}$/u.test(part)))
|
|
15
|
+
throw new CodexSecurityError("GitHub repository must be OWNER/REPO.");
|
|
16
|
+
const owner = parts[1];
|
|
17
|
+
const repo = parts[2];
|
|
18
|
+
const ids = [
|
|
19
|
+
...new Set((options.advisoryIds ?? []).map((id) => id
|
|
20
|
+
.trim()
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.replace(/^ghsa-/u, "GHSA-"))),
|
|
23
|
+
];
|
|
24
|
+
if (ids.some((id) => !/^GHSA-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}$/u.test(id)))
|
|
25
|
+
throw new CodexSecurityError("GitHub advisory IDs must use GHSA-xxxx-xxxx-xxxx form.");
|
|
26
|
+
const source = options.source ?? "repository";
|
|
27
|
+
const state = options.state ?? "published";
|
|
28
|
+
if (source !== "repository" && source !== "global")
|
|
29
|
+
throw new CodexSecurityError("GitHub advisory source must be repository or global.");
|
|
30
|
+
if (!GITHUB_ADVISORY_STATES.includes(state))
|
|
31
|
+
throw new CodexSecurityError("GitHub advisory state is invalid.");
|
|
32
|
+
if (source === "global" && ids.length === 0)
|
|
33
|
+
throw new CodexSecurityError("Select explicit GHSA IDs for global advisories; database-wide import is not supported.");
|
|
34
|
+
if (ids.length > 0 && state !== "published")
|
|
35
|
+
throw new CodexSecurityError("--github-state only filters repository lists; omit it when selecting exact GHSA IDs.");
|
|
36
|
+
const environment = dependencies.environment ?? process.env;
|
|
37
|
+
const host = options.githubHost?.trim() ??
|
|
38
|
+
(environment["GH_HOST"]?.trim() || "github.com");
|
|
39
|
+
if (!host)
|
|
40
|
+
throw new CodexSecurityError("GitHub host must not be empty.");
|
|
41
|
+
try {
|
|
42
|
+
const github = dependencies.createGitHub
|
|
43
|
+
? await dependencies.createGitHub(host, options.signal)
|
|
44
|
+
: await createAuthenticatedGitHub(host, {
|
|
45
|
+
token: options.githubToken,
|
|
46
|
+
environment,
|
|
47
|
+
currentDirectory: dependencies.currentDirectory,
|
|
48
|
+
signal: options.signal,
|
|
49
|
+
});
|
|
50
|
+
const advisories = [];
|
|
51
|
+
if (ids.length > 0) {
|
|
52
|
+
for (const id of ids) {
|
|
53
|
+
options.signal?.throwIfAborted();
|
|
54
|
+
advisories.push(source === "global"
|
|
55
|
+
? await fetchGlobalAdvisory(github, id, options.signal)
|
|
56
|
+
: await fetchRepositoryAdvisory(github, owner, repo, id, options.signal));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
let after;
|
|
61
|
+
const cursors = new Set();
|
|
62
|
+
do {
|
|
63
|
+
options.signal?.throwIfAborted();
|
|
64
|
+
const response = await github.request("GET /repos/{owner}/{repo}/security-advisories", {
|
|
65
|
+
owner,
|
|
66
|
+
repo,
|
|
67
|
+
state,
|
|
68
|
+
per_page: 100,
|
|
69
|
+
after,
|
|
70
|
+
request: { signal: options.signal, redirect: "error" },
|
|
71
|
+
});
|
|
72
|
+
advisories.push(...response.data);
|
|
73
|
+
const next = response.headers.link
|
|
74
|
+
?.split(",")
|
|
75
|
+
.find((link) => /;\s*rel="next"/u.test(link));
|
|
76
|
+
const nextUrl = next?.match(/<([^>]+)>/u)?.[1];
|
|
77
|
+
// Keep requests on the authenticated route; only carry over the cursor.
|
|
78
|
+
after = nextUrl
|
|
79
|
+
? (new URL(nextUrl).searchParams.get("after") ?? undefined)
|
|
80
|
+
: undefined;
|
|
81
|
+
if (next && (!after || cursors.has(after)))
|
|
82
|
+
throw new CodexSecurityError("GitHub returned invalid advisory pagination.");
|
|
83
|
+
if (after)
|
|
84
|
+
cursors.add(after);
|
|
85
|
+
} while (after !== undefined);
|
|
86
|
+
}
|
|
87
|
+
return advisories.map((advisory) => ({
|
|
88
|
+
source: "github-security-advisory",
|
|
89
|
+
selection: source,
|
|
90
|
+
repository,
|
|
91
|
+
githubHost: host,
|
|
92
|
+
ghsaId: advisory.ghsa_id,
|
|
93
|
+
url: advisory.html_url,
|
|
94
|
+
advisory,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
options.signal?.throwIfAborted();
|
|
99
|
+
if (error instanceof CodexSecurityError)
|
|
100
|
+
throw error;
|
|
101
|
+
const status = typeof error === "object" && error !== null && "status" in error
|
|
102
|
+
? error.status
|
|
103
|
+
: undefined;
|
|
104
|
+
if (status === 401)
|
|
105
|
+
throw new CodexSecurityError("GitHub authentication failed.");
|
|
106
|
+
if (status === 403)
|
|
107
|
+
throw new CodexSecurityError("GitHub denied security advisory access. Check repository advisory permissions and API rate limits.");
|
|
108
|
+
if (status === 404)
|
|
109
|
+
throw new CodexSecurityError("GitHub repository or security advisory was not found or is not accessible.");
|
|
110
|
+
if (status === 429)
|
|
111
|
+
throw new CodexSecurityError("GitHub request was rate limited. Wait and retry.");
|
|
112
|
+
throw new CodexSecurityError(`GitHub security advisory request failed${typeof status === "number" ? ` (HTTP ${status})` : ""}: ${errorMessage(error)}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function fetchRepositoryAdvisory(github, owner, repo, id, signal) {
|
|
116
|
+
const response = await github.request("GET /repos/{owner}/{repo}/security-advisories/{ghsa_id}", {
|
|
117
|
+
owner,
|
|
118
|
+
repo,
|
|
119
|
+
ghsa_id: id,
|
|
120
|
+
request: { signal, redirect: "error" },
|
|
121
|
+
});
|
|
122
|
+
return response.data;
|
|
123
|
+
}
|
|
124
|
+
async function fetchGlobalAdvisory(github, id, signal) {
|
|
125
|
+
const response = await github.request("GET /advisories/{ghsa_id}", {
|
|
126
|
+
ghsa_id: id,
|
|
127
|
+
request: { signal, redirect: "error" },
|
|
128
|
+
});
|
|
129
|
+
return response.data;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=github-advisories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-advisories.js","sourceRoot":"","sources":["../src/github-advisories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW;IACX,OAAO;IACP,QAAQ;IACR,QAAQ;CACA,CAAC;AAsCX,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAoC,EACpC,YAAY,GAAqC,EAAE;IAEnD,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAA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MAAM,MAAM,CAAC,OAAO,CACnC,yDAAyD,EACzD;QACE,KAAK;QACL,IAAI;QACJ,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE;KACvC,CACF,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,mBAAmB,CAChC,MAAe,EACf,EAAU,EACV,MAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,2BAA2B,EAAE;QACjE,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE;KACvC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import type { Octokit } from \"@octokit/core\";\nimport { CodexSecurityError, errorMessage } from \"./errors.js\";\nimport { createAuthenticatedGitHub } from \"./github.js\";\n\nexport const GITHUB_ADVISORY_STATES = [\n \"published\",\n \"draft\",\n \"triage\",\n \"closed\",\n] as const;\n\nexport interface GitHubAdvisoryImportOptions {\n /** Source repository, or the selected target for explicit global advisory IDs. */\n repository: string;\n /** Exact GHSA IDs. Required for the global advisory API. */\n advisoryIds?: readonly string[];\n /** Repository advisories by default; global never enumerates the database. */\n source?: \"repository\" | \"global\";\n /** Repository list state (default: published). Exact IDs ignore state. */\n state?: (typeof GITHUB_ADVISORY_STATES)[number];\n /** Defaults to GH_HOST or github.com. */\n githubHost?: string;\n /** Omit to use the authenticated GitHub CLI. */\n githubToken?: string;\n signal?: AbortSignal;\n}\n\ntype RepositoryAdvisory = Awaited<ReturnType<typeof fetchRepositoryAdvisory>>;\ntype GlobalAdvisory = Awaited<ReturnType<typeof fetchGlobalAdvisory>>;\n\nexport interface ImportedGitHubAdvisory {\n source: \"github-security-advisory\";\n selection: \"repository\" | \"global\";\n repository: string;\n githubHost: string;\n ghsaId: string;\n url: string;\n /** Upstream disclosure, not proof that the selected repository is affected. */\n advisory: RepositoryAdvisory | GlobalAdvisory;\n}\n\ninterface GitHubAdvisoryImportDependencies {\n environment?: NodeJS.ProcessEnv;\n currentDirectory?: string;\n createGitHub?: (host: string, signal?: AbortSignal) => Promise<Octokit>;\n}\n\n/** Read repository disclosures or explicitly selected public GHSA records. */\nexport async function importGitHubAdvisories(\n options: GitHubAdvisoryImportOptions,\n dependencies: GitHubAdvisoryImportDependencies = {},\n): Promise<ImportedGitHubAdvisory[]> {\n options.signal?.throwIfAborted();\n const repository = options.repository.trim();\n const parts = /^([a-z0-9_.-]+)\\/([a-z0-9_.-]+)$/iu.exec(repository);\n if (!parts || parts.slice(1).some((part) => /^\\.{1,2}$/u.test(part)))\n throw new CodexSecurityError(\"GitHub repository must be OWNER/REPO.\");\n const owner = parts[1]!;\n const repo = parts[2]!;\n const ids = [\n ...new Set(\n (options.advisoryIds ?? []).map((id) =>\n id\n .trim()\n .toLowerCase()\n .replace(/^ghsa-/u, \"GHSA-\"),\n ),\n ),\n ];\n if (ids.some((id) => !/^GHSA-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}$/u.test(id)))\n throw new CodexSecurityError(\n \"GitHub advisory IDs must use GHSA-xxxx-xxxx-xxxx form.\",\n );\n const source = options.source ?? \"repository\";\n const state = options.state ?? \"published\";\n if (source !== \"repository\" && source !== \"global\")\n throw new CodexSecurityError(\n \"GitHub advisory source must be repository or global.\",\n );\n if (!GITHUB_ADVISORY_STATES.includes(state))\n throw new CodexSecurityError(\"GitHub advisory state is invalid.\");\n if (source === \"global\" && ids.length === 0)\n throw new CodexSecurityError(\n \"Select explicit GHSA IDs for global advisories; database-wide import is not supported.\",\n );\n if (ids.length > 0 && state !== \"published\")\n throw new CodexSecurityError(\n \"--github-state only filters repository lists; omit it when selecting exact GHSA IDs.\",\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) throw new CodexSecurityError(\"GitHub host must not be empty.\");\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 advisories: (RepositoryAdvisory | GlobalAdvisory)[] = [];\n if (ids.length > 0) {\n for (const id of ids) {\n options.signal?.throwIfAborted();\n advisories.push(\n source === \"global\"\n ? await fetchGlobalAdvisory(github, id, options.signal)\n : await fetchRepositoryAdvisory(\n github,\n owner,\n repo,\n id,\n options.signal,\n ),\n );\n }\n } else {\n let after: string | undefined;\n const cursors = new Set<string>();\n do {\n options.signal?.throwIfAborted();\n const response = await github.request(\n \"GET /repos/{owner}/{repo}/security-advisories\",\n {\n owner,\n repo,\n state,\n per_page: 100,\n after,\n request: { signal: options.signal, redirect: \"error\" },\n },\n );\n advisories.push(...response.data);\n const next = response.headers.link\n ?.split(\",\")\n .find((link) => /;\\s*rel=\"next\"/u.test(link));\n const nextUrl = next?.match(/<([^>]+)>/u)?.[1];\n // Keep requests on the authenticated route; only carry over the cursor.\n after = nextUrl\n ? (new URL(nextUrl).searchParams.get(\"after\") ?? undefined)\n : undefined;\n if (next && (!after || cursors.has(after)))\n throw new CodexSecurityError(\n \"GitHub returned invalid advisory pagination.\",\n );\n if (after) cursors.add(after);\n } while (after !== undefined);\n }\n return advisories.map((advisory) => ({\n source: \"github-security-advisory\",\n selection: source,\n repository,\n githubHost: host,\n ghsaId: advisory.ghsa_id,\n url: advisory.html_url,\n advisory,\n }));\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 security advisory access. Check repository advisory permissions and API rate limits.\",\n );\n if (status === 404)\n throw new CodexSecurityError(\n \"GitHub repository or security advisory was not found or is not accessible.\",\n );\n if (status === 429)\n throw new CodexSecurityError(\n \"GitHub request was rate limited. Wait and retry.\",\n );\n throw new CodexSecurityError(\n `GitHub security advisory request failed${typeof status === \"number\" ? ` (HTTP ${status})` : \"\"}: ${errorMessage(error)}`,\n );\n }\n}\n\nasync function fetchRepositoryAdvisory(\n github: Octokit,\n owner: string,\n repo: string,\n id: string,\n signal?: AbortSignal,\n) {\n const response = await github.request(\n \"GET /repos/{owner}/{repo}/security-advisories/{ghsa_id}\",\n {\n owner,\n repo,\n ghsa_id: id,\n request: { signal, redirect: \"error\" },\n },\n );\n return response.data;\n}\n\nasync function fetchGlobalAdvisory(\n github: Octokit,\n id: string,\n signal?: AbortSignal,\n) {\n const response = await github.request(\"GET /advisories/{ghsa_id}\", {\n ghsa_id: id,\n request: { signal, redirect: \"error\" },\n });\n return response.data;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExternalFindings } from "./external-findings.js";
|
|
2
|
+
import type { ImportedGitHubCodeScanningAlert } from "./github.js";
|
|
3
|
+
import type { ImportedGitHubAdvisory } from "./github-advisories.js";
|
|
4
|
+
/** Map selected code-scanning instances while retaining complete upstream evidence. */
|
|
5
|
+
export declare function normalizeGitHubCodeScanningAlerts(alerts: readonly ImportedGitHubCodeScanningAlert[]): ExternalFindings;
|
|
6
|
+
/** Map advisory disclosures without asserting an installed vulnerable dependency. */
|
|
7
|
+
export declare function normalizeGitHubAdvisories(advisories: readonly ImportedGitHubAdvisory[]): ExternalFindings;
|
|
8
|
+
/** Read unfiltered JSON/JSONL output saved by the read-only GitHub import commands. */
|
|
9
|
+
export declare function readGitHubFindings(path: string): Promise<ExternalFindings>;
|
|
10
|
+
//# sourceMappingURL=github-findings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-findings.d.ts","sourceRoot":"","sources":["../src/github-findings.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAwRrE,uFAAuF;AACvF,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,SAAS,+BAA+B,EAAE,GACjD,gBAAgB,CAElB;AAED,qFAAqF;AACrF,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,SAAS,sBAAsB,EAAE,GAC5C,gBAAgB,CAElB;AAED,uFAAuF;AACvF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,gBAAgB,CAAC,CAU3B"}
|