-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Entitlements] Allow policy overrides via system properties #124489
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
Conversation
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
I see from the Jira:
If we, in essence, just want these to "expire" at some point, then a list of patch versions could be needlessly cumbersome. It also raises questions about how this would work for serverless. |
This is why I made version non-semantic, just a (list) of versions.
|
I don't think we'd use this mechanism there. We'd just do an actual patch release. |
I don't think it's worth supporting this case. As mentioned before, we can just patch, or use the "versionless" format. We don't have to worry about this stale configuration being mistakenly kept around even when a fix is deployed because we own the deployment here. |
👍 Presumably whatever we "patch" here will be fixed in the next release. So there's no need to be lenient and allow future patch versions. |
++ |
...itlement/qa/src/javaRestTest/java/org/elasticsearch/entitlement/qa/EntitlementsTestRule.java
Outdated
Show resolved
Hide resolved
Should I remove the ability to specify multiple |
|
IMHO it's hard to imagine regretting support for multiple versions. |
In serverless, this would be faster than a patch release because there's no need a full CI test cycle, right? I think we want to be careful about limiting our options during an incident. |
Got it. This works in the case where we release 9.0.1 or 8.18.0.1 and find an issue. I'm good with keeping this flexability. We can always just not leverage it. |
Good point, it would be a considerably faster remediation. I'm good with allowing "versionless" patches just to give us that option. |
jdconrad
left a comment
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.
In the interest of time I think we should get this change in.
I've left a design change suggestion as a comment in the parser. Please let me know your thoughts -- could be a follow up if you think it would be a positive change.
| this.externalEntitlements = externalEntitlements; | ||
| } | ||
|
|
||
| public VersionedPolicy parseVersionedPolicy() { |
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.
My suggestion would be to not have the version parsing as part of the PolicyParser at all since it's only used to determine if a policy override is valid.
I see two different possibilities to accomplish this:
- Change
PolicyParserto take in an XContentBuilder instead of an InputStream. Pull out the xcontent necessary for version checking in elasticsearch bootstrapping code. - Change the override to only be JSON for the policy and some stream of bytes for the versions. You can then read that stream of bytes up to where the policy begins and then pass the remainder of the
InputStreaminto thePolicyParser.
I think this may also remove the need for a VersionedPolicy record as well.
|
Thanks @jdconrad for the suggestions
I actually started with that but made things more complicated. I will give it another go though.
I don't understand how this would work: currently the parser has to be YAML, not JSON. We can change it, but then it would be strange/cumbersome to pass a JSON + something via the command line. Maybe using JSON for such a simple object can be passed inline does not look so bad. |
…124489) This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property. The system property is in the form es.entitlements.policy.<plugin name>, and accepts a versioned policy: versions: - version1 - versionN policy: <a standard entitlement policy> For example: versions: - 9.1.0 policy: ALL-UNNAMED: - set_https_connection_properties - outbound_network - files: - relative_path: ".config/gcloud" relative_to: home mode: read The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via gradle run: ./gradlew run --debug-jvm -Dtests.jvm.argline="-Des.entitlements.policy.repository-gcs=dmVyc2lvbnM6CiAgLSA5LjEuMApwb2xpY3k6CiAgQUxMLVVOTkFNRUQ6CiAgICAtIHNldF9odHRwc19jb25uZWN0aW9uX3Byb3BlcnRpZXMKICAgIC0gb3V0Ym91bmRfbmV0d29yawogICAgLSBmaWxlczoKICAgICAgLSByZWxhdGl2ZV9wYXRoOiAiLmNvbmZpZy9nY2xvdWQiCiAgICAgICAgcmVsYXRpdmVfdG86IGhvbWUKICAgICAgICBtb2RlOiByZWFkCg==" The versions listed in the policy are string-matched against Build.version().current(); it is possible to specify any number of versions. If the list is empty/there is no versions field, the policy is assumed to match any Elasticsearch versions. The override policy specified for any given plugin replaces the embedded policy for that plugin. See how EntitlementsAllowedViaOverrideIT replaces an empty policy for the entitlement-test-plugin with a policy that allows load_native_libraries and access to files in the test read_dir. Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above). Relates to ES-11009
…124489) This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property. The system property is in the form es.entitlements.policy.<plugin name>, and accepts a versioned policy: versions: - version1 - versionN policy: <a standard entitlement policy> For example: versions: - 9.1.0 policy: ALL-UNNAMED: - set_https_connection_properties - outbound_network - files: - relative_path: ".config/gcloud" relative_to: home mode: read The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via gradle run: ./gradlew run --debug-jvm -Dtests.jvm.argline="-Des.entitlements.policy.repository-gcs=dmVyc2lvbnM6CiAgLSA5LjEuMApwb2xpY3k6CiAgQUxMLVVOTkFNRUQ6CiAgICAtIHNldF9odHRwc19jb25uZWN0aW9uX3Byb3BlcnRpZXMKICAgIC0gb3V0Ym91bmRfbmV0d29yawogICAgLSBmaWxlczoKICAgICAgLSByZWxhdGl2ZV9wYXRoOiAiLmNvbmZpZy9nY2xvdWQiCiAgICAgICAgcmVsYXRpdmVfdG86IGhvbWUKICAgICAgICBtb2RlOiByZWFkCg==" The versions listed in the policy are string-matched against Build.version().current(); it is possible to specify any number of versions. If the list is empty/there is no versions field, the policy is assumed to match any Elasticsearch versions. The override policy specified for any given plugin replaces the embedded policy for that plugin. See how EntitlementsAllowedViaOverrideIT replaces an empty policy for the entitlement-test-plugin with a policy that allows load_native_libraries and access to files in the test read_dir. Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above). Relates to ES-11009
…124489) This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property. The system property is in the form es.entitlements.policy.<plugin name>, and accepts a versioned policy: versions: - version1 - versionN policy: <a standard entitlement policy> For example: versions: - 9.1.0 policy: ALL-UNNAMED: - set_https_connection_properties - outbound_network - files: - relative_path: ".config/gcloud" relative_to: home mode: read The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via gradle run: ./gradlew run --debug-jvm -Dtests.jvm.argline="-Des.entitlements.policy.repository-gcs=dmVyc2lvbnM6CiAgLSA5LjEuMApwb2xpY3k6CiAgQUxMLVVOTkFNRUQ6CiAgICAtIHNldF9odHRwc19jb25uZWN0aW9uX3Byb3BlcnRpZXMKICAgIC0gb3V0Ym91bmRfbmV0d29yawogICAgLSBmaWxlczoKICAgICAgLSByZWxhdGl2ZV9wYXRoOiAiLmNvbmZpZy9nY2xvdWQiCiAgICAgICAgcmVsYXRpdmVfdG86IGhvbWUKICAgICAgICBtb2RlOiByZWFkCg==" The versions listed in the policy are string-matched against Build.version().current(); it is possible to specify any number of versions. If the list is empty/there is no versions field, the policy is assumed to match any Elasticsearch versions. The override policy specified for any given plugin replaces the embedded policy for that plugin. See how EntitlementsAllowedViaOverrideIT replaces an empty policy for the entitlement-test-plugin with a policy that allows load_native_libraries and access to files in the test read_dir. Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above). Relates to ES-11009
…#124862) This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property. The system property is in the form es.entitlements.policy.<plugin name>, and accepts a versioned policy: versions: - version1 - versionN policy: <a standard entitlement policy> For example: versions: - 9.1.0 policy: ALL-UNNAMED: - set_https_connection_properties - outbound_network - files: - relative_path: ".config/gcloud" relative_to: home mode: read The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via gradle run: ./gradlew run --debug-jvm -Dtests.jvm.argline="-Des.entitlements.policy.repository-gcs=dmVyc2lvbnM6CiAgLSA5LjEuMApwb2xpY3k6CiAgQUxMLVVOTkFNRUQ6CiAgICAtIHNldF9odHRwc19jb25uZWN0aW9uX3Byb3BlcnRpZXMKICAgIC0gb3V0Ym91bmRfbmV0d29yawogICAgLSBmaWxlczoKICAgICAgLSByZWxhdGl2ZV9wYXRoOiAiLmNvbmZpZy9nY2xvdWQiCiAgICAgICAgcmVsYXRpdmVfdG86IGhvbWUKICAgICAgICBtb2RlOiByZWFkCg==" The versions listed in the policy are string-matched against Build.version().current(); it is possible to specify any number of versions. If the list is empty/there is no versions field, the policy is assumed to match any Elasticsearch versions. The override policy specified for any given plugin replaces the embedded policy for that plugin. See how EntitlementsAllowedViaOverrideIT replaces an empty policy for the entitlement-test-plugin with a policy that allows load_native_libraries and access to files in the test read_dir. Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above). Relates to ES-11009
…#124860) This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property. The system property is in the form es.entitlements.policy.<plugin name>, and accepts a versioned policy: versions: - version1 - versionN policy: <a standard entitlement policy> For example: versions: - 9.1.0 policy: ALL-UNNAMED: - set_https_connection_properties - outbound_network - files: - relative_path: ".config/gcloud" relative_to: home mode: read The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via gradle run: ./gradlew run --debug-jvm -Dtests.jvm.argline="-Des.entitlements.policy.repository-gcs=dmVyc2lvbnM6CiAgLSA5LjEuMApwb2xpY3k6CiAgQUxMLVVOTkFNRUQ6CiAgICAtIHNldF9odHRwc19jb25uZWN0aW9uX3Byb3BlcnRpZXMKICAgIC0gb3V0Ym91bmRfbmV0d29yawogICAgLSBmaWxlczoKICAgICAgLSByZWxhdGl2ZV9wYXRoOiAiLmNvbmZpZy9nY2xvdWQiCiAgICAgICAgcmVsYXRpdmVfdG86IGhvbWUKICAgICAgICBtb2RlOiByZWFkCg==" The versions listed in the policy are string-matched against Build.version().current(); it is possible to specify any number of versions. If the list is empty/there is no versions field, the policy is assumed to match any Elasticsearch versions. The override policy specified for any given plugin replaces the embedded policy for that plugin. See how EntitlementsAllowedViaOverrideIT replaces an empty policy for the entitlement-test-plugin with a policy that allows load_native_libraries and access to files in the test read_dir. Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above). Relates to ES-11009
…#124861) This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property. The system property is in the form es.entitlements.policy.<plugin name>, and accepts a versioned policy: versions: - version1 - versionN policy: <a standard entitlement policy> For example: versions: - 9.1.0 policy: ALL-UNNAMED: - set_https_connection_properties - outbound_network - files: - relative_path: ".config/gcloud" relative_to: home mode: read The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via gradle run: ./gradlew run --debug-jvm -Dtests.jvm.argline="-Des.entitlements.policy.repository-gcs=dmVyc2lvbnM6CiAgLSA5LjEuMApwb2xpY3k6CiAgQUxMLVVOTkFNRUQ6CiAgICAtIHNldF9odHRwc19jb25uZWN0aW9uX3Byb3BlcnRpZXMKICAgIC0gb3V0Ym91bmRfbmV0d29yawogICAgLSBmaWxlczoKICAgICAgLSByZWxhdGl2ZV9wYXRoOiAiLmNvbmZpZy9nY2xvdWQiCiAgICAgICAgcmVsYXRpdmVfdG86IGhvbWUKICAgICAgICBtb2RlOiByZWFkCg==" The versions listed in the policy are string-matched against Build.version().current(); it is possible to specify any number of versions. If the list is empty/there is no versions field, the policy is assumed to match any Elasticsearch versions. The override policy specified for any given plugin replaces the embedded policy for that plugin. See how EntitlementsAllowedViaOverrideIT replaces an empty policy for the entitlement-test-plugin with a policy that allows load_native_libraries and access to files in the test read_dir. Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above). Relates to ES-11009
|
@ldematte Follow up is totally fine with me. I actually mean YAML 🤦 so I understand how my comment would have been confusing :) |
This PR adds the ability to override entitlement policies for Elasticsearch plugins and modules via a system property.
The system property is in the form
es.entitlements.policy.<plugin name>, and accepts a versioned policy:For example:
The versioned policy needs to be base64 encoded. For example, to pass the above policy to a test cluster via
gradle run:The
versionslisted in the policy are string-matched againstBuild.version().current(); it is possible to specify any number of versions. If the list is empty/there is noversionsfield, the policy is assumed to match any Elasticsearch versions.The override policy specified for any given plugin replaces the embedded policy for that plugin. See how
EntitlementsAllowedViaOverrideITreplaces an empty policy for theentitlement-test-pluginwith a policy that allowsload_native_librariesand access to files in the testread_dir.Also tested manually with an override with a different version, with an override with an invalid policy and with a valid override (see command above).
Relates to ES-11009