You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2021/04/20 07:28:40 UTC
[nifi] branch main updated: NIFI-8397 update to simple-syslog-5424
0.0.16
This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new a44ab0d NIFI-8397 update to simple-syslog-5424 0.0.16
a44ab0d is described below
commit a44ab0d683e053057338b70aa47109e3b5797f1d
Author: Otto Fowler <ot...@gmail.com>
AuthorDate: Tue Apr 6 15:35:04 2021 -0400
NIFI-8397 update to simple-syslog-5424 0.0.16
resolves issue working with syslog with BOM markers
Signed-off-by: Pierre Villard <pi...@gmail.com>
This closes #4978.
---
.../nifi-extension-utils/nifi-syslog-utils/pom.xml | 2 +-
.../syslog/BaseStrictSyslog5424ParserTest.java | 29 +++++++++++++++++++---
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml
index 12c36e3..b960e12 100644
--- a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml
+++ b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/pom.xml
@@ -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>
diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java
index 06c2084..0f9743b 100644
--- a/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java
+++ b/nifi-nar-bundles/nifi-extension-utils/nifi-syslog-utils/src/test/java/org/apache/nifi/syslog/BaseStrictSyslog5424ParserTest.java
@@ -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()));
+ }
}
+
+