def test_normalize(self): value = '123content-location*23' self.failUnless(Clue.normalize(value) == 'content_location_23') value = 'content/location' self.failUnless(Clue.normalize(value) == 'content_location') value = '*content/location123' self.failUnless(Clue.normalize(value) == '_content_location123')
def testNormalize(self): value = '123content-location*23' self.assertTrue(Clue.normalize(value) == 'content_location_23') value = 'content/location' self.assertTrue(Clue.normalize(value) == 'content_location') value = '*content/location123' self.assertTrue(Clue.normalize(value) == '_content_location123')
def testNormalize(self): value = "123content-location*23" self.failUnless(Clue.normalize(value) == "content_location_23") value = "content/location" self.failUnless(Clue.normalize(value) == "content_location") value = "*content/location123" self.failUnless(Clue.normalize(value) == "_content_location123")
def testNormalize(self): value = '123content-location*23' self.failUnless(Clue.normalize(value) == 'content_location_23') value = 'content/location' self.failUnless(Clue.normalize(value) == 'content_location') value = '*content/location123' self.failUnless(Clue.normalize(value) == '_content_location123')
def ignore_changing_fields(clues): """Tries to detect and ignore MIME fields with ever changing content. Some servers might include fields varying with time, randomly, etc. Those fields are likely to alter the clue's digest and interfer with L{analyze}, producing many false positives and making the scan useless. This function detects those fields and recalculates each clue's digest so they can be safely analyzed again. @param clues: Sequence of clues. @type clues: C{list} or C{tuple} """ from Halberd.clues.Clue import Clue different = diff_fields(clues) # First alter Clue to be able to cope with the varying fields. ignored = [] for field in different: method = "_get_" + Clue.normalize(field) if not hasattr(Clue, method): logger.debug("ignoring %s", field) ignored.append(method) setattr(Clue, method, lambda s, f: None) for clue in clues: Clue.parse(clue, clue.headers) for method in ignored: # We want to leave the Clue class as before because a MIME field # causing trouble for the current scan might be the source of precious # information for another scan. delattr(Clue, method) return clues
def ignore_changing_fields(clues): """Tries to detect and ignore MIME fields with ever changing content. Some servers might include fields varying with time, randomly, etc. Those fields are likely to alter the clue's digest and interfer with L{analyze}, producing many false positives and making the scan useless. This function detects those fields and recalculates each clue's digest so they can be safely analyzed again. @param clues: Sequence of clues. @type clues: C{list} or C{tuple} """ from Halberd.clues.Clue import Clue different = diff_fields(clues) # First alter Clue to be able to cope with the varying fields. ignored = [] for field in different: method = '_get_' + Clue.normalize(field) if not hasattr(Clue, method): logger.debug('ignoring %s', field) ignored.append(method) setattr(Clue, method, lambda s, f: None) for clue in clues: Clue.parse(clue, clue.headers) for method in ignored: # We want to leave the Clue class as before because a MIME field # causing trouble for the current scan might be the source of precious # information for another scan. delattr(Clue, method) return clues