Skip to content

Commit aaf4942

Browse files
Urist-McGitfmoessbauer
authored andcommitted
chore(tests): add test for packages that are not properly installed
Packages that do not have the "installed ok install" line in the dpkg status file should not appear in SBOMs. Test that. Signed-off-by: Christoph Steiger <[email protected]>
1 parent 529c571 commit aaf4942

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

tests/root/apt-sources/var/lib/dpkg/status

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,54 @@ Description: GNU binary utilities for bpf
3333
users or developers.
3434
Built-Using: binutils (= 2.40-2)
3535
Homepage: https://sourceware.org/binutils/
36+
37+
Package: openssh-server
38+
Status: deinstall ok config-files
39+
Priority: optional
40+
Section: net
41+
Installed-Size: 1930
42+
Maintainer: Debian OpenSSH Maintainers <[email protected]>
43+
Architecture: amd64
44+
Multi-Arch: foreign
45+
Source: openssh
46+
Version: 1:9.2p1-2+deb12u4
47+
Config-Version: 1:9.2p1-2+deb12u4
48+
Replaces: openssh-client (<< 1:7.9p1-8), ssh, ssh-krb5
49+
Provides: ssh-server
50+
Depends: adduser, libpam-modules, libpam-runtime, lsb-base, openssh-client (= 1:9.2p1-2+deb12u4), openssh-sftp-server, procps, ucf, debconf (>= 0.5) | debconf-2.0, runit-helper (>= 2.14.0~), libaudit1 (>= 1:2.2.1), libc6 (>= 2.36), libcom-err2 (>= 1.43.9), libcrypt1 (>= 1:4.1.0), libgssapi-krb5-2 (>= 1.17), libkrb5-3 (>= 1.13~alpha1+dfsg), libpam0g (>= 0.99.7.1), libselinux1 (>= 3.1~), libssl3 (>= 3.0.15), libsystemd0, libwrap0 (>= 7.6-4~), zlib1g (>= 1:1.1.4)
51+
Pre-Depends: init-system-helpers (>= 1.54~)
52+
Recommends: default-logind | logind | libpam-systemd, ncurses-term, xauth
53+
Suggests: molly-guard, monkeysphere, ssh-askpass, ufw
54+
Breaks: runit (<< 2.1.2-51~)
55+
Conflicts: sftp, ssh-socks, ssh2
56+
Conffiles:
57+
/etc/default/ssh 500e3cf069fe9a7b9936108eb9d9c035
58+
/etc/init.d/ssh 3649a6fe8c18ad1d5245fd91737de507
59+
/etc/pam.d/sshd 8b4c7a12b031424b2a9946881da59812
60+
/etc/ssh/moduli 1f68f6ab5e45958e61ff32297ea1c3ec
61+
/etc/sv/ssh/.meta/installed d41d8cd98f00b204e9800998ecf8427e
62+
/etc/sv/ssh/finish f5f032f6f3e569c821346294d410b636
63+
/etc/sv/ssh/log/run 63e0ec3e1080dafc68d6d71d42b150a9
64+
/etc/sv/ssh/run 411f69ac55d12f0c98998552846b1c78
65+
/etc/ufw/applications.d/openssh-server 486b78d54b93cc9fdc950c1d52ff479e
66+
Description: secure shell (SSH) server, for secure access from remote machines
67+
This is the portable version of OpenSSH, a free implementation of
68+
the Secure Shell protocol as specified by the IETF secsh working
69+
group.
70+
.
71+
Ssh (Secure Shell) is a program for logging into a remote machine
72+
and for executing commands on a remote machine.
73+
It provides secure encrypted communications between two untrusted
74+
hosts over an insecure network. X11 connections and arbitrary TCP/IP
75+
ports can also be forwarded over the secure channel.
76+
It can be used to provide applications with a secure communication
77+
channel.
78+
.
79+
This package provides the sshd server.
80+
.
81+
In some countries it may be illegal to use any encryption at all
82+
without a special permit.
83+
.
84+
sshd replaces the insecure rshd program, which is obsolete for most
85+
purposes.
86+
Homepage: https://www.openssh.com/

tests/test_generation.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,21 @@ def test_pkglist_apt_cache(tmpdir, sbom_generator):
316316
assert binutils_bpf["versionInfo"] == "2.40-2+1-custom"
317317
# make sure we have no additional information
318318
assert binutils_bpf["supplier"] == "NOASSERTION"
319+
320+
321+
def test_residual_config_packages(tmpdir, sbom_generator):
322+
dbom = sbom_generator("tests/root/apt-sources")
323+
outdir = Path(tmpdir)
324+
dbom.generate(str(outdir / "sbom"), validate=True)
325+
with open(outdir / "sbom.spdx.json") as file:
326+
spdx_json = json.loads(file.read())
327+
packages = spdx_json["packages"]
328+
assert "openssh-server" not in [p["name"] for p in packages]
329+
# source package for openssh-server
330+
assert "openssh" not in [p["name"] for p in packages]
331+
with open(outdir / "sbom.cdx.json") as file:
332+
spdx_json = json.loads(file.read())
333+
components = spdx_json["components"]
334+
assert "openssh-server" not in [c["name"] for c in components]
335+
# source package for openssh-server
336+
assert "openssh" not in [c["name"] for c in components]

0 commit comments

Comments
 (0)