@vigolium/piolium 0.0.1
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 +21 -0
- package/README.md +117 -0
- package/agents/access-auditor.md +300 -0
- package/agents/assumption-breaker.md +154 -0
- package/agents/attack-designer.md +116 -0
- package/agents/code-scanner.md +139 -0
- package/agents/concurrency-auditor.md +238 -0
- package/agents/confirm-writer.md +257 -0
- package/agents/context-reviewer.md +274 -0
- package/agents/cross-verifier.md +165 -0
- package/agents/cve-scout.md +381 -0
- package/agents/env-builder.md +282 -0
- package/agents/env-profiler.md +205 -0
- package/agents/evidence-collector.md +140 -0
- package/agents/finding-grader.md +142 -0
- package/agents/finding-writer.md +148 -0
- package/agents/flow-tracer.md +106 -0
- package/agents/goal-backtracer.md +146 -0
- package/agents/history-miner.md +467 -0
- package/agents/independent-verifier.md +118 -0
- package/agents/intent-mapper.md +183 -0
- package/agents/longshot-collector.md +128 -0
- package/agents/longshot-prober.md +126 -0
- package/agents/patch-auditor.md +73 -0
- package/agents/poc-author.md +124 -0
- package/agents/poc-runner.md +194 -0
- package/agents/probe-lead.md +269 -0
- package/agents/red-challenger.md +101 -0
- package/agents/report-composer.md +208 -0
- package/agents/review-adjudicator.md +216 -0
- package/agents/spec-auditor.md +155 -0
- package/agents/taint-tracer.md +265 -0
- package/agents/test-locator.md +209 -0
- package/agents/threat-modeler.md +132 -0
- package/agents/variant-scanner.md +108 -0
- package/agents/variant-spotter.md +110 -0
- package/bin/piolium.mjs +376 -0
- package/extensions/piolium/_vendor/yaml.bundle.d.mts +6 -0
- package/extensions/piolium/_vendor/yaml.bundle.mjs +139 -0
- package/extensions/piolium/agent-runner.ts +322 -0
- package/extensions/piolium/agents.ts +266 -0
- package/extensions/piolium/audit-state.ts +522 -0
- package/extensions/piolium/bundled-resources.ts +97 -0
- package/extensions/piolium/candidate-scan.ts +966 -0
- package/extensions/piolium/command-target.ts +177 -0
- package/extensions/piolium/console-stream.ts +57 -0
- package/extensions/piolium/export-results.ts +380 -0
- package/extensions/piolium/findings.ts +448 -0
- package/extensions/piolium/heartbeat.ts +182 -0
- package/extensions/piolium/help.ts +234 -0
- package/extensions/piolium/index.ts +1865 -0
- package/extensions/piolium/longshot.ts +530 -0
- package/extensions/piolium/matcher-suggestions.ts +196 -0
- package/extensions/piolium/matcher-utils.ts +83 -0
- package/extensions/piolium/modes/balanced.ts +750 -0
- package/extensions/piolium/modes/confirm-bootstrap.ts +186 -0
- package/extensions/piolium/modes/confirm.ts +697 -0
- package/extensions/piolium/modes/deep.ts +917 -0
- package/extensions/piolium/modes/diff.ts +177 -0
- package/extensions/piolium/modes/lite.ts +540 -0
- package/extensions/piolium/modes/longshot.ts +595 -0
- package/extensions/piolium/modes/merge.ts +204 -0
- package/extensions/piolium/modes/phase-runner.ts +267 -0
- package/extensions/piolium/modes/reinvest.ts +546 -0
- package/extensions/piolium/modes/revisit.ts +279 -0
- package/extensions/piolium/modes.ts +48 -0
- package/extensions/piolium/phase-labels.ts +123 -0
- package/extensions/piolium/phase-status-strip.ts +92 -0
- package/extensions/piolium/prompt-prefix-editor.ts +39 -0
- package/extensions/piolium/providers/anthropic-vertex.ts +836 -0
- package/extensions/piolium/recon.ts +409 -0
- package/extensions/piolium/result-stats.ts +105 -0
- package/extensions/piolium/retry.ts +120 -0
- package/extensions/piolium/scheduler.ts +212 -0
- package/extensions/piolium/secrets.ts +368 -0
- package/extensions/piolium/tools/web-tools.ts +148 -0
- package/package.json +77 -0
- package/skills/agentic-actions-auditor/SKILL.md +327 -0
- package/skills/agentic-actions-auditor/references/action-profiles.md +186 -0
- package/skills/agentic-actions-auditor/references/cross-file-resolution.md +209 -0
- package/skills/agentic-actions-auditor/references/foundations.md +94 -0
- package/skills/agentic-actions-auditor/references/vector-a-env-var-intermediary.md +77 -0
- package/skills/agentic-actions-auditor/references/vector-b-direct-expression-injection.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-c-cli-data-fetch.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-d-pr-target-checkout.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-e-error-log-injection.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-f-subshell-expansion.md +82 -0
- package/skills/agentic-actions-auditor/references/vector-g-eval-of-ai-output.md +91 -0
- package/skills/agentic-actions-auditor/references/vector-h-dangerous-sandbox-configs.md +102 -0
- package/skills/agentic-actions-auditor/references/vector-i-wildcard-allowlists.md +88 -0
- package/skills/audit/SKILL.md +562 -0
- package/skills/audit/assets/icon.svg +7 -0
- package/skills/audit/hooks/scripts/validate_phase_output.py +550 -0
- package/skills/audit/references/adversarial-review.md +148 -0
- package/skills/audit/references/architecture-aware-sast.md +306 -0
- package/skills/audit/references/audit-workflow.md +737 -0
- package/skills/audit/references/chamber-protocol.md +384 -0
- package/skills/audit/references/creative-attack-modes.md +221 -0
- package/skills/audit/references/deep-analysis.md +273 -0
- package/skills/audit/references/domain-attack-playbooks.md +1129 -0
- package/skills/audit/references/knowledge-base-template.md +513 -0
- package/skills/audit/references/real-env-validation.md +191 -0
- package/skills/audit/references/report-templates.md +417 -0
- package/skills/audit/references/triage-and-prereqs.md +134 -0
- package/skills/audit/scripts/consolidate_drafts.py +554 -0
- package/skills/audit/scripts/partition_findings.py +152 -0
- package/skills/audit/scripts/rg-hotspots.sh +121 -0
- package/skills/audit/scripts/stamp_file_state.py +349 -0
- package/skills/code-reviewer/SKILL.md +65 -0
- package/skills/codeql/SKILL.md +281 -0
- package/skills/codeql/references/build-fixes.md +90 -0
- package/skills/codeql/references/diagnostic-query-templates.md +339 -0
- package/skills/codeql/references/extension-yaml-format.md +209 -0
- package/skills/codeql/references/important-only-suite.md +153 -0
- package/skills/codeql/references/language-details.md +207 -0
- package/skills/codeql/references/macos-arm64e-workaround.md +179 -0
- package/skills/codeql/references/performance-tuning.md +111 -0
- package/skills/codeql/references/quality-assessment.md +172 -0
- package/skills/codeql/references/ruleset-catalog.md +63 -0
- package/skills/codeql/references/run-all-suite.md +92 -0
- package/skills/codeql/references/sarif-processing.md +79 -0
- package/skills/codeql/references/threat-models.md +51 -0
- package/skills/codeql/workflows/build-database.md +280 -0
- package/skills/codeql/workflows/create-data-extensions.md +261 -0
- package/skills/codeql/workflows/run-analysis.md +301 -0
- package/skills/differential-review/SKILL.md +220 -0
- package/skills/differential-review/adversarial.md +203 -0
- package/skills/differential-review/methodology.md +234 -0
- package/skills/differential-review/patterns.md +300 -0
- package/skills/differential-review/reporting.md +369 -0
- package/skills/fp-check/SKILL.md +125 -0
- package/skills/fp-check/references/bug-class-verification.md +114 -0
- package/skills/fp-check/references/deep-verification.md +143 -0
- package/skills/fp-check/references/evidence-templates.md +91 -0
- package/skills/fp-check/references/false-positive-patterns.md +115 -0
- package/skills/fp-check/references/gate-reviews.md +27 -0
- package/skills/fp-check/references/standard-verification.md +78 -0
- package/skills/insecure-defaults/SKILL.md +117 -0
- package/skills/insecure-defaults/references/examples.md +409 -0
- package/skills/last30days/SKILL.md +444 -0
- package/skills/sarif-parsing/SKILL.md +483 -0
- package/skills/sarif-parsing/resources/jq-queries.md +162 -0
- package/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
- package/skills/security-threat-model/LICENSE.txt +201 -0
- package/skills/security-threat-model/SKILL.md +81 -0
- package/skills/security-threat-model/agents/openai.yaml +4 -0
- package/skills/security-threat-model/references/prompt-template.md +255 -0
- package/skills/security-threat-model/references/security-controls-and-assets.md +32 -0
- package/skills/semgrep/SKILL.md +212 -0
- package/skills/semgrep/references/rulesets.md +162 -0
- package/skills/semgrep/references/scan-modes.md +110 -0
- package/skills/semgrep/references/scanner-task-prompt.md +140 -0
- package/skills/semgrep/scripts/merge_sarif.py +203 -0
- package/skills/semgrep/workflows/scan-workflow.md +311 -0
- package/skills/semgrep-rule-creator/SKILL.md +168 -0
- package/skills/semgrep-rule-creator/references/quick-reference.md +202 -0
- package/skills/semgrep-rule-creator/references/workflow.md +240 -0
- package/skills/semgrep-rule-variant-creator/SKILL.md +205 -0
- package/skills/semgrep-rule-variant-creator/references/applicability-analysis.md +250 -0
- package/skills/semgrep-rule-variant-creator/references/language-syntax-guide.md +324 -0
- package/skills/semgrep-rule-variant-creator/references/workflow.md +518 -0
- package/skills/sharp-edges/SKILL.md +292 -0
- package/skills/sharp-edges/references/auth-patterns.md +252 -0
- package/skills/sharp-edges/references/case-studies.md +274 -0
- package/skills/sharp-edges/references/config-patterns.md +333 -0
- package/skills/sharp-edges/references/crypto-apis.md +190 -0
- package/skills/sharp-edges/references/lang-c.md +205 -0
- package/skills/sharp-edges/references/lang-csharp.md +285 -0
- package/skills/sharp-edges/references/lang-go.md +270 -0
- package/skills/sharp-edges/references/lang-java.md +263 -0
- package/skills/sharp-edges/references/lang-javascript.md +269 -0
- package/skills/sharp-edges/references/lang-kotlin.md +265 -0
- package/skills/sharp-edges/references/lang-php.md +245 -0
- package/skills/sharp-edges/references/lang-python.md +274 -0
- package/skills/sharp-edges/references/lang-ruby.md +273 -0
- package/skills/sharp-edges/references/lang-rust.md +272 -0
- package/skills/sharp-edges/references/lang-swift.md +287 -0
- package/skills/sharp-edges/references/language-specific.md +588 -0
- package/skills/spec-to-code-compliance/SKILL.md +357 -0
- package/skills/spec-to-code-compliance/resources/COMPLETENESS_CHECKLIST.md +69 -0
- package/skills/spec-to-code-compliance/resources/IR_EXAMPLES.md +417 -0
- package/skills/spec-to-code-compliance/resources/OUTPUT_REQUIREMENTS.md +105 -0
- package/skills/supply-chain-risk-auditor/SKILL.md +67 -0
- package/skills/supply-chain-risk-auditor/resources/results-template.md +41 -0
- package/skills/variant-analysis/METHODOLOGY.md +327 -0
- package/skills/variant-analysis/SKILL.md +142 -0
- package/skills/variant-analysis/resources/codeql/cpp.ql +119 -0
- package/skills/variant-analysis/resources/codeql/go.ql +69 -0
- package/skills/variant-analysis/resources/codeql/java.ql +71 -0
- package/skills/variant-analysis/resources/codeql/javascript.ql +63 -0
- package/skills/variant-analysis/resources/codeql/python.ql +80 -0
- package/skills/variant-analysis/resources/semgrep/cpp.yaml +98 -0
- package/skills/variant-analysis/resources/semgrep/go.yaml +63 -0
- package/skills/variant-analysis/resources/semgrep/java.yaml +61 -0
- package/skills/variant-analysis/resources/semgrep/javascript.yaml +60 -0
- package/skills/variant-analysis/resources/semgrep/python.yaml +72 -0
- package/skills/variant-analysis/resources/variant-report-template.md +75 -0
- package/skills/vuln-report/SKILL.md +137 -0
- package/skills/vuln-report/agents/openai.yaml +4 -0
- package/skills/vuln-report/references/report-template.md +135 -0
- package/skills/wooyun-legacy/SKILL.md +367 -0
- package/skills/wooyun-legacy/references/bank-penetration.md +222 -0
- package/skills/wooyun-legacy/references/checklists/command-execution-checklist.md +119 -0
- package/skills/wooyun-legacy/references/checklists/csrf-checklist.md +74 -0
- package/skills/wooyun-legacy/references/checklists/file-upload-checklist.md +108 -0
- package/skills/wooyun-legacy/references/checklists/info-disclosure-checklist.md +114 -0
- package/skills/wooyun-legacy/references/checklists/logic-flaws-checklist.md +95 -0
- package/skills/wooyun-legacy/references/checklists/misconfig-checklist.md +124 -0
- package/skills/wooyun-legacy/references/checklists/path-traversal-checklist.md +87 -0
- package/skills/wooyun-legacy/references/checklists/rce-checklist.md +93 -0
- package/skills/wooyun-legacy/references/checklists/sql-injection-checklist.md +97 -0
- package/skills/wooyun-legacy/references/checklists/ssrf-checklist.md +99 -0
- package/skills/wooyun-legacy/references/checklists/unauthorized-access-checklist.md +89 -0
- package/skills/wooyun-legacy/references/checklists/weak-password-checklist.md +115 -0
- package/skills/wooyun-legacy/references/checklists/xss-checklist.md +103 -0
- package/skills/wooyun-legacy/references/checklists/xxe-checklist.md +130 -0
- package/skills/wooyun-legacy/references/info-disclosure.md +975 -0
- package/skills/wooyun-legacy/references/logic-flaws.md +721 -0
- package/skills/wooyun-legacy/references/path-traversal.md +1191 -0
- package/skills/wooyun-legacy/references/telecom-penetration.md +156 -0
- package/skills/wooyun-legacy/references/unauthorized-access.md +980 -0
- package/skills/wooyun-legacy/references/xss.md +746 -0
- package/skills/zeroize-audit/SKILL.md +371 -0
- package/skills/zeroize-audit/configs/c.yaml +21 -0
- package/skills/zeroize-audit/configs/default.yaml +128 -0
- package/skills/zeroize-audit/configs/rust.yaml +83 -0
- package/skills/zeroize-audit/prompts/report_template.md +238 -0
- package/skills/zeroize-audit/prompts/system.md +163 -0
- package/skills/zeroize-audit/prompts/task.md +97 -0
- package/skills/zeroize-audit/references/compile-commands.md +231 -0
- package/skills/zeroize-audit/references/detection-strategy.md +191 -0
- package/skills/zeroize-audit/references/ir-analysis.md +252 -0
- package/skills/zeroize-audit/references/mcp-analysis.md +221 -0
- package/skills/zeroize-audit/references/poc-generation.md +470 -0
- package/skills/zeroize-audit/references/rust-zeroization-patterns.md +867 -0
- package/skills/zeroize-audit/schemas/input.json +83 -0
- package/skills/zeroize-audit/schemas/output.json +140 -0
- package/skills/zeroize-audit/tools/analyze_asm.sh +202 -0
- package/skills/zeroize-audit/tools/analyze_cfg.py +381 -0
- package/skills/zeroize-audit/tools/analyze_heap.sh +211 -0
- package/skills/zeroize-audit/tools/analyze_ir_semantic.py +429 -0
- package/skills/zeroize-audit/tools/diff_ir.sh +135 -0
- package/skills/zeroize-audit/tools/diff_rust_mir.sh +189 -0
- package/skills/zeroize-audit/tools/emit_asm.sh +67 -0
- package/skills/zeroize-audit/tools/emit_ir.sh +77 -0
- package/skills/zeroize-audit/tools/emit_rust_asm.sh +178 -0
- package/skills/zeroize-audit/tools/emit_rust_ir.sh +150 -0
- package/skills/zeroize-audit/tools/emit_rust_mir.sh +158 -0
- package/skills/zeroize-audit/tools/extract_compile_flags.py +284 -0
- package/skills/zeroize-audit/tools/generate_poc.py +1329 -0
- package/skills/zeroize-audit/tools/mcp/apply_confidence_gates.py +113 -0
- package/skills/zeroize-audit/tools/mcp/check_mcp.sh +68 -0
- package/skills/zeroize-audit/tools/mcp/normalize_mcp_evidence.py +125 -0
- package/skills/zeroize-audit/tools/scripts/check_llvm_patterns.py +481 -0
- package/skills/zeroize-audit/tools/scripts/check_mir_patterns.py +554 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm.py +424 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_aarch64.py +300 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_x86.py +283 -0
- package/skills/zeroize-audit/tools/scripts/find_dangerous_apis.py +375 -0
- package/skills/zeroize-audit/tools/scripts/semantic_audit.py +923 -0
- package/skills/zeroize-audit/tools/track_dataflow.sh +196 -0
- package/skills/zeroize-audit/tools/validate_rust_toolchain.sh +298 -0
- package/skills/zeroize-audit/workflows/phase-0-preflight.md +150 -0
- package/skills/zeroize-audit/workflows/phase-1-source-analysis.md +144 -0
- package/skills/zeroize-audit/workflows/phase-2-compiler-analysis.md +139 -0
- package/skills/zeroize-audit/workflows/phase-3-interim-report.md +46 -0
- package/skills/zeroize-audit/workflows/phase-4-poc-generation.md +46 -0
- package/skills/zeroize-audit/workflows/phase-5-poc-validation.md +136 -0
- package/skills/zeroize-audit/workflows/phase-6-final-report.md +44 -0
- package/skills/zeroize-audit/workflows/phase-7-test-generation.md +42 -0
- package/themes/piolium-srcery.json +94 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diff mode (`/piolium-diff`).
|
|
3
|
+
*
|
|
4
|
+
* Re-audit only what's changed since the last audited commit. Conservative
|
|
5
|
+
* MVP: if the prior audit isn't found / completed, ask the user to run
|
|
6
|
+
* balanced first. If the change set is too broad, recommend rerunning
|
|
7
|
+
* balanced or deep.
|
|
8
|
+
*
|
|
9
|
+
* Otherwise, run a focused balanced-style pipeline limited to changed
|
|
10
|
+
* files. Implementation is a single agent run with the code-scanner
|
|
11
|
+
* agent and a tightly scoped task prompt.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { execFileSync } from "node:child_process";
|
|
15
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import type { AgentRuntimeModel } from "../agent-runner.ts";
|
|
18
|
+
import { loadAgents } from "../agents.ts";
|
|
19
|
+
import {
|
|
20
|
+
type AuditRunState,
|
|
21
|
+
initAudit,
|
|
22
|
+
latestAudit,
|
|
23
|
+
markAuditStatus,
|
|
24
|
+
readAuditState,
|
|
25
|
+
} from "../audit-state.ts";
|
|
26
|
+
import { runCandidateScanAsync } from "../candidate-scan.ts";
|
|
27
|
+
import { runReconAsync } from "../recon.ts";
|
|
28
|
+
import { type PhaseUiHooks, runAgentPhase } from "./phase-runner.ts";
|
|
29
|
+
|
|
30
|
+
export interface RunDiffOptions {
|
|
31
|
+
cwd: string;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
ui?: PhaseUiHooks;
|
|
34
|
+
agentRuntime?: AgentRuntimeModel;
|
|
35
|
+
/** Compare against this commit instead of the prior audited commit. */
|
|
36
|
+
since?: string;
|
|
37
|
+
/** Hard limit on changed files; abort with guidance if exceeded. Default 200. */
|
|
38
|
+
maxChangedFiles?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RunDiffResult {
|
|
42
|
+
auditId?: string;
|
|
43
|
+
status: "complete" | "failed" | "skipped";
|
|
44
|
+
changedFiles: string[];
|
|
45
|
+
priorCommit?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const DIFF_ATTACK_SURFACE_DIR = "piolium/attack-surface";
|
|
49
|
+
export const DIFF_SUMMARY = `${DIFF_ATTACK_SURFACE_DIR}/diff-summary.md`;
|
|
50
|
+
|
|
51
|
+
function safeExec(file: string, args: string[], cwd: string): string | undefined {
|
|
52
|
+
try {
|
|
53
|
+
return execFileSync(file, args, {
|
|
54
|
+
cwd,
|
|
55
|
+
encoding: "utf8",
|
|
56
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
57
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
58
|
+
}).trim();
|
|
59
|
+
} catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function findPriorCommit(state: AuditRunState | undefined, override?: string): string | undefined {
|
|
65
|
+
if (override) return override;
|
|
66
|
+
if (!state) return undefined;
|
|
67
|
+
if (state.status !== "complete") return undefined;
|
|
68
|
+
if (!state.commit) return undefined;
|
|
69
|
+
return state.commit;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function runDiffAudit(opts: RunDiffOptions): Promise<RunDiffResult> {
|
|
73
|
+
const { cwd, signal, ui } = opts;
|
|
74
|
+
ui?.setStatus?.("piolium-diff", "● preparing recon");
|
|
75
|
+
const recon = await runReconAsync(cwd, { signal });
|
|
76
|
+
mkdirSync(join(cwd, DIFF_ATTACK_SURFACE_DIR), { recursive: true });
|
|
77
|
+
ui?.setStatus?.("piolium-diff", "● scanning candidate files");
|
|
78
|
+
const candidateScan = await runCandidateScanAsync(cwd, { signal });
|
|
79
|
+
ui?.notify?.(
|
|
80
|
+
`Candidate scan: ${candidateScan.candidateCount} match(es) across ${candidateScan.candidateFiles} file(s).`,
|
|
81
|
+
"info",
|
|
82
|
+
);
|
|
83
|
+
if (!recon.historyAvailable) {
|
|
84
|
+
ui?.notify?.(
|
|
85
|
+
"Diff mode requires git history. Run /piolium-balanced or /piolium-deep instead.",
|
|
86
|
+
"warning",
|
|
87
|
+
);
|
|
88
|
+
return { status: "skipped", changedFiles: [] };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const stateFile = readAuditState(cwd).state;
|
|
92
|
+
const prior = findPriorCommit(stateFile ? latestAudit(stateFile) : undefined, opts.since);
|
|
93
|
+
if (!prior) {
|
|
94
|
+
ui?.notify?.(
|
|
95
|
+
"No completed prior audit found. Run /piolium-balanced or /piolium-deep first, then come back.",
|
|
96
|
+
"warning",
|
|
97
|
+
);
|
|
98
|
+
return { status: "skipped", changedFiles: [] };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const diff = safeExec("git", ["diff", "--name-only", `${prior}...HEAD`], cwd);
|
|
102
|
+
if (diff === undefined) {
|
|
103
|
+
ui?.notify?.(`git diff against ${prior} failed.`, "error");
|
|
104
|
+
return { status: "failed", changedFiles: [], priorCommit: prior };
|
|
105
|
+
}
|
|
106
|
+
const changedFiles = diff.split("\n").filter(Boolean);
|
|
107
|
+
const cap = opts.maxChangedFiles ?? 200;
|
|
108
|
+
if (changedFiles.length > cap) {
|
|
109
|
+
ui?.notify?.(
|
|
110
|
+
`${changedFiles.length} files changed since ${prior.slice(0, 10)} — too broad for diff mode. Run /piolium-balanced.`,
|
|
111
|
+
"warning",
|
|
112
|
+
);
|
|
113
|
+
return { status: "skipped", changedFiles, priorCommit: prior };
|
|
114
|
+
}
|
|
115
|
+
if (changedFiles.length === 0) {
|
|
116
|
+
ui?.notify?.(`No code changes since ${prior.slice(0, 10)}. Diff mode has nothing to do.`, "info");
|
|
117
|
+
return { status: "skipped", changedFiles, priorCommit: prior };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const audit = await initAudit(cwd, {
|
|
121
|
+
mode: "diff",
|
|
122
|
+
commit: recon.commit ?? null,
|
|
123
|
+
...(recon.branch ? { branch: recon.branch } : {}),
|
|
124
|
+
...(recon.repository ? { repository: recon.repository } : {}),
|
|
125
|
+
history_available: recon.historyAvailable,
|
|
126
|
+
agent_sdk: "pi",
|
|
127
|
+
phases: ["1"],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const { agents } = loadAgents({ cwd });
|
|
131
|
+
const codeScanner = agents.get("code-scanner");
|
|
132
|
+
|
|
133
|
+
let failed = false;
|
|
134
|
+
try {
|
|
135
|
+
await runAgentPhase({
|
|
136
|
+
cwd,
|
|
137
|
+
audit,
|
|
138
|
+
phaseName: "1",
|
|
139
|
+
statusKey: "piolium-diff",
|
|
140
|
+
statusLabel: "● diff scan",
|
|
141
|
+
agent: codeScanner,
|
|
142
|
+
missingAgentMessage: "code-scanner missing",
|
|
143
|
+
task: [
|
|
144
|
+
"You are running /piolium-diff against a previously-audited repository.",
|
|
145
|
+
`Prior commit: ${prior}`,
|
|
146
|
+
`Current commit: ${recon.commit ?? "(unknown)"}`,
|
|
147
|
+
"",
|
|
148
|
+
"Changed files:",
|
|
149
|
+
...changedFiles.map((f) => ` - ${f}`),
|
|
150
|
+
"",
|
|
151
|
+
"Read prior durable context from `piolium/attack-surface/` when present, especially `candidates-summary.md`, `candidates.jsonl`, `knowledge-base-report.md`, `architecture-entrypoints.md`, `source-sink-flows-all-severities.md`, and `manual-attack-surface-inventory.md`.",
|
|
152
|
+
"",
|
|
153
|
+
"Steps:",
|
|
154
|
+
" 1. Read the diff (`git diff PRIOR...HEAD -- <file>`) for each changed file.",
|
|
155
|
+
" 2. Apply the same patterns as lite L3 / deep D5 (command injection, SSRF, authn/z, race conditions, etc.) but ONLY against the changed regions and their immediate callers.",
|
|
156
|
+
" 3. Surface drafts to `piolium/findings-draft/diff-NNN-<slug>.md`.",
|
|
157
|
+
` 4. Write a durable changed-attack-surface summary to \`${DIFF_SUMMARY}\` listing changed files, scope decisions, touched routes/sources/sinks, and finding pointers.`,
|
|
158
|
+
].join("\n"),
|
|
159
|
+
gate: () => existsSync(join(cwd, DIFF_SUMMARY)),
|
|
160
|
+
mode: "diff",
|
|
161
|
+
ui,
|
|
162
|
+
agentRuntime: opts.agentRuntime,
|
|
163
|
+
...(signal ? { signal } : {}),
|
|
164
|
+
});
|
|
165
|
+
} catch {
|
|
166
|
+
failed = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
await markAuditStatus(cwd, audit.audit_id, failed ? "failed" : "complete");
|
|
170
|
+
ui?.notify?.(failed ? "Diff mode failed." : "Diff mode complete.", failed ? "error" : "info");
|
|
171
|
+
return {
|
|
172
|
+
auditId: audit.audit_id,
|
|
173
|
+
status: failed ? "failed" : "complete",
|
|
174
|
+
changedFiles,
|
|
175
|
+
priorCommit: prior,
|
|
176
|
+
};
|
|
177
|
+
}
|