• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rpm-software-management / rpmlint / 27743531775

18 Jun 2026 07:23AM UTC coverage: 88.143% (+0.2%) from 87.933%
27743531775

push

github

6096 of 6916 relevant lines covered (88.14%)

3.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.35
/rpmlint/checks/DBusPolicyCheck.py
1
from xml.dom.minidom import parse
4✔
2

3
from rpmlint.checks.AbstractCheck import AbstractCheck
4✔
4

5
DBUS_DIRECTORIES = ('/etc/dbus-1/system.d/', '/usr/share/dbus-1/system.d/')
4✔
6

7

8
class DBusPolicyCheck(AbstractCheck):
4✔
9
    def check(self, pkg):
4✔
10
        if pkg.is_source:
4✔
11
            return
×
12

13
        for f in pkg.files:
4✔
14
            if f in pkg.ghost_files:
4✔
15
                continue
2✔
16

17
            # catch xml exceptions
18
            try:
4✔
19
                if any(f.startswith(d) for d in DBUS_DIRECTORIES):
4✔
20
                    send_policy_seen = False
4✔
21
                    lf = pkg.dir_name() + f
4✔
22
                    xml = parse(lf)
4✔
23
                    for policy in xml.getElementsByTagName('policy'):
4✔
24
                        send_policy_seen |= self._check_allow_policy_element(pkg, f, policy)
4✔
25
                        self._check_deny_policy_element(pkg, f, policy)
4✔
26

27
                    if not send_policy_seen:
4✔
28
                        self.output.add_info('E', pkg, 'dbus-policy-missing-allow', f)
4✔
29

30
            except Exception as e:
4✔
31
                self.output.add_info('E', pkg, 'dbus-parsing-exception', 'raised an exception: ' + str(e), f)
4✔
32
                continue
4✔
33

34
    def _check_allow_policy_element(self, pkg, f, policy):
4✔
35
        send_policy_seen = False
4✔
36
        for allow in policy.getElementsByTagName('allow'):
4✔
37
            if ((allow.hasAttribute('send_interface') or
4✔
38
                 allow.hasAttribute('send_member') or
39
                 allow.hasAttribute('send_path')) and not
40
                    allow.hasAttribute('send_destination')):
41
                send_policy_seen = True
4✔
42
                self.output.add_info('E', pkg, 'dbus-policy-allow-without-destination', allow.toxml(), f)
4✔
43
            elif allow.hasAttribute('send_destination'):
4✔
44
                send_policy_seen = True
4✔
45

46
            if (allow.hasAttribute('receive_sender') or
4✔
47
                    allow.hasAttribute('receive_interface')):
48
                self.output.add_info('W', pkg, 'dbus-policy-allow-receive', allow.toxml(), f)
4✔
49

50
        return send_policy_seen
51

52
    def _check_deny_policy_element(self, pkg, f, policy):
53
        for deny in policy.getElementsByTagName('deny'):
4✔
54
            if (deny.hasAttribute('send_interface') and not
55
                    deny.hasAttribute('send_destination')):
56
                self.output.add_info('E', pkg, 'dbus-policy-deny-without-destination', deny.toxml(), f)
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc