Skip to content

Commit a075f96

Browse files
authored
Remove the --compression option when creating snapshots, ref. TAP10 (#151)
* Update README.md file by removing the compression manifest option Signed-off-by: Radoslav Dimitrov <[email protected]> * Remove the --compression option when creating snapshots, ref. TAP10 Based on TAP10, the compression option is no longer applicable and so it should be removed from the code base. Signed-off-by: Radoslav Dimitrov <[email protected]> * Update the tests affected by the removal of the --compression option Signed-off-by: Radoslav Dimitrov <[email protected]> * Update README.md file Signed-off-by: Radoslav Dimitrov <[email protected]>
1 parent 014a878 commit a075f96

File tree

9 files changed

+71
-80
lines changed

9 files changed

+71
-80
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# go-tuf
2-
[![build](https://github.com/theupdateframework/go-tuf/workflows/build/badge.svg)](https://github.com/theupdateframework/go-tuf/actions?query=workflow%3Abuild) [![Coverage Status](https://coveralls.io/repos/github/theupdateframework/go-tuf/badge.svg)](https://coveralls.io/github/theupdateframework/go-tuf) [![PkgGoDev](https://pkg.go.dev/badge/github.com/theupdateframework/go-tuf)](https://pkg.go.dev/github.com/theupdateframework/go-tuf) [![Go Report Card](https://goreportcard.com/badge/github.com/theupdateframework/go-tuf)](https://goreportcard.com/report/github.com/theupdateframework/go-tuf)
2+
3+
[![build](https://github.com/theupdateframework/go-tuf/workflows/build/badge.svg)](https://github.com/theupdateframework/go-tuf/actions?query=workflow%3Abuild) [![Coverage Status](https://coveralls.io/repos/github/theupdateframework/go-tuf/badge.svg)](https://coveralls.io/github/theupdateframework/go-tuf) [![PkgGoDev](https://pkg.go.dev/badge/github.com/theupdateframework/go-tuf)](https://pkg.go.dev/github.com/theupdateframework/go-tuf) [![Go Report Card](https://goreportcard.com/badge/github.com/theupdateframework/go-tuf)](https://goreportcard.com/report/github.com/theupdateframework/go-tuf)
34

45
This is a Go implementation of [The Update Framework (TUF)](http://theupdateframework.com/),
56
a framework for securing software update systems.
@@ -19,11 +20,11 @@ A TUF repository has the following directory layout:
1920

2021
The directories contain the following files:
2122

22-
* `keys/` - signing keys (optionally encrypted) with filename pattern `ROLE.json`
23-
* `repository/` - signed manifests
24-
* `repository/targets/` - hashed target files
25-
* `staged/` - either signed, unsigned or partially signed manifests
26-
* `staged/targets/` - unhashed target files
23+
- `keys/` - signing keys (optionally encrypted) with filename pattern `ROLE.json`
24+
- `repository/` - signed manifests
25+
- `repository/targets/` - hashed target files
26+
- `staged/` - either signed, unsigned or partially signed manifests
27+
- `staged/targets/` - unhashed target files
2728

2829
## CLI
2930

@@ -70,10 +71,11 @@ Stages the removal of files with the given path(s) from the `targets` manifest
7071
(they get removed from the filesystem when the change is committed). Specifying
7172
no paths removes all files from the `targets` manifest.
7273

73-
#### `tuf snapshot [--compression=<format>]`
74+
#### `tuf snapshot [--expires=<days>]`
7475

7576
Expects a staged, fully signed `targets` manifest and stages an appropriate
76-
`snapshot` manifest. It optionally compresses the staged `targets` manifest.
77+
`snapshot` manifest. Optionally one can set number of days after which
78+
the snapshot manifest will expire.
7779

7880
#### `tuf timestamp`
7981

client/client_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (s *ClientSuite) SetUpTest(c *C) {
106106
"timestamp": s.genKey(c, "timestamp"),
107107
}
108108
c.Assert(s.repo.AddTarget("foo.txt", nil), IsNil)
109-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
109+
c.Assert(s.repo.Snapshot(), IsNil)
110110
c.Assert(s.repo.Timestamp(), IsNil)
111111
c.Assert(s.repo.Commit(), IsNil)
112112

@@ -162,7 +162,7 @@ func (s *ClientSuite) syncRemote(c *C) {
162162

163163
func (s *ClientSuite) addRemoteTarget(c *C, name string) {
164164
c.Assert(s.repo.AddTarget(name, nil), IsNil)
165-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
165+
c.Assert(s.repo.Snapshot(), IsNil)
166166
c.Assert(s.repo.Timestamp(), IsNil)
167167
c.Assert(s.repo.Commit(), IsNil)
168168
s.syncRemote(c)
@@ -245,7 +245,7 @@ func (s *ClientSuite) TestInitRootTooLarge(c *C) {
245245

246246
func (s *ClientSuite) TestInitRootExpired(c *C) {
247247
s.genKeyExpired(c, "targets")
248-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
248+
c.Assert(s.repo.Snapshot(), IsNil)
249249
c.Assert(s.repo.Timestamp(), IsNil)
250250
c.Assert(s.repo.Commit(), IsNil)
251251
s.syncRemote(c)
@@ -325,7 +325,7 @@ func (s *ClientSuite) TestNewRoot(c *C) {
325325

326326
// update metadata
327327
c.Assert(s.repo.Sign("targets.json"), IsNil)
328-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
328+
c.Assert(s.repo.Snapshot(), IsNil)
329329
c.Assert(s.repo.Timestamp(), IsNil)
330330
c.Assert(s.repo.Commit(), IsNil)
331331
s.syncRemote(c)
@@ -389,7 +389,7 @@ func (s *ClientSuite) TestNewTimestampKey(c *C) {
389389
newIDs := s.genKey(c, "timestamp")
390390

391391
// generate new snapshot (because root has changed) and timestamp
392-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
392+
c.Assert(s.repo.Snapshot(), IsNil)
393393
c.Assert(s.repo.Timestamp(), IsNil)
394394
c.Assert(s.repo.Commit(), IsNil)
395395
s.syncRemote(c)
@@ -426,7 +426,7 @@ func (s *ClientSuite) TestNewSnapshotKey(c *C) {
426426
newIDs := s.genKey(c, "snapshot")
427427

428428
// generate new snapshot and timestamp
429-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
429+
c.Assert(s.repo.Snapshot(), IsNil)
430430
c.Assert(s.repo.Timestamp(), IsNil)
431431
c.Assert(s.repo.Commit(), IsNil)
432432
s.syncRemote(c)
@@ -466,7 +466,7 @@ func (s *ClientSuite) TestNewTargetsKey(c *C) {
466466

467467
// re-sign targets and generate new snapshot and timestamp
468468
c.Assert(s.repo.Sign("targets.json"), IsNil)
469-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
469+
c.Assert(s.repo.Snapshot(), IsNil)
470470
c.Assert(s.repo.Timestamp(), IsNil)
471471
c.Assert(s.repo.Commit(), IsNil)
472472
s.syncRemote(c)
@@ -512,7 +512,7 @@ func (s *ClientSuite) TestLocalExpired(c *C) {
512512

513513
// locally expired snapshot.json is ok
514514
version = client.snapshotVer
515-
c.Assert(s.repo.SnapshotWithExpires(tuf.CompressionTypeNone, s.expiredTime), IsNil)
515+
c.Assert(s.repo.SnapshotWithExpires(s.expiredTime), IsNil)
516516
s.syncLocal(c)
517517
s.withMetaExpired(func() {
518518
c.Assert(client.getLocalMeta(), IsNil)
@@ -585,7 +585,7 @@ func (s *ClientSuite) TestUpdateRemoteExpired(c *C) {
585585
s.assertErrExpired(c, err, "timestamp.json")
586586
})
587587

588-
c.Assert(s.repo.SnapshotWithExpires(tuf.CompressionTypeNone, s.expiredTime), IsNil)
588+
c.Assert(s.repo.SnapshotWithExpires(s.expiredTime), IsNil)
589589
c.Assert(s.repo.Timestamp(), IsNil)
590590
s.syncRemote(c)
591591
s.withMetaExpired(func() {
@@ -594,7 +594,7 @@ func (s *ClientSuite) TestUpdateRemoteExpired(c *C) {
594594
})
595595

596596
c.Assert(s.repo.AddTargetWithExpires("bar.txt", nil, s.expiredTime), IsNil)
597-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
597+
c.Assert(s.repo.Snapshot(), IsNil)
598598
c.Assert(s.repo.Timestamp(), IsNil)
599599
s.syncRemote(c)
600600
s.withMetaExpired(func() {
@@ -604,7 +604,7 @@ func (s *ClientSuite) TestUpdateRemoteExpired(c *C) {
604604

605605
s.genKeyExpired(c, "timestamp")
606606
c.Assert(s.repo.RemoveTarget("bar.txt"), IsNil)
607-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
607+
c.Assert(s.repo.Snapshot(), IsNil)
608608
c.Assert(s.repo.Timestamp(), IsNil)
609609
c.Assert(s.repo.Commit(), IsNil)
610610
s.syncRemote(c)
@@ -631,7 +631,7 @@ func (s *ClientSuite) TestUpdateLocalRootExpiredKeyChange(c *C) {
631631

632632
// update metadata
633633
c.Assert(s.repo.Sign("targets.json"), IsNil)
634-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
634+
c.Assert(s.repo.Snapshot(), IsNil)
635635
c.Assert(s.repo.Timestamp(), IsNil)
636636
c.Assert(s.repo.Commit(), IsNil)
637637
s.syncRemote(c)
@@ -651,7 +651,7 @@ func (s *ClientSuite) TestUpdateMixAndMatchAttack(c *C) {
651651
// generate metadata with an explicit expires so we can make predictable changes
652652
expires := time.Now().Add(time.Hour)
653653
c.Assert(s.repo.AddTargetWithExpires("foo.txt", nil, expires), IsNil)
654-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
654+
c.Assert(s.repo.Snapshot(), IsNil)
655655
c.Assert(s.repo.Timestamp(), IsNil)
656656
s.syncRemote(c)
657657
client := s.updatedClient(c)
@@ -664,7 +664,7 @@ func (s *ClientSuite) TestUpdateMixAndMatchAttack(c *C) {
664664

665665
// generate new remote metadata, but replace targets.json with the old one
666666
c.Assert(s.repo.AddTargetWithExpires("bar.txt", nil, expires), IsNil)
667-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
667+
c.Assert(s.repo.Snapshot(), IsNil)
668668
c.Assert(s.repo.Timestamp(), IsNil)
669669
s.syncRemote(c)
670670
newTargets, ok := s.remote.meta["targets.json"]
@@ -679,7 +679,7 @@ func (s *ClientSuite) TestUpdateMixAndMatchAttack(c *C) {
679679

680680
// do the same but keep the size the same
681681
c.Assert(s.repo.RemoveTargetWithExpires("foo.txt", expires), IsNil)
682-
c.Assert(s.repo.Snapshot(tuf.CompressionTypeNone), IsNil)
682+
c.Assert(s.repo.Snapshot(), IsNil)
683683
c.Assert(s.repo.Timestamp(), IsNil)
684684
s.syncRemote(c)
685685
s.remote.meta["targets.json"] = oldTargets
@@ -937,7 +937,7 @@ func (s *ClientSuite) TestUnknownKeyIDs(c *C) {
937937
// the TUF-0.9 update workflow, where we decide to update the root
938938
// metadata when we observe a new root through the snapshot.
939939
repo, err := tuf.NewRepo(s.store)
940-
c.Assert(repo.Snapshot(tuf.CompressionTypeNone), IsNil)
940+
c.Assert(repo.Snapshot(), IsNil)
941941
c.Assert(repo.Timestamp(), IsNil)
942942
c.Assert(repo.Commit(), IsNil)
943943
s.syncRemote(c)
@@ -964,7 +964,7 @@ func generateRepoFS(c *C, dir string, files map[string][]byte, consistentSnapsho
964964
c.Assert(ioutil.WriteFile(path, data, 0644), IsNil)
965965
c.Assert(repo.AddTarget(file, nil), IsNil)
966966
}
967-
c.Assert(repo.Snapshot(tuf.CompressionTypeNone), IsNil)
967+
c.Assert(repo.Snapshot(), IsNil)
968968
c.Assert(repo.Timestamp(), IsNil)
969969
c.Assert(repo.Commit(), IsNil)
970970
return repo

client/python_interop/python_interop_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func generateRepoFS(c *C, dir string, files map[string][]byte, consistentSnapsho
108108
c.Assert(ioutil.WriteFile(path, data, 0644), IsNil)
109109
c.Assert(repo.AddTarget(file, nil), IsNil)
110110
}
111-
c.Assert(repo.Snapshot(tuf.CompressionTypeNone), IsNil)
111+
c.Assert(repo.Snapshot(), IsNil)
112112
c.Assert(repo.Timestamp(), IsNil)
113113
c.Assert(repo.Commit(), IsNil)
114114
return repo

client/testdata/go-tuf-transition-M3/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newRepo(dir string) *tuf.Repo {
4040
}
4141

4242
func commit(dir string, repo *tuf.Repo) {
43-
assertNotNil(repo.SnapshotWithExpires(tuf.CompressionTypeNone, expirationDate))
43+
assertNotNil(repo.SnapshotWithExpires(expirationDate))
4444
assertNotNil(repo.TimestampWithExpires(expirationDate))
4545
assertNotNil(repo.Commit())
4646

client/testdata/go-tuf-transition-M4/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newRepo(dir string) *tuf.Repo {
4040
}
4141

4242
func commit(dir string, repo *tuf.Repo) {
43-
assertNotNil(repo.SnapshotWithExpires(tuf.CompressionTypeNone, expirationDate))
43+
assertNotNil(repo.SnapshotWithExpires(expirationDate))
4444
assertNotNil(repo.TimestampWithExpires(expirationDate))
4545
assertNotNil(repo.Commit())
4646

client/testdata/go-tuf/generator/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newRepo(dir string) *tuf.Repo {
4040
}
4141

4242
func commit(dir string, repo *tuf.Repo) {
43-
assertNotNil(repo.SnapshotWithExpires(tuf.CompressionTypeNone, expirationDate))
43+
assertNotNil(repo.SnapshotWithExpires(expirationDate))
4444
assertNotNil(repo.TimestampWithExpires(expirationDate))
4545
assertNotNil(repo.Commit())
4646

cmd/tuf/snapshot.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
func init() {
99
register("snapshot", cmdSnapshot, `
10-
usage: tuf snapshot [--expires=<days>] [--compression=<format>]
10+
usage: tuf snapshot [--expires=<days>]
1111
1212
Update the snapshot manifest.
1313
@@ -17,13 +17,12 @@ Options:
1717
}
1818

1919
func cmdSnapshot(args *docopt.Args, repo *tuf.Repo) error {
20-
// TODO: parse --compression
2120
if arg := args.String["--expires"]; arg != "" {
2221
expires, err := parseExpires(arg)
2322
if err != nil {
2423
return err
2524
}
26-
return repo.SnapshotWithExpires(tuf.CompressionTypeNone, expires)
25+
return repo.SnapshotWithExpires(expires)
2726
}
28-
return repo.Snapshot(tuf.CompressionTypeNone)
27+
return repo.Snapshot()
2928
}

repo.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ import (
1616
"github.com/theupdateframework/go-tuf/verify"
1717
)
1818

19-
type CompressionType uint8
20-
21-
const (
22-
CompressionTypeNone CompressionType = iota
23-
CompressionTypeGzip
24-
)
25-
2619
// topLevelManifests determines the order signatures are verified when committing.
2720
var topLevelManifests = []string{
2821
"root.json",
@@ -761,11 +754,11 @@ func (r *Repo) RemoveTargetsWithExpires(paths []string, expires time.Time) error
761754
return r.setMeta("targets.json", t)
762755
}
763756

764-
func (r *Repo) Snapshot(t CompressionType) error {
765-
return r.SnapshotWithExpires(t, data.DefaultExpires("snapshot"))
757+
func (r *Repo) Snapshot() error {
758+
return r.SnapshotWithExpires(data.DefaultExpires("snapshot"))
766759
}
767760

768-
func (r *Repo) SnapshotWithExpires(t CompressionType, expires time.Time) error {
761+
func (r *Repo) SnapshotWithExpires(expires time.Time) error {
769762
if !validExpires(expires) {
770763
return ErrInvalidExpires{expires}
771764
}
@@ -778,7 +771,7 @@ func (r *Repo) SnapshotWithExpires(t CompressionType, expires time.Time) error {
778771
if err != nil {
779772
return err
780773
}
781-
// TODO: generate compressed manifests
774+
782775
for _, name := range snapshotManifests {
783776
if err := r.verifySignature(name, db); err != nil {
784777
return err

0 commit comments

Comments
 (0)