iac.htora.dev · security templates

Home/Templates/Pipeline security findings in front of responders

Pipeline security findings in front of responders

Secret scanning, push protection, and dependency alerts switched on and sent to the SIEM, so a leaked key is an incident.

Terraform

Why bother

A secret pushed to a repository is usually found by someone else first. Secret scanning and push protection catch most of them. Dependency alerts flag known-vulnerable packages. None of it helps if the findings sit in a tab nobody opens, so the second half of this template is getting them to responders.

How you know it worked

Push a test token to a branch. Push protection blocks it. Bypass the block, and the alert reaches your collector.

How it works

1Code is pushedto any repository in the organisation2Scanning runssecrets, dependencies, code3A block or an alertpush protection stops known secret formats4Responders see itthrough a signed webhook to the collector
Step by step, from the thing that happens to the result you want.

Set it up

Pick your platform, then open the level you want. Each level is complete on its own. Read the comments in the files as you go. Anything with a real consequence is explained on the line where it happens.

Terraform. Organisation security settings with the GitHub provider, and a signed webhook that sends security alerts to your collector

What you need first

  • A token or GitHub App with admin rights on the organisation, set as GITHUB_TOKEN.
  • A collector with an HTTPS address that accepts GitHub webhooks and checks their signature, and a shared secret for it.
  • For private repositories, GitHub Secret Protection and Code Security licences. Public repositories get secret scanning and push protection free.

What it creates

  • Secret scanning, push protection, Dependabot alerts and updates, and the dependency graph on for every new repository
  • A read-only default token for Actions workflows
  • An organisation webhook that delivers secret, dependency, and code scanning alerts, security setting changes, and visibility changes
  • Alerts for named existing repositories, a security manager team, and a limit on which actions workflows may use (Standard)
  • An optional rule refusing actions that are not pinned by commit (Standard)
  • supply-chain.yml, a workflow for each repository that builds an image. It writes a CycloneDX SBOM, signs the image keyless with cosign, attaches the SBOM as a signed attestation, and records build provenance (Standard)

See the six alerts this creates

The code

Quick startReadyone file, 91 lines
One file. Security defaults for new repositories, a read-only workflow token, and a signed alert feed to your collector.
Change these first
  • webhook_secret. Shared secret GitHub signs each delivery with, so the collector can reject forgeries. Set it with TF_VAR_webhook_secret. It is stored in state.
  • organization = "your-org" main.tf, line 20
  • billing_email = "billing@example.com" main.tf, line 21
  • collector_url = "https://collector.example.com/github/webhook" main.tf, line 22
Run it
  1. # terraform.tfvars
    webhook_secret = ""
    Create this file beside the others and fill in your values. Terraform reads it on its own.
  2. terraform init
    Downloads the provider. Run it once per folder.
  3. terraform plan
    Shows what will be created. Changes nothing. Read it.
  4. terraform apply
    Shows the plan again and waits for you to type yes.
  5. terraform destroy
    When you have finished. If it refuses, How to undo it below explains why.
Download main.tf
Checks

Formatting passedValid passedLint passed

Security scan: zero checks passed, and none flagged.

Last run 2026-10-02 with OpenTofu v1.12.6 against integrations/github 6.13.0.

outcomes/cicd-signals/github/t0
main.tf
Open main.tf as plain text
StandardReadyfive files, 263 lines
Adds alerts for named existing repositories, a security manager team, an allow list for actions, and an optional rule requiring actions pinned by commit. It also adds a supply-chain workflow that signs each image and attaches its SBOM.
Change these first
  • organization. The GitHub organisation.
  • billing_email. The organisation's billing address, which its settings resource requires.
  • collector_url. HTTPS address of the collector that receives security events and checks their signature.
  • webhook_secret. Shared secret GitHub signs each delivery with. Set it with TF_VAR_webhook_secret. It is stored in state.
