Skip to content

Commit 128ab2e

Browse files
committed
merge: validate submissions with the restored score writer
* commit '3ae7dde30ffcd355b85f4f1f5f1eb2b275fd502c': ci: limit macOS packaging checks to Darwin binaries (#173) test(cli): drain both output streams during CLI tests (#167) fix(ci): share the JSON file writer with submission scoring (#186) test(runner): synchronize cancellation with scanner progress (#179) refactor(runner): share Cisco and AIG report file handling (#183) test(runner): share stdout scanner contract cases (#178) refactor(runner): build SkillSpector evidence results once (#172) refactor(profiles): share YAML field definitions for scanners and mounts (#171) ci: skip the Go cache when submissions are unchanged (#175) ci: reuse each submission score for its summary (#174)
2 parents 4900b4a + 3ae7dde commit 128ab2e

25 files changed

Lines changed: 418 additions & 767 deletions

‎.github/workflows/ci.yml‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
run: npm install -g npm@^12.0.2
8282

8383
- name: Check formatting
84+
if: runner.os == 'Linux'
8485
run: |
8586
unformatted="$(git ls-files '*.go' | xargs gofmt -l)"
8687
if [ -n "$unformatted" ]; then
@@ -92,7 +93,8 @@ jobs:
9293
- name: Test
9394
run: go test ./...
9495

95-
- name: Build CLI
96+
- name: Build CLI for Docker mount tests
97+
if: runner.os == 'Linux'
9698
run: go build ./cmd/clawscan
9799

98100
- name: Test Docker mount paths and permissions
@@ -106,24 +108,29 @@ jobs:
106108
node --test npm/clawscan/test/*.test.mjs
107109
node --test scripts/build-npm-package.test.mjs
108110
node --test scripts/release-notes.test.mjs
109-
node scripts/build-npm-package.mjs --version v0.0.0 --pack --smoke
111+
112+
- name: Smoke the full npm package
113+
if: runner.os == 'Linux'
114+
run: node scripts/build-npm-package.mjs --version v0.0.0 --pack --smoke
110115

111116
- name: Verify macOS minimum and both architectures
112117
if: runner.os == 'macOS'
113118
run: |
119+
node scripts/build-npm-package.mjs --version v0.0.0 --platform darwin-arm64 --out dist/npm-arm64 --pack --smoke
120+
node scripts/build-npm-package.mjs --version v0.0.0 --platform darwin-x64 --out dist/npm-x64
114121
if ! arch -x86_64 /usr/bin/true; then
115122
softwareupdate --install-rosetta --agree-to-license
116123
fi
117124
arch -x86_64 /usr/bin/true
118125
for npm_arch in arm64 x64; do
119-
binary="dist/npm/package/binaries/darwin-${npm_arch}/clawscan"
126+
binary="dist/npm-${npm_arch}/package/binaries/darwin-${npm_arch}/clawscan"
120127
minos=$(xcrun vtool -show-build "$binary" | awk '$1 == "minos" { print $2 }')
121128
test "$minos" = 13.0
122129
done
123-
dist/npm/package/binaries/darwin-arm64/clawscan --version
124-
dist/npm/package/binaries/darwin-arm64/clawscan --help
125-
arch -x86_64 dist/npm/package/binaries/darwin-x64/clawscan --version
126-
arch -x86_64 dist/npm/package/binaries/darwin-x64/clawscan --help
130+
dist/npm-arm64/package/binaries/darwin-arm64/clawscan --version
131+
dist/npm-arm64/package/binaries/darwin-arm64/clawscan --help
132+
arch -x86_64 dist/npm-x64/package/binaries/darwin-x64/clawscan --version
133+
arch -x86_64 dist/npm-x64/package/binaries/darwin-x64/clawscan --help
127134
128135
- name: Test runtime update branch push
129136
run: node --test scripts/push-runtime-tool-update-branch.test.mjs

‎.github/workflows/security-signals-submissions.yml‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,31 @@ jobs:
2424
with:
2525
fetch-depth: 0
2626

27+
# Checkout uses the PR merge commit. An unavailable base falls through to validation.
28+
- name: Check for submission changes
29+
id: submissions
30+
env:
31+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
32+
run: |
33+
if git diff --quiet "$BASE_SHA" HEAD -- leaderboard/submissions; then
34+
echo "unchanged=true" >> "$GITHUB_OUTPUT"
35+
echo "No Security Signals submissions changed." >> "$GITHUB_STEP_SUMMARY"
36+
fi
37+
2738
- name: Set up Go
39+
if: steps.submissions.outputs.unchanged != 'true'
2840
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
2941
with:
3042
go-version: "1.27.3"
3143
go-version-file: go.mod
3244
cache: true
3345

3446
- name: Validate changed submissions
47+
if: steps.submissions.outputs.unchanged != 'true'
3548
run: scripts/validate-security-signals-submissions.sh
3649

3750
- name: Upload score previews
38-
if: always()
51+
if: always() && steps.submissions.outputs.unchanged != 'true'
3952
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
4053
with:
4154
name: security-signals-submission-scores

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Update the Go text-processing dependency to `golang.org/x/text` v0.44.0.
66
- **Breaking:** the `clawhub` and `clawhub-aig` profiles judge skills and plugins with an evidence-only Codex run (`gpt-6.1-sol`) that sees scanner results only. The new profile setting `judge.evidenceOnly` / `overview.evidenceOnly` removes the artifact copy from the command's workspace and refuses `{{ target.files }}`; the profile disables Codex's file, shell, image, web-search and code-execution tools (verified against codex-cli 0.164.0; its sub-agent tools stay offered but inherit the same restrictions). New prompt placeholders `{{ scanner_results }}` and `{{ run_context }}`. `judge.result` keeps the typed fields but no longer carries the Decisions `decision` record. The Decisions API judge remains available through `--judge`.
77
- Give scanner commands run against OpenClaw plugin targets a 30-minute budget (was 20 minutes); skill, file and URL targets keep 20 minutes. The judge and overview budgets are unchanged.
8+
- CI builds the full npm bundle on Linux and checks both Darwin architectures on macOS, avoiding four repeated cross-platform builds per run.
89
- Refresh Node setup to 7.1.0, use Node 24.22.2 for CI and docs, and Node 26.13.0 for release packaging.
910

1011
- **Breaking for plugin targets:** add the plugin-only `aig-mcp` scanner (Tencent A.I.G `aig-mcp-scan` 0.2.0, patched in the runtime image to allow only confined read-only tools, refuse model-chosen MCP destinations and fail unusable reports) and the profile field `pluginScanners`. The `clawhub` profile now runs only `aig-mcp` for OpenClaw plugins, over a bounded copy without `node_modules`; skills keep `skillspector` and `aig`. Consumers that read `scanners.skillspector` or `scanners.aig` for plugin runs must read `scanners["aig-mcp"]` instead. Host runs need `AIG_MCP_SCAN_ALLOW_HOST_EXEC=1` ([#149](https://github.com/openclaw/clawscan/pull/149)).

‎cmd/clawscan/benchmark_lifecycle_test.go‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
"runtime"
1414
"strings"
1515
"testing"
16-
"time"
1716

1817
"github.com/openclaw/clawscan/internal/runner"
18+
"github.com/openclaw/clawscan/internal/testutil"
1919
)
2020

2121
type inertBenchmarkTransport func(*http.Request) (*http.Response, error)
@@ -69,17 +69,16 @@ func TestBenchmarkCLIEmitsCanceledPriorCaseEvidence(t *testing.T) {
6969
t.Setenv("XDG_CACHE_HOME", root)
7070
installGeneratedBenchmarkHTTP(t)
7171
config := filepath.Join(root, "config.yml")
72-
content := "version: 1\nprofiles:\n inert:\n sandbox:\n mode: off\n scanners:\n - id: generated\n targets: [skill]\n command: >-\n if grep -q second {{target}}/SKILL.md; then printf '{\"verdict\":\"clean\"}'; exec sleep 2; fi; printf '{\"verdict\":\"clean\"}'\n"
72+
content := "version: 1\nprofiles:\n inert:\n sandbox:\n mode: off\n scanners:\n - id: generated\n targets: [skill]\n env: [READY_FILE]\n command: >-\n if grep -q second {{target}}/SKILL.md; then printf '{\"verdict\":\"clean\"}'; : > \"$READY_FILE\"; exec sleep 20; fi; printf '{\"verdict\":\"clean\"}'\n"
7373
writeFile(t, config, content)
7474
output := filepath.Join(root, "result.json")
75-
caller, cancel := context.WithTimeout(context.Background(), 150*time.Millisecond)
76-
defer cancel()
75+
caller, ready := testutil.CancelOnReady(t)
7776
var runErr error
7877
stdout := captureStdout(t, func() {
79-
runErr = runContext(caller, []string{"benchmark", dataset, "--config", config, "--profile", "inert", "--json", "--output", output}, []string{"PATH=" + os.Getenv("PATH")})
78+
runErr = runContext(caller, []string{"benchmark", dataset, "--config", config, "--profile", "inert", "--json", "--output", output}, []string{"PATH=" + os.Getenv("PATH"), "READY_FILE=" + ready})
8079
})
81-
if !errors.Is(runErr, context.DeadlineExceeded) {
82-
t.Fatalf("CLI lost operational deadline: %v", runErr)
80+
if !errors.Is(runErr, context.Canceled) {
81+
t.Fatalf("CLI lost caller cancellation: %v", runErr)
8382
}
8483
var artifact runner.BenchmarkArtifact
8584
if err := json.Unmarshal([]byte(stdout), &artifact); err != nil || len(artifact.Cases) != 3 {

‎cmd/clawscan/capture_output_test.go‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import (
77
"testing"
88
)
99

10-
func TestCaptureStdoutDrainsLargeWrites(t *testing.T) {
10+
func TestCaptureOutputDrainsLargeWrites(t *testing.T) {
1111
payload := strings.Repeat("large fixture output\n", 16*1024)
12-
got := captureStdout(t, func() {
12+
errPayload := strings.Repeat("large diagnostic\n", 16*1024)
13+
stdout, stderr := captureOutput(t, func() {
1314
if _, err := io.WriteString(os.Stdout, payload); err != nil {
1415
t.Fatal(err)
1516
}
17+
if _, err := io.WriteString(os.Stderr, errPayload); err != nil {
18+
t.Fatal(err)
19+
}
1620
})
17-
if got != payload {
18-
t.Fatalf("captured %d bytes, want %d", len(got), len(payload))
21+
if stdout != payload || stderr != errPayload {
22+
t.Fatalf("captured %d stdout and %d stderr bytes, want %d and %d", len(stdout), len(stderr), len(payload), len(errPayload))
1923
}
2024
}

‎cmd/clawscan/main_test.go‎

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,15 +1503,29 @@ func writeFile(t *testing.T, path string, content string) {
15031503

15041504
func captureStdout(t *testing.T, fn func()) string {
15051505
t.Helper()
1506+
return captureStream(t, &os.Stdout, fn)
1507+
}
1508+
1509+
func captureOutput(t *testing.T, fn func()) (string, string) {
1510+
t.Helper()
1511+
var stderr string
1512+
stdout := captureStdout(t, func() {
1513+
stderr = captureStream(t, &os.Stderr, fn)
1514+
})
1515+
return stdout, stderr
1516+
}
15061517

1507-
original := os.Stdout
1518+
func captureStream(t *testing.T, stream **os.File, fn func()) string {
1519+
t.Helper()
1520+
1521+
original := *stream
15081522
read, write, err := os.Pipe()
15091523
if err != nil {
15101524
t.Fatal(err)
15111525
}
1512-
os.Stdout = write
1526+
*stream = write
15131527
defer func() {
1514-
os.Stdout = original
1528+
*stream = original
15151529
_ = write.Close()
15161530
_ = read.Close()
15171531
}()
@@ -1536,50 +1550,3 @@ func captureStdout(t *testing.T, fn func()) string {
15361550
}
15371551
return string(result.out)
15381552
}
1539-
1540-
func captureOutput(t *testing.T, fn func()) (string, string) {
1541-
t.Helper()
1542-
1543-
originalStdout := os.Stdout
1544-
originalStderr := os.Stderr
1545-
stdoutRead, stdoutWrite, err := os.Pipe()
1546-
if err != nil {
1547-
t.Fatal(err)
1548-
}
1549-
stderrRead, stderrWrite, err := os.Pipe()
1550-
if err != nil {
1551-
t.Fatal(err)
1552-
}
1553-
os.Stdout = stdoutWrite
1554-
os.Stderr = stderrWrite
1555-
t.Cleanup(func() {
1556-
os.Stdout = originalStdout
1557-
os.Stderr = originalStderr
1558-
})
1559-
1560-
fn()
1561-
1562-
if err := stdoutWrite.Close(); err != nil {
1563-
t.Fatal(err)
1564-
}
1565-
if err := stderrWrite.Close(); err != nil {
1566-
t.Fatal(err)
1567-
}
1568-
stdout, err := io.ReadAll(stdoutRead)
1569-
if err != nil {
1570-
t.Fatal(err)
1571-
}
1572-
stderr, err := io.ReadAll(stderrRead)
1573-
if err != nil {
1574-
t.Fatal(err)
1575-
}
1576-
if err := stdoutRead.Close(); err != nil {
1577-
t.Fatal(err)
1578-
}
1579-
if err := stderrRead.Close(); err != nil {
1580-
t.Fatal(err)
1581-
}
1582-
os.Stdout = originalStdout
1583-
os.Stderr = originalStderr
1584-
return string(stdout), string(stderr)
1585-
}

‎internal/profiles/resolver.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ func (profile Profile) ScannerIDs() []string {
5252
}
5353

5454
type ProfileScanner struct {
55-
ID string
56-
Command string
57-
Env []string
58-
SecretEnv []string
59-
Targets []string
60-
Gate *ProfileScannerGate
55+
ID string `yaml:"id"`
56+
Command string `yaml:"command,omitempty"`
57+
Env []string `yaml:"env,omitempty"`
58+
SecretEnv []string `yaml:"secretEnv,omitempty"`
59+
Targets []string `yaml:"targets,omitempty"`
60+
Gate *ProfileScannerGate `yaml:"gate,omitempty"`
6161
custom bool
6262
mapping bool
6363
}

‎internal/profiles/yaml.go‎

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ func (gate *ProfileScannerGate) UnmarshalYAML(node *yaml.Node) error {
310310
return nil
311311
}
312312

313+
type scannerYAML ProfileScanner
314+
313315
func (scanner *ProfileScanner) UnmarshalYAML(node *yaml.Node) error {
314316
switch node.Kind {
315317
case yaml.ScalarNode:
@@ -334,24 +336,11 @@ func (scanner *ProfileScanner) UnmarshalYAML(node *yaml.Node) error {
334336
return fmt.Errorf("field %s not found in type profiles.ProfileScanner", node.Content[index].Value)
335337
}
336338
}
337-
var value struct {
338-
ID string `yaml:"id"`
339-
Command string `yaml:"command"`
340-
Env []string `yaml:"env,omitempty"`
341-
SecretEnv []string `yaml:"secretEnv,omitempty"`
342-
Targets []string `yaml:"targets,omitempty"`
343-
Gate *ProfileScannerGate `yaml:"gate,omitempty"`
344-
}
339+
value := scannerYAML{custom: scanner.custom, mapping: true}
345340
if err := node.Decode(&value); err != nil {
346341
return err
347342
}
348-
scanner.ID = value.ID
349-
scanner.Command = value.Command
350-
scanner.Env = value.Env
351-
scanner.SecretEnv = value.SecretEnv
352-
scanner.Targets = value.Targets
353-
scanner.Gate = value.Gate
354-
scanner.mapping = true
343+
*scanner = ProfileScanner(value)
355344
return nil
356345
default:
357346
return fmt.Errorf("scanner entry must be a string or object")
@@ -362,16 +351,11 @@ func (scanner ProfileScanner) MarshalYAML() (interface{}, error) {
362351
if !scanner.mapping && !scanner.custom {
363352
return scanner.ID, nil
364353
}
365-
return struct {
366-
ID string `yaml:"id"`
367-
Command string `yaml:"command,omitempty"`
368-
Env []string `yaml:"env,omitempty"`
369-
SecretEnv []string `yaml:"secretEnv,omitempty"`
370-
Targets []string `yaml:"targets,omitempty"`
371-
Gate *ProfileScannerGate `yaml:"gate,omitempty"`
372-
}{scanner.ID, scanner.Command, scanner.Env, scanner.SecretEnv, scanner.Targets, scanner.Gate}, nil
354+
return scannerYAML(scanner), nil
373355
}
374356

357+
type mountYAML SandboxMount
358+
375359
func (m *SandboxMount) UnmarshalYAML(node *yaml.Node) error {
376360
switch node.Kind {
377361
case yaml.ScalarNode:
@@ -384,14 +368,11 @@ func (m *SandboxMount) UnmarshalYAML(node *yaml.Node) error {
384368
return fmt.Errorf("field %s not found in type profiles.SandboxMount", node.Content[index].Value)
385369
}
386370
}
387-
var value struct {
388-
Path string `yaml:"path"`
389-
Write bool `yaml:"write"`
390-
}
371+
var value mountYAML
391372
if err := node.Decode(&value); err != nil {
392373
return err
393374
}
394-
m.Path, m.Write = value.Path, value.Write
375+
*m = SandboxMount(value)
395376
return nil
396377
default:
397378
return fmt.Errorf("sandbox mount must be a string or object")
@@ -402,10 +383,7 @@ func (m SandboxMount) MarshalYAML() (interface{}, error) {
402383
if !m.Write {
403384
return m.Path, nil
404385
}
405-
return struct {
406-
Path string `yaml:"path"`
407-
Write bool `yaml:"write"`
408-
}{Path: m.Path, Write: m.Write}, nil
386+
return mountYAML(m), nil
409387
}
410388

411389
func resolvedYAMLNode(node *yaml.Node) *yaml.Node {

0 commit comments

Comments
 (0)