Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / secrets

Repository ignores what it must not commit

secrets/gitignore-present@v1

The repository carries a .gitignore, so build output and the local credential files beside it are not committed by the next person who runs git add ..

Idsecrets/gitignore-present
Versionv1
Categorysecrets
Default severitywarning
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsfiles

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
filesPresence, size and line counts of the well known files a repository is expected to carry, plus any extra path the guardrail asks for.path

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "secrets/gitignore-present@v1",
              "severity": "warning",
              "with": {
                  "path": ".gitignore",
                  "minLines": "1"
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
pathPath to the ignore file, relative to the directory the CLI runs in..gitignoreGUARDRAIL_INPUT_PATH
minLinesHow many non-blank lines it must have before it counts as written.1GUARDRAIL_INPUT_MINLINES

How to fix

Add a .gitignore at the repository root covering build output and local configuration:

build/
.gradle/
node_modules/
.env
*.pem

Start from github/gitignore for the language and add what this repository writes. Without one, git add . stages whatever the last build and the last terraform apply left in the tree, which is how a .env and a private key reach a remote in the first place.

More in secrets

  • secrets/detector-ran. A secret detector ran, or left a report the build can be judged on, rather than nothing having looked for a credential at all.
  • secrets/no-credential-files-committed. None of the well known credential files is in the working tree: no .env, no private key, no keystore, no kubeconfig and no cloud credential file.
  • secrets/no-hardcoded-credentials. Every secret the detector reported sits below the severity the team gates on, or is a rule the team has already accepted.

All 4 secrets guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412