From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id B2F6D1FF187 for ; Mon, 22 Sep 2025 10:04:45 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3A3911401C; Mon, 22 Sep 2025 10:05:13 +0200 (CEST) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Mon, 22 Sep 2025 10:05:00 +0200 Message-ID: <20250922080509.737332-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922080509.737332-1-d.csapak@proxmox.com> References: <20250922080509.737332-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.974 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_MAILER 2 Automated Mailer Tag Left in Email RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pmg-devel] [PATCH pmg-api 1/1] api: quarantine: include positive and negative spam score sum in list X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pmg-devel-bounces@lists.proxmox.com Sender: "pmg-devel" This can be useful information, so to show it in the web ui, we have to return it in the api here. Signed-off-by: Dominik Csapak --- src/PMG/API2/Quarantine.pm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm index 3887a74..2464ee7 100644 --- a/src/PMG/API2/Quarantine.pm +++ b/src/PMG/API2/Quarantine.pm @@ -91,6 +91,29 @@ sub decode_spaminfo { return $res; } +# parses and returns the sum of the positive and negative spam rule matches, so +# we can show them individually +sub get_spamscores { my ($info) = @_; + + return (0, 0) if !defined($info); + + my $positive = 0; + my $negative = 0; + + foreach my $test (split(',', $info)) { + my ($name, $score) = split(':', $test); + + $score = $score + 0; + if ($score > 0) { + $positive += $score; + } else { + $negative += $score; + } + } + + return ($positive, $negative); +} + my $extract_email = sub { my $data = shift; @@ -149,6 +172,9 @@ my $parse_header_info = sub { $res->{id} = 'C' . $ref->{cid} . 'R' . $ref->{rid} . 'T' . $ref->{ticketid}; $res->{time} = $ref->{time}; $res->{bytes} = $ref->{bytes}; + my ($positive, $negative) = get_spamscores($ref->{info}); + $res->{'score-positive'} = $positive; + $res->{'score-negative'} = $negative; my $qtype = $ref->{qtype}; @@ -880,6 +906,14 @@ __PACKAGE__->register_method({ description => "Spam score.", type => 'number', }, + 'score-positive' => { + description => "Sum of positive spam score matches.", + type => 'number', + }, + 'score-negative' => { + description => "Sum of negative spam score matches.", + type => 'number', + }, }, }, }, -- 2.47.3 _______________________________________________ pmg-devel mailing list pmg-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel