From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pmg-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 221881FF18A
	for <inbox@lore.proxmox.com>; Fri, 21 Feb 2025 11:13:40 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 599D82CCE8;
	Fri, 21 Feb 2025 10:50:01 +0100 (CET)
Message-ID: <2dbddc2b-3976-4d48-9dc1-abd05f849f82@proxmox.com>
Date: Fri, 21 Feb 2025 10:49:59 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
To: Stoiko Ivanov <s.ivanov@proxmox.com>, pmg-devel@lists.proxmox.com
References: <20250220201309.181365-1-s.ivanov@proxmox.com>
 <20250220201309.181365-4-s.ivanov@proxmox.com>
Content-Language: en-US
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20250220201309.181365-4-s.ivanov@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.022 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
 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: Re: [pmg-devel] [PATCH pmg-api v4 3/5] pmg-smtp-filter:
 archive-detection: use header information as well
X-BeenThere: pmg-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Mail Gateway development discussion
 <pmg-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pmg-devel>, 
 <mailto:pmg-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pmg-devel/>
List-Post: <mailto:pmg-devel@lists.proxmox.com>
List-Help: <mailto:pmg-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel>, 
 <mailto:pmg-devel-request@lists.proxmox.com?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pmg-devel-bounces@lists.proxmox.com
Sender: "pmg-devel" <pmg-devel-bounces@lists.proxmox.com>

On 2/20/25 21:13, Stoiko Ivanov wrote:
> This restores the fall-back to the content-type from the header for
> detecting archives, which we want to unpack, as eagerly trying to get
> all information seems sensible in this case.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> ---
>   src/bin/pmg-smtp-filter | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/bin/pmg-smtp-filter b/src/bin/pmg-smtp-filter
> index 6061459..6c03631 100755
> --- a/src/bin/pmg-smtp-filter
> +++ b/src/bin/pmg-smtp-filter
> @@ -561,9 +561,15 @@ sub run_dequeue {
>   sub unpack_entity {
>       my ($self, $unpack, $entity, $msginfo, $queue) = @_;
>   
> -    my ($magic, $path) = $entity->@{'PMX_magic_ct', 'PMX_decoded_path'};
> +    my ($magic, $headerct, $path) = $entity->@{'PMX_magic_ct', 'PMX_header_ct', 'PMX_decoded_path'};
> +
> +    if ($path) {

while not really wrong (currently, since $path and $magic are always set or unset together)
not checking for $magic here sets us up for future bugs

we use both in the branch (independently of one another), so if some codechange in the future
would set $path but not $magic, we'd enter the branch with '$magic = undef' here unintentionally

so keeping the `if ($magic && $path)` here does not hurt us, and only makes
it clearer that both must be set for the branch to be executed..

> +	# in order to not miss information from a misdetected archive use information provided in the
> +	# header here as well
> +	if ($headerct && ($magic && $magic eq 'application/octet-stream')) {
> +	    $magic = $headerct;
> +	}
>   
> -    if ($magic && $path) {
>   	my $filename = basename ($path);
>   
>   	if (PMG::Unpack::is_archive ($magic)) {



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel