Skip to content

Commit 70fd552

Browse files
Merge branch 'main' into faster-translog
2 parents 5d0e727 + 4ba94c7 commit 70fd552

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

docs/changelog/127798.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127798
2+
summary: Handle streaming request body in audit log
3+
area: Audit
4+
type: bug
5+
issues: []

docs/release-notes/known-issues.md

+7
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ This issue will be fixed in a future patch release (see [PR #126990](https://git
2727
```
2828
2929
For information about editing your JVM settings, refer to [JVM settings](https://www.elastic.co/docs/reference/elasticsearch/jvm-settings).
30+
31+
* Users upgrading from an Elasticsearch cluster that had previously been on a version between 7.10.0 and 7.12.1 may see that Watcher will not start on 9.x. The solution is to run the following commands in Kibana Dev Tools (or the equivalent using curl):
32+
```
33+
DELETE _index_template/.triggered_watches
34+
DELETE _index_template/.watches
35+
POST /_watcher/_start
36+
```

x-pack/plugin/security/qa/audit/src/javaRestTest/java/org/elasticsearch/xpack/security/audit/AuditIT.java

+23
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
package org.elasticsearch.xpack.security.audit;
99

10+
import org.apache.http.entity.ContentType;
11+
import org.apache.http.entity.StringEntity;
1012
import org.elasticsearch.client.Request;
1113
import org.elasticsearch.client.Response;
1214
import org.elasticsearch.common.bytes.BytesReference;
@@ -27,6 +29,7 @@
2729
import org.junit.ClassRule;
2830

2931
import java.io.IOException;
32+
import java.nio.charset.StandardCharsets;
3033
import java.time.Instant;
3134
import java.time.ZonedDateTime;
3235
import java.time.format.DateTimeFormatter;
@@ -37,6 +40,7 @@
3740
import java.util.concurrent.TimeUnit;
3841
import java.util.function.Predicate;
3942

43+
import static org.hamcrest.Matchers.allOf;
4044
import static org.hamcrest.Matchers.containsString;
4145
import static org.hamcrest.Matchers.hasEntry;
4246
import static org.hamcrest.Matchers.hasKey;
@@ -103,6 +107,25 @@ public void testFilteringOfRequestBodies() throws Exception {
103107
});
104108
}
105109

110+
public void testAuditAuthenticationSuccessForStreamingRequest() throws Exception {
111+
final Request request = new Request("POST", "/testindex/_bulk");
112+
request.setEntity(new StringEntity("""
113+
{"index":{}}
114+
{}
115+
""", ContentType.create("application/x-ndjson", StandardCharsets.UTF_8)));
116+
executeAndVerifyAudit(
117+
request,
118+
AuditLevel.AUTHENTICATION_SUCCESS,
119+
event -> assertThat(
120+
event,
121+
allOf(
122+
hasEntry(LoggingAuditTrail.AUTHENTICATION_TYPE_FIELD_NAME, "REALM"),
123+
hasEntry(LoggingAuditTrail.REQUEST_BODY_FIELD_NAME, "Request body had not been received at the time of the audit event")
124+
)
125+
)
126+
);
127+
}
128+
106129
private void executeAndVerifyAudit(Request request, AuditLevel eventType, CheckedConsumer<Map<String, Object>, Exception> assertions)
107130
throws Exception {
108131
Instant start = Instant.now();

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/audit/AuditUtil.java

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class AuditUtil {
2727

2828
public static String restRequestContent(RestRequest request) {
2929
if (request.hasContent()) {
30+
if (request.isStreamedContent()) {
31+
return "Request body had not been received at the time of the audit event";
32+
}
3033
var content = request.content();
3134
try {
3235
return XContentHelper.convertToJson(content, false, false, request.getXContentType());

0 commit comments

Comments
 (0)