test: harden lighthouse mirror fail-closed checks
This commit is contained in:
parent
b1533ef23a
commit
4f24edc3b2
4 changed files with 22 additions and 4 deletions
|
|
@ -26,6 +26,7 @@ PRIVATE_VALUE_PATTERNS = [
|
|||
("URL_CREDENTIAL", re.compile(r"(?i)(?:https?|ssh)://[^\s/@:]+:[^\s/@]+@")),
|
||||
]
|
||||
PUBLIC_PAYLOAD_KEYS = {"instructions", "input_schema", "output_schema", "examples", "limitations", "dependencies", "license", "compatibility"}
|
||||
SAFE_INTEGRITY_KEYS = {"freshness_token"}
|
||||
|
||||
|
||||
class MirrorError(RuntimeError):
|
||||
|
|
@ -95,7 +96,7 @@ def sanitize(value: Any) -> Any:
|
|||
|
||||
def contains_private(value: Any) -> bool:
|
||||
if isinstance(value, dict):
|
||||
return any(DENIED_KEYS.search(str(key)) or contains_private(item) for key, item in value.items())
|
||||
return any((key not in SAFE_INTEGRITY_KEYS and DENIED_KEYS.search(str(key))) or contains_private(item) for key, item in value.items())
|
||||
if isinstance(value, list):
|
||||
return any(contains_private(item) for item in value)
|
||||
if isinstance(value, str):
|
||||
|
|
|
|||
Loading…
Reference in a new issue