]> git.proxmox.com Git - proxmox-apt.git/commitdiff
check suites: add special check for Debian security repository
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 18 Jan 2022 12:48:22 +0000 (13:48 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 3 Feb 2022 07:57:04 +0000 (08:57 +0100)
since the suffix was changed with Debian Bullseye.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/repositories/file.rs
tests/repositories.rs
tests/sources.list.d.expected/bad-security.list [new file with mode: 0644]
tests/sources.list.d/bad-security.list [new file with mode: 0644]

index 3e975fce4ca0d7a3ae132dfdb0b499d03b050f7c..1b3ac857a9bafe64fc92b0019135d34b29fc2b90 100644 (file)
@@ -297,8 +297,8 @@ impl APTRepositoryFile {
         Ok(())
     }
 
-    /// Checks if old or unstable suites are configured and also that the
-    /// `stable` keyword is not used.
+    /// Checks if old or unstable suites are configured and that the Debian security repository
+    /// has the correct suite. Also checks that the `stable` keyword is not used.
     pub fn check_suites(&self, current_codename: DebianCodename) -> Vec<APTRepositoryInfo> {
         let mut infos = vec![];
 
@@ -307,6 +307,22 @@ impl APTRepositoryFile {
                 continue;
             }
 
+            let is_security_repo = repo.uris.iter().any(|uri| {
+                let uri = uri.trim_end_matches('/');
+                let uri = uri.strip_suffix("debian-security").unwrap_or(uri);
+                let uri = uri.trim_end_matches('/');
+                matches!(
+                    uri,
+                    "http://security.debian.org" | "https://security.debian.org",
+                )
+            });
+
+            let require_suffix = match is_security_repo {
+                true if current_codename >= DebianCodename::Bullseye => Some("-security"),
+                true => Some("/updates"),
+                false => None,
+            };
+
             let mut add_info = |kind: &str, message| {
                 infos.push(APTRepositoryInfo {
                     path: self.path.clone(),
@@ -323,7 +339,7 @@ impl APTRepositoryFile {
             let message_stable = "use the name of the stable distribution instead of 'stable'!";
 
             for suite in repo.suites.iter() {
-                let base_suite = suite_variant(suite).0;
+                let (base_suite, suffix) = suite_variant(suite);
 
                 match base_suite {
                     "oldoldstable" | "oldstable" => {
@@ -352,6 +368,15 @@ impl APTRepositoryFile {
                 } else if codename > current_codename {
                     add_info("warning", message_new(base_suite));
                 }
+
+                if let Some(require_suffix) = require_suffix {
+                    if suffix != require_suffix {
+                        add_info(
+                            "warning",
+                            format!("expected suite '{}{}'", current_codename, require_suffix),
+                        );
+                    }
+                }
             }
         }
 
index d79ea7268f8e20d343e7523916859afa3d99750a..c6dd3513192ab38b1bbdcbb71a3976eee618d212 100644 (file)
@@ -283,6 +283,37 @@ fn test_check_repositories() -> Result<(), Error> {
 
     assert_eq!(infos, expected_infos);
 
+    let bad_security = read_dir.join("bad-security.list");
+    let mut file = APTRepositoryFile::new(&bad_security)?.unwrap();
+    file.parse()?;
+
+    let path_string = bad_security.into_os_string().into_string().unwrap();
+
+    let mut expected_infos = vec![];
+    for n in 0..=1 {
+        expected_infos.push(APTRepositoryInfo {
+            path: path_string.clone(),
+            index: n,
+            property: Some("Suites".to_string()),
+            kind: "warning".to_string(),
+            message: "expected suite 'bullseye-security'".to_string(),
+        });
+    }
+    for n in 0..=1 {
+        expected_infos.push(APTRepositoryInfo {
+            path: path_string.clone(),
+            index: n,
+            property: None,
+            kind: "origin".to_string(),
+            message: "Debian".to_string(),
+        });
+    }
+    expected_infos.sort();
+
+    let mut infos = check_repositories(&vec![file], DebianCodename::Bullseye);
+    infos.sort();
+
+    assert_eq!(infos, expected_infos);
     Ok(())
 }
 
diff --git a/tests/sources.list.d.expected/bad-security.list b/tests/sources.list.d.expected/bad-security.list
new file mode 100644 (file)
index 0000000..3f64ffa
--- /dev/null
@@ -0,0 +1,4 @@
+deb http://security.debian.org/debian-security/ bullseye/updates main contrib
+
+deb https://security.debian.org bullseye/updates main contrib
+
diff --git a/tests/sources.list.d/bad-security.list b/tests/sources.list.d/bad-security.list
new file mode 100644 (file)
index 0000000..3f64ffa
--- /dev/null
@@ -0,0 +1,4 @@
+deb http://security.debian.org/debian-security/ bullseye/updates main contrib
+
+deb https://security.debian.org bullseye/updates main contrib
+