Skip to content

Close #601: strict tests for objective-c, fix 13 real symbolic-\b bugs - #639

Merged
squid-protocol merged 1 commit into
mainfrom
test-objectivec-strict-parsing
Jul 26, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
test-objectivec-strict-parsing

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Full positive/negative/ambiguity/ReDoS coverage for all 44 checklisted structural signatures objective-c defines (per epic #518's per-language scaffold). Objective-C turned out to be the single worst-hit language yet for the "\b-wrapped-symbolic-token" bug class (see #585, #637): its @-directive syntax and colon-terminated selector keywords are exactly the shape that breaks under a shared \b(...)\b wrapper. 13 confirmed bugs across 11 signatures.

Bugs found and fixed

@-directive fixes (leading \b before non-word @ never matched real code -- \b requires a word/non-word transition, but @ preceded by a space/line-start is non-word-to-non-word, no transition exists):

  • branch, safety: @try/@catch/@finally
  • structural_boundaries: @interface/@implementation/@protocol/@end/@synthesize/@dynamic/@class/@import
  • concurrency, sync_locks: @synchronized
  • panics_and_aborts: @throw
  • encapsulation: @private/@protected/@package
  • ownership: @author

Trailing-colon selector fixes (trailing \b after a literal : only worked when followed by ANOTHER non-word char -- true for a plain identifier argument, false for the equally common @selector(...) form):

  • comprehensions: enumerateObjectsUsingBlock:/filteredArrayUsingPredicate:/makeObjectsPerformSelector:
  • safety_bypasses: performSelector: (also dropped the now-redundant "performSelector:withObject:" alternative -- it's an unreachable subset of "performSelector:" in left-to-right alternation)
  • dependency_injection: inject:/initWithDependency:
  • listeners: addObserver:/observeValueForKeyPath:/subscribeNext:

Bracket-message fix (globals): [UIApplication sharedApplication] and [NSWorkspace sharedWorkspace] never matched -- both leading [ and trailing ] are non-word, so neither boundary could fire.

Also confirmed (not a bug, documented as accepted)

&foo intentionally triggers both bitwise_ops and pointers -- & is genuinely overloaded in C-family syntax for unary address-of and binary bitwise-AND, and disambiguating requires real parsing, not a regex fix. Added a test that locks in this current, accepted dual-classification.

Golden master fixtures

Updated via the sanctioned tests/tools/update_golden_master.py, reviewed before blessing: all 105 diffs confined to objective-c files (Sequential Logic Declarations: 0->1, 0->2 -- real @interface/@implementation detection firing for the first time), zero signal-count collapse.

Test plan

  • pytest tests/ -- 1134 passed
  • python tests/ruff_audit.py --ci -- clean
  • python tests/mypy_audit.py --ci -- clean
  • pytest -m golden_crucible -- passes in both full-precision and zero-dependency modes after fixture regeneration

Closes #601.

🤖 Generated with Claude Code

Full positive/negative/ambiguity/ReDoS coverage for all 44 checklisted
structural signatures objective-c defines (per epic #518's per-language
scaffold). Objective-C turned out to be the single worst-hit language yet
for the "\b-wrapped-symbolic-token" bug class (#585, #637): its @-directive
syntax and colon-terminated selector keywords are exactly the shape that
breaks under a shared \b(...)\b wrapper. 13 confirmed bugs across 11
signatures:

@-directive fixes (leading \b before non-word `@` never matched real code):
- branch: @try/@catch/@finally
- safety: @try/@catch/@finally
- structural_boundaries: @interface/@implementation/@protocol/@end/
  @synthesize/@dynamic/@class/@import
- concurrency: @synchronized
- sync_locks: @synchronized
- panics_and_aborts: @throw
- encapsulation: @private/@protected/@Package
- ownership: @author

Trailing-colon selector fixes (trailing \b after literal `:` only worked
when followed by ANOTHER non-word char -- true for a plain identifier
argument, false for the equally common `@selector(...)` form):
- comprehensions: enumerateObjectsUsingBlock:/filteredArrayUsingPredicate:/
  makeObjectsPerformSelector:
- safety_bypasses: performSelector: (also dropped the now-redundant
  "performSelector:withObject:" alternative -- it's an unreachable subset
  of "performSelector:" in left-to-right alternation)
- dependency_injection: inject:/initWithDependency:
- listeners: addObserver:/observeValueForKeyPath:/subscribeNext:

Bracket-message fix (globals): `[UIApplication sharedApplication]` and
`[NSWorkspace sharedWorkspace]` never matched -- both leading `[` and
trailing `]` are non-word, so neither boundary could fire.

Also confirmed (not fixed, documented as accepted): `&foo` intentionally
triggers both bitwise_ops and pointers -- `&` is genuinely overloaded in
C-family syntax for unary address-of and binary bitwise-AND, and
disambiguating requires real parsing, not a regex fix.

Golden master fixtures updated via the sanctioned
tests/tools/update_golden_master.py and reviewed before blessing: all 105
diffs confined to objective-c files (Sequential Logic Declarations: 0->1,
0->2 -- real @interface/@implementation detection firing for the first
time), zero signal-count collapse.

Full suite (1134 tests), ruff audit, mypy audit, and both golden-crucible
modes pass.

Closes #601.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 1ce93fc into main Jul 26, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the test-objectivec-strict-parsing branch July 26, 2026 18:17
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.

Strict parsing tests: objective-c structural signatures

1 participant