[GitHub] [nifi] exceptionfactory commented on a change in pull request #5530: NIFI-9341 Adding record reader for CEF events

2022-01-27 Thread GitBox


exceptionfactory commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r793722602



##
File path: 
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java
##
@@ -2306,4 +2307,47 @@ public static boolean isFittingNumberType(final Object 
value, final RecordFieldT
 
 return false;
 }
+
+public static DataType inferSimpleDataType(final String value) {
+if (value == null || value.isEmpty()) {
+return null;
+}
+
+if (NumberUtils.isParsable(value)) {

Review comment:
   As mentioned in relation to the commons-lang3 dependency declaration, 
this reference should be replaced with a direct check.  Perhaps implementing a 
simple check for null and empty, together with moving the Boolean string check 
prior to this one would be sufficient?  It would also be helpful to add a unit 
test for this method.

##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/cef/TestCEFUtil.java
##
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.cef;
+
+import org.apache.nifi.serialization.record.Record;
+import org.apache.nifi.serialization.record.RecordField;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.junit.Assert;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public class TestCEFUtil {
+static final String RAW_FIELD = "raw";
+static final String RAW_VALUE = "Oct 12 04:16:11 localhost 
CEF:0|Company|Product|1.2.3|audit-login|Successful login|3|";
+
+static final String INPUT_SINGLE_ROW_HEADER_FIELDS_ONLY = 
"src/test/resources/cef/single-row-header-fields-only.txt";
+static final String INPUT_SINGLE_ROW_WITH_EXTENSIONS = 
"src/test/resources/cef/single-row-with-extensions.txt";
+static final String INPUT_SINGLE_ROW_WITH_EMPTY_EXTENSION = 
"src/test/resources/cef/single-row-with-empty-extension.txt";
+static final String INPUT_SINGLE_ROW_WITH_CUSTOM_EXTENSIONS = 
"src/test/resources/cef/single-row-with-custom-extensions.txt";
+static final String INPUT_SINGLE_ROW_WITH_EMPTY_CUSTOM_EXTENSIONS = 
"src/test/resources/cef/single-row-with-empty-custom-extensions.txt";
+static final String INPUT_SINGLE_ROW_WITH_INCORRECT_HEADER_FIELD = 
"src/test/resources/cef/single-row-with-incorrect-header-field.txt";
+static final String INPUT_SINGLE_ROW_WITH_INCORRECT_CUSTOM_EXTENSIONS = 
"src/test/resources/cef/single-row-with-incorrect-custom-extensions.txt";
+static final String INPUT_EMPTY_ROW = 
"src/test/resources/cef/empty-row.txt";
+static final String INPUT_MISFORMATTED_ROW = 
"src/test/resources/cef/misformatted-row.txt";
+static final String INPUT_MULTIPLE_IDENTICAL_ROWS = 
"src/test/resources/cef/multiple-rows.txt";
+static final String INPUT_MULTIPLE_ROWS_WITH_DIFFERENT_CUSTOM_TYPES = 
"src/test/resources/cef/multiple-rows-with-different-custom-types.txt";
+static final String INPUT_MULTIPLE_ROWS_STARTING_WITH_EMPTY_ROW = 
"src/test/resources/cef/multiple-rows-starting-with-empty-row.txt";
+static final String INPUT_MULTIPLE_ROWS_WITH_EMPTY_ROWS = 
"src/test/resources/cef/multiple-rows-with-empty-rows.txt";
+static final String 
INPUT_MULTIPLE_ROWS_WITH_DECREASING_NUMBER_OF_EXTENSIONS = 
"src/test/resources/cef/multiple-rows-decreasing-number-of-extensions.txt";
+static final String 
INPUT_MULTIPLE_ROWS_WITH_INCREASING_NUMBER_OF_EXTENSIONS = 
"src/test/resources/cef/multiple-rows-increasing-number-of-extensions.txt";
+
+static final Map EXPECTED_HEADER_VALUES = new HashMap<>();
+static final Map EXPECTED_EXTENSION_VALUES = new 
HashMap<>();
+
+static final String CUSTOM_EXTENSION_FIELD_NAME = "loginsequence";
+static final RecordField CUSTOM_EXTENSION_FIELD = new 
RecordField(TestCEFUtil.CUSTOM_EXTENSION_FIELD_NAME, 
RecordFieldType.INT.getDataType());
+

[GitHub] [nifi] exceptionfactory commented on a change in pull request #5530: NIFI-9341 Adding record reader for CEF events

2022-01-27 Thread GitBox


exceptionfactory commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r793681389



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/cef/ValidateLocale.java
##
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.cef;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+import java.util.Locale;
+
+/**
+ * This class is identical to {@code 
org.apache.nifi.processors.standard.ParseCEF.ValidateLocale}.

Review comment:
   Thanks for reply, that seems reasonable given the narrow scope of this 
particular class.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5530: NIFI-9341 Adding record reader for CEF events

2022-01-25 Thread GitBox


exceptionfactory commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r791996926



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/cef/CEFSchemaUtil.java
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.cef;
+
+import org.apache.nifi.serialization.record.DataType;
+import org.apache.nifi.serialization.record.RecordField;
+import org.apache.nifi.serialization.record.RecordFieldType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+final class CEFSchemaUtil {
+
+private static final List HEADER_FIELDS = new ArrayList<>();
+
+static {
+// Reference states that severity might be represented by integer 
values (0-10) and string values (like High) too
+HEADER_FIELDS.add(new RecordField("version", 
RecordFieldType.INT.getDataType()));
+HEADER_FIELDS.add(new RecordField("deviceVendor", 
RecordFieldType.STRING.getDataType()));
+HEADER_FIELDS.add(new RecordField("deviceProduct", 
RecordFieldType.STRING.getDataType()));
+HEADER_FIELDS.add(new RecordField("deviceVersion", 
RecordFieldType.STRING.getDataType()));
+HEADER_FIELDS.add(new RecordField("deviceEventClassId", 
RecordFieldType.STRING.getDataType()));
+HEADER_FIELDS.add(new RecordField("name", 
RecordFieldType.STRING.getDataType()));
+HEADER_FIELDS.add(new RecordField("severity", 
RecordFieldType.STRING.getDataType()));
+}
+
+// Fields known by the CEF Extension Dictionary in version 23
+private static final Set EXTENSIONS_STRING = new 
HashSet<>(Arrays.asList("act", "app", "c6a1Label", "c6a2Label", "c6a3Label",

Review comment:
   It would be very helpful to declare these values one per line, ideally 
alphabetized.  Although it would take some effort, it would make it much easier 
to maintain. On the other hand, would it be better to make String the default 
fallback type and avoid having to declare all of these fields?

##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/cef/ValidateLocale.java
##
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.cef;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+import java.util.Locale;
+
+/**
+ * This class is identical to {@code 
org.apache.nifi.processors.standard.ParseCEF.ValidateLocale}.

Review comment:
   In light of this comment, did you consider creating a new module under 
`nifi-commons` to avoid duplicating this Validator class?

##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/cef/TestCEFReader.java
##
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses 

[GitHub] [nifi] exceptionfactory commented on a change in pull request #5530: NIFI-9341 Adding record reader for CEF events

2022-01-08 Thread GitBox


exceptionfactory commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r780558536



##
File path: nifi-commons/nifi-record/pom.xml
##
@@ -15,6 +15,14 @@
 -->
 http://maven.apache.org/POM/4.0.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd;>
 4.0.0
+
+
+org.apache.commons
+commons-lang3
+3.7

Review comment:
   Recommend upgrading the more recent version 3.12.0:
   ```suggestion
   3.12.0
   ```

##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml
##
@@ -124,6 +124,21 @@
 guava
 27.0.1-jre
 
+
+com.fluenda
+parcefone
+2.1.0
+
+
+org.apache.bval
+bval-jsr
+1.1.2

Review comment:
   This particular version is several years old, the current version is 
2.0.5, is it possible to use that version?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5530: NIFI-9341 Adding record reader for CEF events

2022-01-07 Thread GitBox


exceptionfactory commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r780559141



##
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/pom.xml
##
@@ -124,6 +124,21 @@
 guava
 27.0.1-jre
 
+
+com.fluenda
+parcefone
+2.1.0
+
+
+org.apache.bval
+bval-jsr
+1.1.2

Review comment:
   This particular version is several years old, the current version is 
2.0.5, is it possible to use that version?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [nifi] exceptionfactory commented on a change in pull request #5530: NIFI-9341 Adding record reader for CEF events

2022-01-07 Thread GitBox


exceptionfactory commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r780558536



##
File path: nifi-commons/nifi-record/pom.xml
##
@@ -15,6 +15,14 @@
 -->
 http://maven.apache.org/POM/4.0.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd;>
 4.0.0
+
+
+org.apache.commons
+commons-lang3
+3.7

Review comment:
   Recommend upgrading the more recent version 3.12.0:
   ```suggestion
   3.12.0
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org