Skip to content
Closed
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
32 changes: 16 additions & 16 deletions bottlecap/src/appsec/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,23 +455,23 @@ impl InvocationPayload for IdentifiedTrigger {
}
fn route(&self) -> Option<String> {
match self {
Self::APIGatewayHttpEvent(t) => Some(t.route_key.clone()),
Self::APIGatewayRestEvent(t) => Some(format!(
"{method} {resource}",
method = t.request_context.method,
resource = t.request_context.resource_path
)),
Self::APIGatewayHttpEvent(t) => {
if t.route_key.is_empty() {
None
} else {
Some(
t.route_key
.split_whitespace()
.last()
.unwrap_or(t.route_key.as_str())
.to_string(),
)
}
}
Self::APIGatewayRestEvent(t) => Some(t.request_context.resource_path.clone()),
Self::APIGatewayWebSocketEvent(t) => Some(t.request_context.route_key.clone()),
Self::ALBEvent(t) => Some(format!(
"{method} {path}",
method = t.http_method,
path = t.path.as_ref().map_or("", |s| s.as_str()),
)),
Self::LambdaFunctionUrlEvent(t) => Some(format!(
"{method} {path}",
method = t.request_context.http.method,
path = t.request_context.http.path
)),
Self::ALBEvent(t) => t.path.clone().filter(|p| !p.is_empty()),
Self::LambdaFunctionUrlEvent(t) => Some(t.request_context.http.path.clone()),
// Events that are not relevant to App & API Protection
Self::MSKEvent(_)
| Self::SqsRecord(_)
Expand Down
2 changes: 1 addition & 1 deletion bottlecap/tests/appsec_processor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ async fn test_processor() {
"http.request.headers.user-agent": "Arachni/v2",
"http.request.headers.x-amzn-trace-id": "Root=1-613a52fb-4c43cfc95e0241c1471bfa05",
"http.request.headers.x-forwarded-for": "38.122.226.210",
"http.route": "POST /httpapi/post",
"http.route": "/httpapi/post",
"http.url": "x02yirxc7a.execute-api.sa-east-1.amazonaws.com/httpapi/post",
"http.status_code": "200",
"network.client.ip": "38.122.226.210",
Expand Down
Loading