Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ var topLevelMetadata = []string{
"timestamp.json",
}

var snapshotMetadata = []string{
"root.json",
"targets.json",
}

// TargetsWalkFunc is a function of a target path name and a target payload used to
// execute some function on each staged target file. For example, it may normalize path
// names and generate target file metadata with additional custom metadata.
Expand Down Expand Up @@ -830,6 +825,12 @@ func (r *Repo) Snapshot() error {
return r.SnapshotWithExpires(data.DefaultExpires("snapshot"))
}

func (r *Repo) snapshotManifests() []string {
Comment thread
ethan-lowman-dd marked this conversation as resolved.
Outdated
// Note: root pinning is not supported in Spec 1.0.19.
Comment thread
ethan-lowman-dd marked this conversation as resolved.
Outdated
Comment thread
ethan-lowman-dd marked this conversation as resolved.
Outdated
// root.json might need to be removed.
Comment thread
ethan-lowman-dd marked this conversation as resolved.
Outdated
return []string{"root.json", "targets.json"}
}

func (r *Repo) SnapshotWithExpires(expires time.Time) error {
if !validExpires(expires) {
return ErrInvalidExpires{expires}
Expand All @@ -844,12 +845,12 @@ func (r *Repo) SnapshotWithExpires(expires time.Time) error {
return err
}

for _, name := range snapshotMetadata {
if err := r.verifySignature(name, db); err != nil {
for _, manifestName := range r.snapshotManifests() {
if err := r.verifySignature(manifestName, db); err != nil {
return err
}
var err error
snapshot.Meta[name], err = r.snapshotFileMeta(name)
snapshot.Meta[manifestName], err = r.snapshotFileMeta(manifestName)
if err != nil {
return err
}
Expand Down Expand Up @@ -974,7 +975,7 @@ func (r *Repo) Commit() error {
if err != nil {
return err
}
for _, name := range snapshotMetadata {
for _, name := range r.snapshotManifests() {
expected, ok := snapshot.Meta[name]
if !ok {
return fmt.Errorf("tuf: snapshot.json missing hash for %s", name)
Expand Down