Skip to content

Instantly share code, notes, and snippets.

@meisterluk
meisterluk / zipfile_extractall_secure.py
Created October 5, 2022 01:22
zipfile's extractall method with a path check that the target folder is the prefix after utilizing os.path.normpath
import os.path
import zipfile
# tested with python 3.8.10
def secure_zipfile_extractall(zip_filedesc, target_directory):
"""Copy all files recorded in zipfile `zip_filedesc`
to the directory `target_directory`, but prevent malicious filepaths
like `../../../etc/hosts` by using os.path.normpath
"""
@meisterluk
meisterluk / ansible-runner-broken.txt
Created January 22, 2023 10:11
I put many efforts into getting ansible-runner working. It just does not work.
The status file:
import ansible # tested with 6.7.0
import ansible_runner # tested with 2.3.1
[…]
r = ansible_runner.run(
private_data_dir="ansible/web",