feat(engine): harden mailbox CLIs for v0.2.0
- Atomic delivery: create the temp file inside the destination dir (dot-prefixed, invisible to the inbox glob) so the final rename never crosses filesystems and readers never see a half-written message. - Reject . and .. explicitly in the --reply-to and coord-done name guards instead of relying on downstream failure. - Add -h/--help to coord-inbox.sh (uniform across the three CLIs). - Close selftest gaps: default mailbox path via HOME fallback, malformed frontmatter on the read path, read-only destination dir. 48 -> 64 checks, all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018fduZz8otpU3W3rhfoPD6t
This commit is contained in:
parent
0e6014fe98
commit
0a79e786fc
9 changed files with 80 additions and 26 deletions
|
|
@ -57,7 +57,7 @@ if [ -n "$REPLYTO" ]; then
|
|||
if [ "$BROADCAST" -eq 1 ] || [ -n "$TO" ]; then
|
||||
echo "coord-send: --reply-to cannot be combined with --to/--broadcast" >&2; exit 2
|
||||
fi
|
||||
case "$REPLYTO" in */*|"") echo "coord-send: invalid --reply-to name: $REPLYTO" >&2; exit 2 ;; esac
|
||||
case "$REPLYTO" in */*|.|..|"") echo "coord-send: invalid --reply-to name: $REPLYTO" >&2; exit 2 ;; esac
|
||||
REPLY_ORIG="$COORD/$FROM/inbox/$REPLYTO"
|
||||
[ -e "$REPLY_ORIG" ] || REPLY_ORIG="$COORD/$FROM/archive/$REPLYTO"
|
||||
if [ ! -e "$REPLY_ORIG" ]; then
|
||||
|
|
@ -111,7 +111,11 @@ FNAME="${TS}-$$${RANDOM}-from-${SAFE_FROM}.md"
|
|||
DEST="$DEST_DIR/$FNAME"
|
||||
DATE_ISO="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
|
||||
TMP="$(mktemp)"
|
||||
# Temp file lives INSIDE the destination dir (dot-prefixed so the inbox
|
||||
# *.md glob never sees it): the final mv is then a same-filesystem rename,
|
||||
# so readers never observe a half-written message.
|
||||
TMP="$(mktemp "$DEST_DIR/.coord-send.XXXXXX" 2>/dev/null)"
|
||||
[ -n "$TMP" ] || { echo "coord-send: cannot create temp file in $DEST_DIR" >&2; exit 2; }
|
||||
{
|
||||
echo "---"
|
||||
echo "from: $FROM"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue