-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: linus-sun <[email protected]>
- Loading branch information
Showing
11 changed files
with
278 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# 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. | ||
|
||
# NOTE: This GHA should not be run concurrently. | ||
|
||
# TODO: Write identities to issues when found | ||
|
||
name: Rekor Monitoring Template | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
file_issue: | ||
description: 'True to file an issue on monitoring failure' | ||
required: true | ||
type: boolean | ||
artifact_retention_days: | ||
description: 'The number of days to retain an artifact (default: 14). If this workflow runs as a cron job, it must be greater than the frequency of the job' | ||
required: false | ||
type: number | ||
default: 14 | ||
identities: | ||
description: 'multiline yaml of certificate subjects and issuers, key subjects, and fingerprints. For certificates, if no issuers are specified, match any OIDC provider' | ||
required: false | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
UPLOADED_LOG_NAME: checkpoint | ||
LOG_FILE: checkpoint_log.txt | ||
|
||
jobs: | ||
detect-workflow: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # Needed to detect the current reusable repository and ref. | ||
outputs: | ||
repository: ${{ steps.detect.outputs.repository }} | ||
ref: ${{ steps.detect.outputs.ref }} | ||
steps: | ||
- name: Detect the repository and ref | ||
id: detect | ||
uses: slsa-framework/slsa-github-generator/.github/actions/detect-workflow-js@5a775b367a56d5bd118a224a811bba288150a563 # v2.0.0 | ||
|
||
monitor: | ||
runs-on: ubuntu-latest | ||
needs: [detect-workflow] | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
repository: ${{ needs.detect-workflow.outputs.repository }} | ||
ref: "${{ needs.detect-workflow.outputs.ref }}" | ||
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | ||
with: | ||
go-version: '1.23' | ||
- name: Download artifact | ||
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 | ||
with: | ||
name: ${{ env.UPLOADED_LOG_NAME }} | ||
# Skip on first run since there will be no checkpoint | ||
continue-on-error: true | ||
- name: Log current checkpoints | ||
run: cat ${{ env.LOG_FILE }} | ||
# Skip on first run | ||
continue-on-error: true | ||
- run: go run ./cmd/rekor_consistency --file ${{ env.LOG_FILE }} --once --monitored-values "${{ inputs.identities }}" --user-agent "${{ format('{0}/{1}/{2}', needs.detect-workflow.outputs.repository, needs.detect-workflow.outputs.ref, github.run_id) }}" | ||
- name: Upload checkpoint | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | ||
with: | ||
name: ${{ env.UPLOADED_LOG_NAME }} | ||
path: ${{ env.LOG_FILE }} | ||
retention-days: ${{ inputs.artifact_retention_days }} | ||
- name: Log new checkpoints | ||
run: cat ${{ env.LOG_FILE }} | ||
|
||
if-succeeded: | ||
runs-on: ubuntu-latest | ||
needs: [monitor, detect-workflow] | ||
permissions: | ||
issues: 'write' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_REPOSITORY: ${{ github.repository }} | ||
if: ${{ needs.monitor.result == 'success' && inputs.file_issue }} | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
repository: ${{ needs.detect-workflow.outputs.repository }} | ||
ref: "${{ needs.detect-workflow.outputs.ref }}" | ||
- run: | | ||
set -euo pipefail | ||
./.github/workflows/scripts/report_success.sh | ||
if-failed: | ||
runs-on: ubuntu-latest | ||
needs: [monitor, detect-workflow] | ||
permissions: | ||
issues: 'write' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ISSUE_REPOSITORY: ${{ github.repository }} | ||
if: ${{ always() && needs.monitor.result == 'failure' && inputs.file_issue }} | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
repository: ${{ needs.detect-workflow.outputs.repository }} | ||
ref: "${{ needs.detect-workflow.outputs.ref }}" | ||
- run: | | ||
set -euo pipefail | ||
./.github/workflows/scripts/report_failure.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright 2024 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. | ||
|
||
# NOTE: This GHA should not be run concurrently. | ||
# TODO: Once the workflows for consistency check and identity monitor are fully split, | ||
# the consistency check workflow should no longer require a checkpoint file. | ||
|
||
name: Rekor Identity Monitor Template | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
once: | ||
default: true | ||
required: false | ||
type: boolean | ||
config: | ||
description: 'multiline yaml of configuration settings for identity monitor run' | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
detect-workflow: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # Needed to detect the current reusable repository and ref. | ||
outputs: | ||
repository: ${{ steps.detect.outputs.repository }} | ||
ref: ${{ steps.detect.outputs.ref }} | ||
steps: | ||
- name: Detect the repository and ref | ||
id: detect | ||
uses: slsa-framework/slsa-github-generator/.github/actions/detect-workflow-js@5a775b367a56d5bd118a224a811bba288150a563 # v2.0.0 | ||
|
||
monitor: | ||
runs-on: ubuntu-latest | ||
needs: [detect-workflow] | ||
steps: | ||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | ||
with: | ||
repository: ${{ needs.detect-workflow.outputs.repository }} | ||
ref: "${{ needs.detect-workflow.outputs.ref }}" | ||
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | ||
with: | ||
go-version: '1.23' | ||
- name: Run identity monitor | ||
run: go run ./cmd/rekor_monitor --config ${{ inputs.config }} --once |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.