Skip to content

Commit 7d04e60

Browse files
efd6herrBez
authored andcommitted
packages/aws/data_stream/config: guard against null API response fields (elastic#18787)
The CEL program calls size() on body.EvaluationResults after checking has(), but has() returns true when the field is present with a JSON null value. size(null) has no overload, producing a runtime error that propagates to the ternary operator as "no such overload". Add != null guards to all three has()+size() patterns in the program (EvaluationResults and ConfigRules). Remove dead .orValue([]) on the map call since the true branch already guarantees a non-empty list. Update the test input to return null instead of an empty array for one rule so the fix is exercised by system tests.
1 parent 9b286c7 commit 7d04e60

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎packages/aws/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: "6.14.1"
3+
changes:
4+
- description: Handle null EvaluationResults in AWS Config GetComplianceDetailsByConfigRule response.
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/18787
27
- version: "6.14.0"
38
changes:
49
- description: Enable agentless deployment for AWS RDS metrics.

‎packages/aws/data_stream/config/_dev/deploy/docker/files/config.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ rules:
200200
body: |-
201201
{{ minify_json `
202202
{
203-
"EvaluationResults": []
203+
"EvaluationResults": null
204204
}
205205
`}}
206206
- path: /

‎packages/aws/data_stream/config/agent/stream/cel.yml.hbs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ program: |
6161
:
6262
// Stage 1: Check if we have existing config rules to process
6363
// If we have worklist with ConfigRules, we already fetched rules and now need to get compliance details
64-
has(state.?worklist.ConfigRules) && size(state.worklist.ConfigRules) > 0 ?
64+
has(state.?worklist.ConfigRules) && state.worklist.ConfigRules != null && size(state.worklist.ConfigRules) > 0 ?
6565
{
6666
// State management: preserve existing state from previous iteration
6767
"worklist": state.worklist,
@@ -274,7 +274,7 @@ program: |
274274
// Stage 3: Process results - either exit early on failure or fetch compliance details
275275
!has(config_rules.worklist) ? // Exit early due to POST failure.
276276
config_rules
277-
: has(config_rules.worklist.ConfigRules) && size(config_rules.worklist.ConfigRules) > 0 ?
277+
: has(config_rules.worklist.ConfigRules) && config_rules.worklist.ConfigRules != null && size(config_rules.worklist.ConfigRules) > 0 ?
278278
// API Call: Execute GetComplianceDetailsByConfigRule for specific config rule
279279
post_request(
280280
state.url.trim_right("/"),
@@ -311,8 +311,8 @@ program: |
311311
// Response Processing: Successfully got compliance details
312312
bytes(resp.Body).decode_json().as(body,
313313
{
314-
"events": (has(body.EvaluationResults) && size(body.EvaluationResults) > 0) ?
315-
body.EvaluationResults.orValue([]).map(evt,
314+
"events": (has(body.EvaluationResults) && body.EvaluationResults != null && size(body.EvaluationResults) > 0) ?
315+
body.EvaluationResults.map(evt,
316316
{
317317
"message": evt.with(
318318
{

‎packages/aws/manifest.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: 3.4.0
22
name: aws
33
title: AWS
4-
version: 6.14.0
4+
version: 6.14.1
55
description: Collect logs and metrics from Amazon Web Services (AWS) with Elastic Agent.
66
type: integration
77
categories:

0 commit comments

Comments
 (0)