public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-apt] release-file: improve invalid file-reference handling
@ 2022-08-04  9:43 Fabian Grünbichler
  2022-08-05  7:35 ` [pbs-devel] applied: " Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Grünbichler @ 2022-08-04  9:43 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-05  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04  9:43 [pbs-devel] [PATCH proxmox-apt] release-file: improve invalid file-reference handling Fabian Grünbichler
2022-08-05  7:35 ` [pbs-devel] applied: " Wolfgang Bumiller

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