Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link & SLSA attestor #381

Merged
merged 35 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cadd809
Handle multiple results from run
jkjell Feb 4, 2024
7f3fade
Rename exportRun and add better file naming
jkjell Feb 5, 2024
a281b86
Run make docgen
jkjell Feb 5, 2024
b8df3d2
Update go version in actions and point go.mod to WIP go-witness
jkjell Feb 5, 2024
aeaa710
Add explicit setup-go action for workflows and change attestation fil…
jkjell Feb 5, 2024
898f1d3
Add back license scanning badge (#377)
jkjell Feb 6, 2024
eddb6fa
chore: bump github/codeql-action from 3.23.2 to 3.24.0 (#378)
dependabot[bot] Feb 13, 2024
f66b23f
chore: bump step-security/harden-runner from 2.6.1 to 2.7.0 (#379)
dependabot[bot] Feb 13, 2024
9bbdd77
chore: bump sigstore/cosign-installer from 3.3.0 to 3.4.0 (#380)
dependabot[bot] Feb 13, 2024
b9457d5
chore: bump actions/download-artifact from 4.1.1 to 4.1.2 (#382)
dependabot[bot] Feb 13, 2024
51ba5ba
chore: bump actions/upload-artifact from 4.3.0 to 4.3.1 (#383)
dependabot[bot] Feb 13, 2024
34a321d
Add Tom as a Witness maintainer (#385)
jkjell Feb 19, 2024
6d3e4cd
chore: bump testifysec/witness-run-action from 0.1.3 to 0.1.5 (#389)
dependabot[bot] Feb 19, 2024
a655347
chore: bump golangci/golangci-lint-action from 3.7.0 to 4.0.0 (#387)
dependabot[bot] Feb 19, 2024
0ed61ec
chore: bump fossas/fossa-action from 1.3.1 to 1.3.3 (#390)
dependabot[bot] Feb 19, 2024
7aa235b
chore: bump github/codeql-action from 3.24.0 to 3.24.3 (#391)
dependabot[bot] Feb 19, 2024
acd9a18
chore: bump actions/dependency-review-action from 4.0.0 to 4.1.1 (#392)
dependabot[bot] Feb 19, 2024
4ac175e
chore: bump actions/dependency-review-action from 4.1.1 to 4.1.3 (#395)
dependabot[bot] Feb 27, 2024
76970fe
chore: bump github/codeql-action from 3.24.3 to 3.24.5 (#396)
dependabot[bot] Feb 27, 2024
288d8ea
chore: bump actions/cache from 4.0.0 to 4.0.1 (#401)
dependabot[bot] Mar 5, 2024
7ba330a
chore: bump github/codeql-action from 3.24.5 to 3.24.6 (#400)
dependabot[bot] Mar 5, 2024
6b163ec
chore: bump actions/download-artifact from 4.1.2 to 4.1.4 (#399)
dependabot[bot] Mar 5, 2024
f1b310f
fix: run e2e test script as part of workflows (#397)
mikhailswift Mar 6, 2024
2fa6166
chore: bump github/codeql-action from 3.24.6 to 3.24.8 (#415)
dependabot[bot] Mar 20, 2024
ffcaa83
chore: bump docker/login-action from 3.0.0 to 3.1.0 (#413)
dependabot[bot] Mar 20, 2024
75da05f
chore: bump github/codeql-action from 3.24.8 to 3.24.9 (#419)
dependabot[bot] Mar 25, 2024
f1617cb
chore: bump actions/dependency-review-action from 4.1.3 to 4.2.4 (#420)
dependabot[bot] Mar 25, 2024
32a12e8
chore: bump actions/cache from 4.0.1 to 4.0.2 (#421)
dependabot[bot] Mar 25, 2024
fc695ef
Update dependabot.yml (#405)
jkjell Mar 26, 2024
80c02b9
chore: bump the all-gha group with 1 update (#426)
dependabot[bot] Mar 27, 2024
fc59d7e
Update GHA triggers to fine tune for code changes vs other updates (#…
jkjell Mar 27, 2024
537ee51
make docgen update
jkjell Apr 7, 2024
43e74f3
chore: bump the all-gha group with 2 updates (#431)
dependabot[bot] Apr 17, 2024
1373cea
Merge branch 'main' into link-attestor
jkjell May 9, 2024
bd1efde
Fix breaks from go-witness updates
jkjell May 9, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.21.x
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
Expand Down
54 changes: 30 additions & 24 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ func runRun(ctx context.Context, ro options.RunOptions, args []string, signers .
return fmt.Errorf("no signers found")
}

out, err := loadOutfile(ro.OutFilePath)
if err != nil {
return fmt.Errorf("failed to open out file: %w", err)
}

timestampers := []timestamp.Timestamper{}
for _, url := range ro.TimestampServers {
timestampers = append(timestampers, timestamp.NewTimestamper(timestamp.TimestampWithUrl(url)))
Expand Down Expand Up @@ -117,7 +112,7 @@ func runRun(ctx context.Context, ro options.RunOptions, args []string, signers .
continue
}

attestor, err = registry.SetOptions(attestor, setters...)
attestor, err := registry.SetOptions(attestor, setters...)
if err != nil {
return fmt.Errorf("failed to set attestor option for %v: %w", attestor.Type(), err)
}
Expand All @@ -132,36 +127,47 @@ func runRun(ctx context.Context, ro options.RunOptions, args []string, signers .
roHashes = append(roHashes, cryptoutil.DigestValue{Hash: hash, GitOID: false})
}

defer out.Close()
result, err := witness.Run(
results, err := witness.RunWithExports(
ro.StepName,
signers[0],
witness.RunWithAttestors(attestors),
witness.RunWithAttestationOpts(attestation.WithWorkingDir(ro.WorkingDir), attestation.WithHashes(roHashes)),
witness.RunWithTimestampers(timestampers...),
witness.RunWithSigners(signers...),
)
if err != nil {
return err
}

signedBytes, err := json.Marshal(&result.SignedEnvelope)
if err != nil {
return fmt.Errorf("failed to marshal envelope: %w", err)
}
for _, result := range results {
signedBytes, err := json.Marshal(&result.SignedEnvelope)
if err != nil {
return fmt.Errorf("failed to marshal envelope: %w", err)
}

log.Infof("Writing signed envelope to %s\n", ro.OutFilePath)
if _, err := out.Write(signedBytes); err != nil {
return fmt.Errorf("failed to write envelope to out file: %w", err)
}
// TODO: Find out explicit way to describe "prefix" in CLI options
outfile := ro.OutFilePath
if result.AttestorName != "" {
jkjell marked this conversation as resolved.
Show resolved Hide resolved
outfile += "-" + result.AttestorName + ".json"
}

if ro.ArchivistaOptions.Enable {
archivistaClient := archivista.New(ro.ArchivistaOptions.Url)
if gitoid, err := archivistaClient.Store(ctx, result.SignedEnvelope); err != nil {
return fmt.Errorf("failed to store artifact in archivista: %w", err)
} else {
log.Infof("Stored in archivista as %v\n", gitoid)
out, err := loadOutfile(outfile)
if err != nil {
return fmt.Errorf("failed to open out file: %w", err)
}
defer out.Close()

if _, err := out.Write(signedBytes); err != nil {
return fmt.Errorf("failed to write envelope to out file: %w", err)
}
}

if ro.ArchivistaOptions.Enable {
archivistaClient := archivista.New(ro.ArchivistaOptions.Url)
if gitoid, err := archivistaClient.Store(ctx, result.SignedEnvelope); err != nil {
return fmt.Errorf("failed to store artifact in archivista: %w", err)
} else {
log.Infof("Stored in archivista as %v\n", gitoid)
}
}
}
return nil
}
6 changes: 3 additions & 3 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func runVerify(ctx context.Context, vo options.VerifyOptions, verifiers ...crypt
}
}

verifiedEvidence, err := witness.Verify(
verifiedResult, err := witness.Verify(
ctx,
policyEnvelope,
verifiers,
Expand All @@ -138,8 +138,8 @@ func runVerify(ctx context.Context, vo options.VerifyOptions, verifiers ...crypt
log.Info("Verification succeeded")
log.Info("Evidence:")
num := 0
for _, stepEvidence := range verifiedEvidence {
for _, e := range stepEvidence {
for _, stepEvidence := range verifiedResult.StepResults {
for _, e := range stepEvidence.Passed {
log.Info(fmt.Sprintf("%d: %s", num, e.Reference))
num++
}
Expand Down
2 changes: 2 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ witness run [cmd] [flags]
```
--archivista-server string URL of the Archivista server to store or retrieve attestations (default "https://archivista.testifysec.io")
-a, --attestations strings Attestations to record ('product' and 'material' are always recorded) (default [environment,git])
--attestor-link-export Export the Link predicate in its own attestation
--attestor-maven-pom-path string The path to the Project Object Model (POM) XML file used for task being attested (default "pom.xml"). (default "pom.xml")
--attestor-product-exclude-glob string Pattern to use when recording products. Files that match this pattern will be excluded as subjects on the attestation.
--attestor-product-include-glob string Pattern to use when recording products. Files that match this pattern will be included as subjects on the attestation. (default "*")
--attestor-slsa-export Export the SLSA provenance predicate in its own attestation
--enable-archivista Use Archivista to store or retrieve attestations
--hashes strings Hashes selected for digest calculation. Defaults to SHA256 (default [sha256])
-h, --help help for run
Expand Down
88 changes: 45 additions & 43 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.22.2

require (
github.com/in-toto/go-witness v0.3.1
github.com/in-toto/go-witness v0.3.2-0.20240509152614-87975b4168e0
github.com/olekukonko/tablewriter v0.0.5
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
Expand All @@ -16,43 +16,43 @@ require (
)

require (
github.com/coreos/go-oidc/v3 v3.9.0 // indirect
github.com/coreos/go-oidc/v3 v3.10.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.7 // indirect
github.com/zclconf/go-cty v1.14.2 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
)

require (
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/kms v1.15.7 // indirect
cloud.google.com/go/auth v0.3.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
cloud.google.com/go/kms v1.15.9 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/aws/aws-sdk-go v1.50.27 // indirect
github.com/aws/aws-sdk-go-v2 v1.25.2 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.4 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.4 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.15.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.2 // indirect
github.com/aws/aws-sdk-go v1.50.38 // indirect
github.com/aws/aws-sdk-go-v2 v1.26.1 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.11 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.11 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.29.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.28.1 // indirect
github.com/aws/smithy-go v1.20.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 // indirect
github.com/aws/aws-sdk-go-v2/service/kms v1.31.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect
github.com/aws/smithy-go v1.20.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
Expand All @@ -70,6 +70,7 @@ require (
github.com/go-git/go-git/v5 v5.11.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
Expand All @@ -81,14 +82,15 @@ require (
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.1 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/hashicorp/hcl v1.0.1-vault-3 // indirect
github.com/in-toto/archivista v0.4.0 // indirect
github.com/in-toto/attestation v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jellydator/ttlcache/v3 v3.1.1 // indirect
github.com/jellydator/ttlcache/v3 v3.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/letsencrypt/boulder v0.0.0-20240226214708-a97e074b5a3e // indirect
Expand All @@ -106,16 +108,16 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/common v0.51.1 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.8.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sigstore/fulcio v1.4.4 // indirect
github.com/sigstore/sigstore v1.8.1 // indirect
github.com/sigstore/fulcio v1.4.5 // indirect
github.com/sigstore/sigstore v1.8.3 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
Expand All @@ -130,29 +132,29 @@ require (
github.com/yashtewari/glob-intersection v0.2.0 // indirect
github.com/zeebo/errs v1.3.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.48.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/api v0.167.0 // indirect
google.golang.org/genproto v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/api v0.177.0 // indirect
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading
Loading