@clear-capabilities/agentic-security-scanner 0.74.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/CHANGELOG.md +1580 -0
- package/bin/.agentic-security/findings.json +1577 -0
- package/bin/.agentic-security/last-scan.json +1577 -0
- package/bin/.agentic-security/last-scan.json.sig +1 -0
- package/bin/.agentic-security/scan-history.json +465 -0
- package/bin/.agentic-security/streak.json +25 -0
- package/bin/agentic-security-audit.js +198 -0
- package/bin/agentic-security-consistency.js +80 -0
- package/bin/agentic-security-diff.js +136 -0
- package/bin/agentic-security-lsp.js +12 -0
- package/bin/agentic-security-mcp.js +40 -0
- package/bin/agentic-security-rule.js +153 -0
- package/bin/agentic-security.js +1683 -0
- package/dist/117.index.js +207 -0
- package/dist/178.index.js +250 -0
- package/dist/218.index.js +793 -0
- package/dist/227.index.js +192 -0
- package/dist/301.index.js +167 -0
- package/dist/384.index.js +18 -0
- package/dist/476.index.js +126 -0
- package/dist/513.index.js +373 -0
- package/dist/520.index.js +13 -0
- package/dist/601.index.js +1038 -0
- package/dist/634.index.js +1892 -0
- package/dist/637.index.js +216 -0
- package/dist/660.index.js +131 -0
- package/dist/675.index.js +451 -0
- package/dist/826.index.js +188 -0
- package/dist/830.index.js +133 -0
- package/dist/agentic-security.mjs +272 -0
- package/dist/agentic-security.mjs.sha256 +1 -0
- package/dist/calibration-seed.json +27 -0
- package/package.json +77 -0
- package/src/.agentic-security/findings.json +80844 -0
- package/src/.agentic-security/last-scan.json +80844 -0
- package/src/.agentic-security/last-scan.json.sig +1 -0
- package/src/.agentic-security/scan-history.json +8408 -0
- package/src/.agentic-security/streak.json +26 -0
- package/src/badge.js +188 -0
- package/src/compare.js +203 -0
- package/src/dataflow/.agentic-security/findings.json +3487 -0
- package/src/dataflow/.agentic-security/last-scan.json +3487 -0
- package/src/dataflow/.agentic-security/last-scan.json.sig +1 -0
- package/src/dataflow/.agentic-security/scan-history.json +735 -0
- package/src/dataflow/.agentic-security/streak.json +24 -0
- package/src/dataflow/CLAUDE.md +38 -0
- package/src/dataflow/access-paths.js +172 -0
- package/src/dataflow/async-sequencing.js +177 -0
- package/src/dataflow/backward.js +201 -0
- package/src/dataflow/catalog-expanded.js +485 -0
- package/src/dataflow/catalog.js +659 -0
- package/src/dataflow/cross-repo.js +219 -0
- package/src/dataflow/engine.js +588 -0
- package/src/dataflow/exception-flow.js +116 -0
- package/src/dataflow/exploit-prover.js +187 -0
- package/src/dataflow/higher-order.js +221 -0
- package/src/dataflow/ifds.js +347 -0
- package/src/dataflow/implicit-flow.js +129 -0
- package/src/dataflow/incremental.js +229 -0
- package/src/dataflow/index.js +181 -0
- package/src/dataflow/numeric-domain.js +192 -0
- package/src/dataflow/path-feasibility.js +114 -0
- package/src/dataflow/points-to.js +337 -0
- package/src/dataflow/polyglot.js +190 -0
- package/src/dataflow/proven-clean.js +159 -0
- package/src/dataflow/receiver-context.js +76 -0
- package/src/dataflow/sanitizer-proof.js +154 -0
- package/src/dataflow/soft-taint.js +140 -0
- package/src/dataflow/string-domain.js +234 -0
- package/src/dataflow/stub-aware-filter.js +100 -0
- package/src/dataflow/summaries.js +132 -0
- package/src/dataflow/symbolic-exec.js +238 -0
- package/src/dataflow/tabulation.js +135 -0
- package/src/engine.js +7763 -0
- package/src/history-scan.js +229 -0
- package/src/index.js +3 -0
- package/src/integrations/.agentic-security/findings.json +1504 -0
- package/src/integrations/.agentic-security/last-scan.json +1504 -0
- package/src/integrations/.agentic-security/scan-history.json +40 -0
- package/src/integrations/.agentic-security/streak.json +21 -0
- package/src/integrations/index.js +321 -0
- package/src/integrations/tickets.js +200 -0
- package/src/ir/.agentic-security/findings.json +3036 -0
- package/src/ir/.agentic-security/last-scan.json +3036 -0
- package/src/ir/.agentic-security/last-scan.json.sig +1 -0
- package/src/ir/.agentic-security/scan-history.json +364 -0
- package/src/ir/.agentic-security/streak.json +23 -0
- package/src/ir/CLAUDE.md +172 -0
- package/src/ir/callgraph.js +73 -0
- package/src/ir/class-hierarchy.js +195 -0
- package/src/ir/index.js +152 -0
- package/src/ir/parser-cs.js +260 -0
- package/src/ir/parser-java.js +286 -0
- package/src/ir/parser-js.js +413 -0
- package/src/ir/parser-kt.js +258 -0
- package/src/ir/parser-py-cst.js +136 -0
- package/src/ir/parser-py.helper.py +501 -0
- package/src/ir/parser-py.js +312 -0
- package/src/ir/ssa.js +315 -0
- package/src/ir/type-stubs.js +288 -0
- package/src/leaderboard.js +152 -0
- package/src/llm-validator/.agentic-security/findings.json +1891 -0
- package/src/llm-validator/.agentic-security/last-scan.json +1891 -0
- package/src/llm-validator/.agentic-security/last-scan.json.sig +1 -0
- package/src/llm-validator/.agentic-security/scan-history.json +168 -0
- package/src/llm-validator/.agentic-security/streak.json +20 -0
- package/src/llm-validator/consistency.js +141 -0
- package/src/llm-validator/index.js +437 -0
- package/src/lsp/.agentic-security/findings.json +28 -0
- package/src/lsp/.agentic-security/last-scan.json +28 -0
- package/src/lsp/.agentic-security/scan-history.json +79 -0
- package/src/lsp/.agentic-security/streak.json +22 -0
- package/src/lsp/server.js +275 -0
- package/src/mcp/.agentic-security/findings.json +8358 -0
- package/src/mcp/.agentic-security/last-scan.json +8358 -0
- package/src/mcp/.agentic-security/last-scan.json.sig +1 -0
- package/src/mcp/.agentic-security/scan-history.json +1125 -0
- package/src/mcp/.agentic-security/streak.json +22 -0
- package/src/mcp/CLAUDE.md +54 -0
- package/src/mcp/audit.js +136 -0
- package/src/mcp/redact.js +75 -0
- package/src/mcp/server.js +158 -0
- package/src/mcp/stdio.js +83 -0
- package/src/mcp/tools.js +940 -0
- package/src/mcp/validate.js +49 -0
- package/src/personality.js +164 -0
- package/src/poc-video.js +239 -0
- package/src/posture/.agentic-security/findings.json +51239 -0
- package/src/posture/.agentic-security/last-scan.json +51239 -0
- package/src/posture/.agentic-security/last-scan.json.sig +1 -0
- package/src/posture/.agentic-security/scan-history.json +5557 -0
- package/src/posture/.agentic-security/streak.json +24 -0
- package/src/posture/CLAUDE.md +42 -0
- package/src/posture/adversarial-self-test.js +114 -0
- package/src/posture/adversary-agent.js +204 -0
- package/src/posture/agents-memory.js +135 -0
- package/src/posture/ai-code-fingerprint.js +171 -0
- package/src/posture/aibom.js +284 -0
- package/src/posture/api-inventory.js +96 -0
- package/src/posture/attack-playbooks.js +305 -0
- package/src/posture/auditor-agent.js +115 -0
- package/src/posture/auth-posture-import.js +135 -0
- package/src/posture/baseline-compare.js +114 -0
- package/src/posture/blast-radius.js +836 -0
- package/src/posture/bounty-prediction.js +141 -0
- package/src/posture/business-logic.js +239 -0
- package/src/posture/calibration-drift.js +93 -0
- package/src/posture/calibration-seed.json +27 -0
- package/src/posture/calibration.js +204 -0
- package/src/posture/clustering.js +75 -0
- package/src/posture/concurrency-checker.js +265 -0
- package/src/posture/confidence.js +65 -0
- package/src/posture/container-runtime.js +149 -0
- package/src/posture/counterfactual.js +109 -0
- package/src/posture/cross-lang-graphql.js +165 -0
- package/src/posture/cross-lang-grpc.js +166 -0
- package/src/posture/cross-lang-meta.js +101 -0
- package/src/posture/cross-lang-openapi.js +187 -0
- package/src/posture/cross-lang-orm.js +153 -0
- package/src/posture/cross-lang-queues.js +210 -0
- package/src/posture/crown-jewels.js +110 -0
- package/src/posture/custom-rules.js +361 -0
- package/src/posture/cve-alert-daemon.js +433 -0
- package/src/posture/cve-lookup.js +129 -0
- package/src/posture/dead-code.js +430 -0
- package/src/posture/defender-agent.js +158 -0
- package/src/posture/deploy-platform.js +204 -0
- package/src/posture/detector-fuzz.js +61 -0
- package/src/posture/deterministic.js +99 -0
- package/src/posture/drift.js +165 -0
- package/src/posture/epss.js +156 -0
- package/src/posture/exploitability-probability.js +212 -0
- package/src/posture/exploitability.js +121 -0
- package/src/posture/feature-flags.js +110 -0
- package/src/posture/finding-defaults.js +132 -0
- package/src/posture/fix-history.js +411 -0
- package/src/posture/fix-plan.js +121 -0
- package/src/posture/fix-verify-loop.js +157 -0
- package/src/posture/fix-verify.js +130 -0
- package/src/posture/flow-narration.js +105 -0
- package/src/posture/grader-calibration.js +156 -0
- package/src/posture/harness-discovery.js +113 -0
- package/src/posture/holdout-eval.js +144 -0
- package/src/posture/iac-reachability.js +163 -0
- package/src/posture/iam-policy.js +128 -0
- package/src/posture/integrity.js +97 -0
- package/src/posture/learning.js +166 -0
- package/src/posture/license-policy.js +109 -0
- package/src/posture/llm-redteam-prompts.js +418 -0
- package/src/posture/llm-redteam.js +303 -0
- package/src/posture/material-change.js +163 -0
- package/src/posture/mitigation-composite.js +55 -0
- package/src/posture/mttr.js +91 -0
- package/src/posture/network-policy-import.js +126 -0
- package/src/posture/path-predicates.js +99 -0
- package/src/posture/persona-prioritization.js +153 -0
- package/src/posture/poc-cwe-map.js +51 -0
- package/src/posture/poc-generator.js +500 -0
- package/src/posture/policy-gate.js +174 -0
- package/src/posture/pre-incident-archaeology.js +110 -0
- package/src/posture/profile.js +93 -0
- package/src/posture/reachability-filter.js +42 -0
- package/src/posture/regression-test-gen.js +200 -0
- package/src/posture/reverse-blast-radius.js +110 -0
- package/src/posture/router.js +109 -0
- package/src/posture/rule-overrides.js +198 -0
- package/src/posture/rule-pack-signing.js +209 -0
- package/src/posture/rule-packs.js +143 -0
- package/src/posture/rule-synthesis.js +108 -0
- package/src/posture/ruleset-version.js +71 -0
- package/src/posture/sbom.js +129 -0
- package/src/posture/schema-aware-bridge.js +207 -0
- package/src/posture/security-trend.js +87 -0
- package/src/posture/semantic-clone.js +114 -0
- package/src/posture/specification-mining.js +170 -0
- package/src/posture/stable-id.js +75 -0
- package/src/posture/stack-playbook.js +229 -0
- package/src/posture/streak.js +249 -0
- package/src/posture/suppressions.js +135 -0
- package/src/posture/telemetry-ingest.js +112 -0
- package/src/posture/threat-model.js +145 -0
- package/src/posture/three-agent-pipeline.js +74 -0
- package/src/posture/triage.js +146 -0
- package/src/posture/trust-boundary-diagram.js +115 -0
- package/src/posture/type-narrowing.js +129 -0
- package/src/posture/validator-metrics.js +179 -0
- package/src/posture/verifier-ephemeral.js +118 -0
- package/src/posture/verifier-target.js +147 -0
- package/src/posture/verifier.js +257 -0
- package/src/posture/version.js +75 -0
- package/src/posture/waf-ingest.js +200 -0
- package/src/posture/why-fired.js +141 -0
- package/src/pr-comment.js +172 -0
- package/src/pr-delta.js +198 -0
- package/src/report/.agentic-security/findings.json +79 -0
- package/src/report/.agentic-security/last-scan.json +79 -0
- package/src/report/.agentic-security/last-scan.json.sig +1 -0
- package/src/report/.agentic-security/scan-history.json +332 -0
- package/src/report/.agentic-security/streak.json +23 -0
- package/src/report/index.js +1136 -0
- package/src/report/mascot.js +42 -0
- package/src/runScan.js +141 -0
- package/src/sast/.agentic-security/findings.json +5051 -0
- package/src/sast/.agentic-security/last-scan.json +5051 -0
- package/src/sast/.agentic-security/last-scan.json.sig +1 -0
- package/src/sast/.agentic-security/scan-history.json +788 -0
- package/src/sast/.agentic-security/streak.json +23 -0
- package/src/sast/CLAUDE.md +39 -0
- package/src/sast/_comment-strip.js +46 -0
- package/src/sast/agent-tool-escalation.js +131 -0
- package/src/sast/auth-provider.js +171 -0
- package/src/sast/authz.js +236 -0
- package/src/sast/bench-shape/.agentic-security/findings.json +28 -0
- package/src/sast/bench-shape/.agentic-security/last-scan.json +28 -0
- package/src/sast/bench-shape/.agentic-security/scan-history.json +24 -0
- package/src/sast/bench-shape/.agentic-security/streak.json +22 -0
- package/src/sast/bench-shape/index.js +62 -0
- package/src/sast/claude-hook-injection.js +199 -0
- package/src/sast/claude-md-prompt-injection.js +170 -0
- package/src/sast/claude-settings.js +165 -0
- package/src/sast/client-side.js +149 -0
- package/src/sast/cpp-bench-extras.js +122 -0
- package/src/sast/cpp-dataflow.js +430 -0
- package/src/sast/cpp.js +248 -0
- package/src/sast/csharp.js +152 -0
- package/src/sast/csrf.js +82 -0
- package/src/sast/dart-flutter.js +173 -0
- package/src/sast/db-rls.js +147 -0
- package/src/sast/db-taint.js +215 -0
- package/src/sast/defi-deep.js +242 -0
- package/src/sast/deserialization-gadgets.js +113 -0
- package/src/sast/django-hardening.js +230 -0
- package/src/sast/env-hygiene.js +125 -0
- package/src/sast/fastapi-hardening.js +145 -0
- package/src/sast/go-extended.js +84 -0
- package/src/sast/host-header.js +106 -0
- package/src/sast/index.js +17 -0
- package/src/sast/java-ast-folding.js +561 -0
- package/src/sast/java-bench-extras.js +708 -0
- package/src/sast/java-collection-passthrough.js +178 -0
- package/src/sast/java-constant-fold.js +244 -0
- package/src/sast/java-deserialization.js +125 -0
- package/src/sast/jndi.js +104 -0
- package/src/sast/juliet-shape.js +324 -0
- package/src/sast/jwt-exp.js +104 -0
- package/src/sast/kotlin.js +82 -0
- package/src/sast/laravel-hardening.js +198 -0
- package/src/sast/ldap-injection.js +100 -0
- package/src/sast/llm-owasp.js +465 -0
- package/src/sast/llm-stored-prompt.js +103 -0
- package/src/sast/llm-trading-agent.js +161 -0
- package/src/sast/llm.js +308 -0
- package/src/sast/logic.js +140 -0
- package/src/sast/mass-assignment.js +101 -0
- package/src/sast/mcp-audit.js +242 -0
- package/src/sast/mobile-manifest.js +195 -0
- package/src/sast/model-load.js +164 -0
- package/src/sast/mutation-xss.js +87 -0
- package/src/sast/nosql-injection.js +82 -0
- package/src/sast/open-redirect.js +119 -0
- package/src/sast/php.js +91 -0
- package/src/sast/pipeline.js +122 -0
- package/src/sast/primary-cwe-java.js +155 -0
- package/src/sast/prompt-firewall.js +151 -0
- package/src/sast/prompt-template.js +157 -0
- package/src/sast/prototype-pollution.js +112 -0
- package/src/sast/python-sinks.js +195 -0
- package/src/sast/quarkus-hardening.js +102 -0
- package/src/sast/rag-poisoning.js +118 -0
- package/src/sast/rate-limit.js +128 -0
- package/src/sast/response-splitting.js +138 -0
- package/src/sast/ruby.js +108 -0
- package/src/sast/rust.js +105 -0
- package/src/sast/solidity.js +167 -0
- package/src/sast/springboot-hardening.js +186 -0
- package/src/sast/ssrf-cloud-metadata.js +80 -0
- package/src/sast/ssti.js +116 -0
- package/src/sast/swift.js +162 -0
- package/src/sast/toctou.js +95 -0
- package/src/sast/webhook.js +101 -0
- package/src/sast/xpath-injection.js +51 -0
- package/src/sast/xxe.js +140 -0
- package/src/sast/zip-slip.js +200 -0
- package/src/sca/base-images.json +45 -0
- package/src/sca/container.js +107 -0
- package/src/sca/dep-confusion.js +134 -0
- package/src/sca/index.js +6 -0
- package/src/sca/popular-packages.json +41 -0
- package/src/sca/sarif-ingest.js +187 -0
- package/src/sca/vuln-function-hints.json +89 -0
- package/src/secrets/index.js +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dddfa3a4abc90266b882b4945a7aba57b8e97cc726aa60f4578cfaefcd23b95b
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"timestamp": "2026-05-19T15:44:43.087Z",
|
|
4
|
+
"label": "scan",
|
|
5
|
+
"total": 0,
|
|
6
|
+
"critical": 0,
|
|
7
|
+
"high": 0,
|
|
8
|
+
"medium": 0,
|
|
9
|
+
"low": 0,
|
|
10
|
+
"kev": 0,
|
|
11
|
+
"ids": []
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"timestamp": "2026-05-19T16:01:41.762Z",
|
|
15
|
+
"label": "scan",
|
|
16
|
+
"total": 0,
|
|
17
|
+
"critical": 0,
|
|
18
|
+
"high": 0,
|
|
19
|
+
"medium": 0,
|
|
20
|
+
"low": 0,
|
|
21
|
+
"kev": 0,
|
|
22
|
+
"ids": []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"timestamp": "2026-05-19T18:33:22.830Z",
|
|
26
|
+
"label": "scan",
|
|
27
|
+
"total": 1,
|
|
28
|
+
"critical": 0,
|
|
29
|
+
"high": 0,
|
|
30
|
+
"medium": 1,
|
|
31
|
+
"low": 0,
|
|
32
|
+
"kev": 0,
|
|
33
|
+
"ids": [
|
|
34
|
+
"toctou-fs:agentic-security.js:1105"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"timestamp": "2026-05-19T18:33:28.315Z",
|
|
39
|
+
"label": "scan",
|
|
40
|
+
"total": 1,
|
|
41
|
+
"critical": 0,
|
|
42
|
+
"high": 0,
|
|
43
|
+
"medium": 1,
|
|
44
|
+
"low": 0,
|
|
45
|
+
"kev": 0,
|
|
46
|
+
"ids": [
|
|
47
|
+
"toctou-fs:agentic-security.js:1105"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"timestamp": "2026-05-19T22:20:41.048Z",
|
|
52
|
+
"label": "scan",
|
|
53
|
+
"total": 3,
|
|
54
|
+
"critical": 0,
|
|
55
|
+
"high": 0,
|
|
56
|
+
"medium": 3,
|
|
57
|
+
"low": 0,
|
|
58
|
+
"kev": 0,
|
|
59
|
+
"ids": [
|
|
60
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
61
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
62
|
+
"toctou-fs:agentic-security.js:1105"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"timestamp": "2026-05-19T22:27:05.052Z",
|
|
67
|
+
"label": "scan",
|
|
68
|
+
"total": 4,
|
|
69
|
+
"critical": 0,
|
|
70
|
+
"high": 0,
|
|
71
|
+
"medium": 4,
|
|
72
|
+
"low": 0,
|
|
73
|
+
"kev": 0,
|
|
74
|
+
"ids": [
|
|
75
|
+
"toctou-fs:agentic-security-audit.js:53",
|
|
76
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
77
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
78
|
+
"toctou-fs:agentic-security.js:1105"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"timestamp": "2026-05-19T22:59:58.518Z",
|
|
83
|
+
"label": "scan",
|
|
84
|
+
"total": 4,
|
|
85
|
+
"critical": 0,
|
|
86
|
+
"high": 0,
|
|
87
|
+
"medium": 4,
|
|
88
|
+
"low": 0,
|
|
89
|
+
"kev": 0,
|
|
90
|
+
"ids": [
|
|
91
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
92
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
93
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
94
|
+
"toctou-fs:agentic-security.js:1105"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"timestamp": "2026-05-19T23:00:22.780Z",
|
|
99
|
+
"label": "scan",
|
|
100
|
+
"total": 4,
|
|
101
|
+
"critical": 0,
|
|
102
|
+
"high": 0,
|
|
103
|
+
"medium": 4,
|
|
104
|
+
"low": 0,
|
|
105
|
+
"kev": 0,
|
|
106
|
+
"ids": [
|
|
107
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
108
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
109
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
110
|
+
"toctou-fs:agentic-security.js:1105"
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"timestamp": "2026-05-19T23:44:16.929Z",
|
|
115
|
+
"label": "scan",
|
|
116
|
+
"total": 4,
|
|
117
|
+
"critical": 0,
|
|
118
|
+
"high": 0,
|
|
119
|
+
"medium": 4,
|
|
120
|
+
"low": 0,
|
|
121
|
+
"kev": 0,
|
|
122
|
+
"ids": [
|
|
123
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
124
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
125
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
126
|
+
"toctou-fs:agentic-security.js:1105"
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"timestamp": "2026-05-19T23:44:23.410Z",
|
|
131
|
+
"label": "scan",
|
|
132
|
+
"total": 4,
|
|
133
|
+
"critical": 0,
|
|
134
|
+
"high": 0,
|
|
135
|
+
"medium": 4,
|
|
136
|
+
"low": 0,
|
|
137
|
+
"kev": 0,
|
|
138
|
+
"ids": [
|
|
139
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
140
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
141
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
142
|
+
"toctou-fs:agentic-security.js:1105"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"timestamp": "2026-05-20T03:55:11.940Z",
|
|
147
|
+
"label": "scan",
|
|
148
|
+
"total": 4,
|
|
149
|
+
"critical": 0,
|
|
150
|
+
"high": 0,
|
|
151
|
+
"medium": 4,
|
|
152
|
+
"low": 0,
|
|
153
|
+
"kev": 0,
|
|
154
|
+
"ids": [
|
|
155
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
156
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
157
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
158
|
+
"toctou-fs:agentic-security.js:1105"
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"timestamp": "2026-05-20T03:55:17.682Z",
|
|
163
|
+
"label": "scan",
|
|
164
|
+
"total": 4,
|
|
165
|
+
"critical": 0,
|
|
166
|
+
"high": 0,
|
|
167
|
+
"medium": 4,
|
|
168
|
+
"low": 0,
|
|
169
|
+
"kev": 0,
|
|
170
|
+
"ids": [
|
|
171
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
172
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
173
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
174
|
+
"toctou-fs:agentic-security.js:1105"
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"timestamp": "2026-05-20T04:58:44.060Z",
|
|
179
|
+
"label": "scan",
|
|
180
|
+
"total": 4,
|
|
181
|
+
"critical": 0,
|
|
182
|
+
"high": 0,
|
|
183
|
+
"medium": 4,
|
|
184
|
+
"low": 0,
|
|
185
|
+
"kev": 0,
|
|
186
|
+
"ids": [
|
|
187
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
188
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
189
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
190
|
+
"toctou-fs:agentic-security.js:1105"
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"timestamp": "2026-05-20T04:58:56.341Z",
|
|
195
|
+
"label": "scan",
|
|
196
|
+
"total": 4,
|
|
197
|
+
"critical": 0,
|
|
198
|
+
"high": 0,
|
|
199
|
+
"medium": 4,
|
|
200
|
+
"low": 0,
|
|
201
|
+
"kev": 0,
|
|
202
|
+
"ids": [
|
|
203
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
204
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
205
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
206
|
+
"toctou-fs:agentic-security.js:1105"
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"timestamp": "2026-05-20T05:13:43.297Z",
|
|
211
|
+
"label": "scan",
|
|
212
|
+
"total": 4,
|
|
213
|
+
"critical": 0,
|
|
214
|
+
"high": 0,
|
|
215
|
+
"medium": 4,
|
|
216
|
+
"low": 0,
|
|
217
|
+
"kev": 0,
|
|
218
|
+
"ids": [
|
|
219
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
220
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
221
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
222
|
+
"toctou-fs:agentic-security.js:1105"
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"timestamp": "2026-05-20T05:34:26.018Z",
|
|
227
|
+
"label": "scan",
|
|
228
|
+
"total": 4,
|
|
229
|
+
"critical": 0,
|
|
230
|
+
"high": 0,
|
|
231
|
+
"medium": 4,
|
|
232
|
+
"low": 0,
|
|
233
|
+
"kev": 0,
|
|
234
|
+
"ids": [
|
|
235
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
236
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
237
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
238
|
+
"toctou-fs:agentic-security.js:1105"
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"timestamp": "2026-05-20T05:34:33.300Z",
|
|
243
|
+
"label": "scan",
|
|
244
|
+
"total": 4,
|
|
245
|
+
"critical": 0,
|
|
246
|
+
"high": 0,
|
|
247
|
+
"medium": 4,
|
|
248
|
+
"low": 0,
|
|
249
|
+
"kev": 0,
|
|
250
|
+
"ids": [
|
|
251
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
252
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
253
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
254
|
+
"toctou-fs:agentic-security.js:1105"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"timestamp": "2026-05-20T12:41:04.981Z",
|
|
259
|
+
"label": "scan",
|
|
260
|
+
"total": 4,
|
|
261
|
+
"critical": 0,
|
|
262
|
+
"high": 0,
|
|
263
|
+
"medium": 4,
|
|
264
|
+
"low": 0,
|
|
265
|
+
"kev": 0,
|
|
266
|
+
"ids": [
|
|
267
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
268
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
269
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
270
|
+
"toctou-fs:agentic-security.js:1105"
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"timestamp": "2026-05-20T12:41:11.169Z",
|
|
275
|
+
"label": "scan",
|
|
276
|
+
"total": 4,
|
|
277
|
+
"critical": 0,
|
|
278
|
+
"high": 0,
|
|
279
|
+
"medium": 4,
|
|
280
|
+
"low": 0,
|
|
281
|
+
"kev": 0,
|
|
282
|
+
"ids": [
|
|
283
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
284
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
285
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
286
|
+
"toctou-fs:agentic-security.js:1105"
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"timestamp": "2026-05-20T12:55:32.034Z",
|
|
291
|
+
"label": "scan",
|
|
292
|
+
"total": 4,
|
|
293
|
+
"critical": 0,
|
|
294
|
+
"high": 0,
|
|
295
|
+
"medium": 4,
|
|
296
|
+
"low": 0,
|
|
297
|
+
"kev": 0,
|
|
298
|
+
"ids": [
|
|
299
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
300
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
301
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
302
|
+
"toctou-fs:agentic-security.js:1105"
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"timestamp": "2026-05-20T15:38:53.724Z",
|
|
307
|
+
"label": "scan",
|
|
308
|
+
"total": 4,
|
|
309
|
+
"critical": 0,
|
|
310
|
+
"high": 0,
|
|
311
|
+
"medium": 4,
|
|
312
|
+
"low": 0,
|
|
313
|
+
"kev": 0,
|
|
314
|
+
"ids": [
|
|
315
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
316
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
317
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
318
|
+
"toctou-fs:agentic-security.js:1105"
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"timestamp": "2026-05-20T16:34:56.575Z",
|
|
323
|
+
"label": "scan",
|
|
324
|
+
"total": 4,
|
|
325
|
+
"critical": 0,
|
|
326
|
+
"high": 0,
|
|
327
|
+
"medium": 4,
|
|
328
|
+
"low": 0,
|
|
329
|
+
"kev": 0,
|
|
330
|
+
"ids": [
|
|
331
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
332
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
333
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
334
|
+
"toctou-fs:agentic-security.js:1105"
|
|
335
|
+
]
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"timestamp": "2026-05-20T17:09:07.083Z",
|
|
339
|
+
"label": "scan",
|
|
340
|
+
"total": 4,
|
|
341
|
+
"critical": 0,
|
|
342
|
+
"high": 0,
|
|
343
|
+
"medium": 4,
|
|
344
|
+
"low": 0,
|
|
345
|
+
"kev": 0,
|
|
346
|
+
"ids": [
|
|
347
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
348
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
349
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
350
|
+
"toctou-fs:agentic-security.js:1105"
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"timestamp": "2026-05-20T17:16:51.009Z",
|
|
355
|
+
"label": "scan",
|
|
356
|
+
"total": 4,
|
|
357
|
+
"critical": 0,
|
|
358
|
+
"high": 0,
|
|
359
|
+
"medium": 4,
|
|
360
|
+
"low": 0,
|
|
361
|
+
"kev": 0,
|
|
362
|
+
"ids": [
|
|
363
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
364
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
365
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
366
|
+
"toctou-fs:agentic-security.js:1105"
|
|
367
|
+
]
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"timestamp": "2026-05-20T17:30:57.470Z",
|
|
371
|
+
"label": "scan",
|
|
372
|
+
"total": 4,
|
|
373
|
+
"critical": 0,
|
|
374
|
+
"high": 0,
|
|
375
|
+
"medium": 4,
|
|
376
|
+
"low": 0,
|
|
377
|
+
"kev": 0,
|
|
378
|
+
"ids": [
|
|
379
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
380
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
381
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
382
|
+
"toctou-fs:agentic-security.js:1105"
|
|
383
|
+
]
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"timestamp": "2026-05-20T19:30:22.196Z",
|
|
387
|
+
"label": "scan",
|
|
388
|
+
"total": 4,
|
|
389
|
+
"critical": 0,
|
|
390
|
+
"high": 0,
|
|
391
|
+
"medium": 4,
|
|
392
|
+
"low": 0,
|
|
393
|
+
"kev": 0,
|
|
394
|
+
"ids": [
|
|
395
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
396
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
397
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
398
|
+
"toctou-fs:agentic-security.js:1105"
|
|
399
|
+
]
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"timestamp": "2026-05-20T19:32:44.938Z",
|
|
403
|
+
"label": "scan",
|
|
404
|
+
"total": 4,
|
|
405
|
+
"critical": 0,
|
|
406
|
+
"high": 0,
|
|
407
|
+
"medium": 4,
|
|
408
|
+
"low": 0,
|
|
409
|
+
"kev": 0,
|
|
410
|
+
"ids": [
|
|
411
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
412
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
413
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
414
|
+
"toctou-fs:agentic-security.js:1105"
|
|
415
|
+
]
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"timestamp": "2026-05-20T20:02:44.607Z",
|
|
419
|
+
"label": "scan",
|
|
420
|
+
"total": 4,
|
|
421
|
+
"critical": 0,
|
|
422
|
+
"high": 0,
|
|
423
|
+
"medium": 4,
|
|
424
|
+
"low": 0,
|
|
425
|
+
"kev": 0,
|
|
426
|
+
"ids": [
|
|
427
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
428
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
429
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
430
|
+
"toctou-fs:agentic-security.js:1105"
|
|
431
|
+
]
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"timestamp": "2026-05-20T21:21:28.677Z",
|
|
435
|
+
"label": "scan",
|
|
436
|
+
"total": 4,
|
|
437
|
+
"critical": 0,
|
|
438
|
+
"high": 0,
|
|
439
|
+
"medium": 4,
|
|
440
|
+
"low": 0,
|
|
441
|
+
"kev": 0,
|
|
442
|
+
"ids": [
|
|
443
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
444
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
445
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
446
|
+
"toctou-fs:agentic-security.js:1105"
|
|
447
|
+
]
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"timestamp": "2026-05-20T21:28:34.802Z",
|
|
451
|
+
"label": "scan",
|
|
452
|
+
"total": 4,
|
|
453
|
+
"critical": 0,
|
|
454
|
+
"high": 0,
|
|
455
|
+
"medium": 4,
|
|
456
|
+
"low": 0,
|
|
457
|
+
"kev": 0,
|
|
458
|
+
"ids": [
|
|
459
|
+
"toctou-fs:agentic-security-audit.js:55",
|
|
460
|
+
"toctou-fs:agentic-security-consistency.js:44",
|
|
461
|
+
"toctou-fs:agentic-security-consistency.js:66",
|
|
462
|
+
"toctou-fs:agentic-security.js:1105"
|
|
463
|
+
]
|
|
464
|
+
}
|
|
465
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"firstScanDate": "2026-05-15T12:24:29.316Z",
|
|
3
|
+
"lastScanDate": "2026-05-20T21:28:34.823Z",
|
|
4
|
+
"totalScans": 121,
|
|
5
|
+
"daysCleanCritical": 3,
|
|
6
|
+
"lastCleanDate": "2026-05-20",
|
|
7
|
+
"lastCriticalDate": null,
|
|
8
|
+
"hasEverHadCritical": false,
|
|
9
|
+
"bestDaysCleanCritical": 3,
|
|
10
|
+
"totalFindingsAtFirstScan": 0,
|
|
11
|
+
"totalFindingsAtLastScan": 11,
|
|
12
|
+
"totalFixesInferred": 1,
|
|
13
|
+
"lastGrade": "A-",
|
|
14
|
+
"bestGrade": "A+",
|
|
15
|
+
"launchCheckPassedAt": null,
|
|
16
|
+
"achievements": [
|
|
17
|
+
"first-fix",
|
|
18
|
+
"first-scan",
|
|
19
|
+
"grade-a",
|
|
20
|
+
"grade-a-plus",
|
|
21
|
+
"scan-veteran-100",
|
|
22
|
+
"scan-veteran-25"
|
|
23
|
+
],
|
|
24
|
+
"previousGrade": "A-"
|
|
25
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Transcript-review CLI for the MCP audit log (eval-post recommendation #6).
|
|
3
|
+
//
|
|
4
|
+
// Quote we're implementing:
|
|
5
|
+
// "When a task fails, the transcript tells you whether the agent made a
|
|
6
|
+
// genuine mistake or whether your graders rejected a valid solution.
|
|
7
|
+
// As a rule, we do not take eval scores at face value until someone digs
|
|
8
|
+
// into the details of the eval and reads some transcripts."
|
|
9
|
+
//
|
|
10
|
+
// Subcommands:
|
|
11
|
+
// review print a sampled set of entries from .agentic-security/mcp-audit.log
|
|
12
|
+
// metrics aggregate outcomes by tool over the last N days
|
|
13
|
+
// verify verify the hash chain on the local audit log
|
|
14
|
+
//
|
|
15
|
+
// Usage:
|
|
16
|
+
// agentic-security-audit review # last 24h, 20 entries
|
|
17
|
+
// agentic-security-audit review --last 7d --n 50
|
|
18
|
+
// agentic-security-audit review --tool apply_fix --outcome rejected
|
|
19
|
+
// agentic-security-audit metrics --last 30d
|
|
20
|
+
// agentic-security-audit verify
|
|
21
|
+
'use strict';
|
|
22
|
+
import * as fs from 'node:fs';
|
|
23
|
+
import * as path from 'node:path';
|
|
24
|
+
import { verifyAuditLog } from '../src/mcp/audit.js';
|
|
25
|
+
|
|
26
|
+
function args() {
|
|
27
|
+
const a = process.argv.slice(2);
|
|
28
|
+
const sub = a[0] || 'review';
|
|
29
|
+
const out = { sub, last: '24h', n: 20, tool: null, outcome: null, root: process.cwd(), json: false, bySession: false, outlierThreshold: 20 };
|
|
30
|
+
for (let i = 1; i < a.length; i++) {
|
|
31
|
+
if (a[i] === '--last') out.last = a[++i];
|
|
32
|
+
else if (a[i] === '--n') out.n = parseInt(a[++i], 10);
|
|
33
|
+
else if (a[i] === '--tool') out.tool = a[++i];
|
|
34
|
+
else if (a[i] === '--outcome') out.outcome = a[++i];
|
|
35
|
+
else if (a[i] === '--root') out.root = a[++i];
|
|
36
|
+
else if (a[i] === '--json') out.json = true;
|
|
37
|
+
else if (a[i] === '--by-session') out.bySession = true;
|
|
38
|
+
else if (a[i] === '--outlier-threshold') out.outlierThreshold = parseInt(a[++i], 10);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _parseDuration(s) {
|
|
44
|
+
const m = /^(\d+)([smhdw])$/.exec(String(s || ''));
|
|
45
|
+
if (!m) return 24 * 3600 * 1000;
|
|
46
|
+
const n = parseInt(m[1], 10);
|
|
47
|
+
const u = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000, w: 7 * 86_400_000 }[m[2]];
|
|
48
|
+
return n * u;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _logPath(root) { return path.join(root, '.agentic-security', 'mcp-audit.log'); }
|
|
52
|
+
|
|
53
|
+
function _readEntries(root) {
|
|
54
|
+
const fp = _logPath(root);
|
|
55
|
+
if (!fs.existsSync(fp)) return [];
|
|
56
|
+
const lines = fs.readFileSync(fp, 'utf8').split('\n').filter(Boolean);
|
|
57
|
+
const out = [];
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
try { out.push(JSON.parse(line)); } catch { /* skip malformed line */ }
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _filterEntries(entries, opts) {
|
|
65
|
+
const cutoff = Date.now() - _parseDuration(opts.last);
|
|
66
|
+
return entries.filter(e => {
|
|
67
|
+
const t = Date.parse(e.ts || '');
|
|
68
|
+
if (Number.isFinite(t) && t < cutoff) return false;
|
|
69
|
+
if (opts.tool && e.tool !== opts.tool) return false;
|
|
70
|
+
if (opts.outcome && e.outcome !== opts.outcome) return false;
|
|
71
|
+
return true;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _sample(arr, n) {
|
|
76
|
+
if (arr.length <= n) return arr;
|
|
77
|
+
// Reservoir-style: keep first N, then replace at decreasing probability so
|
|
78
|
+
// the sample stays uniform across the source distribution. Deterministic
|
|
79
|
+
// seed = first entry's ts so a repeated run on the same data sees the same
|
|
80
|
+
// sample. (Operators want reproducible spot-checks.)
|
|
81
|
+
const out = arr.slice(0, n);
|
|
82
|
+
let seed = (arr[0]?.ts || '').length * 9301 + 49297;
|
|
83
|
+
function rand() { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; }
|
|
84
|
+
for (let i = n; i < arr.length; i++) {
|
|
85
|
+
const j = Math.floor(rand() * (i + 1));
|
|
86
|
+
if (j < n) out[j] = arr[i];
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function reviewCmd(opts) {
|
|
92
|
+
const entries = _filterEntries(_readEntries(opts.root), opts);
|
|
93
|
+
if (entries.length === 0) {
|
|
94
|
+
if (opts.json) { console.log('[]'); return; }
|
|
95
|
+
console.log(`No entries match (root=${opts.root}, last=${opts.last}${opts.tool ? ', tool=' + opts.tool : ''}${opts.outcome ? ', outcome=' + opts.outcome : ''}).`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const sample = _sample(entries, opts.n);
|
|
99
|
+
if (opts.json) { console.log(JSON.stringify({ totalMatching: entries.length, sampled: sample.length, entries: sample }, null, 2)); return; }
|
|
100
|
+
console.log('');
|
|
101
|
+
console.log(`Audit transcript — root=${opts.root}, last=${opts.last}, matching=${entries.length}, sampled=${sample.length}`);
|
|
102
|
+
if (opts.tool || opts.outcome) console.log(` filters: ${[opts.tool ? `tool=${opts.tool}` : null, opts.outcome ? `outcome=${opts.outcome}` : null].filter(Boolean).join(', ')}`);
|
|
103
|
+
console.log('');
|
|
104
|
+
for (const e of sample) {
|
|
105
|
+
const tag = e.outcome === 'ok' ? 'OK' : e.outcome === 'rejected' ? 'REJ' : e.outcome === 'error' ? 'ERR' : '???';
|
|
106
|
+
const reasonStr = e.reason ? ` (${e.reason})` : '';
|
|
107
|
+
console.log(` [${tag.padStart(3)}] ${e.ts} ${String(e.tool).padEnd(20)}${reasonStr}`);
|
|
108
|
+
if (e.args) {
|
|
109
|
+
const argStr = String(e.args).length > 200 ? String(e.args).slice(0, 200) + '…' : e.args;
|
|
110
|
+
console.log(` args: ${argStr}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
console.log('');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function metricsCmd(opts) {
|
|
117
|
+
const entries = _filterEntries(_readEntries(opts.root), opts);
|
|
118
|
+
if (opts.bySession) return _metricsBySession(entries, opts);
|
|
119
|
+
const byTool = {};
|
|
120
|
+
for (const e of entries) {
|
|
121
|
+
if (!byTool[e.tool]) byTool[e.tool] = { ok: 0, rejected: 0, error: 0, total: 0 };
|
|
122
|
+
byTool[e.tool].total++;
|
|
123
|
+
byTool[e.tool][e.outcome] = (byTool[e.tool][e.outcome] || 0) + 1;
|
|
124
|
+
}
|
|
125
|
+
if (opts.json) { console.log(JSON.stringify({ last: opts.last, totalEntries: entries.length, byTool }, null, 2)); return; }
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log(`Audit metrics — root=${opts.root}, last=${opts.last}, total=${entries.length}`);
|
|
128
|
+
console.log('');
|
|
129
|
+
console.log(` ${'tool'.padEnd(22)} ${'ok'.padStart(6)} ${'rej'.padStart(6)} ${'err'.padStart(6)} ${'total'.padStart(6)} rejRate`);
|
|
130
|
+
for (const [tool, c] of Object.entries(byTool)) {
|
|
131
|
+
const rejRate = c.total > 0 ? (c.rejected || 0) / c.total : 0;
|
|
132
|
+
console.log(` ${tool.padEnd(22)} ${String(c.ok || 0).padStart(6)} ${String(c.rejected || 0).padStart(6)} ${String(c.error || 0).padStart(6)} ${String(c.total).padStart(6)} ${(rejRate * 100).toFixed(1)}%`);
|
|
133
|
+
}
|
|
134
|
+
console.log('');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Per-session aggregation (harness-anatomy #9). Groups entries by sessionId
|
|
138
|
+
// (stamped on each audit entry at `auditCall` time). Flags sessions where any
|
|
139
|
+
// single tool was called > opts.outlierThreshold times — the "agent went into
|
|
140
|
+
// a tool loop and burned the budget" failure mode.
|
|
141
|
+
function _metricsBySession(entries, opts) {
|
|
142
|
+
const bySession = {};
|
|
143
|
+
for (const e of entries) {
|
|
144
|
+
const sid = e.sessionId || 'pre-instrumented'; // entries from before #9
|
|
145
|
+
if (!bySession[sid]) bySession[sid] = { total: 0, byTool: {}, firstTs: e.ts, lastTs: e.ts };
|
|
146
|
+
const s = bySession[sid];
|
|
147
|
+
s.total++;
|
|
148
|
+
s.lastTs = e.ts;
|
|
149
|
+
if (!s.byTool[e.tool]) s.byTool[e.tool] = 0;
|
|
150
|
+
s.byTool[e.tool]++;
|
|
151
|
+
}
|
|
152
|
+
const sessions = Object.entries(bySession).map(([id, s]) => {
|
|
153
|
+
const maxToolCount = Math.max(...Object.values(s.byTool));
|
|
154
|
+
const dominantTool = Object.entries(s.byTool).sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
155
|
+
return {
|
|
156
|
+
sessionId: id, total: s.total,
|
|
157
|
+
firstTs: s.firstTs, lastTs: s.lastTs,
|
|
158
|
+
byTool: s.byTool, dominantTool, maxToolCount,
|
|
159
|
+
outlier: maxToolCount >= opts.outlierThreshold,
|
|
160
|
+
};
|
|
161
|
+
}).sort((a, b) => b.total - a.total);
|
|
162
|
+
if (opts.json) {
|
|
163
|
+
console.log(JSON.stringify({
|
|
164
|
+
last: opts.last, outlierThreshold: opts.outlierThreshold,
|
|
165
|
+
totalSessions: sessions.length, sessions,
|
|
166
|
+
}, null, 2));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
console.log('');
|
|
170
|
+
console.log(`Audit metrics — by session, root=${opts.root}, last=${opts.last}, threshold=${opts.outlierThreshold} calls/tool`);
|
|
171
|
+
console.log(` ${sessions.length} session(s); ${sessions.filter(s => s.outlier).length} flagged as outliers`);
|
|
172
|
+
console.log('');
|
|
173
|
+
console.log(` ${'sessionId'.padEnd(20)} ${'total'.padStart(6)} ${'dominant'.padEnd(22)} ${'max-of-1'.padStart(8)} flag`);
|
|
174
|
+
for (const s of sessions) {
|
|
175
|
+
const flag = s.outlier ? '⚠ OUTLIER' : '';
|
|
176
|
+
console.log(` ${s.sessionId.slice(0, 20).padEnd(20)} ${String(s.total).padStart(6)} ${(s.dominantTool || '').padEnd(22)} ${String(s.maxToolCount).padStart(8)} ${flag}`);
|
|
177
|
+
}
|
|
178
|
+
console.log('');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function verifyCmd(opts) {
|
|
182
|
+
const fp = _logPath(opts.root);
|
|
183
|
+
if (!fs.existsSync(fp)) { console.log('no audit log present'); process.exit(0); }
|
|
184
|
+
const r = verifyAuditLog(fp);
|
|
185
|
+
if (opts.json) { console.log(JSON.stringify(r, null, 2)); return; }
|
|
186
|
+
if (r.ok) console.log(`Audit chain verified: ${r.entries} entries.`);
|
|
187
|
+
else { console.error(`Audit chain BROKEN at line ${r.brokenAt}: ${r.reason || `expected prev=${r.expected}, got ${r.got}`}`); process.exit(1); }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const opts = args();
|
|
191
|
+
switch (opts.sub) {
|
|
192
|
+
case 'review': reviewCmd(opts); break;
|
|
193
|
+
case 'metrics': metricsCmd(opts); break;
|
|
194
|
+
case 'verify': verifyCmd(opts); break;
|
|
195
|
+
default:
|
|
196
|
+
console.error(`Unknown subcommand: ${opts.sub}. Try: review | metrics | verify`);
|
|
197
|
+
process.exit(2);
|
|
198
|
+
}
|