Skip to content

Commit

Permalink
Fix nondeterminsitic timestamps (#3121)
Browse files Browse the repository at this point in the history
We should not (by default) be making the artifacts we produce
nondeterministic.

Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
  • Loading branch information
jonjohnsonjr authored Jul 24, 2023
1 parent 1e2c91f commit 59a835c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 27 deletions.
12 changes: 0 additions & 12 deletions pkg/oci/mutate/signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/sigstore/cosign/v2/internal/pkg/now"
"github.com/sigstore/cosign/v2/pkg/oci"
)

Expand All @@ -43,17 +42,6 @@ func AppendSignatures(base oci.Signatures, sigs ...oci.Signature) (oci.Signature
return nil, err
}

t, err := now.Now()
if err != nil {
return nil, err
}

// Set the Created date to time of execution
img, err = mutate.CreatedAt(img, v1.Time{Time: t})
if err != nil {
return nil, err
}

return &sigAppender{
Image: img,
base: base,
Expand Down
4 changes: 2 additions & 2 deletions pkg/oci/mutate/signatures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestAppendSignatures(t *testing.T) {

if testCfg, err := threeSig.ConfigFile(); err != nil {
t.Fatalf("ConfigFile() = %v", err)
} else if testCfg.Created.Time.IsZero() {
t.Errorf("Date of Signature was Zero")
} else if !testCfg.Created.Time.IsZero() {
t.Errorf("Date of Signature was not Zero")
}
}
11 changes: 0 additions & 11 deletions pkg/oci/static/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/types"
"github.com/sigstore/cosign/v2/internal/pkg/now"
"github.com/sigstore/cosign/v2/pkg/oci"
"github.com/sigstore/cosign/v2/pkg/oci/signed"
)
Expand All @@ -49,16 +48,6 @@ func NewFile(payload []byte, opts ...Option) (oci.File, error) {
// Add annotations from options
img = mutate.Annotations(img, o.Annotations).(v1.Image)

t, err := now.Now()
if err != nil {
return nil, err
}

// Set the Created date to time of execution
img, err = mutate.CreatedAt(img, v1.Time{Time: t})
if err != nil {
return nil, err
}
return &file{
SignedImage: signed.Image(img),
layer: layer,
Expand Down
4 changes: 2 additions & 2 deletions pkg/oci/static/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func TestNewFile(t *testing.T) {
if err != nil {
t.Fatalf("ConfigFile() = %v", err)
}
if fileCfg.Created.Time.IsZero() {
t.Errorf("Date of Signature was Zero")
if !fileCfg.Created.Time.IsZero() {
t.Errorf("Date of Signature was not Zero")
}
})

Expand Down

0 comments on commit 59a835c

Please sign in to comment.