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

[8.x](backport #40779) x-pack/filebeat/input/cel: add envvar support #41000

Open
wants to merge 1 commit into
base: 8.x
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 26, 2024

Proposed commit message

See title.

Note that the example shown for allowed_environment can be demonstrated by adding the following.

diff --git a/x-pack/filebeat/input/cel/input_test.go b/x-pack/filebeat/input/cel/input_test.go
index 44ad39435b..9409c4f855 100644
--- a/x-pack/filebeat/input/cel/input_test.go
+++ b/x-pack/filebeat/input/cel/input_test.go
@@ -411,6 +411,31 @@ var inputTests = []struct {
                        {"message": "not present"},
                },
        },
+       {
+               name: "env_var_path",
+               config: map[string]interface{}{
+                       "interval": 1,
+                       "allowed_environment": []string{
+                               "PATH",
+                       },
+                       "program": `{
+                               "events": {
+                                       "message": env.?PATH.orValue("").split(":")
+                                               .map(p, try(dir(p)))
+                                               .filter(r, type(r) != type(""))
+                                               .flatten()
+                                               .collate("name")
+                               }
+                       }`,
+                       "state": nil,
+                       "resource": map[string]interface{}{
+                               "url": "",
+                       },
+               },
+               want: []map[string]interface{}{
+                       {"message": ""}, // This will fail, but will show the diff.
+               },
+       },
 
        // FS-based tests.
        {

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs


This is an automatic backport of pull request #40779 done by [Mergify](https://mergify.com).

@mergify mergify bot added the backport label Sep 26, 2024
@mergify mergify bot requested a review from a team as a code owner September 26, 2024 06:47
@mergify mergify bot assigned efd6 Sep 26, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 26, 2024
@botelastic
Copy link

botelastic bot commented Sep 26, 2024

This pull request doesn't have a Team:<team> label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant