-
-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
156 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
------ | ||
custom | ||
------ | ||
|
||
.. automodule:: bandit.formatters.custom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import paramiko | ||
|
||
# this is not safe | ||
paramiko.exec_command('something; really; unsafe') | ||
|
||
# this is safe | ||
paramiko.connect('somehost') | ||
client = paramiko.client.SSHClient() | ||
|
||
# this is not safe | ||
SSHClient.invoke_shell('something; bad; here\n') | ||
client.exec_command('something; really; unsafe') | ||
|
||
# this is safe | ||
client.connect('somehost') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sqlalchemy | ||
|
||
# bad | ||
query = "SELECT * FROM foo WHERE id = '%s'" % identifier | ||
query = "INSERT INTO foo VALUES ('a', 'b', '%s')" % value | ||
query = "DELETE FROM foo WHERE id = '%s'" % identifier | ||
query = "UPDATE foo SET value = 'b' WHERE id = '%s'" % identifier | ||
query = """WITH cte AS (SELECT x FROM foo) | ||
SELECT x FROM cte WHERE x = '%s'""" % identifier | ||
# bad alternate forms | ||
query = "SELECT * FROM foo WHERE id = '" + identifier + "'" | ||
query = "SELECT * FROM foo WHERE id = '{}'".format(identifier) | ||
query = f"SELECT * FROM foo WHERE id = {tmp}" | ||
|
||
# bad | ||
cur.execute("SELECT * FROM foo WHERE id = '%s'" % identifier) | ||
cur.execute("INSERT INTO foo VALUES ('a', 'b', '%s')" % value) | ||
cur.execute("DELETE FROM foo WHERE id = '%s'" % identifier) | ||
cur.execute("UPDATE foo SET value = 'b' WHERE id = '%s'" % identifier) | ||
# bad alternate forms | ||
cur.execute("SELECT * FROM foo WHERE id = '" + identifier + "'") | ||
cur.execute("SELECT * FROM foo WHERE id = '{}'".format(identifier)) | ||
cur.execute(f"SELECT * FROM foo WHERE id {tmp}") | ||
|
||
# good | ||
cur.execute("SELECT * FROM foo WHERE id = '%s'", identifier) | ||
cur.execute("INSERT INTO foo VALUES ('a', 'b', '%s')", value) | ||
cur.execute("DELETE FROM foo WHERE id = '%s'", identifier) | ||
cur.execute("UPDATE foo SET value = 'b' WHERE id = '%s'", identifier) | ||
|
||
# bug: https://bugs.launchpad.net/bandit/+bug/1479625 | ||
def a(): | ||
def b(): | ||
pass | ||
return b | ||
|
||
a()("SELECT %s FROM foo" % val) | ||
|
||
# real world false positives | ||
choices=[('server_list', _("Select from active instances"))] | ||
print("delete from the cache as the first argument") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters