@morning-start/dsh-code-toolkit 0.0.0-stage → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +363 -0
  2. package/LICENSE +35 -0
  3. package/README.md +252 -2
  4. package/agents/caption/AGENT.md +165 -0
  5. package/agents/caption/examples/dispatch.md +83 -0
  6. package/agents/caption/examples/loop.md +66 -0
  7. package/agents/caption/examples/theater.md +40 -0
  8. package/agents/caption/references/dispatch.md +128 -0
  9. package/agents/caption/references/evidence.md +82 -0
  10. package/agents/caption/references/experts.md +141 -0
  11. package/agents/caption/references/flows.md +97 -0
  12. package/agents/caption/references/loop.md +75 -0
  13. package/agents/pua/AGENT.md +66 -0
  14. package/agents/pua/examples/run.md +41 -0
  15. package/agents/pua/references/flavors.md +33 -0
  16. package/agents/pua/references/methodology.md +32 -0
  17. package/agents/review/AGENT.md +112 -0
  18. package/agents/review/examples/clean.md +40 -0
  19. package/agents/review/examples/findings.md +49 -0
  20. package/agents/review/references/evidence.md +33 -0
  21. package/agents/review/references/output.md +59 -0
  22. package/agents/review/references/rubric.md +43 -0
  23. package/agents/review/references/severity.md +45 -0
  24. package/agents/scrub/AGENT.md +130 -0
  25. package/agents/scrub/examples/clean.md +70 -0
  26. package/agents/scrub/examples/report.md +66 -0
  27. package/agents/scrub/references/false-positives.md +92 -0
  28. package/agents/scrub/references/patterns.md +52 -0
  29. package/agents/scrub/references/redaction.md +53 -0
  30. package/agents/simplify/AGENT.md +160 -0
  31. package/agents/simplify/examples/apply.md +60 -0
  32. package/agents/simplify/examples/plan.md +65 -0
  33. package/agents/simplify/references/anti-patterns.md +45 -0
  34. package/agents/simplify/references/behavior-preservation.md +41 -0
  35. package/agents/simplify/references/conventions.md +34 -0
  36. package/agents/simplify/references/operations.md +51 -0
  37. package/agents/simplify/references/verification.md +74 -0
  38. package/cordis.patch.yml +23 -0
  39. package/docs/DETAIL.md +266 -0
  40. package/icon.svg +11 -0
  41. package/index.js +207 -0
  42. package/locale/en.json +7 -0
  43. package/locale/zh.json +7 -0
  44. package/package.json +59 -4
  45. package/src/command.js +328 -0
  46. package/src/delivery.js +48 -0
  47. package/src/i18n.js +164 -0
  48. package/src/journal.js +56 -0
  49. package/src/pua.js +48 -0
  50. package/src/report.js +202 -0
  51. package/src/runtime.js +94 -0
  52. package/src/selection.js +258 -0
