Skip to content

Restrict A1Z26 Magic checks to valid ranges#2644

Open
vetrovk wants to merge 1 commit into
gchq:masterfrom
vetrovk:fix/a1z26-magic-valid-range
Open

Restrict A1Z26 Magic checks to valid ranges#2644
vetrovk wants to merge 1 commit into
gchq:masterfrom
vetrovk:fix/a1z26-magic-valid-range

Conversation

@vetrovk

@vetrovk vetrovk commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #2642.

This change tightens the A1Z26 Magic detection regexes so they only match valid A1Z26 numbers in the 1..26 range. Invalid values like 0 or 27 no longer trigger A1Z26 decode attempts through Magic, avoiding unnecessary OperationError logging.

Changes:

  • restrict A1Z26 Magic checks to valid values 01..09, 1..9, and 10..26
  • preserve valid leading-zero matches such as 01 and 09
  • add Magic regression coverage for invalid and valid A1Z26 candidates

Validation:

  • env PATH="/opt/homebrew/opt/node@24/bin:/Users/kirillvetrov/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Users/kirillvetrov/.codex/tmp/arg0/codex-arg0EUeKBi:/Users/kirillvetrov/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin:/Users/kirillvetrov/.local/bin:/Users/kirillvetrov/.mimocode/bin:/Applications/Codex.app/Contents/Resources" npm ci
  • env PATH="/opt/homebrew/opt/node@24/bin:/Users/kirillvetrov/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Users/kirillvetrov/.codex/tmp/arg0/codex-arg0EUeKBi:/Users/kirillvetrov/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin:/Users/kirillvetrov/.local/bin:/Users/kirillvetrov/.mimocode/bin:/Applications/Codex.app/Contents/Resources" npx grunt configTests
  • full operation tests: 2190/2190 passed
  • env PATH="/opt/homebrew/opt/node@24/bin:/Users/kirillvetrov/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Users/kirillvetrov/.codex/tmp/arg0/codex-arg0EUeKBi:/Users/kirillvetrov/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin:/Users/kirillvetrov/.local/bin:/Users/kirillvetrov/.mimocode/bin:/Applications/Codex.app/Contents/Resources" npm run lint
  • git diff --check

Notes:

  • A1Z26CipherDecode.run() behavior is unchanged.
  • Broader Magic/Recipe error handling and logging behavior are unchanged.

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.

Bug report: Magic this.checks regex(s) in A1Z26 Operation are too broad, leading to console log errors when they incorrectly match

1 participant