Skip to content

Commit

Permalink
cjson - Move to go-securesystemslib (#1141)
Browse files Browse the repository at this point in the history
The existing cjson hasn't been maintained. The last update was 9 years
ago. This was replaced by the upstream go-securesystemslib
secure-systems-lab/go-securesystemslib#10

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan authored Dec 5, 2021
1 parent e233ce8 commit 63e9342
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ require (
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0
github.com/tent/canonical-json-go v0.0.0-20130607151641-96e4ba3a7613
github.com/theupdateframework/go-tuf v0.0.0-20211203210025-7ded50136bf9
github.com/xanzy/go-gitlab v0.52.2
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
Expand Down
8 changes: 4 additions & 4 deletions pkg/cosign/tuf/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/pkg/errors"

cjson "github.com/tent/canonical-json-go"
cjson "github.com/secure-systems-lab/go-securesystemslib/cjson"
)

type Signed struct {
Expand All @@ -54,7 +54,7 @@ type Key struct {

func (k *Key) ID() string {
k.idOnce.Do(func() {
data, _ := cjson.Marshal(k)
data, _ := cjson.EncodeCanonical(k)
digest := sha256.Sum256(data)
k.id = hex.EncodeToString(digest[:])
})
Expand Down Expand Up @@ -127,7 +127,7 @@ func (r *Role) AddKeysWithThreshold(keys []*Key, threshold int) bool {

func (r *Root) Marshal() (*Signed, error) {
// Marshals the Root into a Signed type
b, err := cjson.Marshal(r)
b, err := cjson.EncodeCanonical(r)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func (r *Root) ValidKey(key *Key, role string) (string, error) {

func (s *Signed) JSONMarshal(prefix, indent string) ([]byte, error) {
// Marshals Signed with prefix and indent.
b, err := cjson.Marshal(s)
b, err := cjson.EncodeCanonical(s)
if err != nil {
return []byte{}, err
}
Expand Down

0 comments on commit 63e9342

Please sign in to comment.