Skip to content

fix(probe_data): keep non-ASCII letters intact in caesar and vigenere ciphers - #412

Open
goul4rt wants to merge 1 commit into
msoedov:mainfrom
goul4rt:fix/cipher-non-ascii
Open

goul4rt wants to merge 1 commit into
msoedov:mainfrom
goul4rt:fix/cipher-non-ascii

Conversation

@goul4rt

@goul4rt goul4rt commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

What this changes

caesar_cipher and vigenere_cipher used str.isupper(), str.islower() and str.isalpha(). These are true for non-ASCII letters too, but the shift maths only works for a-z. So é, Ü and ß were turned into unrelated ASCII letters. For example, caesar_cipher("École") gave Jfroh.

Now only ASCII letters are shifted, and everything else is left as it is.

vigenere_cipher also had two problems with the key:

  • A key with non-letters, like k3y, produced a negative shift.
  • An empty key raised ZeroDivisionError.

The key is now reduced to its ASCII letters. If none are left, it raises a ValueError.

How it was tested

Added tests in agentic_security/probe_data/test_stenography_fn.py. 4 of the 5 new tests fail on main and pass with this change. The fifth, which checks plain ASCII shifting, passes on both.

Ran the file with pytest (9 passed). black --check and flake8 are clean on the changed files. I did not run the full pre-commit run --all-files.

Checklist

  • No real API key, token or customer endpoint anywhere in the code, tests, docs or this description (CONTRIBUTING.md).
  • pytest passes and new behaviour has a test. Tests don't call paid APIs.
  • pre-commit run --all-files is clean (not run; black and flake8 ran on the changed files).
  • Docs updated if behaviour changed (no docs affected).

This branch has not been deployed

No deployments
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.

1 participant