Esempio n. 1
0
 def test_parse_cli_good_params(self):
     args = ['sdir=.', 'tdir=test', 'good_param=good_val2']
     parser = CLIParser(args, check_assertions=True)
     parser.add_param('good_param', {'good_val1', 'good_val2'})
     parser.parse_cli()
     oracle = {'sdir': '.', 'tdir': 'test', 'lang': Languages.PYTHON, 'framework': Frameworks.UNITTEST, 'good_param': 'good_val2'}
     for key in oracle:
         self.assertEqual(parser.get_parameter(key).get_value(), oracle[key])
Esempio n. 2
0
 def test_parse_cli_multiple_good_params(self):
     args = ['sdir=.', 'tdir=test', 'good_param1=val1', 'good_param2=val3']
     parser = CLIParser(args, check_assertions=True)
     parser.add_param('good_param1', {'val1', 'val2'})
     parser.add_param('good_param2', {'val3', 'val4'})
     parser.parse_cli()
     param_oracle = {'sdir': '.', 'tdir': 'test', 'lang': Languages.PYTHON, 'good_param1': 'val1', 'good_param2': 'val3'}
     for key in param_oracle:
         self.assertEqual(parser.get_parameter(key).get_value(), param_oracle[key])
Esempio n. 3
0
 def test_parse_cli_one_good_flag(self):
     args = ['sdir=.', 'tdir=test', '-g']
     parser = CLIParser(args, check_assertions=True)
     parser.add_flag('-g', None)
     parser.parse_cli()
     param_oracle = {'sdir': '.', 'tdir': 'test', 'lang': Languages.PYTHON, 'framework': Frameworks.UNITTEST}
     flag_oracle = {'-h': False, '-g': True, '-s': False, '-t': False}
     for key in param_oracle:
         self.assertEqual(parser.get_parameter(key).get_value(), param_oracle[key])
     for key in flag_oracle:
         self.assertEqual(parser.get_flag(key).get_value(), flag_oracle[key])
Esempio n. 4
0
        exit(0)

    # check if the user requested to run in silent/suppressed mode
    silent_mode = cli_parser.get_flag('-s').get_value()

    # initialize the settings module and set the silent mode
    settings.init()
    settings.set_silent(silent_mode)

    # print a warning that Bandit output may look different when printed
    if not silent_mode:
        Log.INFO(
            'Running with silent mode turned OFF. Please note this may cause some output to lose formatting and/or coloring.\n'
        )

    repo_name = cli_parser.get_parameter('repo').get_value()
    repo_path = os.path.abspath(__file__ + f'/../../repos/{repo_name}')
    if not os.path.exists(repo_path):
        Log.ERROR(
            f'Repo "{repo_name}" not found. Please create the appropriate directories in CRACKn/repos.'
        )
        exit(1)
    if not os.path.exists(repo_path + '/src') or not os.path.exists(repo_path +
                                                                    '/test'):
        Log.ERROR(
            f'Repo "{repo_name}" found but is missing required subdirectories. Please ensure "{repo_name}/src" and "{repo_name}/test" exist.'
        )
        exit(1)

    simulators = []
    source_files = set()