set 'ZROK_DANGEROUS_CANARY' guard (#947)

This commit is contained in:
Michael Quigley 2025-04-21 17:04:55 -04:00
parent aff3f5cc40
commit 825e5da3d6
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 17 additions and 0 deletions

13
canary/dangerous.go Normal file
View File

@ -0,0 +1,13 @@
package canary
import (
"fmt"
"os"
)
func AcknowledgeDangerousCanary() error {
if _, ok := os.LookupEnv("ZROK_DANGEROUS_CANARY"); !ok {
return fmt.Errorf("this is a dangerous canary; see canary docs for details on enabling")
}
return nil
}

View File

@ -45,6 +45,10 @@ func newTestCanaryEnabler() *testCanaryEnabler {
} }
func (cmd *testCanaryEnabler) run(_ *cobra.Command, _ []string) { func (cmd *testCanaryEnabler) run(_ *cobra.Command, _ []string) {
if err := canary.AcknowledgeDangerousCanary(); err != nil {
logrus.Fatal(err)
}
root, err := environment.LoadRoot() root, err := environment.LoadRoot()
if err != nil { if err != nil {
panic(err) panic(err)