Skip to content

Commit 252b0e2

Browse files
committed
Add artifact verification
1 parent 1bf0ce0 commit 252b0e2

File tree

10 files changed

+1109
-309
lines changed

10 files changed

+1109
-309
lines changed

README.md

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# RHTAS Console
22

3-
The RHTAS Console is a Go-based RESTful API server, providing functionality for signing and verifying software artifacts using Cosign, interacting with Sigstore's Rekor transparency log, and managing trust configurations with TUF and Fulcio. This repository serves as the backend for the RHTAS Console application, with plans to potentially add a frontend in the future.
3+
The RHTAS Console is a Go-based RESTful API server, providing functionality for verifying software artifacts, interacting with Sigstore's Rekor transparency log, and managing trust configurations with TUF and Fulcio. This repository serves as the backend for the RHTAS Console application, with plans to potentially add a frontend in the future.
44

55
## Features
66

7-
- **Artifact management**: Sign and verify artifacts (e.g., container images, files, SBOMs) using Cosign.
7+
- **Artifact management**: Verify artifacts (e.g., container images, files, SBOMs).
88
- **Rekor integration**: Retrieve transparency log entries and public keys from Rekor.
99
- **Trust configuration**: Get TUF targets and Fulcio certificate authorities for trust policies.
1010
- Built with [Chi](https://github.com/go-chi/chi), a lightweight Go router.
@@ -20,7 +20,6 @@ The RHTAS Console is a Go-based RESTful API server, providing functionality for
2020
```bash
2121
oapi-codegen -generate types,chi-server -package models openapi/rhtas-console.yaml > internal/models/models.go
2222
```
23-
- Optional: [rekor-cli](https://docs.sigstore.dev/rekor/installation/) and [cosign](https://docs.sigstore.dev/cosign/installation/) for testing Rekor and Cosign interactions
2423

2524
### Steps
2625

@@ -82,8 +81,7 @@ The backend exposes the following RESTful endpoints, as defined in the OpenAPI s
8281
| GET | `/healthz` | Retrieves the current health status of the server. |
8382
| GET | `/swagger-ui` | Serves the Swagger User Interface. |
8483
| GET | `/rhtas-console.yaml` | Returns the project OpenAPI spec file. |
85-
| POST | `/api/v1/artifacts/sign` | Signs an artifact using Cosign. |
86-
| POST | `/api/v1/artifacts/verify` | Verifies an artifact using Cosign. |
84+
| POST | `/api/v1/artifacts/verify` | Verifies an artifact. |
8785
| GET | `/api/v1/artifacts/{artifact}/policies` | Retrieves policies and attestations for an artifact. |
8886
| GET | `/api/v1/artifacts/image` | Retrieves metadata for a container image by full reference URI. |
8987
| GET | `/api/v1/rekor/entries/{uuid}` | Retrieves a Rekor transparency log entry by UUID. |
@@ -94,32 +92,69 @@ The backend exposes the following RESTful endpoints, as defined in the OpenAPI s
9492
| GET | `/api/v1/trust/target` | Retrieves a specific TUF target. |
9593
| GET | `/api/v1/trust/targets/certificates` | Retrieves certificates for TUF targets. |
9694

97-
#### Example: Sign an artifact
95+
#### Example: Verify an artifact
9896

99-
To sign a container image using Cosign (keyless signing with OIDC token):
97+
To verify an OCI image:
10098

99+
100+
- Using `ociImage`:
101101
```bash
102-
curl -X POST http://localhost:8080/api/v1/artifacts/sign \
102+
curl -X POST http://localhost:8080/api/v1/artifacts/verify \
103103
-H "Content-Type: application/json" \
104104
-d '{
105-
"artifact": "quay.io/example/app:latest",
106-
"artifactType": "container-image",
107-
"identityToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
108-
"annotations": {"env": "prod"}
105+
"ociImage": "ttl.sh/rhtas/test-image:1h",
106+
"expectedOIDIssuer": "https://accounts.google.com",
107+
"expectedSAN": "[email protected]",
108+
"tufRootURL": "https://tuf-repo-cdn.sigstore.dev"
109+
}'
110+
```
111+
- Using `bundle`:
112+
```bash
113+
# bundle.json: the file which contains the bundle
114+
bundle_json=$(jq -c '.' bundle.json)
115+
curl -X POST http://localhost:8080/api/v1/artifacts/verify \
116+
-H "Content-Type: application/json" \
117+
-d '{
118+
"artifactDigest": "e128e0a064433c8d46f0467b149c70052fedbfa1f9e96ac22e3deefdc943e965",
119+
"expectedOIDIssuer": "https://accounts.google.com",
120+
"expectedSAN": "[email protected]",
121+
"tufRootURL": "https://tuf-repo-cdn.sigstore.dev",
122+
"bundle": '"$bundle_json"'
109123
}'
110124
```
111125

112126
Response:
113127
```json
114128
{
115-
"success": true,
116-
"signature": "MEUCIQC...",
117-
"certificate": "-----BEGIN CERTIFICATE-----\nMIIBIjANBgkq...\n-----END CERTIFICATE-----",
118-
"logEntry": {
119-
"uuid": "108e9186e8c5677a249f2ad46ab96976656298b3feb5e031777b9e1fa5c55aaf7e0115bee955ccaa",
120-
"integratedTime": 1747816420,
121-
"logIndex": 216249784
122-
}
129+
"details":{
130+
"mediaType":"application/vnd.dev.sigstore.verificationresult+json;version=0.1",
131+
"signature":{
132+
"certificate":{
133+
"certificateIssuer":"CN=sigstore-intermediate,O=sigstore.dev",
134+
"issuer":"https://accounts.google.com",
135+
"subjectAlternativeName":"[email protected]"
136+
}
137+
},
138+
"statement":{
139+
140+
},
141+
"verifiedIdentity":{
142+
"issuer":{
143+
"issuer":"https://accounts.google.com"
144+
},
145+
"subjectAlternativeName":{
146+
"subjectAlternativeName":"[email protected]"
147+
}
148+
},
149+
"verifiedTimestamps":[
150+
{
151+
"timestamp":"2025-10-14T09:05:19+02:00",
152+
"type":"Tlog",
153+
"uri":"https://rekor.sigstore.dev"
154+
}
155+
]
156+
},
157+
"verified":true
123158
}
124159
```
125160

@@ -191,4 +226,4 @@ The `models` package is generated from the OpenAPI specification:
191226
make generate-openapi
192227
```
193228

194-
This generates Go types such as `RekorEntry`, `SignArtifactRequest`, `VerifyArtifactResponse`, and others.
229+
This generates Go types such as `RekorEntry`, `VerifyArtifactResponse`, and others.

go.mod

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ require (
1010
github.com/golang-migrate/migrate/v4 v4.18.3
1111
github.com/google/go-containerregistry v0.20.3
1212
github.com/oapi-codegen/runtime v1.1.1
13+
github.com/sigstore/protobuf-specs v0.4.1
14+
github.com/sigstore/sigstore v1.9.4
1315
github.com/sigstore/sigstore-go v1.0.0
1416
github.com/theupdateframework/go-tuf v0.7.0
1517
github.com/theupdateframework/go-tuf/v2 v2.1.1
@@ -18,28 +20,81 @@ require (
1820
require (
1921
filippo.io/edwards25519 v1.1.0 // indirect
2022
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
23+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
24+
github.com/blang/semver v3.5.1+incompatible // indirect
2125
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
22-
github.com/cespare/xxhash/v2 v2.3.0 // indirect
26+
github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7 // indirect
27+
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
28+
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
29+
github.com/fsnotify/fsnotify v1.8.0 // indirect
30+
github.com/go-chi/chi v4.1.2+incompatible // indirect
2331
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
32+
github.com/go-logr/logr v1.4.2 // indirect
33+
github.com/go-logr/stdr v1.2.2 // indirect
34+
github.com/go-openapi/analysis v0.23.0 // indirect
35+
github.com/go-openapi/errors v0.22.1 // indirect
36+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
37+
github.com/go-openapi/jsonreference v0.21.0 // indirect
38+
github.com/go-openapi/loads v0.22.0 // indirect
39+
github.com/go-openapi/runtime v0.28.0 // indirect
40+
github.com/go-openapi/spec v0.21.0 // indirect
41+
github.com/go-openapi/strfmt v0.23.0 // indirect
42+
github.com/go-openapi/swag v0.23.1 // indirect
43+
github.com/go-openapi/validate v0.24.0 // indirect
44+
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
45+
github.com/google/certificate-transparency-go v1.3.1 // indirect
2446
github.com/google/uuid v1.6.0 // indirect
2547
github.com/hashicorp/errwrap v1.1.0 // indirect
2648
github.com/hashicorp/go-multierror v1.1.1 // indirect
49+
github.com/in-toto/attestation v1.1.1 // indirect
50+
github.com/in-toto/in-toto-golang v0.9.0 // indirect
51+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
52+
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b // indirect
53+
github.com/josharian/intern v1.0.0 // indirect
2754
github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec // indirect
55+
github.com/mailru/easyjson v0.9.0 // indirect
56+
github.com/mitchellh/mapstructure v1.5.0 // indirect
57+
github.com/oklog/ulid v1.3.1 // indirect
2858
github.com/opencontainers/go-digest v1.0.0 // indirect
29-
github.com/rogpeppe/go-internal v1.13.1 // indirect
59+
github.com/opentracing/opentracing-go v1.2.0 // indirect
60+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
61+
github.com/sagikazarmark/locafero v0.7.0 // indirect
62+
github.com/sassoftware/relic v7.2.1+incompatible // indirect
3063
github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect
31-
github.com/sigstore/protobuf-specs v0.4.1 // indirect
32-
github.com/sigstore/sigstore v1.9.4 // indirect
64+
github.com/shibumi/go-pathspec v1.3.0 // indirect
65+
github.com/sigstore/rekor v1.3.10 // indirect
66+
github.com/sigstore/timestamp-authority v1.2.7 // indirect
67+
github.com/sourcegraph/conc v0.3.0 // indirect
68+
github.com/spf13/afero v1.12.0 // indirect
69+
github.com/spf13/cast v1.7.1 // indirect
70+
github.com/spf13/cobra v1.9.1 // indirect
71+
github.com/spf13/pflag v1.0.6 // indirect
72+
github.com/spf13/viper v1.20.1 // indirect
73+
github.com/subosito/gotenv v1.6.0 // indirect
3374
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
34-
go.uber.org/atomic v1.7.0 // indirect
75+
github.com/transparency-dev/merkle v0.0.2 // indirect
76+
go.mongodb.org/mongo-driver v1.14.0 // indirect
77+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
78+
go.opentelemetry.io/otel v1.35.0 // indirect
79+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
80+
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
81+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
82+
go.uber.org/atomic v1.9.0 // indirect
83+
go.uber.org/multierr v1.11.0 // indirect
84+
go.uber.org/zap v1.27.0 // indirect
3585
golang.org/x/crypto v0.39.0 // indirect
86+
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
87+
golang.org/x/mod v0.25.0 // indirect
88+
golang.org/x/net v0.40.0 // indirect
3689
golang.org/x/sys v0.33.0 // indirect
3790
golang.org/x/term v0.32.0 // indirect
91+
golang.org/x/text v0.26.0 // indirect
3892
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 // indirect
3993
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
4094
google.golang.org/grpc v1.73.0 // indirect
4195
google.golang.org/protobuf v1.36.6 // indirect
4296
gopkg.in/yaml.v3 v3.0.1 // indirect
97+
k8s.io/klog/v2 v2.130.1 // indirect
4398
)
4499

45100
require (

0 commit comments

Comments
 (0)