fix(redact): cover fireworks token prefixes

This commit is contained in:
luyifan 2026-07-05 03:21:41 +08:00 committed by Teknium
parent e670d9cdd6
commit 2b58febe46
2 changed files with 18 additions and 0 deletions

View file

@ -107,7 +107,9 @@ _PREFIX_PATTERNS = [
r"brv_[A-Za-z0-9]{10,}", # ByteRover API key
r"xai-[A-Za-z0-9]{30,}", # xAI (Grok) API key
r"ntn_[A-Za-z0-9]{10,}", # Notion internal integration token
r"fw-[A-Za-z0-9]{30,}", # Fireworks AI API key
r"fw_[A-Za-z0-9]{30,}", # Fireworks AI API key
r"fpk_[A-Za-z0-9]{30,}", # Fireworks AI project key
]
# ENV assignment patterns: KEY=value where KEY contains a secret-like name.

View file

@ -59,6 +59,22 @@ class TestKnownPrefixes:
result = redact_sensitive_text("fal_abc123def456ghi789jkl")
assert "abc123def456" not in result
def test_fireworks_keys(self):
samples = [
"fw-" + "A" * 40,
"fw_" + "B" * 40,
"fpk_" + "C" * 40,
]
for token in samples:
result = redact_sensitive_text(f"provider error {token}")
assert token not in result
assert "..." in result
def test_short_fireworks_like_words_unchanged(self):
text = "fw-tooshort fw_tooshort fpk_tooshort"
assert redact_sensitive_text(text) == text
def test_notion_internal_integration_token(self):
result = redact_sensitive_text("ntn_abc123def456ghi789jkl")
assert "abc123def456" not in result