Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GCP] Fix check on gcp.audit.authorization_info[].granted #7308

Merged
merged 3 commits into from Aug 9, 2023

Conversation

zmoog
Copy link
Contributor

@zmoog zmoog commented Aug 8, 2023

What does this PR do?

When gcp.audit.authorization_info[] objects do not contain the granted attribute, the if statement fails.

This PR updates the expression in the if to check for null values and uses the granted == true
syntax to avoid another error when there the == operator is not used.

The following error occurs with ... ctx?.gcp?.audit?.authorization_info[0]?.granted and granted is null.

Cannot invoke "Object.getClass()" because "value" is null

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.

How to test this PR locally

# walk into the GCP integration 
cd packages/gcp 

# start a stack version 8.6.2
elastic-package build && elastic-package stack up -d -v --version 8.6.2

# set up the environment variables 
eval $(elastic-package stack shellinit)

And then run the pipeline tests using the new data_stream/audit/_dev/test/pipeline/test-sdh-3695.log test case:

$ elastic-package test pipeline -v
2023/08/08 17:10:45 DEBUG Enable verbose logging
Run pipeline tests for the package
--- Test results for package: gcp - START ---
╭─────────┬────────────────────┬───────────┬────────────────────────┬────────┬──────────────╮
│ PACKAGE │ DATA STREAM        │ TEST TYPE │ TEST NAME              │ RESULT │ TIME ELAPSED │
├─────────┼────────────────────┼───────────┼────────────────────────┼────────┼──────────────┤
│ gcp     │ audit              │ pipeline  │ test-audit.log         │ PASS   │    12.5545ms │
│ gcp     │ audit              │ pipeline  │ test-sdh-3695.log      │ PASS   │   3.589584ms │
│ gcp     │ compute            │ pipeline  │ test-gcp-compute.json  │ PASS   │      2.933ms │
│ gcp     │ dns                │ pipeline  │ test-dns.log           │ PASS   │     11.807ms │
│ gcp     │ firewall           │ pipeline  │ test-firewall.log      │ PASS   │   9.665667ms │
│ gcp     │ loadbalancing_logs │ pipeline  │ test-load-balancer.log │ PASS   │   2.979667ms │
│ gcp     │ vpcflow            │ pipeline  │ test-vpcflow.log       │ PASS   │  65.097875ms │
╰─────────┴────────────────────┴───────────┴────────────────────────┴────────┴──────────────╯
--- Test results for package: gcp - END   ---
Done

Related issues

@zmoog zmoog self-assigned this Aug 8, 2023
@zmoog zmoog added bug Something isn't working Integration:GCP labels Aug 8, 2023
When `gcp.audit.authorization_info[]` objects do not contain the
`granted` attribute, the `if` statement fails.

The updated `if` checks for null values and uses the `granted == true`
syntax to avoid another error when there the `==` operator is not
used:

```
Cannot invoke "Object.getClass()" because "value" is null
```
@elasticmachine
Copy link

elasticmachine commented Aug 8, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-08-08T15:23:03.590+0000

  • Duration: 19 min 9 sec

Test stats 🧪

Test Results
Failed 0
Passed 65
Skipped 0
Total 65

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

elasticmachine commented Aug 8, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (6/6) 💚
Files 100.0% (6/6) 💚
Classes 100.0% (6/6) 💚
Methods 87.826% (101/115) 👎 -12.174
Lines 96.0% (1464/1525) 👎 -0.621
Conditionals 100.0% (0/0) 💚

@zmoog zmoog changed the title Fix check on gcp.audit.authorization_info[].granted [GCP] Fix check on gcp.audit.authorization_info[].granted Aug 8, 2023
@zmoog zmoog marked this pull request as ready for review August 8, 2023 15:22
@zmoog zmoog requested review from a team as code owners August 8, 2023 15:22
Copy link
Contributor

@kcreddy kcreddy left a comment

Choose a reason for hiding this comment

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

LGTM

@zmoog zmoog merged commit 4a2c9e8 into elastic:main Aug 9, 2023
4 checks passed
@zmoog zmoog deleted the zmoog/gcp-audit-logs branch August 9, 2023 20:05
@elasticmachine
Copy link

Package gcp - 2.25.1 containing this change is available at https://epr.elastic.co/search?package=gcp

gizas pushed a commit that referenced this pull request Sep 5, 2023
* Fix check on gcp.audit.authorization_info[].granted

When `gcp.audit.authorization_info[]` objects do not contain the
`granted` attribute, the `if` statement fails.

The updated `if` checks for null values and uses the `granted == true`
syntax to avoid another error when there the `==` operator is not
used:

```
Cannot invoke "Object.getClass()" because "value" is null
```

* Use `override` to avoid using a script expression

* Add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Integration:GCP
Projects
None yet
3 participants