Did I find the right examples for you? yes no

All Samples(4)  |  Call(4)  |  Derive(0)  |  Import(0)
Identify and ignore changing header fields.

After initial analysis one must check that there aren't as many realservers
as obtained clues. If there were it could be a sign of something wrong
happening: each clue is different from the others due to one or more MIME
header fields which change unexpectedly.

@param clues: Raw sequence of clues.
@type clues: C{list}
(more...)

        def reanalyze(clues, analyzed, threshold):
    """Identify and ignore changing header fields.

    After initial analysis one must check that there aren't as many realservers
    as obtained clues. If there were it could be a sign of something wrong
    happening: each clue is different from the others due to one or more MIME
    header fields which change unexpectedly.

    @param clues: Raw sequence of clues.
    @type clues: C{list}

    @param analyzed: Result from the first analysis phase.
    @type analyzed: C{list}

    @param threshold: Minimum clue-to-realserver ratio in order to trigger
    field inspection.
    @type threshold: C{float}
    """
    def ratio():
        return len(analyzed) / float(len(clues))

    assert len(clues) > 0

    r = ratio()
    if r >= threshold:
        logger.debug('clue-to-realserver ratio is high (%.3f)', r)
        logger.debug('reanalyzing clues...')

        ignore_changing_fields(clues)
        analyzed = analyze(clues)

        logger.debug('clue reanalysis done.')

    # Check again to see if we solved the problem but only warn the user if
    # there's a significant amount of evidence.
    if ratio() >= threshold and len(clues) > 10:
        logger.warn(
'''The following results might be incorrect.  It could be because the remote
host keeps changing its server version string or because halberd didn't have
enough samples.''')

    return analyzed
        


src/h/a/halberd-0.2.4/Halberd/shell.py   halberd(Download)
 
        self.task.analyzed = analysis.analyze(self.task.clues)
        self.task.analyzed = analysis.reanalyze(self.task.clues,
                                self.task.analyzed, self.task.ratio_threshold)
 

src/h/a/halberd-HEAD/Halberd/shell.py   halberd(Download)
 
        self.task.analyzed = analysis.analyze(self.task.clues)
        self.task.analyzed = analysis.reanalyze(self.task.clues,
                                self.task.analyzed, self.task.ratio_threshold)
 

src/h/a/halberd-0.2.4/tests/test_clues_analysis.py   halberd(Download)
 
        analyzed = analysis.analyze(clues)
        analyzed = analysis.reanalyze(clues, analyzed, self.threshold)
        self.failUnlessEqual(len(analyzed), expected_analyzed)
 

src/h/a/halberd-HEAD/tests/test_clues_analysis.py   halberd(Download)
 
        analyzed = analysis.analyze(clues)
        analyzed = analysis.reanalyze(clues, analyzed, self.threshold)
        self.failUnlessEqual(len(analyzed), expected_analyzed)