diff --git a/.golangci-comprehensive.yml b/.golangci-comprehensive.yml index 8532b9cdf..eaffe4423 100644 --- a/.golangci-comprehensive.yml +++ b/.golangci-comprehensive.yml @@ -306,6 +306,13 @@ linters: linters: - gosec text: "G404|G301|G302" + # gosec G404 (math/rand) in the ipfeed fixture generator: the random24 + # shape must be reproducible from -seed; test data, not secrets. + # nix/checks/go-sec.nix carries the same scoped rule. + - path: "tools/ipfeed-fixture/main\\.go" + linters: + - gosec + text: "G404" # G705 (XSS taint) in goiphttp's response writer: the `ip` command-line # paths answer with `ip`'s own bytes, which can quote a path token back # (`Device "x" does not exist`), and escaping them would break diff --git a/.golangci.yml b/.golangci.yml index 4c167a360..6609a55cd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -300,6 +300,13 @@ linters: linters: - gosec text: "G404" + # gosec G404 (math/rand) in the ipfeed fixture generator: the random24 + # shape must be reproducible from -seed; test data, not secrets. + # nix/checks/go-sec.nix carries the same scoped rule. + - path: "tools/ipfeed-fixture/main\\.go" + linters: + - gosec + text: "G404" # G705 (XSS taint) in goiphttp's response writer: the `ip` command-line # paths answer with `ip`'s own bytes, which can quote a path token back # (`Device "x" does not exist`), and escaping them would break diff --git a/nix/checks/default.nix b/nix/checks/default.nix index 4a1c68a2d..f408789db 100644 --- a/nix/checks/default.nix +++ b/nix/checks/default.nix @@ -77,7 +77,7 @@ in ernic-run-many = import ./ernic-run-many.nix { inherit pkgs lib; }; # nix/ernic/oracle.nix: the emulator's fault counts against the guest's # NIC counters, on fixture logs. - ernic-oracle = import ./ernic-oracle.nix { inherit pkgs lib; }; + ernic-oracle = import ./ernic-oracle.nix { inherit pkgs; }; # The self-test's stream_until (nix/microvms/self-test-stream-until.nix), # driven against sh stand-ins for a streaming xtcp2client. self-test-stream-until = import ./self-test-stream-until.nix { inherit pkgs; }; diff --git a/nix/checks/ernic-oracle.nix b/nix/checks/ernic-oracle.nix index df99f8711..b32324990 100644 --- a/nix/checks/ernic-oracle.nix +++ b/nix/checks/ernic-oracle.nix @@ -6,10 +6,10 @@ # row builds a console log and server logs, runs the oracle, and prints # ROW PASS|FAIL : # and any FAIL fails the check. -{ pkgs, lib }: +{ pkgs }: let - oracle = import ../ernic/oracle.nix { inherit pkgs lib; }; + oracle = import ../ernic/oracle.nix { inherit pkgs; }; in pkgs.runCommand "xtcp2-ernic-oracle" { diff --git a/nix/checks/go-sec.nix b/nix/checks/go-sec.nix index 5a4b32b4e..bb59181ea 100644 --- a/nix/checks/go-sec.nix +++ b/nix/checks/go-sec.nix @@ -21,6 +21,10 @@ # X-Content-Type-Options: nosniff (TestHandler checks every row). # .golangci.yml and .golangci-comprehensive.yml carry the same # scoped rule. +# G404 in tools/ipfeed-fixture/main.go — math/rand: the fixture generator's +# random24 shape must be reproducible from its -seed; the numbers +# are test data, not secrets or nonces. The golangci configs carry +# the same scoped rule, as does nix/quality-report/default.nix. # # NOT excluded — these would block the build if found: # G104 (unhandled errors), G112 (HTTP timeouts), G401 (weak crypto), etc. @@ -48,7 +52,7 @@ pkgs.runCommand "xtcp2-gosec" export CGO_ENABLED=0 export GOFLAGS=-mod=vendor gosec -exclude=G103,G115,G204,G304 \ - -exclude-rules='internal/goip/goiphttp/handler\.go:G705' \ + -exclude-rules='internal/goip/goiphttp/handler\.go:G705;tools/ipfeed-fixture/main\.go:G404' \ -fmt=text ./... > $out 2>&1 || { rc=$? cat $out diff --git a/nix/ernic/default.nix b/nix/ernic/default.nix index 5ecfb0a42..d1e3e9ef9 100644 --- a/nix/ernic/default.nix +++ b/nix/ernic/default.nix @@ -30,7 +30,7 @@ in profiles = "${rocmErnic}/profiles"; ownProfiles = ./profiles; nics = import ./nics.nix { inherit lib; }; - oracle = import ./oracle.nix { inherit pkgs lib; }; + oracle = import ./oracle.nix { inherit pkgs; }; runMany = import ./run-many.nix { inherit pkgs lib; server = packages.rocm-ernic; diff --git a/nix/ernic/oracle.nix b/nix/ernic/oracle.nix index e1a2b40d9..2503f5f66 100644 --- a/nix/ernic/oracle.nix +++ b/nix/ernic/oracle.nix @@ -24,7 +24,7 @@ # A site that saw no frames fails: a vacuous match proves nothing. # Prints ROW lines like the guest's checks; exits 1 if any fails. # Counts are compared with bc, so any u64 is exact. -{ pkgs, lib }: +{ pkgs }: pkgs.writeShellApplication { name = "ernic-oracle"; diff --git a/nix/ernic/run-many.nix b/nix/ernic/run-many.nix index 84f1125fa..325b699b9 100644 --- a/nix/ernic/run-many.nix +++ b/nix/ernic/run-many.nix @@ -74,7 +74,7 @@ let ''} ${lib.concatStrings ( lib.mapAttrsToList ( - br: brTaps: + br: _brTaps: let f = fabric.${br} or { }; in diff --git a/nix/quality-report/default.nix b/nix/quality-report/default.nix index c71719de9..79a99fa0a 100644 --- a/nix/quality-report/default.nix +++ b/nix/quality-report/default.nix @@ -158,7 +158,7 @@ pkgs.runCommand "xtcp2-quality-report" # `nix flake check` was green), and nothing mechanically enforces it. runtool gosec "$RAW/gosec.json" -- \ gosec -exclude=G103,G115,G204,G304,G702 \ - -exclude-rules='internal/goip/goiphttp/handler\.go:G705' \ + -exclude-rules='internal/goip/goiphttp/handler\.go:G705;tools/ipfeed-fixture/main\.go:G404' \ -fmt=json ./... # ── nix-fmt ──────────────────────────────────────────────────────── diff --git a/tools/ipfeed-fixture/main.go b/tools/ipfeed-fixture/main.go index 4554255cb..e86fdd3e6 100644 --- a/tools/ipfeed-fixture/main.go +++ b/tools/ipfeed-fixture/main.go @@ -113,8 +113,9 @@ func writeRows(out string, n int, shape string, asn uint32, owner string, invali return fmt.Errorf("-prefix %q: %w", prefix, perr) } rows := make([]rowSchema, 0, n) - //nolint:gosec // G404: deterministic-by-design — a fixture artifact must - // be reproducible from its seed; this is not a secret or a nonce. + // math/rand by design: a fixture artifact must be reproducible from its + // seed; this is not a secret or a nonce (gosec G404 is path-scoped off + // for this file in nix/checks/go-sec.nix and the golangci configs). rng := rand.New(rand.NewSource(seed)) for i := 0; i < n; i++ { if invalidEvery > 0 && i%invalidEvery == invalidEvery-1 {