Skip to content

Commit

Permalink
Add arch to kolide_tuf_release_version table too
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed May 12, 2023
1 parent 1e2731e commit 3443ed0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions pkg/osquery/tables/tufinfo/release_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"
"strings"

Expand All @@ -21,6 +22,7 @@ func TufReleaseVersionTable(flags types.Flags) *table.Plugin {
columns := []table.ColumnDefinition{
table.TextColumn("binary"),
table.TextColumn("operating_system"),
table.TextColumn("architecture"),
table.TextColumn("channel"),
table.TextColumn("target"),
}
Expand Down Expand Up @@ -57,7 +59,7 @@ func generateTufReleaseVersionTable(flags types.Flags) table.GenerateFunc {
}

parts := strings.Split(targetFileName, "/")
if len(parts) != 4 {
if len(parts) != 5 {
// Shouldn't happen given the check above, but just in case
continue
}
Expand All @@ -70,7 +72,8 @@ func generateTufReleaseVersionTable(flags types.Flags) table.GenerateFunc {
results = append(results, map[string]string{
"binary": binary,
"operating_system": parts[1],
"channel": parts[2],
"architecture": parts[2],
"channel": parts[3],
"target": metadata.Target,
})
}
Expand All @@ -83,9 +86,15 @@ func generateTufReleaseVersionTable(flags types.Flags) table.GenerateFunc {
func expectedReleaseTargets(binary string) map[string]bool {
targets := make(map[string]bool, 0)
for _, operatingSystem := range []string{"darwin", "windows", "linux"} {
for _, channel := range []string{"stable", "beta", "nightly"} {
targets[fmt.Sprintf("%s/%s/%s/release.json", binary, operatingSystem, channel)] = true
for _, arch := range []string{"universal", "arm64", "amd64"} {
if operatingSystem != "darwin" && arch == "universal" {
continue
}
for _, channel := range []string{"stable", "beta", "alpha", "nightly"} {
targets[path.Join(binary, operatingSystem, arch, channel, "release.json")] = true
}
}

}

return targets
Expand Down
4 changes: 2 additions & 2 deletions pkg/osquery/tables/tufinfo/release_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func TestTufReleaseVersionTable(t *testing.T) {

testRootDir := t.TempDir()
v := randomSemver()
expectedResults["launcher"] = fmt.Sprintf("launcher/%s/launcher-%s.tar.gz", runtime.GOOS, v)
expectedResults["osqueryd"] = fmt.Sprintf("osqueryd/%s/osqueryd-%s.tar.gz", runtime.GOOS, v)
expectedResults["launcher"] = fmt.Sprintf("launcher/%s/%s/launcher-%s.tar.gz", runtime.GOOS, runtime.GOARCH, v)
expectedResults["osqueryd"] = fmt.Sprintf("osqueryd/%s/%s/osqueryd-%s.tar.gz", runtime.GOOS, runtime.GOARCH, v)
tufci.SeedLocalTufRepo(t, v, testRootDir)

mockFlags := mocks.NewFlags(t)
Expand Down

0 comments on commit 3443ed0

Please sign in to comment.