-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Python 3.9 #650
Changes from all commits
d369741
306bcbf
58a3e36
f3d10bd
fd4076b
de4fc86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,15 @@ def hardcoded_password_string(context): | |
if isinstance(targ, ast.Name) and RE_CANDIDATES.search(targ.id): | ||
return _report(node.s) | ||
|
||
elif (isinstance(node._bandit_parent, ast.Subscript) | ||
and RE_CANDIDATES.search(node.s)): | ||
# Py39+: looks for "dict[candidate]='some_string'" | ||
# subscript -> index -> string | ||
assign = node._bandit_parent._bandit_parent | ||
if isinstance(assign, ast.Assign) and isinstance(assign.value, | ||
ast.Str): | ||
return _report(assign.value.s) | ||
|
||
elif (isinstance(node._bandit_parent, ast.Index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could add a comment that this next block can be removed when Python 3.8 is dropped |
||
and RE_CANDIDATES.search(node.s)): | ||
# looks for "dict[candidate]='some_string'" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,58 @@ | ||
# Possible hardcoded password: 'Admin' | ||
# Severity: Low Confidence: Medium | ||
def someFunction(user, password="Admin"): | ||
print("Hi " + user) | ||
|
||
def someFunction2(password): | ||
# Possible hardcoded password: 'root' | ||
# Severity: Low Confidence: Medium | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the way comments are done here is inconsistent (indent & before/after) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it matters that much, so long as there's context around what each one is attempting to warn about. With the exception of the first function here, functions without a real body (e.g., using |
||
if password == "root": | ||
print("OK, logged in") | ||
|
||
def noMatch(password): | ||
# Possible hardcoded password: '' | ||
# Severity: Low Confidence: Medium | ||
if password == '': | ||
print("No password!") | ||
|
||
def NoMatch2(password): | ||
# Possible hardcoded password: 'ajklawejrkl42348swfgkg' | ||
# Severity: Low Confidence: Medium | ||
if password == "ajklawejrkl42348swfgkg": | ||
print("Nice password!") | ||
|
||
# Possible hardcoded password: 'blerg' | ||
# Severity: Low Confidence: Medium | ||
def doLogin(password="blerg"): | ||
pass | ||
|
||
def NoMatch3(a, b): | ||
pass | ||
|
||
# Possible hardcoded password: 'blerg' | ||
# Severity: Low Confidence: Medium | ||
doLogin(password="blerg") | ||
|
||
# Possible hardcoded password: 'blerg' | ||
# Severity: Low Confidence: Medium | ||
password = "blerg" | ||
|
||
# Possible hardcoded password: 'blerg' | ||
# Severity: Low Confidence: Medium | ||
d["password"] = "blerg" | ||
|
||
# Possible hardcoded password: 'secret' | ||
# Severity: Low Confidence: Medium | ||
EMAIL_PASSWORD = "secret" | ||
|
||
# Possible hardcoded password: 'emails_secret' | ||
# Severity: Low Confidence: Medium | ||
email_pwd = 'emails_secret' | ||
|
||
# Possible hardcoded password: 'd6s$f9g!j8mg7hw?n&2' | ||
# Severity: Low Confidence: Medium | ||
my_secret_password_for_email = 'd6s$f9g!j8mg7hw?n&2' | ||
|
||
# Possible hardcoded password: '1234' | ||
# Severity: Low Confidence: Medium | ||
passphrase='1234' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally tangential, I think Doug Hellman wrote a plugin to sphinx (or maybe it was Jeff Forcier) that puts the execution output of something in the docs where desired. We could take advantage of that here maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it, though