Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinZakharov committed Jun 14, 2024
1 parent 726b445 commit c0b46a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,24 @@ public void reportStackTrace(StackTraceEvent stackTraceEvent) {
}

Collection<AppSecEvent> transferCollectedEvents() {
if (this.appSecEvents == null) {
return Collections.emptyList();
}

Collection<AppSecEvent> events = new ArrayList<>();
AppSecEvent item;
while ((item = this.appSecEvents.poll()) != null) {
events.add(item);
}

return events;
}

StackTraceCollection transferStackTracesCollection() {
if (this.stackTraceEvents == null) {
return null;
}

Collection<StackTraceEvent> stackTraces = new ArrayList<>();
StackTraceEvent item;
while ((item = this.stackTraceEvents.poll()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ class AppSecRequestContextSpecification extends DDSpecification {

when:
ctx.reportEvents([new AppSecEvent()])
events = ctx.transferCollectedEvents()

then:
thrown IllegalStateException
events.size() == 1
events[0] != null
}

void 'collect events when none reported'() {
Expand Down Expand Up @@ -144,6 +146,11 @@ class AppSecRequestContextSpecification extends DDSpecification {
collection.exploit[0].frames[0].function == 'method'
}

void 'collect stack traces when none reported'() {
expect:
ctx.transferStackTracesCollection() == null
}

void 'headers allow list should contains only lowercase names'() {
expect:
headers.each {
Expand Down

0 comments on commit c0b46a6

Please sign in to comment.