Skip to content

Commit bff5a4a

Browse files
authored
Rename ecosystem to origin (sigstore#542)
* rename ecosystem to origin Signed-off-by: Asra Ali <asraa@google.com> * update comments Signed-off-by: Asra Ali <asraa@google.com>
1 parent f3a1e3f commit bff5a4a

File tree

5 files changed

+87
-87
lines changed

5 files changed

+87
-87
lines changed

pkg/api/tlog.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ func GetLogInfoHandler(params tlog.GetLogInfoParams) middleware.Responder {
5151
treeSize := int64(root.TreeSize)
5252

5353
sth, err := util.CreateSignedCheckpoint(util.Checkpoint{
54-
Ecosystem: "Rekor",
55-
Size: root.TreeSize,
56-
Hash: root.RootHash,
54+
Origin: "Rekor",
55+
Size: root.TreeSize,
56+
Hash: root.RootHash,
5757
})
5858
if err != nil {
5959
return handleRekorAPIError(params, http.StatusInternalServerError, fmt.Errorf("marshalling error: %w", err), sthGenerateError)

pkg/util/checkpoint.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828
// heavily borrowed from https://github.com/google/trillian-examples/blob/master/formats/log/checkpoint.go
2929

3030
type Checkpoint struct {
31-
// Ecosystem is the ecosystem/version string
32-
Ecosystem string
31+
// Origin is the unique identifier/version string
32+
Origin string
3333
// Size is the number of entries in the log at this checkpoint.
3434
Size uint64
3535
// Hash is the hash which commits to the contents of the entire log.
@@ -41,7 +41,7 @@ type Checkpoint struct {
4141
// String returns the String representation of the Checkpoint
4242
func (c Checkpoint) String() string {
4343
var b strings.Builder
44-
fmt.Fprintf(&b, "%s\n%d\n%s\n", c.Ecosystem, c.Size, base64.StdEncoding.EncodeToString(c.Hash))
44+
fmt.Fprintf(&b, "%s\n%d\n%s\n", c.Origin, c.Size, base64.StdEncoding.EncodeToString(c.Hash))
4545
for _, line := range c.OtherContent {
4646
fmt.Fprintf(&b, "%s\n", line)
4747
}
@@ -70,8 +70,8 @@ func (c *Checkpoint) UnmarshalCheckpoint(data []byte) error {
7070
if len(l) < 4 {
7171
return errors.New("invalid checkpoint - too few newlines")
7272
}
73-
eco := string(l[0])
74-
if len(eco) == 0 {
73+
origin := string(l[0])
74+
if len(origin) == 0 {
7575
return errors.New("invalid checkpoint - empty ecosystem")
7676
}
7777
size, err := strconv.ParseUint(string(l[1]), 10, 64)
@@ -83,9 +83,9 @@ func (c *Checkpoint) UnmarshalCheckpoint(data []byte) error {
8383
return fmt.Errorf("invalid checkpoint - invalid hash: %w", err)
8484
}
8585
*c = Checkpoint{
86-
Ecosystem: eco,
87-
Size: size,
88-
Hash: h,
86+
Origin: origin,
87+
Size: size,
88+
Hash: h,
8989
}
9090
if len(l) >= 3 {
9191
for _, line := range l[3:] {

pkg/util/checkpoint_test.go

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ func TestMarshalCheckpoint(t *testing.T) {
4040
}{
4141
{
4242
c: Checkpoint{
43-
Ecosystem: "Log Checkpoint v0",
44-
Size: 123,
45-
Hash: []byte("bananas"),
43+
Origin: "Log Checkpoint v0",
44+
Size: 123,
45+
Hash: []byte("bananas"),
4646
},
4747
want: "Log Checkpoint v0\n123\nYmFuYW5hcw==\n",
4848
}, {
4949
c: Checkpoint{
50-
Ecosystem: "Banana Checkpoint v5",
51-
Size: 9944,
52-
Hash: []byte("the view from the tree tops is great!"),
50+
Origin: "Banana Checkpoint v5",
51+
Size: 9944,
52+
Hash: []byte("the view from the tree tops is great!"),
5353
},
5454
want: "Banana Checkpoint v5\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
5555
}, {
5656
c: Checkpoint{
57-
Ecosystem: "Banana Checkpoint v7",
57+
Origin: "Banana Checkpoint v7",
5858
Size: 9943,
5959
Hash: []byte("the view from the tree tops is great!"),
6060
OtherContent: []string{"foo", "bar"},
@@ -85,23 +85,23 @@ func TestUnmarshalCheckpoint(t *testing.T) {
8585
desc: "valid one",
8686
m: "Log Checkpoint v0\n123\nYmFuYW5hcw==\n",
8787
want: Checkpoint{
88-
Ecosystem: "Log Checkpoint v0",
89-
Size: 123,
90-
Hash: []byte("bananas"),
88+
Origin: "Log Checkpoint v0",
89+
Size: 123,
90+
Hash: []byte("bananas"),
9191
},
9292
}, {
9393
desc: "valid with different ecosystem",
9494
m: "Banana Checkpoint v1\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n",
9595
want: Checkpoint{
96-
Ecosystem: "Banana Checkpoint v1",
97-
Size: 9944,
98-
Hash: []byte("the view from the tree tops is great!"),
96+
Origin: "Banana Checkpoint v1",
97+
Size: 9944,
98+
Hash: []byte("the view from the tree tops is great!"),
9999
},
100100
}, {
101101
desc: "valid with trailing data",
102102
m: "Log Checkpoint v0\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\nHere's some associated data.\n",
103103
want: Checkpoint{
104-
Ecosystem: "Log Checkpoint v0",
104+
Origin: "Log Checkpoint v0",
105105
Size: 9944,
106106
Hash: []byte("the view from the tree tops is great!"),
107107
OtherContent: []string{"Here's some associated data."},
@@ -110,7 +110,7 @@ func TestUnmarshalCheckpoint(t *testing.T) {
110110
desc: "valid with multiple trailing data lines",
111111
m: "Log Checkpoint v0\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\nlots\nof\nlines\n",
112112
want: Checkpoint{
113-
Ecosystem: "Log Checkpoint v0",
113+
Origin: "Log Checkpoint v0",
114114
Size: 9944,
115115
Hash: []byte("the view from the tree tops is great!"),
116116
OtherContent: []string{"lots", "of", "lines"},
@@ -119,9 +119,9 @@ func TestUnmarshalCheckpoint(t *testing.T) {
119119
desc: "valid with trailing newlines",
120120
m: "Log Checkpoint v0\n9944\ndGhlIHZpZXcgZnJvbSB0aGUgdHJlZSB0b3BzIGlzIGdyZWF0IQ==\n\n\n\n",
121121
want: Checkpoint{
122-
Ecosystem: "Log Checkpoint v0",
123-
Size: 9944,
124-
Hash: []byte("the view from the tree tops is great!"),
122+
Origin: "Log Checkpoint v0",
123+
Size: 9944,
124+
Hash: []byte("the view from the tree tops is great!"),
125125
},
126126
}, {
127127
desc: "invalid - insufficient lines",
@@ -184,9 +184,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
184184
}{
185185
{
186186
c: Checkpoint{
187-
Ecosystem: "Log Checkpoint RSA v0",
188-
Size: 123,
189-
Hash: []byte("bananas"),
187+
Origin: "Log Checkpoint RSA v0",
188+
Size: 123,
189+
Hash: []byte("bananas"),
190190
},
191191
identity: "someone",
192192
signer: rsaKey,
@@ -197,9 +197,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
197197
},
198198
{
199199
c: Checkpoint{
200-
Ecosystem: "Log Checkpoint ECDSA v0",
201-
Size: 123,
202-
Hash: []byte("bananas"),
200+
Origin: "Log Checkpoint ECDSA v0",
201+
Size: 123,
202+
Hash: []byte("bananas"),
203203
},
204204
identity: "someone",
205205
signer: ecdsaKey,
@@ -210,9 +210,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
210210
},
211211
{
212212
c: Checkpoint{
213-
Ecosystem: "Log Checkpoint Ed25519 v0",
214-
Size: 123,
215-
Hash: []byte("bananas"),
213+
Origin: "Log Checkpoint Ed25519 v0",
214+
Size: 123,
215+
Hash: []byte("bananas"),
216216
},
217217
identity: "someone",
218218
signer: edPrivKey,
@@ -223,9 +223,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
223223
},
224224
{
225225
c: Checkpoint{
226-
Ecosystem: "Log Checkpoint Mismatch v0",
227-
Size: 123,
228-
Hash: []byte("bananas"),
226+
Origin: "Log Checkpoint Mismatch v0",
227+
Size: 123,
228+
Hash: []byte("bananas"),
229229
},
230230
identity: "someone",
231231
signer: edPrivKey,
@@ -236,9 +236,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
236236
},
237237
{
238238
c: Checkpoint{
239-
Ecosystem: "Log Checkpoint Mismatch v1",
240-
Size: 123,
241-
Hash: []byte("bananas"),
239+
Origin: "Log Checkpoint Mismatch v1",
240+
Size: 123,
241+
Hash: []byte("bananas"),
242242
},
243243
identity: "someone",
244244
signer: ecdsaKey,
@@ -249,9 +249,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
249249
},
250250
{
251251
c: Checkpoint{
252-
Ecosystem: "Log Checkpoint Mismatch v2",
253-
Size: 123,
254-
Hash: []byte("bananas"),
252+
Origin: "Log Checkpoint Mismatch v2",
253+
Size: 123,
254+
Hash: []byte("bananas"),
255255
},
256256
identity: "someone",
257257
signer: edPrivKey,
@@ -262,9 +262,9 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
262262
},
263263
{
264264
c: Checkpoint{
265-
Ecosystem: "Log Checkpoint Mismatch v3",
266-
Size: 123,
267-
Hash: []byte("bananas"),
265+
Origin: "Log Checkpoint Mismatch v3",
266+
Size: 123,
267+
Hash: []byte("bananas"),
268268
},
269269
identity: "someone",
270270
signer: ecdsaKey,
@@ -274,7 +274,7 @@ func TestSigningRoundtripCheckpoint(t *testing.T) {
274274
wantVerifyErr: true,
275275
},
276276
} {
277-
t.Run(string(test.c.Ecosystem), func(t *testing.T) {
277+
t.Run(string(test.c.Origin), func(t *testing.T) {
278278
sth, err := CreateSignedCheckpoint(test.c)
279279
if err != nil {
280280
t.Fatalf("error creating signed checkpoint")
@@ -332,9 +332,9 @@ func TestInvalidSigVerification(t *testing.T) {
332332
}{
333333
{
334334
checkpoint: Checkpoint{
335-
Ecosystem: "Log Checkpoint v0",
336-
Size: 123,
337-
Hash: []byte("bananas"),
335+
Origin: "Log Checkpoint v0",
336+
Size: 123,
337+
Hash: []byte("bananas"),
338338
},
339339
s: []note.Signature{},
340340
pubKey: ecdsaKey.Public(),
@@ -343,9 +343,9 @@ func TestInvalidSigVerification(t *testing.T) {
343343
{
344344

345345
checkpoint: Checkpoint{
346-
Ecosystem: "Log Checkpoint v0 not base64",
347-
Size: 123,
348-
Hash: []byte("bananas"),
346+
Origin: "Log Checkpoint v0 not base64",
347+
Size: 123,
348+
Hash: []byte("bananas"),
349349
},
350350
pubKey: ecdsaKey.Public(),
351351
s: []note.Signature{
@@ -359,9 +359,9 @@ func TestInvalidSigVerification(t *testing.T) {
359359
},
360360
{
361361
checkpoint: Checkpoint{
362-
Ecosystem: "Log Checkpoint v0 invalid signature",
363-
Size: 123,
364-
Hash: []byte("bananas"),
362+
Origin: "Log Checkpoint v0 invalid signature",
363+
Size: 123,
364+
Hash: []byte("bananas"),
365365
},
366366
pubKey: ecdsaKey.Public(),
367367
s: []note.Signature{
@@ -374,7 +374,7 @@ func TestInvalidSigVerification(t *testing.T) {
374374
expectedResult: false,
375375
},
376376
} {
377-
t.Run(string(test.checkpoint.Ecosystem), func(t *testing.T) {
377+
t.Run(string(test.checkpoint.Origin), func(t *testing.T) {
378378
text, _ := test.checkpoint.MarshalCheckpoint()
379379
sc := SignedNote{
380380
Note: string(text),

pkg/util/timestamp_note.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
// Signed note based timestamp responses
3131

3232
type TimestampNote struct {
33-
// Ecosystem is the ecosystem/version string
34-
Ecosystem string
33+
// Origin is the unique identifier/version string
34+
Origin string
3535
// MessageImprint is the hash of the message to timestamp, of the form sha256:<sha>
3636
MessageImprint string
3737
// Nonce is a short random bytes to prove response freshness
@@ -50,7 +50,7 @@ type TimestampNote struct {
5050
func (t TimestampNote) String() string {
5151
var b strings.Builder
5252
time, _ := t.Time.MarshalText()
53-
fmt.Fprintf(&b, "%s\n%s\n%s\n%s\n%d\n%s\n", t.Ecosystem, t.MessageImprint, base64.StdEncoding.EncodeToString(t.Nonce),
53+
fmt.Fprintf(&b, "%s\n%s\n%s\n%s\n%d\n%s\n", t.Origin, t.MessageImprint, base64.StdEncoding.EncodeToString(t.Nonce),
5454
time, t.Radius, t.CertChainRef)
5555
for _, line := range t.OtherContent {
5656
fmt.Fprintf(&b, "%s\n", line)
@@ -83,8 +83,8 @@ func (t *TimestampNote) UnmarshalText(data []byte) error {
8383
if len(l) < 7 {
8484
return errors.New("invalid timestamp note - too few newlines")
8585
}
86-
eco := string(l[0])
87-
if len(eco) == 0 {
86+
origin := string(l[0])
87+
if len(origin) == 0 {
8888
return errors.New("invalid timestamp note - empty ecosystem")
8989
}
9090
h := string(l[1])
@@ -110,7 +110,7 @@ func (t *TimestampNote) UnmarshalText(data []byte) error {
110110

111111
}
112112
*t = TimestampNote{
113-
Ecosystem: eco,
113+
Origin: origin,
114114
MessageImprint: h,
115115
Nonce: nonce,
116116
Time: timestamp,

0 commit comments

Comments
 (0)