Skip to content

Commit bdb5cee

Browse files
committed
rebase and update test cases to long expiration (10 years from now), by default.
1 parent ba6ffde commit bdb5cee

File tree

731 files changed

+2485
-10944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

731 files changed

+2485
-10944
lines changed

client/client.go

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ import (
77
"io"
88
"io/ioutil"
99
"log"
10-
<<<<<<< HEAD
11-
<<<<<<< HEAD
12-
<<<<<<< HEAD
13-
=======
14-
"sort"
15-
=======
16-
>>>>>>> 2fc418a (addressed several comments.)
17-
"time"
18-
>>>>>>> 78b1631 (test for fast forward attack recovery)
19-
=======
20-
>>>>>>> 5326b91 (fix race condition related to the expired check.)
2110

2211
"github.com/theupdateframework/go-tuf/data"
2312
"github.com/theupdateframework/go-tuf/util"
@@ -247,31 +236,12 @@ func (c *Client) updateRoots() error {
247236

248237
// Prepare for 5.3.11: If the timestamp and / or snapshot keys have been rotated,
249238
// then delete the trusted timestamp and snapshot metadata files.
250-
<<<<<<< HEAD
251-
<<<<<<< HEAD
252239
getKeyInfo := func(role string) KeyInfo {
253240
keyIDs := make(map[string]bool)
254-
=======
255-
getKeyIDs := func(role string) ([]string, int) {
256-
keyIDs := make([]string, 0, len(c.db.GetRole(role).KeyIDs))
257-
>>>>>>> 78b1631 (test for fast forward attack recovery)
258241
for k := range c.db.GetRole(role).KeyIDs {
259242
keyIDs[k] = true
260243
}
261-
<<<<<<< HEAD
262244
return KeyInfo{keyIDs, c.db.GetRole(role).Threshold}
263-
=======
264-
sort.Strings(keyIDs)
265-
return keyIDs, c.db.GetRole(role).Threshold
266-
>>>>>>> 78b1631 (test for fast forward attack recovery)
267-
=======
268-
getKeyInfo := func(role string) KeyInfo {
269-
keyIDs := make(map[string]bool)
270-
for k := range c.db.GetRole(role).KeyIDs {
271-
keyIDs[k] = true
272-
}
273-
return KeyInfo{keyIDs, c.db.GetRole(role).Threshold}
274-
>>>>>>> 2fc418a (addressed several comments.)
275245
}
276246

277247
// The nonRootKeyInfo looks like this:
@@ -280,24 +250,10 @@ func (c *Client) updateRoots() error {
280250
// "snapshot": {KeyIDs={"KEYID3": true}, Threshold=1},
281251
// "targets": {KeyIDs={"KEYID4": true, "KEYID5": true, "KEYID6": true}, Threshold=1}
282252
// }
283-
<<<<<<< HEAD
284-
<<<<<<< HEAD
285-
286-
nonRootKeyInfo := map[string]KeyInfo{"timestamp": {}, "snapshot": {}, "targets": {}}
287-
for k := range nonRootKeyInfo {
288-
nonRootKeyInfo[k] = getKeyInfo(k)
289-
=======
290-
nonRootManifests := map[string][]string{"timestamp": {}, "snapshot": {}, "targets": {}}
291-
nonRootThreshold := map[string]int{"timestamp": 1, "snapshot": 1, "targets": 1}
292-
for k := range nonRootManifests {
293-
nonRootManifests[k], nonRootThreshold[k] = getKeyIDs(k)
294-
>>>>>>> 78b1631 (test for fast forward attack recovery)
295-
=======
296253

297254
nonRootKeyInfo := map[string]KeyInfo{"timestamp": {}, "snapshot": {}, "targets": {}}
298255
for k := range nonRootKeyInfo {
299256
nonRootKeyInfo[k] = getKeyInfo(k)
300-
>>>>>>> 2fc418a (addressed several comments.)
301257
}
302258

303259
// 5.3.1 Temorarily turn on the consistent snapshots in order to download
@@ -379,32 +335,11 @@ func (c *Client) updateRoots() error {
379335
return err
380336
}
381337

382-
<<<<<<< HEAD
383-
<<<<<<< HEAD
384-
<<<<<<< HEAD
385-
=======
386-
>>>>>>> 2fc418a (addressed several comments.)
387338
countDeleted := func(s1 map[string]bool, s2 map[string]bool) int {
388339
c := 0
389340
for k := range s1 {
390341
if _, ok := s2[k]; !ok {
391342
c++
392-
<<<<<<< HEAD
393-
=======
394-
countDeleted := func(s1 []string, s2 []string) int {
395-
c := len(s1)
396-
p2 := 0
397-
for _, v := range s1 {
398-
for p2 < len(s2) && v >= s2[p2] {
399-
if v == s2[p2] {
400-
c--
401-
p2++
402-
break
403-
}
404-
p2++
405-
>>>>>>> 78b1631 (test for fast forward attack recovery)
406-
=======
407-
>>>>>>> 2fc418a (addressed several comments.)
408343
}
409344
}
410345
return c
@@ -414,8 +349,6 @@ func (c *Client) updateRoots() error {
414349
// to be deleted if a threshold of keys are revoked.
415350
// List of metadata that should be deleted per role if a threshold of keys
416351
// are revoked:
417-
<<<<<<< HEAD
418-
<<<<<<< HEAD
419352
// (based on the ongoing PR: https://github.com/mnm678/specification/tree/e50151d9df632299ddea364c4f44fe8ca9c10184)
420353
// timestamp -> delete timestamp.json
421354
// snapshot -> delete timestamp.json and snapshot.json
@@ -436,35 +369,6 @@ func (c *Client) updateRoots() error {
436369
for _, r := range deleteMeta[topLevelRolename] {
437370
c.local.DeleteMeta(r)
438371
}
439-
=======
440-
// 5.3.11 If the timestamp and / or snapshot keys have been rotated,
441-
// then delete the trusted timestamp and snapshot metadata files.
442-
for topLevelRolename := range nonRootManifests {
443-
if !reflect.DeepEqual(
444-
nonRootManifests[topLevelRolename],
445-
getKeyIDs(topLevelRolename)) {
446-
c.local.DeleteMeta(topLevelRolename)
447-
>>>>>>> 6a1b949 (delete (instead of setting to an empty raw message) the top-level metadata when their key has changed.)
448-
=======
449-
=======
450-
// (based on the ongoing PR: https://github.com/mnm678/specification/tree/e50151d9df632299ddea364c4f44fe8ca9c10184)
451-
>>>>>>> 2fc418a (addressed several comments.)
452-
// timestamp -> delete timestamp.json
453-
// snapshot -> delete timestamp.json and snapshot.json
454-
// targets -> delete snapshot.json and targets.json
455-
for topLevelRolename := range nonRootKeyInfo {
456-
ki := getKeyInfo(topLevelRolename)
457-
if countDeleted(nonRootKeyInfo[topLevelRolename].KeyIDs, ki.KeyIDs) >= nonRootKeyInfo[topLevelRolename].Threshold {
458-
deleteMeta := map[string][]string{
459-
"timestamp": {"timestamp.json"},
460-
"snapshot": {"timestamp.json", "snapshot.json"},
461-
"targets": {"snapshot.json", "targets.json"},
462-
}
463-
464-
for _, r := range deleteMeta[topLevelRolename] {
465-
c.local.DeleteMeta(r)
466-
}
467-
>>>>>>> 78b1631 (test for fast forward attack recovery)
468372
}
469373
}
470374

@@ -560,15 +464,7 @@ func (c *Client) loadAndVerifyLocalRootMeta(ignoreExpiredCheck bool) error {
560464
}
561465
// Any trusted local root metadata version must be greater than 0.
562466
if ignoreExpiredCheck {
563-
<<<<<<< HEAD
564-
<<<<<<< HEAD
565-
if err := ndb.VerifyIgnoreExpiredCheck(s, "root", 0); err != nil {
566-
=======
567-
if _, err := ndb.VerifyIgnoreExpiredCheck(s, "root", 0); err != nil {
568-
>>>>>>> 5326b91 (fix race condition related to the expired check.)
569-
=======
570467
if err := ndb.VerifyIgnoreExpiredCheck(s, "root", 0); err != nil {
571-
>>>>>>> c55d799 (update the VerifyIgnoreExpiredCheck method signature and add test for it.)
572468
return err
573469
}
574470
} else {

0 commit comments

Comments
 (0)