Repository: PyCQA/bandit (python)

Issue:
Unable to find qualified name
### Describe the bug

Running bandit on a single source file in the current directory does not seem to work. It produces a warning: 

```
WARNING Unable to find qualified name for module
```

I am not sure what the warning is trying to achieve?

### Reproduction steps

```bash
1. $ touch dummy.py
2. $ bandit dummy.py  # produces the warning
3. $ bandit ./dummy.py  # does not produce the warning
```


### Expected behavior

No warning should be produced.

### Bandit version

1.7.4 (Default)

### Python version

3.8

### Additional context

_No response_

Pull request description:
Prepend ./ for files specified as CLI args
The get_module_qualname_from_path() function called by the node visistor expects that all files are explicitly named with a "head" and "tail" which are path delimiters to denote where the file is within a python project.

However, if someone uses the command line and simply asks bandit to scan dummy.py in the current working directory, it will be missing the explicit "./" prefix in order for get_module_qualname_from_path to run and determine the module fully qualified name from the path.

So this fix simply prepends a dot and delimiter to explicitly denote a file in the current working directory as given from the CLI.

Fixes #907

Patch:
diff --git a/bandit/blacklists/calls.py b/bandit/blacklists/calls.py
index 9e7ec74..d69f5dd 100644
--- a/bandit/blacklists/calls.py
+++ b/bandit/blacklists/calls.py
@@ -198,6 +198,7 @@ https://docs.python.org/library/secrets.html
 |      |                     | - random.choices                   |           |
 |      |                     | - random.uniform                   |           |
 |      |                     | - random.triangular                |           |
+|      |                     | - random.randbytes                 |           |
 +------+---------------------+------------------------------------+-----------+
 
 B312: telnetlib
@@ -523,6 +524,7 @@ def gen_blacklist():
                 "random.choices",
                 "random.uniform",
                 "random.triangular",
+                "random.randbytes",
             ],
             "Standard pseudo-random generators are not suitable for "
             "security/cryptographic purposes.",
diff --git a/bandit/core/manager.py b/bandit/core/manager.py
index 57e0e85..ffc13ca 100644
--- a/bandit/core/manager.py
+++ b/bandit/core/manager.py
@@ -249,6 +249,8 @@ class BanditManager:
                     excluded_path_globs,
                     enforce_glob=False,
                 ):
+                    if fname != "-":
+                        fname = os.path.join(".", fname)
                     files_list.add(fname)
                 else:
                     excluded_files.add(fname)
diff --git a/examples/random_module.py b/examples/random_module.py
index 2bf80d0..224f251 100644
--- a/examples/random_module.py
+++ b/examples/random_module.py
@@ -10,6 +10,7 @@ bad = random.choice()
 bad = random.choices()
 bad = random.uniform()
 bad = random.triangular()
+bad = random.randbytes()
 
 good = os.urandom()
 good = random.SystemRandom()


Test patch:
diff --git a/tests/functional/test_functional.py b/tests/functional/test_functional.py
index 8469943..a230dc3 100644
--- a/tests/functional/test_functional.py
+++ b/tests/functional/test_functional.py
@@ -396,8 +396,8 @@ class FunctionalTests(testtools.TestCase):
     def test_random_module(self):
         """Test for the `random` module."""
         expect = {
-            "SEVERITY": {"UNDEFINED": 0, "LOW": 8, "MEDIUM": 0, "HIGH": 0},
-            "CONFIDENCE": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 0, "HIGH": 8},
+            "SEVERITY": {"UNDEFINED": 0, "LOW": 9, "MEDIUM": 0, "HIGH": 0},
+            "CONFIDENCE": {"UNDEFINED": 0, "LOW": 0, "MEDIUM": 0, "HIGH": 9},
         }
         self.check_example("random_module.py", expect)
 
diff --git a/tests/unit/core/test_manager.py b/tests/unit/core/test_manager.py
index df815f5..5d20c56 100644
--- a/tests/unit/core/test_manager.py
+++ b/tests/unit/core/test_manager.py
@@ -289,7 +289,7 @@ class ManagerTests(testtools.TestCase):
         self.manager.discover_files(
             ["a.py", "test_a.py", "test.py"], True, excluded_paths="test_*.py"
         )
-        self.assertEqual(["a.py", "test.py"], self.manager.files_list)
+        self.assertEqual(["./a.py", "./test.py"], self.manager.files_list)
         self.assertEqual(["test_a.py"], self.manager.excluded_files)
 
     @mock.patch("os.path.isdir")
@@ -298,7 +298,7 @@ class ManagerTests(testtools.TestCase):
         with mock.patch.object(manager, "_is_file_included") as m:
             m.return_value = True
             self.manager.discover_files(["thing"], True)
-            self.assertEqual(["thing"], self.manager.files_list)
+            self.assertEqual(["./thing"], self.manager.files_list)
             self.assertEqual([], self.manager.excluded_files)
 
     def test_run_tests_keyboardinterrupt(self):