Skip to content

test: regression test for -- end-of-options separator in _write_to_journal#122

Merged
GingerGraham merged 2 commits into
fix/issue-120from
copilot/fix-review-comment-3368180009
Jun 6, 2026
Merged

test: regression test for -- end-of-options separator in _write_to_journal#122
GingerGraham merged 2 commits into
fix/issue-120from
copilot/fix-review-comment-3368180009

Conversation

Copilot AI commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

The _write_to_journal fix for option-injection (messages starting with -) had no regression coverage, leaving the behaviour free to silently break.

Changes

  • tests/test_journal_logging.sh — adds test_write_to_journal_passes_double_dash_before_message: invokes log_to_journal INFO '-n not-an-option' via a stub logger and asserts the captured invocation contains -- -n, confirming the -- separator always precedes the message argument in the logger call:

    "$LOGGER_PATH" -p "${SYSLOG_FACILITY}.${priority}" -t "$tag" -- "$message"
    #                                                            ^^
  • Uses assert_contains on $(cat "$STUB_CAPTURE") rather than assert_file_contains to avoid a grep quirk where patterns beginning with -- are misinterpreted as long option names.

Adds test_write_to_journal_passes_double_dash_before_message to
test_journal_logging.sh to assert that log_to_journal passes --
before the message argument when calling logger, preventing
option-injection for messages that begin with a hyphen (e.g.
'-n not-an-option').

Uses assert_contains on the captured stub output instead of
assert_file_contains to avoid a grep quirk where patterns starting
with '--' are misinterpreted as long option names on this platform.

Closes review comment #121 (comment)
Copilot AI changed the title [WIP] Fix code based on review comment 3368180009 test: regression test for -- end-of-options separator in _write_to_journal Jun 6, 2026
Copilot AI requested a review from GingerGraham June 6, 2026 20:28
@GingerGraham GingerGraham marked this pull request as ready for review June 6, 2026 20:33
Copilot AI review requested due to automatic review settings June 6, 2026 20:33
@GingerGraham GingerGraham merged commit ef9de0d into fix/issue-120 Jun 6, 2026
3 checks passed
@GingerGraham GingerGraham deleted the copilot/fix-review-comment-3368180009 branch June 6, 2026 20:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds regression coverage to ensure _write_to_journal always uses the -- end-of-options separator before the message argument, preventing logger option-injection when messages begin with -.

Changes:

  • Adds test_write_to_journal_passes_double_dash_before_message to validate the stubbed logger invocation contains -- immediately before a hyphen-prefixed message.
  • Updates the test suite “Covers” header and ensures the new regression test runs with the rest of the journal logging suite.

GingerGraham added a commit that referenced this pull request Jun 6, 2026
* fix(#120): ensure message handling in journal logging command

* test: regression test for `--` end-of-options separator in `_write_to_journal` (#122)

* Initial plan

* test: add regression test for -- separator in _write_to_journal

Adds test_write_to_journal_passes_double_dash_before_message to
test_journal_logging.sh to assert that log_to_journal passes --
before the message argument when calling logger, preventing
option-injection for messages that begin with a hyphen (e.g.
'-n not-an-option').

Uses assert_contains on the captured stub output instead of
assert_file_contains to avoid a grep quirk where patterns starting
with '--' are misinterpreted as long option names on this platform.

Closes review comment #121 (comment)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.

3 participants