Skip to content

Commit b4833f6

Browse files
committed
test(appsec): cover service_entry_span_mut placeholder filtering
Add two unit tests for `Processor::service_entry_span_mut`: - verifies the non-placeholder span is returned when both a placeholder and a real `aws.lambda` span are present - verifies `None` is returned when only a placeholder span exists These guard against regressions in the span-selection logic that caused AppSec context to be prematurely deleted on Go/Java runtimes, leaving the real invocation span untagged. JJ-Change-Id: vlkyxo
1 parent 65ae689 commit b4833f6

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

  • bottlecap/src/appsec/processor

bottlecap/src/appsec/processor/mod.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,4 +821,41 @@ mod tests {
821821
result
822822
);
823823
}
824+
825+
#[test]
826+
fn service_entry_span_mut_skips_placeholder_lambda_span() {
827+
let mut trace = vec![
828+
Span {
829+
name: "aws.lambda".into(),
830+
resource: crate::traces::INVOCATION_SPAN_RESOURCE.into(),
831+
span_id: 1,
832+
..Default::default()
833+
},
834+
Span {
835+
name: "aws.lambda".into(),
836+
resource: "real.lambda.invocation".into(),
837+
span_id: 2,
838+
..Default::default()
839+
},
840+
];
841+
842+
let selected = Processor::service_entry_span_mut(&mut trace)
843+
.expect("expected non-placeholder aws.lambda span");
844+
845+
assert_eq!(selected.name, "aws.lambda");
846+
assert_ne!(selected.resource, crate::traces::INVOCATION_SPAN_RESOURCE);
847+
assert_eq!(selected.span_id, 2);
848+
}
849+
850+
#[test]
851+
fn service_entry_span_mut_returns_none_for_only_placeholder() {
852+
let mut trace = vec![Span {
853+
name: "aws.lambda".into(),
854+
resource: crate::traces::INVOCATION_SPAN_RESOURCE.into(),
855+
span_id: 1,
856+
..Default::default()
857+
}];
858+
859+
assert!(Processor::service_entry_span_mut(&mut trace).is_none());
860+
}
824861
}

0 commit comments

Comments
 (0)