SA Bugzilla – Bug 4981
[review] urirhssub only supports A records and bitmasks, docs suggest it should support more
Last modified: 2006-08-22 22:54:17 UTC
Documentation says: urirhssub NAME_OF_RULE rhsbl_zone lookuptype subtest Specify a RHSBL-style domain lookup with a sub-test. "NAME_OF_RULE" is the name of the rule to be used, "rhsbl_zone" is the zone to look up domain names in, and "lookuptype" is the type of lookup (TXT or A). "subtest" is the sub-test to run against the returned data. The sub-test may either be an IPv4 dotted address for RHSBLs that return multiple A records, a non-negative decimal number to specify a bitmask for RHSBLs that return a single A record containing a bitmask of results, or (if none of the preceding options seem to fit) a regular expression. Example: urirhssub URIBL_RHSBL_4 rhsbl.example.org. A 127.0.0.4 urirhssub URIBL_RHSBL_8 rhsbl.example.org. A 8 However for an A record, only the bitmask form actually works. The dotted-quad and regexp forms give a warning and fail to match. The attached test email and test cf-file 'A' should show this. Note you need to remove the standard 25_uribl.cf rulefile because it also uses the multi.surbl.org zone. The source of the warning is the following line in Plugin/URIDNSBL.pm but I am not sure if that is the whole problem: uridnsbl_subs_bits |= $_ for keys %{$uridnsbl_subs}; For a TXT record, the results are confusing. I wouldn't expect the mask form or dotted-quad form to work, but the regexp form doesn't work either. The test email and the test cf-file 'TXT' will show them. DNS trace shows a TXT record is queried as expected, it's just not matched.
Created attachment 3576 [details] Test mail
Created attachment 3577 [details] rulefile for testing rhssub with A records
Created attachment 3578 [details] rulefile for testing rhssub with TXT records
Created attachment 3579 [details] test results from the A record case. 25_uribl.cf deliberately made unreadable, as it uses the same zones as the test case.
Please separate my three tests per file into six separate tests - the docs say the zones should be identical and in those files they aren't. For me, the warnings and the failure to match still happen when I run each test separately.
The patch for bug 4842 makes the warnings go away. Does it fix the rest of this bug too?
Looking over the code in URIDNSBL.pm I can see how the regexp test here will not work. urirhssub TEST_A_RE multi.surbl.org. A /\./ parses the regular expression field into a string with value '/\./' and then does the match using if ($rdatastr =~ m/${subtest}/) Am I misunderstanding the perl or is that not correctly dealing with the delimiters in the subtest field? I looked at how we do it in the main rule file, with various tests and then calling Mail::Conf::Parser->add_test and I'm hesitant to jump in with changes to URIDNSBL.pm. Can someone who is familiar with the code in Conf.pm and Parse.pm jump in and look at how it should be done here? The relevant code is in URIDNSBL.pm, where the urirhssub rule is parsed in set_config and where the match is done in complete_dnsbl_lookup.
I'd prefer to just remove the regexp test ability entirely, if possible. if it doesn't work, that's hardly a regression ;), and supporting regexp-testing requires hairy code.
I've tracked down what doesn't work with these tests once the patch for bug 4842 is in place: 1) The regexp can't work for either A or TXT subrules 2) The TXT record with this example returns a string "multi.surbl.org permanent test point" but the rule parser in URIDNSBL.pm has no provision for specifying an arbitrary string with spaces in it. I think this comes down to looking at what the RBLs want to put in the records, especially the TXT records, and decide just what functionality we want to provide for matching them. The code may be complex, but isn't it already in place for rule parsing?
As the reporter, I can certainly live without regexp tests. I fell over this problem when finding out why a third party ruleset with a dotted quad on the RHS didn't work, so it seems other people are using dotted quads.
Created attachment 3659 [details] Patch to remove regexp from POD text, remove regexp case in code, and cause lint error if subtest is not a dotted quad or a 32 bit int number Suggested patch to code and POD against 3.1 branch that removes regexp as an option and enforces in lint that subtest is either a number IP address (in dotted quad syntax) or else is a decimal integer to be used as a bit mask. Please check my regexp for correctness and especially for perl style. review for 3.1. If it's ok I'll also check it in to trunk.
+1
Committed to 3.1 revision 433916. Committed to trunk revision 433917.