Auditor recorded output

← All 27 packs

Proven

Format characters are replaced with spaces instead of removed, splitting words and emoji

buglow src/argus_scout/channels/text.py:4

The finding

The docstring says control and format characters are removed, but the expression maps every category-C character except '\n' and '\t' to a single space. Category C includes Cf (format) characters such as soft hyphen U+00AD, zero-width space/joiner U+200B/U+200D, the BOM U+FEFF and bidi marks. These normally appear inside words or emoji sequences. Examples: 'co\u00adoperate' becomes 'co operate', and a ZWJ family emoji becomes three separate emoji separated by spaces. A stray lone '\r' also becomes a space. The result is corrupted text in briefings sent through echo/mask.

    1| """The ``text`` channel: append each message to a plain-text file, readable with ``tail -f``.
    2| 
    3| ::
    4| 
    5|     - kind: text
    6|       name: log
    7|       dir: .                      # relative to scout.yaml
    8|       file: scout-{kind}.log      # {kind} and {date} (YYYY-MM-DD, UTC) are filled in per message
    9|       rotate_bytes: 1048576       # rotate before the file grows past 1 MiB; leave out to never rotate
   10|       keep: 3                     # rotated files kept (x.log.1 ... x.log.3)
   11| 
   12| **Fenced under ``dir``.** ``dir`` is the operator's choice; ``file`` and anything filled into it are not
   13| trusted to stay inside it. Every write resolves the target through ``argus_cortex.fs.safe_join`` (symlinks
   14| followed): a ``..``, an absolute path or a symlink that leads out of ``dir`` is refused, and the file is then
   15| opened with ``O_NOFOLLOW``, so a symlink swapped in at the last component isn't followed either. A kind
   16| filled into ``{kind}`` is reduced to safe characters first.

The work pack

Recommendation. Drop Cf characters (and ideally other non-whitespace C characters) entirely rather than substituting a space. Keep the space substitution only for actual whitespace-like controls such as '\r', '\v' and '\f'. Update the docstring to match the chosen behaviour.

Acceptance criteria

  • Address: Format characters are replaced with spaces instead of removed, splitting words and emoji
  • Keep the change scoped to the cited file/symbols unless impact requires otherwise
  • Drop Cf characters (and ideally other non-whitespace C characters) entirely rather than substituting a space. Keep the space substitution only for actual whitespace-like controls such as '\r', '\v' and '\f'. Update the docstring to match th
  • Re-check src/argus_scout/channels/text.py after the fix

Status

  1. claimed
  2. resolved

The fix

7a206369dc fix: text channel drops format characters instead of spacing them.

diff --git a/src/argus_scout/channels/text.py b/src/argus_scout/channels/text.pyindex 02c6549..d37fb1b 100644--- a/src/argus_scout/channels/text.py+++ b/src/argus_scout/channels/text.py@@ -40,11 +40,19 @@ _UNSAFE = re.compile(r"[^A-Za-z0-9._-]+")   def clean(text: str) -> str:-    """``text`` with control and format characters removed; newlines kept, tabs as four spaces."""-    return "".join(-        ch if ch == "\n" or not unicodedata.category(ch).startswith("C") else ("    " if ch == "\t" else " ")-        for ch in text.replace("\r\n", "\n")-    )+    """``text`` with control and format characters removed; newlines kept, tabs as four spaces, and the other+    whitespace controls (``\\r``, ``\\v``, ``\\f``) as one space. Other format characters (soft hyphens, bidi+    marks, zero-width spaces) are dropped, never spaced, so they don't split words; the zero-width joiner and+    non-joiner are kept, since emoji sequences and some scripts need them."""+    return "".join(_clean_char(ch) for ch in text.replace("\r\n", "\n"))+++def _clean_char(ch: str) -> str:+    if ch in "\n\u200c\u200d" or not unicodedata.category(ch).startswith("C"):+        return ch+    if ch == "\t":+        return "    "+    return " " if ch in "\r\v\f" else ""   def _segment(value: str) -> str:diff --git a/tests/test_channels.py b/tests/test_channels.pyindex 408bd65..dee8c83 100644--- a/tests/test_channels.py+++ b/tests/test_channels.py@@ -33,7 +33,7 @@ from argus_scout.channels import (     load_registry, ) from argus_scout.channels import registry as registry_module-from argus_scout.channels.text import TextChannel, append, target_path+from argus_scout.channels.text import TextChannel, append, clean, target_path from argus_scout.channels.webhook import PAYLOAD_SCHEMA, WebhookChannel, build_payload, post, sign from argus_scout.cli import app from argus_scout.config import ConfigError, parse_config@@ -838,3 +838,9 @@ def test_deliver_to_a_disabled_channel_says_so(tmp_path, monkeypatch):     path.write_text(json.dumps({"channels": DISABLED_VOICE}))     result = runner.invoke(app, ["deliver", "-c", str(path), "--latest", "--channel", "house"])     assert result.exit_code == 1 and "channel house is disabled" in result.output+++def test_text_clean_drops_format_characters_without_splitting_words():+    family = "\U0001f468\u200d\U0001f469"+    assert clean("co\u00adoperate \u202eabc\u202c x\u200by") == "cooperate abc xy"+    assert clean(f"{family} a\rb\tc\x00d\r\ne") == f"{family} a b    cd\ne"

