carlos / platform Public

gitleaks: leave digest files out by exact path; random-name sentinel

Round 4 of #1251, the fix Paul approved on 2026-11-19 for Astra's two R3
P1s.

P1 1: digest-shaped findings were accepted on shape alone. The judge is
gone. The 25 census test files and the design checklist that gitleaks
flags for their sha256 digests are now not scanned at all, each named by
its whole repository path in scripts/gitleaks-gate/notscanned.go and
compared for equality. A path on the list that git does not track fails
the step. The config comment, the step header, .amadan/README.md and
AGENTS.md say plainly that a key in those files is not found. The 9B8
chunk-boundary fragment allowance only applied to one of those files
and is removed; every other allowance is unchanged.

P1 2: the sentinel overwrote a tracked gitleaks-gate-sentinel.env. It
now goes in a file with a random name per run, opened with O_EXCL, and
only its exact value in that file is set aside.

The self-test now builds a git repository and puts it through scanTree:
a tracked gitleaks-gate-sentinel.env must be reported, every listed file
skipped, near misses of each listed name reported, and an untracked list
entry refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 99612d246d06f5f3ec529f9d2c3648b43e0b60a0 parent 2b8fd0e
9 files changed, +368 −469
  • .amadan/README.md +36 −28
  • .amadan/ci.d/80-gitleaks +7 −2
  • .gitleaks.toml +8 −16
  • AGENTS.md +6 −3
  • Makefile +2 −1
  • scripts/gitleaks-gate/judge.go +0 −149
  • scripts/gitleaks-gate/main.go +111 −59
  • scripts/gitleaks-gate/notscanned.go +49 −0
  • scripts/gitleaks-gate/selftest.go +149 −211

CI cancelled — superseded by a newer push — run details

