Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
7e6de1d
test action
rohankh532 Feb 11, 2022
1765329
Merge pull request #1 from rohankh532/scorecard-cosign-api
rohankh532 Feb 11, 2022
99ac477
sign test data
rohankh532 Feb 14, 2022
90b1a7d
func to sign and upload workflow result
rohankh532 Feb 17, 2022
a6a828c
Merge branch 'ossf:main' into main
rohankh532 Feb 18, 2022
c336f33
Merge branch 'main' of https://github.com/ossf/scorecard-action
rohankh532 Feb 23, 2022
39aeca4
Merge branch 'main' of https://github.com/ossf/scorecard-action into …
rohankh532 Feb 24, 2022
7b77ea3
added signScorecardResult func and test
rohankh532 Feb 24, 2022
136ab80
added signScorecardResult func and test
rohankh532 Feb 24, 2022
d4bc081
Merge branch 'ossf:main' into main
rohankh532 Feb 24, 2022
9c73100
Merge branch 'ossf:main' into scorecard-cosign-api
rohankh532 Feb 24, 2022
b76a7ed
moved signing code into main.go
rohankh532 Feb 24, 2022
8cc47f1
added call to signScorecardResult at the end of main
rohankh532 Feb 24, 2022
3122491
added err checking
rohankh532 Feb 24, 2022
d818df5
comments and added global vars
rohankh532 Feb 25, 2022
a819cef
style changes
rohankh532 Feb 25, 2022
81dec2a
updated test to use randomized payload
rohankh532 Feb 25, 2022
3ba6f99
Merge branch 'ossf:main' into main
rohankh532 Feb 28, 2022
ec3258f
check publish_results
rohankh532 Mar 1, 2022
e2da989
error logging for signScorecardResult call
rohankh532 Mar 3, 2022
fa4123c
error logging
rohankh532 Mar 3, 2022
a813b9b
Merge branch 'ossf:main' into main
rohankh532 Mar 7, 2022
a293769
changed dockerfile entrypoint to go
rohankh532 Mar 7, 2022
3660d60
entrypoint
rohankh532 Mar 7, 2022
a5a2855
updated dockerfile
rohankh532 Mar 7, 2022
e6b1214
dockerfile
rohankh532 Mar 7, 2022
8fab59a
Merge branch 'ossf:main' into main
rohankh532 Mar 8, 2022
03ca286
Merge branch 'ossf:main' into scorecard-cosign-api
rohankh532 Mar 8, 2022
fdae546
dockerfile
rohankh532 Mar 8, 2022
fa8486f
added makefile
rohankh532 Mar 8, 2022
7d20fd6
EnvInputsResults vars added to Options
rohankh532 Mar 8, 2022
cea54d5
resultsfile env var
rohankh532 Mar 8, 2022
831461f
set PAT
rohankh532 Mar 8, 2022
32fc254
create results file with sudo
rohankh532 Mar 8, 2022
71f89f0
sudo create resultsfile
rohankh532 Mar 8, 2022
52d7678
try os.Openfile
rohankh532 Mar 8, 2022
6bd1329
fixed fileapth
rohankh532 Mar 9, 2022
14f0561
changed Distroless to debian
rohankh532 Mar 9, 2022
8c4d904
get output format from env var
rohankh532 Mar 9, 2022
5f8505b
fixed defaultpolicyfile path
rohankh532 Mar 9, 2022
d6c6b36
policy filepath
rohankh532 Mar 9, 2022
bb0cf17
copy policy.yml in dockerfile
rohankh532 Mar 9, 2022
7dd22a9
policyfile
rohankh532 Mar 9, 2022
5e3fab3
moved signing code to separate file
rohankh532 Mar 10, 2022
5652a7d
dockerfile
rohankh532 Mar 10, 2022
f959fb9
Merge branch 'ossf:main' into main
rohankh532 Mar 15, 2022
33b366f
generate results.json file in preRun
rohankh532 Mar 15, 2022
56286d9
Merge branch 'ossf:main' into main
rohankh532 Mar 17, 2022
76d6091
merged main into scorecard-cosign-api
rohankh532 Mar 17, 2022
5e4afab
revert dockerfile to main
rohankh532 Mar 17, 2022
72fb119
json file creation check
rohankh532 Mar 17, 2022
8852901
run scorecard again to produce json output
rohankh532 Mar 17, 2022
08a9198
testing
rohankh532 Mar 17, 2022
537e2af
entrypointJson
rohankh532 Mar 17, 2022
dd68601
print cmd
rohankh532 Mar 17, 2022
00cfdeb
alter env vars in main for json
rohankh532 Mar 17, 2022
8ea5955
opts
rohankh532 Mar 17, 2022
30ea94b
dockerfile uses entrypoint.go
rohankh532 Mar 17, 2022
b664df1
renamed make build
rohankh532 Mar 17, 2022
10259cf
produce both sarif and json
rohankh532 Mar 17, 2022
e2a2155
sign json result
rohankh532 Mar 17, 2022
a149336
sig verification api call
rohankh532 Mar 18, 2022
ab1df92
go mod tidy
rohankh532 Mar 18, 2022
35f292a
readfile fix
rohankh532 Mar 18, 2022
42fbdd7
sign sarif instead of json
rohankh532 Mar 18, 2022
3cf1e8f
http response code checking
rohankh532 Mar 18, 2022
f1ea928
moved api call func into signing.go
rohankh532 Mar 18, 2022
94042f2
dont hardcode repo paths
rohankh532 Mar 18, 2022
50a023e
finalized signing + verif
rohankh532 Mar 19, 2022
a7fa1f8
renamed sign test
rohankh532 Mar 19, 2022
1e1e926
Bump debian from d5cd7e5 to 40f90ea
rohankh532 Mar 19, 2022
1e2db51
Merge branch 'main' into scorecard-cosign-api
rohankh532 Mar 19, 2022
dfb65b6
removed unnecessary slash
rohankh532 Mar 19, 2022
3622a4e
comments
rohankh532 Mar 20, 2022
7ee63b8
policy.yml -> /policy.yml
rohankh532 Mar 20, 2022
68d8a49
refractored signing
rohankh532 Mar 20, 2022
9b476dc
more refractoring + sig processing test
rohankh532 Mar 21, 2022
b9e8575
fixed func call
rohankh532 Mar 21, 2022
7f7235a
fixed sign test
rohankh532 Mar 21, 2022
cb0d5b7
Merge branch 'main' into scorecard-cosign-api
rohankh532 Mar 22, 2022
9750ebb
style + error fmt
rohankh532 Mar 22, 2022
a69939a
Merge branch 'scorecard-cosign-api' of https://github.com/rohankh532/…
rohankh532 Mar 22, 2022
cd36758
Merge branch 'main' of https://github.com/rohankh532/scorecard-action…
rohankh532 Mar 30, 2022
afba93f
reverted dockerfile
rohankh532 Mar 30, 2022
61a12b0
style fixes
rohankh532 Mar 30, 2022
a432844
Merge branch 'main' into scorecard-cosign-api
rohankh532 Mar 30, 2022
f1d14c8
Merge branch 'main' into scorecard-cosign-api
rohankh532 Mar 31, 2022
c65fa57
lint fixes
rohankh532 Mar 31, 2022
39e5cda
Merge branch 'scorecard-cosign-api' of https://github.com/rohankh532/…
rohankh532 Mar 31, 2022
1402539
linting errs
rohankh532 Apr 5, 2022
e58dd60
Merge branch 'main' into scorecard-cosign-api
rohankh532 Apr 6, 2022
09b6704
test workflow permissions
rohankh532 Apr 11, 2022
9d3b726
debug print
rohankh532 Apr 11, 2022
72f2fc5
Merge branch 'main' into scorecard-cosign-api
azeemshaikh38 Apr 14, 2022
2fb31ce
commented out signing test
rohankh532 Apr 14, 2022
8a3b3c8
linting errors
rohankh532 Apr 14, 2022
a1cbb68
removed sarif results from processing & upload
rohankh532 Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
commented out signing test
  • Loading branch information
