-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtest.py
More file actions
76 lines (53 loc) · 1.9 KB
/
test.py
File metadata and controls
76 lines (53 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import logging
import sys
LOGGER = logging.getLogger("LOGGER")
def get_logger():
return LOGGER
def get_password():
return "<PASSWORD>"
def get_cert():
return "<CERT>"
def log_password():
password = get_password()
logging.info("logging.info Password '%s'", password) # NOT OK
LOGGER.log(logging.INFO, "LOGGER.log Password '%s'", password) # NOT OK
logging.root.info("logging.root.info Password '%s'", password) # NOT OK
# name of logger variable should not matter
foo = LOGGER
foo.info("foo.info Password '%s'", password) # NOT OK
# return value from function
get_logger().info("get_logger().info Password '%s'", password) # NOT OK
def log_cert():
logging.debug("Cert=%s", get_cert()) # NOT OK
def print_password():
print(get_password()) # NOT OK
sys.stdout.write(get_password()) # NOT OK
sys.stderr.write(get_password()) # NOT OK
def FPs(account, account_id):
# we assume that any account parameter is sensitive (id/username)
# https://github.com/github/codeql/issues/6363
print(account) # OK
# https://github.com/github/codeql/issues/6927
arn = f"arn:aws:iam::{account_id}:role/cfripper-access"
logging.info(f"Preparing to assume role: {arn}") # OK
# Harmless UUIDs
# https://github.com/github/codeql/issues/6726
# https://github.com/github/codeql/issues/7497
x = generate_uuid4()
print(x) # OK
# username not considered sensitive
# https://github.com/github/codeql/issues/7116
logging.error("Misc Exception. User %s: %s", request.user.username)
# dictionary taint-flow corss-talk
# https://github.com/github/codeql/issues/6380
import settings
config = {
"sleep_timer": 5,
"password": settings.password
}
print(config["sleep_timer"]) # OK
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
log_password()
log_cert()
print_password()