@openai/codex-security 0.6.0 → 0.7.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 +68 -37
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +1 -1
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +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/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/access-advisory.md +11 -0
- package/_bundled_plugin/references/core-scan.md +30 -77
- package/_bundled_plugin/references/final-report.md +45 -189
- package/_bundled_plugin/references/scan-contract.md +2 -0
- package/_bundled_plugin/references/scan-prologue.md +1 -1
- package/_bundled_plugin/references/scan-runtime.md +1 -5
- package/_bundled_plugin/references/threat-model.md +33 -41
- package/_bundled_plugin/schemas/coverage.schema.json +12 -1
- package/_bundled_plugin/schemas/scan-manifest.schema.json +1 -0
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +38 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +39 -39
- package/_bundled_plugin/scripts/deep_scan_workbench.py +145 -85
- package/_bundled_plugin/scripts/finalize_scan_contract.py +189 -57
- package/_bundled_plugin/scripts/report_projection.py +44 -15
- package/_bundled_plugin/scripts/threat_model_projection.py +4 -2
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -14
- package/_bundled_plugin/scripts/workbench/retained_coverage.py +3218 -0
- package/_bundled_plugin/scripts/workbench/retained_records.py +627 -0
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +644 -1
- package/_bundled_plugin/scripts/workbench/saved_outputs.py +72 -0
- package/_bundled_plugin/scripts/workbench/saved_sources.py +712 -0
- package/_bundled_plugin/scripts/workbench_cli.py +3 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +479 -0
- package/_bundled_plugin/scripts/workbench_db.py +51 -22
- package/_bundled_plugin/scripts/workbench_feedback.py +0 -1
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +51 -9
- package/_bundled_plugin/scripts/workbench_native_indexes.py +56 -44
- package/_bundled_plugin/scripts/workbench_saved_results.py +641 -2387
- package/_bundled_plugin/scripts/workbench_scan_history.py +72 -7
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_scopes.py +4 -1
- package/_bundled_plugin/scripts/workbench_target.py +142 -17
- package/_bundled_plugin/scripts/workbench_validation.py +9 -2
- package/_bundled_plugin/shared/workbench-history-repairs.json +21 -0
- package/_bundled_plugin/shared/workbench-migrations.json +28 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +3 -14
- package/_bundled_plugin/skills/assess-patch-risk/references/windows-validation.md +14 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +38 -103
- package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +11 -73
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +57 -116
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +28 -51
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +9 -9
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +26 -140
- package/_bundled_plugin/skills/fix-finding/SKILL.md +9 -28
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +28 -218
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +29 -424
- package/_bundled_plugin/skills/publish-findings/SKILL.md +28 -24
- package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +64 -0
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +12 -12
- package/_bundled_plugin/skills/security-scan/SKILL.md +28 -16
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +11 -17
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +52 -69
- package/_bundled_plugin/skills/threat-model/SKILL.md +16 -9
- package/_bundled_plugin/skills/triage-finding/SKILL.md +5 -15
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -6
- package/_bundled_plugin/skills/validation/SKILL.md +42 -104
- package/_bundled_plugin/skills/validation/references/validation-guidance.md +21 -106
- package/_bundled_plugin/skills/verify-fix/SKILL.md +4 -2
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +21 -159
- package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +18 -60
- package/dist/api.d.ts +5 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +341 -37
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +4 -1
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +674 -419
- package/dist/cli.js.map +1 -1
- package/dist/component-scan.d.ts +8 -2
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +2 -0
- package/dist/component-scan.js.map +1 -1
- package/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +67 -33
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts +18 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +107 -12
- package/dist/cost.js.map +1 -1
- package/dist/coverage-presentation.d.ts +6 -0
- package/dist/coverage-presentation.d.ts.map +1 -0
- package/dist/coverage-presentation.js +34 -0
- package/dist/coverage-presentation.js.map +1 -0
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +30 -4
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +3 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +7 -5
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/endor-findings.d.ts +4 -3
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +16 -11
- package/dist/endor-findings.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +13 -5
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +8 -1
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +1 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +11 -3
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +11 -1
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +15 -6
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-import-contract.d.ts +3 -1
- package/dist/external-import-contract.d.ts.map +1 -1
- package/dist/external-import-contract.js +33 -25
- package/dist/external-import-contract.js.map +1 -1
- package/dist/external-imports-feature.d.ts +6 -0
- package/dist/external-imports-feature.d.ts.map +1 -0
- package/dist/external-imports-feature.js +51 -0
- package/dist/external-imports-feature.js.map +1 -0
- package/dist/finding-workflow.d.ts +22 -5
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +21 -9
- package/dist/finding-workflow.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +3 -1
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-findings.d.ts +4 -3
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +16 -14
- package/dist/github-findings.js.map +1 -1
- package/dist/hosted-remediation.d.ts.map +1 -1
- package/dist/hosted-remediation.js +19 -2
- package/dist/hosted-remediation.js.map +1 -1
- package/dist/hosted-scan.d.ts +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +0 -5
- package/dist/hosted-scan.js.map +1 -1
- package/dist/import-scan.js +1 -1
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -0
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +17 -8
- package/dist/knowledge-base.js.map +1 -1
- package/dist/models.d.ts +1 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/owner-evidence.d.ts +2 -0
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -1
- package/dist/owner-evidence.js.map +1 -1
- package/dist/publish.d.ts +2 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/remediation.d.ts +1 -25
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +3 -24
- package/dist/remediation.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +7 -7
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts +5 -3
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +79 -26
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +8 -2
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-owner-suggestions.d.ts +1 -1
- package/dist/scan-owner-suggestions.d.ts.map +1 -1
- package/dist/scan-owner-suggestions.js +4 -4
- package/dist/scan-owner-suggestions.js.map +1 -1
- package/dist/scan-usage-display.d.ts +8 -0
- package/dist/scan-usage-display.d.ts.map +1 -0
- package/dist/scan-usage-display.js +46 -0
- package/dist/scan-usage-display.js.map +1 -0
- package/dist/scanner-import.d.ts +1 -1
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +7 -3
- package/dist/scanner-import.js.map +1 -1
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +1 -20
- package/dist/security-policy.js.map +1 -1
- package/dist/semgrep-findings.d.ts +4 -3
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +9 -9
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/skill-authentication.d.ts +18 -0
- package/dist/skill-authentication.d.ts.map +1 -0
- package/dist/skill-authentication.js +82 -0
- package/dist/skill-authentication.js.map +1 -0
- package/dist/snyk-findings.d.ts +5 -4
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +18 -17
- package/dist/snyk-findings.js.map +1 -1
- package/dist/suggest-owners.d.ts +4 -1
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +53 -21
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +4 -1
- package/dist/targets.js.map +1 -1
- package/dist/wiz-csv.d.ts +2 -1
- package/dist/wiz-csv.d.ts.map +1 -1
- package/dist/wiz-csv.js +3 -3
- package/dist/wiz-csv.js.map +1 -1
- package/dist/wiz-findings.d.ts +2 -1
- package/dist/wiz-findings.d.ts.map +1 -1
- package/dist/wiz-findings.js +27 -23
- package/dist/wiz-findings.js.map +1 -1
- package/docs/classify-severity-records.md +3 -4
- package/docs/cli.md +155 -38
- package/docs/findings-service.md +119 -118
- package/docs/hosted-remediation.md +19 -17
- package/docs/hosted-scans.md +37 -11
- package/package.json +8 -8
- package/_bundled_plugin/scripts/generate_in_scope_files.py +0 -277
- package/_bundled_plugin/scripts/generate_rank_input.py +0 -350
- package/_bundled_plugin/scripts/rank_preview.py +0 -129
|
@@ -64,7 +64,6 @@ def get_scan_feedback(connection: sqlite3.Connection, scan: sqlite3.Row) -> dict
|
|
|
64
64
|
ORDER BY julianday(upper(updated_at)) DESC,
|
|
65
65
|
julianday(upper(source_completed_at)) DESC,
|
|
66
66
|
source_scan_id DESC, finding_id DESC
|
|
67
|
-
LIMIT 50
|
|
68
67
|
""",
|
|
69
68
|
(scan["target_id"], scan["id"]),
|
|
70
69
|
)
|
|
@@ -6,12 +6,19 @@ import argparse
|
|
|
6
6
|
import hashlib
|
|
7
7
|
import json
|
|
8
8
|
import sqlite3
|
|
9
|
+
import stat
|
|
9
10
|
import sys
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
from typing import Any
|
|
12
13
|
|
|
13
14
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
14
|
-
from workbench_target import
|
|
15
|
+
from workbench_target import (
|
|
16
|
+
UnreadableLocalFile,
|
|
17
|
+
UnsupportedLocalFileType,
|
|
18
|
+
directory_content_digest,
|
|
19
|
+
git_bytes,
|
|
20
|
+
git_revision,
|
|
21
|
+
)
|
|
15
22
|
|
|
16
23
|
WORKFLOW_BINDINGS = {
|
|
17
24
|
"repositoryPath": "repository_path",
|
|
@@ -123,7 +130,24 @@ def finding_workflow(
|
|
|
123
130
|
if payload["action"] == "get":
|
|
124
131
|
return {"workflow": read_workflow(connection, workflow_id)}
|
|
125
132
|
if payload["action"] == "source":
|
|
126
|
-
|
|
133
|
+
evidence = payload.get("evidence") is True
|
|
134
|
+
if evidence:
|
|
135
|
+
try:
|
|
136
|
+
target = Path(payload["repository"])
|
|
137
|
+
metadata = target.lstat()
|
|
138
|
+
if (
|
|
139
|
+
not target.is_absolute()
|
|
140
|
+
or not stat.S_ISDIR(metadata.st_mode)
|
|
141
|
+
or getattr(metadata, "st_reparse_tag", 0) & 0x20000000
|
|
142
|
+
or target.resolve(strict=True) != target
|
|
143
|
+
):
|
|
144
|
+
raise UnreadableLocalFile("The validation evidence directory was replaced.")
|
|
145
|
+
except (OSError, RuntimeError, UnreadableLocalFile):
|
|
146
|
+
if payload.get("optional") is True:
|
|
147
|
+
return {"source": None}
|
|
148
|
+
raise
|
|
149
|
+
else:
|
|
150
|
+
target = Path(payload["repository"]).resolve(strict=True)
|
|
127
151
|
private_paths = payload.get("privateStatePaths", [])
|
|
128
152
|
if not isinstance(private_paths, list) or any(
|
|
129
153
|
not isinstance(path, str) or not Path(path).is_absolute() for path in private_paths
|
|
@@ -133,18 +157,31 @@ def finding_workflow(
|
|
|
133
157
|
excluded = tuple(path for path in excluded if path.is_relative_to(target))
|
|
134
158
|
if target in excluded:
|
|
135
159
|
raise SystemExit("Private runtime storage must not exclude the repository root.")
|
|
160
|
+
try:
|
|
161
|
+
content = directory_content_digest(
|
|
162
|
+
target,
|
|
163
|
+
excluded=excluded,
|
|
164
|
+
include_ignored=True,
|
|
165
|
+
include_git_metadata=evidence,
|
|
166
|
+
)
|
|
167
|
+
except (UnsupportedLocalFileType, UnreadableLocalFile, OSError):
|
|
168
|
+
if payload.get("optional") is True:
|
|
169
|
+
return {"source": None}
|
|
170
|
+
raise
|
|
136
171
|
return {
|
|
137
172
|
"source": {
|
|
138
173
|
"repository": str(target),
|
|
139
|
-
"revision":
|
|
174
|
+
"revision": (
|
|
175
|
+
"unversioned"
|
|
176
|
+
if evidence or payload.get("gitDisabled")
|
|
177
|
+
else git_revision(target)
|
|
178
|
+
),
|
|
140
179
|
"refsDigest": hashlib.sha256(
|
|
141
180
|
b""
|
|
142
|
-
if payload.get("gitDisabled")
|
|
181
|
+
if evidence or payload.get("gitDisabled")
|
|
143
182
|
else (git_bytes(target, "show-ref") or b"").strip()
|
|
144
183
|
).hexdigest(),
|
|
145
|
-
"content":
|
|
146
|
-
target, excluded=excluded, include_ignored=True
|
|
147
|
-
),
|
|
184
|
+
"content": content,
|
|
148
185
|
**({"privateStatePaths": [str(path) for path in excluded]} if excluded else {}),
|
|
149
186
|
}
|
|
150
187
|
}
|
|
@@ -158,15 +195,20 @@ def finding_workflow(
|
|
|
158
195
|
binding = payload["binding"]
|
|
159
196
|
source = binding["source"]
|
|
160
197
|
scope = binding["scope"]
|
|
198
|
+
on_conflict = (
|
|
199
|
+
"DO UPDATE SET result_json = excluded.result_json, created_at = excluded.created_at"
|
|
200
|
+
if payload.get("replace") is True and binding.get("stage") == "scan-validation"
|
|
201
|
+
else "DO NOTHING"
|
|
202
|
+
)
|
|
161
203
|
with connection:
|
|
162
204
|
connection.execute(
|
|
163
|
-
"""INSERT INTO finding_workflow_reviews
|
|
205
|
+
f"""INSERT INTO finding_workflow_reviews
|
|
164
206
|
(workflow_id, review_key, review_contract_version, codex_version,
|
|
165
207
|
source_repository_path, source_revision, source_refs_digest, source_content_digest,
|
|
166
208
|
scope_repository_id, scope_all_repositories, model, effort, settings_digest,
|
|
167
209
|
prompt_digest, contract_digest, result_json, created_at)
|
|
168
210
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
169
|
-
ON CONFLICT(workflow_id, review_key)
|
|
211
|
+
ON CONFLICT(workflow_id, review_key) {on_conflict}""",
|
|
170
212
|
(
|
|
171
213
|
workflow_id,
|
|
172
214
|
payload["key"],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Read-only native findings and repository indexes for the Security workbench."""
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
|
+
import os
|
|
4
5
|
import sqlite3
|
|
5
6
|
import sys
|
|
6
7
|
from collections import Counter
|
|
@@ -204,63 +205,74 @@ def list_repositories(
|
|
|
204
205
|
args: argparse.Namespace | None = None,
|
|
205
206
|
) -> dict[str, Any]:
|
|
206
207
|
scan_count_by_target = Counter()
|
|
207
|
-
|
|
208
|
-
for
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
latest_by_target: dict[str, tuple[sqlite3.Row, dict[str, Any] | None]] = {}
|
|
209
|
+
for row in connection.execute(
|
|
210
|
+
f"""
|
|
211
|
+
SELECT targets.id AS repository_id, targets.display_name, targets.current_path,
|
|
212
|
+
{scan_history.SCAN_SUMMARY_COLUMNS}
|
|
213
|
+
FROM security_targets AS targets
|
|
214
|
+
LEFT JOIN scans ON scans.target_id = targets.id
|
|
215
|
+
AND scans.id IN (SELECT scan_id FROM scan_progress)
|
|
216
|
+
LEFT JOIN scan_progress AS progress ON progress.scan_id = scans.id
|
|
217
|
+
ORDER BY julianday(upper(scans.started_at)) DESC, scans.id DESC, targets.id
|
|
218
|
+
"""
|
|
219
|
+
).fetchall():
|
|
220
|
+
scan = scan_history.scan_summary(row) if row["id"] is not None else None
|
|
221
|
+
target_id = row["repository_id"]
|
|
222
|
+
if scan is not None:
|
|
223
|
+
scan_count_by_target[target_id] += 1
|
|
224
|
+
latest_by_target.setdefault(target_id, (row, scan))
|
|
218
225
|
|
|
219
226
|
open_findings_by_target = Counter(
|
|
220
227
|
row["target_id"] for row in _indexed_findings(connection) if row["status"] == "open"
|
|
221
228
|
)
|
|
222
|
-
targets = {row["id"]: row for row in connection.execute("SELECT * FROM security_targets")}
|
|
223
229
|
repositories = [
|
|
224
230
|
{
|
|
225
|
-
"checkoutAvailable": Path(target["current_path"]).is_dir(),
|
|
226
231
|
"displayName": target["display_name"],
|
|
227
232
|
"latestScan": latest_scan,
|
|
228
|
-
"openFindingsCount": open_findings_by_target
|
|
233
|
+
"openFindingsCount": open_findings_by_target[target_id]
|
|
234
|
+
if latest_scan is not None
|
|
235
|
+
else 0,
|
|
229
236
|
"scanCount": scan_count_by_target[target_id],
|
|
230
237
|
"targetId": target_id,
|
|
231
238
|
"targetPath": target["current_path"],
|
|
232
239
|
}
|
|
233
|
-
for target_id, latest_scan in
|
|
234
|
-
if (target := targets.get(target_id)) is not None
|
|
235
|
-
]
|
|
236
|
-
if args is None:
|
|
237
|
-
return {"repositories": repositories}
|
|
238
|
-
|
|
239
|
-
query = args.query.strip().casefold() if args.query else ""
|
|
240
|
-
repositories = [
|
|
241
|
-
repository
|
|
242
|
-
for repository in repositories
|
|
243
|
-
if (args.target_id is None or repository["targetId"] == args.target_id)
|
|
244
|
-
and args.status != "not_scanned"
|
|
245
|
-
and (args.status != "open_findings" or repository["openFindingsCount"] > 0)
|
|
246
|
-
and (
|
|
247
|
-
not query
|
|
248
|
-
or query in repository["displayName"].casefold()
|
|
249
|
-
or query in repository["targetPath"].casefold()
|
|
250
|
-
)
|
|
240
|
+
for target_id, (target, latest_scan) in latest_by_target.items()
|
|
251
241
|
]
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
242
|
+
pagination = {}
|
|
243
|
+
if args is not None:
|
|
244
|
+
query = args.query.strip().casefold() if args.query else ""
|
|
245
|
+
repositories = [
|
|
246
|
+
repository
|
|
247
|
+
for repository in repositories
|
|
248
|
+
if (args.target_id is None or repository["targetId"] == args.target_id)
|
|
249
|
+
and (args.status != "scanned" or repository["scanCount"] > 0)
|
|
250
|
+
and (args.status != "not_scanned" or repository["scanCount"] == 0)
|
|
251
|
+
and (args.status != "open_findings" or repository["openFindingsCount"] > 0)
|
|
252
|
+
and (
|
|
253
|
+
not query
|
|
254
|
+
or query in repository["displayName"].casefold()
|
|
255
|
+
or query in repository["targetPath"].casefold()
|
|
256
|
+
)
|
|
257
|
+
]
|
|
258
|
+
if args.limit is not None or args.offset:
|
|
259
|
+
limit = min(args.limit or FINDINGS_PAGE_MAX, FINDINGS_PAGE_MAX)
|
|
260
|
+
end = args.offset + limit
|
|
261
|
+
pagination = {
|
|
262
|
+
"limit": limit,
|
|
263
|
+
"nextOffset": end if end < len(repositories) else None,
|
|
264
|
+
"offset": args.offset,
|
|
265
|
+
}
|
|
266
|
+
repositories = repositories[args.offset : end]
|
|
267
|
+
for repository in repositories:
|
|
268
|
+
path = os.path.expanduser(repository["targetPath"])
|
|
269
|
+
try:
|
|
270
|
+
repository["checkoutAvailable"] = Path(path).is_absolute() and os.path.isdir(
|
|
271
|
+
os.path.realpath(path)
|
|
272
|
+
)
|
|
273
|
+
except (OSError, RecursionError):
|
|
274
|
+
repository["checkoutAvailable"] = False
|
|
275
|
+
return {"repositories": repositories, **pagination}
|
|
264
276
|
|
|
265
277
|
|
|
266
278
|
if __name__ == "__main__":
|