Skip to content
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

Remove blacklist call check for os.tempnam #859

Merged
merged 1 commit into from
Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions bandit/blacklists/calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@
B325: tempnam
--------------

The check for this call has been removed.

Use of os.tempnam() and os.tmpnam() is vulnerable to symlink attacks. Consider
using tmpfile() instead.

Expand Down Expand Up @@ -684,15 +686,7 @@ def gen_blacklist():

# skipped B324 (used in bandit/plugins/hashlib_new_insecure_functions.py)

sets.append(
utils.build_conf_dict(
"tempnam",
"B325",
issue.Cwe.INSECURE_TEMP_FILE,
["os.tempnam", "os.tmpnam"],
"Use of os.tempnam() and os.tmpnam() is vulnerable to symlink "
"attacks. Consider using tmpfile() instead.",
)
)
# skipped B325 as the check for a call to os.tempnam and os.tmpnam have
# been removed

return {"Call": sets}
13 changes: 0 additions & 13 deletions examples/tempnam.py

This file was deleted.

8 changes: 0 additions & 8 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,6 @@ def test_mktemp(self):
}
self.check_example("mktemp.py", expect)

def test_tempnam(self):
"""Test for `os.tempnam` / `os.tmpnam`."""
expect = {
"SEVERITY": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 6, "HIGH": 0},
"CONFIDENCE": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 0, "HIGH": 6},
}
self.check_example("tempnam.py", expect)

def test_nonsense(self):
"""Test that a syntactically invalid module is skipped."""
self.run_example("nonsense.py")
Expand Down