Skip to content

Fix Unicode-safe table truncation#2

Open
BinaryHusk wants to merge 1 commit into
fadidevv:masterfrom
BinaryHusk:unicode-safe-truncate
Open

Fix Unicode-safe table truncation#2
BinaryHusk wants to merge 1 commit into
fadidevv:masterfrom
BinaryHusk:unicode-safe-truncate

Conversation

@BinaryHusk
Copy link
Copy Markdown

Summary

  • Fix table truncation to count Unicode scalar values instead of UTF-8 bytes.
  • Prevent panics when repository names or file paths contain multibyte characters.
  • Add regression tests for Chinese paths and repository names.

Reproduction log

Before this change, scanning DeepSeek keys could panic while rendering results if a repository file path contained multibyte characters:

❯ ./target/release/keyhunter scan -p deepseek

    ╦╔═╔═╗╦ ╦╦ ╦╦ ╦╔╗╔╔╦╗╔═╗╦═╗
    ╠╩╗║╣ ╚╦╝╠═╣║ ║║║║ ║ ║╣ ╠╦╝
    ╩ ╩╚═╝ ╩ ╩ ╩╚═╝╝╚╝ ╩ ╚═╝╩╚═

    Fast GitHub API Key Scanner
    ────────────────────────────

🔍 Scanning 1 provider(s), 6 queries total
ℹ Press Ctrl+C to stop and save results

→ Provider: DeepSeek (DeepSeek API Key)
    ⟩ Query 1/6: DEEPSEEK_API_KEY
      ⠋ Searching...
      ↳ 3 keys found
    ⟩ Query 2/6: DEEPSEEK_API_KEY filename:.env
      ⠋ Searching...
      ↳ 12 keys found
    ⟩ Query 3/6: DEEPSEEK_KEY
      ⠋ Searching...
      ↳ 2 keys found
    ⟩ Query 4/6: DEEPSEEK_KEY filename:.env
      ⠋ Searching...
      ↳ 9 keys found
    ⟩ Query 5/6: deepseek_api
      ⠋ Searching...
      ↳ 3 keys found
    ⟩ Query 6/6: deepseek_api filename:.env
      ⠋ Searching...
      ↳ 15 keys found
    ✓ Running total: 33 unique keys


════════════════════════════════════════════════════════════════════════════════
🔑 Found 33 potential leaked keys


thread 'main' (1115095) panicked at src/scanner.rs:844:28:
byte index 4 is not a char boundary; it is inside '州' (bytes 3..6) of `瀛州纪/.env.backup`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Testing

  • cargo test
  • cargo build --release
  • ./target/release/keyhunter scan -p deepseek

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