# openclaw/clawscan architecture

> Architecture diagram of the GitHub repository openclaw/clawscan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openclaw/clawscan
- Repository: https://github.com/openclaw/clawscan

## Overview

ClawScan is a composable security-scanning harness for agent skills and OpenClaw plugins. Its main workflow accepts a target and scanner/profile selection, resolves configuration, scans the target with selected adapters, optionally judges the collected evidence, then emits an artifact and gate outcome. Separate branches provide benchmark runs and submission validation, profile discovery, dependency installation, and an OpenClaw install-policy decision. The graph follows the documented capabilities and source-index references; links to unsampled runner internals are left unverified rather than inferred as direct calls.

Main entry points: [`internal/runner/runner.go`](https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go) (Scan orchestrator), [`cmd/clawscan/main.go`](https://github.com/openclaw/clawscan/blob/main/cmd/clawscan/main.go) (ClawScan CLI), [`internal/profiles/resolver.go`](https://github.com/openclaw/clawscan/blob/main/internal/profiles/resolver.go) (Run resolver), [`internal/installpolicy/policy.go`](https://github.com/openclaw/clawscan/blob/main/internal/installpolicy/policy.go) (Install policy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and profiles"]
  node_npm["Node launcher<br/>[clawscan.js]"]
  node_cli["ClawScan CLI<br/>[main.go]"]
  node_resolver["Run resolver<br/>[resolver.go]"]
  node_profile_catalog["Profile catalog<br/>[registry.go]"]
  node_profile_yaml["Profile YAML<br/>[yaml.go]"]
end

subgraph group_scanning["Scan execution"]
  node_runner["Scan orchestrator<br/>[runner.go]"]
  node_target["Target handling<br/>[target.go]"]
  node_content["Target content<br/>[target_content.go]"]
  node_scanner_registry["Scanner catalog"]
  node_scanner_adapters["Scanner adapters"]
  node_sandbox["Command sandbox<br/>[sandbox.go]"]
end

subgraph group_evaluation["Evaluation and results"]
  node_judge["Judge harness<br/>[runner.go]"]
  node_artifact["Run artifact<br/>[runner.go]"]
  node_benchmarks["Benchmark runs"]
  node_submission["Submission validation<br/>[submission.go]"]
  node_leaderboard["Leaderboard app<br/>[app.py]"]
end

subgraph group_integrations["Host integrations"]
  node_install["Install planning<br/>[install.go]"]
  node_policy["Install policy<br/>[policy.go]"]
  node_policy_stages["Policy stages<br/>[stages.go]"]
  node_clawhub_prompt["ClawHub prompt<br/>[prompt.go]"]
  node_prompt_parity["Prompt parity check<br/>[main.go]"]
end

node_operator(("Operator"))

node_operator -->|"launches"| node_npm
node_operator -->|"runs"| node_cli
node_npm -->|"spawns binary"| node_cli
node_cli -->|"resolves options"| node_resolver
node_cli -->|"runs scans"| node_runner
node_cli -->|"handles policy"| node_policy
node_cli -->|"lists profiles"| node_profile_catalog
node_resolver -.->|"loads profiles"| node_profile_catalog
node_resolver -.->|"parses config"| node_profile_yaml
node_resolver -->|"builds run options"| node_runner
node_profile_catalog -->|"validates scanner IDs"| node_scanner_registry
node_runner -.->|"resolves target"| node_target
node_target -.->|"reads content"| node_content
node_runner -.->|"selects adapters"| node_scanner_registry
node_runner -.->|"dispatches scans"| node_scanner_adapters
node_scanner_adapters -.->|"runs commands"| node_sandbox
node_runner -.->|"invokes judge"| node_judge
node_runner -.->|"writes results"| node_artifact
node_runner -.->|"runs benchmark"| node_benchmarks
node_cli -.->|"validates submission"| node_submission
node_submission -.->|"supplies metrics"| node_leaderboard
node_cli -.->|"installs dependencies"| node_install
node_policy -->|"scans staged target"| node_runner
node_policy -.->|"uses policy stages"| node_policy_stages
node_runner -->|"renders prompt"| node_clawhub_prompt
node_prompt_parity -->|"builds comparison artifact"| node_runner

click node_npm "https://github.com/openclaw/clawscan/blob/main/npm/clawscan/bin/clawscan.js"
click node_cli "https://github.com/openclaw/clawscan/blob/main/cmd/clawscan/main.go"
click node_resolver "https://github.com/openclaw/clawscan/blob/main/internal/profiles/resolver.go"
click node_profile_catalog "https://github.com/openclaw/clawscan/blob/main/internal/profiles/registry.go"
click node_profile_yaml "https://github.com/openclaw/clawscan/blob/main/internal/profiles/yaml.go"
click node_runner "https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go"
click node_target "https://github.com/openclaw/clawscan/blob/main/internal/runner/target.go"
click node_content "https://github.com/openclaw/clawscan/blob/main/internal/runner/target_content.go"
click node_scanner_registry "https://github.com/openclaw/clawscan/blob/main/internal/runner/scanner_registry.go"
click node_scanner_adapters "https://github.com/openclaw/clawscan/tree/main/internal/runner"
click node_sandbox "https://github.com/openclaw/clawscan/blob/main/internal/runner/sandbox.go"
click node_judge "https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go"
click node_artifact "https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go"
click node_benchmarks "https://github.com/openclaw/clawscan/blob/main/internal/runner/benchmark_registry.go"
click node_submission "https://github.com/openclaw/clawscan/blob/main/internal/runner/submission.go"
click node_leaderboard "https://github.com/openclaw/clawscan/blob/main/leaderboard/space/app.py"
click node_install "https://github.com/openclaw/clawscan/blob/main/internal/runner/install.go"
click node_policy "https://github.com/openclaw/clawscan/blob/main/internal/installpolicy/policy.go"
click node_policy_stages "https://github.com/openclaw/clawscan/blob/main/internal/installpolicy/stages.go"
click node_clawhub_prompt "https://github.com/openclaw/clawscan/blob/main/internal/clawhubprompt/prompt.go"
click node_prompt_parity "https://github.com/openclaw/clawscan/blob/main/cmd/verify-clawhub-prompt/main.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_npm,node_cli,node_resolver,node_profile_catalog,node_profile_yaml toneBlue
class node_runner,node_target,node_content,node_scanner_registry,node_scanner_adapters,node_sandbox toneAmber
class node_judge,node_artifact,node_benchmarks,node_submission,node_leaderboard toneMint
class node_install,node_policy,node_policy_stages,node_clawhub_prompt,node_prompt_parity toneRose
class node_operator toneIndigo
```

## Components

### CLI and profiles

- [Node launcher](https://github.com/openclaw/clawscan/blob/main/npm/clawscan/bin/clawscan.js): `npm/clawscan/bin/clawscan.js`
- [ClawScan CLI](https://github.com/openclaw/clawscan/blob/main/cmd/clawscan/main.go): `cmd/clawscan/main.go`
- [Run resolver](https://github.com/openclaw/clawscan/blob/main/internal/profiles/resolver.go): `internal/profiles/resolver.go`
- [Profile catalog](https://github.com/openclaw/clawscan/blob/main/internal/profiles/registry.go): `internal/profiles/registry.go`
- [Profile YAML](https://github.com/openclaw/clawscan/blob/main/internal/profiles/yaml.go): `internal/profiles/yaml.go`

### Scan execution

- [Scan orchestrator](https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go): `internal/runner/runner.go`
- [Target handling](https://github.com/openclaw/clawscan/blob/main/internal/runner/target.go): `internal/runner/target.go`
- [Target content](https://github.com/openclaw/clawscan/blob/main/internal/runner/target_content.go): `internal/runner/target_content.go`
- [Scanner catalog](https://github.com/openclaw/clawscan/blob/main/internal/runner/scanner_registry.go): `internal/runner/scanner_registry.go`
- [Scanner adapters](https://github.com/openclaw/clawscan/tree/main/internal/runner): `internal/runner`
- [Command sandbox](https://github.com/openclaw/clawscan/blob/main/internal/runner/sandbox.go): `internal/runner/sandbox.go`

### Evaluation and results

- [Judge harness](https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go): `internal/runner/runner.go`
- [Run artifact](https://github.com/openclaw/clawscan/blob/main/internal/runner/runner.go): `internal/runner/runner.go`
- [Benchmark runs](https://github.com/openclaw/clawscan/blob/main/internal/runner/benchmark_registry.go): `internal/runner/benchmark_registry.go`
- [Submission validation](https://github.com/openclaw/clawscan/blob/main/internal/runner/submission.go): `internal/runner/submission.go`
- [Leaderboard app](https://github.com/openclaw/clawscan/blob/main/leaderboard/space/app.py): `leaderboard/space/app.py`

### Host integrations

- [Install planning](https://github.com/openclaw/clawscan/blob/main/internal/runner/install.go): `internal/runner/install.go`
- [Install policy](https://github.com/openclaw/clawscan/blob/main/internal/installpolicy/policy.go): `internal/installpolicy/policy.go`
- [Policy stages](https://github.com/openclaw/clawscan/blob/main/internal/installpolicy/stages.go): `internal/installpolicy/stages.go`
- [ClawHub prompt](https://github.com/openclaw/clawscan/blob/main/internal/clawhubprompt/prompt.go): `internal/clawhubprompt/prompt.go`
- [Prompt parity check](https://github.com/openclaw/clawscan/blob/main/cmd/verify-clawhub-prompt/main.go): `cmd/verify-clawhub-prompt/main.go`

### Other components

- **Operator**

## Connections

- Operator → Node launcher: launches (evidence: `README.md`)
- Operator → ClawScan CLI: runs (evidence: `README.md`)
- Node launcher → ClawScan CLI: spawns binary (evidence: `npm/clawscan/bin/clawscan.js`)
- ClawScan CLI → Run resolver: resolves options (evidence: `cmd/clawscan/main.go`)
- ClawScan CLI → Scan orchestrator: runs scans (evidence: `cmd/clawscan/main.go`)
- ClawScan CLI → Install policy: handles policy (evidence: `cmd/clawscan/main.go`)
- ClawScan CLI → Profile catalog: lists profiles (evidence: `cmd/clawscan/main.go`)
- Run resolver → Profile catalog: loads profiles
- Run resolver → Profile YAML: parses config
- Run resolver → Scan orchestrator: builds run options (evidence: `internal/profiles/resolver.go`)
- Profile catalog → Scanner catalog: validates scanner IDs (evidence: `internal/profiles/registry.go`)
- Scan orchestrator → Target handling: resolves target
- Target handling → Target content: reads content
- Scan orchestrator → Scanner catalog: selects adapters
- Scan orchestrator → Scanner adapters: dispatches scans
- Scanner adapters → Command sandbox: runs commands
- Scan orchestrator → Judge harness: invokes judge (evidence: `internal/runner/runner.go`)
- Scan orchestrator → Run artifact: writes results (evidence: `internal/runner/runner.go`)
- Scan orchestrator → Benchmark runs: runs benchmark
- ClawScan CLI → Submission validation: validates submission
- Submission validation → Leaderboard app: supplies metrics
- ClawScan CLI → Install planning: installs dependencies
- Install policy → Scan orchestrator: scans staged target (evidence: `internal/installpolicy/policy.go`)
- Install policy → Policy stages: uses policy stages
- Scan orchestrator → ClawHub prompt: renders prompt (evidence: `internal/runner/runner.go`)
- Prompt parity check → Scan orchestrator: builds comparison artifact (evidence: `cmd/verify-clawhub-prompt/main.go`)
