Commit graph

306 commits

Author SHA1 Message Date
Lorenzo Dematté
591a08f506
[Entitlements] Validation checks on paths (#126852) (#127055)
With this PR we restrict the paths we allow access to, forbidding plugins to specify/request entitlements for reading or writing to specific protected directories.

I added this validation to EntitlementInitialization, as I wanted to fail fast and this is the earliest occurrence where we have all we need: PathLookup to resolve relative paths, policies (for plugins, server, agents) and the Paths for the specific directories we want to protect.

Relates to ES-10918
2025-04-19 00:44:49 +10:00
Mark Vieira
017d7bfcd8
Add inbound_network entitlement to repository-hdfs plugin (#123907) (#124027) 2025-03-05 05:44:07 +11:00
Lorenzo Dematté
e30437206d
[8.18] Fix hdfs-related IT tests for java24 (#122044) (#122989)
* Fix hdfs-related IT tests for java24 (#122044)

* Have ASM recompute frames on patched classes
2025-02-20 20:55:26 +11:00
Lorenzo Dematté
6e8074ed6f
[Entitlements] Instrumentation of NIO Files and Channels (#122816 and #122591) (#122986) (#122993)
* [Entitlements] Add check functions for NIO Files (#122591)

* [Entitlements] Instrumentation of NIO file channels (#122816)

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-02-20 20:45:01 +11:00
Patrick Doyle
0205d3fc86
Entitlements: manage_threads (#122261) (#122533)
* Entitlements: manage_threads (#122261)

* Refactor: protected -> private

* Initial thread-related entitlements

* Entitlements from manual test runs

* Refactor: notEntitled method

* Entitlements reporting mode

* Entitlements from CI

* Revert "Entitlements reporting mode"

This reverts commit 443ca767333269a73accd0cedf9ca6c6ac51698a.

* Remove unnecessary EntitledActions.newThread

* Don't log in entitlements ITs by default

* Import SuppressForbidden

* Respond to PR comments

* Move manage_threads tests to their own file

* Move ForkJoinPool.setParallelism to VersionSpecificManageThreadsActions

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-02-14 09:18:28 +11:00
Ryan Ernst
3537349096
Rename environment dir accessors (#121803) (#121836)
* Rename environment dir accessors (#121803)

The node environment has many paths. The accessors for these currently use a "file" suffix, but they are always directories. This commit renames the accessors to make it clear these paths are directories.

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-02-06 10:28:25 +11:00
Moritz Mack
2b2ae57d04
[Entitlements] Instrument write access to System properties (#120357) (#120544)
Instrument write access to System properties by means of the `WriteSystemPropertiesEntitlement`.
`System.setProperties(Properties)` is always denied.

Part of #ES-10359
2025-01-22 05:13:42 +11:00
Lorenzo Dematté
d223dd0118
[Entitlements] Refactor Network Entitlement (#120391) (#120478) 2025-01-21 06:13:02 +11:00
Lorenzo Dematté
b6994cc423
[Entitlements] Network access checks for NIO classes (#120138) (#120394) 2025-01-20 23:22:54 +11:00
Lorenzo Dematté
1d7872be05
[8.x] Add Hdfs patcher to replace deprecated Subject method (#119781) 2025-01-09 07:54:55 +01: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
Rene Groeschke
110681a9c4
Fix hadoop client api patch configuration cache compatibility (#119324) (#119340) 2024-12-30 17:01:46 +01:00
Ryan Ernst
adf66beeec
Patch Shell class in hdfs to not execute (#119189) (#119243)
Shell utility in hdfs tries to execute a local script statically to
determine whether setsid is available. With the security manager this
doesn't work, but hdfs catches the SecurityException and assumes false.
With entitlements this doesn't work since hdfs does not know about our
NotEntitledException.

This commit reworks the patching of hdfs-client-api to use asm. It then
adds patching of hdfs' Shell class to replace the method that tries to
execute.
2024-12-24 09:13:58 +11:00
David Turner
c31ec176fd
Remove unused BlobStore#deleteBlobsIgnoringIfNotExists (#118245)
This method is never called against a general `BlobStore`, we only use
it in certain implementations for which a bulk delete at the `BlobStore`
level makes sense. This commit removes the unused interface method.
2024-12-09 15:59:19 +00:00
Rene Groeschke
617644f781
[8.x] [Gradle] Remove static use of BuildParams (#115122) (#117436)
* [Gradle] Remove static use of BuildParams (#115122)

Static fields dont do well in Gradle with configuration cache enabled.

- Use buildParams extension in build scripts
- Keep BuildParams.ci for now for easy serverless migration
-  Tweak testing doc

(cherry picked from commit 13c8aaeffa)

# Conflicts:
#	TESTING.asciidoc
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java
#	build.gradle
#	modules/ingest-geoip/qa/full-cluster-restart/build.gradle
#	qa/mixed-cluster/build.gradle
#	x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle
#	x-pack/plugin/eql/qa/rest/build.gradle
#	x-pack/plugin/fleet/qa/rest/build.gradle
#	x-pack/plugin/kql/build.gradle
#	x-pack/plugin/mapper-unsigned-long/build.gradle
#	x-pack/plugin/ml/qa/multi-cluster-tests-with-security/build.gradle
#	x-pack/plugin/security/qa/multi-cluster/build.gradle
#	x-pack/plugin/sql/qa/jdbc/build.gradle
#	x-pack/plugin/transform/qa/multi-cluster-tests-with-security/build.gradle

* fix merge issue

* Fix more merge conflicts

* Fix merge conflicts

* Update TESTING.asciidoc
2024-11-25 18:28:51 +01:00
Jake Landis
4174c89f8a
bump hadoop hdfs to 3.4.1 (#117263) (#117395)
This commit bump hadoop hdfs to 3.4.1 (for repository-hdfs) .
2024-11-23 10:06:58 +11:00
Rene Groeschke
28b2f5248f
[Gradle] Update shadow plugin (#116826) (#116876)
- The shadow plugin has changed ownership and plugin id.
- Make some formatting of poms more reproducible

(cherry picked from commit def490ef85)
2024-11-16 15:06:40 +01:00
Mark Vieira
0279c0a909
Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
David Turner
8f07d60c2c
Fix trappy timeouts in o.e.a.a.cluster.* (#112674)
Removes all usages of `TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT` in
cluster-related APIs in `:server`.

Relates #107984
2024-09-10 08:17:09 +01:00
David Turner
5662f988b2
Remove trappy timeouts in snapshot APIs (#109828)
Wholesale fix of every `TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT` in
`o.e.snapshots` and `o.e.repositories`, just pulling them up to the REST
layer (where they become API params), the test suite (where they become
`TEST_REQUEST_TIMEOUT`), or some other place where an explicit value is
available.

Relates #107984
2024-06-21 07:11:12 +10:00
Rene Groeschke
09583d99b1
Do not run :plugins:repository-hdfs:test on windows (#106765)
before refactoring the hdfs test fixture setup this was implicitly
achieved by disabling test task for docker agent not available on
windows.
2024-03-27 03:11:25 -04:00
Rene Groeschke
ceb2701719
Ignore repository-hdfs integ tests in fips mode (#106762)
Fixes https://github.com/elastic/elasticsearch/issues/106757
2024-03-26 10:31:38 -04:00
Rene Groeschke
b39b3731a7
Port krb5kdc to test container and rework hdfs handling (#106228)
This ports our krb5kdc test fixture to test container and reworks hdfs handling to also be based on test containers.
The yaml rest tests that are using hdfs required introducing variable substitution in yamlresttestparser handling.
2024-03-26 08:39:39 +01:00
Armin Braun
7a63a666e2
Dry up test code that extracts TotalHits from SearchResponse (#103269)
We have the pattern of getting a response only for its `TotalHits` in a couple of spots,
some of them still leaking the `SearchResponse`.
This PR dries up those that I could quickly identify to use the new utilty method to simplify this pattern
or just moves the code to `assertHitCount` where possible.
2023-12-11 18:25:22 +01:00
Yang Wang
b9c29807ec
Extract repositories metrics into its own class (#103034)
This PR is a follow up of
https://github.com/elastic/elasticsearch/pull/102505#discussion_r1402957598
that move the repositories metrics management into its own class which
is then passed around instead of relying on the raw meterRegistry and
string metric names.
2023-12-07 18:26:17 -05:00
Rene Groeschke
ab0bb4889a
Fix :plugins:repository-hdfs:forbiddenApisJavaRestTest (#102983)
Reworking forbiddenApis check to use gradle worker api exposed a bug in
how we resolve krb5kdc keytab information. This fixes the depenendency to krb5kdc keytab configuration and
its builtBy task.

This also changes the usage of krb5kdc keytab files to be passed directly to task classpath as
they are only required at runtime and directly having them as part of javaRestTestRuntimeOnly would mean precommit
requires krb5kdc compose up which we definitely not want
2023-12-06 08:33:27 +01:00
David Turner
824d06c8cf
Use random purpose in blob store repository tests (#102789)
Today many blob store repository tests specify that the operations they
perform have purpose `OperationPurpose#SNAPSHOT`, but most of these
tests do not care about the purpose of these operations. This commit
switches them to using a random purpose to highlight that the purpose is
unimportant to the test.
2023-11-29 20:21:07 -08:00
Armin Braun
cdc83ad29b
Add shorthand for prepareIndex to test infrastructure (#101187)
Same as #101175, shorten `client().prepareIndex(index)` and
`client().prepareIndex().setIndex(index)` via a test utility.
Saves lots of code now and sets up some follow-up simplifcations.
2023-11-23 15:47:36 +01:00
Armin Braun
a9c286b25c
Collapse verbose .execute().actionGet() calls in tests (#102502)
Cleaning this up a little even though it's still quite horrible.
`.get()` in this API actually means `actionGet()` so to speak.
I think a good first step to cleaning this up is to at least reduce
the duplication though and save 1k lines.
2023-11-23 10:10:10 +01:00
Mark Vieira
ee1467d4ff
Improve test avoidance (#101081) 2023-10-26 12:16:06 -07:00
Armin Braun
3945ee75d0
Use assertAcked more (#101201)
Just found that we have a lot of inconsistency and needless verbosity
here in tests. We can just use `assertAcked` in a couple spots
to save `.get`, `.actionGet` etc., especially with the signature
change I added here.
2023-10-23 19:48:10 +02:00
Yang Wang
5628392fa5
Differentiate stats for the same blobstore operation with purposes (#99615)
Today blobstore stats are collected against each HTTP operation, e.g.
Get, List. This is not granular enough because the same HTTP operration
can be performed for different purposes, e.g. cluster state, indices or
translog. This PR adds a new Purpose enum to provide further breakdown
for the same HTTP operation. 

Relates: ES-6800
2023-10-02 06:37:08 -04:00
Francisco Fernández Castaño
f6a2b5c9ef
Add bulk delete method to BlobStore interface and implementations (#98948) 2023-08-29 12:25:03 +02:00
Piotr Stankowski
a462deaccf
HDFS plugin: add replication_factor param (#94132)
Allows users of the HDFS repository plugin to configure the replication factor for files created by the repository implementation at repository creation time.

---------

Co-authored-by: James Baiera <james.baiera@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2023-08-03 14:13:45 -04:00
Armin Braun
dd7d381922
Dry up getting cluster admin client in tests (#96952)
Drying this up further and adding the same short-cut for single node
tests. Dealing with most of the spots that I could grab via automatic
refactorings.
2023-06-22 14:27:23 +02:00
David Turner
350beea181
Arbitrary bytes in blob store register (#96019)
Today the blob store register supports recording only a `long`,
represented as an 8-byte blob. We need to store a little more data in
the register, so this commit generalises things to work with a
`BytesReference` directly.
2023-05-16 06:16:21 -04:00
Przemyslaw Gomulka
257d633f2d
Add slf4j-nop in order to prevent startup warnings (#95459)
currently when Elasticsearch starts up there are warnings on the console complaining about SLF4J providers not found.
this is emitted twice
1 - when repository-azure module is loaded
2 - when xpack-security (depending on transport-netty) module is loaded 

This commits adds a slf4j-nop to fix that warning

related to #93714
and #93878
2023-05-05 09:38:34 +02:00
Rory Hunter
fe1083f6c5
Upgrade spotless plugin to 6.17.0 (#94994)
Fixes #82794. Upgrade the spotless plugin, which addresses the issue
around formatting `instanceof` expressions. Formatting of statements
including lambdas seems to have improved too.
2023-04-04 10:03:32 +01:00
Rene Groeschke
e735455431
Provide hints to Gradle Task.onlyIf declarations (#94953)
* Update gradle enterprise plugin to show skip reasons in build scans
* Unify OS specific handling in build logic
2023-03-31 23:57:55 +02:00
David Turner
95daf492fc
Async blob-store compare-and-exchange API (#94092)
Further work towards the S3 compare-and-exchange implementation showed
that we would like this API to permit async operations. This commit
moves to an async API.

Also, this change made it fairly awkward to use an exception to deliver
to the caller the indication that the current value could not be read,
so this commit adjusts things to use `OptionalLong` throughout as
suggested in the discussion on #93955.
2023-02-27 08:41:34 +00:00
Armin Braun
a6f63df111
Introduce BlobStoreRepository CAS Mechanism (#93825)
Only for testing purposes through the `FsRepository` for now and rather simple,
but should get the job done and technically be correct for a compliant NFS implementation.

Co-authored-by: David Turner <david.turner@elastic.co>
2023-02-16 14:26:12 +00:00
Joe Gallo
582f1be95e
Update log4j2 LICENSE and NOTICE files (#93611) 2023-02-09 08:53:43 -05:00
Armin Braun
f2760c6e18
Nicer buffer handling (#93491)
Some optimisations that I found when reusing searchable snapshot code elsewhere:
* Add an efficient input stream -> byte buffer path that avoids allocations + copies for heap buffers, this is non-trivial in its effects IMO
  * Also at least avoid allocations and use existing thread-local buffer when doing input stream -> direct bb
  * move `readFully` to lower level streams class to enable this
* Use same thread local direct byte buffer for frozen and caching index input instead of constantly allocating new heap buffers and writing those to disk inefficiently
2023-02-06 10:55:56 +01:00
Artem Prigoda
2bc7398754
Use Strings.format instead of String.format(Locale.ROOT, ...) in tests (#92106)
Use local-independent `Strings.format` method instead of `String.format(Locale.ROOT, ...)`. 
Inline `ESTestCase.forbidden` calls with `Strings.format` for the consistency sake.
Add `Strings.format` alias in `common.Strings`
2023-01-03 19:28:27 +01:00
Mark Vieira
c2eda511de
Add JUnit rule based integration test cluster orchestration framework (#92379)
This commit adds a new test framework for configuring and orchestrating
test clusters for both Java and YAML REST testing. This will eventually
replace the existing "test-clusters" Gradle plugin and the build-time
cluster orchestration.
2022-12-21 15:33:46 -08:00
Keith Massey
b8780d3b24
Align all usages of protobuf to be 3.21.9 (#92123)
Updating repository-hdfs, repository-gcs, and vector-tile to all use the same more recent protobuf.
2022-12-07 11:55:18 -06:00
Rene Groeschke
43a0377735
Update forbiddenapis to 3.4 (#90624)
Fix breaking changes to source validation after change in default jdk rule set
2022-10-06 16:52:06 +02:00
Simon Cooper
71455f87d5
Change plugins to use elasticsearch logging (#90227)
Change hdfs, gce, azure, ec2 plugins to use ES logging API
2022-09-29 10:59:31 +01:00
Armin Braun
97c533a562
Increase snaphot pool max size to 10 (#90282)
As discussed, we can be up to twice as fast without increasing CPU use
much on high latency blob stores so increasing the pool size to 10 here
to better utilize larger data nodes.
2022-09-23 17:06:57 +02:00
Yoann Rodière
841ac8e43a
Upgrade Apache Commons Logging to 1.2 (#85745)
* Upgrade to Apache Commons Logging 1.2 (#40305)
* Clarify that Apache HTTP/commons-* dependencies are not just for tests
2022-08-10 13:19:15 -04:00