rohankh532 committed Apr 14, 2022
commit 2fb31ce4ce258a739e588c4701588c13a1434d85
102 changes: 50 additions & 52 deletions signing/signing_test.go
Original file line number Diff line number Diff line change
@@ -1,65 +1,63 @@
package signing

import (
"context"
"crypto/rand"
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/sigstore/cosign/cmd/cosign/cli/options"
"github.com/sigstore/cosign/cmd/cosign/cli/rekor"
"github.com/sigstore/cosign/pkg/cosign"
// "github.com/sigstore/cosign/cmd/cosign/cli/options"
// "github.com/sigstore/cosign/cmd/cosign/cli/rekor"
// "github.com/sigstore/cosign/pkg/cosign"
)

func Test_SignScorecardResult(t *testing.T) {
t.Parallel()
// Generate random bytes to use as our payload. This is done because signing identical payloads twice
// just creates multiple entries under it, so we are keeping this test simple and not comparing timestamps.
fmt.Println("ACTIONS_ID_TOKEN_REQUEST_TOKEN:")
fmt.Println(os.Getenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN"))
scorecardResultsFile := "./sign-random-data.txt"
randomData := make([]byte, 20)
if _, err := rand.Read(randomData); err != nil {
t.Errorf("signScorecardResult() error generating random bytes, %v", err)
return
}
if err := ioutil.WriteFile(scorecardResultsFile, randomData, 0o600); err != nil {
t.Errorf("signScorecardResult() error writing random bytes to file, %v", err)
return
}
// TODO: For this test to work, fake the OIDC token retrieval with something like:
// https://github.com/sigstore/cosign/blob/286bb0c58757009e99ab7080c720b30e51d08855/cmd/cosign/cli/fulcio/fulcio_test.go

// Sign example scorecard results file.
err := SignScorecardResult(scorecardResultsFile)
if err != nil {
t.Errorf("signScorecardResult() error, %v", err)
return
}
// func Test_SignScorecardResult(t *testing.T) {
// t.Parallel()
// // Generate random bytes to use as our payload. This is done because signing identical payloads twice
// // just creates multiple entries under it, so we are keeping this test simple and not comparing timestamps.
// fmt.Println("ACTIONS_ID_TOKEN_REQUEST_TOKEN:")
// fmt.Println(os.Getenv("ACTIONS_ID_TOKEN_REQUEST_TOKEN"))
// scorecardResultsFile := "./sign-random-data.txt"
// randomData := make([]byte, 20)
// if _, err := rand.Read(randomData); err != nil {
// t.Errorf("signScorecardResult() error generating random bytes, %v", err)
// return
// }
// if err := ioutil.WriteFile(scorecardResultsFile, randomData, 0o600); err != nil {
// t.Errorf("signScorecardResult() error writing random bytes to file, %v", err)
// return
// }

// Verify that the signature was created and uploaded to the Rekor tlog by looking up the payload.
ctx := context.Background()
rekorClient, err := rekor.NewClient(options.DefaultRekorURL)
if err != nil {
t.Errorf("signScorecardResult() error getting Rekor client, %v", err)
return
}
scorecardResultData, err := ioutil.ReadFile(scorecardResultsFile)
if err != nil {
t.Errorf("signScorecardResult() error reading scorecard result file, %v", err)
return
}
uuids, err := cosign.FindTLogEntriesByPayload(ctx, rekorClient, scorecardResultData)
if err != nil {
t.Errorf("signScorecardResult() error getting tlog entries, %v", err)
return
}
// // Sign example scorecard results file.
// err := SignScorecardResult(scorecardResultsFile)
// if err != nil {
// t.Errorf("signScorecardResult() error, %v", err)
// return
// }

if len(uuids) != 1 {
t.Errorf("signScorecardResult() error finding signature in Rekor tlog, %v", err)
return
}
}
// // Verify that the signature was created and uploaded to the Rekor tlog by looking up the payload.
// ctx := context.Background()
// rekorClient, err := rekor.NewClient(options.DefaultRekorURL)
// if err != nil {
// t.Errorf("signScorecardResult() error getting Rekor client, %v", err)
// return
// }
// scorecardResultData, err := ioutil.ReadFile(scorecardResultsFile)
// if err != nil {
// t.Errorf("signScorecardResult() error reading scorecard result file, %v", err)
// return
// }
// uuids, err := cosign.FindTLogEntriesByPayload(ctx, rekorClient, scorecardResultData)
// if err != nil {
// t.Errorf("signScorecardResult() error getting tlog entries, %v", err)
// return
// }

// if len(uuids) != 1 {
// t.Errorf("signScorecardResult() error finding signature in Rekor tlog, %v", err)
// return
// }
// }

// Test using scorecard results that have already been signed & uploaded.
func Test_ProcessSignature(t *testing.T) {
Expand Down