Skip to content

Commit

Permalink
Add tsa to scaffolding. (#464)
Browse files Browse the repository at this point in the history
* Add tsa to scaffolding.

Signed-off-by: Ville Aikas <[email protected]>

* Deploy & test tsa.

Signed-off-by: Ville Aikas <[email protected]>

* Export TSA_URL in github test script.

Signed-off-by: Ville Aikas <[email protected]>

* doh, add the path to the ts query.

Signed-off-by: Ville Aikas <[email protected]>

Signed-off-by: Ville Aikas <[email protected]>
  • Loading branch information
vaikas authored Nov 8, 2022
1 parent e09d7b3 commit a4fbf80
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 14 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/fulcio-rekor-kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ jobs:
OIDC_TOKEN=`curl -s $ISSUER_URL`
echo "OIDC_TOKEN=$OIDC_TOKEN" >> $GITHUB_ENV
TSA_URL=$(kubectl -n tsa-system get ksvc tsa -ojsonpath='{.status.url}')
echo "TSA_URL=$TSA_URL" >> $GITHUB_ENV
- name: Sign with cosign from the action using k8s token
run: |
cosign sign --rekor-url ${{ env.REKOR_URL }} --fulcio-url ${{ env.FULCIO_URL }} --force --allow-insecure-registry ${{ env.demoimage }} --identity-token ${{ env.OIDC_TOKEN }}
Expand Down Expand Up @@ -231,6 +234,33 @@ jobs:
# ./cosign initialize --root ${ROOT} --mirror file://${REPOSITORY}
# ./cosign verify --rekor-url ${{ env.REKOR_URL }} --allow-insecure-registry ${{ env.demoimage }}

- name: Checkout TSA for testing.
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
repository: sigstore/timestamp-authority
path: ./src/github.com/sigstore/timestamp-authority
- name: Build timestamp-cli
working-directory: ./src/github.com/sigstore/timestamp-authority
run: |
go build -o ./timestamp-cli ./cmd/timestamp-cli
- name: Exercise TSA
working-directory: ./src/github.com/sigstore/timestamp-authority
run: |
curl ${{ env.TSA_URL }}/api/v1/timestamp/certchain > ts_chain.pem
echo "myblob" > myblob
if ! ./timestamp-cli --timestamp_server ${{ env.TSA_URL }} timestamp --hash sha256 --artifact myblob --out response.tsr ; then
echo "failed to timestamp artifact"
exit =1
fi
if ! ./timestamp-cli verify --timestamp response.tsr --artifact "myblob" --cert-chain ts_chain.pem ; then
echo "failed to verify timestamp"
exit -1
fi
if ! ./timestamp-cli inspect --timestamp response.tsr --format json ; then
echo "failed to inspect the timestamp"
exit -1
fi
- name: Collect diagnostics
if: ${{ failure() }}
uses: chainguard-dev/actions/kind-diag@main
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LDFLAGS=-buildid= -X sigs.k8s.io/release-utils/version.gitVersion=$(GIT_TAG)
KO_DOCKER_REPO ?= ghcr.io/sigstore/scaffolding

# These are the subdirs under config that we'll turn into separate artifacts.
artifacts := trillian ctlog fulcio rekor tuf prober
artifacts := trillian ctlog fulcio rekor tsa tuf prober

.PHONY: ko-resolve
ko-resolve:
Expand Down Expand Up @@ -67,6 +67,11 @@ ko-apply-trillian:
LDFLAGS="$(LDFLAGS)" \
ko apply -BRf ./config/trillian

.PHONY: ko-apply-tsa
ko-apply-tsa:
LDFLAGS="$(LDFLAGS)" \
ko apply -BRf ./config/tsa

.PHONY: ko-apply-tuf
ko-apply-tuf:
LDFLAGS="$(LDFLAGS)" \
Expand Down
5 changes: 1 addition & 4 deletions cmd/rekor/createsecret/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/x509"
"encoding/pem"
"flag"
"log"
"os"

"github.com/sigstore/scaffolding/pkg/secret"
Expand All @@ -48,9 +47,7 @@ var (

func main() {
flag.Parse()
if *rekorURL == "" {
log.Panic("Need a rekorURL")
}

ns := os.Getenv("NAMESPACE")
if ns == "" {
panic("env variable NAMESPACE must be set")
Expand Down
5 changes: 5 additions & 0 deletions config/tsa/createsecret/100-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
kind: Namespace
apiVersion: v1
metadata:
name: tsa-system
24 changes: 24 additions & 0 deletions config/tsa/createsecret/101-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: tsa-system
name: secret-operator
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["secrets"]
verbs: ["create", "get", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: role-secret-operator
namespace: tsa-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: secret-operator
subjects:
- kind: ServiceAccount
name: createsecret
namespace: tsa-system
6 changes: 6 additions & 0 deletions config/tsa/createsecret/101-service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: createsecret
namespace: tsa-system
30 changes: 30 additions & 0 deletions config/tsa/createsecret/300-createsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: createsecret
namespace: tsa-system
spec:
# This number looks crazy, but on k8s 1.23 there does not seem to be
# exponential backoff, so just keep on trying. For any other version
# won't run this far by any chance.
backoffLimit: 90
activeDeadlineSeconds: 300
ttlSecondsAfterFinished: 600
template:
spec:
serviceAccountName: createsecret
restartPolicy: Never
automountServiceAccountToken: true
containers:
- name: createsecret
image: ko://github.com/sigstore/scaffolding/cmd/rekor/createsecret
args: [
"--signing-secret=tsa-signing-secret",
"--secret=tsa-pub-key"
]
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
5 changes: 5 additions & 0 deletions config/tsa/tsa/100-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
kind: Namespace
apiVersion: v1
metadata:
name: tsa-system
49 changes: 49 additions & 0 deletions config/tsa/tsa/300-tsa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: tsa
namespace: tsa-system
---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
namespace: tsa-system
name: tsa
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/min-scale: "1"
spec:
serviceAccountName: tsa
containers:
- name: tsa
# https://github.com/sigstore/timestamp-authority/pkgs/container/timestamp-server/47328709?tag=7053dd7448247db0180a061047ad782b269511ca
# Resolved via crane digest 2022-11-08
image: ghcr.io/sigstore/timestamp-server@sha256:a7a604ca0c2d26a36db84cd2ebae509ee8d3ed575d90a3599e6e3c77cac741c0
ports:
- containerPort: 3000
args: [
"serve",
"--timestamp-signer=file",
"--file-signer-key-path=/var/run/tsa-secrets/signing-secret",
"--file-signer-passwd=$(SECRET_SIGNING_PWD)"
]
env:
- name: SECRET_SIGNING_PWD
valueFrom:
secretKeyRef:
name: tsa-signing-secret
key: signing-secret-password
volumeMounts:
- name: tsa-secrets
mountPath: "/var/run/tsa-secrets"
readOnly: true
volumes:
- name: tsa-secrets
secret:
secretName: tsa-signing-secret
items:
- key: signing-secret
path: signing-secret
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,17 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/prometheus v2.5.0+incompatible // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sassoftware/relic v0.0.0-20210427151427-dfb082b79b74 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.6.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.13.0 // indirect
Expand All @@ -139,7 +140,7 @@ require (
go.etcd.io/etcd/api/v3 v3.6.0-alpha.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.6.0-alpha.0 // indirect
go.etcd.io/etcd/client/v3 v3.6.0-alpha.0 // indirect
go.mongodb.org/mongo-driver v1.10.0 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,9 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down Expand Up @@ -624,15 +625,15 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo=
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI=
github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down Expand Up @@ -712,8 +713,9 @@ go.etcd.io/etcd/client/v3 v3.6.0-alpha.0/go.mod h1:a9JuChoQBDnw7WclHYBYCtTOIC12W
go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg=
go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=
go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
go.mongodb.org/mongo-driver v1.10.0 h1:UtV6N5k14upNp4LTduX0QCufG124fSu25Wz9tu94GLg=
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4=
go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
13 changes: 13 additions & 0 deletions hack/setup-scaffolding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ kubectl wait --timeout 5m -n ctlog-system --for=condition=Complete jobs --all
kubectl wait --timeout 2m -n ctlog-system --for=condition=Ready ksvc ctlog
echo '::endgroup::'

# Install TSA and wait for it to come up
echo '::group:: Install TSA'
make ko-apply-tsa
echo '::endgroup::'

echo '::group:: Wait for TSA ready'
kubectl wait --timeout 5m -n tsa-system --for=condition=Complete jobs --all
kubectl wait --timeout 2m -n tsa-system --for=condition=Ready ksvc tsa
echo '::endgroup::'

# Install tuf
echo '::group:: Install TUF'
make ko-apply-tuf
Expand All @@ -89,6 +99,7 @@ make ko-apply-tuf
kubectl -n ctlog-system get secrets ctlog-public-key -oyaml | sed 's/namespace: .*/namespace: tuf-system/' | kubectl apply -f -
kubectl -n fulcio-system get secrets fulcio-pub-key -oyaml | sed 's/namespace: .*/namespace: tuf-system/' | kubectl apply -f -
kubectl -n rekor-system get secrets rekor-pub-key -oyaml | sed 's/namespace: .*/namespace: tuf-system/' | kubectl apply -f -
kubectl -n tsa-system get secrets tsa-pub-key -oyaml | sed 's/namespace: .*/namespace: tuf-system/' | kubectl apply -f -
echo '::endgroup::'

# Make sure the tuf jobs complete
Expand All @@ -112,5 +123,7 @@ FULCIO_GRPC_URL=$(kubectl -n fulcio-system get ksvc fulcio-grpc -ojsonpath='{.st
export FULCIO_GRPC_URL
CTLOG_URL=$(kubectl -n ctlog-system get ksvc ctlog -ojsonpath='{.status.url}')
export CTLOG_URL
TSA_URL=$(kubectl -n tsa-system get ksvc tsa -ojsonpath='{.status.url}')
export TSA_URL
TUF_MIRROR=$(kubectl -n tuf-system get ksvc tuf -ojsonpath='{.status.url}')
export TUF_MIRROR

0 comments on commit a4fbf80

Please sign in to comment.