Potential fix for code scanning alert no. 48: Clear-text logging of sensitive information#47
Draft
Potential fix for code scanning alert no. 48: Clear-text logging of sensitive information#47
Conversation
…ensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_idvalue 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
printinexample_dispatch_incoming_messageinexamples/python/e2e_encryption_v2_examples/key_manager_example.pyso it no longer interpolatessecret_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 inmessage_builder.pyandsession.pyare about data flow into this sink, not about those functions logging directly.Concretely:
examples/python/e2e_encryption_v2_examples/key_manager_example.py, on line 194, replaceprint(f"[步骤 2] Alice 发送加密消息, secret_key_id={secret_key_id}")with a message that does not reveal
secret_key_id, such asprint("[步骤 2] Alice 发送加密消息(已生成 secret_key_id)").Suggested fixes powered by Copilot Autofix. Review carefully before merging.