Skip to content

Commit

Permalink
Unset env vars which might have secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
cudevmaxwell committed Aug 7, 2024
1 parent 00b0403 commit 600d1b1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ func main() {
log.Fatalln(err)
}

// Unset the environment variables which contain secrets.
log.Println("Checking the environment for variables which might contain secrets, and unsetting them.")
flag.VisitAll(func(f *flag.Flag) {
if strings.Contains(f.Name, "pass") || strings.Contains(f.Name, "key") {
key := fmt.Sprintf("%v%v", EnvPrefix, strings.ToUpper(f.Name))
_, set := os.LookupEnv(key)
if set {
_ = os.Unsetenv(key)
log.Printf("The environment variable %v has been unset.\n", key)
}
}
})

// Exit if any required flags are not set.
if *domain == "" {
log.Fatal("FATAL: An Alma API Server domain is required. https://developers.exlibrisgroup.com/alma/apis/#calling")
Expand Down

0 comments on commit 600d1b1

Please sign in to comment.