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

31 lines
837 B
Python

def get_cert():
return "<CERT>"
def get_password():
return "password"
def write_cert(filename):
cert = get_cert()
with open(filename, "w") as file:
file.write(cert) # OK
lines = [cert + "\n"]
file.writelines(lines) # OK
def write_password(filename):
password = get_password() # $ Source
with open(filename, "w") as file:
file.write(password) # $ Alert # NOT OK
lines = [password + "\n"]
file.writelines(lines) # $ Alert # NOT OK
def FPs():
# just like for cleartext-logging see that file for more elaborate tests
#
# this part is just to make sure the two queries are in line with what is considered
# sensitive information.
with open(filename, "w") as file:
# Harmless UUIDs
x = generate_uuid4()
file.write(x) # OK