Skip to content

Commit 058affc

Browse files
bpo-41192: Add documentation of undocumented audit events (GH-22832)
(cherry picked from commit 3f7e990)
1 parent d84e411 commit 058affc

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

Doc/c-api/file.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ the :mod:`io` APIs instead.
8282
8383
This function is safe to call before :c:func:`Py_Initialize`.
8484
85+
.. audit-event:: setopencodehook "" c.PyFile_SetOpenCodeHook
86+
8587
.. versionadded:: 3.8
8688
8789

Doc/library/audit_events.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,29 @@ information on handling these events.
1919
specific documentation for actual events raised.
2020

2121
.. audit-event-table::
22+
23+
The following events are raised internally and do not correspond to any
24+
public API of CPython:
25+
26+
+--------------------------+-------------------------------------------+
27+
| Audit event | Arguments |
28+
+==========================+===========================================+
29+
| _winapi.CreateFile | ``file_name``, ``desired_access``, |
30+
| | ``share_mode``, ``creation_disposition``, |
31+
| | ``flags_and_attributes`` |
32+
+--------------------------+-------------------------------------------+
33+
| _winapi.CreateJunction | ``src_path``, ``dst_path`` |
34+
+--------------------------+-------------------------------------------+
35+
| _winapi.CreateNamedPipe | ``name``, ``open_mode``, ``pipe_mode`` |
36+
+--------------------------+-------------------------------------------+
37+
| _winapi.CreatePipe | |
38+
+--------------------------+-------------------------------------------+
39+
| _winapi.CreateProcess | ``application_name``, ``command_line``, |
40+
| | ``current_directory`` |
41+
+--------------------------+-------------------------------------------+
42+
| _winapi.OpenProcess | ``process_id``, ``desired_access`` |
43+
+--------------------------+-------------------------------------------+
44+
| _winapi.TerminateProcess | ``handle``, ``exit_code`` |
45+
+--------------------------+-------------------------------------------+
46+
| ctypes.PyObj_FromPtr | ``obj`` |
47+
+--------------------------+-------------------------------------------+

Doc/library/functions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ are always available. They are listed here in alphabetical order.
767767

768768
.. impl-detail:: This is the address of the object in memory.
769769

770+
.. audit-event:: builtins.id id id
771+
770772

771773
.. function:: input([prompt])
772774

Doc/library/types.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ Standard names are defined for the following types:
109109
The type of user-defined functions and functions created by
110110
:keyword:`lambda` expressions.
111111

112+
.. audit-event:: function.__new__ code types.FunctionType
113+
114+
The audit event only occurs for direct instantiation of function objects,
115+
and is not raised for normal compilation.
116+
112117

113118
.. data:: GeneratorType
114119

@@ -138,10 +143,11 @@ Standard names are defined for the following types:
138143

139144
The type for code objects such as returned by :func:`compile`.
140145

141-
.. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags CodeType
146+
.. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType
142147

143148
Note that the audited arguments may not match the names or positions
144-
required by the initializer.
149+
required by the initializer. The audit event only occurs for direct
150+
instantiation of code objects, and is not raised for normal compilation.
145151

146152
.. method:: CodeType.replace(**kwargs)
147153

Doc/reference/datamodel.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,12 @@ access (use of, assignment to, or deletion of ``x.name``) for class instances.
15351535
result of implicit invocation via language syntax or built-in functions.
15361536
See :ref:`special-lookup`.
15371537

1538+
.. audit-event:: object.__getattr__ obj,name object.__getattribute__
1539+
1540+
For certain sensitive attribute accesses, raises an
1541+
:ref:`auditing event <auditing>` ``object.__getattr__`` with arguments
1542+
``obj`` and ``name``.
1543+
15381544

15391545
.. method:: object.__setattr__(self, name, value)
15401546

@@ -1546,12 +1552,24 @@ access (use of, assignment to, or deletion of ``x.name``) for class instances.
15461552
call the base class method with the same name, for example,
15471553
``object.__setattr__(self, name, value)``.
15481554

1555+
.. audit-event:: object.__setattr__ obj,name,value object.__setattr__
1556+
1557+
For certain sensitive attribute assignments, raises an
1558+
:ref:`auditing event <auditing>` ``object.__setattr__`` with arguments
1559+
``obj``, ``name``, ``value``.
1560+
15491561

15501562
.. method:: object.__delattr__(self, name)
15511563

15521564
Like :meth:`__setattr__` but for attribute deletion instead of assignment. This
15531565
should only be implemented if ``del obj.name`` is meaningful for the object.
15541566

1567+
.. audit-event:: object.__delattr__ obj,name object.__delattr__
1568+
1569+
For certain sensitive attribute deletions, raises an
1570+
:ref:`auditing event <auditing>` ``object.__delattr__`` with arguments
1571+
``obj`` and ``name``.
1572+
15551573

15561574
.. method:: object.__dir__(self)
15571575

0 commit comments

Comments
 (0)