Loading...
Loading...
Audits production source code files based on the strategy in workspace/plan.json. Use when a review plan exists and you need to perform static analysis and deep-dive reviews of targeted files. Don't use for planning, deduplicating, or writing patches.
npx skill4agent add google/mantis mantis-researcher/mantis-researcherworkspace/plan.json--snapshot_rootSNAPSHOT_ROOT--snapshot_idSNAPSHOT_IDdiscovery_commit--state_rootworkspace/plan.json.mantis_state.jsonfindings/kb/--target_rootsnapshot_pinneddiscovery_commitworkspace/plan.jsonworkspace/.mantis_state.json"kb_references"workspace/kb/entities/*.mdworkspace/kb/structural_index/manifest.jsonworkspace/helpers/query_structural_index.pyworkspace/findings/<uuid>.jsonworkspace/findings/mantis-dedupetarget_filescode_pathsLOCATOR RESOLUTION (before reading ANY target code or artifact):
0. ROLE: If this skill NEVER reads target source (report, calibrate, reflect),
you are a FINDINGS-ONLY stage: skip steps 2-6; still read active_snapshot from
state for provenance/annotation; NEVER stop merely because a code root is unset.
1. Determine CODE_ROOT, in this priority order:
a. If --target_root is passed on THIS invocation, CODE_ROOT = --target_root.
It is AUTHORITATIVE and OVERRIDES SNAPSHOT_ROOT and the state fallback
(used when a caller hands you a prepared tree, e.g. a patched shadow).
b. Else if --snapshot_root (or SNAPSHOT_ROOT) is passed, use it.
c. Else read state_root/workspace/.mantis_state.json (state_root from
--state_root if passed, else ./workspace/... relative to the current dir)
-> active_snapshot.root / .snapshot_id / .snapshot_pinned.
d. Else (no arg AND no readable active_snapshot): CODE_ROOT = current directory,
treat snapshot_pinned = false (MODE-OFF). Do NOT stop.
2. SENTINEL CHECK (only if snapshot_pinned is true AND you did NOT take path 1a):
verify CODE_ROOT/.mantis_snapshot_id exists and equals SNAPSHOT_ID. If missing
or different -> STOP "snapshot sentinel mismatch". (A --target_root tree (1a) is
deliberately mutated and is sentinel-EXEMPT.)
3. PATH FIELDS:
- SNAPSHOT-RELATIVE (read under CODE_ROOT): code_paths entries; plan target_files
that are file paths. Strip ONLY a trailing ":<digits>". A code_paths entry
containing "://" is a URL/endpoint, NOT a file read. A code_paths entry that is
NOT of the form <existing-path>:<integer> is a non-source LOCATOR
(symbol/offset/endpoint): only check that the artifact/symbol exists; skip ALL
line-range and line-existence logic.
- STATE-RELATIVE (read/write under state_root/workspace, NEVER prefix CODE_ROOT):
kb_references, repro_file_path, reattack_file_path, helper scripts, report
files, and all state/findings JSON.
4. Never WRITE under CODE_ROOT when snapshot_pinned is true. Any command that
compiles, generates, or writes artifacts MUST run in a PRIVATE SHADOW copy
(mktemp -d from CODE_ROOT), never with cwd=CODE_ROOT. Read-only inspection may
cd into CODE_ROOT.
5. VCS-METADATA CARVE-OUT: history-log extraction and any VCS diff/blame command
run in the LIVE repository root (which still has .git/.hg/.repo), NOT CODE_ROOT
(the snapshot copy strips VCS metadata). Do NOT stop merely because CODE_ROOT
lacks .git/.hg/.repo.
6. Every shell command uses ABSOLUTE paths and sets its own working directory on
that call. Do NOT assume the working directory persists between calls.workspace/plan.jsontarget_filescode_pathskb_referencesworkspace/plan.jsonworkspace/.mantis_state.jsonworkspace/findings/workspace/.mantis_state.jsonworkspace/plan.jsonworkspace/plan.json"kb_references"workspace/kb/entities/auth.md"target_files"active_snapshotworkspace/.mantis_state.jsonrootsnapshot_idsnapshot_pinnedactive_snapshot.snapshot_iddiscovery_commitactive_snapshotsnapshot_pinneddiscovery_commitworkspace/plan.jsonworkspace/plan.json{"potentially_flawed": true/false, "reason": "..."}workspace/findings/<id>.json--snapshot_root--snapshot_idtarget_filescode_pathsdiscovery_commitgit pullfetchcheckoutresethg pullupdaterepo syncworkspace/kb/structural_index/manifest.jsonpython3 workspace/helpers/query_structural_index.py resolve_symbol --name "<function_name>" [--language "<lang>"] [--file "<path>"] --state_root <state_root>ambiguous: true--file--languagesymbol_idpython3 workspace/helpers/query_structural_index.py find_callers --symbol_id "<id>" --limit 100 --offset 0 --state_root <state_root>coverage.partition_statuscompleteprecision == semanticcompleteprecision != semanticpartialemptyfailedprecisionbackendsemantictypecheckastsymbol-onlyheuristicdeferredcoverage-onlyfind_callers()potentially_flawedget_function_boundary(file, line)manifest.jsonresolve_symbolfind_callersworkspace/plan.jsonworkspace/kb/THREAT_MODEL.mdworkspace/findings/workspace/findings/<id>.jsonsignaturelineage_idcwecwecwe"CWE-787""CWE-416"signaturenormalized_titletitle[a-zA-Z0-9]normalized_titlenormalized_titlesha256(<original raw title as UTF-8 bytes>)cwe_partcweprimary_targetcode_paths:linesrc/auth.c:145src/auth.ccode_paths://code_pathsprimary_targetsignatureprimary_targetsignaturesha256(normalized_title + "|" + cwe_part + "|" + primary_target)primary_targetsignaturesha256(normalized_title + "|" + cwe_part + "|" + sorted(code_paths).join(","))discovery_commitlineage_idworkspace/archive/findings_pass_*/workspace/archive/loop*_findings/signaturesignaturelineage_idlineage_idprimary_targetcode_paths:linesrc/auth.cauth.cprimary_targetcode_paths[0]:linelib/old_auth.c:88old_auth.clineage_idprimary_targetcode_paths[0]:linelineage-via-basename-renamesignaturelineage_id--state_root/workspace/archive/cwesignaturelineage_iddiscovery_commitdiscovery_commitsignaturelineage_idcwesignaturelineage_idactive_snapshotsignaturestable_keycwestable_keysignaturestable_keytarget_filesdescriptioncode_paths:line{
"id": "A unique identifier generated for this finding (e.g., a UUID or random hash). This must be included and match the filename.",
"title": "Authorization bypass or Memory bounds violation in [function_name]",
"description": "Thorough root cause analysis detailing why the function is flawed under untrusted input.",
"impact": "Exploit outcome (e.g., Privilege escalation, Memory corruption, Data exfiltration).",
"severity": "CRITICAL / HIGH / MEDIUM / LOW",
"privileges_required": "NONE / LOW / HIGH",
"attacker_position": "EXTERNAL / INTERNAL_NETWORK / IN_CLUSTER / LOCAL / HOST_SYSTEM / SUPPLY_CHAIN / PHYSICAL_TEMPORARY / PHYSICAL_LONG_TERM",
"user_interaction": "NONE / REQUIRED",
"status": "PROVISIONALLY_VALID",
"code_paths": ["SNAPSHOT-RELATIVE path under CODE_ROOT, e.g. 'relative/file/path.c:145'. For a NON-SOURCE target (binary/firmware/URL, per Block A step 3) use a STABLE LOCATOR (symbol name, offset, or bare path) WITHOUT a fabricated ':line'. Never invent a line number."],
"discovery_commit": "The active_snapshot.snapshot_id read from workspace/.mantis_state.json at the start of this pass (Step 1). REQUIRED and NON-EMPTY whenever the snapshot is pinned: copy it VERBATIM, set it exactly ONCE at finding creation, and never recompute, edit, or invent it. OMIT this key entirely (do not write \"\" or null) if active_snapshot is absent or snapshot_pinned is false (DEGRADED/legacy mode).",
"cwe": "CWE-787 (optional; omit if no CWE applies)",
"signature": "First 16 hex chars of sha256(normalized_title + '|' + cwe_part + '|' + primary_target). Computed once at creation, never recomputed.",
"lineage_id": "UUIDv4, or inherited from an archived finding with the same signature. Computed once at creation.",
"mitigation": "Recommended corrective modification.",
"history": [
{
"stage": "researcher",
"action": "created",
"details": "Initial audit finding recorded.",
"pass_number": <current_pass_number>,
"timestamp": "<current_iso8601_timestamp>"
}
]
}discovery_commitdiscovery_commitdiscovery_commitactive_snapshot.snapshot_iddiscovery_commitactive_snapshotsnapshot_pinnedsignaturelineage_iddiscovery_commitsignatureworkspace/findings/