Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,10 @@ manifest:
tests/appsec/test_shell_execution.py::Test_ShellExecution::test_track_shell_exec: irrelevant (No method for shell execution in Java)
tests/appsec/test_shell_execution.py::Test_ShellExecution::test_truncate_1st_argument: bug (APPSEC-55672)
tests/appsec/test_shell_execution.py::Test_ShellExecution::test_truncate_blank_2nd_argument: bug (APPSEC-55672)
tests/appsec/test_span_tags_headers.py: bug (APPSEC-61286)
tests/appsec/test_span_tags_headers.py:
- weblog_declaration:
"*": v1.60.0-SNAPSHOT
spring-boot-3-native: irrelevant (GraalVM. Tracing support only)
tests/appsec/test_suspicious_attacker_blocking.py::Test_Suspicious_Attacker_Blocking:
- weblog_declaration:
"*": v1.39.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object AppSecRoutes {
val span = tracer.buildSpan("test-span").start
span.setTag("test-tag", "my value")
withSpan(span) {
complete("Hello world!\n")
complete(HttpEntity(ContentTypes.`text/plain(UTF-8)`, "Hello world!\n"))
}
}
} ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ public class MyResource {
private final CryptoExamples cryptoExamples = new CryptoExamples();

@GET
public String hello() {
public Response hello() {
var tracer = GlobalTracer.get();
Span span = tracer.buildSpan("test-span").start();
span.setTag("test-tag", "my value");
try {
return "Hello world!\n";
return Response.ok("Hello world!\n")
.header("Content-Type", "text/plain")
.header("Content-Length", "13")
.build();
} finally {
span.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AppSecController @Inject()(cc: MessagesControllerComponents, ws: WSClient,
span.setTag("test-tag", "my value")
withSpan(span) {
Results.Ok("Hello world!\n")
.withHeaders("Content-Type" -> "text/plain", "Content-Length" -> "13")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static void main(String[] args) throws Exception {
Span span = tracer.buildSpan("test-span").start();
span.setTag("test-tag", "my value");
try {
ctx.getResponse().getHeaders().set("Content-Length", "13");
ctx.getResponse().send("text/plain", "Hello world!\n");
} finally {
span.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ public class MyResource {
private final CryptoExamples cryptoExamples = new CryptoExamples();

@GET
public String hello() {
public Response hello() {
var tracer = GlobalTracer.get();
Span span = tracer.buildSpan("test-span").start();
span.setTag("test-tag", "my value");
try {
return "Hello world!\n";
return Response.ok("Hello world!\n")
.header("Content-Type", "text/plain")
.header("Content-Length", "13")
.build();
} finally {
span.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public class WebController {
private static final Logger logger = LoggerFactory.getLogger(App.class);

@RequestMapping("/")
String home() {
return "Hello world!\n";
ResponseEntity<String> home() {
return ResponseEntity.ok()
.contentType(MediaType.TEXT_PLAIN)
.contentLength(13)
.body("Hello world!\n");
}

@RequestMapping("/healthcheck")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ public class App {
int PRODUCE_CONSUME_THREAD_TIMEOUT = 5000;

@RequestMapping("/")
String home(HttpServletResponse response) {
ResponseEntity<String> home() {
// open liberty set this header to en-US by default, it breaks the APPSEC-BLOCKING scenario
// if a java engineer knows how to remove this?
// waiting for that, just set a random value
response.setHeader("Content-Language", "not-set");
return "Hello world!\n";
return ResponseEntity.ok()
.contentType(MediaType.TEXT_PLAIN)
.header("Content-Language", "not-set")
.contentLength(13)
.body("Hello world!\n");
}

@RequestMapping("/healthcheck")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ public static void main(String[] args) {
Router router = Router.router(vertx);

router.get("/")
.produces("text/plain")
.handler(ctx -> {
var tracer = GlobalTracer.get();
Span span = tracer.buildSpan("test-span").start();
span.setTag("test-tag", "my value");
try {
ctx.response().setStatusCode(200).end("Hello world!\n");
ctx.response()
.setStatusCode(200)
.putHeader("Content-Type", "text/plain")
.putHeader("Content-Length", "13")
.end("Hello world!\n");
} finally {
span.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ public static void main(String[] args) {
Router router = Router.router(vertx);

router.get("/")
.produces("text/plain")
.handler(ctx -> {
var tracer = GlobalTracer.get();
Span span = tracer.buildSpan("test-span").start();
span.setTag("test-tag", "my value");
try {
ctx.response().setStatusCode(200).end("Hello world!\n");
ctx.response()
.setStatusCode(200)
.putHeader("Content-Type", "text/plain")
.putHeader("Content-Length", "13")
.end("Hello world!\n");
} finally {
span.finish();
}
Expand Down
Loading