def testReturnsCombinedResultsFromTwoExtractors(self): """Test it returns combined results from two extractors.""" detector = core.Detector(extractors=[ TestExtractor(multiplier=2), TestExtractor(multiplier=3) ]) self.assertEqual(detector.Detect("a b"), set(["b_0", "b_1", "b_2"]))
def testPostProcessorMayReturnMultipleProcessedPaths(self): """Test the post processor may return multiple processed paths.""" detector = core.Detector( extractors=[TestExtractor(multiplier=2)], post_processors=[TestPostProcessor("_bar", count=2)]) self.assertEqual( detector.Detect("a b"), set(["b_0_bar", "b_1_bar", "b_0_bar_bar", "b_1_bar_bar"]))
def testAppliesMultiplePostProcessorsToExtractedPaths(self): """Test it applies mutliple post processors to extracted paths.""" detector = core.Detector( extractors=[TestExtractor(multiplier=2)], post_processors=[TestPostProcessor("_foo"), TestPostProcessor("_bar")]) self.assertEqual( detector.Detect("a b"), set(["b_0_foo_bar", "b_1_foo_bar"]))
def CreateWindowsRegistryExecutablePathsDetector(vars_map=None): """Creates Windows paths detector. Commandline strings can be space separated and contain options. e.g. C:\\Program Files\\ACME Corporation\\wiz.exe /quiet /blah See here for microsoft doco on commandline parsing: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx Args: vars_map: Environment variables mapping. Default is None. Returns: A detector (core.Detector instance). """ return core.Detector( extractors=[RunDllExtractor(), ExecutableExtractor()], post_processors=[EnvVarsPostProcessor(vars_map or {})],)
def testReturnsWhatSingleExtractorReturns(self): """Test it returns what a single extractor returns.""" detector = core.Detector(extractors=[TestExtractor()]) self.assertEqual(detector.Detect("a b"), set(["b_0"]))