diff options
author | Ryan Hileman <lunixbochs@gmail.com> | 2021-04-29 23:15:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 23:15:55 (GMT) |
commit | 9a2c2a9ec3140b6c54c9ef9d994311f114128ee3 (patch) | |
tree | fbc87fa594de1ab3f8151dc74786add7eac3e1b3 /Objects | |
parent | 088a15c49d99ecb4c3bef93f8f40dd513c6cae3b (diff) | |
download | cpython-9a2c2a9ec3140b6c54c9ef9d994311f114128ee3.zip cpython-9a2c2a9ec3140b6c54c9ef9d994311f114128ee3.tar.gz cpython-9a2c2a9ec3140b6c54c9ef9d994311f114128ee3.tar.bz2 |
bpo-42800: add audit hooks for f_code and tb_frame (GH-24182)
Accessing the following attributes will now fire PEP 578 style audit hooks as ("object.__getattr__", obj, name):
* PyTracebackObject: tb_frame
* PyFrameObject: f_code
* PyGenObject: gi_code, gi_frame
* PyCoroObject: cr_code, cr_frame
* PyAsyncGenObject: ag_code, ag_frame
Add an AUDIT_READ attribute flag aliased to READ_RESTRICTED.
Update obsolete flag documentation.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 2 | ||||
-rw-r--r-- | Objects/frameobject.c | 2 | ||||
-rw-r--r-- | Objects/genobject.c | 12 |
3 files changed, 8 insertions, 8 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 35fbffd..297b852 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -164,7 +164,7 @@ member_get(PyMemberDescrObject *descr, PyObject *obj, PyObject *type) if (descr_check((PyDescrObject *)descr, obj, &res)) return res; - if (descr->d_member->flags & READ_RESTRICTED) { + if (descr->d_member->flags & AUDIT_READ) { if (PySys_Audit("object.__getattr__", "Os", obj ? obj : Py_None, descr->d_member->name) < 0) { return NULL; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 5920ed8..5c33746 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -13,7 +13,7 @@ static PyMemberDef frame_memberlist[] = { {"f_back", T_OBJECT, OFF(f_back), READONLY}, - {"f_code", T_OBJECT, OFF(f_code), READONLY}, + {"f_code", T_OBJECT, OFF(f_code), READONLY|AUDIT_READ}, {"f_builtins", T_OBJECT, OFF(f_builtins), READONLY}, {"f_globals", T_OBJECT, OFF(f_globals), READONLY}, {"f_trace_lines", T_BOOL, OFF(f_trace_lines), 0}, diff --git a/Objects/genobject.c b/Objects/genobject.c index b02a558..a922d45 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -741,8 +741,8 @@ static PyGetSetDef gen_getsetlist[] = { }; static PyMemberDef gen_memberlist[] = { - {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY}, - {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY}, + {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), READONLY|AUDIT_READ}, + {"gi_code", T_OBJECT, offsetof(PyGenObject, gi_code), READONLY|AUDIT_READ}, {NULL} /* Sentinel */ }; @@ -978,8 +978,8 @@ static PyGetSetDef coro_getsetlist[] = { }; static PyMemberDef coro_memberlist[] = { - {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY}, - {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY}, + {"cr_frame", T_OBJECT, offsetof(PyCoroObject, cr_frame), READONLY|AUDIT_READ}, + {"cr_code", T_OBJECT, offsetof(PyCoroObject, cr_code), READONLY|AUDIT_READ}, {"cr_origin", T_OBJECT, offsetof(PyCoroObject, cr_origin), READONLY}, {NULL} /* Sentinel */ }; @@ -1360,10 +1360,10 @@ static PyGetSetDef async_gen_getsetlist[] = { }; static PyMemberDef async_gen_memberlist[] = { - {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY}, + {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY|AUDIT_READ}, {"ag_running", T_BOOL, offsetof(PyAsyncGenObject, ag_running_async), READONLY}, - {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), READONLY}, + {"ag_code", T_OBJECT, offsetof(PyAsyncGenObject, ag_code), READONLY|AUDIT_READ}, {NULL} /* Sentinel */ }; |