Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rekor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SafSec
rekor
Commits
d38899d7
Unverified
Commit
d38899d7
authored
3 years ago
by
dlorenc
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add the intoto payload hash to our index. (#320)
Signed-off-by:
Dan Lorenc
<
dlorenc@google.com
>
parent
edfba67a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/types/intoto/v0.0.1/entry.go
+4
-0
4 additions, 0 deletions
pkg/types/intoto/v0.0.1/entry.go
pkg/types/intoto/v0.0.1/entry_test.go
+12
-2
12 additions, 2 deletions
pkg/types/intoto/v0.0.1/entry_test.go
with
16 additions
and
2 deletions
pkg/types/intoto/v0.0.1/entry.go
+
4
−
0
View file @
d38899d7
...
...
@@ -63,6 +63,10 @@ func NewEntry() types.EntryImpl {
func
(
v
V001Entry
)
IndexKeys
()
[]
string
{
var
result
[]
string
h
:=
sha256
.
Sum256
([]
byte
(
v
.
env
.
Payload
))
payloadKey
:=
"sha256:"
+
string
(
h
[
:
])
result
=
append
(
result
,
payloadKey
)
return
result
}
...
...
This diff is collapsed.
Click to expand it.
pkg/types/intoto/v0.0.1/entry_test.go
+
12
−
2
View file @
d38899d7
...
...
@@ -19,9 +19,11 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/sha256"
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"reflect"
"testing"
...
...
@@ -95,6 +97,9 @@ func TestV001Entry_Unmarshal(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
validPayload
:=
"hellothispayloadisvalid"
tests
:=
[]
struct
{
name
string
want
models
.
IntotoV001Schema
...
...
@@ -125,7 +130,7 @@ func TestV001Entry_Unmarshal(t *testing.T) {
it
:
&
models
.
IntotoV001Schema
{
PublicKey
:
p
(
pub
),
Content
:
&
models
.
IntotoV001SchemaContent
{
Envelope
:
envelope
(
t
,
key
,
"hello"
,
"text"
),
Envelope
:
envelope
(
t
,
key
,
validPayload
,
"text"
),
},
},
wantErr
:
false
,
...
...
@@ -145,7 +150,7 @@ func TestV001Entry_Unmarshal(t *testing.T) {
it
:
&
models
.
IntotoV001Schema
{
PublicKey
:
p
([]
byte
(
"notavalidkey"
)),
Content
:
&
models
.
IntotoV001SchemaContent
{
Envelope
:
envelope
(
t
,
key
,
"hello"
,
"text"
),
Envelope
:
envelope
(
t
,
key
,
validPayload
,
"text"
),
},
},
wantErr
:
true
,
...
...
@@ -164,6 +169,11 @@ func TestV001Entry_Unmarshal(t *testing.T) {
if
err
:=
v
.
Validate
();
err
!=
nil
{
return
err
}
keys
:=
v
.
IndexKeys
()
h
:=
sha256
.
Sum256
([]
byte
(
v
.
env
.
Payload
))
if
keys
[
0
]
!=
"sha256:"
+
string
(
h
[
:
])
{
return
fmt
.
Errorf
(
"expected index key: %s, got %s"
,
h
[
:
],
keys
[
0
])
}
return
nil
}
if
err
:=
uv
();
(
err
!=
nil
)
!=
tt
.
wantErr
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment