Skip to content

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

Draft
whyseu wants to merge 1 commit intomasterfrom
alert-autofix-48
Draft

Potential fix for code scanning alert no. 48: Clear-text logging of sensitive information#47
whyseu wants to merge 1 commit intomasterfrom
alert-autofix-48

Conversation

@whyseu
Copy link

@whyseu whyseu commented Mar 5, 2026

Potential fix for https://github.com/agent-network-protocol/anp/security/code-scanning/48

In general, the fix is to stop logging the sensitive secret_key_id value in clear text. For this specific example, we can keep the informational log while redacting the actual identifier, so behaviour is unchanged except for what appears in stdout.

The best minimal change is to modify the print in example_dispatch_incoming_message in examples/python/e2e_encryption_v2_examples/key_manager_example.py so it no longer interpolates secret_key_id. Instead, we can either state that a secret key ID was generated, or include only a non-sensitive derived representation (e.g., a fixed placeholder or a short, non-identifying hash). To avoid introducing new dependencies or functionality, we’ll simply remove the interpolation and mention the existence of the ID generically. No other files need changes, because the alerts in message_builder.py and session.py are about data flow into this sink, not about those functions logging directly.

Concretely:

  • In examples/python/e2e_encryption_v2_examples/key_manager_example.py, on line 194, replace
    print(f"[步骤 2] Alice 发送加密消息, secret_key_id={secret_key_id}")
    with a message that does not reveal secret_key_id, such as
    print("[步骤 2] Alice 发送加密消息(已生成 secret_key_id)").
  • No new imports or helper methods 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>
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