Zonemaster::Config(3pm) | User Contributed Perl Documentation | Zonemaster::Config(3pm) |
Zonemaster::Config - configuration access module for Zonemaster
Zonemaster->config->no_network(1); # Forbid network traffic my $value = Zonemaster::Config->get->{key}{subkey}; # Not really recommended way to access config data
Configuration data is loaded in several stages, each one overlaying the result from the previous one (that is, the later in the list take priority over the earlier). The first stage is hardcoded into the source code and loaded while it is being compiled, to make sure that there will always be some basic information available. Later, when the configuration object is first used, the system will look for a file named config.json in each of a list of directories. If the file exists, is readable and contains proper JSON data, it will be loaded and overlaid on the current internal config. The directories are, in order from first checked to last:
perl -MFile::ShareDir=dist_dir -E 'say dist_dir( "Zonemaster" )'
The possible contents of the JSON data is described further down in this manual page.
If the given name does not lead directly to a readable file, each of the usual directories will be checked if the name is there. If the plain name isn't, the suffix ".json" will be appended and another try will be done. For example, a file $HOME/.zonemaster/Example.json may be loaded by calling this method with the string "Example".
The configuration data is stored internally in a nested hash (possibly with arrays as values in places). As of this writing, the file format used is JSON.
The interesting keys are as follows.
defaults
These are the default flag and timing values used for the resolver objects used to actually send DNS queries.
If set to a true value, network traffic is forbidden. Use when you want to be sure that any data is only taken from a preloaded cache.
This key must be a list of domain names. The domains will be assumed to be Cymru-style AS lookup zones. Normally only the first name in the list will be used, the rest are backups in case the earlier ones don't work.
By using this key, the log level of messages can be set in a much more fine-grained way than by the policy file. The intended use is to remove known erroneous results. If you, for example, know that a certain name server is recursive and for some reason should be, you can use this functionality to lower the severity of the complaint about it to a lower level than normal.
The the data under the "logfilter" key should be structured like this:
Module Tag "when" Hash with conditions "set" Level to set if all conditions match
The hash with conditions should have keys matching the attributes of the log entry that's being filtered (check the translation files to see what they are). The values for the keys should be either a single value that the attribute should be, or an array of values any one of which the attribute should be.
A complete entry might could look like this:
"SYSTEM": { "FILTER_THIS": { "when": { "count": 1, "type": ["this", "or"] }, "set": "INFO" } }
This would set the level to "INFO" for any "SYSTEM:FILTER_THIS" messages that had a "count" attribute set to 1 and a "type" attribute set to either "this" or "or".
Like the configuration data, policy data is stored in JSON format. Structurally, it's a bit less complex. All the keys on the top level, with one exception, are names of test implementation modules (without the "Zonemaster::Test::" prefix). Each of those keys hold another hash, where the keys are the tags that the module in question can emit and the values are the the severity levels that should apply to the tags. Any tags that are not found in the policy data will default to level "DEBUG".
The one exception is a top-level key "__testcases__". The value of that must be a hash where the keys are names of test cases from the test specifications, and the corresponding values are booleans specifying if the test case in question should be executed or not. Any missing test cases are treated as if they had the value "true" set. The test cases "basic00", "basic01" and "basic02" will be executed even if their values are set to "false", since part of their function is to verify that the given name can be tested at all. The values here only apply when test modules are asked to run all their tests. A test case that is set to "false" here will still run if asked for specifically.
The easiest way to create a modified policy is to copy the default one and change the relevant values.
2017-06-23 | perl v5.24.1 |