Skip to content

Commit 3f7e990

Browse files
authored
bpo-41192: Add documentation of undocumented audit events (GH-21308)
1 parent 1d34699 commit 3f7e990

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

Doc/c-api/file.rst

+2
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

+26
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

+2
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ are always available. They are listed here in alphabetical order.
783783

784784
.. impl-detail:: This is the address of the object in memory.
785785

786+
.. audit-event:: builtins.id id id
787+
786788

787789
.. function:: input([prompt])
788790

Doc/library/types.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ Standard names are defined for the following types:
116116
The type of user-defined functions and functions created by
117117
:keyword:`lambda` expressions.
118118

119+
.. audit-event:: function.__new__ code types.FunctionType
120+
121+
The audit event only occurs for direct instantiation of function objects,
122+
and is not raised for normal compilation.
123+
119124

120125
.. data:: GeneratorType
121126

@@ -145,10 +150,11 @@ Standard names are defined for the following types:
145150

146151
The type for code objects such as returned by :func:`compile`.
147152

148-
.. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags CodeType
153+
.. audit-event:: code.__new__ code,filename,name,argcount,posonlyargcount,kwonlyargcount,nlocals,stacksize,flags types.CodeType
149154

150155
Note that the audited arguments may not match the names or positions
151-
required by the initializer.
156+
required by the initializer. The audit event only occurs for direct
157+
instantiation of code objects, and is not raised for normal compilation.
152158

153159
.. method:: CodeType.replace(**kwargs)
154160

Doc/reference/datamodel.rst

+18
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,12 @@ access (use of, assignment to, or deletion of ``x.name``) for class instances.
15401540
result of implicit invocation via language syntax or built-in functions.
15411541
See :ref:`special-lookup`.
15421542

1543+
.. audit-event:: object.__getattr__ obj,name object.__getattribute__
1544+
1545+
For certain sensitive attribute accesses, raises an
1546+
:ref:`auditing event <auditing>` ``object.__getattr__`` with arguments
1547+
``obj`` and ``name``.
1548+
15431549

15441550
.. method:: object.__setattr__(self, name, value)
15451551

@@ -1551,12 +1557,24 @@ access (use of, assignment to, or deletion of ``x.name``) for class instances.
15511557
call the base class method with the same name, for example,
15521558
``object.__setattr__(self, name, value)``.
15531559

1560+
.. audit-event:: object.__setattr__ obj,name,value object.__setattr__
1561+
1562+
For certain sensitive attribute assignments, raises an
1563+
:ref:`auditing event <auditing>` ``object.__setattr__`` with arguments
1564+
``obj``, ``name``, ``value``.
1565+
15541566

15551567
.. method:: object.__delattr__(self, name)
15561568

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

1572+
.. audit-event:: object.__delattr__ obj,name object.__delattr__
1573+
1574+
For certain sensitive attribute deletions, raises an
1575+
:ref:`auditing event <auditing>` ``object.__delattr__`` with arguments
1576+
``obj`` and ``name``.
1577+
15601578

15611579
.. method:: object.__dir__(self)
15621580

0 commit comments

Comments
 (0)