Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/clawscan/capture_output_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"io"
"os"
"strings"
"testing"
)

func TestCaptureStdoutDrainsLargeWrites(t *testing.T) {
payload := strings.Repeat("large fixture output\n", 16*1024)
got := captureStdout(t, func() {
if _, err := io.WriteString(os.Stdout, payload); err != nil {
t.Fatal(err)
}
})
if got != payload {
t.Fatalf("captured %d bytes, want %d", len(got), len(payload))
}
}
31 changes: 19 additions & 12 deletions cmd/clawscan/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1520,24 +1520,31 @@ func captureStdout(t *testing.T, fn func()) string {
t.Fatal(err)
}
os.Stdout = write
t.Cleanup(func() {
defer func() {
os.Stdout = original
})

_ = write.Close()
_ = read.Close()
}()

// JSON artifacts can exceed pipe capacity; drain while the CLI writes.
type captured struct {
out []byte
err error
}
done := make(chan captured, 1)
go func() {
out, err := io.ReadAll(read)
done <- captured{out, err}
}()
fn()

if err := write.Close(); err != nil {
t.Fatal(err)
}
out, err := io.ReadAll(read)
if err != nil {
t.Fatal(err)
}
if err := read.Close(); err != nil {
t.Fatal(err)
result := <-done
if result.err != nil {
t.Fatal(result.err)
}
os.Stdout = original
return string(out)
return string(result.out)
}

