Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a sample to redact sensitive information after an agent generates a response #2927

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Git-Noob123
Copy link

Why are these changes needed?

There's a need for a way to redact sensitive data that is stored as env variables. Currently the only way to do this is to use transform_messages which ONLY redacts before an agent generates a response. However, if a user asks an agent to run a script that retrieves env data, it's still going to be revealed. So a way to hide sensitive data after a response is generated is needed. The sample here shows how can we do it using hooks

Related issue number

Checks

@Git-Noob123
Copy link
Author

@microsoft-github-policy-service agree

@ma-armenta ma-armenta removed the request for review from Knucklessg1 June 12, 2024 16:37
@sonichi
Copy link
Collaborator

sonichi commented Jun 13, 2024

Would you like to render the notebook on the website? Please find instructions here: https://microsoft.github.io/autogen/docs/contributor-guide/documentation

@sonichi sonichi requested a review from WaelKarkoub June 13, 2024 05:24
Copy link
Collaborator

@WaelKarkoub WaelKarkoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Git-Noob123 thank you for the notebook!

I like this notebook since it's a good example to show how process_message_before_send (hooks in general) works.

If we hook TransformMessages onto process_message_before_send it makes debugging these agents much more difficult, since you don't know the ground truth (as it gets modified before being stored in the context history). And as you may already know, it's already difficult to debug vanilla LLMs without any modifications.

In the intro, we should maybe explain the differences between each hookable method, and why you picked the process_message_before_send

notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
notebook/agentchat_postresponse_secret_redaction.ipynb Outdated Show resolved Hide resolved
@Git-Noob123
Copy link
Author

Git-Noob123 commented Jun 14, 2024

@WaelKarkoub Thanks for the comments! I have resolved all of them besides the regex one. I added a section at the beginning of the notebook to describe what's hooks in Autogen as well. Please review it and feel free to put in more comments & thoughts.

For debugging with the postprocess hook, I think we should add another section in the notebook to warn readers about how difficult it can be to debug with redacted message, and users can potentially add logging before redaction. On the other hand hiding sensitive information is more of a security concern, as you dont want users to see your secrets. Please let me know what you think

@ghost
Copy link

ghost commented Jun 14, 2024 via email

Copy link

gitguardian bot commented Jul 20, 2024

⚠️ GitGuardian has uncovered 96 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
12853598 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret e43a86c test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret bdb40d7 test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret 954ca45 test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
10404662 Triggered Generic CLI Secret eff19ac .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret 06a0a5d .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret 0524c77 .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret d7ea410 .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret e43a86c .github/workflows/dotnet-build.yml View secret
10404662 Triggered Generic CLI Secret 841ed31 .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret 802f099 .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret 9a484d8 .github/workflows/dotnet-build.yml View secret
10404662 Triggered Generic CLI Secret e973ac3 .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret 89650e7 .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret e07b06b .github/workflows/dotnet-release.yml View secret
10404662 Triggered Generic CLI Secret abe4c41 .github/workflows/dotnet-build.yml View secret
10404662 Triggered Generic CLI Secret 7362fb9 .github/workflows/dotnet-release.yml View secret
12853599 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
10404694 Triggered Generic High Entropy Secret e43a86c test/oai/test_utils.py View secret
10404694 Triggered Generic High Entropy Secret 954ca45 test/oai/test_utils.py View secret
10404694 Triggered Generic High Entropy Secret bdb40d7 test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret abad9ff test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret 954ca45 test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret c7bb588 test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret b97b99d test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret e43a86c test/oai/test_utils.py View secret
12853600 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
12853601 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
10493810 Triggered Generic Password 49e8053 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 501610b notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 49e8053 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 501610b notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password d422c63 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 97fa339 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 49e8053 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password d422c63 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 97fa339 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password d422c63 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 97fa339 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 501610b notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10404696 Triggered Generic High Entropy Secret 954ca45 test/oai/test_utils.py View secret
10404696 Triggered Generic High Entropy Secret bdb40d7 test/oai/test_utils.py View secret
10404696 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
10404696 Triggered Generic High Entropy Secret e43a86c test/oai/test_utils.py View secret
10422482 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
10422482 Triggered Generic High Entropy Secret bdb40d7 test/oai/test_utils.py View secret
12853602 Triggered Generic High Entropy Secret 79dbb7b test/oai/test_utils.py View secret
11616921 Triggered Generic High Entropy Secret a86d0fd notebook/agentchat_agentops.ipynb View secret
11616921 Triggered Generic High Entropy Secret 394561b notebook/agentchat_agentops.ipynb View secret
11616921 Triggered Generic High Entropy Secret 3eac646 notebook/agentchat_agentops.ipynb View secret
11616921 Triggered Generic High Entropy Secret f45b553 notebook/agentchat_agentops.ipynb View secret
11616921 Triggered Generic High Entropy Secret 6563248 notebook/agentchat_agentops.ipynb View secret
12853598 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
12853598 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret 0a3c6c4 test/oai/test_utils.py View secret
10404693 Triggered Generic High Entropy Secret 76f5f5a test/oai/test_utils.py View secret
10404662 Triggered Generic CLI Secret 954ca45 .github/workflows/dotnet-build.yml View secret
12853599 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
12853599 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret
10404694 Triggered Generic High Entropy Secret 76f5f5a test/oai/test_utils.py View secret
10404694 Triggered Generic High Entropy Secret 0a3c6c4 test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret 3b79cc6 test/oai/test_utils.py View secret
10404695 Triggered Generic High Entropy Secret 11baa52 test/oai/test_utils.py View secret
12853600 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret
12853600 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
12853601 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret
12853601 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
10493810 Triggered Generic Password 3b79cc6 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 11baa52 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 11baa52 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10493810 Triggered Generic Password 3b79cc6 notebook/agentchat_pgvector_RetrieveChat.ipynb View secret
10404696 Triggered Generic High Entropy Secret 0a3c6c4 test/oai/test_utils.py View secret
10404696 Triggered Generic High Entropy Secret 76f5f5a test/oai/test_utils.py View secret
10404696 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret
10404696 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
10422482 Triggered Generic High Entropy Secret 2b3a9ae test/oai/test_utils.py View secret
10422482 Triggered Generic High Entropy Secret c03558f test/oai/test_utils.py View secret

and 16 others.

🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants