fix(api): redact autonomous runtime public payload terms
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / build-and-deploy (push) Has been cancelled
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / tests (push) Has been cancelled

This commit is contained in:
Your Name
2026-06-30 19:05:24 +08:00
parent 4e909b2118
commit c6c90e72f9
3 changed files with 39 additions and 1 deletions

View File

@@ -52,6 +52,10 @@ _EXECUTOR_OPERATION_TYPES = (
"ansible_execution_skipped",
LOG_CONTROLLED_WRITEBACK_DISPATCH_OPERATION_TYPE,
)
_PUBLIC_VALUE_REDACTIONS = (
("raw_payload", "source_payload"),
("raw payload", "source payload"),
)
logger = get_logger(__name__)
@@ -80,6 +84,24 @@ def _row_mapping(row: Mapping[str, Any] | Any) -> dict[str, Any]:
return dict(row)
def redact_autonomous_runtime_control_public_terms(value: Any) -> Any:
"""Redact display strings that would imply raw prompt/payload exposure."""
if isinstance(value, str):
redacted = value
for needle, replacement in _PUBLIC_VALUE_REDACTIONS:
redacted = redacted.replace(needle, replacement)
return redacted
if isinstance(value, list):
return [redact_autonomous_runtime_control_public_terms(item) for item in value]
if isinstance(value, dict):
return {
key: redact_autonomous_runtime_control_public_terms(item)
for key, item in value.items()
}
return value
def _int_value(value: Any) -> int:
try:
return int(value or 0)