I ran bandit on my project and got the following issue for security, I don't understand why this is an issue and what are the solutions for the issues.
--------------------------------------------------
>> Issue: [B108:hardcoded_tmp_directory] Probable insecure usage of temp file/directory.
Severity: Medium Confidence: Medium
Location: abc/xyz/xxx.py:176
More Info: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html
175 def get_pickle_file_path(self):
176 return os.path.join("/tmp/aaa", "folder_" + self.name)
177
--------------------------------------------------
>> Issue: [B102:exec_used] Use of exec detected.
Severity: Medium Confidence: High
Location: abc/models.py:1405
More Info: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
1404 loc = {'result': []}
1405 exec(self.code, globals(), loc)
1406 return loc['result']
After searching for the solution of B108 issue. I found this where /tmp
is replaced by tempfile.gettempdir()
function, but the value of the both is same. Is tempfile.gettempdir()
the solution for /tmp
?