feat(runner): support user-defined scanners (BYOS) in profile config#23
Merged
Conversation
Scanner entries in a profile may now be objects declaring id, command,
env (required variable names), and targets. Custom scanners register
into a run-local registry and execute through the standard sandboxed
command path with {{target}} passed positionally to prevent shell
injection. Raw stdout is preserved as artifact evidence; env presence
is recorded as present/missing only.
This was referenced Jul 23, 2026
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(runner): support user-defined scanners (BYOS) in profile config This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this enables
ClawScan runs a fixed set of built-in scanners. This PR lets a profile config
declare its own scanner — an ID plus a shell command — which ClawScan runs
and whose raw JSON stdout it preserves as evidence, exactly like a built-in
adapter. This is "Bring Your Own Scanner" (BYOS).
A profile scanner used to be a name only. It can now also be an object:
{{target}}is substituted with the scan target at run time.Reviewer-checkable proof
With this branch checked out and
semgrepon your PATH, paste this to see acustom scanner run end to end (creates its own temp files, touches nothing in
the repo):
Expected — the risky file is flagged, the clean file is not, and semgrep's own
JSON is preserved untouched:
{ "status": "completed", "findings": 1, "flagged": ["handler_bad.py"] }Two contract checks worth doing while you're here:
--jsonfrom thecommand:line and rerun —semgrep prints plain text, and the scanner result flips to
failed("returned invalid JSON"). Raw evidence must be JSON.
scanners.semgrep.commandshows["/bin/sh","-c","semgrep ... \"$1\"","clawscan-target","<target>"]. Thetarget is passed as a positional argument, never spliced into the command
string, so target paths with spaces or shell metacharacters can't break out.
How it works (the seam)
internal/profiles/resolver.go):ProfileScanner.UnmarshalYAMLaccepts a scalar (built-in name) or a mapping (
{id, command, env, targets},marked
custom).resolver.go: profileScannerRegistry): each custom entrybecomes a
NewUserDefinedScanneradapter appended to the default registry viaScannerRegistry.WithAdapters.internal/runner/runner.go): a newOptions.ScannerRegistryfield carries that registry;
registryForOptions(opts)returns it (or thedefault), so ID validation and target-kind checks see custom scanners.
internal/runner/user_defined_scanner.go: Run): renders{{target}},runs through the sandbox shell (Docker→linux image, else host), and turns
stdout into a
ScannerResultunder the JSON contract above.Scope
Stacked series; this is the base. Review this diff against
main.(
--gate) is feat(runner): evaluate exit-code install-gate policy into artifact verdict #24, and the security hardening for user-defined scanners is astacked series sec (1/9): restrict user-defined scanner IDs to lowercase #25–sec (9/9): document that scanners must not print secrets into raw evidence #33 (sec 1–9 of 9): scanner-ID canonicalization
(sec (1/9): restrict user-defined scanner IDs to lowercase #25),
env:bare-name validation (sec (2/9): reject inline env values in user-defined scanners #26), required active{{target}}(sec (3/9): require an active {{target}} in user-defined scanners #27),benchmark preflight scoping (sec (4/9): scope benchmark requirement preflight to runnable scanners #28), Windows target guard (sec (5/9): reject unsafe targets on the Windows host shell #29), cwd isolation
(sec (6/9): run user-defined scanners in an isolated working directory #30), declared-env redaction (sec (7/9): redact declared scanner env values from error text #31), explicit sandbox mounts (sec (8/9): replace writable-parent mount guess with explicit sandbox mounts #32), and the
raw-evidence secret-safety contract (sec (9/9): document that scanners must not print secrets into raw evidence #33).
main → #23 → #24 → #25 … #33. This baseshould not land on
mainahead of that hardening stack.Verification