Skip to content

Remove stdin mode: require explicit file arguments#88

Merged
campoy merged 2 commits intomasterfrom
remove/stdin
Apr 11, 2026
Merged

Remove stdin mode: require explicit file arguments#88
campoy merged 2 commits intomasterfrom
remove/stdin

Conversation

@campoy
Copy link
Copy Markdown
Owner

@campoy campoy commented Apr 11, 2026

Summary

  • Removes the ability to read from standard input when no file arguments are given.
  • Calling embedmd with no arguments now exits immediately with error: no markdown files provided instead of blocking on stdin.
  • Deletes the stdin package-level variable and all stdin-handling branches in embed.
  • Replaces TestEmbedStreams with TestEmbedNoPaths, which verifies the new error behaviour and the existing -w/-d conflict check.

Motivation

The stdin path was never an intentional feature — it fell out of the "if no args, read stdin" idiom. It is a security liability: without a known base directory there is no boundary to enforce for path traversal checks, so an embed directive arriving via stdin can instruct embedmd to read arbitrary files on the host. The feature also has little practical utility, because file paths embedded in a document have no anchor without a base directory. Removing it eliminates the attack surface entirely.

Follow-up to #84.

Test plan

  • go test ./... passes with no changes to test coverage of non-stdin paths.
  • TestEmbedNoPaths verifies that embed(nil, false, false) returns "error: no markdown files provided".
  • TestEmbedNoPaths also verifies that -w -d together still returns "error: cannot use -w and -d simultaneously".

Francesc Campoy and others added 2 commits April 10, 2026 19:41
Without a base directory there is no boundary to enforce for path
traversal checks, so any embed directive passed via stdin can read
arbitrary files on the host. Additionally, stdin mode has little
practical utility because local file paths embedded in a document have
no anchor without a known base directory.

This commit removes the stdin-reading path entirely. Calling embedmd
with no file arguments now exits with an error instead of blocking on
stdin. The `stdin` package-level variable and all associated branches
in `embed` are deleted; `TestEmbedStreams` is replaced by
`TestEmbedNoPaths` which verifies the new error behaviour.

Follow-up to #84.
@campoy campoy merged commit 2a42830 into master Apr 11, 2026
3 checks passed
@campoy campoy deleted the remove/stdin branch April 11, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant