NIFI-8397 update to simple-syslog-5424 0.0.16

resolves issue working with syslog with BOM markers

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #4978.
This commit is contained in:
Otto Fowler 2021-04-06 15:35:04 -04:00 committed by Pierre Villard
parent bbe75e81dd
commit a44ab0d683
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
2 changed files with 26 additions and 5 deletions

View File

@ -26,7 +26,7 @@
<dependency>
<groupId>com.github.palindromicity</groupId>
<artifactId>simple-syslog-5424</artifactId>
<version>0.0.13</version>
<version>0.0.16</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>

View File

@ -27,6 +27,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
@ -69,7 +70,7 @@ public abstract class BaseStrictSyslog5424ParserTest {
final String procId = "-";
final String msgId = "ID17";
final String structuredData = "-";
final String body = "BOM'su root' failed for lonvick on /dev/pts/8";
final String body = "'su root' failed for lonvick on /dev/pts/8";
final String message = "<" + pri + ">" + version + " " + stamp + " " + host + " "
+ appName + " " + procId + " " + msgId + " " + "-" + " " + body;
@ -116,7 +117,7 @@ public abstract class BaseStrictSyslog5424ParserTest {
final String procId = "-";
final String msgId = "ID17";
final String structuredData = "-";
final String body = "BOM'su root' failed for lonvick on /dev/pts/8";
final String body = "'su root' failed for lonvick on /dev/pts/8";
final String message = "<" + pri + ">" + version + " " + stamp + " " + host + " "
+ appName + " " + procId + " " + msgId + " " + "-" + " " + body;
@ -133,7 +134,7 @@ public abstract class BaseStrictSyslog5424ParserTest {
@Test
public void testTrailingNewLine() {
final String message = "<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - " +
"ID47 - BOM'su root' failed for lonvick on /dev/pts/8\n";
"ID47 - 'su root' failed for lonvick on /dev/pts/8\n";
final byte[] bytes = message.getBytes(CHARSET);
final ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
@ -151,7 +152,7 @@ public abstract class BaseStrictSyslog5424ParserTest {
// supported examples from RFC 5424 including structured data with no message
messages.add("<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - " +
"ID47 - BOM'su root' failed for lonvick on /dev/pts/8");
"ID47 - 'su root' failed for lonvick on /dev/pts/8");
messages.add("<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc " +
"8710 - - %% It's time to make the do-nuts.");
messages.add("<14>1 2014-06-20T09:14:07+00:00 loggregator"
@ -231,4 +232,24 @@ public abstract class BaseStrictSyslog5424ParserTest {
Assert.assertEquals(sender, event.getSender());
Assert.assertEquals("Removing instance", event.getFieldMap().get(SyslogAttributes.SYSLOG_BODY.key()));
}
@Test
public void testParseWithBOM() {
final String message = "<14>1 2014-06-20T09:14:07+00:00 loggregator"
+ " d0602076-b14a-4c55-852a-981e7afeed38 DEA MSG-01"
+ " [exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"]"
+ "[exampleSDID@32480 iut=\"4\" eventSource=\"Other Application\" eventID=\"2022\"] \uFEFFMessage with some Umlauts äöü";
final byte[] bytes = message.getBytes(CHARSET);
final ByteBuffer buffer = ByteBuffer.allocate(bytes.length);
((Buffer)buffer).clear();
buffer.put(bytes);
final Syslog5424Event event = parser.parseEvent(buffer);
Assert.assertNotNull(event);
Assert.assertTrue(event.isValid());
Assert.assertEquals("Message with some Umlauts äöü", event.getFieldMap().get(SyslogAttributes.SYSLOG_BODY.key()));
}
}