public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-apt] release-file: improve invalid file-reference handling
Date: Thu,  4 Aug 2022 11:43:50 +0200	[thread overview]
Message-ID: <20220804094350.3262432-1-f.gruenbichler@proxmox.com> (raw)

if we encounter a file reference pointing to a component that is not
contained in the componenents list, we can just ignore it as unknown.
only treat parsing errors for references pointing to known components as
actual errors.

this currently triggers with (In)Release files for debian-updates and
debian-security, which reference (empty) files for a "non-free-firmware"
component that is not listed in the `Components` field of the release
file.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/deb822/release_file.rs | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/deb822/release_file.rs b/src/deb822/release_file.rs
index ee805bb..6068238 100644
--- a/src/deb822/release_file.rs
+++ b/src/deb822/release_file.rs
@@ -389,11 +389,16 @@ impl TryFrom<ReleaseFileRaw> for ReleaseFile {
             let (component, file_type) = components
                 .iter()
                 .find_map(|component| {
-                    FileReferenceType::parse(component, &file)
-                        .ok()
-                        .map(|file_type| (component.clone(), file_type))
+                    if !file.starts_with(&format!("{component}/")) {
+                        return None;
+                    }
+
+                    Some(
+                        FileReferenceType::parse(component, &file)
+                            .map(|file_type| (component.clone(), file_type)),
+                    )
                 })
-                .ok_or_else(|| format_err!("failed to parse file reference '{file}'"))?;
+                .unwrap_or_else(|| Ok(("UNKNOWN".to_string(), FileReferenceType::Unknown)))?;
 
             Ok((
                 FileReference {
-- 
2.30.2





             reply	other threads:[~2022-08-04  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  9:43 Fabian Grünbichler [this message]
2022-08-05  7:35 ` [pbs-devel] applied: " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220804094350.3262432-1-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal