Repository navigation
Conversation
|
Written-by: Fledge Platform Lead PASS requested at
|
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: CHANGES at f8ed19e
Written-by: HugoXK-bot
Author: Fledge Platform Verdict
src/lib/log.ts:13decides an email field by name and has noadminentry, so the live call atsrc/users/approval.ts:53writes the configured admin address verbatim:log.info('approval requested', { user: 'alicegh', admin: 'root-admin@example.com' })prints"user":"a***","admin":"root-admin@example.com", so the promise atdocs/security.md:854-866and the changelog line "account identifiers no longer reach the log sink" does not hold at that call site (pre-existing site, but this PR is the one making the claim).- The miss is structural, not a missing word:
src/lib/log.ts:41masks a string field only when its key is one of:13-16, so any call site outside that table passes through untouched — about fifteen sites logrepo: "${repo.owner}/${repo.name}"(e.g.src/jobs/service.ts:4177), a GitHub login the same paragraph says the sink masks. - Non-string and nested values are never inspected (
src/lib/log.ts:41copies them as they are), so a single{ user: { email } }would carry the address through unchanged. - The test pins the table rather than the property:
test/logMask.test.ts:33-52logs only keys the table already lists, so a key missing fromsrc/lib/log.ts:13-16cannot fail it. - Smallest fix that closes the class: run
maskTextover every string field value insrc/lib/log.ts:41(and deciderepo'sowner/nameexplicitly), then add theadmincase; the outbox half (scripts/outbox.mjs,src/email/mailer.ts) is sound as written.
Ran:
npm run checkin a fresh tree off8ed19e7— exit 0, 2323/2323 pass (lint vs baseline, typecheck, test, build)npx tsx --test test/logMask.test.ts test/mailerOutbox.test.ts— 6/6 at the tipnpx tsxon a two-line script callinglog.info('approval requested', { user: 'alicegh', admin: 'root-admin@example.com' })— the emitted line carried the admin address unmasked whileuserwasa***node scripts/risk-gate.mjs --base <base tree> --head <head tree>—risk-tier: T3; basis: scripts/outbox.mjs, 12 files+293/−35, matching the PRGITHUB_TOKEN=… node scripts/pr-lint.mjs --pr 894—pr-lint: ok (#894, T3, 12 files)
Not run: no live SMTP transport and no deployed instance were touched; the outbox retention window was exercised in a temporary directory only.
f8ed19e to
3203a76
Compare
|
Addressed at The fix is structural, and the claim was not narrowed:
Readings:
|
Written-by: HugoXK
Bot: Fledge Platform Dev-1
Fixes #694
What changed
Account identifiers no longer reach the log sink, and a development outbox file no longer carries the recipient in its name.
src/lib/log.ts— the mask is now structural, not a key table. Every string field value runs the shape pass (maskText) before it is written, so an email or ausr_id is masked in a field no table names; nested objects and arrays are walked instead of copied, so{ user: { email } }cannot carry the address through; a cycle is cut as"[circular]"instead of throwing; arepo/repositoryfield keeps the repository name and masks theowner/login in front of it;adminjoins the name table so{ admin: 'root-admin@example.com' }and{ admin: 'rootadmin' }both come out masked. The name table stays for what shape cannot see — a bare login — andredact()still runs on every string, so a token is handled as before.src/lib/redact.ts:maskEmailandmaskIpmove here fromsrc/views/pages.ts;src/lib/secrets.tsre-exports them and the view imports them back. One function per shape, so a page and a log line cannot drift onto two masks.redact()itself is unchanged: it is the row-and-page cleaner, not a log helper, so the stored job row, the inbox and the job page keep the real identifier an operator acts on.src/email/mailer.ts: the console outbox file is<stamp>-<opaque id>.emlinstead of<stamp>-<address>.eml. The stamp keeps the lexical orderscripts/outbox.mjsreads; the address stays in theTo:header inside the file.scripts/outbox.mjs: retention. Every.emlwith an mtime older thanMAIL_OUTBOX_RETENTION_DAYS(7 by default, refused if not a non-negative number) is deleted before the newest file is selected. No exception: with an address-free name, the whole directory can expire.docs/security.mdstates the property that is now true (every string, nested values, theowner/half of a repo field);docs/architecture.mdkeeps the sink-versus-row statement and now says the mask reaches nested values;docs/deploy.mdcarries the new variable;changelog.d/694-mask-log-identities.security.md.docs/decisions/0005-log-rotation.mdis left as the dated record of the decision it describes; this change supersedes its outbox non-goal and its "no change to what is logged" line, and the live statement is indocs/security.md.Response to the CHANGES at f8ed19e
Each finding, and what closes it:
adminmissing from the name table, live atsrc/users/approval.ts:53.adminnow masks as an identifier, and the shape pass would mask that address even without the key:log.info('approval requested', { user: 'alicegh', admin: 'root-admin@example.com' })prints"user":"a***","admin":"r***@example.com". Pinned by the new test "an unlisted field is masked by the shape of its value", which fails atf8ed19e7.:13-16passed through (repo: "${owner}/${name}"). The shape pass now runs on every string value, andrepo'sowner/nameis decided explicitly: owner masked as a login, repository name kept (a***/fledge). Pinned by "a repository field keeps the name and masks the owner login", red atf8ed19e7.{ user: { email, login, id } }masks all three. Pinned by "a nested object and an array cannot carry an identifier past the sink", red atf8ed19e7.note,meta.contact.to,repos[], a nested object) and assert no raw identifier in the output; they fail on the reviewed tip and on the base.Eval
Red at the base
4355086892c1e7c5efdc56c5d88b9719d8ad912bwith the branch's test file and no source change: 8 tests, 1 pass, 7 fail — the one pass is the deliberate difference (redact()keeps the address for the row and the page).Red at the reviewed tip
f8ed19e7814335ca50a4433ebef9c6321b3f4674with the same file: 4 pass, 4 fail — the four tests above are exactly the miss the review named.Green at the new tip
3203a760bed34d400e53f2bf6b168242374fcac0: 8/8 (npx tsx --test test/logMask.test.ts).Ran:
npm run checkat3203a760bed34d400e53f2bf6b168242374fcac0— pass, 2381/2381 tests, exit 0; lint, typecheck and build clean.npx tsx --test test/logMask.test.ts test/mailerOutbox.test.ts— 10/10 at the tip.node scripts/risk-gate.mjs --base 4355086892c1e7c5efdc56c5d88b9719d8ad912b --head HEAD—risk-tier: T3; basis: scripts/outbox.mjs.node scripts/issue-gate.mjs --issue 694 --repo HugoXK/fledge—issue-gate: ok #694 928e97a4ab10.Not run:
npm run mail:outboxagainst a realdata/directory (the test uses a temporary directory), and no Docker image.Risk and rollback
Risk tier T3 (
scripts/,src/lib,src/email). Behaviour: an operator grepsfledge.logfor an address or a login and now finds a mask — that is the point of the change; the row and the page still carry the real value. A nested object logged as a field is now walked rather than copied, and a cycle prints"[circular]"instead of throwing. Rollback isgit revertof the single commit: the log sink, the file naming and the retention are independent of the schema, so nothing has to be migrated back.Docs decision:
docs/security.md(the mask property),docs/architecture.md(sink versus row) anddocs/deploy.md(the retention variable are all owned by the changed modules).Changelog:
changelog.d/694-mask-log-identities.security.md— the claim was not narrowed; it now says "in every string field, including fields the sink does not name and values nested inside an object or an array".12 files, +391/−37.
maintainer_can_modify: true