Skip to content

Potential fix for code scanning alert no. 21: Clear-text logging of sensitive information#25

Merged
johnteee merged 1 commit into
mainfrom
alert-autofix-21
May 25, 2026
Merged

Potential fix for code scanning alert no. 21: Clear-text logging of sensitive information#25
johnteee merged 1 commit into
mainfrom
alert-autofix-21

Conversation

@johnteee

Copy link
Copy Markdown
Member

Potential fix for https://github.com/TeaEntityLab/teaAgent/security/code-scanning/21

Best fix: strengthen sanitization before logging so that known secret-like values are redacted even when they are not under sensitive-looking keys.

In teaagent/cli/_handlers/_doctor.py, update _redact_sensitive_fields to support a contextual pass of sensitive values discovered under sensitive keys, and then redact matching scalar occurrences anywhere else in the payload. This preserves existing behavior while closing the gap that CodeQL tracks from checks['api_token'] to print_json. No functional behavior changes besides safer output.

Concretely:

  • Extend _redact_sensitive_fields signature to carry an optional known_sensitive_values set.
  • When visiting dict entries whose key is sensitive, store the original scalar value in that set and replace with _REDACTED.
  • When visiting scalar values later, if they match a known sensitive value, replace with _REDACTED.
  • Keep existing recursive dict/list traversal and current key-based redaction.
  • print_json can remain as-is (safe_value = _redact_sensitive_fields(value)), since default set creation happens in the function.

No new dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@johnteee
johnteee marked this pull request as ready for review May 25, 2026 02:17
@johnteee
johnteee merged commit bb3207f into main May 25, 2026
14 of 18 checks passed
@johnteee
johnteee deleted the alert-autofix-21 branch May 25, 2026 02:17
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