fix: feat: stack lock protocol for singleton project stack access (#255) #270
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
in-progress
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#270
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-255"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #255
Changes
AI Review — Error\n\nReview failed.\n---\n
a5d3f23AI Review
Summary
New
lib/stack-lock.shprovides a file-based lock protocol for singleton project stack access. The logic is sound and well-structured: check → acquire (with stale-break) → heartbeat → release. The awk refactor inagent-smoke.shis a clean, correct equivalent of the prior grep/sed pipeline. Thedetect-duplicates.pyexemption for the shared structural pattern is justified.One real security issue blocks merge.
Issues
security
lib/stack-lock.sh:68-69,159,163,188:$lock_fileis interpolated directly intopython3 -c "...open('$lock_file')...". The outer shell string uses double-quotes, so$lock_fileis expanded by bash before Python sees it. If$project(the caller-supplied argument) ever contains a single-quote or Python metacharacters, the injected string can escape theopen('...')argument and execute arbitrary Python. A minimal fix is to pass the path as a positional argument — usepython3 -c '...' "$lock_file"withsys.argv[1]inside a single-quoted-cstring so bash never expands it. This pattern repeats in five places across the file.minor
lib/stack-lock.sh:110-117: The temp-file +mvapproach is documented as "atomic", but two concurrent callers that both observefreewill bothmktempand bothmv— the secondmvsilently overwrites the first. On Linux,mvwithin one filesystem is an atomicrename(2), but it does not prevent the TOCTOU window between the check and the write. For the current use case (one CI pipeline + one reproduce-agent), the race window is narrow and probably acceptable in practice, but the comment should not claim atomicity.Non-issues (noted for clarity)
set -euo pipefailin a sourced library: consistent with every other file inlib/, not a problem._stack_lock_epochGNU/BSD dual-path: correct — GNUdate -daccepts ISO 8601 withTnatively.agent-smoke.shfaithfully replicates the original grep/sed regex — no regression.holderinprintf '%s'format: safe, not expanded as a format string.Verdict
REQUEST_CHANGES — python3 -c embeds $lock_file via double-quote interpolation — code injection if project names contain single quotes
Reviewed at
a5d3f23| AGENTS.mdAI Review: REQUEST_CHANGES — python3 -c embeds $lock_file via double-quote interpolation — code injection if project names contain single quotes
AI Review — Error\n\nReview failed.\n---\n
bf2842eAI Re-review (round 2)
Previous Findings
security
lib/stack-lock.sh:68-69,159,163,188— python3 interpolation injection → FIXED: All five occurrences switched to single-quoted-cstrings withsys.argv[1], correctly passing$lock_fileas a positional argument. Injection vector eliminated.minor
lib/stack-lock.sh:110— comment claimed "atomic write" when TOCTOU race still exists → FIXED: Comment updated to "Write to temp file then rename to avoid partial reads by other processes" — accurate description of what the code actually guarantees.New Issues
None.
Verdict
APPROVE — Both requested changes addressed: injection fixed via sys.argv[1], misleading atomicity comment corrected
Reviewed at
bf2842e| Previous:a5d3f23| AGENTS.mdAI Re-review (round 2): APPROVE — Both requested changes addressed: injection fixed via sys.argv[1], misleading atomicity comment corrected