From d43c18ca7b0ff19c8c9504b6893f094f405bf072 Mon Sep 17 00:00:00 2001 From: Oleg Kashaev <80004794+okashaev-splunk@users.noreply.github.com> Date: Mon, 13 Dec 2021 12:39:37 +0100 Subject: [PATCH] fix(cim_field_report): adopts new PSA tags parser --- pytest_splunk_addon/tools/cim_field_report.py | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pytest_splunk_addon/tools/cim_field_report.py b/pytest_splunk_addon/tools/cim_field_report.py index beabd874d..5a3854a2a 100644 --- a/pytest_splunk_addon/tools/cim_field_report.py +++ b/pytest_splunk_addon/tools/cim_field_report.py @@ -498,22 +498,18 @@ def get_addon_eventtypes(addon_path): parser = AddonParser(addon_path) eventtypes = { - eventtype: None for eventtype in parser.eventtype_parser.eventtypes.sects + eventtype: [] for eventtype in parser.eventtype_parser.eventtypes.sects } - stanza_pattern = re.compile("eventtype\s*=\s*(\w+)") - for stanza, section in parser.tags_parser.tags.sects.items(): - match = stanza_pattern.match(stanza) - if match and match.groups(): - eventtype = match.groups()[0] - if eventtype in eventtypes: - tags = [ - key - for key, option in section.options.items() - if option.value.strip() == "enabled" - ] - eventtypes[eventtype] = tags + for item in parser.tags_parser.get_tags(): + stanza, tag, enabled = item["stanza"], item["tag"], item["enabled"] + parts = [s.strip().strip('"') for s in stanza.split("=", 1)] + if len(parts) > 1 and parts[0] == "eventtype": + eventtype = parts[1] + if enabled and eventtype in eventtypes and tag not in eventtypes[eventtype]: + eventtypes[eventtype].append(tag) + LOGGER.debug(eventtypes) return eventtypes