-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-135543: emit sys.remote_exec
audit event when sys.remote_exec
has been called
#135544
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?
Conversation
…c has been called Signed-off-by: Manjusaka <me@manjusaka.me>
Lib/test/test_sys.py
Outdated
@@ -2118,6 +2118,7 @@ def audit_hook(event, arg): | |||
self.assertEqual(returncode, 0) | |||
self.assertIn(b"Remote script executed successfully!", stdout) | |||
self.assertIn(b"Audit event: remote_debugger_script, arg: ", stdout) | |||
self.assertIn(b"Audit event: remote_exec, arg: ", stdout) |
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.
This is wrong this string will not appear in the remote it will appear in the process that executed remote_exec
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.
My bad,fixed
Signed-off-by: Manjusaka <me@manjusaka.me>
def audit_hook(event, arg): | ||
if event == "remote_exec": | ||
nonlocal remote_exec_event_triggered | ||
remote_exec_event_triggered = True |
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.
It would be better to save arg
, not just True
. And compare arg
with the expected value.
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.
SGTM
if event == "remote_exec": | ||
nonlocal remote_exec_event_triggered | ||
remote_exec_event_triggered = True | ||
sys.addaudithook(audit_hook) |
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.
It's not possible to clear audit hooks, so move this test to test_audit which is designed for that: see Lib/test/audit-tests.py
.
@@ -1933,6 +1933,11 @@ always available. Unless explicitly noted otherwise, all variables are read-only | |||
interpreter is pre-release (alpha, beta, or release candidate) then the | |||
local and remote interpreters must be the same exact version. | |||
|
|||
.. audit-event:: remove_exec pid script_path |
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.
.. audit-event:: remove_exec pid script_path | |
.. audit-event:: remote_exec pid script_path |
.. audit-event:: remove_exec pid script_path | ||
|
||
When the code is executed in the remote process, an :ref:`auditing event <auditing>` | ||
``remove_exec`` is raised with the *pid* and the path to the script file. |
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.
``remove_exec`` is raised with the *pid* and the path to the script file. | |
``remote_exec`` is raised with the *pid* and the path to the script file. |
emit ``sys.remote_exec`` audit event when ``sys.remote_exec`` has been | ||
called |
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.
emit ``sys.remote_exec`` audit event when ``sys.remote_exec`` has been | |
called | |
Emit ``remote_exec`` audit event when :func:`sys.remote_exec` is called. |
Fix #135543
sys.remote_exec()
#135543📚 Documentation preview 📚: https://cpython-previews--135544.org.readthedocs.build/