Skip to content

Commit

Permalink
Fix Windows embedded file path bug (#103)
Browse files Browse the repository at this point in the history
* hardcode embed file system path separator

Signed-off-by: Meredith Lancaster <[email protected]>

* add temporary panic

Signed-off-by: Meredith Lancaster <[email protected]>

* remove panic

Signed-off-by: Meredith Lancaster <[email protected]>

* use platform matrix to test on Windows

Signed-off-by: Meredith Lancaster <[email protected]>

* Updated to latest go tuf

Signed-off-by: Fredrik Skogman <[email protected]>

* Added debug prints for windows testing

Signed-off-by: Fredrik Skogman <[email protected]>

* Make sure the timestamp expired in the past to make tests more reliable
on other platforms such as windows

Signed-off-by: Fredrik Skogman <[email protected]>

* add mac os matrix job

Signed-off-by: Meredith Lancaster <[email protected]>

---------

Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Fredrik Skogman <[email protected]>
Co-authored-by: Fredrik Skogman <[email protected]>
  • Loading branch information
malancas and kommendorkapten authored Feb 22, 2024
1 parent 4e750e1 commit d0d98c7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ permissions:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- os: macos-latest
- os: ubuntu-latest
- os: windows-latest
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/sigstore/sigstore v1.8.1
github.com/sigstore/timestamp-authority v1.2.1
github.com/stretchr/testify v1.8.4
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240207172116-f5cf71290141
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240222081530-454b12158917
golang.org/x/crypto v0.19.0
golang.org/x/mod v0.15.0
google.golang.org/protobuf v1.32.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/theupdateframework/go-tuf v0.7.0 h1:CqbQFrWo1ae3/I0UCblSbczevCCbS31Qvs5LdxRWqRI=
github.com/theupdateframework/go-tuf v0.7.0/go.mod h1:uEB7WSY+7ZIugK6R1hiBMBjQftaFzn7ZCDJcp1tCUug=
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240207172116-f5cf71290141 h1:SsiWxSpJ9AD71/vqiZVUjXW1Uusv1wlKn4zPKFNq25w=
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240207172116-f5cf71290141/go.mod h1:D7dcS4bZMmF3pXOgUo8Vs6GLYM9sdrFFd37JqiP3hN4=
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240222081530-454b12158917 h1:Ov8+IAeR7pivNDC0Cd25MyyaCR3WPlGBED4wNxIFQ8s=
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240222081530-454b12158917/go.mod h1:+gWwqe1pk4nvGeOKosGJqPgD+N/kbD9M0QVLL9TGIYU=
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0=
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399/go.mod h1:LdwHTNJT99C5fTAzDz0ud328OgXz+gierycbcIx2fRs=
github.com/transparency-dev/merkle v0.0.2 h1:Q9nBoQcZcgPamMkGn7ghV8XiTZ/kRxn1yCG81+twTK4=
Expand Down
2 changes: 1 addition & 1 deletion pkg/tuf/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestExpiredTimestamp(t *testing.T) {
// Using ForceCache, so we should get the old version
assert.Equal(t, target, []byte("foo version 1"))

r.SetTimestamp(time.Now())
r.SetTimestamp(time.Now().Add(-1 * time.Second))

// Manually write timestamp to disk, as Refresh() will fail
err = r.roles.Timestamp().ToFile(filepath.Join(opt.CachePath, "testing.local", "timestamp.json"), false)
Expand Down
4 changes: 3 additions & 1 deletion pkg/tuf/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ func DefaultOptions() *Options {

// DefaultRoot returns the root.json for the public good instance
func DefaultRoot() []byte {
var p = filepath.Join("repository", "root.json")
// The embed file system always uses forward slashes as path separators,
// even on Windows
p := "repository/root.json"

b, err := embeddedRepo.ReadFile(p)
if err != nil {
Expand Down

0 comments on commit d0d98c7

Please sign in to comment.