Skip to content

Commit

Permalink
Ensure build env is sorted on input to config hash (#3279)
Browse files Browse the repository at this point in the history
* Ensure build env is sorted on input to config hash

* delimit
  • Loading branch information
peterebden authored Oct 18, 2024
1 parent 2819f51 commit 653b203
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"fmt"
"io"
iofs "io/fs"
"maps"
"os"
"path/filepath"
"reflect"
"runtime"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -755,9 +757,12 @@ func (config *Configuration) Hash() []byte {
for _, l := range config.Licences.Reject {
h.Write([]byte(l))
}
for _, env := range config.getBuildEnv(false, false) {
if !strings.HasPrefix(env, "SECRET") {
h.Write([]byte(env))
env := config.getBuildEnv(false, false)
for _, k := range slices.Sorted(maps.Keys(env)) {
if !strings.HasPrefix(k, "SECRET") {
h.Write([]byte(k))
h.Write([]byte{'='})
h.Write([]byte(env[k]))
}
}
return h.Sum(nil)
Expand Down

0 comments on commit 653b203

Please sign in to comment.