Skip to content

Commit b34c073

Browse files
ti_opencti: fix pipeline errors due to access method from a null reference (#16129)
Pipeline tests were failing with the error: "cannot access method/field [add] from a null def reference". This failure was caused by script processors calling .add() on fields whose parent object (threat.indicator) could be null. The fix updates the ingest pipeline scripts to safely initialize ctx.threat, ctx.threat.indicator, and the target array field before adding elements.
1 parent b7acdc2 commit b34c073

File tree

11 files changed

+33
-28
lines changed

11 files changed

+33
-28
lines changed

packages/ti_opencti/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "2.10.1"
3+
changes:
4+
- description: Fix null reference errors in ingest pipelines.
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/16129
27
- version: "2.10.0"
38
changes:
49
- description: Add comprehensive filtering support for indicators including pattern types, confidence levels, labels, dates, authors, creators, and marking definitions.

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_artifact.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ processors:
4848
ignore_empty_value: true
4949

5050
# append object
51-
- append:
52-
field: threat.indicator.file
53-
value: []
5451
- script:
5552
description: Append to the destination
5653
lang: painless
5754
source: |
55+
ctx.threat = ctx.threat ?: [:];
56+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
57+
ctx.threat.indicator.file = ctx.threat.indicator.file ?: [];
5858
ctx.threat.indicator.file.add(ctx._tmp_file);
5959
6060
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_autonomous_system.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ processors:
1111
value: "{{{_ingest._value.name}}}"
1212

1313
# append object
14-
- append:
15-
field: threat.indicator.as
16-
value: []
1714
- script:
1815
description: Append to the destination
1916
lang: painless
2017
source: |
18+
ctx.threat = ctx.threat ?: [:];
19+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
20+
ctx.threat.indicator.as = ctx.threat.indicator.as ?: [];
2121
ctx.threat.indicator.as.add(ctx._tmp_as);
2222
2323
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_directory.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ processors:
2828
ignore_empty_value: true
2929

3030
# append object
31-
- append:
32-
field: threat.indicator.file
33-
value: []
3431
- script:
3532
description: Append to the destination
3633
lang: painless
3734
source: |
35+
ctx.threat = ctx.threat ?: [:];
36+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
37+
ctx.threat.indicator.file = ctx.threat.indicator.file ?: [];
3838
ctx.threat.indicator.file.add(ctx._tmp_file);
3939
4040
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_domain_name_or_hostname.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ processors:
1212
ignore_missing: true
1313

1414
# append object
15-
- append:
16-
field: threat.indicator.url
17-
value: []
1815
- script:
1916
description: Append to the destination
2017
lang: painless
2118
source: |
19+
ctx.threat = ctx.threat ?: [:];
20+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
21+
ctx.threat.indicator.url = ctx.threat.indicator.url ?: [];
2222
ctx.threat.indicator.url.add(ctx._tmp_url);
2323
2424
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_file.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ processors:
9191
ignore_empty_value: true
9292

9393
# append object
94-
- append:
95-
field: threat.indicator.file
96-
value: []
9794
- script:
9895
description: Append to the destination
9996
lang: painless
10097
source: |
98+
ctx.threat = ctx.threat ?: [:];
99+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
100+
ctx.threat.indicator.file = ctx.threat.indicator.file ?: [];
101101
ctx.threat.indicator.file.add(ctx._tmp_file);
102102
103103
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_url_field.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ processors:
2626
copy_from: _tmp_url.original
2727

2828
# append object
29-
- append:
30-
field: threat.indicator.url
31-
value: []
3229
- script:
3330
description: Append to the destination
3431
lang: painless
3532
source: |
33+
ctx.threat = ctx.threat ?: [:];
34+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
35+
ctx.threat.indicator.url = ctx.threat.indicator.url ?: [];
3636
ctx.threat.indicator.url.add(ctx._tmp_url);
3737
3838
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_windows_registry_key.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ processors:
2424
if: ctx._tmp_registry?.hive != null
2525

2626
# append object
27-
- append:
28-
field: threat.indicator.registry
29-
value: []
3027
- script:
3128
description: Append to the destination
3229
lang: painless
3330
source: |
31+
ctx.threat = ctx.threat ?: [:];
32+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
33+
ctx.threat.indicator.registry = ctx.threat.indicator.registry ?: [];
3434
ctx.threat.indicator.registry.add(ctx._tmp_registry);
3535
3636
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_windows_registry_value_type.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ processors:
1515
value: "{{{_ingest._value.data}}}"
1616

1717
# append object
18-
- append:
19-
field: threat.indicator.registry
20-
value: []
2118
- script:
2219
description: Append to the destination
2320
lang: painless
2421
source: |
22+
ctx.threat = ctx.threat ?: [:];
23+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
24+
ctx.threat.indicator.registry = ctx.threat.indicator.registry ?: [];
2525
ctx.threat.indicator.registry.add(ctx._tmp_registry);
2626
2727
- remove:

packages/ti_opencti/data_stream/indicator/elasticsearch/ingest_pipeline/ecs_from_x509_certificate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ processors:
4343
value: "{{{_ingest._value.version}}}"
4444

4545
# append object
46-
- append:
47-
field: threat.indicator.x509
48-
value: []
4946
- script:
5047
description: Append to the destination
5148
lang: painless
5249
source: |
50+
ctx.threat = ctx.threat ?: [:];
51+
ctx.threat.indicator = ctx.threat.indicator ?: [:];
52+
ctx.threat.indicator.x509 = ctx.threat.indicator.x509 ?: [];
5353
ctx.threat.indicator.x509.add(ctx._tmp_x509);
5454
5555
- remove:

0 commit comments

Comments
 (0)