Repository navigation
Merged
Conversation
…made false (#437) #429 replaced the merged config file's PID-suffixed literal path (remember-config-$$.json) with an unpredictable mktemp name to close a symlink-planting TOCTOU. That left "0600 per PID" describing a filename the code no longer generates in scripts/log.sh (x2), scripts/post-tool-hook.sh (x2), tests/test_log_sh.py, README.md, and -- not counted by #429's own grep -- two sites in tests/test_session_end_hook_345.py that named the old literal path directly. All eight now describe the current mechanism: 0600, an unpredictable mktemp name, one per invocation, under an EXIT trap. CHANGELOG.md's own two matches are left alone as the historical record of past releases. tests/test_layered_config.py gains test_merged_config_is_0600_and_not_pid_named, pinning both the mode and the mktemp-shaped basename so a regression to either the old literal path or a permissive mode fails a test rather than only reading stale in a comment. Confirmed red against the pre-#429 shape (scripts/lib-memory-dir.sh as of d2cf399^) and green against current code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ng "unpredictable" for the relocated path Both spawned reviewers (Explore and oss:auditor) independently found the same gap: `bootstrap-dirs.sh`'s own #362 relocation renames the merged config's mktemp file back to a PID-suffixed name under `REMEMBER_DIR/tmp` before `log.sh` and `post-tool-hook.sh` ever read it -- private directory, so no TOCTOU risk, but it meant "unpredictable mktemp name" in those two scripts' own comments (and the matching README.md sentence) overclaimed what the file they actually operate on looks like. Both now say "0600, fresh every invocation" instead, which holds at both stages. Sites that describe lib-memory-dir.sh's own write specifically -- tests/test_log_sh.py, tests/test_layered_config.py's new assertion -- keep the more precise "unpredictable mktemp name" wording, since that part is accurate there. Confirmed empirically (not just read): sourcing detect-tools.sh -> bootstrap-dirs.sh -> log.sh end to end in a scratch project produces a final REMEMBER_CONFIG at $REMEMBER_DIR/tmp/remember-config-<pid>.json, not an XXXXXX-shaped mktemp name. Also swept two sites the concept-grep missed the first time: scripts/bootstrap-dirs.sh's own #362-relocation comment named the old $SYS_TMPDIR/remember-config-$$.json path as lib-memory-dir.sh's current output, and tests/test_trap_quoting_375.py's docstring made the same claim about lib-memory-dir.sh's own trap target. tests/test_session_end_hook_345.py's two comments now describe the full two-stage path (mktemp write, then bootstrap-dirs.sh relocation) rather than stopping at the first stage, since session-end-hook.sh's own sourcing order (bootstrap-dirs.sh before log.sh) means the relocated path is what env["REMEMBER_CONFIG"] actually is by the time these tests run. Full suite: 1828 passed, 43 skipped, 0 failed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ing test_umask.py CI's ubuntu-latest/3.12 leg went red on the new test from #437: REMEMBER_CONFIG_MODE came back holding GNU stat's "File: ..." block instead of an octal mode. The probe tried `stat -f '%Lp' ... || stat -c '%a' ...` -- BSD-first. On Linux, `stat -f` means "filesystem status", not "format": it exits 0 and prints the wrong thing, so `||` never reaches the GNU branch that would have worked. Green locally (macOS, where `stat -c` is the option that fails) said nothing about this. tests/test_umask.py already solved this exact problem, twice, including for this exact file (TestMergedConfigPermissions pins REMEMBER_CONFIG's mode too): `stat -c '%a' ... 2>/dev/null || stat -f '%Lp' ...`, GNU first. Matched that idiom instead of inventing a third spelling. Re-confirmed red/green the same way as the first time: checked out scripts/lib-memory-dir.sh as of d2cf399^ (pre-#429) into the worktree, ran the new test -- AssertionError: remember-config-23537.json against the basename regex, same failure shape as before, mode assertion untouched since 0600 predates #429 too -- then restored the current file (git diff clean) and reran: 1 passed. Full suite: 1828 passed, 43 skipped, 0 failed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
4 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #437.
#429 replaced the merged config file's PID-suffixed literal path (
remember-config-$$.json) with an unpredictablemktempname to close a symlink-planting TOCTOU. That left several comments and one test docstring describing the file as0600 per PID-- a filename the code no longer generates.What the issue's own grep undercounted
#429's own grep (
per PID) found five site groups (six lines):scripts/log.sh:78,392,tests/test_log_sh.py:874,README.md:276,scripts/post-tool-hook.sh:73,178. Grepping the concept instead -- mode, per-PID claim, EXIT trap,lib-memory-dir.sh's creation contract -- across the whole tree (excludingCHANGELOG.md, an assembled historical record left untouched) turned up ten stale sites, not five: the original six lines plus two comments intests/test_session_end_hook_345.pythat named the old literal path directly, and (found only during self-review, below) one comment inscripts/bootstrap-dirs.shand one docstring intests/test_trap_quoting_375.py.The judgment call, and where it went wrong the first time
Not every
per-PID/$$-shaped comment in the tree is stale -- several describe the fix itself (scripts/lib-memory-dir.sh's own#429comment,scripts/lib-env-cache.sh,tests/test_case_divergence_298.py's_SANCTIONED_DIVERGENCEold-code snapshot) and are correctly left alone.Self-review (an
Explorereviewer and theoss:auditor, run independently against the first commit) both caught a real gap in my first pass:scripts/bootstrap-dirs.sh's own#362relocation logic renames the mktemp file back to a PID-suffixed name ($REMEMBER_DIR/tmp/remember-config-$$.json) beforescripts/log.shandscripts/post-tool-hook.shever read it -- safe there because that directory is private rather than shared, so the TOCTOU concern doesn't reapply, but it means those two scripts' comments (and README.md's matching sentence), as I first wrote them, overclaimed "unpredictable mktemp name" for a file that is, by the time those scripts see it, PID-suffixed again. Confirmed empirically: sourcingdetect-tools.sh->bootstrap-dirs.sh->log.shend to end produced a finalREMEMBER_CONFIGat.../tmp/remember-config-<pid>.json, not anXXXXXX-shaped name. Fixed in the second commit: those four sites (plus README.md) now say0600, fresh every invocation-- true at both stages -- while sites describinglib-memory-dir.sh's own write specifically (tests/test_log_sh.py, the new test below) keep the more precise wording, since that part is accurate there.The new assertion
tests/test_layered_config.pygainedtest_merged_config_is_0600_and_not_pid_named, which runslib-memory-dir.shvia subprocess and pins both the file mode (0600) and the mktemp-shaped basename, with a paired negative control against the exact oldremember-config-<digits>.jsonshape. Confirmed red against the pre-#429 code (scripts/lib-memory-dir.shas ofd2cf399^) and green against current code.Docs
README.md(this lane's onlydocs_targetsentry) updated -- one sentence corrected, matching #443's existing Codex-section content elsewhere in the file, which was not touched.Tests
Full suite: 1828 passed, 43 skipped, 0 failed (
pytest -q, ~8 minutes). Fragment checked with.oss/assemble_changelog.py --check: ok.Review
Spawned an
Explorereviewer andoss:auditorin parallel against the first commit; both returned real findings, both addressed in the second commit (see above). No findings judged below the bar.