Skip to content

Commit

Permalink
[WIP] Further work on corim files
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed Sep 30, 2024
1 parent b38531e commit af81048
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 174 deletions.
27 changes: 14 additions & 13 deletions corim/example_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ func Example_profile_unmarshal() {
Extensions.MustGetString("Address"))

fmt.Printf("Measurements:\n")
for _, refVal := range extractedComid.Triples.ReferenceValues.Values {
for _, m := range extractedComid.Triples.ReferenceValues.Values[0].Measurements.Values {

val := hex.EncodeToString((*refVal.Measurement.Val.Digests)[0].HashValue)
tsInt := refVal.Measurement.Val.Extensions.MustGetInt64("timestamp")
val := hex.EncodeToString((*m.Val.Digests)[0].HashValue)
tsInt := m.Val.Extensions.MustGetInt64("timestamp")
ts := time.Unix(tsInt, 0).UTC()

fmt.Printf(" %v taken at %s\n", val, ts.Format("2006-01-02T15:04:05"))
Expand Down Expand Up @@ -152,6 +152,15 @@ func Example_profile_marshal() {
log.Fatalf("could not set entity Address: %v", err)
}

refVal := comid.ValueTriple{
Environment: comid.Environment{
Class: comid.NewClassImplID(comid.TestImplID).
SetVendor("ACME Ltd.").
SetModel("RoadRunner 2.0"),
},
Measurements: *comid.NewMeasurements(),
}

measurement := comid.MustNewPSAMeasurement(
comid.MustCreatePSARefValID(
comid.TestSignerID, "BL", "5.0.5",
Expand All @@ -168,15 +177,7 @@ func Example_profile_marshal() {
log.Fatal("could not register refval extensions")
}

refVal := comid.ValueTriple{
Environment: comid.Environment{
Class: comid.NewClassImplID(comid.TestImplID).
SetVendor("ACME Ltd.").
SetModel("RoadRunner 2.0"),
},
Measurement: *measurement,
}

refVal.Measurements.Add(measurement)
myComid.Triples.AddReferenceValue(refVal)

err = myComid.Valid()
Expand All @@ -194,5 +195,5 @@ func Example_profile_marshal() {
fmt.Printf("corim: %v", hex.EncodeToString(buf))

// output:
// corim: a300f6018158d8d901faa40065656e2d474201a100676578616d706c650281a4006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028101206f3132332046616b652053747265657404a1008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e30a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00037822687474703a2f2f6578616d706c652e636f6d2f6578616d706c652d70726f66696c65
// corim: a300f6018158d9d901faa40065656e2d474201a100676578616d706c650281a4006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028101206f3132332046616b652053747265657404a1008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e3081a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00037822687474703a2f2f6578616d706c652e636f6d2f6578616d706c652d70726f66696c65
}
4 changes: 2 additions & 2 deletions corim/profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestProfile_marshaling(t *testing.T) {
address := cmd.Entities.Values[0].Extensions.MustGetString("Address")
assert.Equal(t, "123 Fake Street", address)

ts := cmd.Triples.ReferenceValues.Values[0].Measurement.
ts := cmd.Triples.ReferenceValues.Values[0].Measurements.Values[0].
Val.Extensions.MustGetInt("timestamp")
assert.Equal(t, 1720782190, ts)

Expand Down Expand Up @@ -169,7 +169,7 @@ func TestProfile_marshaling(t *testing.T) {
address = cmd.Entities.Values[0].Extensions.MustGetString("Address")
assert.Equal(t, "123 Fake Street", address)

ts = cmd.Triples.ReferenceValues.Values[0].Measurement.
ts = cmd.Triples.ReferenceValues.Values[0].Measurements.Values[0].
Val.Extensions.MustGetInt("timestamp")
assert.Equal(t, 1720782190, ts)

Expand Down
1 change: 1 addition & 0 deletions corim/testcases/comid.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"value": "cfg v1.0.0"
},
"value": {
"timestamp": 1720782190,
"raw-value": {
"type": "bytes",
"value": "cmF3dmFsdWUKcmF3dmFsdWUK"
Expand Down
93 changes: 39 additions & 54 deletions corim/testcases/src/corim-with-extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,42 @@
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: BL
4: 2.1.0
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=
-1: 1720782190
- - 0:
0:
tag: 600
value: !!binary |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: PRoT
4: 1.3.5
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=
-1: 1720782190
- - 0:
0:
tag: 600
value: !!binary |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: ARoT
4: 0.1.4
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=
-1: 1720782190

- - 0:
tag: 601
value:
1: BL
4: 2.1.0
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=
-1: 1720782190
- 0:
tag: 601
value:
1: PRoT
4: 1.3.5
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=
-1: 1720782190
- 0:
tag: 601
value:
1: ARoT
4: 0.1.4
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=
-1: 1720782190
93 changes: 39 additions & 54 deletions corim/testcases/src/example-corim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,57 +36,42 @@
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: BL
4: 2.1.0
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=
-1: 1720782190
- - 0:
0:
tag: 600
value: !!binary |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: PRoT
4: 1.3.5
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=
-1: 1720782190
- - 0:
0:
tag: 600
value: !!binary |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: ARoT
4: 0.1.4
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=
-1: 1720782190

- - 0:
tag: 601
value:
1: BL
4: 2.1.0
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=
-1: 1720782190
- 0:
tag: 601
value:
1: PRoT
4: 1.3.5
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=
-1: 1720782190
- 0:
tag: 601
value:
1: ARoT
4: 0.1.4
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=
-1: 1720782190
87 changes: 36 additions & 51 deletions corim/testcases/src/good-corim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,54 +27,39 @@
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: BL
4: 2.1.0
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=
- - 0:
0:
tag: 600
value: !!binary |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: PRoT
4: 1.3.5
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=
- - 0:
0:
tag: 600
value: !!binary |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=
1: ACME
2: RoadRunner
- 0:
tag: 601
value:
1: ARoT
4: 0.1.4
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=

- - 0:
tag: 601
value:
1: BL
4: 2.1.0
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=
- 0:
tag: 601
value:
1: PRoT
4: 1.3.5
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=
- 0:
tag: 601
value:
1: ARoT
4: 0.1.4
5: !!binary |-
rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=
1:
2:
- - 1
- !!binary |-
o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=

0 comments on commit af81048

Please sign in to comment.