Skip to content

Commit

Permalink
update-fingerprints: sort OutputFingerprint (#47)
Browse files Browse the repository at this point in the history
maps are automatically sorted by the json package, but none of the slices were sorted, so this does that explicitly, which should make the git diff of fingerprints_data.json useful

the sorted fingerprints_data.json is not included in this commit to prevent merge conflicts after automated updates happen. After merging, the next weekly update will do the initial sort
  • Loading branch information
derekperkins authored Jun 7, 2023
1 parent 2c1f5b8 commit 3357b07
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/update-fingerprints/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"os"
"reflect"
"sort"
"strings"
)

Expand Down Expand Up @@ -157,6 +158,8 @@ func normalizeFingerprints(fingerprints *Fingerprints) *OutputFingerprints {
for js := range fingerprint.JS {
output.JS = append(output.JS, strings.ToLower(js))
}
sort.Strings(output.JS)

for header, pattern := range fingerprint.Headers {
output.Headers[strings.ToLower(header)] = strings.ToLower(pattern)
}
Expand All @@ -177,6 +180,8 @@ func normalizeFingerprints(fingerprints *Fingerprints) *OutputFingerprints {
output.HTML = append(output.HTML, strings.ToLower(pat))
}
}

sort.Strings(output.HTML)
}

// Use reflection type switch for determining Script tag type
Expand All @@ -194,6 +199,8 @@ func normalizeFingerprints(fingerprints *Fingerprints) *OutputFingerprints {
output.Script = append(output.Script, strings.ToLower(pat))
}
}

sort.Strings(output.Script)
}

for header, pattern := range fingerprint.Meta {
Expand All @@ -215,6 +222,7 @@ func normalizeFingerprints(fingerprints *Fingerprints) *OutputFingerprints {
pat := pattern.(string)
final = append(final, strings.ToLower(pat))
}
sort.Strings(final)
output.Meta[strings.ToLower(header)] = final
}
}
Expand All @@ -234,6 +242,8 @@ func normalizeFingerprints(fingerprints *Fingerprints) *OutputFingerprints {
output.Implies = append(output.Implies, pat)
}
}

sort.Strings(output.Implies)
}

// Use reflection type switch for determining CSS tag type
Expand All @@ -251,7 +261,10 @@ func normalizeFingerprints(fingerprints *Fingerprints) *OutputFingerprints {
output.CSS = append(output.CSS, pat)
}
}

sort.Strings(output.CSS)
}

// Only add if the fingerprint is valid
outputFingerprints.Apps[app] = output
}
Expand Down

0 comments on commit 3357b07

Please sign in to comment.