Skip to content

Conversation

@kcreddy
Copy link
Contributor

@kcreddy kcreddy commented Jun 19, 2025

Proposed commit message

There is no null check on resources[].Details.AwsEc2Instance.IpV4Addresses 
or resources[].Details.AwsEc2Instance.IpV6Addresses when extracting host.ip 
leading to pipeline_error.
This PR adds the required null check to prevent pipeline_error.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

How to test this PR locally

Added new pipeline test samples to simulate the behaviour.
Before:

--- Test results for package: aws - START ---
FAILURE DETAILS:
aws/securityhub_findings_full_posture test-securityhub-findings-full-posture.log:
[0] unexpected pipeline error: [Processor 'conditional' with tag 'script_extract_fields_from_single_resource' failed with message 'cannot access method/field [iterator] from a null def reference']


╭─────────┬───────────────────────────────────┬───────────┬───────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────┬──────────────╮
│ PACKAGE │ DATA STREAM                       │ TEST TYPE │ TEST NAME                                                             │ RESULT                                                                      │ TIME ELAPSED │
├─────────┼───────────────────────────────────┼───────────┼───────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────┼──────────────┤
│ aws     │ securityhub_findings_full_posture │ pipeline  │ (ingest pipeline warnings test-securityhub-findings-full-posture.log) │ PASS                                                                        │ 440.180209ms │
│ aws     │ securityhub_findings_full_posture │ pipeline  │ test-securityhub-findings-full-posture.log                            │ FAIL: test case failed: one or more problems with fields found in documents │ 296.372708ms │
╰─────────┴───────────────────────────────────┴───────────┴───────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────┴──────────────╯
--- Test results for package: aws - END   ---
Done

After:

--- Test results for package: aws - START ---
╭─────────┬───────────────────────────────────┬───────────┬───────────────────────────────────────────────────────────────────────┬────────┬──────────────╮
│ PACKAGE │ DATA STREAM                       │ TEST TYPE │ TEST NAME                                                             │ RESULT │ TIME ELAPSED │
├─────────┼───────────────────────────────────┼───────────┼───────────────────────────────────────────────────────────────────────┼────────┼──────────────┤
│ aws     │ securityhub_findings              │ pipeline  │ (ingest pipeline warnings test-securityhub-findings.log)              │ PASS   │ 431.320292ms │
│ aws     │ securityhub_findings              │ pipeline  │ test-securityhub-findings.log                                         │ PASS   │  288.70975ms │
│ aws     │ securityhub_findings_full_posture │ pipeline  │ (ingest pipeline warnings test-securityhub-findings-full-posture.log) │ PASS   │ 453.879208ms │
│ aws     │ securityhub_findings_full_posture │ pipeline  │ test-securityhub-findings-full-posture.log                            │ PASS   │ 275.653208ms │
╰─────────┴───────────────────────────────────┴───────────┴───────────────────────────────────────────────────────────────────────┴────────┴──────────────╯
--- Test results for package: aws - END   ---
Done
@kcreddy kcreddy self-assigned this Jun 19, 2025
@kcreddy kcreddy added Integration:aws AWS bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Jun 19, 2025
@kcreddy kcreddy marked this pull request as ready for review June 19, 2025 12:42
@kcreddy kcreddy requested review from a team as code owners June 19, 2025 12:42
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

"IamInstanceProfileArn": "arn:aws:iam::1111111111:instance-profile/eks-00c3ac5a-8d2a-1a50-9bd3-6c1939f83db6",
"ImageId": "ami-0e0ff40957f238bdd",
"IpV4Addresses": [
"67.43.156.245",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change those IPs to be within the range reserved for documentation by RFC 5737.

https://github.com/elastic/elastic-package/blob/6f9523b118c70377de3c792abb228cf5757dca78/docs/howto/ingest_geoip.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 397c0ac

if (res.Type == 'AwsEcsContainer' && res.Details.AwsEcsContainer?.Name != null) {
ctx.host.name = res.Details.AwsEcsContainer.Name;
}
if (res.Type == 'AwsEc2Instance' && (res.Details.AwsEc2Instance?.IpV4Addresses != null || res.Details.AwsEc2Instance?.IpV6Addresses != null)) {
Copy link
Member

@andrewkroh andrewkroh Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this && (res.Details.AwsEc2Instance?.IpV4Addresses != null || res.Details.AwsEc2Instance?.IpV6Addresses != null) is now redundant and could be removed.

Same comment for L1832 and for the full_posture pipeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as per suggestion in 397c0ac

@kcreddy kcreddy requested a review from andrewkroh June 19, 2025 16:25
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @kcreddy

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kcreddy kcreddy merged commit b4bd0e2 into elastic:main Jun 20, 2025
7 checks passed
@elastic-vault-github-plugin-prod

Package aws - 3.8.2 containing this change is available at https://epr.elastic.co/package/aws/3.8.2/

shmsr pushed a commit to shmsr/integrations that referenced this pull request Jun 30, 2025
…elastic#14264)

There is no null check on resources[].Details.AwsEc2Instance.IpV4Addresses 
or resources[].Details.AwsEc2Instance.IpV6Addresses when extracting host.ip 
leading to pipeline_error.
This PR adds the required null check to prevent pipeline_error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:aws AWS Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

3 participants