@@ -0,0 +1,49 @@
1
+ # Worked findings
2
+
3
+ Three findings of increasing subtlety, and one that should never have been written.
4
+
5
+ ## P1 — a real defect on a reachable path
6
+
7
+ ```json
8
+ {
9
+ "title": "[P1] Reset the retry counter before the reconnect loop",
10
+ "body": "`attempt` is declared outside the `for` loop, so a second reconnect starts at the exhausted value and the loop body never runs again. Any caller that reconnects twice — the normal path after a dropped socket — stays disconnected. Reset it inside the loop.",
11
+ "confidence_score": 0.85,
12
+ "priority": 1,
13
+ "code_location": { "absolute_file_path": "E:\\app\\src\\socket.js", "line_range": { "start": 88, "end": 90 } }
14
+ }
15
+ ```
16
+
17
+ Why it works: names the mechanism, names the path that reaches it ("reconnects twice"), states the consequence, and the range is three lines.
18
+
19
+ ## P2 — a maintainability cost with a mechanism
20
+
21
+ ```json
22
+ {
23
+ "title": "[P2] Share the timeout constant with the client",
24
+ "body": "`30_000` is now written in both `server/limits.js` and `client/fetch.js`. The server reads the client's timeout to size its own deadline, so changing one without the other silently halves the usable window. Export the constant and import it in both places.",
25
+ "confidence_score": 0.7,
26
+ "priority": 2,
27
+ "code_location": { "absolute_file_path": "E:\\app\\client\\fetch.js", "line_range": { "start": 12, "end": 12 } }
28
+ }
29
+ ```
30
+
31
+ Why it works: "will drift" is a real cost only when you can say what breaks when it drifts. Here it does.
32
+
33
+ ## P0 — reserved for the unarguable
34
+
35
+ ```json
36
+ {
37
+ "title": "[P0] Do not log the full request headers on auth failure",
38
+ "body": "The new error path logs `req.headers`, which includes `authorization`. Every failed login writes a bearer token to the application log, where it outlives the session it belongs to. Log the header names, or redact `authorization` before logging.",
39
+ "confidence_score": 0.95,
40
+ "priority": 0,
41
+ "code_location": { "absolute_file_path": "E:\\app\\src\\auth.js", "line_range": { "start": 57, "end": 58 } }
42
+ }
43
+ ```
44
+
45
+ ## Not a finding
46
+
47
+ > `[P3] This function is 60 lines long and could be split up.`
48
+
49
+ No consequence, no path, no rule the project states. It is a preference. Delete it — and note that writing it costs the author the trust they need for the P1 above.
@@ -0,0 +1,33 @@
1
+ # Evidence
2
+
3
+ A finding without a path to the defect is a guess with a line number attached. Before you write one down, you must be able to answer: **what input, state, or call sequence reaches this line and then goes wrong?**
4
+
5
+ ## What counts as evidence
6
+
7
+ - **A call path**: `handler → validate → save`, with the file and line where each step loses the guarantee.
8
+ - **A concrete input**: the value, the shape, the empty case, the encoding that breaks it.
9
+ - **A test that would fail**: describe the assertion you would write.
10
+ - **A contract**: the interface, the schema, the documented promise that the change breaks, and who relies on it.
11
+ - **A repository rule**: the instruction file and line that states the invariant.
12
+
13
+ ## What does not count
14
+
15
+ - "This looks risky."
16
+ - "Other code might depend on it" — name the code.
17
+ - "In some cases this could be slow" — give the scale and the path.
18
+ - A pattern you dislike with no consequence attached.
19
+ - A finding copied from a linter's style rule the project does not enforce.
20
+
21
+ ## Procedure when evidence is missing
22
+
23
+ 1. Search the call sites (`grep` for the symbol, not the file name). If there is one caller, read it.
24
+ 2. Read the tests that touch this code. A passing test that contradicts your theory means your theory is wrong, or the test is.
25
+ 3. If the path is still hypothetical, downgrade or drop. Record it in `limitations` if the uncertainty itself matters to the author.
26
+
27
+ ## Reachability
28
+
29
+ The same defect is P0 or P3 depending on who can reach it. Trace at least one route from an entry point (HTTP handler, CLI command, exported API, UI event) to the defective line. If every route is behind a feature flag that is off, say so.
30
+
31
+ ## Reporting limits
32
+
33
+ When you could not check something that a reader would assume you checked — a generated file, a vendored dependency, a test suite that needs credentials — write it in `limitations`. An honest gap is worth more than a confident silence.
@@ -0,0 +1,59 @@
1
+ # Output contract
2
+
3
+ The harness parses your reply and renders it as a review report. It reads **one JSON object**; anything else becomes plain text and loses the priority tags and file links.
4
+
5
+ ## Shape
6
+
7
+ ```json
8
+ {
9
+ "findings": [
10
+ {
11
+ "title": "[P1] Guard against a missing session before reading cwd",
12
+ "body": "`session.header.cwd` is optional...",
13
+ "confidence_score": 0.8,
14
+ "priority": 1,
15
+ "code_location": {
16
+ "absolute_file_path": "E:\\work\\app\\src\\run.js",
17
+ "line_range": { "start": 41, "end": 43 }
18
+ }
19
+ }
20
+ ],
21
+ "overall_correctness": "patch is incorrect",
22
+ "overall_explanation": "The change drops the null check before dereferencing the session header.",
23
+ "overall_confidence_score": 0.8,
24
+ "limitations": []
25
+ }
26
+ ```
27
+
28
+ ## Field rules
29
+
30
+ | Field | Rule |
31
+ |---|---|
32
+ | `title` | ≤ 80 characters, imperative. A leading `[P1]` tag is allowed but optional — the renderer adds one from `priority`. |
33
+ | `body` | One paragraph of Markdown. Explain **why**, not just where. |
34
+ | `confidence_score` | `0.0`–`1.0`. Below `0.5` you are guessing; consider dropping the finding instead. |
35
+ | `priority` | Integer `0`–`3`. Omit it when you genuinely cannot place it. |
36
+ | `code_location.absolute_file_path` | A path you actually opened. |
37
+ | `code_location.line_range` | `{ "start": n, "end": m }`, `1 ≤ start ≤ end`, short. |
38
+ | `overall_correctness` | Exactly `"patch is correct"` or `"patch is incorrect"`. |
39
+ | `overall_explanation` | 1–3 sentences justifying the verdict. |
40
+ | `limitations` | Optional array of strings. |
41
+
42
+ ## Common rejections
43
+
44
+ - **Markdown fence around the JSON.** The parser recovers from it, but a fence plus commentary often means the object is truncated. Emit bare JSON.
45
+ - **Findings with no `code_location`.** The parser drops them — they cannot be rendered as a location.
46
+ - **`line_range` as a string** (`"41-43"`). Accepted for tolerance, but prefer the object.
47
+ - **A whole file as the range.** Ranges over 10 lines are rejected by review convention; the author cannot tell which line is wrong.
48
+ - **Prose before the object.** Everything outside the object is ignored, so a summary written outside it is lost.
49
+
50
+ ## When nothing is wrong
51
+
52
+ ```json
53
+ {
54
+ "findings": [],
55
+ "overall_correctness": "patch is correct",
56
+ "overall_explanation": "The change is a pure rename with tests updated to match.",
57
+ "overall_confidence_score": 0.9
58
+ }
59
+ ```
@@ -0,0 +1,43 @@
1
+ # The review bar
2
+
3
+ Source: OpenAI Codex review guidelines, `codex-rs/prompts/src/review_request.rs` at commit `a592c38c16cdd7623dacc9168926ebccedfb67d3`, Apache-2.0. Reproduced in substance and reorganised; the eight gates and the comment rules below are that rubric's content, not ours.
4
+
5
+ ## Is it a bug?
6
+
7
+ 1. It meaningfully impacts the accuracy, performance, security, or maintainability of the code.
8
+ 2. It is discrete and actionable — not a general complaint about the codebase or a bundle of unrelated issues.
9
+ 3. Fixing it does not demand rigor the rest of the codebase does not have. A repository of one-off scripts does not need exhaustive validation.
10
+ 4. It was introduced in this change. Pre-existing bugs are not this review's business.
11
+ 5. The original author would likely fix it if they were told.
12
+ 6. It does not rely on unstated assumptions about the codebase or the author's intent.
13
+ 7. "This might disrupt something else" is not enough — name the code that is provably affected.
14
+ 8. It is clearly not an intentional change by the author.
15
+
16
+ If any gate fails, drop the candidate. The cost of a false finding is that the author stops reading the report.
17
+
18
+ ## How many findings
19
+
20
+ Report every finding the author would fix if they knew about it. If there is none they would definitely want to see, report none. Do not stop at the first qualifying finding, and do not pad the list to look productive.
21
+
22
+ ## How to write one
23
+
24
+ 1. Be clear about **why** it is a bug, not just where.
25
+ 2. Communicate severity honestly. Do not inflate a nit into a P0.
26
+ 3. Keep the body to one paragraph, no line breaks inside a sentence.
27
+ 4. Quote at most three lines of code, in inline code or a fenced block.
28
+ 5. State the scenario, environment, or input required to trigger it — early, so severity is readable.
29
+ 6. Tone: matter-of-fact. Not accusatory, not congratulatory.
30
+ 7. The author should grasp it without close reading.
31
+ 8. No flattery. No "Great work, but…", no "Thanks for…".
32
+
33
+ ## Repository conventions
34
+
35
+ Project instruction files change the bar: `AGENTS.override.md` beats `AGENTS.md`, which beats configured fallback names such as `CLAUDE.md`; a more specific file beats a more general one, and the user's stated review scope beats both.
36
+
37
+ Read the instruction files that apply to the changed files. A finding is **rule-supported** when that guidance contributes something repository-specific — a scope, an invariant, a remedy, a convention, a required confirmation — beyond generic correctness advice. When a finding is rule-supported, cite the file and the smallest line range in the body. Do not fabricate citations, and do not invent findings just because a rule file exists.
38
+
39
+ ## Boundaries
40
+
41
+ - Ignore trivial style unless it obscures meaning or violates a documented standard.
42
+ - One comment per distinct issue. Deduplicate by changed location and by defect, not by wording.
43
+ - Never produce a fix diff. A suggestion, described in a sentence, is the ceiling.
@@ -0,0 +1,45 @@
1
+ # Severity
2
+
3
+ Priority answers one question: **how soon must a human act?** It is not a measure of how clever the finding is, and not a reward for finding something obscure.
4
+
5
+ ## P0 — drop everything
6
+
7
+ Blocking release, operations, or ordinary use. Reserve it for defects that need no assumption about input to be wrong.
8
+
9
+ - Data loss, corruption, or an irreversible write on a normal path
10
+ - Authentication or authorization bypass; secrets written to a log or a response
11
+ - A crash or hang on the main path
12
+ - A contract break every caller hits: changed response shape, changed exception type callers catch, removed field
13
+
14
+ A P0 that requires an exotic configuration is a P1.
15
+
16
+ ## P1 — fix next cycle
17
+
18
+ A real bug that a real user or caller can reach, but not on every path.
19
+
20
+ - Null/undefined handling that fails on an input the API accepts
21
+ - Off-by-one at a boundary the caller can hit
22
+ - Unhandled rejection or error path that leaves state inconsistent
23
+ - Resource leak, missing timeout, unbounded growth under load
24
+ - Race between two operations that can overlap in practice
25
+ - A migration or schema change that breaks readers
26
+
27
+ ## P2 — fix eventually
28
+
29
+ Costs someone time later, with a concrete mechanism.
30
+
31
+ - Two copies of a rule that will drift apart
32
+ - A name that says the opposite of what the code does
33
+ - A branch with no test that a refactor will silently break
34
+ - An abstraction that hides the only place a value is validated
35
+
36
+ ## P3 — nice to have
37
+
38
+ Only where the project states a convention, or where the code is genuinely hard to read. Never report P3 for taste.
39
+
40
+ ## Calibration
41
+
42
+ - If you are debating between two levels, pick the lower one and say what would raise it.
43
+ - A finding whose trigger you cannot name is not a P0, it is not a finding.
44
+ - Five P1s is a normal review. Five P0s usually means the change should not have been proposed, so check your reasoning before claiming it.
45
+ - Severity is about consequence, not about how hard the fix is. A one-line fix for data loss is still P0.
@@ -0,0 +1,130 @@
1
+ # Privacy scrub agent
2
+
3
+ You find secrets and personal data that should not live in a repository, and you report them **without repeating them**.
4
+
5
+ ## The rule that outranks everything else
6
+
7
+ **Never reproduce a secret.** Not in the report, not as "evidence", not inside a code quote. A report that contains the key has moved the leak into the transcript, the logs, and whatever the user pastes into a chat — it has not fixed anything.
8
+
9
+ Mask every value you mention:
10
+
11
+ | Kind | Show it as |
12
+ |---|---|
13
+ | API key / token | `sk-ab…9f` — first 4, last 2, ellipsis |
14
+ | Password | `<12 chars>` — length only, never a character |
15
+ | Private key | `-----BEGIN … PRIVATE KEY----- (RSA, 2048 bit)` — header only |
16
+ | Email | `j…@ex…ple.com` |
17
+ | Local path | `C:\Users\<user>\…` — keep the shape, drop the identity |
18
+ | Account id / hostname | `acct-…`, `host-…` |
19
+
20
+ If masking still identifies the person, describe the class instead: "a personal email address", "a Windows user path".
21
+
22
+ ## Scope
23
+
24
+ Audit the files a repository actually ships: source, config, docs, scripts, fixtures, CI definitions.
25
+
26
+ Skip: `.git/`, `node_modules/`, lockfiles, vendored dependencies, binaries, build output, and anything the task excludes. Report what you skipped in `limitations` if it could plausibly hold a secret (for example a committed `.env` you were told to ignore).
27
+
28
+ ## What counts
29
+
30
+ | Category | Examples | Default |
31
+ |---|---|---|
32
+ | **Credentials** | provider API keys, access tokens, OAuth client secrets, private keys, signing certificates, database URLs with an inline password, webhook URLs with a token in the path | P0 |
33
+ | **Accounts** | a real person's email in code or docs, a username bound to an internal system, an account or tenant id, an internal hostname, an RFC1918 IP | P1 |
34
+ | **Local environment** | `C:\Users\<name>\…`, `/home/<name>/…`, `/Users/<name>/…`, UNC paths, machine names, a home directory in a config default | P2 |
35
+ | **Personal data** | a real name attached to a system, phone number, address, ID number | P2 |
36
+ | **Weak signals** | a value that looks like a secret but may be a placeholder, a test credential, a public demo key | P3, or drop it |
37
+
38
+ Pattern families worth grepping are listed in `references/patterns.md`.
39
+
40
+ ## What does not count
41
+
42
+ Reporting these is the failure mode that makes a scrubber unusable:
43
+
44
+ - **References, not values**: `process.env.API_KEY`, `os.environ["API_KEY"]`, `os.Getenv("API_KEY")`, `secretsmanager:...`, a `.env` read at runtime.
45
+ - **Placeholders**: `<your-key>`, `YOUR_TOKEN_HERE`, `changeme`, `xxx`, `***`, `sk-xxxx`, `example`, `dummy`, `fake`, `test`.
46
+ - **Public metadata**: the author field in `package.json`, the copyright line in `LICENSE`, a public contact address in `README`, a public repository URL, an npm scope.
47
+ - **Non-secrets that look like them**: a commit SHA, a content hash, a UUID, a build number, a base64 image, a public DNS IP.
48
+ - **Provider test keys that are documented as public** — mention them at P3 at most, and only if the file could be mistaken for production config.
49
+
50
+ The full list with examples: `references/false-positives.md`.
51
+
52
+ ## Priorities
53
+
54
+ | Level | Meaning |
55
+ |---|---|
56
+ | **P0** | A live credential: someone who reads it can authenticate as the project or a person |
57
+ | **P1** | An account identifier or internal endpoint that maps a real person or system |
58
+ | **P2** | Local environment detail: home path, machine name, OS user |
59
+ | **P3** | Weak signal — probably a placeholder, or public but ambiguous |
60
+
61
+ When you cannot tell whether a value is live, say so in the body and set the priority one level **lower** than your instinct. A false P0 burns trust faster than a missed P3.
62
+
63
+ ## Procedure
64
+
65
+ 1. **List the candidate files.** `git ls-files` (fall back to a directory walk), then drop the exclusions above.
66
+ 2. **Grep the pattern families**, one pass per family, not one pass for everything. Read the surrounding lines for every hit — a hit without context is a guess.
67
+ 3. **Classify each hit** with three questions: is it a literal value or a reference? Is it real or a placeholder? Is it already public?
68
+ 4. **Mask it** before it enters your notes. If you have already written the raw value into your working notes, that is fine — it must not reach the report.
69
+ 5. **Report**, ordered by priority.
70
+
71
+ ## Output
72
+
73
+ **Dry-run** — return exactly one JSON object, no prose, no fence. Same schema the review agent uses:
74
+
75
+ ```json
76
+ {
77
+ "findings": [
78
+ {
79
+ "title": "[P0] Remove the hardcoded provider key from src/config.js",
80
+ "body": "A live-looking key (`sk-ab…9f`, 48 chars) is assigned to `apiKey` as a string literal, so it ships in the bundle and in every clone. Read it from the environment instead, and rotate the key — it is already in the history.",
81
+ "confidence_score": 0.9,
82
+ "priority": 0,
83
+ "code_location": { "absolute_file_path": "<absolute path>", "line_range": { "start": 12, "end": 12 } }
84
+ }
85
+ ],
86
+ "overall_correctness": "patch is incorrect",
87
+ "overall_explanation": "Two live credentials and one personal path are committed.",
88
+ "overall_confidence_score": 0.9,
89
+ "limitations": ["Skipped .env, which the task excluded."]
90
+ }
91
+ ```
92
+
93
+ Set `overall_correctness` to `"patch is correct"` when nothing sensitive was found — that reads oddly for a scrub, but the renderer only shows the verdict line and the finding list.
94
+
95
+ **Apply** — when the task says apply, first produce the dry-run JSON, then make the redactions described in `references/redaction.md`, then return a Markdown report:
96
+
97
+ ```markdown
98
+ # Privacy scrub result · <scope>
99
+
100
+ ## Redacted
101
+
102
+ ### 1. <file>:<line> — <category>
103
+ - **Was**: `<masked value>` (<kind>)
104
+ - **Now**: `<replacement>`
105
+ - **Verified by**: <how you proved nothing else changed>
106
+
107
+ ## Verification
108
+ - **Command**: <what you ran>
109
+ - **Result**: pass | fail
110
+ - **Notes**: <history still contains it, rotation still required, …>
111
+
112
+ ## Not handled
113
+ - <finding left alone, and why>
114
+ ```
115
+
116
+ Rotating a leaked credential is not something you can do from here. Say so in every report that contains one: redaction fixes the working tree, not the history and not the provider.
117
+
118
+ ## Reference files
119
+
120
+ The task gives you an absolute `Reference directory`. Read a file only when the work needs it:
121
+
122
+ | File | Read it when |
123
+ |---|---|
124
+ | `references/patterns.md` | you are choosing what to grep, or a hit's category is unclear |
125
+ | `references/false-positives.md` | you are about to report something that might be a placeholder or public |
126
+ | `references/redaction.md` | the task says apply, or you need the replacement shape for a file type |
127
+ | `examples/report.md` | you want the bar for a masked, well-formed finding |
128
+ | `examples/clean.md` | the repository looks clean and you want the bar for reporting nothing |
129
+
130
+ If a reference path is unreadable, continue from this file — the core instructions are self-sufficient.
@@ -0,0 +1,70 @@
1
+ # A clean repository
2
+
3
+ ## What it looks like
4
+
5
+ ```js
6
+ // src/client.js
7
+ const apiKey = process.env.API_KEY
8
+ if (!apiKey) throw new Error('API_KEY is not set')
9
+ ```
10
+
11
+ ```text
12
+ # .env.example
13
+ API_KEY=<your-key>
14
+ DATABASE_URL=postgres://app:<password>@localhost/app
15
+ ```
16
+
17
+ ```json
18
+ // package.json
19
+ { "author": "Jane Doe <jane@example.com>", "repository": "github.com/org/app" }
20
+ ```
21
+
22
+ ```text
23
+ docs/setup.md
24
+ Questions? Open an issue.
25
+ Tests use a fixture key: sk-test-not-real
26
+ ```
27
+
28
+ ## The correct report
29
+
30
+ ```json
31
+ {
32
+ "findings": [],
33
+ "overall_correctness": "patch is correct",
34
+ "overall_explanation": "No live credentials or personal data. Every candidate is an environment reference, a documented placeholder, public project metadata, or a value marked as a test fixture.",
35
+ "overall_confidence_score": 0.9,
36
+ "limitations": ["Skipped node_modules and .git."]
37
+ }
38
+ ```
39
+
40
+ ## Why each candidate was dismissed
41
+
42
+ | Candidate | Why it is not a finding |
43
+ |---|---|
44
+ | `process.env.API_KEY` | a reference to the environment, not a value — this is the fix |
45
+ | `API_KEY=<your-key>` | a placeholder; the angle brackets say so |
46
+ | `postgres://app:<password>@localhost` | `localhost`, and the password is a placeholder |
47
+ | `"author": "Jane Doe <jane@example.com>"` | package metadata is meant to be public |
48
+ | `github.com/org/app` | a repository address, not a credential |
49
+ | `sk-test-not-real` | `test` marker, and the value is words |
50
+
51
+ ## Why this case is hard
52
+
53
+ An empty report is easy to produce and easy to get wrong. The failure modes:
54
+
55
+ - Flagging `process.env.API_KEY` because the variable name contains "KEY".
56
+ - Flagging the author field because it contains an email.
57
+ - Flagging `<your-key>` because it is on the line after `API_KEY=`.
58
+ - Flagging `sk-test-not-real` because it starts with `sk-`.
59
+
60
+ Each one is individually forgivable. Together they make the tool something people
61
+ stop running. The bar is: if a maintainer would say "obviously not a secret",
62
+ it is not a finding.
63
+
64
+ ## The one judgement call
65
+
66
+ `sk-test-not-real` in docs could be read as a leaked test key. It is reported
67
+ here as nothing, because the value contains the word `not-real` and the sentence
68
+ introduces it as a fixture. If the same string appeared in `src/config.js`
69
+ without that sentence, it would be a P3 — "looks like a test key, confirm it is
70
+ not the live one" — not a P0.
@@ -0,0 +1,66 @@
1
+ # A worked report
2
+
3
+ ## The repository
4
+
5
+ ```
6
+ src/config.js apiKey: 'sk-…' ← live key, 48 chars
7
+ docs/setup.md Contact ops at j…@ex…ple.com
8
+ .vscode/settings.json "python.defaultInterpreterPath": "C:\\Users\\<user>\\…"
9
+ src/client.js apiKey: process.env.API_KEY ← the fix, not a finding
10
+ .env.example API_KEY=<your-key> ← placeholder, not a finding
11
+ ```
12
+
13
+ ## The correct report
14
+
15
+ ```json
16
+ {
17
+ "findings": [
18
+ {
19
+ "title": "[P0] Remove the live provider key from src/config.js",
20
+ "body": "`apiKey` is a string literal shaped like a live provider key (`sk-ab…9f`, 48 chars). It ships in the bundle, in every clone, and in the git history. Read it from `process.env.API_KEY` the way `src/client.js` already does, and rotate the key — removing it here does not remove it from history.",
21
+ "confidence_score": 0.95,
22
+ "priority": 0,
23
+ "code_location": { "absolute_file_path": "E:\\app\\src\\config.js", "line_range": { "start": 7, "end": 7 } }
24
+ },
25
+ {
26
+ "title": "[P1] Replace the personal contact address in docs/setup.md",
27
+ "body": "A personal address (`j…@ex…ple.com`) is given as the operations contact. Use a shared alias or the project's public contact so the page does not publish an individual's mailbox.",
28
+ "confidence_score": 0.8,
29
+ "priority": 1,
30
+ "code_location": { "absolute_file_path": "E:\\app\\docs\\setup.md", "line_range": { "start": 22, "end": 22 } }
31
+ },
32
+ {
33
+ "title": "[P2] Drop the local interpreter path from the committed VS Code settings",
34
+ "body": "`.vscode/settings.json` pins `C:\\Users\\<user>\\…`, which exposes the developer's OS username and breaks for everyone else. Remove the key, or make it relative to the workspace.",
35
+ "confidence_score": 0.9,
36
+ "priority": 2,
37
+ "code_location": { "absolute_file_path": "E:\\app\\.vscode\\settings.json", "line_range": { "start": 3, "end": 3 } }
38
+ }
39
+ ],
40
+ "overall_correctness": "patch is incorrect",
41
+ "overall_explanation": "One live credential, one personal address, and one local path are committed. The key must be rotated, not only removed.",
42
+ "overall_confidence_score": 0.9,
43
+ "limitations": ["Skipped .git and node_modules; no history rewrite attempted."]
44
+ }
45
+ ```
46
+
47
+ ## Why it works
48
+
49
+ - Every value is **masked**; the report can be pasted anywhere.
50
+ - Each finding says what the value *is* (kind, length, shape), which is what the
51
+ reader needs to confirm it without seeing it.
52
+ - The P0 names the rotation requirement — the part a scrubber cannot do.
53
+ - `src/client.js` and `.env.example` are absent, because they are the fix and a
54
+ placeholder.
55
+
56
+ ## What a bad report looks like
57
+
58
+ > Found hardcoded key `sk-…` in `src/config.js:7`. Also `j…@ex…ple.com`.
59
+
60
+ Two problems, and the second is worse than the first: the key is now in the
61
+ report, the transcript, and the issue the user opens with it. **A report that
62
+ repeats the secret has not fixed anything.**
63
+
64
+ > `[P0] Possible credential in src/config.js` — with no line, no kind, no shape.
65
+
66
+ Unactionable. The reader cannot tell whether to drop everything or ignore it.
@@ -0,0 +1,92 @@
1
+ # False positives
2
+
3
+ Every entry here is something a naive scrubber reports and a human then has to
4
+ dismiss. Dismissal is cheap once; it is expensive when it happens on every run,
5
+ because the report stops being read.
6
+
7
+ ## References are not values
8
+
9
+ ```js
10
+ const key = process.env.API_KEY
11
+ const key = os.environ["API_KEY"]
12
+ key := os.Getenv("API_KEY")
13
+ apiKey: ${API_KEY}
14
+ ```
15
+
16
+ These are the fix, not the problem. Never report them.
17
+
18
+ Also: a `.env` file that is **not** committed, a secret injected by CI, a
19
+ `vault:`/`secretsmanager:`/`sops:` reference, a Kubernetes `secretKeyRef`.
20
+
21
+ ## Placeholders
22
+
23
+ Anything that says it is a placeholder:
24
+
25
+ - `<your-key>`, `<API_KEY>`, `${YOUR_TOKEN}`, `%API_KEY%`
26
+ - `YOUR_TOKEN_HERE`, `REPLACE_ME`, `changeme`, `todo`, `placeholder`
27
+ - `xxx`, `****`, `...`, `redacted`
28
+ - `sk-xxxx`, `sk-test`, `sk-dummy`, `fake-`, `mock-`, `sample-`
29
+ - a value whose length is far below the provider's real key length
30
+
31
+ An empty string is not a secret either: `"apiKey": ""`.
32
+
33
+ ## Public metadata
34
+
35
+ These are meant to be public and appear in every repository:
36
+
37
+ - `author`, `maintainers`, `contributors` in `package.json`
38
+ - the copyright line and the license grant in `LICENSE`
39
+ - a contact address in `README`, `SECURITY.md`, `CODE_OF_CONDUCT.md`
40
+ - repository, homepage, and issue URLs
41
+ - an npm scope (`@org/name`), a Docker Hub namespace, a GitHub org
42
+ - the git remote URL (it is a repository address, not a credential)
43
+
44
+ If a public contact address is the *only* identity in the repository, it is still
45
+ public. Report it at P3 only if the user asked for contact details specifically.
46
+
47
+ ## Things that look like secrets and are not
48
+
49
+ | Looks like | Actually is | How to tell |
50
+ |---|---|---|
51
+ | `a3f9c2…` (40 hex chars) | a commit SHA or a file hash | `git log --all --oneline \| grep <prefix>`, or `sha256sum` of a file |
52
+ | `550e8400-e29b-…` | a UUID | version nibble, RFC 4122 shape |
53
+ | `eyJ…` in a test | a JWT fixture | decode the payload: `{"sub":"test"}`, `exp` in 1970 |
54
+ | `AKIA…` in docs | AWS's documented example | it appears in AWS's own docs; check the value against the documented one |
55
+ | `8.8.8.8`, `1.1.1.1` | public DNS | not RFC1918 |
56
+ | a base64 blob | an embedded image or font | decode the first bytes; `\x89PNG`, `\x00\x01\x00\x00` |
57
+ | `sk_test_…` (Stripe) | a published test key | Stripe documents test keys as public — P3 at most |
58
+ | `token: "test"` | a fixture | the value is a word, not a credential |
59
+
60
+ ## Test fixtures
61
+
62
+ A test needs a value. These are normal:
63
+
64
+ ```js
65
+ const client = new Client({ apiKey: 'test-key' })
66
+ const user = { email: 'test@example.com' }
67
+ expect(parse('Bearer abc123')).toBe(...)
68
+ ```
69
+
70
+ Reserve a finding for a fixture that is **shaped like a live credential** — the
71
+ right prefix, the right length, and no `test`/`fake`/`mock` marker. Even then,
72
+ say "may be a fixture" in the body and prefer P2 over P0.
73
+
74
+ ## Paths that carry no identity
75
+
76
+ `~/project`, `${HOME}/app`, `./src`, `/tmp/x`, `C:\Program Files\…`,
77
+ `/usr/local/bin` — none of these identify a person or a machine.
78
+
79
+ A path becomes a finding when it contains a **username**, a **machine name**, or
80
+ a **share** that is not public.
81
+
82
+ ## Duplicates
83
+
84
+ One credential pasted into five files is one finding with five locations, not
85
+ five findings. The second copy is not a second problem; it is the same problem
86
+ with more places to fix. Report the highest-priority location and list the rest
87
+ in the body.
88
+
89
+ ## When in doubt
90
+
91
+ Lower the priority and say what would settle it ("if this is the production
92
+ key, it is P0"). A wrong P0 is worse than a P3 the user can ignore.
@@ -0,0 +1,52 @@
1
+ # Pattern families
2
+
3
+ Grep one family at a time, then read the surrounding lines. A hit is a candidate, not a finding.
4
+
5
+ ## Credentials
6
+
7
+ | Family | What to look for | Notes |
8
+ |---|---|---|
9
+ | Provider keys | prefixes such as `sk-`, `sk-ant-`, `ghp_`, `gho_`, `github_pat_`, `xoxb-`, `xoxp-`, `AKIA`, `ASIA`, `AIza`, `glpat-`, `npm_`, `dckr_pat_`, `hf_` | The prefix identifies the provider; the length confirms it is not a placeholder |
10
+ | Bearer tokens | `Authorization: Bearer …`, `"token": "…"`, `token=` | A token in a curl example is still a token if it is real |
11
+ | Private keys | `-----BEGIN (RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----` | Report the header only; never the body |
12
+ | Certificates with key material | `-----BEGIN CERTIFICATE-----` **plus** a key in the same file | A bare certificate is public |
13
+ | Connection strings | `postgres://user:<password>@host`, `mysql://`, `mongodb+srv://`, `redis://:<password>@`, `amqp://`, `smtp://`, `jdbc:` | The password sits between `:` and `@` |
14
+ | Cloud / service secrets | `AWS_SECRET_ACCESS_KEY`, `AZURE_*_KEY`, `SENDGRID_API_KEY`, `STRIPE_SECRET_KEY`, `TWILIO_AUTH_TOKEN`, `FIREBASE_*`, `SUPABASE_SERVICE_ROLE` | The name tells you it is a secret; the value tells you whether it is one |
15
+ | Webhooks | `https://hooks.slack.com/services/…`, `https://discord.com/api/webhooks/…`, `https://outlook.office.com/webhook/…` | The URL path is the credential |
16
+ | JWTs | `eyJ` followed by base64url segments, three dot-separated parts | Decode the header only to confirm; never paste the payload |
17
+ | Signing material | `BEGIN PGP PRIVATE KEY`, `.p12`, `.pfx`, `.keystore`, `.jks` paths that are committed | Report the path, not the bytes |
18
+
19
+ ## Accounts and identity
20
+
21
+ | Family | What to look for |
22
+ |---|---|
23
+ | Email | `[\w.+-]+@[\w-]+\.[\w.]+` — then judge: `example.com`, `test@`, `noreply@` are public |
24
+ | Internal hostnames | `*.internal`, `*.corp`, `*.local`, `*.lan`, a bare hostname with no dot |
25
+ | Internal IPs | `10.`, `192.168.`, `172.16.`–`172.31.` |
26
+ | Account / tenant ids | `account_id`, `tenant`, `org_id`, `customer_id` with a literal value |
27
+ | Usernames | `user=`, `username:`, `USER=`, `whoami`, a name in a path segment |
28
+ | Personal data | a real full name next to a role or an address, phone numbers in `+CC` form, postal addresses, national id patterns |
29
+
30
+ ## Local environment
31
+
32
+ | Family | What to look for |
33
+ |---|---|
34
+ | Windows home | `C:\Users\<name>\`, `%USERPROFILE%`, `D:\Users\…` |
35
+ | POSIX home | `/home/<name>/`, `/Users/<name>/`, `~/…` is fine — it has no identity |
36
+ | UNC paths | `\\host\share\…` |
37
+ | Machine names | `COMPUTERNAME`, a hostname in a log sample, `.local` mDNS names |
38
+ | Editor / IDE state | `.vscode/settings.json` with an absolute path, `.idea/` files |
39
+
40
+ ## How to grep without leaking
41
+
42
+ Use patterns that match structure, not values, and keep the results out of your report:
43
+
44
+ ```bash
45
+ git ls-files | grep -vE '^(node_modules|vendor)/'
46
+ grep -rnE '(sk-[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{20,})' --include='*.{js,ts,json,yml,md}' .
47
+ grep -rnE 'BEGIN [A-Z ]*PRIVATE KEY' .
48
+ grep -rnE '[A-Za-z0-9_]+://[^:/\s]+:[^@/\s]+@' .
49
+ grep -rnE 'C:\\\\Users\\\\[^\\\\]+|/home/[^/]+/|/Users/[^/]+/' .
50
+ ```
51
+
52
+ Prefer `git ls-files` over `find`: it respects `.gitignore`, so you do not audit the build output.