* [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save
@ 2023-06-29 14:14 Dominik Csapak
2023-06-29 14:14 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo Dominik Csapak
2023-06-30 6:33 ` [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2023-06-29 14:14 UTC (permalink / raw)
To: pmg-devel
and warn only when it's an invalid regex on execution, because users may
have previously had such rules. Otherwise, pmg-smtp-filter will restart
every time it encounters such a rule.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/PMG/RuleDB/WhoRegex.pm | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/PMG/RuleDB/WhoRegex.pm b/src/PMG/RuleDB/WhoRegex.pm
index 5c13604..1db6418 100644
--- a/src/PMG/RuleDB/WhoRegex.pm
+++ b/src/PMG/RuleDB/WhoRegex.pm
@@ -60,6 +60,11 @@ sub save {
defined($self->{address}) || die "undefined address: ERROR";
my $adr = $self->{address};
+
+ # test regex for validity
+ eval { "" =~ /^$adr$/i; };
+ die "invalid regex: $@\n" if $@;
+
$adr =~ s/\\/\\\\/g;
$adr = encode('UTF-8', $adr);
@@ -100,7 +105,12 @@ sub who_match {
my $t = $self->address;
- return $addr =~ m/^$t$/i;
+ my $res = '';
+ eval {
+ $res = $addr =~ m/^$t$/i;
+ };
+ warn "invalid regex: $@\n" if $@;
+ return $res;
}
sub address {
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo
2023-06-29 14:14 [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
@ 2023-06-29 14:14 ` Dominik Csapak
2023-06-30 6:33 ` [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2023-06-29 14:14 UTC (permalink / raw)
To: pmg-devel
by adding the missing closing parenthesis
Fixes: 9972a7c ("postgresql compat: cast result from EXTRACT to INTEGER")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/PMG/Statistic.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PMG/Statistic.pm b/src/PMG/Statistic.pm
index 950dbc2..e0dea5e 100644
--- a/src/PMG/Statistic.pm
+++ b/src/PMG/Statistic.pm
@@ -342,7 +342,7 @@ sub update_stats_virusinfo {
my $sql = '';
push @values, "Count = Count + $ref->{count}" if $ref->{count};
- push @values, "MTime = EXTRACT(EPOCH FROM now()::INTEGER)";
+ push @values, "MTime = EXTRACT(EPOCH FROM now())::INTEGER)";
if (scalar (@values)) {
$sql .= "UPDATE VirusInfo SET ";
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save
2023-06-29 14:14 [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
2023-06-29 14:14 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo Dominik Csapak
@ 2023-06-30 6:33 ` Dominik Csapak
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2023-06-30 6:33 UTC (permalink / raw)
To: pmg-devel
please disregard these two patches, the first one is missing
the remaining instances where we match with a regex, and
the second one is wrong, as the closing bracket at the
end is also wrong
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-30 6:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29 14:14 [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
2023-06-29 14:14 ` [pmg-devel] [PATCH pmg-api 2/2] statistics: fix update virusinfo Dominik Csapak
2023-06-30 6:33 ` [pmg-devel] [PATCH pmg-api 1/2] fix #4811: who regex: test validity on save Dominik Csapak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox