@openai/codex-security 0.1.18 → 0.1.20
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 +133 -9
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- package/_bundled_plugin/scripts/workbench_cli.py +5 -1
- package/_bundled_plugin/scripts/workbench_db.py +53 -0
- package/dist/bulk-scan-discovery.d.ts +8 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +15 -1
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/cli.d.ts +5 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +364 -71
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts +16 -0
- package/dist/cloud-publish.d.ts.map +1 -0
- package/dist/cloud-publish.js +142 -0
- package/dist/cloud-publish.js.map +1 -0
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/linear.d.ts +5 -0
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +25 -9
- package/dist/linear.js.map +1 -1
- package/dist/publication-events.d.ts +40 -13
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +218 -104
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts +1 -0
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +73 -26
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +6 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +13 -0
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +41 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +611 -251
- package/dist/publish.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -730,6 +730,83 @@ and scans stopped at their configured cost limit do not start another turn.
|
|
|
730
730
|
invocation and defaults to `1`. Results remain under `--output-dir`; rerun the
|
|
731
731
|
same command to resume.
|
|
732
732
|
|
|
733
|
+
### Publish multiple completed scans to Cloud
|
|
734
|
+
|
|
735
|
+
Choose completed scans from your local history:
|
|
736
|
+
|
|
737
|
+
```bash
|
|
738
|
+
npx @openai/codex-security publish scan --to cloud --dry-run --json
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
The picker shows each scan's repository, finding count, age, and scan ID.
|
|
742
|
+
Press <kbd>Space</kbd> to select or deselect scans, then press
|
|
743
|
+
<kbd>Enter</kbd> to submit. At least one scan is required, and no scans are
|
|
744
|
+
selected automatically.
|
|
745
|
+
|
|
746
|
+
For scripts, repeat `--scan` with saved scan IDs or unique ID prefixes (at
|
|
747
|
+
least eight characters):
|
|
748
|
+
|
|
749
|
+
```bash
|
|
750
|
+
npx @openai/codex-security publish scan \
|
|
751
|
+
--scan SCAN_ID_A --scan SCAN_ID_B \
|
|
752
|
+
--to cloud --dry-run --json
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
Use `scans list --json` to find IDs for the current repository. `--scan latest`
|
|
756
|
+
selects its latest completed scan. The CLI resolves IDs through saved history,
|
|
757
|
+
processes each selected scan once, and checks that its sealed artifacts match
|
|
758
|
+
the selected ID. Picker selections use the order shown; repeated `--scan`
|
|
759
|
+
selections use argument order. The artifacts must still be available locally.
|
|
760
|
+
|
|
761
|
+
`--dry-run` validates the scans and prints their findings without uploading or
|
|
762
|
+
requiring a login. Remove `--dry-run` to upload. Live uploads require ChatGPT
|
|
763
|
+
credentials explicitly stored in a file. Set this in your Codex `config.toml`,
|
|
764
|
+
then sign in with ChatGPT again:
|
|
765
|
+
|
|
766
|
+
```toml
|
|
767
|
+
cli_auth_credentials_store = "file"
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
Automatic and keyring credential storage are not accepted for Cloud
|
|
771
|
+
publication, even when an `auth.json` file exists, because that file may be
|
|
772
|
+
stale and belong to a different account. The CLI sends one scan at a time,
|
|
773
|
+
with each scan's findings and metadata in a separate request.
|
|
774
|
+
|
|
775
|
+
For artifacts outside local history, use repeated `--scan-dir PATH` instead.
|
|
776
|
+
A single positional directory is still accepted and can be combined with
|
|
777
|
+
`--scan-dir`. Do not combine directory inputs with `--scan`. Each directory
|
|
778
|
+
must contain one completed, sealed scan; bulk-run directories and
|
|
779
|
+
`results.jsonl` files are not accepted. Relative paths start at the current
|
|
780
|
+
directory, and `~/...` starts at your home directory. Each resolved directory
|
|
781
|
+
is processed once.
|
|
782
|
+
|
|
783
|
+
For multiple distinct scans, output contains:
|
|
784
|
+
|
|
785
|
+
- `results`: receipts or dry-run previews, each with its `scanId` and `scanDir`.
|
|
786
|
+
- `failed`: errors with `scanDir` and, for saved selections, `scanId`.
|
|
787
|
+
- `notAttempted`: saved scan IDs, or paths for directory inputs, that the command
|
|
788
|
+
did not reach before cancellation.
|
|
789
|
+
|
|
790
|
+
For one distinct scan, the CLI returns the scan result directly,
|
|
791
|
+
without the batch fields above.
|
|
792
|
+
|
|
793
|
+
The CLI continues after a failed scan and exits with code `2` if any scan
|
|
794
|
+
fails. Ctrl-C or SIGTERM stops new requests and returns the results collected
|
|
795
|
+
so far. When cancellation stops work before every requested publication is
|
|
796
|
+
confirmed, the exit code is `130` for Ctrl-C and `143` for SIGTERM. If the
|
|
797
|
+
single response or final batch response has already confirmed the complete
|
|
798
|
+
publication, the command exits with code `0`. Cloud publication receipts
|
|
799
|
+
appear in command output; the CLI does not save them to scan history.
|
|
800
|
+
|
|
801
|
+
A successful receipt contains one opaque Cloud finding ID for each submitted
|
|
802
|
+
finding, in request order. These are not local finding IDs. The CLI verifies
|
|
803
|
+
the authenticated response status, count, and ID uniqueness, but cannot map
|
|
804
|
+
opaque server IDs back to individual local findings independently.
|
|
805
|
+
|
|
806
|
+
The CLI never retries an upload automatically. An upload with a missing or
|
|
807
|
+
invalid receipt may already have been accepted. Check whether Cloud accepted
|
|
808
|
+
that scan before retrying it. Do not resend scans with confirmed receipts.
|
|
809
|
+
|
|
733
810
|
### Custom validation
|
|
734
811
|
|
|
735
812
|
Use a prompt file to replace the final validation step in a standard or diff
|
|
@@ -802,17 +879,21 @@ Publish every finding from a completed standard, deep, or scoped scan to one
|
|
|
802
879
|
Linear team:
|
|
803
880
|
|
|
804
881
|
```bash
|
|
805
|
-
npx @openai/codex-security publish scan
|
|
882
|
+
npx @openai/codex-security publish scan --scan SCAN_ID \
|
|
806
883
|
--to linear \
|
|
807
884
|
--linear-team TEAM_ID
|
|
808
885
|
```
|
|
809
886
|
|
|
887
|
+
Linear accepts one scan. Use a saved scan ID, a unique ID prefix, or `latest`.
|
|
888
|
+
For external artifacts, a positional directory or `--scan-dir PATH` is also
|
|
889
|
+
accepted.
|
|
890
|
+
|
|
810
891
|
Add `--linear-project PROJECT_ID` to place the issues in a Linear project.
|
|
811
892
|
The existing `--project` flag remains an alias. Without a project, issues are
|
|
812
893
|
created directly in the selected team.
|
|
813
894
|
|
|
814
895
|
To choose from all completed scans saved in your local scan history, omit the
|
|
815
|
-
scan
|
|
896
|
+
scan selector. The selector highlights each repository and shows its finding
|
|
816
897
|
count, relative run time, and abbreviated scan ID:
|
|
817
898
|
|
|
818
899
|
```bash
|
|
@@ -856,6 +937,20 @@ added to successful publication results, scan history, or sealed scan artifacts.
|
|
|
856
937
|
Error messages are preserved as returned. `--dry-run` never contacts Linear in
|
|
857
938
|
either mode.
|
|
858
939
|
|
|
940
|
+
Use `publish check` to verify that the completed scan and its findings match
|
|
941
|
+
local history, and to see which findings already have recorded Linear issues:
|
|
942
|
+
|
|
943
|
+
```bash
|
|
944
|
+
npx @openai/codex-security publish check /path/to/completed-scan \
|
|
945
|
+
--to linear --linear-team TEAM_ID --json
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
The check does not create issues, migrate scan history, or change sealed scan
|
|
949
|
+
artifacts. With a Linear API key, it also makes read-only authentication, team,
|
|
950
|
+
optional project, and assignee checks. Without a key, connected-app access is
|
|
951
|
+
reported as `not-checked`. Issue-creation permission is always `not-tested`;
|
|
952
|
+
successful read access does not prove write permission.
|
|
953
|
+
|
|
859
954
|
Each finding creates a separate new issue titled
|
|
860
955
|
`[Codex Security][HIGH] Finding title`. The issue includes the scan ID,
|
|
861
956
|
repository, scanned scope, source locations and code snippets, severity,
|
|
@@ -864,14 +959,38 @@ Verified immutable Git revisions include source links. Findings are published
|
|
|
864
959
|
concurrently in batches of up to 20. Successful issue identifiers are linked
|
|
865
960
|
to their findings in the local scan-history database, and structured results
|
|
866
961
|
are read back from that database rather than generated by Codex. The completed
|
|
867
|
-
scan must already exist in the local scan history.
|
|
868
|
-
creates another set of issues for the same scan
|
|
869
|
-
|
|
962
|
+
scan must already exist in the local scan history. By default, running
|
|
963
|
+
publication again creates another set of issues for the same scan. Add
|
|
964
|
+
`--skip-existing` to skip findings with a recorded issue for the exact scan
|
|
965
|
+
occurrence, team, and optional project. Combine it with `--dry-run` to preview
|
|
966
|
+
only the remaining findings. Results distinguish newly `created` issues from
|
|
967
|
+
previously recorded `skipped` issues.
|
|
968
|
+
|
|
969
|
+
This option uses local publication history; it does not search, update, or
|
|
970
|
+
verify the continued existence of remote issues. Recover any retained handoff
|
|
971
|
+
from an interrupted or uncertain publication before retrying. Concurrent
|
|
972
|
+
publishers and remote creations that were never recorded can still create
|
|
973
|
+
duplicates.
|
|
870
974
|
|
|
871
975
|
Issue descriptions contain source code and vulnerability details. Select a
|
|
872
976
|
Linear destination authorized to receive that information. Publication receipts
|
|
873
977
|
are stored separately from the sealed scan artifacts.
|
|
874
978
|
|
|
979
|
+
Before recording a connected-app publication, Codex Security verifies the exact
|
|
980
|
+
mutation arguments and reconciles every recognized issue identifier and
|
|
981
|
+
non-empty URL in the connector result with its durable handoff. If those claims
|
|
982
|
+
conflict, or a completed mutation cannot be verified, publication exits with an
|
|
983
|
+
indeterminate recovery error. The private handoff, connector-event evidence,
|
|
984
|
+
and partial receipts remain in local state; independently verified sibling
|
|
985
|
+
issues may already be recorded in scan history.
|
|
986
|
+
|
|
987
|
+
Do not immediately rerun an indeterminate publication. Inspect the retained
|
|
988
|
+
evidence and the selected Linear destination, reconcile every issue that may
|
|
989
|
+
already have been created, and retry only after confirming that no unrecorded
|
|
990
|
+
issue would be duplicated. Publication does not perform a fresh remote readback
|
|
991
|
+
or recover unrecorded remote creations. The opt-in `--skip-existing` behavior
|
|
992
|
+
only skips issues already recorded in local history.
|
|
993
|
+
|
|
875
994
|
You can also publish a scan from TypeScript:
|
|
876
995
|
|
|
877
996
|
```ts
|
|
@@ -881,7 +1000,9 @@ const publication = await publishScan("/path/to/completed-scan", {
|
|
|
881
1000
|
destination: "linear",
|
|
882
1001
|
teamId: "TEAM_ID",
|
|
883
1002
|
onProgress: (progress) => {
|
|
884
|
-
if (progress.type === "
|
|
1003
|
+
if (progress.type === "handoff_recorded") {
|
|
1004
|
+
console.error("Saved mutation result", progress.recorded);
|
|
1005
|
+
} else if (progress.type === "issue_completed") {
|
|
885
1006
|
console.error(
|
|
886
1007
|
`Processed ${progress.completed} of ${progress.total} findings.`,
|
|
887
1008
|
);
|
|
@@ -894,7 +1015,9 @@ console.log(publication.created.length);
|
|
|
894
1015
|
```
|
|
895
1016
|
|
|
896
1017
|
Add `projectId: "PROJECT_ID"` to the options to publish into a specific Linear
|
|
897
|
-
project instead of directly to the team.
|
|
1018
|
+
project instead of directly to the team. Pass `skipExisting: true` to skip
|
|
1019
|
+
recorded successes, or import `checkScanPublication` and call it with the same
|
|
1020
|
+
destination options for a read-only preflight.
|
|
898
1021
|
|
|
899
1022
|
Pass `linearApiKey` to publish directly through the Linear API. Omit
|
|
900
1023
|
`assigneeId` to leave issues unassigned, or supply a Linear user ID or email
|
|
@@ -1025,8 +1148,9 @@ for a personal API key, or `LINEAR_ACCESS_TOKEN` for an OAuth access token.
|
|
|
1025
1148
|
`LINEAR_API_KEY` is also accepted. `--linear-api-key KEY` overrides these
|
|
1026
1149
|
environment settings; prefer the environment variable to keep keys out of shell
|
|
1027
1150
|
history. Imported content is always literal, and issue URLs must match the
|
|
1028
|
-
selected workspace.
|
|
1029
|
-
|
|
1151
|
+
selected workspace. Each imported issue includes its title, description, and
|
|
1152
|
+
all comments with their source links. Linear access is read-only, and its
|
|
1153
|
+
credentials are not passed to the patch subprocess.
|
|
1030
1154
|
|
|
1031
1155
|
Use `verify-fix` to check whether an existing security fix actually closes its
|
|
1032
1156
|
original vulnerability without modifying the repository. Pass a finding
|
|
@@ -330,7 +330,11 @@ def parse_args(description: str) -> argparse.Namespace:
|
|
|
330
330
|
export_findings.add_argument("--scan-id", required=True)
|
|
331
331
|
export_findings.add_argument("--format", choices=EXPORT_FORMATS, required=True)
|
|
332
332
|
|
|
333
|
-
for command in (
|
|
333
|
+
for command in (
|
|
334
|
+
"inspect-linear-publication",
|
|
335
|
+
"prepare-linear-publication",
|
|
336
|
+
"record-linear-publications",
|
|
337
|
+
):
|
|
334
338
|
publication = subparsers.add_parser(command)
|
|
335
339
|
publication.add_argument("--input-file", required=True)
|
|
336
340
|
|
|
@@ -21,6 +21,7 @@ from contextlib import closing, contextmanager
|
|
|
21
21
|
from datetime import datetime, timedelta, timezone
|
|
22
22
|
from pathlib import Path, PurePosixPath
|
|
23
23
|
from typing import Any
|
|
24
|
+
from urllib.parse import quote
|
|
24
25
|
|
|
25
26
|
try:
|
|
26
27
|
import fcntl as posix_file_lock
|
|
@@ -2499,6 +2500,8 @@ def verify_linear_publication_scan(
|
|
|
2499
2500
|
raise SystemExit(
|
|
2500
2501
|
"The selected scan directory does not match its local Codex Security scan history."
|
|
2501
2502
|
)
|
|
2503
|
+
if "seal_manifest_digest" in scan.keys():
|
|
2504
|
+
require_recorded_manifest_digest(scan, recorded_directory)
|
|
2502
2505
|
|
|
2503
2506
|
stored_findings = {
|
|
2504
2507
|
row["id"]: row["finding_id"]
|
|
@@ -2520,6 +2523,52 @@ def verify_linear_publication_scan(
|
|
|
2520
2523
|
return scan
|
|
2521
2524
|
|
|
2522
2525
|
|
|
2526
|
+
def inspect_linear_publication(args: argparse.Namespace) -> dict[str, Any]:
|
|
2527
|
+
payload, destination, findings = linear_publication_input(args, recording=False)
|
|
2528
|
+
database_uri = f"file:{quote(str(database_path()), safe='')}?mode=ro"
|
|
2529
|
+
with closing(sqlite3.connect(database_uri, uri=True, timeout=5)) as connection:
|
|
2530
|
+
connection.row_factory = sqlite3.Row
|
|
2531
|
+
connection.execute("BEGIN")
|
|
2532
|
+
scan = verify_linear_publication_scan(connection, payload, findings)
|
|
2533
|
+
recorded: dict[str, dict[str, str]] = {}
|
|
2534
|
+
if connection.execute(
|
|
2535
|
+
"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'finding_publications'"
|
|
2536
|
+
).fetchone():
|
|
2537
|
+
for row in connection.execute(
|
|
2538
|
+
"""
|
|
2539
|
+
SELECT finding_id, occurrence_id, external_id, external_url
|
|
2540
|
+
FROM finding_publications
|
|
2541
|
+
WHERE scan_id = ? AND destination_type = ? AND team_id = ? AND project_id IS ?
|
|
2542
|
+
ORDER BY created_at, external_id
|
|
2543
|
+
""",
|
|
2544
|
+
(
|
|
2545
|
+
scan["id"],
|
|
2546
|
+
destination["type"],
|
|
2547
|
+
destination["teamId"],
|
|
2548
|
+
destination.get("projectId"),
|
|
2549
|
+
),
|
|
2550
|
+
):
|
|
2551
|
+
recorded.setdefault(
|
|
2552
|
+
row["occurrence_id"],
|
|
2553
|
+
{
|
|
2554
|
+
"findingId": row["finding_id"],
|
|
2555
|
+
"occurrenceId": row["occurrence_id"],
|
|
2556
|
+
"issueIdentifier": row["external_id"],
|
|
2557
|
+
**({"url": row["external_url"]} if row["external_url"] is not None else {}),
|
|
2558
|
+
},
|
|
2559
|
+
)
|
|
2560
|
+
return {
|
|
2561
|
+
"scanId": scan["id"],
|
|
2562
|
+
"destination": destination,
|
|
2563
|
+
"findingCount": len(findings),
|
|
2564
|
+
"recorded": [
|
|
2565
|
+
recorded[finding["occurrenceId"]]
|
|
2566
|
+
for finding in findings
|
|
2567
|
+
if finding["occurrenceId"] in recorded
|
|
2568
|
+
],
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
|
|
2523
2572
|
def prepare_linear_publication(
|
|
2524
2573
|
connection: sqlite3.Connection, args: argparse.Namespace
|
|
2525
2574
|
) -> dict[str, Any]:
|
|
@@ -3810,6 +3859,10 @@ def main() -> None:
|
|
|
3810
3859
|
result = inspect_setup(args)
|
|
3811
3860
|
print(json.dumps(result, allow_nan=False, sort_keys=True))
|
|
3812
3861
|
return
|
|
3862
|
+
if args.command == "inspect-linear-publication":
|
|
3863
|
+
result = inspect_linear_publication(args)
|
|
3864
|
+
print(json.dumps(result, allow_nan=False, sort_keys=True))
|
|
3865
|
+
return
|
|
3813
3866
|
with closing(connect()) as connection:
|
|
3814
3867
|
remediation.require_available(connection, args, require_scan)
|
|
3815
3868
|
if args.command == "create-workspace":
|
|
@@ -11,6 +11,14 @@ export interface BulkScanPrompt {
|
|
|
11
11
|
}[], presentation?: {
|
|
12
12
|
header?: string;
|
|
13
13
|
}, signal?: AbortSignal): Promise<Value>;
|
|
14
|
+
checkbox<Value extends string>(question: string, options: readonly {
|
|
15
|
+
label: string;
|
|
16
|
+
value: Value;
|
|
17
|
+
short?: string;
|
|
18
|
+
}[], presentation?: {
|
|
19
|
+
header?: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
}, signal?: AbortSignal): Promise<Value[]>;
|
|
14
22
|
}
|
|
15
23
|
export interface BulkScanDiscoveryDependencies {
|
|
16
24
|
prompt: BulkScanPrompt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-scan-discovery.d.ts","sourceRoot":"","sources":["../src/bulk-scan-discovery.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA8CxC,MAAM,WAAW,cAAc;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;AAED,wBAAgB,mCAAmC,CAAC,OAAO,EAAE;IAC3D,MAAM,EAAE,YAAY,CAAC;IACrB,GAAG,IAAI,MAAM,CAAC;IACd,gBAAgB,IAAI,MAAM,CAAC;CAC5B,GAAG,6BAA6B,CAwChC;AAED,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,6BAA6B,EAC3C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CA8DtC"}
|
|
@@ -5,7 +5,7 @@ import { join, resolve } from "node:path";
|
|
|
5
5
|
import { stdin } from "node:process";
|
|
6
6
|
import { Writable } from "node:stream";
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
|
-
import { confirm, input, search } from "@inquirer/prompts";
|
|
8
|
+
import { checkbox, confirm, input, search, Separator } from "@inquirer/prompts";
|
|
9
9
|
import { Octokit } from "@octokit/core";
|
|
10
10
|
import Papa from "papaparse";
|
|
11
11
|
import { expandHome } from "./runtime.js";
|
|
@@ -222,6 +222,20 @@ function createTerminalPrompt(output) {
|
|
|
222
222
|
},
|
|
223
223
|
confirm: (message, defaultValue = false, signal) => confirm({ message, default: defaultValue }, context(signal)),
|
|
224
224
|
input: (message, defaultValue, signal) => input({ message, default: defaultValue }, context(signal)),
|
|
225
|
+
checkbox: (message, options, presentation, signal) => checkbox({
|
|
226
|
+
message,
|
|
227
|
+
choices: [
|
|
228
|
+
...(presentation?.header === undefined
|
|
229
|
+
? []
|
|
230
|
+
: [new Separator(presentation.header)]),
|
|
231
|
+
...options.map(({ label, value, short }) => ({
|
|
232
|
+
name: label,
|
|
233
|
+
value,
|
|
234
|
+
...(short === undefined ? {} : { short }),
|
|
235
|
+
})),
|
|
236
|
+
],
|
|
237
|
+
required: presentation?.required,
|
|
238
|
+
}, context(signal)),
|
|
225
239
|
select: (message, options, presentation, signal) => search({
|
|
226
240
|
message,
|
|
227
241
|
...(presentation?.header === undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;aAC1C,CAAC,CAAC;SACR,EACD,OAAO,CAAC,MAAM,CAAC,CAChB;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import { execFile as execFileCallback } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { lstat, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { stdin } from \"node:process\";\nimport { Writable } from \"node:stream\";\nimport { promisify } from \"node:util\";\nimport { confirm, input, search } from \"@inquirer/prompts\";\nimport { Octokit } from \"@octokit/core\";\nimport Papa from \"papaparse\";\nimport { expandHome } from \"./runtime.js\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\n\nconst execFile = promisify(execFileCallback);\nconst GITHUB_REPOSITORIES_QUERY = `\n query($owner: String!, $cursor: String) {\n repositoryOwner(login: $owner) {\n repositories(\n first: 100\n after: $cursor\n isArchived: false\n isFork: false\n orderBy: { field: PUSHED_AT, direction: DESC }\n ) {\n nodes {\n nameWithOwner\n pushedAt\n defaultBranchRef { target { oid } }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n }\n`;\n\ninterface GitHubRepository {\n fullName: string;\n url: string;\n revision: string;\n}\n\ninterface GitHubRepositoriesResponse {\n repositoryOwner: {\n repositories: {\n nodes: Array<{\n nameWithOwner: string;\n pushedAt: string;\n defaultBranchRef: { target: { oid: string } } | null;\n }>;\n pageInfo: { hasNextPage: boolean; endCursor: string | null };\n };\n } | null;\n}\n\nexport interface BulkScanPrompt {\n isInteractive(): boolean;\n write(value: string): void;\n confirm(\n question: string,\n defaultValue?: boolean,\n signal?: AbortSignal,\n ): Promise<boolean>;\n input(\n question: string,\n defaultValue?: string,\n signal?: AbortSignal,\n ): Promise<string>;\n select<Value extends string>(\n question: string,\n options: readonly { label: string; value: Value; short?: string }[],\n presentation?: { header?: string },\n signal?: AbortSignal,\n ): Promise<Value>;\n}\n\nexport interface BulkScanDiscoveryDependencies {\n prompt: BulkScanPrompt;\n now(): number;\n currentDirectory(): string;\n githubHost?: string;\n createGitHub(host: string, signal?: AbortSignal): Promise<Octokit>;\n}\n\nexport interface BulkScanWizardResult {\n inputPath: string;\n outputDir: string;\n githubHost: string;\n}\n\ninterface PromptOutput {\n write(value: string): unknown;\n readonly isTTY?: boolean;\n readonly columns?: number;\n}\n\nexport function createBulkScanDiscoveryDependencies(options: {\n output: PromptOutput;\n now(): number;\n currentDirectory(): string;\n}): BulkScanDiscoveryDependencies {\n return {\n prompt: createTerminalPrompt(options.output),\n now: options.now,\n currentDirectory: options.currentDirectory,\n ...(process.env[\"GH_HOST\"]?.trim()\n ? { githubHost: process.env[\"GH_HOST\"].trim() }\n : {}),\n createGitHub: async (host, signal) => {\n const trusted = await resolveTrustedExecutable(\n \"gh\",\n process.env,\n options.currentDirectory(),\n );\n if (trusted === null) {\n throw new Error(\n \"GitHub CLI is required. Install gh and sign in first.\",\n );\n }\n\n let token: string;\n try {\n const { stdout } = await execFile(\n trusted.executable,\n [\"auth\", \"token\", \"--hostname\", host],\n { env: trusted.environment, signal },\n );\n token = stdout.trim();\n } catch {\n signal?.throwIfAborted();\n throw new Error(\n \"GitHub sign-in is required. Run 'gh auth login' first.\",\n );\n }\n return new Octokit({\n auth: token,\n ...(host === \"github.com\" ? {} : { baseUrl: `https://${host}/api/v3` }),\n });\n },\n };\n}\n\nexport async function runBulkScanWizard(\n dependencies: BulkScanDiscoveryDependencies,\n signal?: AbortSignal,\n): Promise<BulkScanWizardResult | null> {\n const { prompt } = dependencies;\n if (!prompt.isInteractive()) {\n throw new Error(\n \"Interactive repository selection requires a terminal. Provide a CSV with 'codex-security bulk-scan repositories.csv --output-dir ./security-scans'.\",\n );\n }\n signal?.throwIfAborted();\n\n const githubHost = dependencies.githubHost ?? \"github.com\";\n const github = await dependencies.createGitHub(githubHost, signal);\n const owner = await selectGitHubOwner(github, prompt, signal);\n prompt.write(\"\\nFinding active repositories...\\n\");\n const discovered = await discoverGitHubRepositories(\n github,\n githubHost,\n owner,\n dependencies.now() - 90 * 86_400_000,\n signal,\n );\n if (discovered.length === 0) {\n prompt.write(\"\\nNo repositories matched your selection.\\n\");\n return null;\n }\n\n prompt.write(`\\nFound ${discovered.length} repositories.\\n`);\n const repositories = await selectGitHubRepositories(discovered, prompt);\n\n const outputDir = resolve(\n dependencies.currentDirectory(),\n expandHome(\n await prompt.input(\n \"Where should scan results be saved?\",\n \"./security-scans\",\n ),\n ),\n );\n const inputPath = join(outputDir, \"repositories.csv\");\n await validateWizardOutput(outputDir);\n prompt.write(\n `\\nReady to scan ${repositories.length} repositories?\\n` +\n `Results: ${outputDir}\\nRepository list: ${inputPath}\\n`,\n );\n if (!(await prompt.confirm(\"Start scanning?\"))) {\n prompt.write(\"\\nScan canceled.\\n\");\n return null;\n }\n signal?.throwIfAborted();\n\n await mkdir(outputDir, { recursive: true, mode: 0o700 });\n await writeFile(\n inputPath,\n `${Papa.unparse(\n repositories.map(({ fullName, url, revision }) => ({\n id: repositoryId(fullName),\n repository: url,\n revision,\n })),\n )}\\n`,\n { flag: \"wx\", mode: 0o600, ...(signal === undefined ? {} : { signal }) },\n );\n return { inputPath, outputDir, githubHost };\n}\n\nasync function selectGitHubOwner(\n github: Octokit,\n prompt: BulkScanPrompt,\n signal?: AbortSignal,\n): Promise<string> {\n const [firstPage, user] = await Promise.all([\n github.request(\"GET /user/orgs\", { per_page: 100, request: { signal } }),\n github.request(\"GET /user\", { request: { signal } }),\n ]);\n const organizations = [...firstPage.data];\n let response = firstPage;\n let page = 1;\n while (response.headers.link?.includes('rel=\"next\"')) {\n signal?.throwIfAborted();\n response = await github.request(\"GET /user/orgs\", {\n per_page: 100,\n page: ++page,\n request: { signal },\n });\n organizations.push(...response.data);\n }\n const personal = user.data.login;\n const owners = [personal, ...organizations.map(({ login }) => login)].sort();\n if (owners.length > 1) {\n return await prompt.select(\n \"Which account or organization should we scan?\",\n owners.map((owner) => ({ label: owner, value: owner })),\n );\n }\n prompt.write(`\\nFinding repositories in ${personal}.\\n`);\n return personal;\n}\n\nasync function selectGitHubRepositories(\n repositories: GitHubRepository[],\n prompt: BulkScanPrompt,\n): Promise<GitHubRepository[]> {\n const selected = new Set<string>();\n while (selected.size < repositories.length) {\n const choice = await prompt.select(\n \"Select repositories to scan (type to filter)\",\n [\n {\n label: selected.size\n ? `Done (${selected.size} selected)`\n : `All ${repositories.length} repositories`,\n value: \"\",\n },\n ...repositories\n .filter(({ fullName }) => !selected.has(fullName))\n .map(({ fullName }) => ({ label: fullName, value: fullName })),\n ],\n );\n if (!choice) break;\n selected.add(choice);\n }\n return selected.size\n ? repositories.filter(({ fullName }) => selected.has(fullName))\n : repositories;\n}\n\nasync function discoverGitHubRepositories(\n github: Octokit,\n host: string,\n owner: string,\n cutoff: number,\n signal?: AbortSignal,\n): Promise<GitHubRepository[]> {\n const repositories: GitHubRepository[] = [];\n let cursor: string | null = null;\n\n do {\n signal?.throwIfAborted();\n const result: GitHubRepositoriesResponse = await github.graphql(\n GITHUB_REPOSITORIES_QUERY,\n { owner, cursor, request: { signal } },\n );\n const connection = result.repositoryOwner?.repositories;\n if (connection === undefined) {\n throw new Error(\"GitHub could not list repositories for this account.\");\n }\n\n for (const repository of connection.nodes) {\n if (Date.parse(repository.pushedAt) < cutoff) return repositories;\n if (repository.defaultBranchRef === null) continue;\n repositories.push({\n fullName: repository.nameWithOwner,\n url: `https://${host}/${repository.nameWithOwner}.git`,\n revision: repository.defaultBranchRef.target.oid.toLowerCase(),\n });\n }\n cursor = connection.pageInfo.hasNextPage\n ? connection.pageInfo.endCursor\n : null;\n } while (cursor !== null);\n\n return repositories;\n}\n\nfunction repositoryId(fullName: string): string {\n const id = fullName.replace(\"/\", \"--\");\n if (id.length <= 128) return id;\n const hash = createHash(\"sha256\").update(fullName).digest(\"hex\").slice(0, 16);\n return `${id.slice(0, 111)}-${hash}`;\n}\n\nasync function validateWizardOutput(outputDir: string): Promise<void> {\n let metadata;\n try {\n metadata = await lstat(outputDir);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n throw error;\n }\n if (!metadata.isDirectory()) {\n throw new Error(\"The scan output must be a real directory.\");\n }\n\n for (const name of [\"repositories.csv\", \"manifest.json\"]) {\n try {\n await lstat(join(outputDir, name));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n throw error;\n }\n throw new Error(\n \"The selected output directory already contains a repository list or scan. Choose a new directory or resume the existing scan.\",\n );\n }\n}\n\nfunction createTerminalPrompt(output: PromptOutput): BulkScanPrompt {\n const context = (signal?: AbortSignal) => {\n const stream = new Writable({\n write(chunk: Buffer, _encoding, callback) {\n output.write(chunk.toString(\"utf8\"));\n callback();\n },\n });\n Object.defineProperty(stream, \"columns\", {\n configurable: true,\n get: () => output.columns,\n });\n return { input: stdin, output: stream, signal };\n };\n\n return {\n isInteractive: () => stdin.isTTY === true && output.isTTY === true,\n write: (value) => {\n output.write(value);\n },\n confirm: (message, defaultValue = false, signal) =>\n confirm({ message, default: defaultValue }, context(signal)),\n input: (message, defaultValue, signal) =>\n input({ message, default: defaultValue }, context(signal)),\n select: (message, options, presentation, signal) =>\n search(\n {\n message,\n ...(presentation?.header === undefined\n ? {}\n : {\n theme: {\n style: {\n searchTerm: (term: string) =>\n `${term}\\n ${presentation.header}`,\n },\n },\n }),\n source: (term) =>\n options\n .filter(({ label }) =>\n label.toLowerCase().includes(term?.toLowerCase() ?? \"\"),\n )\n .map(({ label, value, short }) => ({\n name: label,\n value,\n ...(short === undefined ? {} : { short }),\n })),\n },\n context(signal),\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bulk-scan-discovery.js","sourceRoot":"","sources":["../src/bulk-scan-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,E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E;yBACtC;qBACF;iBACF,CAAC;YACN,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,OAAO;iBACJ,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACpB,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CACxD;iBACA,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;gBACjC,IAAI,EAAE,KAAK;gBACX,KAAK;gBACL,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;aAC1C,CAAC,CAAC;SACR,EACD,OAAO,CAAC,MAAM,CAAC,CAChB;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import { execFile as execFileCallback } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { lstat, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { stdin } from \"node:process\";\nimport { Writable } from \"node:stream\";\nimport { promisify } from \"node:util\";\nimport { checkbox, confirm, input, search, Separator } from \"@inquirer/prompts\";\nimport { Octokit } from \"@octokit/core\";\nimport Papa from \"papaparse\";\nimport { expandHome } from \"./runtime.js\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\n\nconst execFile = promisify(execFileCallback);\nconst GITHUB_REPOSITORIES_QUERY = `\n query($owner: String!, $cursor: String) {\n repositoryOwner(login: $owner) {\n repositories(\n first: 100\n after: $cursor\n isArchived: false\n isFork: false\n orderBy: { field: PUSHED_AT, direction: DESC }\n ) {\n nodes {\n nameWithOwner\n pushedAt\n defaultBranchRef { target { oid } }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n }\n`;\n\ninterface GitHubRepository {\n fullName: string;\n url: string;\n revision: string;\n}\n\ninterface GitHubRepositoriesResponse {\n repositoryOwner: {\n repositories: {\n nodes: Array<{\n nameWithOwner: string;\n pushedAt: string;\n defaultBranchRef: { target: { oid: string } } | null;\n }>;\n pageInfo: { hasNextPage: boolean; endCursor: string | null };\n };\n } | null;\n}\n\nexport interface BulkScanPrompt {\n isInteractive(): boolean;\n write(value: string): void;\n confirm(\n question: string,\n defaultValue?: boolean,\n signal?: AbortSignal,\n ): Promise<boolean>;\n input(\n question: string,\n defaultValue?: string,\n signal?: AbortSignal,\n ): Promise<string>;\n select<Value extends string>(\n question: string,\n options: readonly { label: string; value: Value; short?: string }[],\n presentation?: { header?: string },\n signal?: AbortSignal,\n ): Promise<Value>;\n checkbox<Value extends string>(\n question: string,\n options: readonly { label: string; value: Value; short?: string }[],\n presentation?: { header?: string; required?: boolean },\n signal?: AbortSignal,\n ): Promise<Value[]>;\n}\n\nexport interface BulkScanDiscoveryDependencies {\n prompt: BulkScanPrompt;\n now(): number;\n currentDirectory(): string;\n githubHost?: string;\n createGitHub(host: string, signal?: AbortSignal): Promise<Octokit>;\n}\n\nexport interface BulkScanWizardResult {\n inputPath: string;\n outputDir: string;\n githubHost: string;\n}\n\ninterface PromptOutput {\n write(value: string): unknown;\n readonly isTTY?: boolean;\n readonly columns?: number;\n}\n\nexport function createBulkScanDiscoveryDependencies(options: {\n output: PromptOutput;\n now(): number;\n currentDirectory(): string;\n}): BulkScanDiscoveryDependencies {\n return {\n prompt: createTerminalPrompt(options.output),\n now: options.now,\n currentDirectory: options.currentDirectory,\n ...(process.env[\"GH_HOST\"]?.trim()\n ? { githubHost: process.env[\"GH_HOST\"].trim() }\n : {}),\n createGitHub: async (host, signal) => {\n const trusted = await resolveTrustedExecutable(\n \"gh\",\n process.env,\n options.currentDirectory(),\n );\n if (trusted === null) {\n throw new Error(\n \"GitHub CLI is required. Install gh and sign in first.\",\n );\n }\n\n let token: string;\n try {\n const { stdout } = await execFile(\n trusted.executable,\n [\"auth\", \"token\", \"--hostname\", host],\n { env: trusted.environment, signal },\n );\n token = stdout.trim();\n } catch {\n signal?.throwIfAborted();\n throw new Error(\n \"GitHub sign-in is required. Run 'gh auth login' first.\",\n );\n }\n return new Octokit({\n auth: token,\n ...(host === \"github.com\" ? {} : { baseUrl: `https://${host}/api/v3` }),\n });\n },\n };\n}\n\nexport async function runBulkScanWizard(\n dependencies: BulkScanDiscoveryDependencies,\n signal?: AbortSignal,\n): Promise<BulkScanWizardResult | null> {\n const { prompt } = dependencies;\n if (!prompt.isInteractive()) {\n throw new Error(\n \"Interactive repository selection requires a terminal. Provide a CSV with 'codex-security bulk-scan repositories.csv --output-dir ./security-scans'.\",\n );\n }\n signal?.throwIfAborted();\n\n const githubHost = dependencies.githubHost ?? \"github.com\";\n const github = await dependencies.createGitHub(githubHost, signal);\n const owner = await selectGitHubOwner(github, prompt, signal);\n prompt.write(\"\\nFinding active repositories...\\n\");\n const discovered = await discoverGitHubRepositories(\n github,\n githubHost,\n owner,\n dependencies.now() - 90 * 86_400_000,\n signal,\n );\n if (discovered.length === 0) {\n prompt.write(\"\\nNo repositories matched your selection.\\n\");\n return null;\n }\n\n prompt.write(`\\nFound ${discovered.length} repositories.\\n`);\n const repositories = await selectGitHubRepositories(discovered, prompt);\n\n const outputDir = resolve(\n dependencies.currentDirectory(),\n expandHome(\n await prompt.input(\n \"Where should scan results be saved?\",\n \"./security-scans\",\n ),\n ),\n );\n const inputPath = join(outputDir, \"repositories.csv\");\n await validateWizardOutput(outputDir);\n prompt.write(\n `\\nReady to scan ${repositories.length} repositories?\\n` +\n `Results: ${outputDir}\\nRepository list: ${inputPath}\\n`,\n );\n if (!(await prompt.confirm(\"Start scanning?\"))) {\n prompt.write(\"\\nScan canceled.\\n\");\n return null;\n }\n signal?.throwIfAborted();\n\n await mkdir(outputDir, { recursive: true, mode: 0o700 });\n await writeFile(\n inputPath,\n `${Papa.unparse(\n repositories.map(({ fullName, url, revision }) => ({\n id: repositoryId(fullName),\n repository: url,\n revision,\n })),\n )}\\n`,\n { flag: \"wx\", mode: 0o600, ...(signal === undefined ? {} : { signal }) },\n );\n return { inputPath, outputDir, githubHost };\n}\n\nasync function selectGitHubOwner(\n github: Octokit,\n prompt: BulkScanPrompt,\n signal?: AbortSignal,\n): Promise<string> {\n const [firstPage, user] = await Promise.all([\n github.request(\"GET /user/orgs\", { per_page: 100, request: { signal } }),\n github.request(\"GET /user\", { request: { signal } }),\n ]);\n const organizations = [...firstPage.data];\n let response = firstPage;\n let page = 1;\n while (response.headers.link?.includes('rel=\"next\"')) {\n signal?.throwIfAborted();\n response = await github.request(\"GET /user/orgs\", {\n per_page: 100,\n page: ++page,\n request: { signal },\n });\n organizations.push(...response.data);\n }\n const personal = user.data.login;\n const owners = [personal, ...organizations.map(({ login }) => login)].sort();\n if (owners.length > 1) {\n return await prompt.select(\n \"Which account or organization should we scan?\",\n owners.map((owner) => ({ label: owner, value: owner })),\n );\n }\n prompt.write(`\\nFinding repositories in ${personal}.\\n`);\n return personal;\n}\n\nasync function selectGitHubRepositories(\n repositories: GitHubRepository[],\n prompt: BulkScanPrompt,\n): Promise<GitHubRepository[]> {\n const selected = new Set<string>();\n while (selected.size < repositories.length) {\n const choice = await prompt.select(\n \"Select repositories to scan (type to filter)\",\n [\n {\n label: selected.size\n ? `Done (${selected.size} selected)`\n : `All ${repositories.length} repositories`,\n value: \"\",\n },\n ...repositories\n .filter(({ fullName }) => !selected.has(fullName))\n .map(({ fullName }) => ({ label: fullName, value: fullName })),\n ],\n );\n if (!choice) break;\n selected.add(choice);\n }\n return selected.size\n ? repositories.filter(({ fullName }) => selected.has(fullName))\n : repositories;\n}\n\nasync function discoverGitHubRepositories(\n github: Octokit,\n host: string,\n owner: string,\n cutoff: number,\n signal?: AbortSignal,\n): Promise<GitHubRepository[]> {\n const repositories: GitHubRepository[] = [];\n let cursor: string | null = null;\n\n do {\n signal?.throwIfAborted();\n const result: GitHubRepositoriesResponse = await github.graphql(\n GITHUB_REPOSITORIES_QUERY,\n { owner, cursor, request: { signal } },\n );\n const connection = result.repositoryOwner?.repositories;\n if (connection === undefined) {\n throw new Error(\"GitHub could not list repositories for this account.\");\n }\n\n for (const repository of connection.nodes) {\n if (Date.parse(repository.pushedAt) < cutoff) return repositories;\n if (repository.defaultBranchRef === null) continue;\n repositories.push({\n fullName: repository.nameWithOwner,\n url: `https://${host}/${repository.nameWithOwner}.git`,\n revision: repository.defaultBranchRef.target.oid.toLowerCase(),\n });\n }\n cursor = connection.pageInfo.hasNextPage\n ? connection.pageInfo.endCursor\n : null;\n } while (cursor !== null);\n\n return repositories;\n}\n\nfunction repositoryId(fullName: string): string {\n const id = fullName.replace(\"/\", \"--\");\n if (id.length <= 128) return id;\n const hash = createHash(\"sha256\").update(fullName).digest(\"hex\").slice(0, 16);\n return `${id.slice(0, 111)}-${hash}`;\n}\n\nasync function validateWizardOutput(outputDir: string): Promise<void> {\n let metadata;\n try {\n metadata = await lstat(outputDir);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n throw error;\n }\n if (!metadata.isDirectory()) {\n throw new Error(\"The scan output must be a real directory.\");\n }\n\n for (const name of [\"repositories.csv\", \"manifest.json\"]) {\n try {\n await lstat(join(outputDir, name));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n throw error;\n }\n throw new Error(\n \"The selected output directory already contains a repository list or scan. Choose a new directory or resume the existing scan.\",\n );\n }\n}\n\nfunction createTerminalPrompt(output: PromptOutput): BulkScanPrompt {\n const context = (signal?: AbortSignal) => {\n const stream = new Writable({\n write(chunk: Buffer, _encoding, callback) {\n output.write(chunk.toString(\"utf8\"));\n callback();\n },\n });\n Object.defineProperty(stream, \"columns\", {\n configurable: true,\n get: () => output.columns,\n });\n return { input: stdin, output: stream, signal };\n };\n\n return {\n isInteractive: () => stdin.isTTY === true && output.isTTY === true,\n write: (value) => {\n output.write(value);\n },\n confirm: (message, defaultValue = false, signal) =>\n confirm({ message, default: defaultValue }, context(signal)),\n input: (message, defaultValue, signal) =>\n input({ message, default: defaultValue }, context(signal)),\n checkbox: (message, options, presentation, signal) =>\n checkbox(\n {\n message,\n choices: [\n ...(presentation?.header === undefined\n ? []\n : [new Separator(presentation.header)]),\n ...options.map(({ label, value, short }) => ({\n name: label,\n value,\n ...(short === undefined ? {} : { short }),\n })),\n ],\n required: presentation?.required,\n },\n context(signal),\n ),\n select: (message, options, presentation, signal) =>\n search(\n {\n message,\n ...(presentation?.header === undefined\n ? {}\n : {\n theme: {\n style: {\n searchTerm: (term: string) =>\n `${term}\\n ${presentation.header}`,\n },\n },\n }),\n source: (term) =>\n options\n .filter(({ label }) =>\n label.toLowerCase().includes(term?.toLowerCase() ?? \"\"),\n )\n .map(({ label, value, short }) => ({\n name: label,\n value,\n ...(short === undefined ? {} : { short }),\n })),\n },\n context(signal),\n ),\n };\n}\n"]}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { CodexSecurity } from "./api.js";
|
|
3
|
+
import { publishScanToCloud } from "./cloud-publish.js";
|
|
3
4
|
import { type BulkScanDiscoveryDependencies, type BulkScanPrompt } from "./bulk-scan-discovery.js";
|
|
4
5
|
import { type CodexSecurityConfig, type ExternalModelProvider, type JsonObject } from "./config.js";
|
|
5
6
|
import { type LinearClientFactory } from "./linear.js";
|
|
6
7
|
import type { Finding } from "./models.js";
|
|
7
8
|
import { planComponents } from "./component-plan.js";
|
|
8
|
-
import { publishScan } from "./publish.js";
|
|
9
|
+
import { checkScanPublication, publishScan } from "./publish.js";
|
|
9
10
|
import { type CodexCommand } from "./runtime.js";
|
|
10
11
|
import { type matchScanFindings } from "./scan-comparison.js";
|
|
11
12
|
import type { PatchSelection } from "./patch-tui.js";
|
|
@@ -50,8 +51,10 @@ interface CliDependencies {
|
|
|
50
51
|
prepareAuthenticationHome?: (environment: NodeJS.ProcessEnv) => Promise<string>;
|
|
51
52
|
hasStoredChatGPTSignIn?: (signal?: AbortSignal) => Promise<boolean>;
|
|
52
53
|
scanAuthenticationPrompt?: Pick<BulkScanPrompt, "isInteractive" | "select">;
|
|
53
|
-
publishPrompt?: Pick<BulkScanPrompt, "isInteractive" | "select"
|
|
54
|
+
publishPrompt?: Pick<BulkScanPrompt, "isInteractive" | "select"> & Partial<Pick<BulkScanPrompt, "checkbox">>;
|
|
55
|
+
checkScanPublication?: typeof checkScanPublication;
|
|
54
56
|
publishScan?: typeof publishScan;
|
|
57
|
+
publishScanToCloud?: typeof publishScanToCloud;
|
|
55
58
|
confirmPatchReview?: (question: string) => Promise<boolean>;
|
|
56
59
|
patchEditor?: (repository: string, findings: readonly Finding[]) => Promise<PatchSelection | null>;
|
|
57
60
|
currentDirectory(): string;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA2CA,OAAO,EAEL,aAAa,EAUd,MAAM,UAAU,CAAC;AAElB,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAcrB,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAuB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA2CA,OAAO,EAEL,aAAa,EAUd,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAOL,KAAK,m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