Files
codeql/python/ql/test/query-tests/Security/CWE-732-WeakFilePermissions/test.py
2026-06-15 16:15:17 +01:00

17 lines
406 B
Python

import os
import stat
file = 'semmle/important_secrets'
os.chmod(file, 0o7) # $ Alert # BAD
os.chmod(file, 0o77) # $ Alert # BAD
os.chmod(file, 0o777) # $ Alert # BAD
os.chmod(file, 0o600) # GOOD
os.chmod(file, 0o550) # $ Alert # BAD
os.chmod(file, stat.S_IRWXU) # GOOD
os.chmod(file, stat.S_IWGRP) # BAD
os.chmod(file, 400) # $ Alert # BAD -- Decimal format.
os.open(file, 'w', 0o704) # $ Alert # BAD