@@ -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
175166type 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
261242func 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
389362func 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
414381func 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-
541486func 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-
572501type skillSpectorAnalysis struct {
573502 Status string `json:"status"`
574503 Score int `json:"score"`
0 commit comments