-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
gh-149473: Emit audit event on calling os.environ.clear() #149768
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Calling ``os.environ.clear()`` now emits ``os._clearenv`` auditing event. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The event is only emitted if we use the C implementation right? Otherwise
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If import os, sys
os.environ.clear()
os.environ['key1'] = 'value1'
os.environ['key2'] = 'value2'
def hook(*args):
print("audit:", args)
sys.addaudithook(hook)
os.environ.clear()Output with Output without
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be explicitly documented actually. With the new docs, I think people could expect
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the PR to add a paragraph explaining exactly which audit events are emitted by |
||
| Patch by Victor Stinner. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.