Skip to content

Commit 4d03454

Browse files
committed
Make the test fail
Pipe should not be a valid separator in mac addresses
1 parent d05a393 commit 4d03454

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CefParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ final class CefParser {
7171
private static final Pattern MAC_ADDRESS_PATTERN = Pattern.compile(
7272
Stream.of(
7373
// Combined colon and hyphen separated 6-group patterns
74-
"(([0-9A-Fa-f]{2}[:|-]){5}[0-9A-Fa-f]{2})",
74+
"(([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2})",
7575
// Dot-separated 6-group pattern
7676
"([0-9A-Fa-f]{4}\\.){2}[0-9A-Fa-f]{4}",
7777
// Combined colon and hyphen separated 8-group patterns
78-
"([0-9A-Fa-f]{2}[:|-]){7}[0-9A-Fa-f]{2}",
78+
"([0-9A-Fa-f]{2}[:-]){7}[0-9A-Fa-f]{2}",
7979
// Dot-separated EUI-64
8080
"([0-9A-Fa-f]{4}\\.){3}[0-9A-Fa-f]{4}"
8181
).collect(Collectors.joining("|", "^(", ")$"))

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CefProcessorTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,8 @@ public void testToMacAddressWithSeparators() {
972972

973973
public void testInvalidMacAddressSeparator() {
974974
CefParser parser = new CefParser(ZoneId.of("UTC"), false);
975-
String macAddress = "00|0D|60|AF|1B|61";
976-
String result = parser.toMACAddress(macAddress);
977-
assertEquals("00|0D|60|AF|1B|61", result);
975+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> parser.toMACAddress("00|0D|60|AF|1B|61"));
976+
assertThat(e.getMessage(), equalTo("Invalid MAC address format"));
978977
}
979978

980979
public void testEUI48ToMacAddressWithOutSeparators() {

0 commit comments

Comments
 (0)