How it was judged

Proven 1 test(s) fail on dev and pass with the fix: tests/test_channels.py::test_text_clean_drops_format_characters_without_splitting_words

Judged 24 Nov 2026, 04:49 UTC against dev at d0c0f66.

Teston devdev + patch
tests/test_channels.py::test_text_clean_drops_format_characters_without_splitting_wordsfailedpassed
The other 34 tests in the run (34 with the same result on both trees)
tests/test_channels.py::test_a_briefing_job_writes_its_report_to_the_text_channel_oncepassedpassed
tests/test_channels.py::test_a_disabled_channel_is_still_validatedpassedpassed
tests/test_channels.py::test_a_disabled_channel_needs_no_extra_and_is_never_builtpassedpassed
tests/test_channels.py::test_a_failing_speaker_or_synthesiser_fails_voice_onlypassedpassed
tests/test_channels.py::test_a_plugin_model_raising_anything_fails_only_its_channelpassedpassed
tests/test_channels.py::test_bad_channel_entries_do_not_stop_the_otherspassedpassed
tests/test_channels.py::test_builtins_are_registered_through_entry_pointspassedpassed
tests/test_channels.py::test_channel_configpassedpassed
tests/test_channels.py::test_channel_kind_that_is_not_text_is_a_config_errorpassedpassed
tests/test_channels.py::test_channels_run_concurrentlypassedpassed
tests/test_channels.py::test_check_config_passes_with_disabled_channels_and_no_extraspassedpassed
tests/test_channels.py::test_check_config_reports_a_bad_channelpassedpassed
tests/test_channels.py::test_cli_deliver_charges_the_speech_capspassedpassed
tests/test_channels.py::test_cli_deliver_latestpassedpassed
tests/test_channels.py::test_concurrent_deliveries_of_one_message_send_oncepassedpassed
tests/test_channels.py::test_deliver_to_a_disabled_channel_says_sopassedpassed
tests/test_channels.py::test_delivery_from_report_and_eventpassedpassed
tests/test_channels.py::test_fan_out_and_a_failing_channel_never_blocks_the_otherspassedpassed
tests/test_channels.py::test_heartbeat_gatespassedpassed
tests/test_channels.py::test_no_duplicate_delivery_after_restartpassedpassed
tests/test_channels.py::test_no_synthesiser_holds_voice_back_and_text_still_goespassedpassed
tests/test_channels.py::test_plain_speechpassedpassed
tests/test_channels.py::test_runtime_deliver_writes_the_text_channelpassedpassed
tests/test_channels.py::test_severity_kind_and_enabled_filterspassedpassed
tests/test_channels.py::test_speech_is_synthesised_once_for_every_voice_channelpassedpassed
tests/test_channels.py::test_starter_config_delivers_text_out_of_the_boxpassedpassed
tests/test_channels.py::test_text_channel_appendspassedpassed
tests/test_channels.py::test_text_channel_paths_outside_root_are_refusedpassedpassed
tests/test_channels.py::test_text_channel_rotatespassedpassed
tests/test_channels.py::test_the_voice_gate_suppresses_voice_but_not_textpassedpassed
tests/test_channels.py::test_third_party_voice_channel_from_an_entry_pointpassedpassed
tests/test_channels.py::test_webhook_payload_and_signaturepassedpassed
tests/test_channels.py::test_webhook_refuses_to_send_without_its_secrets_or_to_another_hostpassedpassed
tests/test_channels.py::test_webhook_retries_with_backoff_then_gives_uppassedpassed