Skip to content

Preflight v2: follow one execution step into referenced scripts - #524

Merged
blitzcrieg1 merged 3 commits into
masterfrom
feat/preflight-script-inspection
Nov 28, 2026
Merged

blitzcrieg1 merged 3 commits into
masterfrom
feat/preflight-script-inspection

Conversation

@blitzcrieg1

Copy link
Copy Markdown
Owner

Preflight v2, step 1: follow one execution step.

When a declaration (npm lifecycle script, folder-open task, session-start hook, MCP command) resolves to a local script, the script is now read as data, never executed, never followed through a link, hashed with SHA-256, and checked against a small set of conservative observation patterns. The report shows present_inspected with file size, content hash prefix and observation names only. Contents stay out of the report and on the machine, so the local-first and EU data-residency story is unchanged.

New core/scanner/script_inspect.py:

  • text patterns: download_pipe_to_shell, base64_decode_pipe, eval_of_substitution, credential_key_path, persistence_file_write, long_encoded_blob
  • Python AST check for module-level-only calls: module_level_eval_call, module_level_subprocess_call, module_level_network_call
  • conftest.py / tests/conftest.py are inventoried as pytest_conftest (import_time), since pytest imports them at collection time

Observations name a shape; they are not a malware verdict or severity, matching the existing preflight contract.

Safety properties:

  • detection-frozen files untouched, ruleset fingerprint does not move (verified: 0 changes under core/audit/detection and policies/detection)
  • symlink/junction skip and O_NOFOLLOW reads still apply; 1 MB per-file cap unchanged
  • tests assert script contents never appear in JSON or text output

Verification: pytest tests/test_repository_preflight.py tests/test_scanner.py 96 passed, 1 skipped (platform symlink skip); ruff check clean; CLI smoke on a synthetic repo reports download_pipe_to_shell and module_level_subprocess_call with hash prefixes only, exit 0.

Next steps after this: remote preflight (scan --github OWNER/REPO@SHA via Trees/Blobs API, read-only), then dashboard correlation of preflight findings (repo + SHA) with recorded sessions in that workspace.

A resolved local script reference is now read as data (never executed,
never followed through a link), hashed with SHA-256, and checked against
a small set of conservative observation patterns. The report carries
status present_inspected with file size, content hash and observation
names only; contents stay out of the report and on the machine.

New script_inspect module: text patterns for download-pipe-to-shell,
base64-decode-pipe, eval-of-substitution, credential key paths,
persistence file writes and long encoded blobs, plus an AST check for
Python module-level eval/subprocess/network calls. conftest.py and
tests/conftest.py are inventoried as pytest_conftest (import_time)
surfaces, since pytest imports them at collection time.

Observations name a shape; they are not a malware verdict or severity.
Detection-frozen files are untouched, so the ruleset fingerprint does
not move. docs/scanner.md updated; tests cover suspicious and benign
scripts, conftest module-level calls, and content exclusion from output.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
@blitzcrieg1
blitzcrieg1 merged commit 967af41 into master Nov 28, 2026
10 checks passed
blitzcrieg1 added a commit that referenced this pull request Nov 28, 2026
Rebuilt on master after #524 merged: the same #525 content (bounded
GitHub preflight reads, symlink skips, partial-report preservation)
rebased onto the squashed preflight v2 base.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
blitzcrieg1 added a commit that referenced this pull request Nov 28, 2026
Rebuilt on master after #524 merged: the same #525 content (bounded
GitHub preflight reads, symlink skips, partial-report preservation)
rebased onto the squashed preflight v2 base.

Generated by Mistral Vibe.

Co-authored-by: Mistral Vibe <[email protected]>
blitzcrieg1 added a commit that referenced this pull request Nov 28, 2026
Preflight v2 ships as one release: preflight follows referenced scripts
(#524), a read-only GitHub preflight at a pinned commit (#525), and
preflight correlation with recorded sessions (#526). The canonical event
schema moves to 1.3.0 with the additive workspace_sha256 field. Version
and changelog move together per the version provenance tests.

Generated by Mistral Vibe.

Co-authored-by: Mistral Vibe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant