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

Fix OIDC test #2050

Merged
merged 7 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/github-oidc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ jobs:
with:
go-version: '1.17'
check-latest: true
cache: true

# Install tools.
- uses: sigstore/cosign-installer@48866aa521d8bf870604709cd43ec2f602d03ff2 # v2.3.0
- uses: imjasonh/setup-ko@2c3450ca27f6e6f2b02e72a40f2163c281a1f675 # v0.4

- name: build cosign from the HEAD
run: |
make cosign
./cosign version

- name: Build and sign a container image
run: |
set -e
Expand All @@ -54,5 +59,4 @@ jobs:
- name: Build and sign a blob
run: |
set -e
make cosign
make sign-blob-experimental
41 changes: 41 additions & 0 deletions scripts/sign-images-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

# Copyright 2022 The Sigstore Authors
#
# 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.

set -o errexit
set -o nounset
set -o pipefail

: "${GIT_HASH:?Environment variable empty or not defined.}"
: "${GITHUB_RUN_ID:?Environment variable empty or not defined.}"
: "${GITHUB_RUN_ATTEMPT:?Environment variable empty or not defined.}"

export COSIGN_EXPERIMENTAL=1
COSIGN_CLI=./cosign

if [[ ! -f cosignImagerefs ]]; then
echo "cosignImagerefs not found"
exit 1
fi

if [[ ! -f sgetImagerefs ]]; then
echo "sgetImagerefs not found"
exit 1
fi

echo "Signing cosign images using Keyless..."

$COSIGN_CLI sign -a sha="$GIT_HASH" -a run_id="$GITHUB_RUN_ID" -a run_attempt="$GITHUB_RUN_ATTEMPT" "$(cat cosignImagerefs)"
$COSIGN_CLI sign -a sha="$GIT_HASH" -a run_id="$GITHUB_RUN_ID" -a run_attempt="$GITHUB_RUN_ATTEMPT" "$(cat sgetImagerefs)"
5 changes: 1 addition & 4 deletions test/ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ sign-ci-containers: ko

.PHONY: sign-ci-keyless-containers
sign-ci-keyless-containers: ko
cosign sign -a sha=$(GIT_HASH) -a run_id=${GITHUB_RUN_ID} -a run_attempt=${GITHUB_RUN_ATTEMPT} ${KO_PREFIX}/cosign:$(GIT_HASH)
cosign sign -a sha=$(GIT_HASH) -a run_id=${GITHUB_RUN_ID} -a run_attempt=${GITHUB_RUN_ATTEMPT} ${KO_PREFIX}/cosign:$(GIT_VERSION)
cosign sign -a sha=$(GIT_HASH) -a run_id=${GITHUB_RUN_ID} -a run_attempt=${GITHUB_RUN_ATTEMPT} ${KO_PREFIX}/sget:$(GIT_HASH)
cosign sign -a sha=$(GIT_HASH) -a run_id=${GITHUB_RUN_ID} -a run_attempt=${GITHUB_RUN_ATTEMPT} ${KO_PREFIX}/sget:$(GIT_VERSION)
./scripts/sign-images-ci.sh

.PHONY: sign-blob-experimental
sign-blob-experimental:
Expand Down
10 changes: 5 additions & 5 deletions test/sign_blob_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ BLOB=verify-experimental-blob
date > $BLOB
cat $BLOB

echo "Sign the blob with cosign first and upload to rekor"
SIG=$($COSIGN_CLI sign-blob $BLOB)
# echo "Sign the blob with cosign first and upload to rekor"
cpanato marked this conversation as resolved.
Show resolved Hide resolved
# $COSIGN_CLI sign-blob --output-certificate blob.cert --output-signature blob.sig $BLOB

echo "Verifying ..."
$COSIGN_CLI verify-blob -signature $SIG $BLOB
# echo "Verifying ..."
# $COSIGN_CLI verify-blob --signature blob.sig --cert blob.cert $BLOB

# Now, sign the blob with a self-signed certificate and upload to rekor
SIG_FILE=verify-experimental-signature
Expand Down Expand Up @@ -78,4 +78,4 @@ curl -X POST https://rekor.sigstore.dev/api/v1/log/entries -H 'Content-Type: app

# Verifying should still work
echo "Verifying ..."
$COSIGN_CLI verify-blob --signature $SIG $BLOB
$COSIGN_CLI verify-blob --signature "$SIG_FILE" --cert "$CERT_FILE" "$BLOB"
26 changes: 26 additions & 0 deletions test/testdata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generate Certificate

If the `test/testdata/test_blob_cert.pem` expire you can generate a new certificate to use in the tests running the
following command:

```shell
$ openssl req -key test/testdata/test_blob_private_key -x509 -days 3650 -out cert.pem -new -nodes

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) []:US
State or Province Name (full name) []:CA
Locality Name (eg, city) []:SF
Organization Name (eg, company) []:Company
Organizational Unit Name (eg, section) []:Unit
Common Name (eg, fully qualified host name) []:www.example.org
Email Address []:email@email.com
```

and then you replace the old `test/testdata/test_blob_cert.pem` with the new certificate.

10 changes: 5 additions & 5 deletions test/testdata/test_blob_cert.pem
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-----BEGIN CERTIFICATE-----
MIIB9jCCAZwCCQDmJAPXiurv9jAKBggqhkjOPQQDAjCBgjELMAkGA1UEBhMCVVMx
MIIB9zCCAZwCCQCtaU3hib3CkTAKBggqhkjOPQQDAjCBgjELMAkGA1UEBhMCVVMx
CzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEQMA4GA1UECgwHQ29tcGFueTENMAsG
A1UECwwEVW5pdDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUub3JnMR4wHAYJKoZIhvcN
AQkBFg9lbWFpbEBlbWFpbC5jb20wHhcNMjIwMzI4MTgwNDIwWhcNMjIwNDI3MTgw
NDIwWjCBgjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEQ
AQkBFg9lbWFpbEBlbWFpbC5jb20wHhcNMjIwNzA2MTQyMzU5WhcNMzIwNzAzMTQy
MzU5WjCBgjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQswCQYDVQQHDAJTRjEQ
MA4GA1UECgwHQ29tcGFueTENMAsGA1UECwwEVW5pdDEYMBYGA1UEAwwPd3d3LmV4
YW1wbGUub3JnMR4wHAYJKoZIhvcNAQkBFg9lbWFpbEBlbWFpbC5jb20wWTATBgcq
hkjOPQIBBggqhkjOPQMBBwNCAAR1Q4hB1jtagrdsVxygtDa/rli00U7n/1I/NSw8
yoMRQ+MOAjRhg3gtcV0tha34L6150qJirQHbfocsao8X6wFmMAoGCCqGSM49BAMC
A0gAMEUCIQDkZ4ZmFOK2Ze+znScge1JidTRzxNxCLbrdfc5yEJia2QIgCEjIY6Zo
QUwiyuC3ll5a9GDc4swfguZq9kOFX9bD0XQ=
A0kAMEYCIQDperCsZxqQRZXSMk4DiJCxSQfT+gaX+aLbhOS1AoTbGQIhAO22bQ87
9ngud/Klrih6bm4rde6oLtfVB+12wSetEqpd
-----END CERTIFICATE-----