-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Restrict integration changes for managed policies #90675
[Fleet] Restrict integration changes for managed policies #90675
Conversation
Pinging @elastic/fleet (Feature:Fleet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we verify in the delete method of the packagePolicy service too that the policy is not managed?
} | ||
if (parentAgentPolicy.is_managed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not blocking) I have the feeling that is time to refactor L64-L80 to a new function something like _validateParentAgentPolicy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wanted to consolidate the two sources of the "There is already a package named..." errors
kibana/x-pack/plugins/fleet/server/services/package_policy.ts
Lines 297 to 304 in 45f420c
if ( | |
(parentAgentPolicy.package_policies as PackagePolicy[]).find( | |
(siblingPackagePolicy) => | |
siblingPackagePolicy.id !== id && siblingPackagePolicy.name === packagePolicy.name | |
) | |
) { | |
throw new Error('There is already a package with the same name on this agent policy'); | |
} |
And perhaps give it a specific error name/type. I plan on circling back to that after I get the other features in.
I'll open a ticket
@@ -39,6 +39,52 @@ export default function ({ getService }: FtrProviderContext) { | |||
.send({ agentPolicyId }); | |||
}); | |||
|
|||
it('should fail for managed agent policies', async function () { | |||
if (server.enabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick we have a helper that does the same thing but I found it less verbose https://github.com/elastic/kibana/blob/master/x-pack/test/fleet_api_integration/apis/epm/data_stream.ts/#L37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder. I was just copy/pasting from the rest of the file. I'll update
@elasticmachine merge upstream |
@nchaulet I put the check in the AgentPolicyService because Package Policy delete calls it
And in the Package Policy service we only have the Agent Policy id string, not the whole object. Which we do have in the AgentPolicyService. |
Does that mean there is no possibility to force adding/removing an integration? @ruflin has a more concrete plan on the policy set up than I do, but so far I was under the impression that a force flag could be used for the initial set up of the managed policy. |
@simitt you cannot current bypass the guards for managed policies. However, you can work around them by doing something like
I'll open an issue to discuss the force flag (we have it some other places already and it doesn't mean quite the same thing) but I think the "make it unmanaged" workaround means everything is still possible without adding API which we might be inconsistent or changed later. |
thanks @jfsiii - the described workflow should work for now. |
…ithub.com:jfsiii/kibana into 90445-no-integration-changes-for-managed-policies
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
* master: (44 commits) [APM] Add experimental support for Data Streams (elastic#89650) [Search Session] Control "Kibana / Search Sessions" management section by privileges (elastic#90818) [Lens] Median as default function (elastic#90952) Implement custom global header banner (elastic#87438) [Fleet] Reduce permissions. (elastic#90302) Update dependency @elastic/charts to v24.5.1 (elastic#89822) [Create index pattern] Can't create single character index without wildcard (elastic#90919) [ts/build_ts_refs] add support for --clean flag (elastic#91060) Don't clean when running e2e tests (elastic#91057) Fixes track_total_hits in the body not having an effect when using search strategy (elastic#91068) [Security Solution][Detections] Adds list plugin Saved Objects to Security feature privilege (elastic#90895) Removing the code plugin entirely for 8.0 (elastic#77940) chore(NA): move the instruction to remove yarn global bazelisk package into the first place on install bazel tools (elastic#91026) [jest/ci] remove max-old-space-size override to use 4gb default (elastic#91020) [Fleet] Restrict integration changes for managed policies (elastic#90675) [CI] Fix auto-backport condditions so that it doesn't trigger for other labels (elastic#91042) [DOCS] Uses variable to refer to query profiler (elastic#90976) [App Search] Relevance Tuning logic listeners (elastic#89461) [Metrics UI] Fix saving/loading saved views from URL (elastic#90216) Limit cardinality of transaction.name (elastic#90955) ...
) ## Summary - [x] Integrations cannot be added ~~, unless with a force flag~~ - [x] API - [x] UI - [x] tests - [x] Integrations cannot be removed ~~, unless with a force flag~~ - [x] API - [x] UI - [x] tests closes elastic#90445 refs elastic#89617 ### Cannot add integrations to managed policy <img height="400" alt="Screen Shot 2021-02-08 at 1 56 32 PM" src="https://user-images.githubusercontent.com/57655/107277261-25c48300-6a22-11eb-936a-0a7361667093.png"> ### Cannot delete integrations from managed policy <img alt="Screen Shot 2021-02-08 at 3 05 16 PM" src="https://user-images.githubusercontent.com/57655/107277318-337a0880-6a22-11eb-836f-fc66b510d257.png"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
…91150) ## Summary - [x] Integrations cannot be added ~~, unless with a force flag~~ - [x] API - [x] UI - [x] tests - [x] Integrations cannot be removed ~~, unless with a force flag~~ - [x] API - [x] UI - [x] tests closes #90445 refs #89617 ### Cannot add integrations to managed policy <img height="400" alt="Screen Shot 2021-02-08 at 1 56 32 PM" src="https://user-images.githubusercontent.com/57655/107277261-25c48300-6a22-11eb-936a-0a7361667093.png"> ### Cannot delete integrations from managed policy <img alt="Screen Shot 2021-02-08 at 3 05 16 PM" src="https://user-images.githubusercontent.com/57655/107277318-337a0880-6a22-11eb-836f-fc66b510d257.png"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
Summary
, unless with a force flag, unless with a force flagcloses #90445
refs #89617
Cannot add integrations to managed policy
Cannot delete integrations from managed policy
Checklist