@openai/codex-security 0.1.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/LICENSE +201 -0
- package/README.md +306 -0
- package/_bundled_plugin/.app.json +20 -0
- package/_bundled_plugin/.codex-plugin/plugin.json +41 -0
- package/_bundled_plugin/.mcp.json +20 -0
- package/_bundled_plugin/assets/logo.png +0 -0
- package/_bundled_plugin/examples/completed-scan/coverage.json +22 -0
- package/_bundled_plugin/examples/completed-scan/findings.json +51 -0
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +43 -0
- package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
- package/_bundled_plugin/mcp/server.mjs +24 -0
- 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/preflight/capability-profiles.toml +179 -0
- package/_bundled_plugin/references/config-preflight.md +115 -0
- package/_bundled_plugin/references/final-report.md +205 -0
- package/_bundled_plugin/references/finding-detail-fields.md +162 -0
- package/_bundled_plugin/references/sarif-adapter.md +26 -0
- package/_bundled_plugin/references/scan-artifacts.md +116 -0
- package/_bundled_plugin/references/scan-contract.md +164 -0
- package/_bundled_plugin/references/security-guidance.md +15 -0
- package/_bundled_plugin/references/shared-hard-rules.md +15 -0
- package/_bundled_plugin/references/static-finding-assessment.md +75 -0
- package/_bundled_plugin/schemas/coverage.schema.json +228 -0
- package/_bundled_plugin/schemas/findings.schema.json +359 -0
- package/_bundled_plugin/schemas/scan-manifest.schema.json +332 -0
- package/_bundled_plugin/scripts/config_preflight.py +901 -0
- package/_bundled_plugin/scripts/deep_scan_config.py +108 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +1547 -0
- package/_bundled_plugin/scripts/filesystem_identity.py +30 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +2208 -0
- package/_bundled_plugin/scripts/finding_preview.py +270 -0
- package/_bundled_plugin/scripts/generate_rank_input.py +1013 -0
- package/_bundled_plugin/scripts/normalize_candidates.py +320 -0
- package/_bundled_plugin/scripts/rank_preview.py +968 -0
- package/_bundled_plugin/scripts/report_projection.py +844 -0
- package/_bundled_plugin/scripts/resolve_security_md.py +158 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +26 -0
- package/_bundled_plugin/scripts/validate_report_format.py +138 -0
- package/_bundled_plugin/scripts/validate_scan_contract.py +108 -0
- package/_bundled_plugin/scripts/validate_tracking_source.py +92 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +612 -0
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -0
- package/_bundled_plugin/scripts/workbench/handoff.py +238 -0
- package/_bundled_plugin/scripts/workbench_cli.py +325 -0
- package/_bundled_plugin/scripts/workbench_constants.py +81 -0
- package/_bundled_plugin/scripts/workbench_db.py +3728 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +242 -0
- package/_bundled_plugin/scripts/workbench_progress.py +226 -0
- package/_bundled_plugin/scripts/workbench_remediation.py +125 -0
- package/_bundled_plugin/scripts/workbench_scan_history.py +829 -0
- package/_bundled_plugin/scripts/workbench_scan_start.py +149 -0
- package/_bundled_plugin/scripts/workbench_schema.py +714 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +99 -0
- package/_bundled_plugin/scripts/workbench_target.py +469 -0
- package/_bundled_plugin/scripts/workbench_target_state.py +63 -0
- package/_bundled_plugin/scripts/workbench_validation.py +294 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +117 -0
- package/_bundled_plugin/skills/attack-path-analysis/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +76 -0
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +153 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +166 -0
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +93 -0
- package/_bundled_plugin/skills/define-security-policy/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +155 -0
- package/_bundled_plugin/skills/finding-discovery/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +112 -0
- package/_bundled_plugin/skills/fix-finding/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +240 -0
- package/_bundled_plugin/skills/propose-security-hardening/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +424 -0
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +167 -0
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +42 -0
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +48 -0
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +85 -0
- package/_bundled_plugin/skills/threat-model/SKILL.md +59 -0
- package/_bundled_plugin/skills/threat-model/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model/references/threat-model-guidance.md +48 -0
- package/_bundled_plugin/skills/track-findings/SKILL.md +222 -0
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +6 -0
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +54 -0
- package/_bundled_plugin/skills/track-findings/references/jira.md +77 -0
- package/_bundled_plugin/skills/triage-finding/SKILL.md +342 -0
- package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +168 -0
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +62 -0
- package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +108 -0
- package/_bundled_plugin/skills/validation/SKILL.md +110 -0
- package/_bundled_plugin/skills/validation/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/validation/references/validation-guidance.md +122 -0
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +263 -0
- package/_bundled_plugin/skills/vulnerability-writeup/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +104 -0
- package/bin/codex-security.mjs +26 -0
- package/dist/api.d.ts +112 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +1051 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +29 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +246 -0
- package/dist/auth.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts +35 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -0
- package/dist/bulk-scan-discovery.js +217 -0
- package/dist/bulk-scan-discovery.js.map +1 -0
- package/dist/cli.d.ts +67 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2128 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +199 -0
- package/dist/config.js.map +1 -0
- package/dist/contract.d.ts +21 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +848 -0
- package/dist/contract.js.map +1 -0
- package/dist/cost.d.ts +30 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +280 -0
- package/dist/cost.js.map +1 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge-base.d.ts +7 -0
- package/dist/knowledge-base.d.ts.map +1 -0
- package/dist/knowledge-base.js +181 -0
- package/dist/knowledge-base.js.map +1 -0
- package/dist/models.d.ts +231 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +3 -0
- package/dist/models.js.map +1 -0
- package/dist/multiscan.d.ts +30 -0
- package/dist/multiscan.d.ts.map +1 -0
- package/dist/multiscan.js +397 -0
- package/dist/multiscan.js.map +1 -0
- package/dist/result.d.ts +39 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +71 -0
- package/dist/result.js.map +1 -0
- package/dist/runtime.d.ts +69 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +997 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scan-comparison.d.ts +42 -0
- package/dist/scan-comparison.d.ts.map +1 -0
- package/dist/scan-comparison.js +153 -0
- package/dist/scan-comparison.js.map +1 -0
- package/dist/scan-history-renderer.d.ts +13 -0
- package/dist/scan-history-renderer.d.ts.map +1 -0
- package/dist/scan-history-renderer.js +297 -0
- package/dist/scan-history-renderer.js.map +1 -0
- package/dist/targets.d.ts +39 -0
- package/dist/targets.d.ts.map +1 -0
- package/dist/targets.js +295 -0
- package/dist/targets.js.map +1 -0
- package/dist/trusted-executable.d.ts +6 -0
- package/dist/trusted-executable.d.ts.map +1 -0
- package/dist/trusted-executable.js +77 -0
- package/dist/trusted-executable.js.map +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +42 -0
- package/dist/version.js.map +1 -0
- package/dist/worker-progress.d.ts +13 -0
- package/dist/worker-progress.d.ts.map +1 -0
- package/dist/worker-progress.js +113 -0
- package/dist/worker-progress.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""Shared scan-start helpers for the Codex Security workbench."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
import sqlite3
|
|
8
|
+
import sys
|
|
9
|
+
import tempfile
|
|
10
|
+
from datetime import datetime, timezone
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
# Some plugin hosts launch Python with safe-path isolation enabled.
|
|
14
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
15
|
+
from filesystem_identity import serialize_filesystem_identity
|
|
16
|
+
from workbench_target import (
|
|
17
|
+
directory_content_digest,
|
|
18
|
+
git_revision,
|
|
19
|
+
worktree_content_digest,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def safe_segment(value: str) -> str:
|
|
24
|
+
segment = "".join(
|
|
25
|
+
character if character.isalnum() or character in "._-" else "-" for character in value
|
|
26
|
+
)
|
|
27
|
+
return segment.strip("-") or "scan"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def compact_timestamp() -> str:
|
|
31
|
+
return datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def scan_target_identity(
|
|
35
|
+
target: Path,
|
|
36
|
+
diff_target: dict[str, str] | None,
|
|
37
|
+
*,
|
|
38
|
+
metadata: os.stat_result | None = None,
|
|
39
|
+
) -> tuple[str, str | None, int | str, int | str]:
|
|
40
|
+
if metadata is None:
|
|
41
|
+
metadata = target.stat()
|
|
42
|
+
revision = diff_target["headRevision"] if diff_target else git_revision(target)
|
|
43
|
+
snapshot_digest = None
|
|
44
|
+
if diff_target is None:
|
|
45
|
+
snapshot_digest = (
|
|
46
|
+
directory_content_digest(target)
|
|
47
|
+
if revision == "unversioned"
|
|
48
|
+
else worktree_content_digest(target)
|
|
49
|
+
)
|
|
50
|
+
return (
|
|
51
|
+
revision,
|
|
52
|
+
snapshot_digest,
|
|
53
|
+
serialize_filesystem_identity(metadata.st_dev),
|
|
54
|
+
serialize_filesystem_identity(metadata.st_ino),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def scan_diff_identity(
|
|
59
|
+
diff_target: dict[str, str] | None,
|
|
60
|
+
) -> tuple[str | None, str | None, str | None, str | None]:
|
|
61
|
+
if diff_target is None:
|
|
62
|
+
return (None, None, None, None)
|
|
63
|
+
return (
|
|
64
|
+
diff_target["kind"],
|
|
65
|
+
diff_target["baseRevision"],
|
|
66
|
+
diff_target["headRevision"],
|
|
67
|
+
diff_target.get("contentDigest"),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def insert_running_scan(
|
|
72
|
+
connection: sqlite3.Connection,
|
|
73
|
+
*,
|
|
74
|
+
scan_id: str,
|
|
75
|
+
workspace: sqlite3.Row,
|
|
76
|
+
target: Path,
|
|
77
|
+
scope: str,
|
|
78
|
+
diff_target: dict[str, str] | None,
|
|
79
|
+
target_identity: tuple[str, str | None, int | str, int | str],
|
|
80
|
+
target_root: Path,
|
|
81
|
+
target_summary: str | None,
|
|
82
|
+
scope_file_count: int,
|
|
83
|
+
timestamp: str,
|
|
84
|
+
handoff_status: str = "pending",
|
|
85
|
+
scan_dir: Path | None = None,
|
|
86
|
+
) -> str:
|
|
87
|
+
revision = target_identity[0]
|
|
88
|
+
if scan_dir is None:
|
|
89
|
+
scan_dir = Path(
|
|
90
|
+
tempfile.mkdtemp(
|
|
91
|
+
prefix=f"{safe_segment(revision)}_{compact_timestamp()}_",
|
|
92
|
+
dir=target_root,
|
|
93
|
+
)
|
|
94
|
+
).resolve()
|
|
95
|
+
connection.execute(
|
|
96
|
+
"""
|
|
97
|
+
INSERT INTO scans (
|
|
98
|
+
id, workspace_id, target_id, target_path, target_revision, target_snapshot_digest,
|
|
99
|
+
target_device, target_inode, scope, mode, user_context,
|
|
100
|
+
deep_scan_owner_thread_id, diff_target_kind, diff_base_revision,
|
|
101
|
+
diff_head_revision, diff_content_digest, target_summary, scan_dir, status, phase,
|
|
102
|
+
handoff_status, started_at, created_at, updated_at
|
|
103
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', 'preflight',
|
|
104
|
+
?, ?, ?, ?)
|
|
105
|
+
""",
|
|
106
|
+
(
|
|
107
|
+
scan_id,
|
|
108
|
+
workspace["id"],
|
|
109
|
+
workspace["target_id"],
|
|
110
|
+
str(target),
|
|
111
|
+
*target_identity,
|
|
112
|
+
scope,
|
|
113
|
+
workspace["default_mode"],
|
|
114
|
+
workspace["user_context"],
|
|
115
|
+
workspace["thread_id"] if workspace["default_mode"] == "deep" else None,
|
|
116
|
+
diff_target["kind"] if diff_target else None,
|
|
117
|
+
diff_target["baseRevision"] if diff_target else None,
|
|
118
|
+
diff_target["headRevision"] if diff_target else None,
|
|
119
|
+
diff_target.get("contentDigest") if diff_target else None,
|
|
120
|
+
target_summary,
|
|
121
|
+
str(scan_dir),
|
|
122
|
+
handoff_status,
|
|
123
|
+
timestamp,
|
|
124
|
+
timestamp,
|
|
125
|
+
timestamp,
|
|
126
|
+
),
|
|
127
|
+
)
|
|
128
|
+
connection.execute(
|
|
129
|
+
"""
|
|
130
|
+
INSERT INTO scan_progress (
|
|
131
|
+
scan_id, scope_file_count, review_items_total, review_items_completed,
|
|
132
|
+
reportable_findings_count, updated_at
|
|
133
|
+
) VALUES (?, ?, 0, 0, 0, ?)
|
|
134
|
+
""",
|
|
135
|
+
(scan_id, scope_file_count, timestamp),
|
|
136
|
+
)
|
|
137
|
+
connection.execute(
|
|
138
|
+
"UPDATE workspaces SET active_scan_id = ?, updated_at = ? WHERE id = ?",
|
|
139
|
+
(scan_id, timestamp, workspace["id"]),
|
|
140
|
+
)
|
|
141
|
+
return scan_id
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def main() -> None:
|
|
145
|
+
argparse.ArgumentParser(description=__doc__).parse_args()
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if __name__ == "__main__":
|
|
149
|
+
main()
|