[pmg-devel] [PATCH WIP api/gui] Extend rule system

Leo Nunner l.nunner at proxmox.com
Thu Sep 14 11:52:21 CEST 2023


This is a WIP series to rework the PMG rule system by adding the
capabiliy to negate and group objects inside rules. Negated objects will
only match if their conditions are not met.

Match groups allow objects of the same type to be grouped together. A
match group evaluates like one big object, only evaluating as a match if
all objects that are contained inside the group match. In contrast to
previous versions, it is now possible to have multiple match groups for
each object type. They can also be named to make their purpose clearer
at first glance.

Match groups can be visualized as follows:

Rule
    - 'Who' Objects
	- Match group
	    Object 1
	    Object 2
	    Object 3
	- Object 4

The 'Who' objects will only match if either (Object 1 AND Object 2 AND
Object 3) evaluates to true, or if Object 4 evaluates to true. This
means that match groups are connected via logical OR to all other
top-level objects inside the rule, while all objects contained inside
the group are connected via logical AND.

Since this series is still WIP and has been changed since the last
iteration, some things are still missing:
    - The matching logic for negation needs proper implementation
	The last iteration of this series had some fundamental errors in
	how negation was handled for some object types. Especially for
	'What' objects it can be rather hard to define what negation
	entails.
    - The matching logic for match groups
	Since we now have multiple match groups for each object type,
	the matching logic needs to be adapted accordingly. This could
	be achieved by first going through all objects which do not have
	their MatchGroup field set, and then going through all match
	groups associated with that rule (the facilities for which are
	already there).
    - UI Tweaks
	The UI for match groups still needs some tweaks, such as edit
	functionality for match groups (which also still needs to be
	implemented in the API), reloading the tree after adding a
	group, and maybe changing some icons (negation comes to mind).

pmg-api:

Leo Nunner (11):
  negation: add field to database
  negation: parse negation value into objects
  negation: expand/implement API endpoints
  negation: implement matching logic
  match groups: update database schema
  match groups: add functions for database access
  match groups: parse field into objects
  match groups: add API endpoints for create/delete
  match groups: list match groups in rule API
  match groups: update existing object API endpoints
  match groups: implement matching logic

 src/PMG/API2/ObjectGroupHelpers.pm     |  10 +-
 src/PMG/API2/RuleDB.pm                 |   4 +-
 src/PMG/API2/Rules.pm                  | 202 ++++++++++++++++++++++++-
 src/PMG/DBTools.pm                     |  40 +++++
 src/PMG/RuleCache.pm                   |  61 ++++++--
 src/PMG/RuleDB.pm                      | 131 +++++++++++++++-
 src/PMG/RuleDB/ArchiveFilter.pm        |   6 +-
 src/PMG/RuleDB/ContentTypeFilter.pm    |   6 +-
 src/PMG/RuleDB/MatchArchiveFilename.pm |   4 +-
 src/PMG/RuleDB/MatchField.pm           |   2 +-
 src/PMG/RuleDB/MatchFilename.pm        |   2 +-
 11 files changed, 445 insertions(+), 23 deletions(-)

pmg-gui:

Leo Nunner (2):
  negate objects inside rules
  introduce logical 'and' for rules

 css/ext6-pmg.css |  20 +++
 js/RuleInfo.js   | 433 +++++++++++++++++++++++++++++++++++++++--------
 js/Utils.js      |  14 +-
 3 files changed, 391 insertions(+), 76 deletions(-)

-- 
2.39.2





More information about the pmg-devel mailing list