diff --git a/.amadan/README.md b/.amadan/README.md
index d06cbb31c..2d7dddce4 100644
--- a/.amadan/README.md
+++ b/.amadan/README.md
@@ -155,40 +155,48 @@ hands it to `scripts/gitleaks-gate`. The gate scans the tracked files as
they are in the working tree, not the history. Untracked files are left
out. The step fails when:
-- a finding is not an approved digest and `.gitleaks.toml` does not allow
- its exact value;
-- a planted key goes unreported, or a well-formed census entry is refused
- (the self-test, below);
+- gitleaks reports anything that `.gitleaks.toml` does not allow by exact
+ value;
+- a planted key goes unreported, or a file is left out that
+ `notscanned.go` does not name (the self-test, below);
+- `scripts/gitleaks-gate/notscanned.go` names a path git does not track;
- gitleaks is missing or is not the pinned version, its config does not
load, its report cannot be read, or the scan misses the key the gate
plants beside the tracked files;
- a `.gitleaksignore` is tracked. Allowances are made by value, in
`.gitleaks.toml`, and `gitleaks:allow` comments are ignored.
-**Digests are judged by the gate, not allowed in the config.** The census
-tests and `implementation/always-awake-consumers.json` pin sha256 digests,
-and gitleaks' generic rule reads those as keys. A gitleaks allowance can
-test a line or the reported secret, but not both, so a census-shaped line
-could hide a key in its unit field. `scripts/gitleaks-gate/judge.go` accepts
-a finding only when the whole line is a well-formed entry, every field
-holding what the census can write, and the reported secret is that entry's
-digest. The one exception is the start of a digest that a gitleaks chunk
-boundary cuts in `plan9_b8_census_test.go`, allowed by exact value in that
-file alone.
-
-A 64-character lowercase hex value in the digest field is accepted as a
-digest, because nothing in its shape can tell the two apart.
-
-**The self-test runs first, on every scan.** It generates keys at run time
-and plants them in each field of a census entry, in the checklist, at a
-chunk boundary and in ordinary source. Each case is also scanned with
-gitleaks' default rules alone, so a case the rules would never flag fails
-instead of passing for free. It checks that well-formed new entries pass
-and that a broken config or a missing binary fails the scan.
-
-If a new census class, method or key name turns the step red, add it to the
-lists in `judge.go`. The log names the file and line of a finding and never
-its value. It needs the Go module proxy, to fetch gitleaks.
+**Some files are not scanned at all.** Census test files pin a sha256
+digest of each unit's source, and `implementation/always-awake-consumers.json`
+pins one per file in `source_hashes`. Those are content digests, not
+secrets, but gitleaks' generic rule reads a digest as a key, and nothing in
+a 64-character hex value tells the two apart. So the gate leaves those files
+out whole. `scripts/gitleaks-gate/notscanned.go` names each one by its
+exact repository path: no globs, no directories, only the 26 files gitleaks
+flags today. A credential committed in one of them is not found. A file
+renamed away from its entry is scanned under its new name, and an entry
+for a path git does not track fails the step.
+
+If a new census layer turns the step red, check that every finding in it is
+a digest, then add the file's exact path to `notscanned.go`.
+
+**The self-test runs first, on every scan.** It plants keys generated at
+run time in ordinary source and in an allowed fixture, and scans each case
+with gitleaks' default rules alone as well, so a case the rules would never
+flag fails instead of passing for free. Then it builds a small git
+repository and scans it the way the real scan does: a tracked file named
+`gitleaks-gate-sentinel.env` (the gate's own planted key once used that
+name) must be reported, every file `notscanned.go` names must be left out,
+and the same key under a near miss of each name must be reported. It also
+checks that a broken config, a missing binary and a stale list entry fail
+the scan.
+
+The gate's own planted key goes in a file with a new random name on each
+run, created only if nothing is there, so it can never replace a tracked
+file.
+
+The log names the file and line of a finding and never its value. It needs
+the Go module proxy, to fetch gitleaks.
## `gofmt`: ported by widening it, not by reproducing it
diff --git a/.amadan/ci.d/80-gitleaks b/.amadan/ci.d/80-gitleaks
index 101cff399..900fd79c4 100755
--- a/.amadan/ci.d/80-gitleaks
+++ b/.amadan/ci.d/80-gitleaks
@@ -9,12 +9,17 @@
# The tree, not the history: what a branch adds is found in the run that
# adds it, and old values already in every clone would hold every branch red.
#
+# Not scanned at all: the census test files and the design checklist that
+# scripts/gitleaks-gate/notscanned.go names by exact path. They hold sha256
+# digests of source, not secrets, and a key committed in one is not found.
+#
# Red means one of:
# - a value gitleaks takes for a secret. Remove it, and rotate it if it was
# ever real. A fake a test needs is allowed by exact value in
# .gitleaks.toml, with its reason;
-# - the self-test: a planted key went unreported, or a well-formed census
-# entry was refused (scripts/gitleaks-gate/selftest.go);
+# - the self-test: a planted key went unreported, or a file other than the
+# ones notscanned.go names was left out (scripts/gitleaks-gate/selftest.go);
+# - notscanned.go names a path git does not track;
# - a scan that could not run: no binary, the wrong version, a config that
# does not load. None of these passes.
#
diff --git a/.gitleaks.toml b/.gitleaks.toml
index ceea7c3df..b52233128 100644
--- a/.gitleaks.toml
+++ b/.gitleaks.toml
@@ -7,10 +7,14 @@
# allowance is scoped to them (condition AND: a path and a value), so the
# same value anywhere else still fails the gate.
#
-# Source digests are NOT allowed here. An allowance can test the line or the
-# reported secret but not both, so it cannot tell a census entry's digest
-# from a key in another field of the same line. scripts/gitleaks-gate/judge.go
-# decides those, and its self-test plants keys to prove it.
+# Some files are NOT SCANNED AT ALL: the census test files that pin sha256
+# digests of source, and the design checklist,
+# implementation/always-awake-consumers.json, which pins one per file in
+# source_hashes. They hold content digests, not secrets, but gitleaks'
+# generic rule reads a digest as a key and no allowance can tell the two
+# apart. So scripts/gitleaks-gate leaves those files out whole, each named
+# by its exact path in scripts/gitleaks-gate/notscanned.go (no globs, no
+# directories), and a credential committed in one of them is not found.
#
# Nothing is allowed by fingerprint or by comment: the gate refuses a tracked
# .gitleaksignore and scans with --ignore-gitleaks-allow.
@@ -27,18 +31,6 @@
[extend]
useDefault = true
-# The start of one census digest. gitleaks reads a big file in chunks, and in
-# this file one chunk ends inside a digest, so what it reports is the digest's
-# first 59 characters, which no whole-entry check can recognise. Older census
-# layers are frozen, so that boundary does not move. The self-test finds this
-# value here and checks it is honoured in this file and nowhere else.
-[[allowlists]]
-description = "digest fragment at a chunk boundary in the 9B8 census"
-targetRules = ["generic-api-key"]
-condition = "AND"
-paths = ['''^internal/provision/plan9_b8_census_test\.go$''']
-regexes = ['''^c635b439ae4bec54933118a8ff983251d47b81b40d1bb42663e881b55a6$''']
-
# Fake credentials typed into tests, each recognisable as one: a counting
# run (0123456789abcdef), a word (SecretValue, SENTINEL, nope), a test's
# own label. The Stripe keys exist to test that the console tells a live
diff --git a/AGENTS.md b/AGENTS.md
index d78d41e56..38fcc3754 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -309,9 +309,12 @@ anything.
keys are still reported. A real finding is removed, and rotated if it
was ever live. A fake a test needs is allowed by exact value in
`.gitleaks.toml`, scoped to its files; `gitleaks:allow` comments and
- `.gitleaksignore` do not work here. Census and checklist digests are
- judged by `scripts/gitleaks-gate/judge.go`, so a new census class, method
- or key name is added to its lists. `.amadan/README.md` has the details.
+ `.gitleaksignore` do not work here. The census test files and the design
+ checklist that `scripts/gitleaks-gate/notscanned.go` names by exact path
+ are not scanned at all: they hold sha256 digests of source, not secrets,
+ and a key committed in one would not be found. A new census file that
+ turns the step red with digest findings is added there by its exact
+ path. `.amadan/README.md` has the details.
- `20-cross@5` adds `GOOS=darwin`/`windows`/`linux-arm64` compiles, one
per shard. **The gate is not Linux-only**: `internal/host` is linked
into the CLI, which people run on Macs, so a Linux-only type assumption
diff --git a/Makefile b/Makefile
index f976f66eb..f419d81df 100644
--- a/Makefile
+++ b/Makefile
@@ -108,7 +108,8 @@ govulncheck:
# Installed once and handed to scripts/gitleaks-gate, because the gate runs
# it many times: it plants keys and proves they are reported, then scans the
# tracked files as they are now, uncommitted edits included. Untracked files
-# are not scanned. The tree, not the history: what a branch adds is found in
+# are not scanned, nor are the digest files scripts/gitleaks-gate/notscanned.go
+# names by exact path. The tree, not the history: what a branch adds is found in
# the run that adds it, and old values already in every clone would hold
# every branch red. The `&&` matters: no binary, no pass.
GITLEAKS_VERSION := v8.30.1
diff --git a/scripts/gitleaks-gate/judge.go b/scripts/gitleaks-gate/judge.go
deleted file mode 100644
index 8577d55e3..000000000
--- a/scripts/gitleaks-gate/judge.go
+++ /dev/null
@@ -1,149 +0,0 @@
-package main
-
-import (
- "os"
- "path/filepath"
- "regexp"
- "strings"
-)
-
-// What an approved digest looks like. gitleaks' generic rule reads a source
-// digest as a key whenever the field before it names one (key:RecordKey), so
-// the digests the repository pins have to be accepted somewhere.
-//
-// They are accepted here and not in .gitleaks.toml because an allowlist
-// cannot say what has to be true. A gitleaks allowance tests the line or the
-// reported secret, never both at once, and a line can be a perfect census
-// entry while the secret reported on it is another field: a bare key in the
-// unit field, after a file named auth.go, is a valid-looking unit name. So
-// approve holds the two together: the whole line must be a well-formed entry
-// AND the reported secret must be that entry's digest field.
-//
-// Every field below is limited to what censusParse
-// (internal/provision/plan9_b8_census_test.go) can write. A census change that
-// adds a class, a method or a key name turns the gate red here until the
-// lists catch up, which is the safe direction.
-const (
- goIdent = `[A-Za-z_][A-Za-z0-9_]*`
-
- // A repository-relative Go file: no separators a key=value needs.
- entryFile = `(?:[A-Za-z0-9_-]+/)*[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.go`
-
- // censusParse's unit names: Func, Recv.Method (? when the receiver has
- // no name), "var name", "var#1" for a grouped declaration, and #N on a
- // name seen twice in one file.
- entryUnit = `(?:` +
- `(?:(?:` + goIdent + `|\?)\.)?` + goIdent + `(?:#[0-9]+)?` +
- `|(?:var|const|type) ` + goIdent + `(?:#[0-9]+)?` +
- `|(?:var|const|type)#[0-9]+(?:#[0-9]+)?` +
- `)`
-
- // censusClasses.
- entryClass = `(?:record-primitive|record-writer|record-writer-raw|record-transport` +
- `|versioned-transport|foreign-recordkey|nonrecord|key-site|reference|testsupport)`
-
- // censusMethods.
- censusMethod = `(?:Put|PutFrom|PutIfAbsent|PutIfAbsentVersioned|PutIfAbsentVersionedAt` +
- `|PutObjectFrom|PutReplace|CopyVersion|CopyVersioned|CopyVersionedAt)`
-
- // censusKeyIdent: censusKeySuffixes, then censusKeyExact.
- censusKeyName = `(?:[A-Za-z0-9_]*(?i:recordkey|recordsprefix|sidecarsprefix|sidecarkey` +
- `|sidecarmanifestkey|writerecord|sequencedrecord)` +
- `|(?i:createrecord|updaterecord|setrecordregion|setrecordmove|setrecordrun` +
- `|setrecordinteractive|setrecordseed|setrecordfleetbox|setrecordfirstfleetbox` +
- `|setrecordcoordinator|setrecordreplicarelease|setrecordreplicaassignment` +
- `|recordreplicaretired|clearrecordreplicaassignment|haltrecordreplicadeploy` +
- `|setrecordreplicadeploy|requestrecordreplicaretry|requestreplicaretries` +
- `|setrecordassetgen|mintrecordassetgen|createsidecarrecord|claimrawupdaterecord))`
-
- entryKind = `(?:(?:def|id|sel|str):` + censusMethod +
- `|key:` + censusKeyName +
- `|lit:(?:instances|sidecars))`
-
- sha256Hex = `[0-9a-f]{64}`
-)
-
-const (
- categoryCensus = "census entry digests"
- categoryChecklist = "design checklist digests"
-
- checklistFile = "implementation/always-awake-consumers.json"
-)
-
-var (
- censusFile = regexp.MustCompile(`^internal/provision/[^/]+_census_test\.go$`)
-
- // {"file.go", "unit", "class", "kind,kind", "digest"}, or the }) that
- // closes a layer built with append.
- censusEntry = regexp.MustCompile(`^[ \t]*(?:censusEntry)?\{"` + entryFile + `", "` + entryUnit +
- `", "` + entryClass + `", "` + entryKind + `(?:,` + entryKind + `)*", "(` + sha256Hex + `)"\}\)?,?[ \t]*$`)
-
- // "file.go": "digest", inside source_hashes.
- checklistEntry = regexp.MustCompile(`^[ \t]*"` + entryFile + `": "(` + sha256Hex + `)",?[ \t]*$`)
-)
-
-// finding is the part of gitleaks' JSON report the gate reads.
-type finding struct {
- RuleID string
- File string
- Secret string
- StartLine int
- EndLine int
- Tags []string
-}
-
-// judge decides findings against the files of one scanned tree.
-type judge struct {
- dir string
- lines map[string][]string
-}
-
-func newJudge(dir string) *judge {
- return &judge{dir: dir, lines: map[string][]string{}}
-}
-
-// approve names the category a finding is approved under, or returns "" for
-// a finding that stands. It reads the line from the scanned file because
-// gitleaks' JSON report leaves the line out.
-func (j *judge) approve(f finding) string {
- if f.RuleID != "generic-api-key" || f.StartLine != f.EndLine {
- return ""
- }
- for _, tag := range f.Tags {
- if strings.HasPrefix(tag, "decoded:") {
- return ""
- }
- }
- var pattern *regexp.Regexp
- var category string
- switch {
- case censusFile.MatchString(f.File):
- pattern, category = censusEntry, categoryCensus
- case f.File == checklistFile:
- pattern, category = checklistEntry, categoryChecklist
- default:
- return ""
- }
- m := pattern.FindStringSubmatch(j.line(f.File, f.StartLine))
- if m == nil || m[1] != f.Secret {
- return ""
- }
- return category
-}
-
-// line returns line n (from 1) of a scanned file, or "" if there is none,
-// which no pattern accepts.
-func (j *judge) line(file string, n int) string {
- lines, ok := j.lines[file]
- if !ok {
- data, err := os.ReadFile(filepath.Join(j.dir, filepath.FromSlash(file)))
- if err == nil {
- lines = strings.Split(string(data), "\n")
- }
- j.lines[file] = lines
- }
- if n < 1 || n > len(lines) {
- return ""
- }
- return strings.TrimSuffix(lines[n-1], "\r")
-}
diff --git a/scripts/gitleaks-gate/main.go b/scripts/gitleaks-gate/main.go
index 47e1f58fc..8f9e5726d 100644
--- a/scripts/gitleaks-gate/main.go
+++ b/scripts/gitleaks-gate/main.go
@@ -2,9 +2,10 @@
// proves the scan still finds planted keys, then scans the tracked files.
//
// gitleaks does the finding, with its default rules less the exact values
-// .gitleaks.toml allows. This program decides what a finding means, as
-// scripts/govulncheck-gate does for govulncheck: the only findings it can
-// accept are source digests (judge.go says exactly which).
+// .gitleaks.toml allows. This program decides what is scanned and what a
+// finding means, as scripts/govulncheck-gate does for govulncheck: every
+// tracked file is scanned except the ones notscanned.go names by exact path,
+// and every finding fails the step except the key the gate plants itself.
//
// Anything it cannot establish is a failure: the wrong binary, a config
// gitleaks will not load, a report it cannot read, or a scan that did not
@@ -40,10 +41,16 @@ const (
// something", so that its own failures (status 1) cannot be mistaken
// for a scan that finished.
exitFindings = 3
-
- sentinelFile = "gitleaks-gate-sentinel.env"
)
+// finding is the part of gitleaks' JSON report the gate reads.
+type finding struct {
+ RuleID string
+ File string
+ Secret string
+ StartLine int
+}
+
func main() {
bin := flag.String("gitleaks", "", "path to the gitleaks binary")
version := flag.String("version", "", "the version the gitleaks binary must be")
@@ -141,78 +148,112 @@ func scan(ctx context.Context, bin, config, dir string) ([]finding, error) {
return findings, nil
}
-// scanTracked copies the tracked files into a scratch directory, scans them
-// with a sentinel key beside them, and fails on every finding not approved.
+// scanTracked scans the tracked files of the repository in the current
+// directory and fails on every finding.
func scanTracked(ctx context.Context, bin, config string) error {
- dir, err := os.MkdirTemp("", "gitleaks-gate-tree-")
+ tree, err := scanTree(ctx, bin, config, ".")
if err != nil {
return err
}
+ fmt.Printf("gitleaks: scanned %d tracked files; %d not scanned, by exact path (scripts/gitleaks-gate/notscanned.go)\n",
+ tree.scanned, tree.skipped)
+ if len(tree.standing) == 0 {
+ fmt.Println("gitleaks: clean")
+ return nil
+ }
+ for _, f := range tree.standing {
+ // Never the value: this goes to the CI log.
+ fmt.Printf("%s:%d: %s\n", f.File, f.StartLine, f.RuleID)
+ }
+ return fmt.Errorf("%d findings above: remove the value and rotate it if it was ever real; a fake a test needs is allowed by exact value in .gitleaks.toml", len(tree.standing))
+}
+
+// treeScan is what scanTree found in one repository.
+type treeScan struct {
+ scanned int // tracked files copied and scanned
+ skipped int // tracked files left out because notScanned names them
+ standing []finding // every finding but the planted sentinel, by file and line
+}
+
+// scanTree copies the tracked files of repo into a scratch directory, adds a
+// sentinel key beside them, scans the lot and returns every finding but the
+// sentinel's. A scan that does not report the sentinel is an error.
+//
+// The sentinel goes in a file whose name is random for each run and which is
+// created only if nothing is there, so it can never replace or hide a tracked
+// file: a tracked file of any name, gitleaks-gate-sentinel.env included, is
+// copied and scanned like the rest. Only the sentinel's own finding, its
+// exact value in its own file, is set aside.
+func scanTree(ctx context.Context, bin, config, repo string) (treeScan, error) {
+ dir, err := os.MkdirTemp("", "gitleaks-gate-tree-")
+ if err != nil {
+ return treeScan{}, err
+ }
defer os.RemoveAll(dir)
- files, err := copyTracked(ctx, dir)
+ scanned, skipped, err := copyTracked(ctx, repo, dir)
if err != nil {
- return err
+ return treeScan{}, err
}
sentinel := newKey(40)
- body := fmt.Sprintf("api_key = \"%s\"\n", sentinel)
- if err := os.WriteFile(filepath.Join(dir, sentinelFile), []byte(body), 0o600); err != nil {
- return err
+ sentinelFile := "gitleaks-gate-sentinel-" + newKey(12) + ".env"
+ out, err := os.OpenFile(filepath.Join(dir, sentinelFile), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)
+ if err != nil {
+ return treeScan{}, fmt.Errorf("plant the sentinel: %w", err)
+ }
+ _, err = fmt.Fprintf(out, "api_key = \"%s\"\n", sentinel)
+ if cerr := out.Close(); err == nil {
+ err = cerr
+ }
+ if err != nil {
+ return treeScan{}, fmt.Errorf("plant the sentinel: %w", err)
}
findings, err := scan(ctx, bin, config, dir)
if err != nil {
- return err
+ return treeScan{}, err
}
- j := newJudge(dir)
- approved := map[string]int{}
- var standing []finding
+ tree := treeScan{scanned: scanned, skipped: skipped}
sawSentinel := false
for _, f := range findings {
- if f.File == sentinelFile {
- sawSentinel = sawSentinel || f.Secret == sentinel
+ if f.File == sentinelFile && f.Secret == sentinel {
+ sawSentinel = true
continue
}
- if category := j.approve(f); category != "" {
- approved[category]++
- continue
- }
- standing = append(standing, f)
+ tree.standing = append(tree.standing, f)
}
if !sawSentinel {
- return errors.New("the scan did not report the key planted beside the tracked files")
- }
-
- fmt.Printf("gitleaks: scanned %d tracked files; approved %d %s and %d %s\n",
- files, approved[categoryCensus], categoryCensus, approved[categoryChecklist], categoryChecklist)
- if len(standing) == 0 {
- fmt.Println("gitleaks: clean")
- return nil
+ return treeScan{}, errors.New("the scan did not report the key planted beside the tracked files")
}
- sort.Slice(standing, func(a, b int) bool {
- if standing[a].File != standing[b].File {
- return standing[a].File < standing[b].File
+ sort.Slice(tree.standing, func(a, b int) bool {
+ if tree.standing[a].File != tree.standing[b].File {
+ return tree.standing[a].File < tree.standing[b].File
}
- return standing[a].StartLine < standing[b].StartLine
+ return tree.standing[a].StartLine < tree.standing[b].StartLine
})
- for _, f := range standing {
- // Never the value: this goes to the CI log.
- fmt.Printf("%s:%d: %s\n", f.File, f.StartLine, f.RuleID)
- }
- return fmt.Errorf("%d findings above: remove the value and rotate it if it was ever real; a fake a test needs is allowed by exact value in .gitleaks.toml", len(standing))
+ return tree, nil
}
-// copyTracked copies every tracked regular file into dir and returns how
-// many. It reads the list from the index and the bytes from the working
-// tree, so an uncommitted edit is scanned and an untracked file is not.
-// git archive would do the copying but honours export-ignore, which would
-// let a tracked .gitattributes take files out of the scan.
-func copyTracked(ctx context.Context, dir string) (int, error) {
- out, err := exec.CommandContext(ctx, "git", "ls-files", "-z", "--stage").Output()
+// copyTracked copies every tracked regular file of repo into dir, except the
+// ones notScanned names, and returns how many it copied and how many it left
+// out. It reads the list from the index and the bytes from the working tree,
+// so an uncommitted edit is scanned and an untracked file is not. git archive
+// would do the copying but honours export-ignore, which would let a tracked
+// .gitattributes take files out of the scan.
+//
+// Every notScanned entry has to be a tracked file: one that is not is an
+// error, so the list cannot keep a path that a new file could later take.
+func copyTracked(ctx context.Context, repo, dir string) (copied, skipped int, err error) {
+ cmd := exec.CommandContext(ctx, "git", "ls-files", "-z", "--stage")
+ cmd.Dir = repo
+ out, err := cmd.Output()
if err != nil {
- return 0, fmt.Errorf("list tracked files: %w", err)
+ return 0, 0, fmt.Errorf("list tracked files: %w", err)
+ }
+ excluded := map[string]bool{}
+ for _, path := range notScanned {
+ excluded[path] = false
}
- copied := 0
seen := map[string]bool{}
for _, entry := range strings.Split(string(out), "\x00") {
meta, path, ok := strings.Cut(entry, "\t")
@@ -221,39 +262,50 @@ func copyTracked(ctx context.Context, dir string) (int, error) {
}
seen[path] = true
if filepath.Base(path) == ".gitleaksignore" {
- return 0, fmt.Errorf("%s is tracked: findings are allowed in .gitleaks.toml, by value, and not by fingerprint", path)
+ return 0, 0, fmt.Errorf("%s is tracked: findings are allowed in .gitleaks.toml, by value, and not by fingerprint", path)
}
// Symlinks (120000) and submodules (160000) have no content here.
if !strings.HasPrefix(meta, "100") {
continue
}
- info, err := os.Lstat(path)
+ if _, listed := excluded[path]; listed {
+ excluded[path] = true
+ skipped++
+ continue
+ }
+ source := filepath.Join(repo, filepath.FromSlash(path))
+ info, err := os.Lstat(source)
if errors.Is(err, fs.ErrNotExist) {
continue // deleted in the working tree: nothing left to scan
}
if err != nil {
- return 0, err
+ return 0, 0, err
}
if !info.Mode().IsRegular() {
continue
}
- data, err := os.ReadFile(path)
+ data, err := os.ReadFile(source)
if err != nil {
- return 0, err
+ return 0, 0, err
}
target := filepath.Join(dir, filepath.FromSlash(path))
if err := os.MkdirAll(filepath.Dir(target), 0o700); err != nil {
- return 0, err
+ return 0, 0, err
}
if err := os.WriteFile(target, data, 0o600); err != nil {
- return 0, err
+ return 0, 0, err
}
copied++
}
+ for _, path := range notScanned {
+ if !excluded[path] {
+ return 0, 0, fmt.Errorf("notscanned.go names %s, which is not a tracked file: take it off the list", path)
+ }
+ }
if copied == 0 {
- return 0, errors.New("git lists no tracked files to scan")
+ return 0, 0, errors.New("git lists no tracked files to scan")
}
- return copied, nil
+ return copied, skipped, nil
}
// newKey returns a random credential-shaped value of n characters. Its
diff --git a/scripts/gitleaks-gate/notscanned.go b/scripts/gitleaks-gate/notscanned.go
new file mode 100644
index 000000000..889e92e5a
--- /dev/null
+++ b/scripts/gitleaks-gate/notscanned.go
@@ -0,0 +1,49 @@
+package main
+
+// notScanned names the tracked files the gate does not scan at all. Nothing
+// in them is read by gitleaks, so a credential committed in one of them is
+// NOT found.
+//
+// They hold sha256 digests of source, not secrets: the census test files pin
+// a digest per unit, and the design checklist pins a digest per file in its
+// source_hashes. gitleaks' generic rule reads a digest after a key-like word
+// as a key, and no allowance can tell a digest from a 64-character hex key,
+// so these files are left out whole, by name, rather than judged by shape.
+//
+// Each entry is a whole repository path, compared for equality: no globs, no
+// directory prefixes, no patterns. A file renamed away from its entry is
+// scanned under its new name, and the gate fails while an entry names a path
+// that git does not track, so a stale entry cannot later cover a new file.
+//
+// The list holds only the files gitleaks flags. A census file not listed here
+// is scanned like any other; if a new census layer turns the step red with
+// digest findings, check that every finding is a digest, then add the file's
+// exact path below.
+var notScanned = []string{
+ "implementation/always-awake-consumers.json",
+ "internal/provision/agent_start_demo_3_census_test.go",
+ "internal/provision/claim_empty_cohort_fix1_census_test.go",
+ "internal/provision/console_remote_instances_census_test.go",
+ "internal/provision/demo_census_test.go",
+ "internal/provision/edge_asset_cache_1_census_test.go",
+ "internal/provision/fleet_public_routes_census_test.go",
+ "internal/provision/instance_egress_sizes_census_test.go",
+ "internal/provision/instance_restore_658_census_test.go",
+ "internal/provision/linked_deployments_slice1_census_test.go",
+ "internal/provision/nearest_region_a_census_test.go",
+ "internal/provision/nearest_region_b_census_test.go",
+ "internal/provision/operator_pages_census_test.go",
+ "internal/provision/plan14_e_write_census_test.go",
+ "internal/provision/plan14_p3_census_test.go",
+ "internal/provision/plan9_b8_census_test.go",
+ "internal/provision/platform_mail_submission_census_test.go",
+ "internal/provision/region_ha_g2_fixes_census_test.go",
+ "internal/provision/regional_domains_447_census_test.go",
+ "internal/provision/retire_app_lock_407_census_test.go",
+ "internal/provision/retire_window_415_census_test.go",
+ "internal/provision/rootfs_apps_4_census_test.go",
+ "internal/provision/self_serve_moves1_census_test.go",
+ "internal/provision/stateless_placement_census_test.go",
+ "internal/provision/stateless_replicas_4_drill1_census_test.go",
+ "internal/provision/team_scoped_credentials_census_test.go",
+}
diff --git a/scripts/gitleaks-gate/selftest.go b/scripts/gitleaks-gate/selftest.go
index 64219c712..311af191c 100644
--- a/scripts/gitleaks-gate/selftest.go
+++ b/scripts/gitleaks-gate/selftest.go
@@ -5,56 +5,38 @@ import (
"errors"
"fmt"
"os"
+ "os/exec"
+ "path"
"path/filepath"
- "regexp"
+ "sort"
"strings"
"sync"
)
// The self-test runs inside the gitleaks step because it needs the binary.
-// It plants keys generated at run time, so none is ever committed, and scans
-// each case twice:
+// It plants keys generated at run time, so none is ever committed.
+//
+// Each single-file case is scanned twice:
//
// - with gitleaks' default rules alone, the control: the planted value has
// to be found there, or the case proves nothing;
-// - with the real config and the judge: a planted key must still stand,
-// and a well-formed entry must pass.
-const (
- plantedCensus = "internal/provision/zz_planted_census_test.go"
- ordinaryFile = "internal/widgets/pump.go"
- boundaryFile = "internal/provision/plan9_b8_census_test.go"
-
- // gitleaks reads 100,000 bytes and then up to 25,000 more looking for
- // a blank line, so a file with no blank line is cut at this offset.
- // The boundary cases fail if a new gitleaks moves it.
- chunkBoundary = 125_000
-)
-
-var knownFragment = regexp.MustCompile(`'''\^([0-9a-f]{59})\$'''`)
+// - with the real config: the planted key must still be reported.
+//
+// Then a whole repository is built and put through scanTree, the path the
+// real scan takes, to prove what is and is not scanned (trackedTest).
+const ordinaryFile = "internal/widgets/pump.go"
-// selfCase is one file to scan. A planted case names the line and the value
-// that must be reported; a passing case (passes) names the lines the default
-// rules flag and the judge must accept.
+// selfCase is one file to scan and the value that must be reported on line.
type selfCase struct {
name string
file string
body string
- lines []int
+ line int
secret string
- exact bool // the reported value must be secret itself, not contain it
- passes bool
}
func selfTest(ctx context.Context, bin, config string) error {
- raw, err := os.ReadFile(config)
- if err != nil {
- return err
- }
- m := knownFragment.FindSubmatch(raw)
- if m == nil {
- return fmt.Errorf("%s names no 59-character digest fragment", config)
- }
- cases := selfCases(string(m[1]))
+ cases := selfCases()
control, err := os.MkdirTemp("", "gitleaks-gate-control-")
if err != nil {
@@ -81,22 +63,21 @@ func selfTest(ctx context.Context, bin, config string) error {
wg.Wait()
var failed []error
- planted, passing := 0, 0
+ planted := 0
for i, c := range cases {
verdict := "reported"
- if c.passes {
- verdict = "passes"
- }
if results[i] != nil {
failed = append(failed, fmt.Errorf("%s: %w", c.name, results[i]))
verdict = "FAILED"
- } else if c.passes {
- passing++
} else {
planted++
}
fmt.Printf("self-test: %-8s %s\n", verdict, c.name)
}
+ tracked, err := trackedTest(ctx, bin, config, control)
+ if err != nil {
+ failed = append(failed, fmt.Errorf("tracked files: %w", err))
+ }
closed, err := failClosed(ctx, bin, config, control)
if err != nil {
failed = append(failed, err)
@@ -104,8 +85,8 @@ func selfTest(ctx context.Context, bin, config string) error {
if len(failed) > 0 {
return errors.Join(failed...)
}
- fmt.Printf("self-test: %d planted keys reported, %d well-formed cases passed, %d broken setups refused\n",
- planted, passing, closed)
+ fmt.Printf("self-test: %d planted keys reported, %d tracked files judged, %d broken setups refused\n",
+ planted, tracked, closed)
return nil
}
@@ -127,51 +108,144 @@ func (c selfCase) run(ctx context.Context, bin, defaults, config string) error {
if err != nil {
return fmt.Errorf("control scan: %w", err)
}
- for _, line := range c.lines {
- if !c.reported(found, line) {
- return fmt.Errorf("the default rules do not flag line %d, so this case proves nothing", line)
+ if !c.reported(found) {
+ return fmt.Errorf("the default rules do not flag line %d, so this case proves nothing", c.line)
+ }
+ if found, err = scan(ctx, bin, config, dir); err != nil {
+ return err
+ }
+ if !c.reported(found) {
+ return errors.New("THE PLANTED KEY WAS HIDDEN")
+ }
+ return nil
+}
+
+// reported says whether findings include this case's value on its line.
+func (c selfCase) reported(findings []finding) bool {
+ for _, f := range findings {
+ if f.File == c.file && f.StartLine == c.line && strings.Contains(f.Secret, c.secret) {
+ return true
}
}
+ return false
+}
- found, err = scan(ctx, bin, config, dir)
- if err != nil {
+// trackedTest builds a git repository and scans it with scanTree, as the
+// real scan does, to prove three things:
+//
+// - a tracked file named gitleaks-gate-sentinel.env, the sentinel's old
+// fixed name, is scanned and its key reported: the sentinel cannot
+// replace or hide a tracked file;
+// - every file notScanned names is left out, and nothing else: the same
+// key under a near miss of each name (another directory above it, a
+// suffix, a prefix on the file name) is reported, as is one in a census
+// file the list does not name;
+// - a list entry that git does not track is refused.
+//
+// It returns how many tracked files it judged.
+func trackedTest(ctx context.Context, bin, config, scratch string) (int, error) {
+ repo := filepath.Join(scratch, "repo")
+ if err := os.MkdirAll(repo, 0o700); err != nil {
+ return 0, err
+ }
+ want := map[string]string{} // file: the key that must be reported in it
+ hidden := map[string]bool{} // files whose key must not be reported
+ plant := func(file string) (string, error) {
+ key := newKey(40)
+ target := filepath.Join(repo, filepath.FromSlash(file))
+ if err := os.MkdirAll(filepath.Dir(target), 0o700); err != nil {
+ return "", err
+ }
+ return key, os.WriteFile(target, []byte("api_key = \""+key+"\"\n"), 0o600)
+ }
+ expect := func(file string) error {
+ key, err := plant(file)
+ want[file] = key
return err
}
- j := newJudge(dir)
- var standing []finding
- for _, f := range found {
- if j.approve(f) == "" {
- standing = append(standing, f)
+
+ if err := expect("gitleaks-gate-sentinel.env"); err != nil {
+ return 0, err
+ }
+ if err := expect("internal/provision/zz_planted_census_test.go"); err != nil {
+ return 0, err
+ }
+ for _, p := range notScanned {
+ if _, err := plant(p); err != nil {
+ return 0, err
+ }
+ hidden[p] = true
+ dir, base := path.Split(p)
+ for _, near := range []string{"x/" + p, p + ".orig", dir + "zz_" + base} {
+ if err := expect(near); err != nil {
+ return 0, err
+ }
+ }
+ }
+ if err := git(ctx, repo, "init", "-q"); err != nil {
+ return 0, err
+ }
+ if err := git(ctx, repo, "add", "-A"); err != nil {
+ return 0, err
+ }
+
+ tree, err := scanTree(ctx, bin, config, repo)
+ if err != nil {
+ return 0, err
+ }
+ if tree.skipped != len(notScanned) {
+ return 0, fmt.Errorf("%d files left out, want the %d notscanned.go names", tree.skipped, len(notScanned))
+ }
+ got := map[string]bool{}
+ for _, f := range tree.standing {
+ switch {
+ case hidden[f.File]:
+ return 0, fmt.Errorf("%s is listed in notscanned.go but was scanned", f.File)
+ case want[f.File] == "" || f.Secret != want[f.File] || f.StartLine != 1:
+ return 0, fmt.Errorf("unexpected finding at %s:%d", f.File, f.StartLine)
}
+ got[f.File] = true
}
- if c.passes {
- if len(standing) > 0 {
- return fmt.Errorf("%d findings stand against a well-formed entry, the first on line %d", len(standing), standing[0].StartLine)
+ var missed []string
+ for file := range want {
+ if !got[file] {
+ missed = append(missed, file)
}
- return nil
}
- if !c.reported(standing, c.lines[0]) {
- return errors.New("THE PLANTED KEY WAS HIDDEN")
+ sort.Strings(missed)
+ if len(missed) > 0 {
+ return 0, fmt.Errorf("THE PLANTED KEY WAS HIDDEN in %s", strings.Join(missed, ", "))
}
- return nil
+ fmt.Printf("self-test: %-8s a tracked file named gitleaks-gate-sentinel.env\n", "reported")
+ fmt.Printf("self-test: %-8s %d near misses of the names notscanned.go lists\n", "reported", len(want)-1)
+ fmt.Printf("self-test: %-8s the %d files notscanned.go lists\n", "skipped", len(hidden))
+
+ // Untrack one listed file: the list now names a path git does not
+ // track, which must be refused.
+ if err := git(ctx, repo, "rm", "-q", "--cached", notScanned[0]); err != nil {
+ return 0, err
+ }
+ if _, _, err := copyTracked(ctx, repo, filepath.Join(scratch, "stale")); err == nil {
+ return 0, fmt.Errorf("a notscanned.go entry git does not track (%s) was not refused", notScanned[0])
+ }
+ fmt.Printf("self-test: %-8s a notscanned.go entry git does not track\n", "refused")
+ return len(want) + len(hidden), nil
}
-// reported says whether findings include this case's value on line.
-func (c selfCase) reported(findings []finding, line int) bool {
- for _, f := range findings {
- if f.File != c.file || f.StartLine != line {
- continue
- }
- switch {
- case c.secret == "":
- return true
- case c.exact && f.Secret == c.secret:
- return true
- case !c.exact && strings.Contains(f.Secret, c.secret):
- return true
+// git runs git in repo with no inherited repository settings, so it can
+// only act on repo.
+func git(ctx context.Context, repo string, args ...string) error {
+ cmd := exec.CommandContext(ctx, "git", args...)
+ cmd.Dir = repo
+ for _, kv := range os.Environ() {
+ if !strings.HasPrefix(kv, "GIT_") {
+ cmd.Env = append(cmd.Env, kv)
}
}
- return false
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("git %s: %w: %s", strings.Join(args, " "), err, strings.TrimSpace(string(out)))
+ }
+ return nil
}
// failClosed checks that a setup that cannot scan is an error, never a pass.
@@ -201,157 +275,21 @@ func failClosed(ctx context.Context, bin, config, scratch string) (int, error) {
return len(setups), nil
}
-// entry writes one census entry from its five fields.
-func entry(file, unit, class, kinds, digest string) string {
- return fmt.Sprintf(`{"%s", "%s", "%s", "%s", "%s"},`, file, unit, class, kinds, digest)
-}
-
-// censusBody puts lines into a census test file; the first is on line 4.
-func censusBody(lines ...string) string {
- return "package provision\n\nvar inventory = []censusEntry{\n\t" + strings.Join(lines, "\n\t") + "\n}\n"
-}
-
-// checklistBody puts one line into the checklist's shape, on line 3.
-func checklistBody(line string) string {
- return "{\n \"source_hashes\": {\n " + line + "\n }\n}\n"
-}
-
-// boundaryBody places line so that the first chunk ends cut bytes into it,
-// and returns the file with the line's number.
-func boundaryBody(line string, cut int) (string, int) {
- var b strings.Builder
- b.WriteString("package provision\n")
- n := 1
- target := chunkBoundary - cut
- for ; target-b.Len() >= 128; n++ {
- b.WriteString("//" + strings.Repeat(" ", 61) + "\n")
- }
- b.WriteString("//" + strings.Repeat(" ", target-b.Len()-3) + "\n")
- n++
- b.WriteString(line + "\n")
- for range 40 {
- b.WriteString("// the rest of the layer\n")
- }
- return b.String(), n + 1
-}
-
-func selfCases(fragment string) []selfCase {
- const (
- file = "internal/widgets/pump.go"
- auth = "internal/console/auth.go"
- unit = "Pump.Start"
- class = "nonrecord"
- kinds = "key:RecordKey"
- )
+func selfCases() []selfCase {
key, digest := newKey(40), newDigest()
-
- census := func(name, line, secret string) selfCase {
- return selfCase{name: name, file: plantedCensus, body: censusBody(line), lines: []int{4}, secret: secret}
- }
- checklist := func(name, line, secret string) selfCase {
- return selfCase{name: name, file: checklistFile, body: checklistBody(line), lines: []int{3}, secret: secret}
- }
ordinary := func(name, line, secret string) selfCase {
body := "package widgets\n\n" + line + "\n"
- return selfCase{name: name, file: ordinaryFile, body: body, lines: []int{3}, secret: secret}
- }
- boundary := func(name, path, line string, cut int, secret string, passes bool) selfCase {
- body, n := boundaryBody(line, cut)
- return selfCase{name: name, file: path, body: body, lines: []int{n}, secret: secret, exact: true, passes: passes}
+ return selfCase{name: name, file: ordinaryFile, body: body, line: 3, secret: secret}
}
-
- prefix := "\t" + `{"` + file + `", "` + unit + `", "key-site", "` + kinds + `", "`
- otherFragment := newDigest()[:len(fragment)]
- longKey := newKey(80)
- const keyPrefix = `api_key = "`
-
return []selfCase{
- // Field 1: the file.
- census("census field 1 (file): key=value", entry("internal/widgets/api_key="+key+".go", unit, class, kinds, digest), key),
- census("census field 1 (file): key after a colon", entry("internal/widgets/token:"+key+".go", unit, class, kinds, digest), key),
-
- // Field 2: the unit. The last two are valid unit names, so only
- // tying the finding to the digest field reports them.
- census("census field 2 (unit): key=value", entry(file, "api_key="+key, class, kinds, digest), key),
- census("census field 2 (unit): password: value", entry(file, "password: "+key, class, kinds, digest), key),
- census("census field 2 (unit): bare key after a key-named file", entry(auth, key, class, kinds, digest), key),
- census("census field 2 (unit): Recv.key after a key-named file", entry(auth, "Zq."+key, class, kinds, digest), key),
-
- // Field 3: the class.
- census("census field 3 (class): key=value", entry(file, unit, "token="+key, kinds, digest), key),
- census("census field 3 (class): bare key after a key-named unit", entry(file, "rotateApiKey", key, kinds, digest), key),
-
- // Field 4: the kinds.
- census("census field 4 (kinds): key=value after a real kind", entry(file, unit, class, "key:RecordKey,api_key="+key, digest), key),
- census("census field 4 (kinds): bare key as a key name", entry(file, unit, class, "key:"+key, digest), key),
- census("census field 4 (kinds): secret=value", entry(file, unit, class, "secret="+key, digest), key),
-
- // Field 5: the digest.
- census("census field 5 (digest): a key in place of the digest", entry(file, unit, class, kinds, key), key),
- census("census field 5 (digest): uppercase hex", entry(file, unit, class, kinds, strings.ToUpper(digest)), strings.ToUpper(digest)),
- census("census field 5 (digest): 63 hex characters", entry(file, unit, class, kinds, digest[:63]), digest[:63]),
- census("census field 5 (digest): digest followed by key=value", entry(file, unit, class, kinds, digest+" api_key="+key), key),
-
- // Around an entry, and on other lines of a census file.
- census("census line: key=value after a whole entry", entry(file, unit, class, kinds, digest)+" // api_key="+key, key),
- census("census line: key=value before a whole entry", `var api_key = "`+key+`"; `+entry(file, unit, class, kinds, digest), key),
- census("census file: 64-hex value assigned to a key", `api_key = "`+digest+`"`, digest),
- census("census file: 64-hex value in a short entry", `{"auth", "`+digest+`"},`, digest),
-
- // Text no rule flags still voids the entry: the digest on that line
- // is reported, so every field has to hold what a census can write.
- census("malformed entry: other text in field 1", entry("internal/widgets/note="+key+".go", unit, class, kinds, digest), digest),
- census("malformed entry: other text in field 2", entry(file, "note="+key, class, kinds, digest), digest),
- census("malformed entry: other text in field 3", entry(file, unit, "note="+key, kinds, digest), digest),
- census("malformed entry: other text in field 4", entry(file, unit, class, "note="+key+","+kinds, digest), digest),
- census("malformed entry: other text after the entry", entry(file, unit, class, kinds, digest)+" // note="+key, digest),
-
- // The JSON checklist.
- checklist("checklist: a key in place of the digest", `"`+auth+`": "`+key+`",`, key),
- checklist("checklist: 64-hex value under a key name", `"api_key": "`+digest+`",`, digest),
- checklist("checklist: key=value in the file name", `"token=`+key+`.go": "`+digest+`",`, key),
- checklist("checklist: digest followed by key=value", `"`+auth+`": "`+digest+` api_key=`+key+`",`, key),
- {
- name: "checklist: a well-formed line in another file", file: "implementation/other.json",
- body: checklistBody(`"` + auth + `": "` + digest + `",`), lines: []int{3}, secret: digest,
- },
-
- // A chunk boundary: gitleaks reports the cut-off start of a value.
- boundary("chunk boundary: another digest fragment in the known file", boundaryFile,
- prefix+otherFragment+"abcde\"},", len(prefix)+len(otherFragment), otherFragment, false),
- boundary("chunk boundary: the known fragment in another census file", plantedCensus,
- prefix+fragment+"abcde\"},", len(prefix)+len(fragment), fragment, false),
- boundary("chunk boundary: a key cut in half", boundaryFile,
- keyPrefix+longKey+`"`, len(keyPrefix)+40, longKey[:40], false),
-
- // Ordinary source files.
ordinary("source file: a key", `const apiKey = "`+key+`"`, key),
ordinary("source file: a 64-hex key", `const signingSecret = "`+digest+`"`, digest),
- ordinary("source file: a whole census entry", entry(auth, unit, class, kinds, digest), digest),
+ ordinary("source file: a census-shaped entry", `{"internal/console/auth.go", "Pump.Start", "nonrecord", "key:RecordKey", "`+digest+`"},`, digest),
ordinary("source file: a key marked gitleaks:allow", `const apiKey = "`+key+`" // gitleaks:allow`, key),
ordinary("source file: a test's fake value outside tests", `const token = "tok-`+`flagship-2"`, "tok-"+"flagship-2"),
{
name: "allowed file: another key beside its allowed value", file: "internal/console/testdata/configseal_vectors.json",
- body: "{\n \"note\": \"vectors\",\n \"api_key\": \"" + key + "\"\n}\n", lines: []int{3}, secret: key,
- },
-
- // What has to keep passing, with no change to any config.
- {
- name: "well-formed new census entries", file: "internal/provision/new_layer_census_test.go",
- body: censusBody(
- entry("internal/brandnew/store.go", "Store.WriteThing", "record-writer", "sel:Put,key:RecordKey", newDigest()),
- entry("internal/brandnew/store.go", "writeSomethingNew", "key-site", "def:PutFrom,key:RecordKey", newDigest()),
- entry("internal/brandnew/store.go", "var recordNames", "reference", "lit:instances,key:RecordKey", newDigest()),
- entry("internal/brandnew/store.go", "const#2", "nonrecord", "str:Put,key:RecordKey", newDigest()),
- "censusEntry"+strings.TrimSuffix(entry("internal/brandnew/store.go", "Store.Close#2", "testsupport", "id:CopyVersion,key:RecordKey", newDigest()), ",")+")",
- ),
- lines: []int{4, 5, 6, 7, 8}, passes: true,
- },
- {
- name: "a well-formed new checklist line", file: checklistFile,
- body: checklistBody(`"` + auth + `": "` + digest + `",`), lines: []int{3}, secret: digest, passes: true,
+ body: "{\n \"note\": \"vectors\",\n \"api_key\": \"" + key + "\"\n}\n", line: 3, secret: key,
},
- boundary("the known digest fragment at its boundary", boundaryFile,
- prefix+fragment+"abcde\"},", len(prefix)+len(fragment), fragment, true),
}
}