Skip to content

Commit

Permalink
Chore/upstream go witness (#4)
Browse files Browse the repository at this point in the history
* Initial commit

* chore: Configure SAST in `.gitlab-ci.yml`, creating this file if it does not already exist

* chore: initial commit of judge monorepo core projects

* chore: Set up our new home for product and development planning (in-toto#7)

chore: Set up our new home for product development and onboarding

Fixes #1
Fixes #2
removed spire k8s

* fix(web): friendly errors

fixes in-toto#19

* chore: Added issue templates for additional issue types

closes in-toto#16 a bit further, had some idle time

* chore: Added issue templates for epic and feature

* chore: update Judge monorepo with latest judge-api change delta

* story: As a user I want a simple and intuitive sign-in flow

fixes in-toto#20

Now when the user registers with their github, they are automatically signed in

* docs(web): added todo to move sorting logic that shouldn't be in frontend

* fix(web): the dashboard attestation results should belong to the repo they are associated with

fixes in-toto#18

* chore(web): remove of .old web ui

* fix(web): tests all pass

fixes in-toto#31

* chore: implemented prepush-if-changed so that we can only run tests for things on push if we actually changed them

* chore: implemented prepush test githooks for all go subprojectsg

* docs: wrote docs for our githooks

* chore: sorted our root package.json scripts

* feat: add proxies to production services for netlify deployments (in-toto#34)

Sets up proxies to archivista, judge-api, kratos, and login from
netlify deployments to our production instances of these. Eventually we
may need to break these out to short lived versions of the back end
services.

Fixes in-toto#33

* fix: adds missing wildcards to netlify redirects

Netlify was only doing redirects for exact matches of `/archivista` or
`/login`, where we want all paths to be redirected to those services.

Fixes in-toto#33

* fix: tell kratos to return us to our current judge web instance

* chore: implemented conventioanal-commits with commitlint

* docs: updated githooks documentation for conventional commits

* chore: implemented git-conventional-commits

this helps enable generating our versions and changelog from our git tree

helps close in-toto#9

* fix: githooks should be frictionless 

subtasks:
fix: prepush-if-changed shouldn't run node tests if node files aren't touched
chore: update commitlint to allow for bypassing with 'wip'
fix: prepushrc for node and go prepush test hook
chore: updates to commitlint for longer messages

fixes in-toto#40

if a ops developer contributed code but had not run `npm run start:web` on the web project to produce the graphql cache, then linting would fail.

Rather than ask ops devs to make sure they start the web app every now and then, we have addressed this by making the graphql cache optional.

* chore: updated subtree scripts

* Squashed 'subtrees/witness/' content from commit cc2478e

git-subtree-dir: subtrees/witness
git-subtree-split: cc2478e854c6dd91cc6b20ed3baa6ba47dbadb3f

* Squashed 'subtrees/archivista/' content from commit 21ab99d

git-subtree-dir: subtrees/archivista
git-subtree-split: 21ab99d5c42737eb9526ac43e51e460f74436685

* Squashed 'subtrees/go-witness/' content from commit 31e6790

git-subtree-dir: subtrees/go-witness
git-subtree-split: 31e6790

* chore: move subtrees to subtrees/ subfolder

closes in-toto#27

updated dev environment and githooks to work with new subtrees subfolder
updated docs on subtrees

* chore: upgrade kratos to v13.0 (in-toto#55)

chore: upgrade kratos

* fix: tests fail if you run npm build instead of npm start before testing

fixes in-toto#56

* chore(web): implement node workflow to github workflows

closes in-toto#60

allows us to build and test our web project from the monorepo as on changes to our trunk (`main`)

Signed-off-by: Kris Coleman <[email protected]>

* feat: implemented metadata webhook in kratos for updating tenant metadata

closes in-toto#28

* feat: upgrade kratos ui

* Squashed 'subtrees/witness-run-action/' content from commit bdd8272

git-subtree-dir: subtrees/witness-run-action
git-subtree-split: bdd82729b316d071606007cc9eecae326429caaf

* chore: updated conventional-commit to support subtree type

* subtree(witness-run-action): onboarded the witness-run-action to the monorepo 

closes in-toto#70

* chore: updated download-compress-witness.sh to support macos

* chore: updated how we push subtrees to a smarter approach

now we don't push directly to main... we should just make a new branch off our trunk before we push using the provided scripts. this will push a clean branch of just the subtree changes to the subtree.

* chore(web): update the yo generators to work with monorepo OOTB

also improved cli wordage

* feat(web): implemented RepoCard

RepoCard provides a reusable component for showing a repo with a Card view

* feat(web): implemented CommitLink component

provides a reusable commit for displaying a Commit

* story: as a user, anytime I click on a git sha, I want to copy it the clipboard

* ops(go): implement go ci workflow to github workflows

closes in-toto#62

* chore: dogfood the witness-run-action on the monorepo

closes in-toto#22

* subtree(witness-run-action): updated docs to help users with generating attestations in monorepos

* subtree(witness): updated `run` docs to help users with generating attestations in monorepos

* subtree(witness): updated `run` docs to help users with generating attestations with npm

* ops: renamed web.yaml to node.yml

* chore(judge-api): use logrus directly

* chore(archivista): use logrus directly

* fix(archivista): update archivista's usage of updated go-witness function

* feat(monorepo): add go workspace file to monorepo

* chore(judge-api): rename go module

* fix(monorepo): update witness-run-action version used

* chore(deps): bump yaml in /subtrees/witness-run-action

Bumps [yaml](https://github.com/eemeli/yaml) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/eemeli/yaml/releases)
- [Commits](eemeli/yaml@v2.2.1...v2.2.2)

---
updated-dependencies:
- dependency-name: yaml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(judge-api): support multiple database providers

* fix(witness): witness should not error on an empty git repo with no commits
Fixes in-toto#121

* chore: make skaffold config modular

* chore: add skaffold README

* chore(policy): implemented struct representing a decision on a policy

* feat(policy): judge-api has a endpoint for submitting witness verify results and stores them

* refactor(witness): use generic registry for attestor options

* refactor(go-witness): use generic registry for attestor options

* feat(go-witness): add signer provider registry

* refactor: add SetOptions helper to registry, fix return values in some signer's option funcs

* feat(witness): use signer registry to setup signers for CLI flags

* docs(witness): regenerate docs for new cli flags

* fix: use go mod download in install scripts for go modules

* feat(go-witness): add time.Duration option for registries

* feat(go-witness): add vault pki signer provider

* refactor(witness): create helper function to add options from registries

* docs(witness): regenerate docs for new cli flags

* fix(witness): re-enable verify tests

As part of the signer registry refactor I commented these tests out to
work on some other tests. Turns out I forgot to uncomment and fix these
before merging the refactor... Ooops.

* fix: fix remotes:add:all script

* Squashed 'subtrees/witness/' changes from cc2478e..8a53d68

8a53d68 fix: update github actions to use new fulcio url
2dc9401 fix: update goreleaser action to use go 1.20.x
9bac7df chore(deps): bump github.com/cloudflare/circl from 1.3.2 to 1.3.3
57b29fd feat: publish ko built images to ghcr
bde414e fix: use witness-run-action instead of testifysec-run-action
58b3f59 fix: update scorecard version to fix invalid key error

git-subtree-dir: subtrees/witness
git-subtree-split: 8a53d681de06d9a447210841c1e96e03b6c2edfb

* feat(policy, witness): added decisionLogUrl argument to verify

* feat(policy, go-witness): implemented decisionLogUrl and also implemented the policydecision cloudevent posting to decision log provider

* Squashed 'subtrees/witness/' changes from 8a53d68..be20100

be20100 fix: dev/Dockerfile.go-builder to reduce vulnerabilities
aa35c1f fix: update changed signer flags in tests
f7d7e96 fix: use the pflag.FlagSet.Set function to set values from config files
03ab65f fix: re-enable verify tests
5bf31d7 docs: regenerate docs for new cli flags
d713711 refactor: create helper function to add options from registries
88a8d93 docs: regenerate docs for new cli flags
4a41144 feat: use signer registry to setup signers for CLI flags
0c7a4e5 refactor: use generic registry for attestor options

git-subtree-dir: subtrees/witness
git-subtree-split: be20100af602c780deeef50c54f5338662ce917c

* Revert "feat(policy, go-witness): implemented decisionLogUrl and also implemented the policydecision cloudevent posting to decision log provider"

This reverts commit 21d6a66b5be18a9a165d18ce0528c8fbcf4ebd79.

* Revert "feat(policy): judge-api has a endpoint for submitting witness verify results and stores them"

This reverts commit f178afe.

* Revert "chore(policy): implemented struct representing a decision on a policy"

This reverts commit 627a7a2.

* Squashed 'subtrees/witness/' changes from be20100..06031da

06031da Checking attestors for duplicates (in-toto#361)
1a9b5a2 Initial attempt at PR and Issue templates (in-toto#351)
83ca942 chore: bump actions/download-artifact from 4.1.0 to 4.1.1 (in-toto#358)
63cc5d8 chore: bump github/codeql-action from 3.22.12 to 3.23.0 (in-toto#357)
70e0b09 chore: bump actions/upload-artifact from 4.0.0 to 4.1.0 (in-toto#356)
d2471e6 chore: bump actions/cache from 3.3.2 to 3.3.3 (in-toto#355)
f2e2a6f Update cloudflare/circl due to dependabot failure (in-toto#352)
abce18b Add cosign install
15d9014 Add signing to goreleaser and Best Practices badge to readme.
93768db Pin dependencies and restrict permissions
494d44a Add Security MD files an add FOSSA scan badge
b9e38d5 Add FOSSA license scanning
617e15a chore: bump actions/dependency-review-action from 3.1.4 to 3.1.5 (in-toto#349)
2c590bb Update go-git to resolve vulnerability (in-toto#346)
88881fa chore: bump actions/download-artifact from 4.0.0 to 4.1.0 (in-toto#342)
ea67d31 chore: bump github/codeql-action from 3.22.11 to 3.22.12 (in-toto#343)
b8f36d6 chore: bump actions/upload-artifact from 3.1.3 to 4.0.0 (in-toto#337)
34563ab chore: bump github/codeql-action from 2.22.9 to 3.22.11 (in-toto#336)
46b168d chore: bump actions/download-artifact from 3.0.2 to 4.0.0 (in-toto#335)
b36c96d Bumping Go version for goreleaser (in-toto#333)
c06555d Migrating to the use of in-toto/go-witness module (in-toto#331)
c0f5843 Migrating go module (in-toto#328)
937eab8 Adding the contributing.md from archivista (in-toto#327)
f0c8f43 Adding help to Makefile and updating `make test` target (in-toto#325)
71856fd chore: bump actions/dependency-review-action from 2.5.1 to 3.1.4 (in-toto#324)
709ad35 chore: bump github/codeql-action from 2.22.8 to 2.22.9 (in-toto#323)
684fd6a chore: bump actions/setup-go from 4.1.0 to 5.0.0 (in-toto#322)
a823f58 chore: bump actions/checkout from 3.6.0 to 4.1.1 (in-toto#321)
862d8c4 chore: bump actions/upload-artifact from 3.0.0 to 3.1.3 (in-toto#320)
b19afc8 Fix initial pre-commit violations (in-toto#319)
a56715e Refactoring error messages to use `%w` formatting directive and fix logging issue (in-toto#314)
0bca967 feat: add algo hash list for digest calc in config (in-toto#292)
81bdfce Improve gha (in-toto#318)
f65b232 [StepSecurity] Apply security best practices (in-toto#316)
bcf7ecf Update README.md - fixing quickstart url
8dde14c docs: correct sign policy file command in README.md
752b9e0 chore: bump github/codeql-action from 2.22.7 to 2.22.8
15bec9e chore: bump github.com/go-jose/go-jose/v3 from 3.0.0 to 3.0.1
0363ee3 chore: bump actions/setup-go from 2 to 4
a412c18 chore: bump actions/cache from 2 to 3
e7a6f44 chore: bump github/codeql-action from 2.22.6 to 2.22.7
932ff1e chore: bump actions/checkout from 2 to 4 (in-toto#301)
5e56558 chore: bump github.com/stretchr/testify from 1.8.1 to 1.8.4 (in-toto#305)
f49ff8e chore: bump github.com/sirupsen/logrus from 1.9.0 to 1.9.3 (in-toto#304)
873f55c chore: bump golangci/golangci-lint-action from 2 to 3 (in-toto#303)
1880baa chore: bump ossf/scorecard-action from 2.1.3 to 2.3.1 (in-toto#302)
9380cbe chore: bump github/codeql-action from 1.0.26 to 2.22.6 (in-toto#300)
21cb944 chore: bump docker/login-action from 2 to 3 (in-toto#299)
2219a76 fix: updating urls to `in-toto` from `testifysec` and `-L` to the curl for version (in-toto#297)
b3d7207 Add dependabot config and add reusable workflow for calling witness (in-toto#298)
5beb113 Add maintainers file
602dc48 chore(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3
edef808 docs: Update key to signer-file-key-path in getting starter .witness.yaml
8e9d798 fix: dev/Dockerfile.go-builder to reduce vulnerabilities
27f68b9 chore(deps): bump golang.org/x/net from 0.7.0 to 0.17.0

git-subtree-dir: subtrees/witness
git-subtree-split: 06031da4459ee4aea13ee83c59f9dee8171133ff

* Squashed 'subtrees/witness/' changes from 06031da4..74f6c3dc

74f6c3dc chore: bump the all-go-mod group with 1 update (#425)
bed18639 Update GHA triggers to fine tune for code changes vs other updates (#406)
6f7d4a80 Adding ability to list attestors (in-toto#384)
1fbdaa9b chore: bump the all-gha group with 1 update (#426)
90cb5acb Update dependabot.yml (#405)
c86b46dc small typo fix (#424)
f5deef58 chore: bump express from 4.18.3 to 4.19.2 in /docs-website (#423)
6bec1817 chore: bump actions/cache from 4.0.1 to 4.0.2 (#421)
78f1a7b6 chore: bump actions/dependency-review-action from 4.1.3 to 4.2.4 (#420)
2b4213f1 chore: bump github/codeql-action from 3.24.8 to 3.24.9 (#419)
fe61acd7 chore: bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /docs-website (#417)
917e13b5 chore: bump docker/login-action from 3.0.0 to 3.1.0 (#413)
b1ee6814 chore: bump github/codeql-action from 3.24.6 to 3.24.8 (#415)
10f895d4 chore: bump actions/checkout from 4.1.1 to 4.1.2 (#412)
1844b269 chore: bump k8s.io/apimachinery from 0.29.2 to 0.29.3 (#411)
7528df2d chore: bump follow-redirects from 1.15.5 to 1.15.6 in /docs-website (#410)
3fc10e4e chore: bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (#409)
bb8b3c07 chore: bump the go_modules group group with 2 updates (#408)
910d630e Witness website netlify (in-toto#394)
a4c40293 doc: fix example in signers kms doc (in-toto#403)
09f8cbb2 fix: run e2e test script as part of workflows (in-toto#397)
e54d8be3 chore: bump actions/download-artifact from 4.1.2 to 4.1.4 (in-toto#399)
feac3aa7 chore: bump github/codeql-action from 3.24.5 to 3.24.6 (in-toto#400)
3c8d14d6 chore: bump actions/cache from 4.0.0 to 4.0.1 (in-toto#401)
997af3b5 Bump to go-witness v0.3.1 (in-toto#398)
dcac011c chore: bump github/codeql-action from 3.24.3 to 3.24.5 (in-toto#396)
c211bfee chore: bump actions/dependency-review-action from 4.1.1 to 4.1.3 (in-toto#395)
0df242bb chore: bump actions/dependency-review-action from 4.0.0 to 4.1.1 (in-toto#392)
db7a2664 chore: bump github/codeql-action from 3.24.0 to 3.24.3 (in-toto#391)
161286db chore: bump fossas/fossa-action from 1.3.1 to 1.3.3 (in-toto#390)
f772f2db chore: bump golangci/golangci-lint-action from 3.7.0 to 4.0.0 (in-toto#387)
001a113b chore: bump k8s.io/apimachinery from 0.26.13 to 0.26.14 (in-toto#386)
e438568f chore: bump testifysec/witness-run-action from 0.1.3 to 0.1.5 (in-toto#389)
17bdb4ed Add Tom as a Witness maintainer (in-toto#385)
c27a4f56 KMS Support (in-toto#376)
be37eeee chore: bump actions/upload-artifact from 4.3.0 to 4.3.1 (in-toto#383)
58fe0939 chore: bump actions/download-artifact from 4.1.1 to 4.1.2 (in-toto#382)
1144fa56 chore: bump sigstore/cosign-installer from 3.3.0 to 3.4.0 (in-toto#380)
3195add2 chore: bump step-security/harden-runner from 2.6.1 to 2.7.0 (in-toto#379)
2923f967 chore: bump github/codeql-action from 3.23.2 to 3.24.0 (in-toto#378)
0e7dda92 Add back license scanning badge (in-toto#377)
dfd64fe7 Updated witness to use changes made to `cryptoutil.DigestValue` implemented in go-witness (in-toto#371)
58d5516f chore: bump github/codeql-action from 3.23.1 to 3.23.2 (in-toto#370)
cd18d5eb chore: bump actions/upload-artifact from 4.2.0 to 4.3.0 (in-toto#369)
1bbd0e84 Updating timestamper (in-toto#367)
df179e2e Fixing mistakes in the readme (in-toto#368)
b90f41ba README and docs restructure (in-toto#362)
2b872a34 chore: bump actions/dependency-review-action from 3.1.5 to 4.0.0 (in-toto#366)
9247c817 chore: bump github/codeql-action from 3.23.0 to 3.23.1 (in-toto#365)
55418b54 chore: bump actions/upload-artifact from 4.1.0 to 4.2.0 (in-toto#363)
272e492b chore: bump actions/cache from 3.3.3 to 4.0.0 (in-toto#364)

git-subtree-dir: subtrees/witness
git-subtree-split: 74f6c3dcb07ad6b6c2e67eede125bca3ef302793

* chore(go-witness): update go-witness to use new store with http client methods

* chore: onboarding aws and localstack

chore(aws): refactor account numbers and regions to be set in cdk.json
feat(aws): judge-container-stack and eks construct
feat(aws): judge container stack
feat(aws): added s3 bucket
feat(aws): codebuild stack
feat(aws): judge aws self-mutating pipeline
feat(aws): new release action

* chore(deps): bump the go_modules group across 3 directories with 3 updates

Bumps the go_modules group with 3 updates in the /judge-api directory: [github.com/go-jose/go-jose/v3](https://github.com/go-jose/go-jose), [golang.org/x/net](https://github.com/golang/net) and gopkg.in/go-jose/go-jose.v2.
Bumps the go_modules group with 1 update in the /subtrees/archivista directory: [golang.org/x/net](https://github.com/golang/net).
Bumps the go_modules group with 1 update in the /subtrees/go-witness directory: [golang.org/x/net](https://github.com/golang/net).


Updates `github.com/go-jose/go-jose/v3` from 3.0.2 to 3.0.3
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Changelog](https://github.com/go-jose/go-jose/blob/v3.0.3/CHANGELOG.md)
- [Commits](go-jose/go-jose@v3.0.2...v3.0.3)

Updates `golang.org/x/net` from 0.23.0 to 0.24.0
- [Commits](golang/net@v0.23.0...v0.24.0)

Updates `gopkg.in/go-jose/go-jose.v2` from 2.6.2 to 2.6.3

Updates `golang.org/x/net` from 0.22.0 to 0.23.0
- [Commits](golang/net@v0.23.0...v0.24.0)

Updates `golang.org/x/net` from 0.22.0 to 0.23.0
- [Commits](golang/net@v0.23.0...v0.24.0)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v3
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: gopkg.in/go-jose/go-jose.v2
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <[email protected]>

* subtree(go-witness): add git refs to go witness git attestor

* chore(deps): bump the go_modules group across 3 directories with 2 updates

Bumps the go_modules group with 2 updates in the /judge-api directory: [golang.org/x/net](https://github.com/golang/net) and google.golang.org/protobuf.
Bumps the go_modules group with 2 updates in the /subtrees/go-witness directory: [golang.org/x/net](https://github.com/golang/net) and google.golang.org/protobuf.
Bumps the go_modules group with 2 updates in the /subtrees/witness directory: [golang.org/x/net](https://github.com/golang/net) and google.golang.org/protobuf.


Updates `golang.org/x/net` from 0.24.0 to 0.25.0
- [Commits](golang/net@v0.24.0...v0.25.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.34.1

Updates `golang.org/x/net` from 0.23.0 to 0.25.0
- [Commits](golang/net@v0.24.0...v0.25.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.34.1

Updates `golang.org/x/net` from 0.23.0 to 0.25.0
- [Commits](golang/net@v0.24.0...v0.25.0)

Updates `google.golang.org/protobuf` from 1.33.0 to 1.34.1

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  dependency-group: go_modules
- dependency-name: golang.org/x/net
  dependency-type: indirect
  dependency-group: go_modules
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <[email protected]>

* Squashed 'subtrees/witness/' changes from 74f6c3dcb..47b6e1cc1

47b6e1cc1 chore: bump github.com/spf13/viper from 1.18.2 to 1.19.0 in the all-go-mod group (#462)
3d08ed511 chore: bump the all-gha group with 2 updates (#461)
308aee9db Added generation of SBOM (#451)
f499ffbc7 docs(getting-started): add information about slsa attestor (#456)
b495cf739 fix(install-witness.sh): ensure compatibility with macOS for checksum verification (#459)
fa443884a Adding Signers section to website sidebar (#460)
6ab0464f5 Updating yarn and modifying ignore on netlify toml (#455)
d9733deea chore: bump the all-gha group with 2 updates (#457)
bb49495ad Changed all the broken links (#453)
16beb9e7f chore: bump k8s.io/apimachinery from 0.30.0 to 0.30.1 in the all-go-mod group (#450)
1b286b7a6 chore: bump the all-gha group with 2 updates (#449)
cb6a006bb Updating go-witness to v0.4.0 (#447)
405a64ddd Adding collection concept to docs and fixing code snippet formatting in md (#445)
b951db3fe Fixing CA Path Flag to be used and adding policy timestamp server flag (in-toto#353)
53aa6ade1 chore: bump the all-gha group with 5 updates (#444)
8e1f2fcda Attestor json schema (#443)
d866f90e8 Improving Verify Error Response (#430)
fc4849443 Link & SLSA attestor (in-toto#381)
0cd05b61f feat: Enable Witness Policy verify from Archivista (#438)
3a926efa6 chore: bump the all-gha group with 4 updates (#440)
7ba97fc2c Fixing incorrect error message on Verify (in-toto#350)
fb1519143 chore: bump k8s.io/apimachinery from 0.29.3 to 0.30.0 in the all-go-mod group (#433)
a099009e2 chore: bump the all-gha group with 5 updates (#435)
aa955f000 chore: bump the all-gha group with 4 updates (#434)
58c8f0708 chore: bump golang.org/x/net from 0.21.0 to 0.23.0 in the go_modules group (#432)
406b2bdba chore: bump the all-gha group with 2 updates (#431)

git-subtree-dir: subtrees/witness
git-subtree-split: 47b6e1cc1cdb55b2eb4c5610111514a737ccb4be

* feat: implemented dapr workflow engine and vulnerability scanning in JUDGE

Co-Authored-by: chaosinthecrd <[email protected]>

Signed-off-by: chaosinthecrd <[email protected]>

* Squashed 'subtrees/witness/' changes from 47b6e1cc..f07725e5

f07725e5 refactor: make all run options have shorthand vars (#441)
f5f2ae60 Add logging of passed step if found during policy failure (#454)
54e8d188 fix: temporarily disable omnitrail on windows builds (#467)
f5b0e7b6 Remove Windows Arm64 build until fixed (#466)
c1352bd7 SBOM and Omnitrail Attestor (#464)
460f0401 chore: bump the all-gha group with 3 updates (#463)

git-subtree-dir: subtrees/witness
git-subtree-split: f07725e52356cdfe9bf113b2054521b923aef5d8

* feat(go-witness): add vex attestor

Co-authored-by: Nick Kane <[email protected]>

---------

Signed-off-by: Kris Coleman <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: chaosinthecrd <[email protected]>
Signed-off-by: John Kjell <[email protected]>
Co-authored-by: Mikhail Swift <[email protected]>
Co-authored-by: Mikhail Swift <[email protected]>
Co-authored-by: David Lake <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Cole <[email protected]>
Co-authored-by: Nick Kane <[email protected]>
Co-authored-by: John Kjell <[email protected]>
Co-authored-by: Nick Kane <[email protected]>
  • Loading branch information
9 people authored Jun 15, 2024
1 parent 4f3e5c4 commit 189c426
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 12 deletions.
2 changes: 1 addition & 1 deletion archivista/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

func (c *Client) Store(ctx context.Context, env dsse.Envelope) (string, error) {
resp, err := archivistaapi.Upload(ctx, c.url, env)
resp, err := archivistaapi.Store(ctx, c.url, env)

Check failure on line 25 in archivista/store.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: archivistaapi.Store is deprecated: Use Upload instead. It will be removed in version >= v0.6.0 (staticcheck)
if err != nil {
return "", err
}
Expand Down
33 changes: 31 additions & 2 deletions attestation/link/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ func TestAttest(t *testing.T) {

testJson := []byte(testLinkJSON)
if !bytes.Equal(linkJson, testJson) {
t.Errorf("expected \n%s\n, got \n%s\n", testJson, linkJson)
testJson := []byte(testLinkJSONAlternative)
if !bytes.Equal(linkJson, testJson) {
t.Errorf("expected \n%s\n, got \n%s\n", testJson, linkJson)
}
}
}

Expand Down Expand Up @@ -178,6 +181,7 @@ func setupLink(t *testing.T) *Link {

return link
}

func TestRegistration(t *testing.T) {
registrations := attestation.RegistrationEntries()

Expand All @@ -191,7 +195,6 @@ func TestRegistration(t *testing.T) {
if !found {
t.Errorf("expected %s to be registered", Name)
}

}

const testLinkJSON = `{
Expand Down Expand Up @@ -219,3 +222,29 @@ const testLinkJSON = `{
"COLORTERM": "truecolor"
}
}`

const testLinkJSONAlternative = `{
"name": "test",
"command": [
"touch",
"test.txt"
],
"materials": [
{
"name": "test1",
"digest": {
"sha256": "a53d0741798b287c6dd7afa64aee473f305e65d3f49463bb9d7408ec3b12bf5f"
}
},
{
"name": "test2",
"digest": {
"sha256": "a53d0741798b287c6dd7afa64aee473f305e65d3f49463bb9d7408ec3b12bf5f"
}
}
],
"environment": {
"COLORFGBG": "7;0",
"COLORTERM": "truecolor"
}
}`
5 changes: 5 additions & 0 deletions attestation/product/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ func getFileContentType(fileName string) (string, error) {
return bytes.HasPrefix(buf, []byte(`<?xml version="1.0" encoding="UTF-8"?><bom xmlns="http://cyclonedx.org/schema/bom/`))
}, "application/vnd.cyclonedx+xml", ".cdx.xml")

// Add Vex JSON detector
mimetype.Lookup("application/json").Extend(func(buf []byte, limit uint32) bool {
return bytes.HasPrefix(buf, []byte(`{"@context":"https://openvex.dev/ns`))
}, "application/vex+json", ".vex.json")

contentType, err := mimetype.DetectFile(fileName)
if err != nil {
return "", err
Expand Down
14 changes: 7 additions & 7 deletions attestation/slsa/slsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestAttest(t *testing.T) {
// Setup OCI
o := attestors.NewTestOCIAttestor()

var tests = []struct {
tests := []struct {
name string
attestors []attestation.Attestor
expectedJson string
Expand All @@ -140,9 +140,9 @@ func TestAttest(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Logf("Running test %s", test.name)
s := New()
slsaAttestor := New()

ctx, err := attestation.NewContext("test", append(test.attestors, s))
ctx, err := attestation.NewContext("test", append(test.attestors, slsaAttestor))
if err != nil {
t.Errorf("error creating attestation context: %s", err)
}
Expand All @@ -154,17 +154,17 @@ func TestAttest(t *testing.T) {

// TODO: We don't have a way to mock out times on attestor runs
// Set attestor times manually to match testProvenanceJSON
s.PbProvenance.RunDetails.Metadata.StartedOn = &timestamppb.Timestamp{
slsaAttestor.PbProvenance.RunDetails.Metadata.StartedOn = &timestamppb.Timestamp{
Seconds: 1711199861,
Nanos: 560152000,
}
s.PbProvenance.RunDetails.Metadata.FinishedOn = &timestamppb.Timestamp{
slsaAttestor.PbProvenance.RunDetails.Metadata.FinishedOn = &timestamppb.Timestamp{
Seconds: 1711199861,
Nanos: 560152000,
}

var prov []byte
if prov, err = json.MarshalIndent(s, "", " "); err != nil {
if prov, err = json.MarshalIndent(slsaAttestor, "", " "); err != nil {
t.Errorf("unexpected error: %s", err)
}

Expand Down Expand Up @@ -221,6 +221,7 @@ func setupProvenance(t *testing.T) *Provenance {

return provenance
}

func TestRegistration(t *testing.T) {
registrations := attestation.RegistrationEntries()

Expand All @@ -234,7 +235,6 @@ func TestRegistration(t *testing.T) {
if !found {
t.Errorf("expected %s to be registered", Name)
}

}

const testGHProvJSON = `{
Expand Down
122 changes: 122 additions & 0 deletions attestation/vex/vex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright 2024 The Witness Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package vex

import (
"encoding/json"
"fmt"
"io"
"os"

"github.com/in-toto/go-witness/attestation"
"github.com/in-toto/go-witness/cryptoutil"
"github.com/in-toto/go-witness/log"
"github.com/invopop/jsonschema"
vex "github.com/openvex/go-vex/pkg/vex"
)

const (
Name = "vex"
Type = "https://openvex.dev/ns"
RunType = attestation.PostProductRunType
)

// This is a hacky way to create a compile time error in case the attestor
// doesn't implement the expected interfaces.
var (
_ attestation.Attestor = &Attestor{}
)

func init() {
attestation.RegisterAttestation(Name, Type, RunType, func() attestation.Attestor {
return New()
})
}

type Attestor struct {
VEXDocument vex.VEX `json:"vexDocument"`
ReportFile string `json:"reportFileName,omitempty"`
ReportDigestSet cryptoutil.DigestSet `json:"reportDigestSet,omitempty"`
}

func New() *Attestor {
return &Attestor{}
}

func (a *Attestor) Name() string {
return Name
}

func (a *Attestor) Type() string {
return Type
}

func (a *Attestor) RunType() attestation.RunType {
return RunType
}

func (a *Attestor) Schema() *jsonschema.Schema {
return jsonschema.Reflect(&a)
}

func (a *Attestor) Attest(ctx *attestation.AttestationContext) error {
if err := a.getCandidate(ctx); err != nil {
log.Debugf("(attestation/vex) error getting candidate: %w", err)
return err
}

return nil
}

func (a *Attestor) getCandidate(ctx *attestation.AttestationContext) error {
products := ctx.Products()

if len(products) == 0 {
return fmt.Errorf("no products to attest")
}

for path, product := range products {
newDigestSet, err := cryptoutil.CalculateDigestSetFromFile(path, ctx.Hashes())
if newDigestSet == nil || err != nil {
return fmt.Errorf("error calculating digest set from file: %s", path)
}

if !newDigestSet.Equal(product.Digest) {
return fmt.Errorf("integrity error: product digest set does not match candidate digest set")
}

f, err := os.Open(path)
if err != nil {
return fmt.Errorf("error opening file: %s", path)
}

reportBytes, err := io.ReadAll(f)
if err != nil {
return fmt.Errorf("error reading file: %s", path)
}

// Check to see if we can unmarshal into VEX type
if err := json.Unmarshal(reportBytes, &a.VEXDocument); err != nil {
log.Debugf("(attestation/vex) error unmarshaling VEX document: %w", err)
continue
}

a.ReportFile = path
a.ReportDigestSet = product.Digest

return nil
}
return fmt.Errorf("no VEX file found")
}
98 changes: 98 additions & 0 deletions attestation/vex/vex_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright 2024 The Witness Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package vex

import (
"bytes"
"encoding/json"
"testing"
"time"

"github.com/in-toto/go-witness/attestation"
vex "github.com/openvex/go-vex/pkg/vex"
)

// NOTE(nick): examples https://github.com/openvex/vexctl/tree/main/examples/openvex

const vexDocumentExpected = `{
"vexDocument": {
"@context": "https://openvex.dev/ns/v0.2.0",
"@id": "https://openvex.dev/docs/public/vex-0f3be8817faafa24e4bfb3d17eaf619efb1fe54923b9c42c57b156a936b91431",
"author": "John Doe",
"role": "Senior Trusted Vex Issuer",
"timestamp": "1970-01-01T00:00:00Z",
"version": 1,
"statements": [
{
"vulnerability": {
"name": "CVE-1234-5678"
},
"products": [
{
"@id": "pkg:apk/wolfi/[email protected]"
}
],
"status": "fixed"
}
]
}
}`

func TestAttest(t *testing.T) {
vexAttestor := New()
vexAttestor.VEXDocument.Context = "https://openvex.dev/ns/v0.2.0"
vexAttestor.VEXDocument.ID = "https://openvex.dev/docs/public/vex-0f3be8817faafa24e4bfb3d17eaf619efb1fe54923b9c42c57b156a936b91431"
vexAttestor.VEXDocument.Author = "John Doe"
vexAttestor.VEXDocument.AuthorRole = "Senior Trusted Vex Issuer"
vexAttestor.VEXDocument.Version = 1
time := time.Date(1970, 1, 1, 0, 0, 0, 0, time.Now().UTC().Location())
vexAttestor.VEXDocument.Timestamp = &time
vexAttestor.VEXDocument.Statements = []vex.Statement{
{
Vulnerability: vex.Vulnerability{
Name: "CVE-1234-5678",
},
Products: []vex.Product{
{
Component: vex.Component{
ID: "pkg:apk/wolfi/[email protected]",
},
},
},
Status: vex.StatusFixed,
},
}

attestorCollection := []attestation.Attestor{vexAttestor}
ctx, err := attestation.NewContext("test", append(attestorCollection, vexAttestor))
if err != nil {
t.Errorf("error creating attestation context: %s", err)
}
err = ctx.RunAttestors()
if err != nil {
t.Errorf("error attesting: %s", err.Error())
}

vexDocJSON, err := json.MarshalIndent(vexAttestor, "", " ")
if err != nil {
t.Errorf("unexpected error: %s", err)
}

expectedJSON := []byte(vexDocumentExpected)

if !bytes.Equal(vexDocJSON, expectedJSON) {
t.Errorf("expected \n%s\n, got \n%s\n", expectedJSON, vexDocJSON)
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/omnibor/omnibor-go v0.0.0-20230521145532-a77de61a16cd // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/package-url/packageurl-go v0.1.1 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
Expand Down Expand Up @@ -137,6 +138,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/openvex/go-vex v0.2.5
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
Expand All @@ -161,5 +163,3 @@ require (
replace github.com/sigstore/rekor => github.com/testifysec/rekor v0.4.0-dsse-intermediates-2

replace github.com/gin-gonic/gin v1.5.0 => github.com/gin-gonic/gin v1.7.7

replace github.com/opencontainers/image-spec => github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,12 @@ github.com/open-policy-agent/opa v0.64.0 h1:2g0JTt78zxhFaoBmZViY4UXvtOlzBjhhrnyr
github.com/open-policy-agent/opa v0.64.0/go.mod h1:j4VeLorVpKipnkQ2TDjWshEuV3cvP/rHzQhYaraUXZY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/openvex/go-vex v0.2.5 h1:41utdp2rHgAGCsG+UbjmfMG5CWQxs15nGqir1eRgSrQ=
github.com/openvex/go-vex v0.2.5/go.mod h1:j+oadBxSUELkrKh4NfNb+BPo77U3q7gdKME88IO/0Wo=
github.com/owenrumney/go-sarif v1.1.1 h1:QNObu6YX1igyFKhdzd7vgzmw7XsWN3/6NMGuDzBgXmE=
github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U=
github.com/package-url/packageurl-go v0.1.1 h1:KTRE0bK3sKbFKAk3yy63DpeskU7Cvs/x/Da5l+RtzyU=
github.com/package-url/packageurl-go v0.1.1/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down

0 comments on commit 189c426

Please sign in to comment.