Skip to content

Commit db87c7c

Browse files
kamil-certatsebix
authored andcommitted
Simplify and fix upgrade function
1 parent 2c9f753 commit db87c7c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

intelmq/lib/upgrades.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -980,15 +980,22 @@ def v341_new_fields(configuration, harmonization, dry_run, **kwargs):
980980
"""
981981
Add new fields to IntelMQ Data Format
982982
"""
983-
changed = False
984-
if "event" in harmonization and "severity" not in harmonization["event"]:
985-
harmonization["event"]["severity"] = {
986-
"description": "Severity of the event, based on the information from the source, and eventually modified by IntelMQ during processing. Meaning of the levels may differ based on the event source.",
987-
"length": 10,
988-
"regex": "^(critical|high|medium|low|info|undefined)$",
989-
"type": "LowercaseString",
990-
}
991-
changed = True
983+
changed = None
984+
if "event" not in harmonization:
985+
return changed, configuration, harmonization
986+
987+
builtin_harmonisation = load_configuration(
988+
resource_filename("intelmq", "etc/harmonization.conf")
989+
)
990+
for field in [
991+
"severity",
992+
]:
993+
if field not in harmonization["event"]:
994+
if field not in builtin_harmonisation["event"]:
995+
# ensure forward-compatibility if we ever remove something from harmonisation
996+
continue
997+
harmonization["event"][field] = builtin_harmonisation["event"][field]
998+
changed = True
992999
return changed, configuration, harmonization
9931000

9941001

0 commit comments

Comments
 (0)