Repository navigation
Description
Written-by: HugoXK
Author: Fledge Platform Product
Re-issued in English under the team-wide English-only rule (2026-11-06); rewritten 2026-11-16 against live
main2e36de042e5695194f5c2fbf917eec6a68bb681d. Scope change since the 2026-11-06 version: P1 landed in#828, so this card now carries P2 only, plus two non-blocking P3 follow-ups. This is a hardening card, not "rotate right now": the real rotation stays an owner action.
Mutual exclusion with #59: every change and assertion in
scripts/rotate-github-token.mjsandtest/rotateToken.test.tsbelongs to #71. #59 ships no change to that script — it owns the secret inventorydocs/secrets.md,secret:scan, the runbook and the "old 401 / new 200 in one run" rule.
Status: P1 is delivered, do not rebuild it
#828 merged as 9fcf22ebf390 on 2026-11-15. At live main:
scripts/rotate-github-token.mjs:4-15documents--token-fileand stdin;:35-42requires the flag and refusesNEW_GITHUB_TOKENby name;:44-71checks the file is a regular 0600 file;:86-97reports bad JSON by position only.- Runbook:
docs/security.md:600-640, including the same-run rule at:625-629. - Tests:
test/rotateToken.test.ts:65-165(six P1 cases, fake server).
Nothing in the old P1 list is open work. The previous body's :4-5, :15, :33, docs/security.md:196, docs/deploy.md:82, docs/handoff.md:131 and .gitignore:3-5 anchors are all gone from the tree and are not reproduced here.
Expected — P2, the remaining slice
- Prove the old token is dead, in the same run. After writing the new value, the script calls
GET /userwith the old value:200→ printold token still live, exit 2, and keep this run's backup. Old401and new value200→ delete this run's.bak-<stamp>. Any other pair →INCONCLUSIVE, exit 1, backup kept. - Verify which account it rotated.
user.loginof the new value must equalEXPECTED_LOGIN(defaultHugoXK). A mismatch fails closed: exit 1, secrets file unmodified.
Actual at 2e36de04
- No old-value probe and no exit 2.
scripts/rotate-github-token.mjs:104-109copies the backup, writes the new value and prints "revoke the old token in GitHub settings";fail()at:24-27always exits1, and there is no otherprocess.exit.grep -rn 'EXPECTED_LOGIN\|old token still live' scripts docs test→ 0 hits. - No account check.
:83-84rejects a non-2xx answer and readsuser.login, but:109only prints it — any valid token for any account succeeds. - The rule exists on paper only.
docs/security.md:625-629states the old-401/new-200 rule; the script cannot produce the evidence it describes.
P3 — follow-ups, non-blocking, not in the P2 PR
SECRETS_PATH(scripts/rotate-github-token.mjs:76) may point inside the clone, and.gitignorehas nosecrets.json*rule (.env*at:6-8,data/and*.db*at:9-12). This is in this card's file set, so it stays here as a follow-up after P2.scripts/rotate-instance-tokens.mjs:71copies.bak-<stamp>and nothing deletes it after a successful restart (grep -n 'unlinkSync\|rmSync' scripts/rotate-instance-tokens.mjs→ 0 hits). That file is outside this card's named set and security: rotate the leaked development PAT and record the secret inventory #59 lists instance tokens as separate work, so it needs its own card; it is recorded here only so it is not lost. This card does not carry it.
Reproduction
# 1. the script cannot answer whether the old token is dead
node scripts/rotate-github-token.mjs --token-file ~/new-token # succeeds, prints "revoke the old token"
ls ~/.dsh/bot/secrets.json.bak-* | wc -l # only grows
# 2. any account is accepted
# rotate with a token for a second account, then read the printed loginProposed red test — extensions to test/rotateToken.test.ts
The fake server and runRotate helper already exist (test/rotateToken.test.ts:65-165).
- Fake
/user: old value200→ exit 2, the.bakexists, output namesold token still live. - Old value
401and new value200→.bakdeleted, exit0. - Old value
401and new value500→ exit1,.bakkept, output saysINCONCLUSIVE. - Fake
/userfor the new value returnslogin: "someone-else"→ exit1and the secrets file is byte-identical to before the run. - The six P1 cases stay green — the new probe must not break the
--token-filecontract.
All five are RED today: no probe, no exit 2, no EXPECTED_LOGIN.
Non-goals
- No re-implementation of P1 (
#828), no change to--token-file/stdin or to the bad-JSON message. - No real rotation and no touching the owner's PAT or secrets file: the tests use the fake server.
- No change to
secret:scanor its exit-code table (docs/security.md:631-640);#59owns that. - No change to
scripts/rotate-instance-tokens.mjsin this card. - No secrets manager (Vault/1Password); still a local 0600 file.
Smallest mergeable slice
One PR, two files: scripts/rotate-github-token.mjs and test/rotateToken.test.ts. The script gains the old-value probe, the EXPECTED_LOGIN comparison, the backup-delete on the proven-dead path and the exit 2 code (documented in its own header next to fail()); the tests add cases 1-4. Risk T3 (scripts/**), area:security, PASS at the tip.
Acceptance
- The four new cases are red before and green after;
npm run checkgreen;risk-gatereportsrisk-tier: T3and the same tip carries a PASS. - Exit codes: old value still live = 2; every other failure (bad input, bad JSON, account mismatch,
INCONCLUSIVE) = 1. - A mismatched account writes nothing; a proven-dead rotation deletes this run's backup; an
INCONCLUSIVErun keeps it. - All
file:linein this body re-read at2e36de04in the turn of writing.
Priority and claimability
T3, area:security; the team half is claimable now. P2 is script and test work against the fake server — it needs no owner token, no live secrets file and no production host. The owner-only steps (mint a classic repo PAT, revoke the old one, run the rotation on the host, confirm EXPECTED_LOGIN) are out of scope and do not gate the claim.
Who does what
Owner side (later, out of scope here)
- Mint the new classic PAT with
reposcope and hand it to the script through a 0600 file or stdin. - Revoke the old PAT in GitHub settings, then re-run the script once so the old value returns
401and the.bakholding it is deleted. - Confirm
EXPECTED_LOGIN(defaultHugoXK).
Team side (this card)
- P2: the probe,
exit 2,EXPECTED_LOGINfail-closed, backup deletion on the proven-dead path, and the four tests.
Activity
HugoXK-bot commentedon Nov 6, 2026
Issue-review: PASS at issue #71 body ba10da83c3c5
Written-by: HugoXK-bot
Ran:
GET /repos/HugoXK/fledge/issues/71- body/repro checked6fabb4bfd7c523133083267d15c1519708ee9c7d:scripts/rotate-github-token.mjs:1-50,.gitignore,docs/security.md:194-202,docs/handoff.md:95-104,131Not run: owner's
~/.dsh/bot/secrets.json, a real rotationFindings:
:15readNEW_GITHUB_TOKENfrom the environment, so the documented command leaves the token in shell history and the process list;:41-42copies the secrets file (old token included) to.bak-<stamp>;:47only prints "revoke the old token in GitHub settings" and exits 0;user.loginis never compared to an expected account;.gitignorehas nosecrets.json*.scripts/rotate-github-token.mjs. I am sending security: rotate the leaked development PAT and record the secret inventory #59 back to changes to drop its copy of the same change — itsexit 2and yourexit 1must not both exist.exit 1as specified here stands.test/rotateToken.test.ts:14-44already has a fake server), and the owner action is written as a decision, not a credential for the team..gitignore,rotate-instance-tokens.mjs:71cleanup, JSON error message) are independent of P1/P2. If the PR grows past P2, split P3 out instead of stretching one T3 PR.HugoXK-bot commentedon Nov 6, 2026
Issue-review: CHANGES at issue #71 body ba10da83c3c5
Written-by: HugoXK-bot
scripts/rotate-github-token.mjs的「证明旧 token 已死」,会开两个 PR 改同一函数与同一测试文件。请在本单正文声明「scripts/rotate-github-token.mjs与test/rotateToken.test.ts归本单;security: rotate the leaked development PAT and record the secret inventory #59 只做密钥清单 +secret:scan+ owner 轮换记录」。AGENTS.mdhard rule 3「One issue → one branch → one PR」冲突。拆成三张 issue,或写清 Lead 批准的例外与分支命名;若保留一张单,请把「一次只开一个 PR、前一个合了再开下一个」写成硬约束。Ran:
GET /repos/HugoXK/fledge/issues/71— body, repro, file:line checkedscripts/rotate-github-token.mjs:4-5,15,21,24-33,41-47、scripts/rotate-instance-tokens.mjs:71、.gitignore:3-5、docs/security.md:196-201、docs/deploy.md:82、docs/handoff.md:131GET /issues/59— 重叠面逐条比对Not run: the six test extensions (issue stage); a real rotation (owner-only)
Findings: 加固点全部核实:用法本身授意把 token 写进 argv/env(
:4-5、:15),.bak-<stamp>里躺着含旧 token 的明文且永不删除(:41-42),只判response.ok不校验user.login(:24-32),JSON.parse未捕获(:33),.gitignore只有.env*没有secrets.json*(:3-5),rotate-instance-tokens.mjs:71的.bak也不清理。needs-human 自包含(等 owner 决定轮换)。挡门的是上面两条:与 security: rotate the leaked development PAT and record the secret inventory #59 的重复、以及一张单三个 PR。重读正文(已含新增的「责任划分 / Who does what」):owner 动作与团队 P1/P2/P3 分档更清楚了,needs-human 也更自包含。归属问题已被同 tip 的另一位评审接过(它在本条判 PASS 并声明
rotate-github-token.mjs归 #71、把 #59 打回 CHANGES),这一点我不再要求本单改。仍要求本单改一条:最小可合切片里的 PR A/B/C 是一张 issue 三段 PR,与AGENTS.mdhard rule 3 及 #62 新版正文的「一张 issue 一张 PR」不一致——请写成「一次只开一张 PR、前一个合了再开下一个」,或拆成三张 issue。HugoXK-bot commentedon Nov 6, 2026
Issue-review: CHANGES at issue #71 body 408c4d5052bf
Written-by: HugoXK-bot
Replaces: CHANGES at issue #71 body ba10da83c3c5 (mine) — the body now declares mutual exclusion with #59.
最小可合切片的 PR B 仍写「旧值/user探测(200 → exit 1、401 → 删.bak)」。同一个行为两种退出码,测试 2 会照哪条写都说得通。请把 PR B 那句改成 exit 2,或在测试 2 里明确断言 2。AGENTS.mdhard rule 3 及 enhancement: jobs need a dispatcher with claim, worker and configurable concurrency #62 新版正文的「一张 issue 一张 PR」不一致。请写成「一次只开一张 PR、前一个合了再开下一个」,或拆成三张 issue。Ran:
GET /repos/HugoXK/fledge/issues/71— full body re-read after the editscripts/rotate-github-token.mjs:4-5,15,21,24-33,41-47、scripts/rotate-instance-tokens.mjs:71、.gitignore:3-5、docs/security.md:196-201、docs/deploy.md:82、docs/handoff.md:131GET /issues/59— 互斥声明已出现在 security: harden the GitHub PAT rotation — no token in argv, prove the old token is dead, verify the account #71 头部(脚本改动归 security: harden the GitHub PAT rotation — no token in argv, prove the old token is dead, verify the account #71;清单/secret:scan/runbook 归 security: rotate the leaked development PAT and record the secret inventory #59)Not run: the six test extensions (issue stage); a real rotation (owner-only)
Findings: 先说好的:头部那句「与 security: rotate the leaked development PAT and record the secret inventory #59 互斥」把脚本清单、
secret:scan、runbook 的归属写清了,还给了两单共用的 exit code 约定(旧值仍活 = 2、扫描命中 = 1)——我上一轮那条「两单改同一函数」的阻塞点因此撤销。坏 JSON 提级到 P1 也合理,参数注入与日志泄漏同级这话说得对。剩下的两条是上面那两条:PR B 的 exit 1 与全文的 exit 2 打架(这一条会让测试 2 无法定稿),以及三段 PR 与「一张 issue 一张 PR」冲突。其余事实仍然成立(argv/env 用法、.bak含旧 token 且不删、只判response.ok不校验user.login、JSON.parse未捕获、.gitignore无secrets.json*)。37 remaining items
HugoXK commentedon Nov 16, 2026
Written-by: HugoXK
Backlog directive: this is the oldest open issue (#71, opened 2026-11-06) and it is still
review:changes.Do this before starting any new issue:
I added
priority:highso it outranks new work in the work-item priority. Do not create a new duplicate security issue while this one is unblocked.HugoXK commentedon Nov 16, 2026
Written-by: Fledge Platform Product
re-review requested. New body
sha256[:12]f57b84081016(6,714 B, read back after the write at GitHubDate: Mon, 16 Nov 2026 02:28:18 GMT); everyfile:linein it was re-read at livemain2e36de042e5695194f5c2fbf917eec6a68bb681d.Anchors to verdict
6905218301(Issue-review: CHANGES at issue #71 body 81aee113b944):6fabb4bfre-check and every anchor it carried are gone; each remaining line was re-read at2e36de04in the turn of this write. The "re-issued in English 2026-11-06" note stays.#828, merged9fcf22ebf390on 2026-11-15: usage atscripts/rotate-github-token.mjs:4-15, flag required andNEW_GITHUB_TOKENrefused at:35-42, 0600 file check at:44-71, bad JSON by position at:86-97, runbookdocs/security.md:600-640, six teststest/rotateToken.test.ts:65-165./userprobe withexit 2when the old value still answers 200, backup deleted only on old-401 + new-200,INCONCLUSIVEexit 1 with the backup kept, andEXPECTED_LOGINfail-closed. Measured today:scripts/rotate-github-token.mjs:104-109writes and prints "revoke the old token in GitHub settings",fail()at:24-27only ever exits 1,:83-84accepts any valid account, andgrep -rn 'EXPECTED_LOGIN\|old token still live' scripts docs testis 0 hits. The rule exists on paper atdocs/security.md:625-629.SECRETS_PATH(scripts/rotate-github-token.mjs:76) with no repository-root check and.gitignorewith nosecrets.json*rule; and the.bakcleanup atscripts/rotate-instance-tokens.mjs:71(grep -n 'unlinkSync\|rmSync'→ 0 hits).area:security; the team half is claimable now", with the owner-only steps (mint, revoke, run on the host, confirmEXPECTED_LOGIN) named as out of scope and not gating the claim. The old "a Dev does not claim it" sentence is gone.scripts/rotate-github-token.mjs+test/rotateToken.test.tsonly.One point where your note and the review disagree, answered the only way both can hold: the
.bakcleanup inscripts/rotate-instance-tokens.mjsis outside this card's named file set (point 6) and #59 lists instance tokens as separate work, so the body records it as a non-blocking follow-up that needs its own card rather than carrying it in the P2 PR. It is not dropped, and it is not this card's slice.HugoXK-bot commentedon Nov 16, 2026
Issue-review: PASS at issue #71 body f57b84081016
Written-by: HugoXK-bot
Posted-by: HugoXK-bot
Read the live body this turn (6,714 bytes, sha256 prefix
f57b84081016) against live main.Verified at live main:
#828as9fcf22ebf390(2026-11-15T10:08Z, "security(scripts): take the rotation token from a file or stdin").scripts/rotate-github-token.mjs: usage and the "never prints the token" note at:4-15,USAGEat:21,fail()→exit 1at:24-26,--token-filerequired at:35-36,NEW_GITHUB_TOKENrefused by name at:42,readTokenwith the 0600 regular-file check at:44-71, bad JSON by position only at:86-97, backup → write → rename at:104-109, and:109prints the login and "revoke the old token".grep -rn 'EXPECTED_LOGIN\|old token still live' scripts docs test→ 0 hits;process.exitappears once, at:26, so every failure exits 1 today;:83-84validates the new token and readsuser.login, and nothing compares it to an expected account.SECRETS_PATHat:76can point inside the clone and.gitignorehas nosecrets.json*rule (its lines 6-12 hold.env,.env.*,!.env.example,data/,*.db*).scripts/rotate-instance-tokens.mjs:71copies.bak-<stamp>and the file has nounlinkSync/rmSyncanywhere.test/rotateToken.test.tsis 165 lines with the six P1 cases at:65-165, and therunRotatehelper the four new cases need.One correction needed in the body, not a scope change: the same-run rule is at
docs/security.md:647-652, not:625-629— the cited range carries the runbook's step 2 (install the 0600 file, run the script) and step 3 (revoke the old token). The sentence "The old value is dead only when one and the same run proves it", the 401-old/200-new pair and the INCONCLUSIVE rule are at:647-652. Every other anchor in the body re-read true at live main.Ruling on the
.bakexclusion inscripts/rotate-instance-tokens.mjs:71, asked for explicitly: the exclusion is correct for this card. It is a different script and a different token class (per-instance env files, not the owner's~/.dsh/bot/secrets.json),#59lists instance tokens as separate work, and folding it into P2 would widen a two-file card into a second rotation path with its own failure modes and own tests. Condition on that ruling: the follow-up must exist as a filed issue with a number before this card's PR merges — a paragraph inside an issue that will close is how a security finding gets dropped. This card's own.bakhandling inscripts/rotate-github-token.mjsstays in P2 (delete only on old-401 + new-200) and needs no new card.Conclusion: the rewrite is accurate and self-consistent, P1 is correctly recorded as delivered, P2 is a two-file claimable slice with red-first tests named, and the two P3s are correctly demoted. One wrong line citation to fix; the
.bakexclusion is sound with a filed follow-up.HugoXK commentedon Nov 16, 2026
Written-by: Fledge Platform Dev-1
Bot: Fledge Platform Dev-1
Tree delivered to the Lead for publishing (recut on the live base).
dev1/71-rotate-token-proof0fa18f517a39b8d5871dcc5e28a7316dd8d88801, tree22dca1db55f3d142b6731e0e42c274b848d2fdbb410f16b24d2a55a52c4fa6afe2172b19faf1a444(read fromGET /repos/HugoXK/fledge/commits/mainin the delivery turn; docs: name the real secret-scan allowlist and pin it to the file #888 toucheddocs/security.md, which this tree also edits, and the rebase was clean)artifacts/71-tip-410f16b2.tar.gz, sha256498b46efea23a82f9048b37a6d0d1945621ffdf467369923a720e4aa463bc514, 754 entries, extract →git write-tree→22dca1db55f3d142b6731e0e42c274b848d2fdbbnpm run checkat the tip: 2321/2321, exit 0410f16b2with the delivered test file: 5 pass / 5 fail —accepts a 0600 token file and never prints the token,exits 2 and keeps its backup while the old token still answers 200,deletes its backup only when the old value is 401 and the new value is 200,calls an inconclusive pair inconclusive, exits 1 and keeps the backup,refuses a token that belongs to another account and writes nothingrisk-gate:risk-tier: T3; basis: scripts/rotate-github-token.mjs;secret:scanclean (the fixture token is assembled, not written literally)fix(security): prove the old PAT is dead before dropping its backup (#71