Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

First matching rule is applied, rather than rule from highest-priority file #463

Open
tehybel opened this issue May 29, 2023 · 0 comments
Open

Comments

@tehybel
Copy link

tehybel commented May 29, 2023

Let's say I create a rules file, 90-myrules.rules, and another rules file, 91-part2.rules. Both have a rule matching my program. The intuitive behavior would be that the rule in 91-part2.rules has highest priority, i.e., is applied last.

However the current behavior is that the first matching rule is applied, and no other rules are applied. The current behavior is not intuitive, and is the opposite of e.g. systemd.

This is caused by the line self.rules[key] = ... inside get_rule_info, which simply inserts the rules in order of discovery into the self.rules dictionary. Later, inside get_tpid_rule, the first matching rule is returned. get_tpid_rule should instead update a result variable and return the last match:

    def get_tpid_rule(self, tpid: TPID):
        rule_cmdlines = tpid.cmdline
        result = None
        for rule_name in [tpid.cmd, tpid.stat_name]:
            for key in self.rules:
                name, cmdlines = key
                if name == rule_name:
                    if cmdlines:
                        for cl in cmdlines:
                            if cl not in rule_cmdlines:
                                break
                        else:
                            result = self.rules[key]
                    else:
                        result = self.rules[key]
        return result
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant