Skip to content

Validate policy type when storing an enrich policy #48126

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

Merged
merged 1 commit into from
Oct 18, 2019

Conversation

martijnvg
Copy link
Member

No description provided.

@martijnvg martijnvg added >non-issue :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP labels Oct 16, 2019
@martijnvg martijnvg requested a review from hub-cap October 16, 2019 12:39
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Ingest)

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

One question, also, is this the only thing we should be validating at PUT time? I know the PUT rquest, if security is enabled, validates that the user can use the index, but for insecure clusters it does no such validation on whether the backing index exists. Should we add this somewhere?

@@ -53,7 +55,11 @@ public static void putPolicy(String name, EnrichPolicy policy, ClusterService cl
if (name.toLowerCase(Locale.ROOT).equals(name) == false) {
throw new IllegalArgumentException("Invalid policy name [" + name + "], must be lowercase");
}
// TODO: add policy validation
Set<String> supportedPolicyTypes = Set.of(EnrichPolicy.SUPPORTED_POLICY_TYPES);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we put this validation into the constructors of the EnrichPolicy instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason I put it here, is because it makes generating random policies easier and
down the line I think that determining what types are valid isn't going to be checking
whether the matches with an entry in EnrichPolicy.SUPPORTED_POLICY_TYPES.

@martijnvg
Copy link
Member Author

I know the PUT rquest, if security is enabled, validates that the user can use the index, but for insecure clusters it does no such validation on whether the backing index exists.

So for clusters with security enabled, it checks whether there are permissions to use the source index, but not whether the source index really exists.

The check whether a source index exists, happens when executing the policy. We can also check for the existence of the source index in putPolicy(...), but then we force everyone to create the source index prior to creating the policy. I'm not sure whether that is really required and perhaps we should allow policies to be created before the source index is created, like we do now. Also any check about the source index we add in this method is no guarantee, because after the policy is created, the user can delete the source index. So these checks for the source index in putPolicy(...) also need to exist in the execute policy api.

@martijnvg
Copy link
Member Author

I'm not sure whether that is really required and perhaps we should allow policies to be created before the source index is created, like we do now. Also any check about the source index we add in this method is no guarantee, because after the policy is created, the user can delete the source index.

I've changed my mind. I think it is helpful if the enrich policy is in a valid state from the beginning. Mainly because a policy can't be updated. I think it is okay, if we require that the source exists prior to storing the enrich policy. I will address this is a separate PR.

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

Looking forward to the next PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants