https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6210

           Summary: Support timestamp and modulo (%) in conditionals, e.g.
                     if (time < 1253806618)
           Product: Spamassassin
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Rules
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Please allow if() to deal with time, date, and time of day, and add the modulo
(%) operator to the acceptable arithmetic operators.  This is specifically
useful for rulesets that need to expire, like my bug 6114.

(from the perldoc for Mail::SpamAssassin::Conf)
> The conditional accepts a limited subset of perl for security --
> just enough to perform basic arithmetic comparisons.  The following
> input is accepted:
>
> numbers, whitespace, arithmetic operations and grouping
>       ( ) - + * / _ . , < = > ! ~ 0-9 whitespace
> version
> plugin(Name::Of::Plugin)

(Uh, note that it doesn't mention || and && are acceptable...)

I just want to add one arithmetic operator and three simple variables to that. 
Modulo and the first variable are trivial because they already exists in perl. 
The others should be all-but trivial.  Formatted like the perldoc:

time
    The UNIX time, seconds since 1970-01-01 00:00:00 UTC
date
    The date in the form CCYYMMDDhhmm.ss (local time),
    so 200901021533.04 is 2009 January 2 3:33:04 PM.
weektime
    Seconds since Sunday 00:00:00 (local time), H*3600+M*60+S,
    so 223021 = Tuesday at 13:57:01 (1:57:01p).
    You can get the time of day (in seconds) with (weektime % 86400).
    You can get the day of week with ( (weektime - weektime % 86400) / 86400).


Examples:

  if (time < 1257698474)  # before 45 days from now (`date -d '45 days' +%s`)
    ...
  endif
  # or by the math; y2k + 10y + 3 leap-days = 2010/1/1 00:00:00 UTC
  if (time < (946684800+((365*10+3)*24*60*60)) )
    ...
  endif
  if (date < 201001010000) # before 2010-01-01 00:00:00 EDT
    ....
  endif
  # work week check ( is sunday or is saturday or is before 8a or is after 6p )
  if (weektime < 86400 || weektime > 86400 * 6 
      || weektime % 86400 < 28800 || 64800 < weektime % 86400)
    ...
  endif

-- 
Configure bugmail: 
https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to