Every change is scanned inside the forge after it is submitted and before it can land, for secrets and for regulated data. A finding keeps the change waiting until a person clears it. Security lesson 4 walks through it on a forge of your own.
What is read
The scan reads each file the commit changes against its parent (for a merge, against its parents merged), and judges only its new lines: lines the parent’s version doesn’t have. Moving a line doesn’t make it new.
A binary file is skipped, whatever its size. A file is binary, as git decides it, if its first 8,000 bytes hold a zero byte.
Large changes, and many at once
A change’s size limits neither the scan nor the memory it takes. The forge reads a change’s files one after another, in path order, within limits a node sets for all its scans together: so many files read at once, and findings written to the repository as they are made, in small batches. A merge’s parents are merged the same way, a file at a time. When more changes are submitted than a node scans at once, they wait their turn in a durable queue, which a new leader takes up where the last left it. A landing waits until its scans are done, and a scan that fails is tried again after a minute.
The rules are data the forge’s own scanner reads. Secrets are found with Gitleaks’ default rule file, from release v8.30.1; nothing of Gitleaks runs. Regulated data is found with the forge’s own rules, in the same format: payment card numbers that pass the Luhn check, and international bank account numbers that pass their mod 97 check.
From a match to a finding
The scanner applies the rules as Gitleaks’ detector does:
- a rule with keywords runs only on text that holds one of them;
- the secret is the whole match, or the group of it the rule names;
- a rule’s entropy threshold and the allowlists, the file’s and the rule’s, discard what they allow;
- a generic rule’s finding gives way to a more specific rule’s on the same line whose secret holds it.
One thing differs on purpose: a gitleaks:allow comment silences nothing, since an agent could write one to clear its own finding.
Encoded text
A secret written in another encoding is still a secret. After reading the text as written, the scan decodes percent-encoding, unicode escapes, hex and base64 as Gitleaks’ decoder does, and reads the result again, up to five encodings deep. A match found this way is placed on the lines of exactly the encoded text it came from, even when one encoded run spans several lines, and its hash is of the decoded secret, so one secret has one hash however it is written.
Here a card number is written in hex:
$ af-server --dev
...$ source ~/af-dev/dev/env
$ af workspace add ~/scan
Workspace at /home/you/scan
Paths: **
main has no landing yet
$ cd ~/scan
$ af new -m "Add a billing fixture"
Working on change tomrqtmxzztsotzvrnkmnukxulxzuwkv at commit cb6de5bfde5e7bbc234cc4674a7f8753df3e36fca6e578eb29888da4a6d0f7a9
$ echo "card = 34313131313131313131313131313131" > billing.txt
$ af submit
Submitted commit 156a10d5f9d804e33ef332efa01f0f1111198155bce3698fdc82d6955ec854e7, 1 edit in its last snapshot$ af status
Change tomrqtmxzztsotzvrnkmnukxulxzuwkv (submitted) at commit 156a10d5f9d804e33ef332efa01f0f1111198155bce3698fdc82d6955ec854e7
Landing waits for: clearance
The landing scan found 1 thing$ af scan
commit 156a10d5f9d804e33ef332efa01f0f1111198155bce3698fdc82d6955ec854e7: 1 finding, by gitleaks v8.30.1 default rules; atoll-forge regulated data
rules sha256 eb894a9ed5a3e046adfeea5b6a2745e835fcddd9534b73f545c2a974c3f6103e
billing.txt:1 payment-card-number sha256 9bbef19476623ca56c17da75fd57734dbf82530686043a6e491c6d71befe8f6e decoded from hex (depth 1)The finding names what the secret was decoded from, and how deep. af scan --json prints the same as one JSON object, for a program to read.
Who sees what
A scan can name files in folders a reader may not read. What each reader sees follows the folder access it has when it asks:
- Someone who may read every path the change touches reads the scan whole.
- Anyone else reads a view: only the findings and omitted files at paths they may read, counted as theirs alone, with a line saying the view is partial. Nothing in it tells what the rest holds, how much there is, or where it is.
The change’s landing requirements stay visible to every reader of it, as does the event that says a scan found something or couldn’t read a file: they say that the change needs attention, never where.
Access is checked as it stands. Before each page or message of results goes out, the node brings its copy of the organization’s records current, so a revocation committed before then counts, on every node.
Here the payroll folder is restricted to a team after a change to it was submitted:
$ cd ~
$ af workspace add ~/views
Workspace at /home/you/views
Paths: **
main has no landing yet
$ cd ~/views
$ af new -m "Add test cards"
Working on change tnvomsqwnuyqsqqtuuuvpuulwrnwnlyu at commit 71f6ecbdaeb3f570f2561da1b3ade05c549033aa0471e042786c1569a6a3f9e8
$ mkdir -p billing payroll
$ echo "card: 4111111111111111" > billing/test.txt
$ echo "card: 5555555555554444" > payroll/test.txt
$ af submit
Submitted commit 7d5fe25e88732712c02089775ca82206290297091ab4fdf2fbba346435f7712a, 2 edits in its last snapshot$ af status
Change tnvomsqwnuyqsqqtuuuvpuulwrnwnlyu (submitted) at commit 7d5fe25e88732712c02089775ca82206290297091ab4fdf2fbba346435f7712a
Landing waits for: clearance
The landing scan found 2 things$ af folder restrict payroll --team payroll --reason "salary data"
done: it took effect at once, on your word as an administrator
$ af scan
commit 7d5fe25e88732712c02089775ca82206290297091ab4fdf2fbba346435f7712a: 1 finding, by gitleaks v8.30.1 default rules; atoll-forge regulated data
rules sha256 eb894a9ed5a3e046adfeea5b6a2745e835fcddd9534b73f545c2a974c3f6103e
billing/test.txt:1 payment-card-number sha256 9bbef19476623ca56c17da75fd57734dbf82530686043a6e491c6d71befe8f6e
a partial view: you may not read every folderThe view counts one finding, though the scan holds two. An agent started by this person reads no more than they do.
What the record keeps
A finding is its rule, its file and line, and the SHA-256 of what matched, never the match: the forge’s records are kept for good, so a secret written into them could never be taken back, and a hash is enough for anyone who has the secret to confirm it.
A landing’s provenance names the rules that ran, by name and by the SHA-256 of their files, and the policy the scan ran under: the SHA-256 of a short document naming everything that decides what a scan covers.
policy=2
decode-depth=5
limit=unlimited
binary=nul-in-first-8000
rules=<SHA-256 of Gitleaks' rule file>
rules=<SHA-256 of the forge's rule file>A scan counts only under the forge’s current policy, so a forge started with other rules scans a waiting change again before it can land. A policy may also limit how much of one file a scan reads. The default sets no limit. Under one, a text file over it isn’t read: the scan is incomplete, the change waits for a complete scan, and no clearance counts for text no scan read.
Clearing a finding
A finding that isn’t a real secret (a test value, a key already rotated) may be cleared, with a reason, by a person who holds the approver role and may read every path the change touches: nobody clears what they cannot see. The clearance signs the scan’s results: their SHA-256 and count, under the forge’s policy. af clear reads every result, checks that what it read has that digest and count, prints it, and signs only that. The record is the same size whatever the scan found, and names no path or secret. If the commit changes, so does the scan, and the clearance no longer counts. A scan that left a file unread is never cleared. An approver may clear findings on a change of their own line unless the forge requires another person (af-server --two-administrators), and every compliance report lists such a clearance as an exception.
The card number in hex was a test value. Its approver clears it:
$ cd ~/scan
$ af grant dev@localhost approver --reason "reviews test fixtures"
done: it took effect at once, on your word as an administrator
$ af clear @ --reason "a test card number, never real"
commit 156a10d5f9d804e33ef332efa01f0f1111198155bce3698fdc82d6955ec854e7: 1 finding, by gitleaks v8.30.1 default rules; atoll-forge regulated data
rules sha256 eb894a9ed5a3e046adfeea5b6a2745e835fcddd9534b73f545c2a974c3f6103e
billing.txt:1 payment-card-number sha256 9bbef19476623ca56c17da75fd57734dbf82530686043a6e491c6d71befe8f6e decoded from hex (depth 1)
cleared 1 finding of commit 156a10d5f9d804e33ef332efa01f0f1111198155bce3698fdc82d6955ec854e7 of change tomrqtmxzztsotzvrnkmnukxulxzuwkvWhen the secret is real
Abandon the change, remove the secret and submit again. Then rotate the secret: it reached the forge’s storage with the change, whether or not the change landed. Purging can erase the contents themselves.
Next
- Security lesson 4: a card number held back, a token encoded, a test value cleared.
af scanandaf clearin the reference.- Permissions and approvals: the approver role and the landing’s other requirements.