Run it
  1. # terraform.tfvars
    organization = ""
    billing_email = ""
    collector_url = ""
    webhook_secret = ""
    Create this file beside the others and fill in your values. Terraform reads it on its own.
  2. terraform init
    Downloads the provider. Run it once per folder.
  3. terraform plan
    Shows what will be created. Changes nothing. Read it.
  4. terraform apply
    Shows the plan again and waits for you to type yes.
  5. terraform output verify
    Prints the commands that prove it worked.
Download all five files as a zip
Checks

Formatting passedValid passedLint passed

Security scan: zero checks passed, and none flagged.

Last run 2026-10-02 with OpenTofu v1.12.6 against integrations/github 6.13.0.

outcomes/cicd-signals/github/t1
main.tf
Open main.tf as plain text
outputs.tf
Open outputs.tf as plain text
supply-chain.yml
Open supply-chain.yml as plain text
variables.tf
Open variables.tf as plain text
versions.tf
Open versions.tf as plain text
HardenedReadysix files, 202 lines
Standard as a module. Plan rules refuse the webhook, Actions allow list, or token settings deleted, new-repository security defaults off, and Dependabot off for a listed repository. They also refuse a writable default token, all actions allowed, and a weakened webhook. A daily plan reports drift, and the scan fails on any unexplained finding.
Change these first
  • organization. The GitHub organisation.
  • billing_email. The organisation's billing address, which its settings resource requires.
  • collector_url. HTTPS address of the collector that receives security events and checks their signature.
  • webhook_secret. Shared secret GitHub signs each delivery with. Set it with TF_VAR_webhook_secret. It is stored in state.
Run it
  1. # terraform.tfvars
    organization = ""
    billing_email = ""
    collector_url = ""
    webhook_secret = ""
    Create this file beside the others and fill in your values. Terraform reads it on its own.
  2. terraform init
    Downloads the provider. Run it once per folder.
  3. terraform plan
    Shows what will be created. Changes nothing. Read it.
  4. terraform apply
    Shows the plan again and waits for you to type yes.
  5. terraform output verify
    Prints the commands that prove it worked.
Download all six files as a zip
Checks

Formatting passedValid passedLint passed

Security scan: zero checks passed, and none flagged.

Last run 2026-10-02 with OpenTofu v1.12.6 against integrations/github 6.13.0.

outcomes/cicd-signals/github/t2
.checkov.yml
Open .checkov.yml as plain text
guard.yml
Open guard.yml as plain text
main.tf
Open main.tf as plain text
outputs.tf
Open outputs.tf as plain text
variables.tf
Open variables.tf as plain text
versions.tf
Open versions.tf as plain text

How to check it worked

In a new repository, push a fine-grained personal access token with no permissions. Push protection blocks it. Bypass the block, and the alert reaches your collector. Revoke the token.

What catches people

The organisation settings resource manages every setting it covers, so in a real organisation read the plan before applying. The quick start is built for a scratch one.

The new-repository settings leave existing repositories as they are. Standard switches alerts on for the ones you list.

The webhook's signing secret is stored in Terraform state, so the state needs the same protection as the secret.

Requiring actions pinned by commit stops every workflow that uses a tag, so Standard leaves it off until your workflows are pinned.

The supply-chain workflow signs with a certificate issued to the workflow run, so the signature names the repository and workflow file. The admission policy's subject pattern has to match that, which is why both templates use https://github.com/your-org/*.

How to undo it

terraform destroy removes the webhook, the Actions limits, and the security manager assignment. Organisation settings keep their last values, because GitHub has no way to delete them.

What it costs

Nothing for public repositories. Private repositories need GitHub's security licences for secret scanning and push protection.

Good to know

  • A leaked key found by push protection costs nothing. The same key found in a public repository a week later is an incident, so the alert feed treats every bypass as one.
  • The webhook also reports when someone switches a scanner off or makes a repository public, which is how a quiet exposure usually starts.

Registry 0.23.0. Built 2026-11-17.

Made by Habibullah Tora. Source on GitHub. Code under the MIT licence, writing under CC BY 4.0.