This is the headless entry point of the automatic scan (suitable for any agent-CLI). You run the security-flow for checking a single Bitrix module, headless (the container is isolated, there is no external network — only the model relay; no web UI).
This skill itself contains no audit heuristics. The audit is in the skill scan, the severity
policy is in journal-review. The same steps in human-readable form are described in
using-marketplace-sec (upstream reference).
You are given in the prompt:
- MODULE_DIR — path to the unpacked PHP source of the module (invocation argument).
- RESULT_PATH — path where the final JSON report should be saved.
- REVIEW_SCRIPT — absolute path to
review_journal.py(deterministic severity-review script). Already on disk — use the path as is, do NOT look for it viafind.
If the path to REVIEW_SCRIPT is not given in the prompt — report this and stop the flow.
Mandatory sequence
Execute ALL steps in order. You must not write the raw audit directly to RESULT_PATH — RESULT_PATH must contain the reviewed (reviewed) report after step 2.
-
SCAN. Invoke the skill
scanwith the MODULE_DIR argument — conduct a thorough security audit according to its methodology (includingscan/references/*). Save the raw JSON to/tmp/raw-scan.json. Format strictly:{success, requestId, data:{vulnerabilities[], summary, scannedFiles, riskLevel, auditedFiles}}; EACH finding hasfile, line, type, severity, description, recommendation, fix. -
REVIEW (BUS-aware severity). Execute (substitute the real RESULT_PATH and REVIEW_SCRIPT from the prompt):
python3 "$REVIEW_SCRIPT" /tmp/raw-scan.json --output "RESULT_PATH"
The script preserves the original fields, replaces only severity with the reviewed severity, adds a reviewed node to each finding and data.reviewSummary. Now RESULT_PATH is the final report.
On a NON-zero exit code
review_journal.pythe script does NOT invent anything — it prints tostderrthe full list of actual gaps. Act with a deterministic loop (maximum 3 iterations):- Read
stderr. The machine-readable list is in the lineREVIEW_VALIDATION_ERRORS: [...](JSON array of all problematic findings at once). Each element:index,file,line,type,missingKeys,invalidSeverity. - For each listed finding, do a targeted check: open
(
Read) itsfile(if necessary byline) and write into/tmp/raw-scan.jsonreal the missing value derived from the code — the actualdescription/recommendation/fix, or the correctseverityfrom the set{high, medium, low}. Fix all findings from the list in one pass. No stubs/placeholders. - Rerun the same command
review_journal.py. Repeat the cycle until the exit code becomes 0.
If you fail to converge within 3 iterations — do NOT slip in fabricated data: stop the flow with an error (the outer layer will restart the scan from scratch). An honest retry is better than a fake report.
- Read
-
VALIDATE final. First the syntax:
python3 -m json.tool "RESULT_PATH". Then — self-check the real final form before declaring it done. ReadRESULT_PATHand verify each point:data.summary— it is a string (not an object, not an array).data.scannedFiles— it is a number.data.riskLevel∈{high, medium, low, none}.data.auditedFiles— it is an array of strings.- у each
data.vulnerabilities[i]contains all 7 keys (file, line, type, severity, description, recommendation, fix), anddescription,recommendation,fix— non-empty. data.riskLevelequals the maximum severity among the findings (none, if there are no findings).
If the self-check found a gap — do NOT insert a placeholder. Fix the real content: reread the module file and write in the actual
fix/recommendation/description, then rerun the REVIEW step (item 2, with the same bounded loop — at most 3 iterations), so that the reviewed report is reassembled from the corrected data. If you fail to converge — stop the flow with an error, do not submit a fake report. -
One-line summary: reviewed severity counters (high/medium/low) from data.reviewSummary.
Do not start any UI/web servers. The cumulative log (journal-update) in
this headless pipeline is NOT maintained — cross-run state is tracked by the API.