ffe64b7706
Bandit 0.13.2 was released and this is the min version in requirements.txt. This version updated the tests that are available. Using the latest default bandit.yaml from bandit 0.13.2: 1) Copied the latest bandit config stuff from the top of the file. 2) Copied the list of all tests from the sample "All" profile: - Left the new tests that we weren't running disabled, these will be enabled if they work, marked with TODO. - Removed crypto_random and shell_injection since these are not in the list of all tests anymore. - Some tests weren't enabled before, I added the reason why. 3) After the profiles comes the configuration for each test, which bandit 0.13.2 has changed. Changes to the configs for the blacklist_calls and blacklist_imports tests caused some new lines to be flagged, so these will be handled separately. Follow-on commits will handle enabling the new tests or providing a reason why the test is not run and updating the test configs to the latest from 0.13.2. [1] http://git.openstack.org/cgit/openstack/bandit/tree/bandit/config/bandit.yaml?id=0.13.2 Change-Id: Iee28a669853497d3fa79d6d89ecbb2d8b755e78e
187 lines
6.1 KiB
YAML
187 lines
6.1 KiB
YAML
# optional: after how many files to update progress
|
|
#show_progress_every: 100
|
|
|
|
# optional: plugins directory name
|
|
#plugins_dir: 'plugins'
|
|
|
|
# optional: plugins discovery name pattern
|
|
plugin_name_pattern: '*.py'
|
|
|
|
# optional: terminal escape sequences to display colors
|
|
#output_colors:
|
|
# DEFAULT: '\033[0m'
|
|
# HEADER: '\033[95m'
|
|
# LOW: '\033[94m'
|
|
# MEDIUM: '\033[93m'
|
|
# HIGH: '\033[91m'
|
|
|
|
# optional: log format string
|
|
#log_format: "[%(module)s]\t%(levelname)s\t%(message)s"
|
|
|
|
# globs of files which should be analyzed
|
|
include:
|
|
- '*.py'
|
|
- '*.pyw'
|
|
|
|
# a list of strings, which if found in the path will cause files to be excluded
|
|
# for example /tests/ - to remove all all files in tests directory
|
|
exclude_dirs:
|
|
- '/tests/'
|
|
|
|
profiles:
|
|
gate:
|
|
include:
|
|
|
|
# TODO:
|
|
# - any_other_function_with_shell_equals_true
|
|
|
|
# TODO:
|
|
# - assert_used
|
|
|
|
- blacklist_calls
|
|
|
|
# TODO:
|
|
# - blacklist_import_func
|
|
|
|
- blacklist_imports
|
|
- exec_used
|
|
|
|
# TODO:
|
|
# - execute_with_run_as_root_equals_true
|
|
|
|
# TODO:
|
|
# - hardcoded_bind_all_interfaces
|
|
|
|
# Not working because wordlist/default-passwords file not bundled,
|
|
# see https://bugs.launchpad.net/bandit/+bug/1451575 :
|
|
# - hardcoded_password
|
|
|
|
# Not used because it's prone to false positives:
|
|
# - hardcoded_sql_expressions
|
|
|
|
# TODO:
|
|
# - hardcoded_tmp_directory
|
|
|
|
# TODO:
|
|
# - jinja2_autoescape_false
|
|
|
|
- linux_commands_wildcard_injection
|
|
|
|
# TODO:
|
|
# - paramiko_calls
|
|
|
|
# TODO:
|
|
# - password_config_option_not_marked_secret
|
|
|
|
- request_with_no_cert_validation
|
|
- set_bad_file_permissions
|
|
- subprocess_popen_with_shell_equals_true
|
|
|
|
# TODO:
|
|
# - subprocess_without_shell_equals_true
|
|
|
|
# TODO:
|
|
# - start_process_with_a_shell
|
|
|
|
# TODO:
|
|
# - start_process_with_no_shell
|
|
|
|
# TODO:
|
|
# - start_process_with_partial_path
|
|
|
|
- ssl_with_bad_defaults
|
|
- ssl_with_bad_version
|
|
- ssl_with_no_version
|
|
|
|
# TODO:
|
|
# - try_except_pass
|
|
|
|
# TODO:
|
|
# - use_of_mako_templates
|
|
|
|
blacklist_calls:
|
|
bad_name_sets:
|
|
- pickle:
|
|
qualnames: [pickle.loads, pickle.load, pickle.Unpickler,
|
|
cPickle.loads, cPickle.load, cPickle.Unpickler]
|
|
message: "Pickle library appears to be in use, possible security issue."
|
|
- marshal:
|
|
qualnames: [marshal.load, marshal.loads]
|
|
message: "Deserialization with the marshal module is possibly dangerous."
|
|
- md5:
|
|
qualnames: [hashlib.md5, Crypto.Hash.MD2.new, Crypto.Hash.MD4.new, Crypto.Hash.MD5.new, cryptography.hazmat.primitives.hashes.MD5]
|
|
message: "Use of insecure MD2, MD4, or MD5 hash function."
|
|
- mktemp_q:
|
|
qualnames: [tempfile.mktemp]
|
|
message: "Use of insecure and deprecated function (mktemp)."
|
|
- eval:
|
|
qualnames: [eval]
|
|
message: "Use of possibly insecure function - consider using safer ast.literal_eval."
|
|
- mark_safe:
|
|
names: [mark_safe]
|
|
message: "Use of mark_safe() may expose cross-site scripting vulnerabilities and should be reviewed."
|
|
- httpsconnection:
|
|
qualnames: [httplib.HTTPSConnection]
|
|
message: "Use of HTTPSConnection does not provide security, see https://wiki.openstack.org/wiki/OSSN/OSSN-0033"
|
|
- yaml_load:
|
|
qualnames: [yaml.load]
|
|
message: "Use of unsafe yaml load. Allows instantiation of arbitrary objects. Consider yaml.safe_load()."
|
|
- urllib_urlopen:
|
|
qualnames: [urllib.urlopen, urllib.urlretrieve, urllib.URLopener, urllib.FancyURLopener, urllib2.urlopen, urllib2.Request]
|
|
message: "Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected."
|
|
|
|
shell_injection:
|
|
# Start a process using the subprocess module, or one of its wrappers.
|
|
subprocess: [subprocess.Popen, subprocess.call, subprocess.check_call,
|
|
subprocess.check_output, utils.execute, utils.execute_with_timeout]
|
|
# Start a process with a function vulnerable to shell injection.
|
|
shell: [os.system, os.popen, os.popen2, os.popen3, os.popen4,
|
|
popen2.popen2, popen2.popen3, popen2.popen4, popen2.Popen3,
|
|
popen2.Popen4, commands.getoutput, commands.getstatusoutput]
|
|
# Start a process with a function that is not vulnerable to shell injection.
|
|
no_shell: [os.execl, os.execle, os.execlp, os.execlpe, os.execv,os.execve,
|
|
os.execvp, os.execvpe, os.spawnl, os.spawnle, os.spawnlp,
|
|
os.spawnlpe, os.spawnv, os.spawnve, os.spawnvp, os.spawnvpe,
|
|
os.startfile]
|
|
|
|
blacklist_imports:
|
|
bad_import_sets:
|
|
- telnet:
|
|
imports: [telnetlib]
|
|
level: ERROR
|
|
message: "Telnet is considered insecure. Use SSH or some other encrypted protocol."
|
|
|
|
hardcoded_tmp_directory:
|
|
tmp_dirs: ['/tmp', '/var/tmp', '/dev/shm']
|
|
|
|
hardcoded_password:
|
|
# Support for full path, relative path and special "%(site_data_dir)s"
|
|
# substitution (/usr/{local}/share)
|
|
word_list: "%(site_data_dir)s/wordlist/default-passwords"
|
|
|
|
ssl_with_bad_version:
|
|
bad_protocol_versions:
|
|
- 'PROTOCOL_SSLv2'
|
|
- 'SSLv2_METHOD'
|
|
- 'SSLv23_METHOD'
|
|
- 'PROTOCOL_SSLv3' # strict option
|
|
- 'PROTOCOL_TLSv1' # strict option
|
|
- 'SSLv3_METHOD' # strict option
|
|
- 'TLSv1_METHOD' # strict option
|
|
|
|
password_config_option_not_marked_secret:
|
|
function_names:
|
|
- oslo.config.cfg.StrOpt
|
|
- oslo_config.cfg.StrOpt
|
|
|
|
execute_with_run_as_root_equals_true:
|
|
function_names:
|
|
- ceilometer.utils.execute
|
|
- cinder.utils.execute
|
|
- neutron.agent.linux.utils.execute
|
|
- nova.utils.execute
|
|
- nova.utils.trycmd
|
|
|
|
try_except_pass:
|
|
check_typed_exception: True
|