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

[Fleet] Fix package policy validation #123153

Merged
merged 2 commits into from
Jan 18, 2022

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Jan 17, 2022

Summary

Part of #122679

Improve package policy validation to use variable definition from the package instead of the one provided by the user.
Improve the UI to no crash in case an invalidate package policy is here to allow user to fix it.

In a following PR I will add the package policy validation to the create and update package policy API where we do not validate the user provided info against the package.

How to test

  1. Create an invalid package policy (missing required variables)
curl --request POST \
  --url http://localhost:5601/api/fleet/package_policies \
  --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \
  --header 'Content-Type: application/json' \
  --header 'kbn-xsrf: as' \
  --data '{
  "enabled": true,
  "inputs": [
    {
      "enabled": true,
      "streams": [
        {
          "data_stream": {
            "dataset": "auditd.log",
            "type": "logs"
          },
          "enabled": true,
          "vars": {
          }
        }
      ],
      "type": "logfile"
    }
  ],
  "name": "test-124",
  "namespace": "default",
  "output_id": "fleet-default-output",
  "package": {
    "name": "auditd",
    "title": "Auditd",
    "version": "1.3.0"
  },
  "policy_id": "a14e96b6-ad4c-5e47-aa64-6d3d8c8c6ef5"
}'
  1. Visit the UI you should see validation errors and be able to fix them

Screen Shot 2022-01-17 at 11 02 06 AM

@nchaulet nchaulet self-assigned this Jan 17, 2022
@nchaulet nchaulet added auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.17.0 v8.0.0 v8.1.0 labels Jan 17, 2022
@nchaulet nchaulet marked this pull request as ready for review January 17, 2022 16:07
@nchaulet nchaulet requested a review from a team as a code owner January 17, 2022 16:07
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 644.1KB 644.3KB +177.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 112.7KB 112.8KB +76.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @nchaulet

@juliaElastic
Copy link
Contributor

I think the API should not accept an invalid policy, are you saying that will be fixed in the next pr?

@nchaulet
Copy link
Member Author

I think the API should not accept an invalid policy, are you saying that will be fixed in the next pr?

Yes I want to add the API validation in a separate PR so it's easily revert-able if this cause new bugs.

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

@nchaulet nchaulet merged commit e721b2b into elastic:main Jan 18, 2022
@nchaulet nchaulet deleted the fix-package-policy-validation branch January 18, 2022 12:58
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 18, 2022
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 18, 2022
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.0
7.17

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jan 18, 2022
(cherry picked from commit e721b2b)

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
kibanamachine added a commit that referenced this pull request Jan 18, 2022
(cherry picked from commit e721b2b)

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
@dikshachauhan-qasource
Copy link

Hi @nchaulet

We have attempted to validate above changes using API shared above on 8.0 selfmanged env.

On hitting the API, we observed below errors shared in screenshot:
image

Further, when we attempted to add Auditd integration with missing values to default policy, observed only two errors for path and Tags.

image

However, we didn't observed any error on enabling preserve original event as shared in above screenshot in ticket summary. Could you please let us know if we are missing anything.

We also observed same behavior on cloud while adding Auditd integration with missing values.

Thanks
QAS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.17.0 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants