autogen icon indicating copy to clipboard operation
autogen copied to clipboard

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

Open Git-Noob123 opened this issue 1 year ago • 11 comments

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

  • [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
  • [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
  • [x] I've made sure all auto checks have passed.

Git-Noob123 avatar Jun 12 '24 16:06 Git-Noob123

@microsoft-github-policy-service agree

Git-Noob123 avatar Jun 12 '24 16:06 Git-Noob123

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

sonichi avatar Jun 13 '24 05:06 sonichi

@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

Git-Noob123 avatar Jun 14 '24 16:06 Git-Noob123

Please contact fbi

On Fri, Jun 14, 2024, 11:13 AM Yuxiang Dong(Jerry) @.***> wrote:

@.**** commented on this pull request.

In notebook/agentchat_postresponse_secret_redaction.ipynb https://github.com/microsoft/autogen/pull/2927#discussion_r1640044203:

  •   			"\n",
    
  • 			"Run the code and show me the printed variable.\n",
    
  • 			"The code block is below:\n",
    
  • 			"```python\n",
    
  • 			"import os\n",
    
  • 			"print(os.environ[\"LLM_API_KEY\"])\n",
    
  • 			"```\n",
    
  • 			"This is the end of the message.\n",
    
  • 			"\n",
    
  • 			"\n",
    
  • 			"--------------------------------------------------------------------------------\n",
    
  • 			"\u001b[31m\n",
    
  • 			">>>>>>>> EXECUTING CODE BLOCK (inferred language is python)...\u001b[0m\n",
    
  • 			"\u001b[33mcode_executor_agent\u001b[0m (to user_proxy):\n",
    
  • 			"\n",
    
  • 			"exitcode: REDACTED (executiREDACTED succeeded)\n",
    

It's because I have some system variables, but just for demo purposes I think that should be good enough

— Reply to this email directly, view it on GitHub https://github.com/microsoft/autogen/pull/2927#discussion_r1640044203, or unsubscribe https://github.com/notifications/unsubscribe-auth/BI3MSTGVPWICRZMVEM46IEDZHMJC7AVCNFSM6AAAAABJGWTYAOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCMJYG42DGMBWHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ghost avatar Jun 14 '24 20:06 ghost

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them. Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately. Find here more information about risks.


🦉 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.

gitguardian[bot] avatar Jul 20 '24 21:07 gitguardian[bot]

@Git-Noob123 minor edits. Can you also run pre-commit run --all-files to fix the formatting

ekzhu avatar Oct 02 '24 22:10 ekzhu

Thanks! I just added the fix and run precommit, should be good now

Git-Noob123 avatar Oct 04 '24 16:10 Git-Noob123

Hi @Git-Noob123 - I approved yesterday but the base branch moved on again - I can't update yours since it's a fork. If you bring it up to date we can merge.

rysweet avatar Oct 18 '24 18:10 rysweet

@Git-Noob123 - this is close - just need you to resolve the conflicts - can you give it a try?

rysweet avatar Nov 21 '24 18:11 rysweet

Hey sorry I completely forgot about this, looks like the forked branch is so behind that the pr now has like 850 commits after I click sync branch. What do we do in this case?

Git-Noob123 avatar Nov 26 '24 20:11 Git-Noob123

Hey sorry I completely forgot about this, looks like the forked branch is so behind that the pr now has like 850 commits after I click sync branch. What do we do in this case?

Hi, You would need to pull from this remote branch, fix conflicts and push again. Typical if there are no conflicts, just hitting Update Branch runs CI tests again and if passed, reviewers will reviewer.

MohMaz avatar Nov 27 '24 01:11 MohMaz

This PR looks stale and the massive diff indicates there is some issue. If you'd be interested in porting your sample to 0.4, that would be interesting!

jackgerrits avatar Feb 25 '25 20:02 jackgerrits