diff options
author | Michael Weiser <michael.weiser@gmx.de> | 2019-04-18 08:57:15 +0000 |
---|---|---|
committer | Michael Weiser <michael.weiser@gmx.de> | 2019-04-25 12:20:20 +0000 |
commit | 77d2ff1348a6f1ade05b54b297fc771abd0e14cd (patch) | |
tree | e7914e3ad89f36b65aced27f53132244f894832f /peekaboo/exceptions.py | |
parent | e6c44a8ca3c2216904731e4d889e53473691c0dc (diff) |
Validate ruleset config
Validate the ruleset configuration at startup to inform the user about
misconfiguration and exit immediately instead of giving warnings during
seemingly normal operation. This also gives us a chance to pre-compile
regexes for more efficient matching later on.
We give rules a new method get_config() which retrieves their
configuration. This is called for each rule by new method the
validate_config() of the ruleset engine to catch errors. This way the
layout and extent of configuration is still completely governed by the
rule and we can interview it about its happiness with what's provided in
the configuration file.
As an incidental cleanup, merge class PeekabooRulesetConfig into
PeekabooRulesetParser because there's nothing left where it could and
would need to help the rules with an abstraction of the config file.
Also switch class PeekabooConfig to be a subclass of
PeekabooConfigParser so it can (potentially) benefit from the list
parsing code there. By moving the special log level and by-default-type
getters over there as well we end up with nicely generic config classes
that can benefit directly from improvements in the configparser module.
Update the test suite to test and use this new functionality.
Incidentally, remove the convoluted inheritance-based config testing
layout in favour of creating subclasses of the config classes.
Diffstat (limited to 'peekaboo/exceptions.py')
-rw-r--r-- | peekaboo/exceptions.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/peekaboo/exceptions.py b/peekaboo/exceptions.py index 1ee8097..298cd21 100644 --- a/peekaboo/exceptions.py +++ b/peekaboo/exceptions.py @@ -40,6 +40,11 @@ class PeekabooRulesetException(PeekabooException): pass +class PeekabooRulesetConfigError(PeekabooException): + """ Used to signal that a rule is unhappy with its configuration. """ + pass + + class PeekabooAnalysisDeferred(PeekabooRulesetException): """ Analysis has been deferred to a later point in time. |