Пример #1
0
    def testGetSignatureScanner(self):
        """Tests the _GetSignatureScanner function."""
        specification_store = specification.FormatSpecificationStore()

        signature_scanner = analyzer.Analyzer._GetSignatureScanner(
            specification_store)
        self.assertIsNotNone(signature_scanner)
Пример #2
0
  def _GetSpecificationStore(cls, format_category):
    """Retrieves the specification store for specified format category.

    Args:
      format_category (str): format category.

    Returns:
      tuple[FormatSpecificationStore,list[AnalyserHelper]]: a format
          specification store and remaining analyzer helpers that do not have
          a format specification.
    """
    specification_store = specification.FormatSpecificationStore()
    remainder_list = []

    for analyzer_helper in iter(cls._analyzer_helpers.values()):
      if not analyzer_helper.IsEnabled():
        continue

      if format_category in analyzer_helper.format_categories:
        format_specification = analyzer_helper.GetFormatSpecification()

        if format_specification is not None:
          specification_store.AddSpecification(format_specification)
        else:
          remainder_list.append(analyzer_helper)

    return specification_store, remainder_list
Пример #3
0
    def testAddSpecification(self):
        """Function to test the AddSpecification function."""
        store = specification.FormatSpecificationStore()

        format_regf = specification.FormatSpecification(u'REGF')
        format_regf.AddNewSignature(b'regf', offset=0)

        format_esedb = specification.FormatSpecification(u'ESEDB')
        format_esedb.AddNewSignature(b'\xef\xcd\xab\x89', offset=4)

        store.AddSpecification(format_regf)
        store.AddSpecification(format_esedb)

        with self.assertRaises(KeyError):
            store.AddSpecification(format_regf)
Пример #4
0
    def _GetSpecificationStore(cls, format_category):
        """Retrieves the specification store for specified format category.

    Args:
      format_category: the format category.

    Returns:
      A tuple of a format specification store (instance of
      FormatSpecificationStore) and the list of remaining analyzer helpers
      that do not have a format specification.
    """
        specification_store = specification.FormatSpecificationStore()
        remainder_list = []

        for analyzer_helper in cls._analyzer_helpers.itervalues():
            if format_category in analyzer_helper.format_categories:
                format_specification = analyzer_helper.GetFormatSpecification()

                if format_specification is not None:
                    specification_store.AddSpecification(format_specification)
                else:
                    remainder_list.append(analyzer_helper)

        return specification_store, remainder_list