Merge pull request #1054 from crytic/issue-1052

add check for default config file
pull/1069/head
Feist Josselin 3 years ago committed by GitHub
commit f7b55bc3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      slither/__main__.py
  2. 9
      slither/utils/command_line.py

@ -462,7 +462,7 @@ def parse_args(detector_classes, printer_classes): # pylint: disable=too-many-s
help="Provide a config file (default: slither.config.json)", help="Provide a config file (default: slither.config.json)",
action="store", action="store",
dest="config_file", dest="config_file",
default="slither.config.json", default=None,
) )
group_misc.add_argument( group_misc.add_argument(

@ -52,6 +52,15 @@ defaults_flag_in_config = {
def read_config_file(args): def read_config_file(args):
# No config file was provided as an argument
if args.config_file is None:
# Check wether the default config file is present
if os.path.exists("slither.config.json"):
# The default file exists, use it
args.config_file = "slither.config.json"
else:
return
if os.path.isfile(args.config_file): if os.path.isfile(args.config_file):
try: try:
with open(args.config_file, encoding="utf8") as f: with open(args.config_file, encoding="utf8") as f:

Loading…
Cancel
Save