-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add validation rule to ensure security capability depending on security-rule assets #820
Conversation
This validation rule checks if there is any security-rule asset in kibana folder. If there is any, then security capability must be defined as part of the package manifest.
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#11453 |
/test |
This version allows us to report also skipped tests.
- junit-annotate#v2.4.1: | ||
artifacts: "*.xml" | ||
- junit-annotate#v2.5.0: | ||
artifacts: "build/test-results/*.xml" |
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.
Ensures that this step just downloads and process the XML files from the unit test steps (linux and windows).
if !slices.Contains(capabilities, "security") { | ||
return specerrors.ValidationErrors{ | ||
specerrors.NewStructuredErrorf("found security rule assets in package but security capability is missing in package manifest"), | ||
} | ||
} |
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 check that none of the observability capabilities are defined too?https://github.com/elastic/kibana/blob/77102c1854bba7253da5363168e8aafb66a34579/config/serverless.oblt.yml#L145
As this validation is defined now, it just enforces to be present security
capability.
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.
Something like:
if slices.Contains(capabilities, "observability") || slices.Contains(capabilities, "apm") || slices.Contains(capabilities, "uptime") {
return specerrors.ValidationErrors{
specerrors.NewStructuredErrorf("found security rule assets in package but observability capabilities are defined in package manifest"),
}
}
The issue here is if those capabilities are modified in Kibana or a new one is added.
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.
Or maybe ensure that just one capability is defined, and that one is "security" ?
Currently, it is just allowed "security":
https://github.com/elastic/kibana/blob/6f4346e4e6f61cf67db50fbe7ce0836c0317cc09/config/serverless.security.yml#L77
That would need to update good_v2 and good_v3 packages (manifests) to just have security capability.
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.
It would be enough with checking that it contains the security capability. If the package has security assets and the deployment has the security capability, it doesn't matter if it also has the observability capability.
If there were a type of project with both capabilities, a package with the security capability should work there, as well as a package with both capabilities.
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.
Perfect, I agree with that too. Thanks!
/test |
if !slices.Contains(capabilities, "security") { | ||
return specerrors.ValidationErrors{ | ||
specerrors.NewStructuredErrorf("found security rule assets in package but security capability is missing in package manifest"), | ||
} | ||
} |
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.
It would be enough with checking that it contains the security capability. If the package has security assets and the deployment has the security capability, it doesn't matter if it also has the observability capability.
If there were a type of project with both capabilities, a package with the security capability should work there, as well as a package with both capabilities.
@@ -212,6 +212,7 @@ func (s Spec) rules(pkgType string, rootSpec spectypes.ItemSpec) validationRules | |||
{fn: semantic.ValidateKibanaFilterPresent, since: semver.MustParse("3.0.0")}, | |||
{fn: semantic.ValidateKibanaNoLegacyVisualizations, types: []string{"integration"}, since: semver.MustParse("3.0.0")}, | |||
{fn: semantic.ValidateDimensionsPresent, types: []string{"integration"}, since: semver.MustParse("3.0.1")}, | |||
{fn: semantic.ValidateCapabilitiesRequired, since: semver.MustParse("2.10.0")}, // capabilities definition was added in spec version 2.10.0 |
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.
Using the version where capabilities were introduced looks good to me, but we don't necessarily have to use this version, we could introduce the check on a later version. I guess it will depend if there are packages currently failing with this check.
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.
I set that version to ensure that the expected capabilities are added into the manifest since the first version were those fields were introduced into the manifest (2.10.0).
We could also start testing this validation from 3.0.0. That spec was the minimum one set for Serverless projects. For instance, for observability:
https://github.com/elastic/kibana/blob/68b3267ca2f76d8de4fedef622608d8685e7eceb/config/serverless.security.yml#L78
The current packages defining security-rule
assets are:
security_detection_engine
: defines spec version 3.0.0tychon
: defines spec version 3.2.2
Currently, there are no other packages failing in integrations because of that.
Do you think it would be better to set since: 3.0.0
to match with versioning used in Serverless rather than 2.10.0?
@@ -772,6 +769,53 @@ func TestValidateForbiddenDataStreamName(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestValidateCapabilitiesRequried(t *testing.T) { |
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.
Would it be possible to make this work as part of TestValidateFile
? This could be reported as a failure int the manifest.yml
file, as the problem would be a missing capability there.
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.
Sure!
I've added the file manifest path into the message error to show that the manifest is invalid. That allows me to move the test for the capabilities to "TestValidateFile".
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.
Added in d16f9fd
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#11453 |
💚 Build Succeeded
History
cc @mrodm |
What does this PR do?
Add a new validation rule to ensure that security capability is added in the manifest if there is any security-rule asset (in Kibana folder).
Additional changes:
Why is it important?
Currently, there are just two packages using security-rule assets. Both packages have defined the security capability.
This PR ensures that packages containing this kind of security-rule assets are not listed as available to be installed in Observability Serverless projects.
Checklist
test/packages
that prove my change is effective.spec/changelog.yml
.Related issues