Skip to content

Simplify policy evaluation #17712

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

Closed

Conversation

kumargu
Copy link
Contributor

@kumargu kumargu commented Mar 27, 2025

A draft to simplify policy evaluation

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Enumeration<PolicyParser.GrantEntry> enum_ = pp.grantElements();
while (enum_.hasMoreElements()) {
PolicyParser.GrantEntry ge = enum_.nextElement();
addGrantEntry(ge, keyStore, newInfo);
Copy link
Member

Choose a reason for hiding this comment

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

In addition to the keystore, it looks like the GrantEntry itself supports some additional configurations, like signedBy, that are unnecessary. I believe that signedBy is also used in the context of keystore, where you can specify that jars are signed by the alias of a particular key.

See jarsigner which is a tool shipped with the JDK for signing jars

Copy link
Member

Choose a reason for hiding this comment

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

Similarly to signedBy, principal also goes unused within the project: https://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html

Copy link
Member

@cwperks cwperks Mar 27, 2025

Choose a reason for hiding this comment

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

I just realized that OpenSearch already has some custom logic around the policy files here. This function pre-processes the policy files, looks for jars with possible classifiers and then sets system properties to ensure that the property expansion works on the grant statements.

For example the entry for:

grant codeBase "${codebase.jackson-core}" {
  permission java.net.SocketPermission "*", "connect,resolve";
};

will get the property replaced with the system property of the same name. In my case, when testing locally it would make this substitution.

grant codeBase "file:/Users/cwperx/Projects/opensearch/OpenSearch/build/distribution/local/opensearch-3.0.0-SNAPSHOT/lib/jackson-core-2.18.2.jar" {
  permission java.net.SocketPermission "*", "connect,resolve";
};

After the PropertyFile is instantiated at the end of that method, it will clear the system properties for the codebases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In addition to the keystore, it looks like the GrantEntry itself supports some additional configurations, like signedBy, that are unnecessary.

You are right. I think I removed the traces of signedBy, i will check if they are still out there.

Copy link
Contributor Author

@kumargu kumargu Mar 27, 2025

Choose a reason for hiding this comment

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

I just realized that OpenSearch already has some custom logic around the policy files here.

Ah great find. We can try to reuse that code part, over skimming, it does look sufficient to me.

Copy link
Member

Choose a reason for hiding this comment

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

We need this code block since it sets the system properties needed for the PolicyParser to do property expansion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack.

Copy link
Contributor

❌ Gradle check result for df4f4be:

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for d9eeb20:

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for d6f928c: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 6dd55b7: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 36b6c96: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 0e15d94: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from 0e15d94 to 507cab5 Compare March 28, 2025 16:09
Copy link
Contributor

❌ Gradle check result for 507cab5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 52fd718: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from 52fd718 to 56a1e87 Compare March 29, 2025 17:55
Copy link
Contributor

❌ Gradle check result for 56a1e87: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for bba8b59: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from bba8b59 to eafb80b Compare March 30, 2025 16:22
Copy link
Contributor

❌ Gradle check result for eafb80b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from eafb80b to 6d44cec Compare March 30, 2025 17:27
Copy link
Contributor

❌ Gradle check result for 6d44cec: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from 6d44cec to 40efa5a Compare March 30, 2025 17:42
@kumargu kumargu force-pushed the simplify_policy_evaluation branch 2 times, most recently from 414e4b6 to dc7e124 Compare April 5, 2025 15:03
Copy link
Contributor

github-actions bot commented Apr 5, 2025

❌ Gradle check result for dc7e124: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from dc7e124 to 0c60c59 Compare April 5, 2025 20:24
Copy link
Contributor

github-actions bot commented Apr 5, 2025

❌ Gradle check result for 0c60c59: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from 0c60c59 to 2b18f7d Compare April 6, 2025 05:18
Copy link
Contributor

github-actions bot commented Apr 6, 2025

❌ Gradle check result for 2b18f7d: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from 2b18f7d to 6aa4d19 Compare April 6, 2025 07:46
Copy link
Contributor

github-actions bot commented Apr 6, 2025

❌ Gradle check result for 6aa4d19: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from 6aa4d19 to 0942b10 Compare April 6, 2025 09:54
Copy link
Contributor

github-actions bot commented Apr 6, 2025

❌ Gradle check result for 0942b10: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

github-actions bot commented Apr 7, 2025

❌ Gradle check result for b2ae05d: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@kumargu kumargu force-pushed the simplify_policy_evaluation branch from b2ae05d to 3091cba Compare April 7, 2025 10:36
Copy link
Contributor

github-actions bot commented Apr 7, 2025

❌ Gradle check result for 3091cba: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@peterzhuamazon
Copy link
Member

Assuming this can be closed now @kumargu ?

Thanks.

@kumargu kumargu closed this Apr 10, 2025
@kumargu
Copy link
Contributor Author

kumargu commented Apr 10, 2025

yes closed in favour of #17753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants