mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
practracker: add a --regen-overbroad option to remove overbroad exceptions.
Closes ticket 32372.
This commit is contained in:
@@ -29,6 +29,8 @@ class ProblemVault(object):
|
||||
def __init__(self, exception_fname=None):
|
||||
# Exception dictionary: { problem.key() : Problem object }
|
||||
self.exceptions = {}
|
||||
# Exception list: list of Problem objects, in the order added.
|
||||
self.exception_list = []
|
||||
# Exception dictionary: maps key to the problem it was used to
|
||||
# suppress.
|
||||
self.used_exception_for = {}
|
||||
@@ -63,6 +65,7 @@ class ProblemVault(object):
|
||||
sys.exit(1)
|
||||
|
||||
self.exceptions[problem.key()] = problem
|
||||
self.exception_list.append(problem)
|
||||
#print "Registering exception: %s" % problem
|
||||
|
||||
def register_problem(self, problem):
|
||||
@@ -98,6 +101,24 @@ class ProblemVault(object):
|
||||
if p is None or e.is_worse_than(p):
|
||||
yield (e, p)
|
||||
|
||||
def list_exceptions_without_overbroad(self):
|
||||
"""Return an iterator of new problems, such that overbroad
|
||||
exceptions are replaced with minimally broad versions, or removed.
|
||||
"""
|
||||
for e in self.exception_list:
|
||||
p = self.used_exception_for.get(e.key())
|
||||
if p is None:
|
||||
# This exception wasn't needed at all.
|
||||
continue
|
||||
if e.is_worse_than(p):
|
||||
# The exception is worse than the problem we found.
|
||||
# Yield the problem as the new exception value.
|
||||
yield p
|
||||
else:
|
||||
# The problem is as bad as the exception, or worse.
|
||||
# Yield the exception.
|
||||
yield e
|
||||
|
||||
def set_tolerances(self, fns):
|
||||
"""Adjust the tolerances for the exceptions in this vault. Takes
|
||||
a map of problem type to a function that adjusts the permitted
|
||||
|
||||
Reference in New Issue
Block a user