test: reject the config.example.yml placeholder signing_key
The placeholder is 45 characters, so it passes the length check and a deployment could unknowingly sign URLs with a key that is public in this repository. Add a failing validation case (and the placeholder constant it references); the rejection follows. Model: opus-4-8
This commit is contained in:
@@ -44,6 +44,12 @@ const (
|
|||||||
keyCacheMaxBytes = "cache_max_bytes"
|
keyCacheMaxBytes = "cache_max_bytes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// placeholderSigningKey is the dummy signing_key shipped in
|
||||||
|
// config.example.yml. It is 45 characters, so it passes the length
|
||||||
|
// check, but it is public in this repository and must be rejected at
|
||||||
|
// startup so no deployment ever signs URLs with it.
|
||||||
|
const placeholderSigningKey = "CHANGE_ME_generate_with_openssl_rand_base64_32"
|
||||||
|
|
||||||
// Static validation errors. Each use site attaches the offending key
|
// Static validation errors. Each use site attaches the offending key
|
||||||
// and value by wrapping these with fmt.Errorf and %w.
|
// and value by wrapping these with fmt.Errorf and %w.
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -303,6 +303,11 @@ func invalidHostAndCredentialCases() []abortCase {
|
|||||||
yaml: "signing_key: short\n",
|
yaml: "signing_key: short\n",
|
||||||
wantErrSubstrings: []string{keySigningKey},
|
wantErrSubstrings: []string{keySigningKey},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "signing_key is the documented placeholder",
|
||||||
|
yaml: "signing_key: " + placeholderSigningKey + "\n",
|
||||||
|
wantErrSubstrings: []string{keySigningKey},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "signing_key missing",
|
name: "signing_key missing",
|
||||||
yaml: "port: 8080\n",
|
yaml: "port: 8080\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user