Skip to content

Commit 1d3ca1a

Browse files
fix(profiles): remove VirusTotal from clawhub (#19)
1 parent f4f5c44 commit 1d3ca1a

14 files changed

Lines changed: 84 additions & 311 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ clawscan profiles -v
181181

182182
| Profile | Scanners | Judge |
183183
| --- | --- | --- |
184-
| `clawhub` | `skillspector`, `virustotal`, `clawscan-static` | Codex `gpt-5.5`, high reasoning, bundled ClawHub prompt/schema |
184+
| `clawhub` | `skillspector`, `clawscan-static` | Codex `gpt-5.5`, high reasoning, bundled ClawHub prompt/schema |
185185

186186
### Build a custom profile with `.clawscan.yml`
187187

‎cmd/clawscan/main_test.go‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,12 @@ func TestRunCommandUsesBuiltInProfile(t *testing.T) {
498498
writeSkill(t, target, "# Profile\n")
499499
skillSpectorFixture := filepath.Join(dir, "skillspector.json")
500500
writeFile(t, skillSpectorFixture, `{"status":"clean","findings":[]}`)
501-
virusTotalFixture := filepath.Join(dir, "virustotal.json")
502-
writeFile(t, virusTotalFixture, `{"status":"not_found","data":null}`)
503501

504502
stdout := captureStdout(t, func() {
505503
if err := run([]string{
506504
target,
507505
"--profile", "clawhub",
508506
"--scanner-result", "skillspector=" + skillSpectorFixture,
509-
"--scanner-result", "virustotal=" + virusTotalFixture,
510507
"--judge", clawHubReceiptJudgeCommand(),
511508
"--sandbox", "off",
512509
"--json",
@@ -542,15 +539,12 @@ func TestRunCommandDiscoversSkillsWithExplicitProfile(t *testing.T) {
542539
writeSkill(t, filepath.Join(dir, "skills", "bar"), "# Bar\n")
543540
skillSpectorFixture := filepath.Join(dir, "skillspector.json")
544541
writeFile(t, skillSpectorFixture, `{"status":"clean","findings":[]}`)
545-
virusTotalFixture := filepath.Join(dir, "virustotal.json")
546-
writeFile(t, virusTotalFixture, `{"status":"not_found","data":null}`)
547542
t.Chdir(dir)
548543

549544
stdout := captureStdout(t, func() {
550545
if err := run([]string{
551546
"--profile", "clawhub",
552547
"--scanner-result", "skillspector=" + skillSpectorFixture,
553-
"--scanner-result", "virustotal=" + virusTotalFixture,
554548
"--judge", clawHubReceiptJudgeCommand(),
555549
"--sandbox", "off",
556550
"--json",

‎cmd/verify-clawhub-prompt/main.go‎

Lines changed: 35 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"regexp"
1414
"strings"
1515

16-
"github.com/openclaw/clawscan/internal/clawhubprompt"
1716
"github.com/openclaw/clawscan/internal/profiles"
1817
"github.com/openclaw/clawscan/internal/runner"
1918
)
@@ -34,7 +33,6 @@ func run() error {
3433
outClawScanPrompt := flag.String("out-clawscan-prompt", "", "Optional exact ClawScan-rendered prompt path")
3534
outOutputSchema := flag.String("out-output-schema", "", "Optional exported output schema path")
3635
outSkillSpectorResult := flag.String("out-skillspector-result", "", "Optional exported SkillSpector fixture JSON path")
37-
outVirusTotalResult := flag.String("out-virustotal-result", "", "Optional exported VirusTotal fixture JSON path")
3836
fixturePath := flag.String("fixture", "", "Optional production context and scanner fixture JSON path")
3937
flag.Parse()
4038
if *clawhubDir == "" {
@@ -60,7 +58,7 @@ func run() error {
6058
)
6159
}
6260
systemPrompt := rendered.SystemPrompt
63-
expected, actual, vtInput, skillSpectorInput, fixtureLabel, err := renderParityInputs(
61+
expected, actual, skillSpectorInput, fixtureLabel, err := renderParityInputs(
6462
resolvedClawHubDir,
6563
*fixturePath,
6664
rendered,
@@ -87,15 +85,11 @@ func run() error {
8785
if err != nil {
8886
return err
8987
}
90-
vtFixture, err := prettyJSON(vtInput)
91-
if err != nil {
92-
return err
93-
}
9488
skillSpectorFixture, err := prettyJSON(skillSpectorInput)
9589
if err != nil {
9690
return err
9791
}
98-
promptTemplate, err := buildPromptTemplate(actual, vtFixture, skillSpectorFixture)
92+
promptTemplate, err := buildPromptTemplate(actual, skillSpectorFixture)
9993
if err != nil {
10094
promptTemplate, err = buildPromptTemplateFromRendered(actual)
10195
if err != nil {
@@ -142,9 +136,6 @@ func run() error {
142136
if err := writeOptionalFile(*outSkillSpectorResult, []byte(skillSpectorFixture)); err != nil {
143137
return err
144138
}
145-
if err := writeOptionalFile(*outVirusTotalResult, []byte(vtFixture)); err != nil {
146-
return err
147-
}
148139
if err := writeOptionalFile(*outOutputSchema, schema); err != nil {
149140
return err
150141
}
@@ -174,7 +165,6 @@ func firstPromptDifference(expected string, actual string) string {
174165

175166
type parityFixture struct {
176167
Context json.RawMessage `json:"context"`
177-
VirusTotal json.RawMessage `json:"virustotal"`
178168
SkillSpector json.RawMessage `json:"skillspector"`
179169
}
180170

@@ -183,9 +173,8 @@ func renderParityInputs(
183173
fixturePath string,
184174
rendered clawHubPromptRender,
185175
clawScanPromptSource string,
186-
) (expected string, actual string, vtInput any, skillSpectorInput any, fixtureLabel string, err error) {
176+
) (expected string, actual string, skillSpectorInput any, fixtureLabel string, err error) {
187177
if fixturePath == "" {
188-
job := proofJob()
189178
skillSpectorAnalysis := proofSkillSpectorAnalysis()
190179
actual, err := runner.RenderClawHubPrompt(clawScanPromptSource, runner.Artifact{
191180
Profile: "clawhub",
@@ -198,64 +187,56 @@ func renderParityInputs(
198187
"skillSpectorCheckedAt":123
199188
}`),
200189
Scanners: map[string]runner.ScannerResult{
201-
"virustotal": {
202-
Status: "completed",
203-
Raw: mustJSON(job.Target.Version.VTAnalysis),
204-
},
205190
"skillspector": {
206191
Status: "completed",
207192
Raw: mustJSON(skillSpectorAnalysis),
208193
},
209194
},
210195
})
211196
if err != nil {
212-
return "", "", nil, nil, "", err
197+
return "", "", nil, "", err
213198
}
214-
return rendered.Prompt, actual, job.Target.Version.VTAnalysis, skillSpectorAnalysis, "synthetic", nil
199+
return rendered.Prompt, actual, skillSpectorAnalysis, "synthetic", nil
215200
}
216201

217202
resolvedFixturePath, err := filepath.Abs(fixturePath)
218203
if err != nil {
219-
return "", "", nil, nil, "", err
204+
return "", "", nil, "", err
220205
}
221206
raw, err := os.ReadFile(resolvedFixturePath)
222207
if err != nil {
223-
return "", "", nil, nil, "", err
208+
return "", "", nil, "", err
224209
}
225210
var fixture parityFixture
226211
if err := json.Unmarshal(raw, &fixture); err != nil {
227-
return "", "", nil, nil, "", fmt.Errorf("parse parity fixture: %w", err)
212+
return "", "", nil, "", fmt.Errorf("parse parity fixture: %w", err)
228213
}
229214
if !json.Valid(fixture.Context) {
230-
return "", "", nil, nil, "", fmt.Errorf("parity fixture context is not valid JSON")
215+
return "", "", nil, "", fmt.Errorf("parity fixture context is not valid JSON")
231216
}
232217
context, err := parityFixtureContext(fixture)
233218
if err != nil {
234-
return "", "", nil, nil, "", err
219+
return "", "", nil, "", err
235220
}
236221
expected, err = renderClawHubFixturePrompt(clawhubDir, resolvedFixturePath)
237222
if err != nil {
238-
return "", "", nil, nil, "", err
223+
return "", "", nil, "", err
239224
}
240225
artifact := runner.Artifact{
241226
Profile: "clawhub",
242227
Context: context,
243228
Scanners: map[string]runner.ScannerResult{
244-
"virustotal": {Status: "completed", Raw: fixture.VirusTotal},
245229
"skillspector": {Status: "completed", Raw: fixture.SkillSpector},
246230
},
247231
}
248232
actual, err = runner.RenderClawHubPrompt(clawScanPromptSource, artifact)
249233
if err != nil {
250-
return "", "", nil, nil, "", err
251-
}
252-
if err := json.Unmarshal(fixture.VirusTotal, &vtInput); err != nil {
253-
return "", "", nil, nil, "", fmt.Errorf("parse VirusTotal fixture: %w", err)
234+
return "", "", nil, "", err
254235
}
255236
if err := json.Unmarshal(fixture.SkillSpector, &skillSpectorInput); err != nil {
256-
return "", "", nil, nil, "", fmt.Errorf("parse SkillSpector fixture: %w", err)
237+
return "", "", nil, "", fmt.Errorf("parse SkillSpector fixture: %w", err)
257238
}
258-
return expected, actual, vtInput, skillSpectorInput, resolvedFixturePath, nil
239+
return expected, actual, skillSpectorInput, resolvedFixturePath, nil
259240
}
260241

261242
func parityFixtureContext(fixture parityFixture) (json.RawMessage, error) {
@@ -369,46 +350,32 @@ func writeOptionalFile(path string, content []byte) error {
369350
return os.WriteFile(path, content, 0o644)
370351
}
371352

372-
func buildPromptTemplate(prompt string, vtFixture string, skillSpectorFixture string) (string, error) {
373-
replacements := []struct {
374-
fixture string
375-
placeholder string
376-
}{
377-
{fixture: vtFixture, placeholder: "{{ scanners.virustotal }}"},
378-
{fixture: skillSpectorFixture, placeholder: "{{ scanners.skillspector }}"},
379-
}
380-
for _, replacement := range replacements {
381-
prompt = strings.Replace(prompt, replacement.fixture, replacement.placeholder, 1)
382-
if !strings.Contains(prompt, replacement.placeholder) {
383-
return "", fmt.Errorf("failed to build exported prompt template with scanner placeholder %s", replacement.placeholder)
384-
}
353+
func buildPromptTemplate(prompt string, skillSpectorFixture string) (string, error) {
354+
const placeholder = "{{ scanners.skillspector }}"
355+
prompt = strings.Replace(prompt, skillSpectorFixture, placeholder, 1)
356+
if !strings.Contains(prompt, placeholder) {
357+
return "", fmt.Errorf("failed to build exported prompt template with scanner placeholder %s", placeholder)
385358
}
386359
return prompt, nil
387360
}
388361

389362
func buildPromptTemplateFromRendered(prompt string) (string, error) {
390-
replacements := []struct {
391-
label string
392-
placeholder string
393-
}{
394-
{label: "VirusTotal telemetry supplied to Codex:", placeholder: "{{ scanners.virustotal }}"},
395-
{label: "SkillSpector findings supplied to Codex:", placeholder: "{{ scanners.skillspector }}"},
396-
}
397-
for _, replacement := range replacements {
398-
prefix := replacement.label + "\n```json\n"
399-
start := strings.Index(prompt, prefix)
400-
if start == -1 {
401-
return "", fmt.Errorf("rendered prompt missing %s block", replacement.label)
402-
}
403-
contentStart := start + len(prefix)
404-
contentEndOffset := strings.Index(prompt[contentStart:], "\n```")
405-
if contentEndOffset == -1 {
406-
return "", fmt.Errorf("rendered prompt has unterminated %s block", replacement.label)
407-
}
408-
contentEnd := contentStart + contentEndOffset
409-
prompt = prompt[:contentStart] + replacement.placeholder + prompt[contentEnd:]
410-
}
411-
return prompt, nil
363+
const (
364+
label = "SkillSpector findings supplied to Codex:"
365+
placeholder = "{{ scanners.skillspector }}"
366+
)
367+
prefix := label + "\n```json\n"
368+
start := strings.Index(prompt, prefix)
369+
if start == -1 {
370+
return "", fmt.Errorf("rendered prompt missing %s block", label)
371+
}
372+
contentStart := start + len(prefix)
373+
contentEndOffset := strings.Index(prompt[contentStart:], "\n```")
374+
if contentEndOffset == -1 {
375+
return "", fmt.Errorf("rendered prompt has unterminated %s block", label)
376+
}
377+
contentEnd := contentStart + contentEndOffset
378+
return prompt[:contentStart] + placeholder + prompt[contentEnd:], nil
412379
}
413380

414381
func prettyJSON(value any) (string, error) {
@@ -516,28 +483,6 @@ func clawHubWorkerOutputSchemaRelPath(workerSource string) (string, error) {
516483
return matches[1], nil
517484
}
518485

519-
func proofJob() clawhubprompt.Job {
520-
return clawhubprompt.Job{
521-
Job: clawhubprompt.JobMetadata{
522-
TargetKind: "skillVersion",
523-
Source: "publish",
524-
HasMaliciousSignal: true,
525-
},
526-
Target: clawhubprompt.Target{
527-
TrustedOpenClawPlugin: true,
528-
Version: &clawhubprompt.Version{
529-
VTAnalysis: vtAnalysis{
530-
Status: "suspicious",
531-
Source: "engines",
532-
Metadata: vtMetadata{
533-
Stats: vtStats{Malicious: 1, Suspicious: 0, Harmless: 12},
534-
},
535-
},
536-
},
537-
},
538-
}
539-
}
540-
541486
func proofSkillSpectorAnalysis() skillSpectorAnalysis {
542487
return skillSpectorAnalysis{
543488
Status: "suspicious",
@@ -553,22 +498,6 @@ func proofSkillSpectorAnalysis() skillSpectorAnalysis {
553498
}
554499
}
555500

556-
type vtAnalysis struct {
557-
Status string `json:"status"`
558-
Source string `json:"source"`
559-
Metadata vtMetadata `json:"metadata"`
560-
}
561-
562-
type vtMetadata struct {
563-
Stats vtStats `json:"stats"`
564-
}
565-
566-
type vtStats struct {
567-
Malicious int `json:"malicious"`
568-
Suspicious int `json:"suspicious"`
569-
Harmless int `json:"harmless"`
570-
}
571-
572501
type skillSpectorAnalysis struct {
573502
Status string `json:"status"`
574503
Score int `json:"score"`

‎cmd/verify-clawhub-prompt/main_test.go‎

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,34 @@ func TestResolveClawHubDirReturnsAbsolutePath(t *testing.T) {
2525
}
2626
}
2727

28-
func TestBuildPromptTemplateReplacesScannerFixtures(t *testing.T) {
29-
vtFixture := `{
30-
"status": "suspicious",
31-
"source": "engines"
32-
}`
28+
func TestBuildPromptTemplateReplacesSkillSpectorFixture(t *testing.T) {
3329
skillSpectorFixture := `{
3430
"status": "suspicious",
3531
"score": 55
3632
}`
3733
prompt := strings.Join([]string{
38-
"VirusTotal telemetry supplied to Codex:",
39-
"```json",
40-
vtFixture,
41-
"```",
4234
"SkillSpector findings supplied to Codex:",
4335
"```json",
4436
skillSpectorFixture,
4537
"```",
4638
}, "\n")
4739

48-
template, err := buildPromptTemplate(prompt, vtFixture, skillSpectorFixture)
40+
template, err := buildPromptTemplate(prompt, skillSpectorFixture)
4941
if err != nil {
5042
t.Fatal(err)
5143
}
5244

53-
for _, placeholder := range []string{"{{ scanners.virustotal }}", "{{ scanners.skillspector }}"} {
54-
if !strings.Contains(template, placeholder) {
55-
t.Fatalf("template missing placeholder %s:\n%s", placeholder, template)
56-
}
45+
if !strings.Contains(template, "{{ scanners.skillspector }}") {
46+
t.Fatalf("template missing SkillSpector placeholder:\n%s", template)
5747
}
58-
for _, fixture := range []string{vtFixture, skillSpectorFixture} {
59-
if strings.Contains(template, fixture) {
60-
t.Fatalf("template still contains raw fixture %q:\n%s", fixture, template)
61-
}
48+
if strings.Contains(template, skillSpectorFixture) {
49+
t.Fatalf("template still contains raw fixture:\n%s", template)
6250
}
6351
}
6452

65-
func TestBuildPromptTemplateFromRenderedReplacesScannerBlocks(t *testing.T) {
53+
func TestBuildPromptTemplateFromRenderedReplacesSkillSpectorBlock(t *testing.T) {
6654
prompt := strings.Join([]string{
6755
"Before",
68-
"VirusTotal telemetry supplied to Codex:",
69-
"```json",
70-
`{"status":"clean"}`,
71-
"```",
72-
"Middle",
7356
"SkillSpector findings supplied to Codex:",
7457
"```json",
7558
`{"status":"suspicious"}`,
@@ -81,15 +64,11 @@ func TestBuildPromptTemplateFromRenderedReplacesScannerBlocks(t *testing.T) {
8164
if err != nil {
8265
t.Fatal(err)
8366
}
84-
for _, placeholder := range []string{"{{ scanners.virustotal }}", "{{ scanners.skillspector }}"} {
85-
if !strings.Contains(template, placeholder) {
86-
t.Fatalf("template missing placeholder %s:\n%s", placeholder, template)
87-
}
67+
if !strings.Contains(template, "{{ scanners.skillspector }}") {
68+
t.Fatalf("template missing SkillSpector placeholder:\n%s", template)
8869
}
89-
for _, fixture := range []string{`{"status":"clean"}`, `{"status":"suspicious"}`} {
90-
if strings.Contains(template, fixture) {
91-
t.Fatalf("template still contains raw fixture %q:\n%s", fixture, template)
92-
}
70+
if strings.Contains(template, `{"status":"suspicious"}`) {
71+
t.Fatalf("template still contains raw fixture:\n%s", template)
9372
}
9473
}
9574

‎docs/profiles.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ clawscan profiles -v
2020

2121
| Profile | Scanners | Judge |
2222
| --- | --- | --- |
23-
| `clawhub` | `skillspector`, `virustotal`, `clawscan-static` | Codex `gpt-5.5`, high reasoning, bundled ClawHub prompt/schema |
23+
| `clawhub` | `skillspector`, `clawscan-static` | Codex `gpt-5.5`, high reasoning, bundled ClawHub prompt/schema |
2424

2525
## Build a custom profile with `.clawscan.yml`
2626

0 commit comments

Comments
 (0)