Пример #1
0
    def _analyze_command(self, args, components):
        """
        Implements the "analyze" command to analyze a list of hashes.

        Args:
            args (Namespace): The command-line arguments as parsed.
            components (dict): Dict containing all the component references as returned from _init_components.

        """
        if args.file is not None:
            hash_group = cli_input.read_csv(args.file)
        else:
            hash_group = cli_input.read_json(args.list)

        before = len(hash_group)
        log.info("Checking for previously executed binaries")
        hash_group = components["deduplicate"].deduplicate(hash_group)
        if before > len(hash_group):
            log.info(f"Found {before - len(hash_group)} binaries that have already been analyzed")

        metadata_list = components["ingest"].fetch_metadata(hash_group)
        self._process_metadata(components, metadata_list)
Пример #2
0
 def test_csv_exceptions(self, error, input_file_path: str, msg: str):
     """Unit testing read_csv function exceptions"""
     with pytest.raises(error) as context:
         csv_file = open(attach_path(input_file_path))
         read_csv(csv_file)
     assert str(context.value) == msg
Пример #3
0
 def test_csv(self, input_file_path: str, answer_file_path: List[Dict]):
     """Unit testing read_csv function"""
     with open(attach_path(answer_file_path), 'r') as answer_file:
         csv_file = open(attach_path(input_file_path))
         assert str(read_csv(csv_file)) == answer_file.read().strip()