Cover remaining C1 controls in stdisplay tests - #8
Conversation
|
stdisplay builds an allowlist of safe characters: printable ASCII (0x20–0x7E), newline, tab, and allowed SGR escape sequences. Everything else—including other control characters, Unicode beyond ASCII, and any escape sequence that is not an allowed SGR—is replaced with underscores. Conclusion Added a dedicated test case class covering hostile non-SGR escape sequences (OSC, DCS, kitty graphics, UTF-8 mode, and C1 CSI) to ensure they are neutralized by stdisplay. Added coverage for APC, PM, SOS, and C1 APC control strings to verify stdisplay redacts them outside the SGR allowlist. Added zero-width and right-to-left override examples to the shared escape-case corpus to verify they are reduced to safe placeholders. Introduced coverage for single C1 control characters and 8-bit string commands to confirm stdisplay neutralizes them. Added Unicode formatting controls (bidi overrides/isolates, zero-width joiner, BOM, and related markers) to the shared escape corpus to confirm they are reduced to safe placeholders. Added coverage for additional C0/C1 controls and nested OSC/DCS clipboard payloads to ensure stdisplay neutralizes them with underscores. Added regression coverage for additional C1 control bytes (NEL, PAD/SS3, and STS–EPA range) to confirm stdisplay replaces them with safe placeholders. |
| ] | ||
|
|
||
|
|
||
| class TestSTDisplayMaliciousCases(unittest.TestCase): |
There was a problem hiding this comment.
These don't have to go in their own class.
| ("\x1b]0;evil title\x07", "_]0;evil title_"), | ||
| ("\x1bP1;2|malicious\x1b\\", "_P1;2|malicious_\\"), | ||
| ("\x1b_Gf=24,s=1,v=1;AAAA\x1b\\", "__Gf=24,s=1,v=1;AAAA_\\"), | ||
| ("\x1b%Gpayload", "_%Gpayload"), |
There was a problem hiding this comment.
ESC % doesn't seem to be a C1 control sequence that I can tell.
All accepted. (I didn't audit to make sure all of the sequences in this PR are the sequences ChatGPT says it included, but really any weird Unicode and escape sequences should be caught by stdisplay, so I don't care too much about whether the commands being sanitized out are well-formed or even valid. We only cared about this for the CSI commands because stdisplay is supposed to semi-interpret and allow through some CSI commands.) Added the test cases in ArrayBolt3@bb095e1. (Did not use the redundant code from this.) This PR can be closed. |
…nload-error coverity: stop masking the download step's exit status
Address the actionable code-level alerts surfaced by CodeQL on the default branch. Skipped Scorecard meta-alerts (repo policy, not code) and the random-between clear-text-logging alert (false positive: the script's documented purpose is to print the random number to stdout). Fixed: - stdisplay.py: drop tautological `if sgr >= 2**3` so sgr_combo is always initialized (alert #9, py/uninitialized-local-variable). - guimessage.py: open file via `with`, drop dead commented-out code, drop unused local `message` (Kicksecure#21, #7, #8). - str_replace: open file via `with`; stdin path no longer needs a shared file handle (Kicksecure#22, py/file-not-closed). - sttee.py: manage output file lifetimes via `contextlib.ExitStack` instead of manual try/finally close loop (Kicksecure#23). - get-backing-devices-for-mountpoint: replace builtin `exit()` with `sys.exit()` (#10, py/use-of-exit-or-quit). - translations.py: bare `except:` -> `except Exception:`, `== None` -> `is None`, drop unused `import sys` (#17, Kicksecure#24, Kicksecure#25, Kicksecure#26). - leak-tests/{exhaustive_ip_send,simple_ping,tcp_test,udp_test}.py, find_wl_compositor, tor-dormant-check, tor-signal-newnym: drop unused imports (#11, #12, #13, #14, #15, #16, #18). - strip_markup/tests/strip_markup.py and unicode_show/tests/ unicode_show.py: replace `from unittest import mock` with `import unittest.mock as mock` so `unittest` isn't imported both ways (#19, #20).
Summary
Testing
Codex Task