diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b2937e1..a526095 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -10,7 +10,29 @@ permissions: id-token: write jobs: + # A repo with no audit role yet (like the template repo) runs this job instead + # of the benchmark, and it says what to set up. Once AWS_AUDIT_ROLE_ARN is set, it skips. + benchmark-not-set-up: + name: "Benchmark skipped: set up AWS first" + if: vars.AWS_AUDIT_ROLE_ARN == '' + runs-on: ubuntu-latest + steps: + - name: Say what to set up + run: | + echo "::notice title=Benchmark skipped: set up AWS first::Set the AWS_AUDIT_ROLE_ARN variable to run the CIS benchmark. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Benchmark skipped: this repo has no audit role yet + + The weekly Prowler CIS benchmark signs in to AWS as a read-only `security-audit` role: + + 1. Create the `security-audit` role with `reference/security-audit-trust.json` (Security section, Unit 1). + 2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_AUDIT_ROLE_ARN`, set to that role's ARN. + + Then run it from **Actions → Benchmark → Run workflow**, or wait for Monday's run. + EOF + prowler: + if: vars.AWS_AUDIT_ROLE_ARN != '' runs-on: ubuntu-latest steps: # Pinned to a full commit SHA, not a version tag. Unit 3 explains why. diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f7041fa..860491f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -97,11 +97,33 @@ jobs: name: security-reports path: reports/ + # A repo with no AWS role yet (like the template repo) runs this job instead + # of deploy, and it says what to set up. Once AWS_DEPLOY_ROLE_ARN is set, it skips. + deploy-not-set-up: + name: "Deploy skipped: set up AWS first" + needs: build + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN == '' + runs-on: ubuntu-latest + steps: + - name: Say what to set up + run: | + echo "::notice title=Deploy skipped: set up AWS first::Every gate passed. Set the AWS_DEPLOY_ROLE_ARN variable to deploy. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Deploy skipped: this repo has no AWS role yet + + Every gate in the build job passed. To let the deploy job sign in to AWS: + + 1. Make the `github-deploy` role, if you have not already (CI/CD section, Phase 4). + 2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_DEPLOY_ROLE_ARN`, set to that role's ARN. + + Then re-run this workflow. + EOF + # Deploying is the last stage of the lifecycle, so it only happens for main. - # A pull request never gets to sign in to AWS. + # A pull request never gets to sign in to AWS. And it needs a role to sign in as. deploy: needs: build - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN != '' runs-on: ubuntu-latest permissions: id-token: write diff --git a/README.md b/README.md index e766d6e..c8e92c6 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,10 @@ | **Runs on** | Every tool from the Security section, your capstone repo, DefectDojo on your VM | | **Deliverable** | A branch with five planted weaknesses caught twice, a decision for every finding in DefectDojo, four fixes proven by green gates. The branch is never merged | -> [!WARNING] -> **GitHub Actions is switched off on this template repo.** In **your** repo the pipeline and the weekly benchmark run for real. +> [!NOTE] +> [![CI/CD Pipeline](https://github.com/wjpearce-github/TechTwoForty-Security/actions/workflows/pipeline.yml/badge.svg)](https://github.com/wjpearce-github/TechTwoForty-Security/actions/workflows/pipeline.yml) +> +> **The pipeline runs on this template repo.** Open the [Actions tab](https://github.com/wjpearce-github/TechTwoForty-Security/actions) to see every scanner run as a gate against this code, and download the reports it keeps. There is no AWS account behind it, so the deploy job and the weekly benchmark are replaced by jobs called **set up AWS first** that list what to set. In **your** repo, with `AWS_DEPLOY_ROLE_ARN` and `AWS_AUDIT_ROLE_ARN` set, both run for real. ## The big picture