Commit Graph

336 Commits

Author SHA1 Message Date
David Turner bfcc93a042
Anonymize AbstractRefCounted (#77208)
Today `AbstractRefCounted` has a `name` field which is only used to
construct the exception message when calling `incRef()` after it's been
closed. This isn't really necessary, the stack trace will identify the
reference in question and give loads more useful detail besides. It's
also slightly irksome to have to name every single implementation.

This commit drops the name and the constructor parameter, and also
introduces a handy factory method for use when there's no extra state
needed and you just want to run a method or lambda when all references
are released.
2021-09-03 07:59:44 +01:00
Ignacio Vera 07715438b5
Refactor of GeoShape integration tests (#77052)
This commit joins GeoFilterIT and GeoShapeIntegrationIT into one test case called GeoShapeIntegTestCase 
which is moved into the test framework.
2021-09-01 07:21:15 +02:00
Dan Hermann 90d2899323
ECS support for Grok processor (#76885) 2021-08-31 06:40:52 -05:00
Dan Hermann d648b768d8
Sync grok processor patterns with Logstash (#76752) 2021-08-24 07:34:27 -05:00
Rory Hunter d01efa4fd6
Changes to keep Checkstyle happy after reformatting (#76464)
* Reformatting to keep Checkstyle after formatting

* Configure spotless everywhere, and disable the tasks if necessary

* Add XContentBuilder helpers, fix test

* Tweaks

* Add a TODO

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-08-18 07:15:55 -04:00
sindhusp f4e3f33f77
Add (Extended)KeyUsage KeyUsage, CipherSuite & Protocol to SSL diagnostics (#65634)
This commit extends the SSL diagnostics message to include descriptions of the

- The KeyUsage and ExtendedKeyUsage of the peer's certificate
- The CipherSuite & Protocol (TLS/SSL version) of the current session 

These can be helpful in diagnosing SSL errors.

Co-authored-by: Tim Vernum <tim@adjective.org>
2021-08-16 13:19:37 +10:00
Nik Everett b86d526a35
Fix copyCurentStructure(MapXContentParser) (#76357)
This stops `MapXContentParser` from throwing an
`UnsupportedOperationException` when passed as an argument to
`XContentBuilder#copyCurrentStructure`. This is mostly useful in tests
where `Map` is a convenient way to talk about structured configuration
but the production APIs need the map to be embedded into a larger blob
of `XContent`.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2021-08-11 13:30:37 -04:00
Tim Vernum 3681240b98
In MultiCommand, show command list when required (#75993)
A MultiCommand requires that a (sub)command is provided for each
execution. Previously, the error handling for MultiCommand would
simply state "ERROR: Missing command" but give no assistance about
what commands were accepted. The user was required to pass "-help" in
order to get the command list.

This commit changes the behaviour so that the list of commands is
printed after the error message.
2021-08-09 18:27:38 +10:00
Przemyslaw Gomulka c8c5d22571
[Rest Api Compatibility] Make query registration easier (#75722)
Refactoring to NamedXContentRegistry to make it easier to register new
query builders. It removes the concept of separate compatibel
namedXContentRegistry and adds a second dimension - restApiVersion - to
registry in NamedXContentRegistry.
This makes the design similar to the solution in ObjectParser where the
field parser lookup map also needs has a restApiVersion

relates #51816
2021-08-03 10:25:21 +02:00
Tim Vernum c6a90bb5d1
Add support for KeyStore filters to ssl-config (#75407)
This commit adds the concept of a KeyStore filter to the SSL
configuration library.
Such a filter it applied to a KeyStore before it is used to construct
a KeyManager, in order to modify the entries in the keystore
(typically to remove entries that should not be used as SSL
client/server keys).
2021-08-03 13:22:13 +10:00
Rory Hunter 4bfead03a4
Fix compiler warnings in :server - part 2 (#75792)
Part of #40366. Fix a number of javac issues when linting is enforced in `server/`.
2021-08-02 15:45:53 +01:00
Albert Zaharovits b9bc7a6f3f
Configure security for the initial node cli (#74868)
This introduces a new cmd line tool that generates the security configuration
for a new node in a new cluster (as opposed to joining an existing cluster).
The security configuration consists of TLS key and certificates, which
are stored in a directory inside the config path, as well as settings appended
to the elasticsearch.yml referencing the aforementioned certs.
2021-07-21 07:45:39 +03:00
Tim Vernum 940a890958
Update "ssl-config" to support X-Pack features (#74887)
This commit upgrades the existing SSPL licensed "ssl-config" library
to include additional features that are supported by the X-Pack SSL
library.

This commit does not make any changes to X-Pack to use these new
features - it introduces them in preparation for their future use by
X-Pack.

The reindex module is updated to reflect API changes in ssl-config
2021-07-15 19:46:00 +10:00
Armin Braun 15f6cfe6e1
Dry Up XContent Parser Construction (#75114)
Cleanup duplication in how we parse byte arrrays directly.
2021-07-08 14:14:19 +02:00
Felix Barnsteiner 67fbc337ea
Json processor: allow duplicate keys (#74956) 2021-07-06 15:02:32 +02:00
David Roberts a0d26954bd
Improve efficiency of Grok circular reference check (#74814)
This change is a tweak to #74581 which removes the N^2
loop that was added in that PR.
2021-07-01 14:30:03 +01:00
Dan Hermann 7603fded04
Improve circular reference detection in grok processor (#74581) 2021-06-30 09:23:29 -05:00
Lyudmila Fokina c37f9f1c2f
Calculate SHA256 fingerprint for enrollment token (#74511)
* Calculate SHA256 fingerprint for enrollment token

A follow up PR for:
#73573

* Adding a test fix

Resolves: #74525
2021-06-24 14:42:45 +02:00
Ryan Ernst 63012c8a40
Move ParseField to o.e.c.xcontent (#73923)
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates #73784
2021-06-08 13:32:14 -07:00
Ryan Ernst 68817d7ca2
Rename o.e.common in libs/core to o.e.core (#73909)
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates #73784
2021-06-08 09:53:28 -07:00
Ignacio Vera d42c0cf016
Make methods in GeoJson and WellKnownText static (#73805)
This change makes all methods on those utility classes static.
2021-06-08 08:37:29 +02:00
Przemyslaw Gomulka 4bdd00d452
[Rest Api Compatibility] Typed endpoint for bulk api (#73571)
retrofits typed endpoint and type in request parsing
the original types removal commit
#46983

relates #51816
2021-06-07 19:36:31 +02:00
Ryan Ernst f98b374cf6
Revert "Upgrade Azure SDK and Jackson (#72833) (#72995)" (#73837)
The recent upgrade of the Azure SDK has caused a few test failures that
have been difficult to debug and do not yet have a fix. In particular, a
change to the netty reactor resolving
(https://github.com/reactor/reactor-netty/issues/1655). We need to wait
for a fix for that issue, so this reverts commit
6c4c4a0ecb.

relates #73493
2021-06-07 10:20:46 -07:00
Ryan Ernst 64054de1ac
Rename bootstrap package in core jar (#73788)
The org.elasticsearch.bootstrap package exists in server with classes
for starting up Elasticsearch. The elasticsearch-core jar has a handful
of classes that were split out from there, namely java version parsing
and jarhell. This commit moves those classes to a new
org.elasticsearch.jdk package so as to not split the server owned
bootstrap package.

relates #73784
2021-06-07 08:14:44 -07:00
Ryan Ernst e81323e147
Move plugin classloader to its own package (#73786)
The plugin classloader exists in its own jar file for legacy reasons,
and while it should go away in the future, it currently duplicates the
package name of the rest of the plugin classes. This commit moves the
classloader into its own unique package.

relates #73784
2021-06-07 08:12:24 -07:00
Nhat Nguyen d6d5d0d66d Fix assertion message in directFieldAsBase64 method
Relates #73804
2021-06-06 22:56:15 -04:00
Nhat Nguyen cb1144886f
Allow build XContent directly from Writable (#73804)
Today, writing a Writable value to XContent in Base64 format performs 
these steps: (1) create a BytesStreamOutput, (2) write Writable to that
output, (3) encode a copy of bytes from that output stream, (4) create a
string from the encoded bytes, (5) write the encoded string to XContent. 
These steps allocate/use memory 5 times than writing the encode chars
directly to the output of XContent.

This API would help reduce memory usage when storing a large response 
of an async search.

Relates #67594
2021-06-06 12:11:52 -04:00
Ryan Ernst 6c4c4a0ecb
Upgrade Azure SDK and Jackson (#72833) (#72995)
This commit upgrades the Azure SDK to 12.11.0 and Jackson to 2.12.2. The
Jackson upgrade must happen at the same time due to Azure depending on
this new version of Jackson.

closes #66555
closes #67214

Co-authored-by: Francisco Fernández Castaño <francisco.fernandez.castano@gmail.com>
2021-05-27 07:55:18 -07:00
Marten 8e46acf6ba
Fix typo in Rectangle() error message (#73124)
Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2021-05-18 10:58:44 -04:00
Michael Bischoff d74885244e
Dissect parsing: An `%` occurring in the delimiter causes incorrect capture of the `${key}` that follows (#72876)
* Extending parser Regex Patterns to take into account % appearing in the input.
* Adding example failure from the ER to the tests
2021-05-18 09:04:48 +02:00
Ryan Ernst 8cd3944a0a
Revert "Upgrade Azure SDK and Jackson (#72833)"
This reverts commit dca0e92bef.
2021-05-06 20:51:31 -07:00
Ryan Ernst dca0e92bef
Upgrade Azure SDK and Jackson (#72833)
This commit upgrades the Azure SDK to 12.11.0 and Jackson to 2.12.2. The
Jackson upgrade must happen at the same time due to Azure depending on
this new version of Jackson.

closes #66555
closes #67214
2021-05-06 20:36:42 -07:00
Albert Zaharovits aba322745b
[TEST] Updated smoke test JDK's trusted certs (#72594)
The list of trusted CAs in the latest OpenJDK builds has changed:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8243559
This PR updates the default jdk trust config smoke test.

Closes #71717
2021-05-04 12:53:29 +03:00
Alan Woodward b27eaa38dc
Remove 'external values', and replace with swapped out XContentParsers (#72203)
The majority of field mappers read a single value from their positioned
XContentParser, and do not need to call nextToken. There is a general
assumption that the same holds for any multifields defined on them, and
so the XContentParser is passed down to their multifields builder as-is.
This assumption does not hold for mappers that accept json objects,
and so we have a second mechanism for passing values around called
'external values', where a mapper can set a specific value on its context
and child mappers can then check for these external values before reading
from xcontent. The disadvantage of this is that every field mapper now
needs to check its context for external values. Because the values are
defined by their java class, we can also know that in the vast majority of
cases this functionality is unused. We have only two mappers that actually
make use of this, CompletionFieldMapper and GeoPointFieldMapper.

This commit removes external values entirely, and replaces it with the ability
to pass a modified XContentParser to multifields. FieldMappers can just check
the parser attached to their context for data and don't need to worry about
multiple sources.

Plugins implementing field mappers will need to take the removal of external
values into account. Implementations that are passing structured objects
as external values should instead use ParseContext.switchParser and
wrap the objects using MapXContentParser.wrapObject().

GeoPointFieldMapper passes on a fake parser that just wraps its input data
formatted as a geohash; CompletionFieldMapper has a slightly more complicated
parser that in general wraps its metadata, but if textOrNull() is called without
the parser being advanced just returns its text input.

Relates to #56063
2021-04-29 09:17:18 +01:00
David Kyle 351a824937
Mute DefaultJdkTrustConfigTests (#72208)
For #71717
2021-04-26 10:08:10 +01:00
Alan Woodward 289d202cb2
Rework geo mappers to index value by value (#71696)
The various geo field mappers are organised in a hierarchy that shares
parsing and indexing code. This ends up over-complicating things,
particularly when we have some mappers that accept multiple values
and others that only accept singletons. It also leads to confusing
behaviour around ignore_malformed behaviour: geo fields will ignore
all values if a single one is badly formed, while all other field mappers
will only ignore the problem value and index the rest. Finally, this
structure makes adding index-time scripts to geo_point needlessly
complex.

This commit refactors the indexing logic of the hierarchy to move the
individual value indexing logic into the concrete implementations,
and aligns the ignore_malformed behaviour with that of other mappers.

It contains two breaking changes:

* The geo field mappers no longer check for external field values on the
  parse context. This added considerable complication to the refactored
  parse methods, and is unused anywhere in our codebase, but may
  impact plugin-based field mappers which expect to use geo fields
  as multifields
* The geo_point field mapper now passes geohashes to its multifields
  one-by-one, instead of formatting them into a comma-delimited
  string and passing them all at once. Completion multifields using
  this as an input should still behave as normal because by default
  they would split this combined geohash string on the commas in any
  case, but keyword subfields may look different.

Fixes #69601
2021-04-19 12:38:01 +01:00
Armin Braun 74c20f1bc8
Assert That AbstractRefCounted#decRef Does not Throw on Closing (#70373)
We should not allow exceptions in the internal close I think.
If the exceptions thrown here are fatal then they should just be errors
instead as well. If they are not and need handling then the handling should happen
in the `closeInternal` call. Otherwise, all callers of `decRef` must be aware of
necessary exception handling which would make reasoning about the behavior
of exceptions in `#closeInternal` extremely complicated.
2021-04-17 07:39:48 +02:00
Jack Conradson 065d7696c2
Add missing boolean array to unknown value writers for xcontent (#71651)
This change adds the ability to call value on an XContentBuilder and consume a boolean[]. This was 
missing from the set of other writers for the unknown value call.
2021-04-13 12:49:14 -07:00
Przemyslaw Gomulka 45ef2ab63c
Make restApiVersion on XContentBuilder final (#70878)
When passing in restApiVersion during creation of XContentBuilder
it makes it more clear that this field is final.
This prevents accidental change of the version during the xcontent
creation.
The withCompatibleVersion method can also be removed, since the field
only needs to be set in constructor.

relates #51816
2021-03-29 10:28:39 +02:00
Nik Everett 7693aeafcd
Banish build-eclipse (#70696)
Move it to `out` so we can be like the cool kids.
2021-03-24 16:00:52 -04:00
Przemyslaw Gomulka a54685cf48
Parsing: Validate that fields are not registered twice (#70243)
It is possible that a developer accidentally declares two parsers for the
same field name.
This commit introduces a validation to prevent that from happening.
2021-03-18 07:45:44 +01:00
Rory Hunter d181b947c2
Remove depth limit from checkstyle negation rule (#70274)
The Checkstyle rule that bans unary negation in favour of an explicit
`== false` has a `maximumDepth` of 2 configured, which meant that it
didn't catch all violations. The `maximumDepth` isn't required (actually
it has a really high default), so this change removes the limit and
fixes the resulting violations.
2021-03-10 22:06:50 +00:00
Przemyslaw Gomulka 9ad9c781de
Add compatible logging when parsing a compatible field (#69539)
A #68808 introduced a possibility to declare fields which will be only available to parsing when a compatible API was used.

This commit replaces deprecated log with compatible logging when a 'compatible only' field was used. Also includes a refactoring of LoggingDeprecationHandler method names

relates #51816
2021-03-09 12:29:40 +01:00
Przemyslaw Gomulka 8d09fbf82b
Allow for field declaration for future rest versions (#69774)
When renaming/removing a field, a new field might be declared which
should be parseable starting with the current version.
This commit changes the way ParseField is declared for compatible
Version. Instead of concrete version a boolean function has to be used
to indicate for what version a field is parseable. The onOrAfter and
equalTo functions are declared on RestApiVersion to allow for
this.
2021-03-05 08:27:00 +01:00
Joe Gallo f2763edb2d
Additional renames of RestApiCompatibleVersion to RestApiVersion (#69913) 2021-03-03 13:56:03 -05:00
Joe Gallo 638735bbb9
Rename RestApiCompatibleVersion to RestApiVersion (#69897) 2021-03-03 12:17:48 -05:00
Armin Braun bb77ab46e0
Stop Ignoring Exceptions on Close in Network Code (#69665)
We should not be ignoring and suppressing exceptions on releasing
network resources quietly in these spots.

Co-authored-by: David Turner <david.turner@elastic.co>
2021-03-01 14:38:18 +01:00
Armin Braun 1baa0619d8
Add Ref Count Assertion to Page (#69599)
Added this assertion to have an easier time debugging
work on #67502 and found that we were accessing `refcount == 0`
bytes in the `SSLOutboundBuffer` so I fixed that buffer to not
keep references to released pages.
2021-02-25 17:57:59 +01:00
Armin Braun c2370ffde5
Add Leak Tracking Infrastructure (#67688)
This commit adds leak tracking infrastructure that enables assertions
about the state of objects at GC time (simplified version of what Netty
uses to track `ByteBuf` instances).
This commit uses the infrastructure to improve the quality of leak
checks for page recycling in the mock nio transport (the logic in
`org.elasticsearch.common.util.MockPageCacheRecycler#ensureAllPagesAreReleased`
does not run for all tests and tracks too little information to allow for debugging
what caused a specific leak in most cases due to the lack of an equivalent of the added
`#touch` logic).

Co-authored-by: David Turner <david.turner@elastic.co>
2021-02-25 11:41:48 +01:00
Przemyslaw Gomulka f22adc47d8
Refactor ObjectParser and CompatibleObjectParser to support REST Compatible API (#68808)
In order to support compatible fields when parsing XContent additional information has to be set during ParsedField declaration.
This commit adds a set of RestApiCompatibleVersion on a ParsedField in order to specify on which versions a field is supported. By default ParsedField is allowed to be parsed on both current and previous major versions.

ObjectParser - which is used for constructing objects using 'setters' - has a modified fieldParsersMap to be Map of Maps. with key being RestApiCompatibility. This allows to choose set of field-parsers as specified on a request.
Under RestApiCompatibility.minimumSupported key, there is a map that contains field-parsers for both previous and current versions.
Under RestApiCompatibility.current there will be only current versions field (compatible fields not a present)

ConstructingObjectParser - which is used for constructing objects using 'constructors' - is modified to contain a map of Version To constructorArgInfo , declarations of fields to be set on a constructor depending on a version

relates #51816
2021-02-16 11:33:11 +01:00