https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8559

            Bug ID: 8559
           Summary: /o freezes per-call regexes for the process lifetime
           Product: Spamassassin
           Version: 4.0.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: spamassassin
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: Undefined

Hi,

Several places interpolate a value that changes per call, per rule or per
Mail::SpamAssassin object into a match compiled with /o. Perl compiles such a
pattern on the first execution of the match op and keeps it until the process
exits, so every later call matches against the first value. r1933226 (bug
#8388) removed /o from the code generated by Check.pm for the same reason; this
series fixes the remaining instances found by reviewing every /o site in lib/.

The attached series is against trunk r1940367, one commit per context. Each
adds a regression test that fails before the change and passes after it. All
defects are also present in 4.0.2 and 4.0.3-rc3 (except NeuralNetwork as is new
in 4.0.3).

1. FreeMail: do not freeze per-rule regexes with /o.
check_freemail_from/header/body() with a regex argument match every rule
against the regex of whichever such rule ran first, already within a single
message check. The stock ruleset only uses '\d@' so it is unaffected, but a
local rule with another regex hits or misses according to the stock one. The
freemail_import_welcomelist_auth lookup only ever tries the first
welcomelist_auth entry in hash order.

2. Message::Node: do not freeze the delete_header() pattern with /o. check()
calls delete_header('X-Spam-.*') to drop sender-supplied X-Spam-* headers
before rules run. When the first delete_header() call of the process comes from
metadata extraction instead (after learn(), a report, or in a spamd child whose
first request is a TELL), the frozen pattern is X-Spam-Relays-Trusted, and
later checks no longer strip X-Spam-Status, X-Spam-Flag, etc.: header rules and
plugins see the values supplied by the sender. Not affected: the
X-Spam-Relays-* values seen by rules (get() serves the computed strings) and
the rewritten message (rewrite_mail strips X-Spam-* from the pristine headers
itself).

3. Conf: do not freeze the trim_rules() regexp with /o. Every object created
after the first in a process with only_these_rules (mass-check --rules) keeps
the first object's rule selection.

4. PerMsgStatus: do not freeze the text URI regex with /o. The schemeless URI
regex embeds the object's valid TLD list. A later object with another list
misses its schemeless URIs, and rejects those it does extract. The regex is a
lone qr//, so dropping /o is free.

5. BayesStore: do not freeze the dump_db_toks() regexp with /o. DBM, SDBM and
BDB: a second dump_bayes_db() in the same process filters with the first
caller's regexp. sa-learn is unaffected (one dump per process).

6. NeuralNetwork: do not freeze the dump regexp with /o. Same defect as 5.

7. DnsResolver: do not freeze the likely matching query lookup with /o. Logging
only: in a long-lived process every "a likely matching query" line names the
pending queries of the first unmatched reply's DNS id.

8. FreeMail: document the default freemail_domains list. Not a /o fix, included
because it touches the same plugin; happy to move it to its own bug. Adds a
DEFAULT DOMAINS section: the list ships in 20_freemail_domains.cf and
20_freemail_mailcom_domains.cf via sa-update, freemail_domains in local.cf adds
to it, and the plugin disables itself when no entry is defined.

Remaining /o sites are left as is: they interpolate process-wide constants
(IP_PRIVATE, IP_ADDRESS, ARITH_EXPRESSION_LEXER, the Bayes magic regex,
fq_hostname, $^O checks), except the /op and /gop in the code generated by
OneLineBodyRuleType. That code only runs for rules compiled with sa-compile,
which excludes capture rules, and I found no reachable failure there. It is
still inconsistent with r1933226 and could be aligned separately.

Tested against Perl 5.44.0 on Linux. The full t/ suite passes with the series
applied. handler_pdf.t tests 13-16 fail without CryptX (Crypt::Mode::CBC),
identically on unpatched trunk, and pass on both once it is installed.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to