mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
* redis2: let Redis hash the Lua scripts (no SHA-1 at package init) redis.NewScript computes the script's SHA-1 in Go when the package-level vars are initialized. redis2 is linked into every weed binary, so under GODEBUG=fips140=only every subcommand, including `weed version`, panics before main. NewScriptServerSHA leaves the digest to Redis (SCRIPT LOAD on first use) and keeps Run's EVALSHA-then-EVAL behaviour. weed/fips140_only_test.go runs the weed main package's test binary with fips140=only, so any package init that uses an unapproved algorithm fails `go test ./weed/...`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * redis2: run the Lua scripts by a pinned digest (no SCRIPT LOAD, no lock) NewScriptServerSHA gets the digest with SCRIPT LOAD inside ensureHash, which holds the Script's write lock across the round trip and does not remember a failed load. Where an ACL denies SCRIPT but allows EVAL, every call retried SCRIPT LOAD under that lock before falling back to EVAL. The two scripts are now constants next to their SHA-1 digests, and runScript sends EVALSHA and falls back to EVAL on NOSCRIPT, the same commands Script.Run sent on master. No SHA-1 is computed in Go, at init or at run time. TestScriptDigests checks each pinned digest against its source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * redis2: hash the script digests in the test without FIPS enforcement TestScriptDigests panicked under GODEBUG=fips140=only, the mode this change is for, because sha1.Sum is not approved there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
19 lines
510 B
Go
19 lines
510 B
Go
//go:debug fips140=only
|
|
|
|
package main
|
|
|
|
import (
|
|
"crypto/fips140"
|
|
"testing"
|
|
)
|
|
|
|
// TestInitUnderFIPS140Only runs with GODEBUG=fips140=only and links every
|
|
// package the weed binary imports, so package initialization that uses an
|
|
// algorithm FIPS 140-3 does not approve (such as SHA-1) panics before this
|
|
// test runs and fails the package.
|
|
func TestInitUnderFIPS140Only(t *testing.T) {
|
|
if !fips140.Enforced() {
|
|
t.Fatal("fips140=only is not in effect; the //go:debug directive above was not applied")
|
|
}
|
|
}
|