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

Allow optional strict checking of variable names in EQL expressions #2678

Merged
merged 15 commits into from
May 15, 2023

Conversation

faec
Copy link
Contributor

@faec faec commented May 11, 2023

This fixes the issue in #2607 where spec file prevention conditions with nonexistent variable names are silently skipped, which led to conditions being unknowingly skipped because of copy-paste errors. It adds a flag allowMissingVariables to the EQL evaluation functions, and sets it to false when evaluating spec file preventions. (I left it true when evaluating upgrade conditions and AST conditions which I believe are used in autodiscovery, to avoid breaking code that depends on the current behavior, though those call sites might deserve a closer look at some point.)

Once invalid variables in spec files became an error, some of the existing tests started failing because of the variable errors from #2606, so I folded that change into this one and added full tests.

Fixes #2607.

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/fragments using the changelog tool
  • I have added an integration test or an E2E test

@faec faec added bug Something isn't working Team:Elastic-Agent Label for the Agent team labels May 11, 2023
@faec faec self-assigned this May 11, 2023
@mergify
Copy link
Contributor

mergify bot commented May 11, 2023

This pull request does not have a backport label. Could you fix it @faec? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@elasticmachine
Copy link
Contributor

elasticmachine commented May 11, 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-05-15T14:22:29.791+0000

  • Duration: 20 min 20 sec

Test stats 🧪

Test Results
Failed 0
Passed 5659
Skipped 19
Total 5678

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

  • /package : Generate the packages.

  • run integration tests : Run the Elastic Agent Integration tests.

  • run end-to-end tests : Generate the packages and run the E2E Tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@faec
Copy link
Contributor Author

faec commented May 12, 2023

an encouraging CI failure :-)

component_test.go:1824: 
        	Error Trace:	/home/runner/work/elastic-agent/elastic-agent/pkg/component/component_test.go:1824
        	Error:      	Not equal: 
        	            	expected: &component.ErrInputRuntimeCheckFail{message:"No support for RHEL7 on arm64"}
        	            	actual  : &component.ErrInputRuntimeCheckFail{message:"unknown variable at line 1 column 2: \"runtime.user.root\""}

@elasticmachine
Copy link
Contributor

elasticmachine commented May 12, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 98.611% (71/72) 👍
Files 68.273% (170/249) 👍
Classes 67.021% (315/470) 👍
Methods 53.652% (955/1780) 👍 0.052
Lines 39.406% (10958/27808) 👎 -0.028
Conditionals 100.0% (0/0) 💚

@faec faec mentioned this pull request May 12, 2023
7 tasks
@faec faec marked this pull request as ready for review May 12, 2023 21:45
@faec faec requested a review from a team as a code owner May 12, 2023 21:45
Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM. Nice addition!

@faec faec merged commit 0af676d into elastic:main May 15, 2023
@faec faec deleted the eql-strict-vars branch May 15, 2023 20:36
@faec faec added the backport-v8.8.0 Automated backport with mergify label May 31, 2023
mergify bot pushed a commit that referenced this pull request May 31, 2023
faec added a commit that referenced this pull request May 31, 2023
…2678) (#2758)

(cherry picked from commit 0af676d)

Co-authored-by: Fae Charlton <fae.charlton@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip backport-v8.8.0 Automated backport with mergify bug Something isn't working skip-changelog Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent silently ignores spec file preventions with nonexistent variables
3 participants