bandit/examples/hardcoded-passwords.py
Eric Brown 87c8b70e7b Refactor check_example to be clearer on error
Currently the check_example in test_functional computes sums and
on error tells the developer the difference in sums, which is
confusing and error prone.

It also leads to false positives where sums may be correct, but
the exact number of MEDIUM, HIGH, etc is different. This was the
case for two tests: test_xml and test_secret_config_option.

The general_hardcoded_password test was also broken for py35
because it was assuming function args are ast.Name not ast.arg.
But surprisingly the tests passed because of a syntax error in
the example.

Change-Id: Icd06fb7ca27a8a01d6442f199775d474d436371b
2017-02-23 19:01:46 -08:00

25 lines
474 B
Python

def someFunction(user, password="Admin"):
print("Hi " + user)
def someFunction2(password):
if password == "root":
print("OK, logged in")
def noMatch(password):
if password == '':
print("No password!")
def NoMatch2(password):
if password == "ajklawejrkl42348swfgkg":
print("Nice password!")
def doLogin(password="blerg"):
pass
def NoMatch3(a, b):
pass
doLogin(password="blerg")
password = "blerg"
d["password"] = "blerg"