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

510 - SBOM attestation stdout #785

Merged
merged 127 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 125 commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
7e49265
wip
spiffcs Jan 20, 2022
976a404
update attest to import new library changes
spiffcs Jan 31, 2022
fafa270
revert to initial keysign bare bones execution
spiffcs Jan 31, 2022
fb3d29b
remove writer from attest command
spiffcs Jan 31, 2022
11f73e7
add barebones password function - attestation work
spiffcs Feb 1, 2022
bfa8622
remove outdated format
spiffcs Feb 1, 2022
3f0929f
inject context
spiffcs Feb 1, 2022
333f66b
bind keyPath to local command flag
spiffcs Feb 1, 2022
5af16b9
update command documentation - inject ctx
spiffcs Feb 3, 2022
7f0f70a
update to use partybus to prevent hang
spiffcs Feb 3, 2022
e7249f8
update so static analysis does not timeout on CI
spiffcs Feb 3, 2022
14cefe5
add back framework for integration tests
spiffcs Feb 8, 2022
0f2f920
update command output remove todo
spiffcs Feb 8, 2022
86e87cd
update example text
spiffcs Feb 8, 2022
9138a27
update attestation command to not panic
spiffcs Feb 8, 2022
0f8415b
update flag shorthand
spiffcs Feb 10, 2022
25223fb
remove double publish
spiffcs Feb 10, 2022
c1ba5d7
update parse for format option
spiffcs Feb 10, 2022
5d454f1
remove old status line
spiffcs Feb 10, 2022
0613231
update password support
spiffcs Feb 10, 2022
e51334d
move password support before terminal
spiffcs Feb 10, 2022
2a8d347
update output
spiffcs Feb 11, 2022
2df53ea
update static errors
spiffcs Feb 11, 2022
7d9eaaf
remove confirm pass functionality
spiffcs Feb 14, 2022
eef0682
update signer type
spiffcs Feb 14, 2022
7fe13fb
add scheme validation and update docs
spiffcs Feb 14, 2022
7bd05dd
update predicate type switch
spiffcs Feb 14, 2022
2d56a9e
add smoketest for cli
spiffcs Feb 14, 2022
899d311
add cosign as dependency for cli test
spiffcs Feb 14, 2022
d6c61ff
update assertion based on docs change
spiffcs Feb 14, 2022
5debdcb
update scheme validation
spiffcs Feb 14, 2022
1ba21a1
add todo for PR feedback on Predicate Types
spiffcs Feb 14, 2022
ec1cceb
static updates
spiffcs Feb 15, 2022
0d5a7ea
update schemeHelp to be const across cmd
spiffcs Feb 16, 2022
4ee8004
pin cosign version
spiffcs Feb 16, 2022
f4980ca
update makefile version
spiffcs Feb 17, 2022
4f46f92
Merge branch 'main' into 510-attach-sbomb-attestation
spiffcs Feb 17, 2022
ae18f5d
check if cache issue
spiffcs Feb 17, 2022
732b2aa
access local temp directory
spiffcs Feb 17, 2022
55a6abb
update to find cosign temp
spiffcs Feb 17, 2022
79fc729
update to bootstrap go
spiffcs Feb 17, 2022
f7877ea
update ci workflow to boostrap tools on cli tests
spiffcs Feb 17, 2022
6977232
update correct predicate type formats for JSON
spiffcs Feb 17, 2022
68bad60
update function usage
spiffcs Feb 17, 2022
f3a38f6
dog food attestation on syft image
spiffcs Feb 17, 2022
d13e681
comment out test for future work
spiffcs Feb 17, 2022
c7deea0
update password select mechanism
spiffcs Feb 17, 2022
4fefb3b
test harness for password verification
spiffcs Feb 17, 2022
5f8787b
update nit comments
spiffcs Feb 16, 2022
763a161
configure failing tests
spiffcs Feb 17, 2022
d3bfbfb
tests are passing
spiffcs Feb 17, 2022
c56a4dc
Merge branch 'main' into 510-attach-sbomb-attestation
spiffcs Feb 17, 2022
7cac690
update exported function for tests
spiffcs Feb 17, 2022
dede845
update go mod
spiffcs Feb 17, 2022
e1efb4b
update go.mod to latest cosign version
spiffcs Feb 18, 2022
fbb3997
wip
spiffcs Jan 20, 2022
f4f337f
update attest to import new library changes
spiffcs Jan 31, 2022
5ba1b64
revert to initial keysign bare bones execution
spiffcs Jan 31, 2022
b8121f8
remove writer from attest command
spiffcs Jan 31, 2022
02af299
add barebones password function - attestation work
spiffcs Feb 1, 2022
c2fd6b2
remove outdated format
spiffcs Feb 1, 2022
9c27646
inject context
spiffcs Feb 1, 2022
5da8ca9
bind keyPath to local command flag
spiffcs Feb 1, 2022
2a0dd1e
update command documentation - inject ctx
spiffcs Feb 3, 2022
9310e49
update to use partybus to prevent hang
spiffcs Feb 3, 2022
e5be166
update so static analysis does not timeout on CI
spiffcs Feb 3, 2022
cdde3bd
add back framework for integration tests
spiffcs Feb 8, 2022
e7e9231
update command output remove todo
spiffcs Feb 8, 2022
e487215
update example text
spiffcs Feb 8, 2022
9b47da9
update attestation command to not panic
spiffcs Feb 8, 2022
e56b29d
update flag shorthand
spiffcs Feb 10, 2022
d09cec8
remove double publish
spiffcs Feb 10, 2022
e99e966
update parse for format option
spiffcs Feb 10, 2022
5bdfe59
remove old status line
spiffcs Feb 10, 2022
6752ada
update password support
spiffcs Feb 10, 2022
be0ae30
move password support before terminal
spiffcs Feb 10, 2022
58248fd
update output
spiffcs Feb 11, 2022
2a35b11
update static errors
spiffcs Feb 11, 2022
c24c28b
remove confirm pass functionality
spiffcs Feb 14, 2022
45cf526
update signer type
spiffcs Feb 14, 2022
7f3b048
add scheme validation and update docs
spiffcs Feb 14, 2022
179a86f
update predicate type switch
spiffcs Feb 14, 2022
4902557
add smoketest for cli
spiffcs Feb 14, 2022
26c6a96
add cosign as dependency for cli test
spiffcs Feb 14, 2022
cc037e7
update assertion based on docs change
spiffcs Feb 14, 2022
65aef34
update scheme validation
spiffcs Feb 14, 2022
470d9e6
add todo for PR feedback on Predicate Types
spiffcs Feb 14, 2022
e177a9d
static updates
spiffcs Feb 15, 2022
050b457
update schemeHelp to be const across cmd
spiffcs Feb 16, 2022
2cf8857
pin cosign version
spiffcs Feb 16, 2022
31d9b90
update makefile version
spiffcs Feb 17, 2022
f677d5b
Add pURL generation for java packages + fix NPM pURL generation (#812)
wagoodman Feb 10, 2022
a069273
deduplicate SPDX tag-value package IDs (#813)
wagoodman Feb 10, 2022
578463a
update golang crypto library dependency (#815)
spiffcs Feb 11, 2022
f5d8128
bump stereoscope to include functional options (#823)
wagoodman Feb 15, 2022
7425b3b
remove duplicate manifest lines (#828)
spiffcs Feb 15, 2022
3d62917
Upgrade install.sh to support installations for previous versions (#830)
wagoodman Feb 15, 2022
9101b6d
check if cache issue
spiffcs Feb 17, 2022
6fc8736
access local temp directory
spiffcs Feb 17, 2022
323649d
update to find cosign temp
spiffcs Feb 17, 2022
b2237c1
update to bootstrap go
spiffcs Feb 17, 2022
fb92591
update ci workflow to boostrap tools on cli tests
spiffcs Feb 17, 2022
fbb7afd
update correct predicate type formats for JSON
spiffcs Feb 17, 2022
f999845
update function usage
spiffcs Feb 17, 2022
4fa5184
dog food attestation on syft image
spiffcs Feb 17, 2022
878df65
comment out test for future work
spiffcs Feb 17, 2022
e8ad930
update password select mechanism
spiffcs Feb 17, 2022
c1d39d3
test harness for password verification
spiffcs Feb 17, 2022
5d1fa28
update nit comments
spiffcs Feb 16, 2022
4ecf3b4
configure failing tests
spiffcs Feb 17, 2022
eb10737
tests are passing
spiffcs Feb 17, 2022
2879091
Fix panic in requirements.txt parsing (#834)
luhring Feb 17, 2022
c31931d
Base64 encoder closing (#822)
houdini91 Feb 17, 2022
1680cde
ignore minor parsing error when reading dpkg status files (#786)
jonasagx Feb 17, 2022
19e4387
update exported function for tests
spiffcs Feb 17, 2022
eda3ca2
update go mod
spiffcs Feb 17, 2022
c0d60ce
update go.mod to latest cosign version
spiffcs Feb 18, 2022
47fa22d
adjust attest options to be 12-factor-like
wagoodman Feb 18, 2022
b9bfa48
Merge branch '510-attach-sbomb-attestation' of https://github.com/anc…
spiffcs Feb 18, 2022
1883815
update static analysis
spiffcs Feb 18, 2022
36da7f4
update failing test
spiffcs Feb 18, 2022
bcd435e
uopdate README
spiffcs Feb 18, 2022
2525d42
update readme with command
spiffcs Feb 18, 2022
fe62f30
update getting started
spiffcs Feb 18, 2022
4ef7657
minor edits
spiffcs Feb 18, 2022
5524ea5
readme updates
spiffcs Feb 18, 2022
d6fa678
update to latest cosign
spiffcs Feb 23, 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
13 changes: 10 additions & 3 deletions .github/workflows/validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,16 @@ jobs:
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-

- name: (cache-miss) Bootstrap go dependencies
if: steps.go-cache.outputs.cache-hit != 'true'
run: make bootstrap-go
- name: Restore tool cache
id: tool-cache
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/.tmp
key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }}

- name: (cache-miss) Bootstrap all project dependencies
if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true'
run: make bootstrap

- name: Build key for tar cache
run: make cli-fingerprint
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ bin/
# macOS Finder metadata
.DS_STORE

*.profile
*.profile

# attestation
cosign.key
cosign.pub
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TEMPDIR = ./.tmp
RESULTSDIR = test/results
COVER_REPORT = $(RESULTSDIR)/unit-coverage-details.txt
COVER_TOTAL = $(RESULTSDIR)/unit-coverage-summary.txt
LINTCMD = $(TEMPDIR)/golangci-lint run --tests=false --timeout=2m --config .golangci.yaml
LINTCMD = $(TEMPDIR)/golangci-lint run --tests=false --timeout=4m --config .golangci.yaml
RELEASE_CMD=$(TEMPDIR)/goreleaser release --rm-dist
SNAPSHOT_CMD=$(RELEASE_CMD) --skip-publish --snapshot
VERSION=$(shell git describe --dirty --always --tags)
Expand Down Expand Up @@ -111,6 +111,7 @@ bootstrap-tools: $(TEMPDIR)
curl -sSfL https://raw.githubusercontent.com/anchore/chronicle/main/install.sh | sh -s -- -b $(TEMPDIR)/ v0.3.0
.github/scripts/goreleaser-install.sh -d -b $(TEMPDIR)/ v1.4.1
GOBIN="$(shell realpath $(TEMPDIR))" go install github.com/neilpa/[email protected]
GOBIN="$(shell realpath $(TEMPDIR))" go install github.com/sigstore/cosign/cmd/[email protected]

.PHONY: bootstrap-go
bootstrap-go:
Expand Down
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ A CLI tool and Go library for generating a Software Bill of Materials (SBOM) fro

## Features
- Catalog container images and filesystems to discover packages and libraries.
- Generate in-toto attestations where an SBOM is included as the payload.
- Supports packages and libraries from various ecosystems (APK, DEB, RPM, Ruby Bundles, Python Wheel/Egg/requirements.txt, JavaScript NPM/Yarn, Java JAR/EAR/WAR/PAR/SAR, Jenkins plugins JPI/HPI, Go modules, PHP Composer)
- Linux distribution identification (supports Alpine, BusyBox, CentOS/RedHat, Debian/Ubuntu flavored distributions)
- Supports Docker and OCI image formats
Expand Down Expand Up @@ -68,6 +69,7 @@ nix-shell -p syft

## Getting started

#### SBOM
To generate an SBOM for a Docker or OCI image:
```
syft <image>
Expand All @@ -85,6 +87,17 @@ To include software from all image layers in the SBOM, regardless of its presenc
syft packages <image> --scope all-layers
```

#### Attestation
spiffcs marked this conversation as resolved.
Show resolved Hide resolved
To generate an attested SBOM for a Docker or OCI image as the predicate of an in-toto attestation
```
syft attest --output [FORMAT] --key [KEY] [SOURCE] [flags]
```

The above output is in the form of the [DSSE envelope](https://github.com/secure-systems-lab/dsse/blob/master/envelope.md#dsse-envelope).
The payload is a base64 encoded SBOM, the payload type is `application/vnd.in-toto+json`, and the signatures array is populated
with the contents needed for public key verification. For details on workflows using this command see [here](#adding-an-sbom-to-an-image-as-an-attestation-using-syft).


### Supported sources

Syft can generate a SBOM from a variety of sources:
Expand Down Expand Up @@ -396,6 +409,16 @@ registry:
token: ""
# - ... # note, more credentials can be provided via config file only

# generate an attested SBOM
attest:
# path to the private key file to use for attestation
# SYFT_ATTEST_KEY env var
key: "cosign.key"

# password to decrypt to given private key
# SYFT_ATTEST_PASSWORD env var, additionally responds to COSIGN_PASSWORD
password: ""

log:
# use structured logging
# same as SYFT_LOG_STRUCTURED env var
Expand Down Expand Up @@ -432,7 +455,10 @@ anchore:
dockerfile: ""
```

### Adding an SBOM to an image as an attestation
### Adding an SBOM to an image as an attestation using Syft

`syft attest --output [FORMAT] --key [KEY] [SOURCE] [flags]`

SBOMs themselves can serve as input to different analysis tools. The Anchore organization offers the vulnerability scanner
[grype](https://github.com/anchore/grype) as one such tool.
One of the foundational approaches to "trust" between tools is for producers to use the artifacts generated by syft as attestations to their images.
Expand All @@ -444,8 +470,8 @@ its remote reference. Replace $MY_PRIVATE_KEY with a private key you own or have

```bash
cosign sign --key $MY_PRIVATE_KEY test/image:latest
syft test/image:latest -o json > test_latest_sbom.json
cosign attest --predicate test_latest_sbom.json --key $MY_PRIVATE_KEY test/image:latest
syft attest --key $MY_PRIVATE_KEY test/image:latest > test_latest_sbom_attestation.json
cosign attach --predicate test_latest_sbom_attestation.json --key $MY_PRIVATE_KEY test/image:latest
```

Verify the new attestation exists on your image
Expand Down
Loading