-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add DLS stats to _security/stats
#135271
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
Merged
Merged
Add DLS stats to _security/stats
#135271
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ca99025
Add role stats to `_security/stats`
szybia 5d1135a
fix yaml tests
szybia 8dd801f
Merge remote-tracking branch 'upstream/main' into security-stats-with…
szybia fadf041
Update docs/changelog/135271.yaml
szybia 9fca013
Merge remote-tracking branch 'upstream/main' into security-stats-with…
szybia 06f3f98
update transport
szybia 61d6bee
return just DLS stats
szybia eed12d1
Merge remote-tracking branch 'upstream/main' into security-stats-with…
szybia 1d43baa
update transport
szybia f3c503d
spotless
szybia 8459878
changelog and no birthday problems (no one wants those)
szybia 31892e0
Merge remote-tracking branch 'upstream/main' into security-stats-with…
szybia 698bb78
update transport
szybia 8559de0
Merge remote-tracking branch 'upstream/main' into security-stats-with…
szybia 6ac2653
update transport
szybia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 135271 | ||
| summary: Add DLS stats to `_security/stats` | ||
| area: Authorization | ||
| type: enhancement | ||
| issues: [] |
1 change: 1 addition & 0 deletions
1
server/src/main/resources/transport/definitions/referable/roles_security_stats.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 9176000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| contextual_ai_service,9175000 | ||
| roles_security_stats,9176000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...org/elasticsearch/xpack/core/security/action/stats/GetSecurityStatsNodeResponseTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.core.security.action.stats; | ||
|
|
||
| import org.elasticsearch.cluster.node.DiscoveryNodeUtils; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| public class GetSecurityStatsNodeResponseTests extends AbstractWireSerializingTestCase<GetSecurityStatsNodeResponse> { | ||
|
|
||
| @Override | ||
| protected Writeable.Reader<GetSecurityStatsNodeResponse> instanceReader() { | ||
| return GetSecurityStatsNodeResponse::new; | ||
| } | ||
|
|
||
| @Override | ||
| protected GetSecurityStatsNodeResponse createTestInstance() { | ||
| return new GetSecurityStatsNodeResponse( | ||
| DiscoveryNodeUtils.builder(randomAlphaOfLength(10)).ephemeralId(randomAlphanumericOfLength(10)).build(), | ||
| randomBoolean() ? null : Map.of("key", randomAlphaOfLength(5)) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| protected GetSecurityStatsNodeResponse mutateInstance(GetSecurityStatsNodeResponse instance) throws IOException { | ||
| final var node = instance.getDiscoveryNode(); | ||
| final var value = Objects.requireNonNullElse(instance.getRolesStoreStats(), Map.of()).get("key"); | ||
| return switch (randomIntBetween(0, 1)) { | ||
| case 0 -> new GetSecurityStatsNodeResponse( | ||
| DiscoveryNodeUtils.builder(randomValueOtherThan(node.getId(), () -> randomAlphaOfLength(10))) | ||
| // DiscoverNode#hashCode only tests ephemeralId, so make sure to change it too | ||
| .ephemeralId(randomValueOtherThan(node.getEphemeralId(), () -> randomAlphanumericOfLength(10))) | ||
| .build(), | ||
| instance.getRolesStoreStats() | ||
| ); | ||
| case 1 -> new GetSecurityStatsNodeResponse(node, Map.of("key", randomValueOtherThan(value, () -> randomAlphaOfLength(5)))); | ||
| default -> throw new IllegalStateException("Unexpected value"); | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ck/plugin/src/yamlRestTest/resources/rest-api-spec/test/security/stats/20_roles_stats.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| "Security stats return just DLS stats": | ||
| - requires: | ||
| cluster_features: [ "security_stats_endpoint" ] | ||
| reason: Introduced in 9.2 | ||
|
|
||
| - do: | ||
| security.get_stats: {} | ||
|
|
||
| - set: | ||
| nodes._arbitrary_key_: node_id | ||
| - length: { nodes.$node_id: 1 } | ||
| - length: { nodes.$node_id.roles: 1 } | ||
| - length: { nodes.$node_id.roles.dls: 1 } | ||
| - length: { nodes.$node_id.roles.dls.bit_set_cache: 8 } | ||
| - gte: { nodes.$node_id.roles.dls.bit_set_cache.count: 0 } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.