Repository navigation
Feat/m5 corpus #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0ffa9fe
feat(corpus): labeled precision/recall harness for detection quality
mkmuniz 0cec92f
fix(detect/br): standardize mask separators, and stop matching across…
mkmuniz 433c606
feat(detect/aws): detect AWS access key ids, which the upstream corpu…
mkmuniz eec1bba
docs: record the corpus and the AWS detector in the project map
mkmuniz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Corpus | ||
|
|
||
| Labeled examples that measure what vedei catches and what it cries wolf over. | ||
|
|
||
| A scanner's worth is not that it compiles. It is precision and recall on real | ||
| input, and for Brazilian data the hard one is precision: the upstream secret | ||
| rules score candidates against an English dictionary, so a Portuguese word like | ||
| `senhapadrao` reads as random and gets reported. That cost is invisible until | ||
| you measure it against labeled data. This directory is that data. | ||
|
|
||
| ## Format | ||
|
|
||
| One directive per line in `cases/*.txt`: | ||
|
|
||
| ``` | ||
| expect cpf 529.982.247-25 # must be found, as a cpf | ||
| reject 529.982.247-00 # must not be reported — wrong check digit | ||
| ``` | ||
|
|
||
| - **`expect <type> <value>`** — a true positive. The engine must report a | ||
| finding of `<type>` over `<value>`. A miss is a recall failure: a leak walked | ||
| past. | ||
| - **`reject <value> # reason`** — a false positive. The engine must report | ||
| nothing. A hit is a precision failure: on the agent hook, redacting something | ||
| the model needed. The reason is required — a reject nobody can explain is a | ||
| reject nobody can safely remove. | ||
|
|
||
| Everything after `#` is a comment. | ||
|
|
||
| ## Running | ||
|
|
||
| ```bash | ||
| make corpus # or: go test ./corpus/ | ||
| ``` | ||
|
|
||
| The gate is strict: every `expect` must be found and every `reject` must stay | ||
| quiet. That is right for hand-labeled data, where each line is a deliberate | ||
| claim — a threshold is for scraped corpora where some error is expected. The | ||
| test still prints precision and recall, because the numbers are the point and a | ||
| reviewer should see them move. | ||
|
|
||
| ## Adding a case | ||
|
|
||
| When a scan produces a false positive, add the value here as a `reject` with the | ||
| reason, then fix the detector until this test passes again. When a detector | ||
| gains a document type, add `expect` cases for it. The file | ||
| `cases/false-positives.txt` is the running record of what scanning the real | ||
| world actually produced — every entry in it was once a wrong finding. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # CNPJ — numeric and the alphanumeric format in force from 2026-07-06. | ||
|
|
||
| expect cnpj 11.222.333/0001-81 | ||
| expect cnpj 11222333000181 | ||
|
|
||
| expect cnpj 00.000.000/0001-91 # the Uniao's CNPJ: body all zeros, but check digits close | ||
|
|
||
| reject 11.222.333/0001-82 # check digit wrong | ||
| reject 12.345.678/0001-00 # check digits do not close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # CPF — true positives and the near-misses that must stay quiet. | ||
| # All valid values have correct check digits by construction; a fixture with a | ||
| # wrong one would only prove the generator agrees with the validator. | ||
|
|
||
| expect cpf 529.982.247-25 | ||
| expect cpf 52998224725 | ||
| expect cpf 111.444.777-35 | ||
|
|
||
| # The check digit is the whole point: these are one digit off and must not be | ||
| # reported, or vedei is just a regex and claims otherwise. | ||
| reject 529.982.247-00 # last digit wrong, fails mod 11 | ||
| reject 111.444.777-30 # check digit does not close | ||
| reject 000.000.000-00 # repeated sequence, invalid by rule even though mod 11 passes | ||
|
|
||
| # Shapes that look CPF-ish but are not. | ||
| reject 1234567890 # ten digits, too short | ||
| reject app version 1.2.3 # dotted, but not eleven digits | ||
|
|
||
| # Space as a separator, standardized across every document type. The feared | ||
| # cost is a three-digit table column; the check digit is what keeps it quiet. | ||
| expect cpf 529 982 247 25 | ||
| reject linha 100 200 300 40 # three-digit columns, check digit does not close | ||
| reject valores 123 456 789 10 # same shape, fails mod 11 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # The precision corpus proper: things that pass a checksum or match a shape by | ||
| # accident. Every one of these was a real false positive, or the exact class of | ||
| # one, that an earlier version reported. This file is the record of what running | ||
| # vedei against the world actually produced. | ||
|
|
||
| # A Go module pseudo-version. The timestamp YYYYMMDDHHMMSS passes Luhn about one | ||
| # time in ten; this one did, and was reported as a credit card. | ||
| reject v0.0.0-20240915155400-7ee5256398cf # timestamp read as card-pan | ||
| reject migration_20240915155400_add.sql # same timestamp, in a filename | ||
|
|
||
| # A UUID. A v4 is a valid Pix EVP key by shape and essentially never one in | ||
| # fact; the sixteen digits straddling a hyphen also passed Luhn once. | ||
| reject session 11111111-2222-3333-4444-555555555555 # UUID read as card-pan | ||
|
|
||
| # A Brazilian phone number in E.164 once read as a card-pan: it begins with 55, | ||
| # inside the Mastercard issuer range, and its digits passed Luhn. That reading is | ||
| # gone. It is still a Pix key by type, which is correct and lives in pix.txt — the | ||
| # bare number here must simply never be a card. | ||
| reject boleto 4532 1111 1111 111 # 15 digits, grouped as a card but fails Luhn | ||
|
|
||
| # A base64 module hash in go.sum: entropy by design, not a secret. | ||
| reject h1:o1uxfymjZ7jZ4MsgCErcwWGtVKSiNAXtS59Lhs6uI/g= # go.sum hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # CNH, PIS, título and CNS. Vectors generated by each published algorithm and | ||
| # confirmed against the live extractor, never copied from a third party. | ||
|
|
||
| expect cnh 73022314994 | ||
| expect cnh 20909550300 | ||
| expect pis 43912547832 | ||
| expect pis 22322316163 | ||
| expect titulo-eleitor 306636791040 | ||
| expect titulo-eleitor 862441572097 | ||
| expect cns 100000000000007 | ||
|
|
||
| reject 11111111111 # a repeated digit is not a valid document of any kind | ||
|
|
||
| # Space-separated forms, now caught uniformly. | ||
| expect pis 439 12547 83 2 | ||
| expect titulo-eleitor 3066 3679 1040 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Pix keys. A phone or email used as a Pix key is sensitive data, not noise, so | ||
| # these are true positives. The phone is the one that used to be read as a card. | ||
|
|
||
| expect pix-key recebedor +5511980198775 | ||
| expect pix-key chave pix fulano@exemplo.com.br | ||
|
|
||
| # A random UUID with no Pix context is not a key: a v4 is a valid EVP key by | ||
| # shape and almost never one in fact. | ||
| reject trace 11111111-2222-3333-4444-555555555555 # UUID, no Pix context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Credentials. The AWS access-key cases are the gap this milestone closes: the | ||
| # upstream corpus reports none of them, measured, not even with an assignment | ||
| # context. Values are assembled so the file carries no live-shaped secret. | ||
|
|
||
| expect aws-access-key-id AKIA4KJ7WQZR2LMNXBTQ | ||
| expect aws-access-key-id ASIA4KJ7WQZR2LMNXBTQ | ||
|
mkmuniz marked this conversation as resolved.
Dismissed
|
||
| expect aws-access-key-id export AWS_ACCESS_KEY_ID=AKIA4KJ7WQZR2LMNXBTQ | ||
|
mkmuniz marked this conversation as resolved.
Dismissed
|
||
|
|
||
| # base32 has no 0, 1, 8 or 9, and the prefix must be a credential-bearing one. | ||
| reject ABCD4KJ7WQZR2LMNXBTQ # 20 chars, base32 body, but not an AWS prefix | ||
| reject AKIA1KJ7WQZR2LMNXBTQ # AKIA prefix but a 1 is not base32 | ||
|
mkmuniz marked this conversation as resolved.
Dismissed
|
||
| reject the quick brown fox jumped over the lazy dog # ordinary prose | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.