Skip to content

Commit

Permalink
[7.12] Fix typo in validation for destination port of community ID pr…
Browse files Browse the repository at this point in the history
…ocessor (#70883) (#71530)
  • Loading branch information
danhermann committed Apr 12, 2021
1 parent 5b60678 commit ad55975
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private Flow buildFlow(IngestDocument d) {

Object destinationPortValue = d.getFieldValue(destinationPortField, Object.class, ignoreMissing);
flow.destinationPort = parseIntFromObjectOrString(destinationPortValue, "destination port");
if (flow.destinationPort < 1 || flow.sourcePort > 65535) {
if (flow.destinationPort < 1 || flow.destinationPort > 65535) {
throw new IllegalArgumentException("invalid destination port [" + destinationPortValue + "]");
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ public void testInvalidPort() throws Exception {
source2.put("port", 65536);
e = expectThrows(IllegalArgumentException.class, () -> testCommunityIdProcessor(event, null));
assertThat(e.getMessage(), containsString("invalid source port [65536]"));

event = buildEvent();
@SuppressWarnings("unchecked")
Map<String, Object> source3 = (Map<String, Object>) event.get("destination");
source3.put("port", 0);
e = expectThrows(IllegalArgumentException.class, () -> testCommunityIdProcessor(event, null));
assertThat(e.getMessage(), containsString("invalid destination port [0]"));

event = buildEvent();
@SuppressWarnings("unchecked")
Map<String, Object> source4 = (Map<String, Object>) event.get("destination");
source4.put("port", 65536);
e = expectThrows(IllegalArgumentException.class, () -> testCommunityIdProcessor(event, null));
assertThat(e.getMessage(), containsString("invalid destination port [65536]"));
}

public void testIgnoreMissing() throws Exception {
Expand Down

0 comments on commit ad55975

Please sign in to comment.