pySCG: Python Hardening Guide: we should mention and explain audit hooks, sys.audit and sys.addaudithook
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Documentation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- documentation, security
Piste de recherche
Read the logging rules in the CWE-532 guideline linked from the issue and review PEP 578 alongside the example01.py example in the issue. Decide whether audit hooks should be explained in a log related rule and whether they help separate internal and user facing logs; done means the relevant guidance clearly explains the recommendation and its limits.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
sys.audit allows to create events that can be used during audits as demonstrated in example01.py
aduprocess.py Popen class has a line that creates an audit event looking like this:
sys.audit("subprocess.Popen", executable, args, cwd, env)
These type of events are Python internal and not handled unless there is a listener/hook.
The example01.py creates the audit method that is attached/hooked into the Python audit system via sys.addaudtihook(audit).
The audit method allows any sort of handling of an event including suppressing functions.
example01.py:
"""
Playing around with audit hooks
https://www.youtube.com/watch?v=sIibadhDqaw
https://github.com/ossf/wg-best-practices-os-developers/issues
"""
import sys
from typing import Any
import subprocess
def audit(event: str, args: tuple[Any, ...]) -> None:
""" foo """
# if "subprocess" in event:
print("audit::", event, args)
sys.addaudithook(audit)
# compile(None, '<stdin>')
# print('hi')
subprocess.Popen(('echo', 'hi'))
import email
In our rules about logging we recommend to prevent sensitive information such as system internals to end-users. We recommend to split logging between internal and user facing. The use facing has sensitive system-internal information removed. Audit logs should be mentioned as part of one of the log related rules. We will need to investigate if the use of audit logs can be recommended to solve the issue around splitting back-ed, front-end.
related guideline:
PEP 578 – Python Runtime Audit Hooks
CWE-532: Insertion of Sensitive Information into Log File
- Langage dominant
- Python
- Étoiles
- 2
- Forks
- 2
- Merge moyen
- 11 min
- PR mergées (30 j)
- 2
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ossf/python-secure-coding-guide
-
pyscg-0051 should use a context managerPeut-être pris @s19110 l’a pris il y a 8 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
ossf/python-secure-coding-guide#1 · 4 commentaires · 1 personne assignée ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 65/100
ossf/python-secure-coding-guide#29 · 1 commentaire ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
Toutes les issues de ossf/python-secure-coding-guide
Issues similaires
-
README Quick Start query command fails, and doctor points to a missing Prerequisites sectionOuvertedocumentation type/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
add entry to blockOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Peut-être pris @0z5a l’a pris aujourd’hui. Ouverteneeds-triage
Difficulté 2/5 Une demi-journée Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 2 jours
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2xPeut-être pris @Shizoqua l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
microsoft/TokenEconomizer#221 ·
Les mainteneurs répondent en général sous 1 jour
-
plot_graph crashes when a mesh node has no m2m edgePeut-être pris @tygvi l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
mllam/neural-lam#883 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours