fix: exclude Alpine service supervision from native discovery

This commit is contained in:
VAIO73
2026-10-17 11:53:30 +00:00
parent c393a56b92
commit 22098042ba
2 changed files with 20 additions and 0 deletions
+2
View File
@@ -46,6 +46,8 @@ _NAME = re.compile(r'[A-Za-z0-9][A-Za-z0-9_.+@-]{0,63}\Z')
_VERSION = re.compile(r'v?\d+(?:\.\d+){1,4}(?:[-+._][A-Za-z0-9.-]+)?\Z')
_SYSTEM = {
'ssh', 'sshd', 'cron', 'crond', 'postfix', 'rsyslog', 'syslog', 'syslog-ng',
# Alpine/OpenRC system logging and service supervision are not apps.
'klogd', 'syslogd', 'openrc-user', 'runit', 'runsvdir', 'runsv', 'supervise-daemon',
'dbus', 'dbus-broker', 'systemd', 'udev', 'networking', 'network', 'networkmanager',
'dhcpcd', 'dhclient', 'chrony', 'chronyd', 'ntp', 'ntpd', 'openntpd', 'agetty',
'getty', 'login', 'polkit', 'polkitd', 'accounts-daemon', 'acpid', 'anacron',
@@ -126,6 +126,24 @@ class DiscoveryFixtures(unittest.TestCase):
self.assertEqual(result['candidates'], [])
self.assertFalse(any(native.FOOTPRINT_SCRIPT in call for call in self.calls))
def test_alpine_openrc_infrastructure_has_zero_footprint_probes(self):
# Actual Alpine 3.24.1 CT217 init metadata: klogd, user and runsvdir.
# The runsvdir definition can exist without /usr/bin/runsvdir installed;
# rejecting it must precede probing, not turn the scan into partial.
for name, executable in (
('klogd', '/sbin/klogd'),
('user', '/usr/libexec/rc/bin/openrc-user'),
('runsvdir', '/usr/bin/runsvdir'),
('renamed-system-service', '/usr/libexec/rc/bin/openrc-user'),
):
with self.subTest(name=name):
self.calls.clear()
result = native.scan(101, self.runner(
service(name=name, exe=executable, directory='', manager='openrc')))
self.assertEqual(result['status'], 'complete')
self.assertEqual(result['candidates'], [])
self.assertFalse(any(native.FOOTPRINT_SCRIPT in call for call in self.calls))
def test_helper_services_and_templates_have_zero_footprint_probes(self):
cases = [
('netpulse-stable-update', '/bin/bash', '/opt/netpulse', '/opt/netpulse/stable-apply.sh'),