Commit graph

176 commits

Author SHA1 Message Date
Lorenzo Dematté
d91427e5c1
[Entitlements] Add set_https_connection_properties entitlement and checks (#118577) (#119464) 2025-01-03 03:19:40 +11:00
Rene Groeschke
6b7cd0339e
Update Gradle wrapper to 8.12 (#118683) (#119363)
This updates the gradle wrapper to 8.12

We addressed deprecation warnings due to the update that includes:

- Fix change in TestOutputEvent api
- Fix deprecation in groovy syntax
- Use latest ospackage plugin containing our fix
- Remove project usages at execution time
- Fix deprecated project references in repository-old-versions

(cherry picked from commit ba61f8c7f7)
2024-12-31 08:36:31 +01:00
Patrick Doyle
6cd41647f4
Mandatory class name (#118626) (#119374)
* Use $$ for static check methods

* Always use class name from checker method name

* Spotless

* Varargs assertParseCheckerMethodSignatureThrows

* Remove hasReceiver again

* Spotless

* Cosmetic changes

* Change to new check method naming convention
2024-12-31 10:29:37 +11:00
Patrick Doyle
b5f8da1833
Grant all entitlements to system modules (#119168) (#119364)
* Grant all entitlements to system modules

* [CI] Auto commit changes from spotless

* Make NO_ENTITLEMENTS_MODULE non-null

* Initialize NO_ENTITLEMENTS_MODULE with @BeforeClass.

Looks like @WithoutSecurityManager doesn't work with static initializers.

* Move check to public method

* Logging adjustments

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2024-12-31 05:48:32 +11:00
Patrick Doyle
01e68a4239
Add missing ProcessBuilder.start entitlements test (#119100) (#119127) 2024-12-20 06:30:17 +11:00
Ryan Ernst
7af5f287fc
Limit which classes are retransformed (#118786) (#119120)
During entitlements initialization the transformer is added to
instrumenation after some classes are already loaded. Currently we end
up force loading (though not initializing) all classes that want to
transform. This commit simplifies the retransform to only apply to
classes which we know are already loaded by the jdk, which
Instrumentation provides.
2024-12-20 05:13:52 +11:00
Ryan Ernst
b7dc70ddae
[8.x] Simplify instrumenter and tests (#118493) (#118714)
This commit simplifies the entitlements instrumentation service and
instrumenter a bit. It especially removes some repetition in the
instrumenter tests.
2024-12-19 08:59:06 -08:00
Patrick Doyle
d9578c58aa
Process execution checks and IT tests (#119010) (#119106)
* Process creation checks and IT tests

* Remove process queries; only forbid execution
2024-12-20 03:44:19 +11:00
Lorenzo Dematté
7b2a12a853
Implementing the correct exit functions (Runtime) (#118657) (#118680) 2024-12-19 10:18:18 -05:00
Patrick Doyle
5b9cb891c8
Entitlements: More robust frame skipping (#118983) (#119009)
* More robust frame skipping

* Cosmetic improvements for clarity

* Explicit set of runtime classes

* Pass entitlements runtime module to PolicyManager ctor

* Use the term "entitlements module" and filter instead of dropWhile

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2024-12-19 07:16:10 +11:00
Lorenzo Dematté
21021ee4fc
[Entitlements] Differentiate between ES modules and plugins (external) (#117973) (#118551) 2024-12-13 00:22:32 +11:00
Lorenzo Dematté
5f376e6eec
Building scope -> entitlements map during PolicyManager initialization (#118070) (#118528) 2024-12-12 20:40:05 +11:00
Ryan Ernst
34a5457d32
Rename instrumenter tests (#118462) (#118479)
The "sythetic" tests are the only unit tests for the instrumenter. This
commit renames the test suite to be more clear it is the place to put
instrumenter tests.
2024-12-12 04:16:14 +11:00
Lorenzo Dematté
73689dc56e
[Entitlements] Moving and refactoring IT tests (#118254) (#118467) 2024-12-12 03:06:13 +11:00
Ryan Ernst
c3994ab5b0
Remove old instrumentation tests (#118411) (#118461)
The newer "sythetic" tests cover all the cases of instrumentation
2024-12-12 01:50:19 +11:00
Ryan Ernst
38fcaba9ea
Add a diagram of how entitlements loading works (#117513) (#118120)
This commit adds a diagram to source control that explains how the
entitlements lib is loaded.
2024-12-08 02:08:17 +11:00
Lorenzo Dematté
d2b33a9856
Update ASM 9.7 -> 9.7.1 to support JDK 24 (#118094) (#118128) 2024-12-06 19:35:48 +11:00
Lorenzo Dematté
aecb48c183
[Entitlements] Integrate PluginsLoader with PolicyManager (#117239) (#118055)
This PR expands `PolicyManager` to actually use `Policy` and
`Entitlement` classes for checks, instead of hardcoding them.

It also introduces a separate `PluginsResolver`, with a dedicated
function to map a Class to a Plugin (name). `PluginsResolver` is
initialized with data from `PluginsLoader`, and then its resolve
function is used internally in `PolicyManager` to find a plugin policy
(and then test against the entitlements declared in the policy).
2024-12-05 21:36:21 +11:00
Lorenzo Dematté
36d8307abd
CreateClassLoaderEntitlement + extensions to parse logic (#117754) (#117978) 2024-12-05 07:50:46 +01:00
Lorenzo Dematté
2f64565c75
[Entitlements] Refactor InstrumenterImpl tests (#117688) (#117791)
Following up
https://github.com/elastic/elasticsearch/pull/117332#discussion_r1856803255,
I refactored `InstrumenterImpl` tests, splitting them into 2 suites:  -
`SyntheticInstrumenterImplTests`, which tests the mechanics of
instrumentation using ad-hoc test cases. This should see little change
now that we have our Instrumenter working as intended -
`InstrumenterImplTests`, which is back to its original intent to make
sure (1) the right arguments make it all the way to the check methods,
and (2) if the check method throws, that exception correctly bubbles up
through the instrumented method.

The PR also includes a little change to `InstrumenterImpl`  construction
to clean it up a bit and make it more testable.
2024-11-30 20:43:02 +11:00
Jack Conradson
124091161e
Remove entitlement parameter (#117597) (#117663)
Removes the "entitlement" parameter from policy parsing.
2024-11-28 08:55:32 +11:00
Lorenzo Dematté
d06927f7ab
[Entitlements] Add support for instrumenting constructors (#117332) (#117620) 2024-11-27 22:36:42 +11:00
Ryan Ernst
cd316cb263
Backport entitlement tools (#117416)
* Entitlement tools: SecurityManager scanner (#116020)

* Fix entitlement tools to build (#117351)

This commit adjusts the common lib of entitlement tools to use
elasticsearch.build so that it gets java version configuration
automatically. Additionally the mrjar plugin is removed from the core
lib since it is not used there.

* fix compile

---------

Co-authored-by: Lorenzo Dematté <lorenzo.dematte@elastic.co>
2024-11-25 03:22:15 +11:00
Ryan Ernst
68d9db633b
Catch up entitlements backports (#117363)
* [Entitlements] Consider only system modules in the boot layer (#117017)

* [Entitlements] Implement entry point definitions via checker function signature (#116754)

* Policy manager for entitlements (#116695)

* Add java version variants of entitlements checker (#116878)

As each version of Java is released, there may be additional methods we
want to instrument for entitlements. Since new methods won't exist in
the base version of Java that Elasticsearch is compiled with, we need to
hava different classes and compilation for each version.

This commit adds a scaffolding for adding the classes for new versions
of Java. Unfortunately it requires several classes in different
locations. But hopefully these are infrequent enough that the
boilerplate is ok. We could consider adding a helper Gradle task to
templatize the new classes in the future if it is too cumbersome. Note
that the example for Java23 does not have anything meaningful in it yet,
it's only meant as an example until we find go through classes and
methods that were added after Java 21.

* Spotless

---------

Co-authored-by: Lorenzo Dematté <lorenzo.dematte@elastic.co>
Co-authored-by: Jack Conradson <osjdconrad@gmail.com>
Co-authored-by: Patrick Doyle <patrick.doyle@elastic.co>
2024-11-23 06:44:27 +11:00
Lorenzo Dematté
cb4485e168
[Entitlements] External IT test for checkSystemExit (#116435) (#116705) 2024-11-13 20:41:48 +11:00
Patrick Doyle
37edf70bda
Backport entitlement work up to #116473 to 8.x (#116613)
* Add initial entitlement policy parsing (#114448)

This change adds entitlement policy parsing with the following design:
* YAML file for readability and re-use of our x-content parsers
* hierarchical structure to group entitlements under a single scope
* no general entitlements without a scope or for the entire project

* Avoid double instrumentation via class annotation (#115398)

* Move entitlement jars to libs (#115883)

The distribution tools are meant to be CLIs. This commit moves the
entitlements jar projects to the libs dir, under a single
libs/entitlement root directory to keep the related jars together.

* Entitlement tools: SecurityManager scanner (#116020)

* Dynamic entitlement agent (#116125)

* Refactor: treat "maybe" JVM options uniformly

* WIP

* Get entitlement running with bridge all the way through, with qualified
exports

* Cosmetic changes to SystemJvmOptions

* Disable entitlements by default

* Bridge module comments

* Fixup forbidden APIs

* spotless

* Rename EntitlementChecker

* Fixup InstrumenterTests

* exclude recursive dep

* Fix some compliance stuff

* Rename asm-provider

* Stop using bridge in InstrumenterTests

* Generalize readme for asm-provider

* InstrumenterTests doesn't need EntitlementCheckerHandle

* Better javadoc

* Call parseBoolean

* Add entitlement to internal module list

* Docs as requested by Lorenzo

* Changes from Jack

* Rename ElasticsearchEntitlementChecker

* Remove logging javadoc

* exportInitializationToAgent should reference EntitlementInitialization, not EntitlementBootstrap.

They're currently in the same module, but if that ever changes, this code would have become wrong.

* Some suggestions from Mark

---------

Co-authored-by: Ryan Ernst <ryan@iernst.net>

* Remove unused EntitlementInternals (#116473)

* Revert "Entitlement tools: SecurityManager scanner (#116020)"

This reverts commit 023fb663de.

---------

Co-authored-by: Jack Conradson <osjdconrad@gmail.com>
Co-authored-by: Lorenzo Dematté <lorenzo.dematte@elastic.co>
Co-authored-by: Ryan Ernst <ryan@iernst.net>
2024-11-13 05:36:55 +11:00