Skip to content

Commit 3dbeebf

Browse files
committed
Upgrade harmonisation
1 parent 81ffe54 commit 3dbeebf

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ Please refer to the change log for a full list of changes.
1818
### Tools
1919

2020
### Data Format
21+
To save new fields from IntelMQ Data Format in existing PostgreSQL instances, the following schema
22+
update is necessary:
23+
```sql
24+
ALTER TABLE events ADD "product.full_name" text;
25+
ALTER TABLE events ADD "product.name" text;
26+
ALTER TABLE events ADD "product.vendor" text;
27+
ALTER TABLE events ADD "product.version" text;
28+
ALTER TABLE events ADD "product.vulnerabilities" text;
29+
```
2130

2231
### Configuration
2332

intelmq/lib/upgrades.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
'v320_update_turris_greylist_url',
4242
'v322_url_replacement',
4343
'v322_removed_feeds_and_bots',
44-
'v340_deprecations'
44+
'v340_deprecations',
45+
'v341_new_fields'
4546
]
4647

4748

@@ -974,6 +975,30 @@ def v340_deprecations(configuration, harmonization, dry_run, **kwargs):
974975
return message or changed, configuration, harmonization
975976

976977

978+
def v341_new_fields(configuration, harmonization, dry_run, **kwargs):
979+
"""
980+
Add new fields to IntelMQ Data Format
981+
"""
982+
changed = None
983+
if "event" not in harmonization:
984+
return changed, configuration, harmonization
985+
986+
builtin_harmonisation = load_configuration(
987+
resource_filename("intelmq", "etc/harmonization.conf")
988+
)
989+
for field in [
990+
"product.full_name",
991+
"product.name",
992+
"product.vendor",
993+
"product.version",
994+
"product.vulnerabilities",
995+
]:
996+
if field not in harmonization["event"]:
997+
harmonization["event"][field] = builtin_harmonisation["event"][field]
998+
changed = True
999+
return changed, configuration, harmonization
1000+
1001+
9771002
UPGRADES = OrderedDict([
9781003
((1, 0, 0, 'dev7'), (v100_dev7_modify_syntax,)),
9791004
((1, 1, 0), (v110_shadowserver_feednames, v110_deprecations)),
@@ -1004,7 +1029,8 @@ def v340_deprecations(configuration, harmonization, dry_run, **kwargs):
10041029
((3, 3, 0), ()),
10051030
((3, 3, 1), ()),
10061031
((3, 4, 0), (v340_deprecations, )),
1007-
((3, 4, 1), ()),
1032+
((3, 4, 1), (v341_new_fields, )),
1033+
10081034
])
10091035

10101036
ALWAYS = (harmonization,)

intelmq/tests/bin/initdb.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ CREATE INDEX "idx_events_source.asn" ON events USING btree ("source.asn");
9898
CREATE INDEX "idx_events_source.ip" ON events USING btree ("source.ip");
9999
CREATE INDEX "idx_events_source.fqdn" ON events USING btree ("source.fqdn");
100100
CREATE INDEX "idx_events_time.observation" ON events USING btree ("time.observation");
101-
CREATE INDEX "idx_events_time.source" ON events USING btree ("time.source");
101+
CREATE INDEX "idx_events_time.source" ON events USING btree ("time.source");

0 commit comments

Comments
 (0)