func captureOutput(t *testing.T, fn func()) (string, string) {
Expand Down
1 change: 1 addition & 0 deletions docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ clawscan profiles -v
| Profile | Scanners | Judge |
| --- | --- | --- |
| `clawhub` | skills: `skillspector`, `aig`; plugins: `aig-mcp` | Evidence-only Codex `gpt-6.1-sol` verdict from scanner results (no artifact copy; file, shell, web and code-execution tools disabled), then an evidence-only Codex `gpt-6-luna` low-effort overview |
| `clawhub-template` | `aig-mcp` only, entire shipped Template | Same existing evidence-only verdict judge and optional overview; see [Template contract](template-audit.md) |
| `clawhub-aig` | `skillspector`, `aig` | Same judge and overview as `clawhub` |
| `openclaw-install-policy` | `skillspector` | none |

Expand Down
12 changes: 7 additions & 5 deletions docs/scanners.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ config-backed run. The same JSON rules work for built-in and command scanners:
| `command` | yes | Shell command to execute. Unquoted `{{target}}` is replaced with the safely passed resolved target; do not wrap the placeholder in shell quotes. |
| `env` | no | Required non-secret environment variable names passed to the scanner. Their values are not automatically redacted from scanner error text. |
| `secretEnv` | no | Required secret environment variable names passed to the scanner. Their values are redacted from scanner error text regardless of how the names are spelled. |
| `targets` | no | Supported target kinds: `skill`, `plugin`, and/or `url`. Defaults to `skill` and `url`. |
| `targets` | no | Supported target kinds: `skill`, `plugin`, `template`, and/or `url`. Defaults to `skill` and `url`. |
| `gate` | no | JSON and/or exit-code policy applied after the scanner completes. |

### JSON gate rules
Expand Down Expand Up @@ -294,7 +294,7 @@ the result in the artifact `target.kind` field:
| `plugin` | directory (or selected manifest) holds `openclaw.plugin.json` or a supported bundle marker | Native identity comes from `id`; bundle identity comes from canonical name normalization. Host paths are never used as identity. |
| `url` | `http`/`https` input | Local file and directory scanners skip URLs. |

The built-in `clawhub` profile runs only the plugin-only `aig-mcp` scanner for
The built-in `clawhub` profile runs only the `aig-mcp` scanner for
`plugin` targets, described below. SkillSpector and Socket also support
plugins when selected explicitly or through a custom profile. Other scanners
that assume skill layouts return an explicit `skipped` result naming the
Expand All @@ -319,8 +319,10 @@ manifest selection and the native identifier grammar are unchanged.

Native OpenClaw plugins run in-process in the gateway with its full
permissions, so `aig-mcp` audits plugin code with Tencent A.I.G's
`aig-mcp-scan` (pinned to 0.2.0 in the runtime image). It analyzes only
`plugin` targets and skips skill, file and URL targets. The built-in `clawhub`
`aig-mcp-scan` (pinned to 0.2.0 in the runtime image). It analyzes `plugin` and `template` targets and skips skill, file and URL targets.
The separate `clawhub-template` profile retains every shipped file and uses a
Template-aware prompt; see the [Template audit contract](template-audit.md).
The following plugin-specific behavior is unchanged. The built-in `clawhub`
profile lists it under `pluginScanners`, so a plugin is reviewed by `aig-mcp`
and the judge only; SkillSpector and the `aig` skill scanner are not run or
recorded for plugins, and skills keep those scanners. For each
Expand Down Expand Up @@ -432,7 +434,7 @@ commas, single-quoted strings, and unquoted keys.
| --- | --- | --- | --- | --- | --- |
| `agentverus` | AgentVerus | [repo](https://github.com/agentverus/agentverus-scanner) | Local file or directory scanner invoked through agentverus-scanner. | none | `npm install --save-dev agentverus-scanner` |
| `aig` | Tencent AI-Infra-Guard | [repo](https://github.com/Tencent/AI-Infra-Guard/tree/main/skill-scan) | Tencent Zhuque Lab's local directory scanner invoked through `aig-skill-scan`. Produces SARIF 2.1.0 with SkillTrustBench T01-T09 evidence. | `LLM_API_KEY` or `OPENAI_API_KEY`<br><details><summary>Optional config</summary><code>DEFAULT_MODEL</code>, <code>REASONING_EFFORT</code> (requires the patched runtime), <code>AIG_SERVICE_TIER</code> (Sol only), <code>DEFAULT_BASE_URL</code>, <code>DEFAULT_MODEL_CONTEXT_WINDOW</code>, <code>LOG_LEVEL</code>.</details> | `pip install aig-skill-scan` |
| `aig-mcp` | Tencent AI-Infra-Guard MCP scanner | [repo](https://github.com/Tencent/AI-Infra-Guard/tree/main/mcp-scan) | Tencent Zhuque Lab's LLM-driven MCP server code audit invoked through `aig-mcp-scan`, run on OpenClaw plugin targets only (skill, file and URL targets are skipped). Audits a bounded temporary copy of the whole plugin without `node_modules`, using an OpenClaw plugin audit prompt, and produces SARIF 2.1.0 with MCP01-MCP10 evidence. Runs in the Docker sandbox, whose runtime image removes the agent's shell and file-write tools. | `LLM_API_KEY` or `OPENAI_API_KEY`<br><details><summary>Optional config</summary><code>DEFAULT_MODEL</code>, <code>DEFAULT_BASE_URL</code> (same defaults as <code>aig</code>), <code>DEFAULT_MODEL_CONTEXT_WINDOW</code>, <code>AIG_MCP_SCAN_ALLOW_HOST_EXEC=1</code> (required with <code>--sandbox off</code>).</details> | runtime image (patched `aig-mcp-scan==0.2.0`); `pip install aig-mcp-scan==0.2.0` is unpatched |
| `aig-mcp` | Tencent AI-Infra-Guard MCP scanner | [repo](https://github.com/Tencent/AI-Infra-Guard/tree/main/mcp-scan) | Tencent Zhuque Lab's LLM-driven MCP server code audit invoked through `aig-mcp-scan`, run on OpenClaw plugin and Template targets (skill, file and URL targets are skipped). Audits a bounded temporary copy of the whole plugin without `node_modules`, using an OpenClaw plugin audit prompt, and produces SARIF 2.1.0 with MCP01-MCP10 evidence. Runs in the Docker sandbox, whose runtime image removes the agent's shell and file-write tools. | `LLM_API_KEY` or `OPENAI_API_KEY`<br><details><summary>Optional config</summary><code>DEFAULT_MODEL</code>, <code>DEFAULT_BASE_URL</code> (same defaults as <code>aig</code>), <code>DEFAULT_MODEL_CONTEXT_WINDOW</code>, <code>AIG_MCP_SCAN_ALLOW_HOST_EXEC=1</code> (required with <code>--sandbox off</code>).</details> | runtime image (patched `aig-mcp-scan==0.2.0`); `pip install aig-mcp-scan==0.2.0` is unpatched |
| `cisco` | Cisco AI Defense skill-scanner | [repo](https://github.com/cisco-ai-defense/skill-scanner) | Local file or directory scanner invoked through `skill-scanner` with JSON report output. Optional upstream env vars enable LLM, VirusTotal, and Cisco AI Defense analyzers. | none<br><details><summary>Optional config</summary><code>SKILL_SCANNER_LLM_API_KEY</code>, <code>SKILL_SCANNER_LLM_PROVIDER</code>, <code>SKILL_SCANNER_LLM_MODEL</code>, <code>SKILL_SCANNER_LLM_BASE_URL</code>, <code>SKILL_SCANNER_LLM_USER</code>, <code>SKILL_SCANNER_LLM_API_VERSION</code>, <code>SKILL_SCANNER_LLM_FORCE_JSON_OBJECT</code>, <code>SKILL_SCANNER_META_LLM_API_KEY</code>, <code>SKILL_SCANNER_META_LLM_MODEL</code>, <code>SKILL_SCANNER_META_LLM_BASE_URL</code>, <code>SKILL_SCANNER_META_LLM_API_VERSION</code>, <code>AWS_PROFILE</code>, <code>AWS_REGION</code>, <code>GOOGLE_APPLICATION_CREDENTIALS</code>, <code>VIRUSTOTAL_API_KEY</code>, <code>AI_DEFENSE_API_KEY</code>, <code>AI_DEFENSE_API_URL</code>.</details> | `uv pip install cisco-ai-skill-scanner` |
| `relyable` | Relyable | [repo](https://github.com/veriker/relyable) | Functional re-derivation evidence: does the skill still do what its docs claim, recomputed? Emits the strongest grade that applies. `exogenous`: a declared `rederive.json` property manifest (idempotence / round-trip), with both sides of the relation computed from the skill's own code and the result mutation-tested against vacuity. `self_spec`: re-runs the author's own committed oracle (shipped tests or documented I/O examples). `cold_golden`: when an LLM key is set, a code-blind model infers goldens from SKILL.md alone and abstains unless the docs pin exact behavior; divergences are reported as unconfirmed, never as accusations. `non_rederivable`: the honest floor, never a fabricated pass. Functional axis only; complements the security scanners and does not detect malware or prompt injection. Skill code runs only inside the Docker sandbox (or with an explicit opt-in), in a scrubbed environment, and the scanner fails closed otherwise. Not preinstalled in the `clawscan-runtime` image. | none<br><details><summary>Optional config</summary><code>RELYABLE_SCAN_ALLOW_HOST_EXEC</code> — explicit ack that the host is disposable when running with <code>--sandbox off</code>.<br><br><code>RELYABLE_LLM_API_KEY</code> (+ <code>RELYABLE_LLM_PROVIDER</code> <code>anthropic|openai</code>, <code>RELYABLE_LLM_MODEL</code>, <code>RELYABLE_LLM_BASE_URL</code>) — explicit per-scanner opt-in that enables the <code>cold_golden</code> lane; key presence only is ever recorded in the payload. Generic <code>ANTHROPIC_API_KEY</code>/<code>OPENAI_API_KEY</code> are honored by standalone <code>relyable-scan</code> but are deliberately not auto-forwarded by ClawScan.</details> | `clawscan install relyable` — not preinstalled in the runtime image |
| `skillspector` | NVIDIA SkillSpector | [repo](https://github.com/NVIDIA/skillspector) | Local skill or OpenClaw plugin file/directory scanner. Uses LLM mode when provider env vars are set; otherwise runs with `--no-llm`. | none<br><details><summary>Optional config</summary><code>SKILLSPECTOR_PROVIDER</code>, <code>SKILLSPECTOR_MODEL</code>, <code>SKILLSPECTOR_REASONING_EFFORT</code>, <code>SKILLSPECTOR_TEMPERATURE</code>, <code>SKILLSPECTOR_SEED</code>, <code>SKILLSPECTOR_SERVICE_TIER</code> (Sol only), <code>SKILLSPECTOR_MODEL_REGISTRY</code>, <code>SKILLSPECTOR_LOG_LEVEL</code>, <code>SKILLSPECTOR_SSL_VERIFY</code>, <code>NVIDIA_INFERENCE_KEY</code>, <code>OPENAI_API_KEY</code>, <code>OPENAI_BASE_URL</code>, <code>ANTHROPIC_API_KEY</code>, <code>ANTHROPIC_PROXY_ENDPOINT_URL</code>, <code>ANTHROPIC_PROXY_API_KEY</code>, <code>ANTHROPIC_PROXY_API_VERSION</code>.</details> | `uv tool install git+https://github.com/NVIDIA/skillspector.git` |
Expand Down
Loading
Loading