Skip to content

test: add edge case coverage for path_escaper #18

@Fieldnote-Echo

Description

Summary

The path_escaper has 4 tests covering basic traversal attacks, but several edge cases are untested.

What to do

Add test methods to the TestPathEscaper class in tests/test_escapers.py:

  1. Multiple consecutive slashespath_escaper("foo///bar") should normalize
  2. Dot-only inputspath_escaper("..") and path_escaper(".") alone
  3. Dots within filenamespath_escaper("file..txt") and path_escaper("..hidden") should be preserved (not path components)
  4. Encoded traversal artifactspath_escaper("foo\x00/../bar") (null byte + traversal)
  5. Trailing traversalpath_escaper("foo/bar/../../")

If any test reveals a bug, note it in the PR — fixing it is a bonus but not required.

Files

  • tests/test_escapers.py — add to TestPathEscaper

Hints

  • Read src/navi_sanitize/escapers/_path.py to understand the regex logic
  • Note that path_escaper runs after the main pipeline (null bytes are already stripped by then), but test the escaper in isolation too
  • Run tests with: uv run pytest tests/test_escapers.py -v --benchmark-disable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions