fix(hide-secrets): drop the plugin docstrings and pin the block-scalar shapes

This commit is contained in:
Yucheng He 2026-09-07 22:41:36 -07:00
parent 3b9742a34a
commit 0521663378
2 changed files with 6 additions and 8 deletions

View file

@ -1,7 +1,3 @@
"""
This plugin searches for credential-shaped values assigned to a credential-named key.
"""
import re
from collections.abc import Generator, Mapping
from typing import Final
@ -15,10 +11,6 @@ _LOWERCASE_WORD_SEQUENCE: Final = re.compile(r"[a-z]+(?:[-._/][a-z]+)+")
class CredentialKeywordDetector(KeywordDetector): # pyright: ignore[reportUntypedBaseClass] # detect_secrets ships no type information
"""Yields the values ``KeywordDetector`` matches that are one credential-shaped token of
at least ``minimum_length`` characters, dropping the ones that name a credential rather
than holding one."""
secret_type = "Credential Keyword"
def __init__(

View file

@ -329,6 +329,9 @@ def test_scan_message_keeps_every_value_when_a_config_repeats_a_key():
" api_key: aB3dE6gH9jK2mN5p\n",
"aB3dE6gH9jK2mN5p",
),
("api_key: >\n aB3dE6gH9jK2mN5p", "aB3dE6gH9jK2mN5p"),
("api_key: |-\n aB3dE6gH9jK2mN5p", "aB3dE6gH9jK2mN5p"),
("secret= \\\n aB3dE6gH9jK2mN5p", "aB3dE6gH9jK2mN5p"),
],
ids=[
"flat-assignment",
@ -338,6 +341,9 @@ def test_scan_message_keeps_every_value_when_a_config_repeats_a_key():
"prose-after",
"prose-both-sides",
"indented-config",
"yaml-folded-block",
"yaml-literal-block",
"backslash-continuation",
],
)
def test_scan_message_still_sees_assignments_sharing_a_message_with_a_vendor_key(