diff --git a/common/build.gradle b/common/build.gradle index ab45e8383..f53ddd5e7 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -12,8 +12,8 @@ version "${file("VERSION").text.trim()}" // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { diff --git a/common/src/main/java/com/ibm/guardium/universalconnector/commons/Util.java b/common/src/main/java/com/ibm/guardium/universalconnector/commons/Util.java index 61fd269ac..f7e6e68d5 100644 --- a/common/src/main/java/com/ibm/guardium/universalconnector/commons/Util.java +++ b/common/src/main/java/com/ibm/guardium/universalconnector/commons/Util.java @@ -5,7 +5,7 @@ package com.ibm.guardium.universalconnector.commons; /** - * A utility class for creating a Guardium {@link com.ibm.guardium.universalconnector.commons.structures.Record Record}. + * A utility class for creating a Guardium {@link com.ibm.guardium.universalconnector.commons.structures.UCRecord Record}. */ public class Util { /** diff --git a/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Accessor.java b/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Accessor.java index 3cab1870b..c30b2d852 100644 --- a/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Accessor.java +++ b/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Accessor.java @@ -174,7 +174,7 @@ public String getServiceName() { * the OS level service that runs the DB instace. * * @param serviceName Usually identical to DB name, or container identifier in data source. - * @see Record#setDbName(String) + * @see UCRecord#setDbName(String) */ public void setServiceName(String serviceName) { this.serviceName = serviceName; diff --git a/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Record.java b/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/UCRecord.java similarity index 99% rename from common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Record.java rename to common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/UCRecord.java index 87696aba7..70f09e847 100644 --- a/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/Record.java +++ b/common/src/main/java/com/ibm/guardium/universalconnector/commons/structures/UCRecord.java @@ -24,7 +24,7 @@ *
  • App username specifies an application username * */ -public class Record { +public class UCRecord { /** * Not to be filled by filter developer @@ -233,7 +233,7 @@ public void setRecordsAffected(Integer recordsAffected) { @Override public String toString() { - return "Record{" + + return "UCRecord{" + "connectorName='" + connectorName + '\'' + ", connectorId='" + connectorId + '\'' + ", sessionId='" + sessionId + '\'' + @@ -247,4 +247,4 @@ public String toString() { ", recordsAffected=" + recordsAffected + '}'; } -} \ No newline at end of file +} diff --git a/common/src/test/java/com/ibm/guardium/universalconnector/commons/structures/RecordTest.java b/common/src/test/java/com/ibm/guardium/universalconnector/commons/structures/RecordTest.java index da7a3be66..4ce6e24c6 100644 --- a/common/src/test/java/com/ibm/guardium/universalconnector/commons/structures/RecordTest.java +++ b/common/src/test/java/com/ibm/guardium/universalconnector/commons/structures/RecordTest.java @@ -9,7 +9,7 @@ public class RecordTest { - Record record = new Record(); + UCRecord record = new UCRecord(); @Test public void testAccessorPostManipulation() { diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/Aurora-Mysql-offlinePlugin.zip b/filter-plugin/logstash-filter-aurora-mysql-guardium/Aurora-Mysql-offlinePlugin.zip index d4a38c0e5..d532c74d8 100644 Binary files a/filter-plugin/logstash-filter-aurora-mysql-guardium/Aurora-Mysql-offlinePlugin.zip and b/filter-plugin/logstash-filter-aurora-mysql-guardium/Aurora-Mysql-offlinePlugin.zip differ diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/AuroraMysqlOverCloudwatchPackage/AuroraMysql/Aurora-Mysql-offlinePlugin.zip b/filter-plugin/logstash-filter-aurora-mysql-guardium/AuroraMysqlOverCloudwatchPackage/AuroraMysql/Aurora-Mysql-offlinePlugin.zip index d4a38c0e5..d532c74d8 100644 Binary files a/filter-plugin/logstash-filter-aurora-mysql-guardium/AuroraMysqlOverCloudwatchPackage/AuroraMysql/Aurora-Mysql-offlinePlugin.zip and b/filter-plugin/logstash-filter-aurora-mysql-guardium/AuroraMysqlOverCloudwatchPackage/AuroraMysql/Aurora-Mysql-offlinePlugin.zip differ diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/build.gradle b/filter-plugin/logstash-filter-aurora-mysql-guardium/build.gradle index ce96925df..19a01bf85 100644 --- a/filter-plugin/logstash-filter-aurora-mysql-guardium/build.gradle +++ b/filter-plugin/logstash-filter-aurora-mysql-guardium/build.gradle @@ -11,7 +11,7 @@ group 'com.ibm.guardium.auroramysql' // must match the pack version "${file("VERSION").text.trim()}" // read from required VERSION file description = "Aurora Mysql Guardium filter plugin" pluginInfo.licenses = ['Apache-2.0'] // list of SPDX license IDs -pluginInfo.longDescription = "This gem is a Logstash saphana filter plugin required to be installed as part of IBM Security Guardium, Guardium Universal connector configuration. This gem is not a stand-alone program." +pluginInfo.longDescription = "This gem is a Logstash Aurora MySQL filter plugin required to be installed as part of IBM Security Guardium, Guardium Universal connector configuration. This gem is not a stand-alone program." pluginInfo.authors = ['IBM', 'Laxmikant Mahale'] pluginInfo.email = ['Laxmikant.Mahale@ibm.com'] pluginInfo.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html" @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "AuroraMysqlGuardiumPluginFilter" pluginInfo.pluginName = "auroramysqlguardiumpluginfilter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.1' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/gradlew b/filter-plugin/logstash-filter-aurora-mysql-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/AuroraMysqlGuardiumPluginFilter.java b/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/AuroraMysqlGuardiumPluginFilter.java index 047edd91f..9a879a35c 100644 --- a/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/AuroraMysqlGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/AuroraMysqlGuardiumPluginFilter.java @@ -56,7 +56,7 @@ public Collection filter(Collection events, FilterMatchListener ma JsonObject data = new JsonObject(); data = inputData(e); try { - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/Parser.java b/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/Parser.java index 827d1f173..d771452b2 100644 --- a/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/Parser.java +++ b/filter-plugin/logstash-filter-aurora-mysql-guardium/src/main/java/com/ibm/guardium/auroramysql/Parser.java @@ -11,8 +11,8 @@ public class Parser { private static Logger log = LogManager.getLogger(Parser.class); - public static Record parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); if (data != null) { if (data.has(Constants.SESSION_ID) && !data.get(Constants.SESSION_ID).isJsonNull()) { diff --git a/filter-plugin/logstash-filter-aurora-mysql-guardium/src/test/java/com/ibm/guardium/auroramysql/ParserTest.java b/filter-plugin/logstash-filter-aurora-mysql-guardium/src/test/java/com/ibm/guardium/auroramysql/ParserTest.java index 81f74a152..1963c4099 100644 --- a/filter-plugin/logstash-filter-aurora-mysql-guardium/src/test/java/com/ibm/guardium/auroramysql/ParserTest.java +++ b/filter-plugin/logstash-filter-aurora-mysql-guardium/src/test/java/com/ibm/guardium/auroramysql/ParserTest.java @@ -6,10 +6,7 @@ import java.text.ParseException; import com.google.gson.JsonObject; -import com.ibm.guardium.auroramysql.Constants; -import com.ibm.guardium.auroramysql.Parser; import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.Record; import org.junit.Assert; import org.junit.Test; @@ -35,7 +32,7 @@ public void testParseRecord_CreateTable() throws ParseException { data.addProperty(Constants.DB_USER, "admin"); data.addProperty(Constants.DB_NAME, "music"); data.addProperty(Constants.SERVERHOSTNAME, "serverHostName"); - final Record record = Parser.parseRecord(data); + final UCRecord record = Parser.parseRecord(data); Assert.assertEquals( "CREATE TABLE Orders (OrderID int NOT NULL,OrderNumber int NOT NULL,PersonID int,PRIMARY KEY (OrderID))", @@ -56,7 +53,7 @@ public void testParseRecord_Error () throws ParseException { data.addProperty(Constants.DB_USER, "JOHNNY"); data.addProperty(Constants.DB_NAME, "music"); data.addProperty(Constants.SERVERHOSTNAME, "serverHostName"); - final Record record = Parser.parseRecord(data); + final UCRecord record = Parser.parseRecord(data); Assert.assertEquals("LOGIN_FAILED", record.getException().getExceptionTypeId()); Assert.assertEquals("CONNECT", record.getException().getDescription()); } @@ -78,7 +75,7 @@ public void testParseAccessor() throws ParseException { data.addProperty(Constants.DB_USER, "JOHNNY"); data.addProperty(Constants.DB_NAME, "MUSIC"); data.addProperty(Constants.SERVERHOSTNAME, "serverHostName"); - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); Accessor actual = record.getAccessor(); Assert.assertEquals(Constants.DB_PROTOCOL, actual.getDbProtocol()); diff --git a/filter-plugin/logstash-filter-azure-apachesolr-guardium/build.gradle b/filter-plugin/logstash-filter-azure-apachesolr-guardium/build.gradle index 501ec599f..3c2a909ec 100644 --- a/filter-plugin/logstash-filter-azure-apachesolr-guardium/build.gradle +++ b/filter-plugin/logstash-filter-azure-apachesolr-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginName = "apache_solr_azure_connector" // must match the @Lo // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } diff --git a/filter-plugin/logstash-filter-azure-apachesolr-guardium/gradlew b/filter-plugin/logstash-filter-azure-apachesolr-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrAzureConnector.java b/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrAzureConnector.java index 4b749bb9b..44c76c234 100644 --- a/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrAzureConnector.java +++ b/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrAzureConnector.java @@ -11,7 +11,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; @@ -47,7 +47,7 @@ public Collection filter(Collection events, FilterMatchListener ma for (Event event : events) { if (isQtpEvent(event)) { try { - Record rec = Parser.parseQtpRecord(event); + UCRecord rec = Parser.parseQtpRecord(event); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java b/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java index 34df73ad6..d79bb063e 100644 --- a/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java +++ b/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java @@ -27,7 +27,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -54,8 +54,8 @@ public class Parser { * @return record * @throws Exception */ - public static Record parseQtpRecord(final Event event) throws Exception { - Record record = new Record(); + public static UCRecord parseQtpRecord(final Event event) throws Exception { + UCRecord record = new UCRecord(); try { record.setSessionId(getSessionId(event)); record.setAppUserName(ApplicationConstant.NOT_AVAILABLE); @@ -385,7 +385,7 @@ private static String getRedactedData(Event event) { /** * Using this to set redactedDataSql * - * @param eventF + * @param event * @return redactedsql */ private static String getRedactedSql(final Event event) { @@ -453,7 +453,7 @@ protected static Sentence parseQtpSentence(final Event event) throws Exception { * Using this to perform operation on input, convert String core into * sentenceObject Object and then return the value as response * - * @param String core + * @param core * @return sentenceobject * */ diff --git a/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java b/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java index e5b8e87a1..eefe8fea9 100644 --- a/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java +++ b/filter-plugin/logstash-filter-azure-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java @@ -12,7 +12,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -111,7 +111,7 @@ public void testRedacted() throws Exception { event.setField(ApplicationConstant.WEBAPP_FOR_FULLSQL, ApplicationConstantTest.WEBAPP_FOR_FULLSQL_VALUE); event.setField(ApplicationConstant.PATH_FOR_FULLSQL, ApplicationConstantTest.PATH_FOR_FULLSQL_VALUE); event.setField(ApplicationConstant.PARAMS, ApplicationConstantTest.PARAMS_VALUE); - Record record = Parser.parseQtpRecord(event); + UCRecord record = Parser.parseQtpRecord(event); String redacted = record.getData().getConstruct().getRedactedSensitiveDataSql(); Assert.assertNotNull(redacted); Assert.assertEquals(ApplicationConstantTest.REDACTED_VALUE, redacted); diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/build.gradle b/filter-plugin/logstash-filter-azure-postgresql-guardium/build.gradle index f79d9a899..db99f43e8 100644 --- a/filter-plugin/logstash-filter-azure-postgresql-guardium/build.gradle +++ b/filter-plugin/logstash-filter-azure-postgresql-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginName = "azure_postgresql_guardium_plugin_filter" // must m // ===========================================================================shPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -137,7 +137,6 @@ tasks.register("copyDependencyLibs", Copy){ } apply plugin: 'jacoco' -//apply plugin: 'org.barfuin.gradle.jacocolog' version '2.0.0' apply plugin: "org.barfuin.gradle.jacocolog" // ------------------------------------ // JaCoCo is a code coverage tool @@ -188,4 +187,4 @@ jacocoTestCoverageVerification { })) } } -project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) \ No newline at end of file +project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/gradlew b/filter-plugin/logstash-filter-azure-postgresql-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/logstash-filter-azure_postgresql_guardium_plugin_filter.zip b/filter-plugin/logstash-filter-azure-postgresql-guardium/logstash-filter-azure_postgresql_guardium_plugin_filter.zip index 817b606c0..8e7ff6495 100644 Binary files a/filter-plugin/logstash-filter-azure-postgresql-guardium/logstash-filter-azure_postgresql_guardium_plugin_filter.zip and b/filter-plugin/logstash-filter-azure-postgresql-guardium/logstash-filter-azure_postgresql_guardium_plugin_filter.zip differ diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilter.java b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilter.java index de926d389..c4dfd0060 100644 --- a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilter.java @@ -8,9 +8,7 @@ import java.io.File; import java.util.Collection; import java.util.Collections; -import java.util.Map; -import org.apache.commons.collections.map.HashedMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; @@ -18,7 +16,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -74,7 +72,7 @@ public Collection filter(Collection events, FilterMatchListener ma try { - Record record = Parser.parseRecord(e); + UCRecord record = Parser.parseRecord(e); final GsonBuilder builder = new GsonBuilder(); diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/Parser.java b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/Parser.java index 30bbeb754..eaa9776b1 100644 --- a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/Parser.java +++ b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/main/java/com/ibm/guardium/azurepostgresql/Parser.java @@ -4,27 +4,14 @@ #*/ package com.ibm.guardium.azurepostgresql; -import java.text.SimpleDateFormat; - -import org.apache.logging.log4j.LogManager; - -import org.apache.logging.log4j.Logger; - import java.util.Date; - +import java.text.SimpleDateFormat; import java.text.ParseException; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; - -import com.ibm.guardium.universalconnector.commons.structures.Data; - -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; - -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; - -import com.ibm.guardium.universalconnector.commons.structures.Time; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import co.elastic.logstash.api.Event; @@ -32,9 +19,9 @@ public class Parser { private static Logger log = LogManager.getLogger(Parser.class); - public static Record parseRecord(final Event e) throws ParseException { + public static UCRecord parseRecord(final Event e) throws ParseException { - Record record = new Record(); + UCRecord record = new UCRecord(); String dbname = Constants.NA; if (e.getField(Constants.DATABASE_NAME) != null) { @@ -102,7 +89,7 @@ public static Time parseTimestamp(final Event e) { return new Time(millis, 0, 0); } - public static void parseSessionId(final Event e, final Record record) { + public static void parseSessionId(final Event e, final UCRecord record) { if (e.getField(Constants.SESSION_ID) != null) { record.setSessionId(e.getField(Constants.SESSION_ID).toString()); diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilterTest.java b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilterTest.java index 0a6f74643..b8a176c6f 100644 --- a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilterTest.java +++ b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/AzurePostgresqlGuardiumPluginFilterTest.java @@ -11,8 +11,6 @@ import org.junit.Test; import org.logstash.plugins.ContextImpl; -import com.ibm.guardium.azurepostgresql.Constants; -import com.ibm.guardium.azurepostgresql.AzurePostgresqlGuardiumPluginFilter; import com.ibm.guardium.universalconnector.commons.GuardConstants; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; diff --git a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/ParserTest.java b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/ParserTest.java index b3a6717d2..c6176d0c5 100644 --- a/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/ParserTest.java +++ b/filter-plugin/logstash-filter-azure-postgresql-guardium/src/test/java/com/ibm/guardium/azurepostgresql/ParserTest.java @@ -6,15 +6,12 @@ package com.ibm.guardium.azurepostgresql; import java.text.ParseException; -import java.util.Map; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; -import com.ibm.guardium.azurepostgresql.Constants; -import com.ibm.guardium.azurepostgresql.Parser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; import co.elastic.logstash.api.Event; @@ -47,7 +44,7 @@ public void createQuery() throws ParseException { Event e = intitalizeEventObject(); e.setField(Constants.STATEMENT, "create table emp1(id int);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getOriginalSqlCommand(),"create table emp1(id int);"); } @@ -59,7 +56,7 @@ public void insertQuery() throws ParseException { e.setField(Constants.STATEMENT, "INSERT INTO Employee (EmployeeNo, FirstName, LastName, DOB, JoinedDate, DepartmentNo )" + "VALUES ( 101, 'sss', 'shinde','1980-01-05', '2005-03-27', 01);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getOriginalSqlCommand(), "INSERT INTO Employee (EmployeeNo, FirstName, LastName, DOB, JoinedDate, DepartmentNo )" + "VALUES ( 101, 'sss', 'shinde','1980-01-05', '2005-03-27', 01);"); } @@ -70,7 +67,7 @@ public void selectQuery() throws ParseException { Event e = intitalizeEventObject(); e.setField(Constants.STATEMENT, "Select * from employee;"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getOriginalSqlCommand(),"Select * from employee;" ); } @@ -80,7 +77,7 @@ public void selectQueryNew() throws ParseException { Event e = intitalizeEventObject(); e.setField(Constants.STATEMENT, "\"SELECT \n first_name || ' ' || last_name \"\"Full Name\"\"\nFROM \n AutomationEdge\""); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getOriginalSqlCommand(),"SELECT \n" + " first_name || ' ' || last_name \"Full Name\"\n" + "FROM \n" + @@ -93,7 +90,7 @@ public void updateQuery() throws ParseException { Event e = intitalizeEventObject(); e.setField(Constants.STATEMENT, "UPDATE Employee SET DepartmentNo = 03 WHERE EmployeeNo = 101;"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getOriginalSqlCommand(),"UPDATE Employee SET DepartmentNo = 03 WHERE EmployeeNo = 101;"); } @@ -103,7 +100,7 @@ public void deleteQuery() throws ParseException { Event e = intitalizeEventObject(); e.setField(Constants.STATEMENT, "DELETE FROM Employee WHERE EmployeeNo = 101;"); - Record record = Parser.parseRecord(e); + UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getOriginalSqlCommand(),"DELETE FROM Employee WHERE EmployeeNo = 101;"); } @@ -144,7 +141,7 @@ public void testErrors() throws ParseException { e.setField(Constants.SUCCEEDED, "ERROR"); e.setField(Constants.MESSAGE, "relation \"dept\" already exists"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(Constants.SQL_ERROR, record.getException().getExceptionTypeId()); Assert.assertEquals("relation \"dept\" already exists", record.getException().getDescription()); } @@ -157,7 +154,7 @@ public void testAuth() throws ParseException { e.setField(Constants.SQL_STATE,"28P01"); e.setField(Constants.PREFIX,"28P01"); e.setField(Constants.MESSAGE, "password authentication failed for user \"postgres\""); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(Constants.LOGIN_ERROR, record.getException().getExceptionTypeId()); Assert.assertEquals("password authentication failed for user \"postgres\"", record.getException().getDescription()); diff --git a/filter-plugin/logstash-filter-azure-sql-guardium/build.gradle b/filter-plugin/logstash-filter-azure-sql-guardium/build.gradle index 84379a9d3..507237a3d 100644 --- a/filter-plugin/logstash-filter-azure-sql-guardium/build.gradle +++ b/filter-plugin/logstash-filter-azure-sql-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginName = "azuresql_guardium_plugin_filter" // must match the // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-azure-sql-guardium/gradlew b/filter-plugin/logstash-filter-azure-sql-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/AzureSQLGuardiumPluginFilter.java b/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/AzureSQLGuardiumPluginFilter.java index db4083de4..0063ad764 100644 --- a/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/AzureSQLGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/AzureSQLGuardiumPluginFilter.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.Collections; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; @@ -11,7 +12,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -52,7 +52,7 @@ public Collection filter(Collection events, FilterMatchListener ma for (Event e : events) { try { - Record record = Parser.parseRecord(e); + UCRecord record = Parser.parseRecord(e); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/Parser.java b/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/Parser.java index 01cbec64c..06ee3a762 100644 --- a/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/Parser.java +++ b/filter-plugin/logstash-filter-azure-sql-guardium/src/main/java/com/ibm/guardium/azureSQL/Parser.java @@ -4,20 +4,16 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.*; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Event; public class Parser { - public static Record parseRecord(final Event e) throws ParseException { + public static UCRecord parseRecord(final Event e) throws ParseException { - Record record = new Record(); + UCRecord record = new UCRecord(); record.setSessionId(e.getField(Constants.Session_ID).toString()); diff --git a/filter-plugin/logstash-filter-azure-sql-guardium/src/test/java/com/ibm/guardium/azureSQL/ParserTest.java b/filter-plugin/logstash-filter-azure-sql-guardium/src/test/java/com/ibm/guardium/azureSQL/ParserTest.java index d0f58ce98..2572e1030 100644 --- a/filter-plugin/logstash-filter-azure-sql-guardium/src/test/java/com/ibm/guardium/azureSQL/ParserTest.java +++ b/filter-plugin/logstash-filter-azure-sql-guardium/src/test/java/com/ibm/guardium/azureSQL/ParserTest.java @@ -9,10 +9,8 @@ import org.junit.Assert; import org.junit.Test; -import com.ibm.guardium.azureSQL.Constants; -import com.ibm.guardium.azureSQL.Parser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -44,7 +42,7 @@ public void createQuery() throws ParseException { Event e=intitalizeEventObject(); e.setField(Constants.STATEMENT, "create table emp1(id int);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -55,7 +53,7 @@ public void insertQuery() throws ParseException { e.setField(Constants.STATEMENT, "INSERT INTO Employee (EmployeeNo, FirstName, LastName, DOB, JoinedDate, DepartmentNo )" + "VALUES ( 101, 'Mike', 'James', '1980-01-05', '2005-03-27', 01);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -66,7 +64,7 @@ public void selectQuery() throws ParseException { e.setField(Constants.STATEMENT, "SELECT A.EmployeeNo, A.DepartmentNo, B.NetPay FROM Employee A " + "INNER JOIN Salary B ON (A.EmployeeNo = B. EmployeeNo);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -77,7 +75,7 @@ public void updateQuery() throws ParseException { Event e=intitalizeEventObject(); e.setField(Constants.STATEMENT, "UPDATE Employee SET DepartmentNo = 03 WHERE EmployeeNo = 101;"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -88,7 +86,7 @@ public void deleteQuery() throws ParseException { Event e=intitalizeEventObject(); e.setField(Constants.STATEMENT, "DELETE FROM Employee WHERE EmployeeNo = 101;"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -128,7 +126,7 @@ public void testErrors() throws ParseException { e.setField(Constants.STATEMENT, "select * from emp;"); e.setField(Constants.ADDITIONAL_INFORMATION, "Invalid object name"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(Constants.SQL_ERROR,record.getException().getExceptionTypeId()); Assert.assertEquals("Invalid object name" diff --git a/filter-plugin/logstash-filter-cassandra-guardium/build.gradle b/filter-plugin/logstash-filter-cassandra-guardium/build.gradle index 33d40d9d8..1b06822ac 100644 --- a/filter-plugin/logstash-filter-cassandra-guardium/build.gradle +++ b/filter-plugin/logstash-filter-cassandra-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginName = "cassandra_guardium_plugin_filter" // must match th // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-cassandra-guardium/gradlew b/filter-plugin/logstash-filter-cassandra-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/CassandraGuardiumPluginFilter.java b/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/CassandraGuardiumPluginFilter.java index 4122ea1a2..90d5156fb 100644 --- a/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/CassandraGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/CassandraGuardiumPluginFilter.java @@ -9,6 +9,7 @@ import java.util.Collections; import java.util.Map; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.commons.collections.map.HashedMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -17,7 +18,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -72,7 +72,7 @@ public Collection filter(Collection events, FilterMatchListener ma String[] keyValue = input_value.split(Constants.INPUT_SPLIT3,Constants.limit); dataMap.put(keyValue[0], keyValue[1]); } - Record record = Parser.parseRecord(dataMap); + UCRecord record = Parser.parseRecord(dataMap); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/Parser.java b/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/Parser.java index 37fed7917..ac9846fc0 100644 --- a/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/Parser.java +++ b/filter-plugin/logstash-filter-cassandra-guardium/src/main/java/com/ibm/guardium/cassandra/Parser.java @@ -6,20 +6,16 @@ import java.text.ParseException; import java.util.Map; + +import com.ibm.guardium.universalconnector.commons.structures.*; import org.apache.commons.validator.routines.InetAddressValidator; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; public class Parser { static ExceptionRecord exceptionRecord; - public static Record parseRecord(final Map data) throws ParseException { + public static UCRecord parseRecord(final Map data) throws ParseException { - Record record = new Record(); + UCRecord record = new UCRecord(); record.setSessionId(Constants.UNKNOWN_STRING); @@ -40,7 +36,7 @@ public static Record parseRecord(final Map data) throws ParseExc } - public static void setDbName(Record record, Map data) { + public static void setDbName(UCRecord record, Map data) { if (data.containsKey(Constants.KEYSPACE)) { record.setDbName(data.get(Constants.KEYSPACE)); } else { @@ -118,7 +114,7 @@ public static Accessor parseAccessor(Map data) { return accessor; } - public static void setExceptionOrDataPart(final Record record, Map data) { + public static void setExceptionOrDataPart(final UCRecord record, Map data) { String operation = data.get(Constants.OPERATION); if (data.get(Constants.CATEGORY).equals(Constants.AUTH)) { if (data.get(Constants.TYPE).equals(Constants.LOGIN_SUCCESS)) { @@ -143,14 +139,14 @@ public static void setExceptionOrDataPart(final Record record, Map data, Record record, String[] error) { + static void setException(Map data, UCRecord record, String[] error) { exceptionRecord.setDescription(error[1]); exceptionRecord.setSqlString(error[0]); record.setException(exceptionRecord); } - static void setData(Map data, Record record) { + static void setData(Map data, UCRecord record) { Data outputData = new Data(); outputData.setOriginalSqlCommand(data.get(Constants.OPERATION)); record.setData(outputData); diff --git a/filter-plugin/logstash-filter-cassandra-guardium/src/test/java/com/ibm/guardium/cassandra/ParserTest.java b/filter-plugin/logstash-filter-cassandra-guardium/src/test/java/com/ibm/guardium/cassandra/ParserTest.java index d6caef44f..4b26580dd 100644 --- a/filter-plugin/logstash-filter-cassandra-guardium/src/test/java/com/ibm/guardium/cassandra/ParserTest.java +++ b/filter-plugin/logstash-filter-cassandra-guardium/src/test/java/com/ibm/guardium/cassandra/ParserTest.java @@ -10,7 +10,7 @@ import org.junit.Assert; import org.junit.Test; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; public class ParserTest { @@ -36,7 +36,7 @@ Map intializeMap() { @Test public void testParseRecord() throws ParseException { - final Record record = Parser.parseRecord(intializeMap()); + final UCRecord record = Parser.parseRecord(intializeMap()); Assert.assertEquals(Constants.TEXT, record.getAccessor().getDataType()); Assert.assertEquals(null, record.getException()); @@ -54,7 +54,7 @@ public void testParseRecordError() throws ParseException { "Select * from employee;; No keyspace has been specified. USE a keyspace, or explicitly specify keyspace.tablename"); intrimData.put("category", "ERROR"); - final Record record = Parser.parseRecord(intrimData); + final UCRecord record = Parser.parseRecord(intrimData); Assert.assertEquals(Constants.TEXT, record.getAccessor().getDataType()); Assert.assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); @@ -73,7 +73,7 @@ public void testParseRecordAuthSuccess() throws ParseException { intrimData.put("operation", "LOGIN SUCCESSFUL"); intrimData.put("category", "AUTH"); - final Record record = Parser.parseRecord(intrimData); + final UCRecord record = Parser.parseRecord(intrimData); Assert.assertEquals(Constants.TEXT, record.getAccessor().getDataType()); Assert.assertNull(record.getException()); @@ -93,7 +93,7 @@ public void testParseRecordAuthFail() throws ParseException { "CREATE USER test WITH PASSWORD *******; User test does not have sufficient privileges to perform the requested operation"); intrimData.put("category", "AUTH"); - final Record record = Parser.parseRecord(intrimData); + final UCRecord record = Parser.parseRecord(intrimData); Assert.assertEquals(Constants.TEXT, record.getAccessor().getDataType()); Assert.assertNotNull(record.getException()); diff --git a/filter-plugin/logstash-filter-cosmos-azure-guardium/AzureCosmosOverAzureEventHub/guardium_logstash-offline-plugin-azure-cosmos.zip b/filter-plugin/logstash-filter-cosmos-azure-guardium/AzureCosmosOverAzureEventHub/guardium_logstash-offline-plugin-azure-cosmos.zip index 620384c49..8669d5327 100644 Binary files a/filter-plugin/logstash-filter-cosmos-azure-guardium/AzureCosmosOverAzureEventHub/guardium_logstash-offline-plugin-azure-cosmos.zip and b/filter-plugin/logstash-filter-cosmos-azure-guardium/AzureCosmosOverAzureEventHub/guardium_logstash-offline-plugin-azure-cosmos.zip differ diff --git a/filter-plugin/logstash-filter-cosmos-azure-guardium/build.gradle b/filter-plugin/logstash-filter-cosmos-azure-guardium/build.gradle index 4416fc462..f7e83d806 100644 --- a/filter-plugin/logstash-filter-cosmos-azure-guardium/build.gradle +++ b/filter-plugin/logstash-filter-cosmos-azure-guardium/build.gradle @@ -21,8 +21,8 @@ pluginInfo.pluginClass = "AzureCosmosGuardiumFilter" pluginInfo.pluginName = "azure_cosmos_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { @@ -34,7 +34,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -143,4 +143,4 @@ jacocoTestReport { }) } } -test.finalizedBy jacocoTestReport \ No newline at end of file +test.finalizedBy jacocoTestReport diff --git a/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/AzureCosmosGuardiumFilter.java b/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/AzureCosmosGuardiumFilter.java index fc294fe2a..1e7afa0a6 100644 --- a/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/AzureCosmosGuardiumFilter.java +++ b/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/AzureCosmosGuardiumFilter.java @@ -7,6 +7,7 @@ import java.util.Collection; import java.util.Collections; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,7 +15,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -54,7 +54,7 @@ public Collection filter(Collection events, FilterMatchListener ma String messageString = event.getField("message").toString(); try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final Gson gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create(); event.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, gson.toJson(record)); matchListener.filterMatched(event); diff --git a/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/Parser.java b/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/Parser.java index 3ce25da8d..b0c33449e 100644 --- a/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/Parser.java +++ b/filter-plugin/logstash-filter-cosmos-azure-guardium/src/main/java/com/ibm/guardium/azure/cosmos/Parser.java @@ -5,15 +5,7 @@ package com.ibm.guardium.azure.cosmos; import com.ibm.guardium.universalconnector.commons.Util; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.*; import java.net.URLDecoder; import java.time.ZonedDateTime; @@ -39,13 +31,13 @@ public class Parser { * @return * @throws Exception */ - public static Record parseRecord(final JsonObject records) throws Exception { + public static UCRecord parseRecord(final JsonObject records) throws Exception { if(log.isDebugEnabled()){ log.debug("Event Now: ",records); } - - Record record = new Record(); + + UCRecord record = new UCRecord(); try { if(records.has(ApplicationConstants.PROPERTIES) && records.get(ApplicationConstants.PROPERTIES).getAsJsonObject()!=null){ @@ -457,7 +449,7 @@ private static SessionLocator parserSessionLocator(JsonObject records, JsonObjec * * @param subId * @param accountId - * @param records + * @param properties * @return */ private static Accessor parseAccessor(String subId, String accountId, JsonObject properties) { diff --git a/filter-plugin/logstash-filter-cosmos-azure-guardium/src/test/java/com/ibm/guardium/azure/cosmos/ParserTest.java b/filter-plugin/logstash-filter-cosmos-azure-guardium/src/test/java/com/ibm/guardium/azure/cosmos/ParserTest.java index a4f7e249c..8c5da0ce5 100644 --- a/filter-plugin/logstash-filter-cosmos-azure-guardium/src/test/java/com/ibm/guardium/azure/cosmos/ParserTest.java +++ b/filter-plugin/logstash-filter-cosmos-azure-guardium/src/test/java/com/ibm/guardium/azure/cosmos/ParserTest.java @@ -7,7 +7,7 @@ import static org.junit.Assert.*; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Test; public class ParserTest { @@ -16,7 +16,7 @@ public class ParserTest { public void testparseGetTime() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T11:37:17.0556567Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"DataPlaneRequests\",\"operationName\":\"Create\",\"properties\":{\"activityId\":\"880d1d92-159c-4134-ae35-9c4e48807fd3\",\"requestResourceType\":\"DatabaseFeed\",\"requestResourceId\":\"\\/dbs\",\"collectionRid\":\"\",\"databaseRid\":\"\",\"statusCode\":\"201\",\"duration\":\"444.264900\",\"userAgent\":\"Microsoft.Azure.Documents.Common\\/2.14.0\",\"clientIpAddress\":\"20.193.136.102\",\"requestCharge\":\"1.000000\",\"requestLength\":\"25\",\"responseLength\":\"175\",\"resourceTokenPermissionId\":\"\",\"resourceTokenPermissionMode\":\"\",\"resourceTokenUserRid\":\"\",\"region\":\"Central India\",\"partitionId\":\"\",\"aadAppliedRoleAssignmentId\":\"\",\"aadPrincipalId\":\"\",\"authTokenType\":\"PrimaryMasterKey\",\"keyType\":\"PrimaryMasterKey\",\"connectionMode\":\"Gateway\",\"subscriptionId\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"databaseName\":\"\",\"collectionName\":\"\"}}"; final JsonObject CosmosJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record = Parser.parseRecord(CosmosJson); + UCRecord record = Parser.parseRecord(CosmosJson); assertEquals(1676979437055L, record.getTime().getTimstamp()); assertNotNull(record); } @@ -26,7 +26,7 @@ public void testparseGetTime() throws Exception { public void testparseClientip() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T11:37:17.0556567Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"DataPlaneRequests\",\"operationName\":\"Create\",\"properties\":{\"activityId\":\"880d1d92-159c-4134-ae35-9c4e48807fd3\",\"requestResourceType\":\"DatabaseFeed\",\"requestResourceId\":\"\\/dbs\",\"collectionRid\":\"\",\"databaseRid\":\"\",\"statusCode\":\"201\",\"duration\":\"444.264900\",\"userAgent\":\"Microsoft.Azure.Documents.Common\\/2.14.0\",\"clientIpAddress\":\"20.193.136.102\",\"requestCharge\":\"1.000000\",\"requestLength\":\"25\",\"responseLength\":\"175\",\"resourceTokenPermissionId\":\"\",\"resourceTokenPermissionMode\":\"\",\"resourceTokenUserRid\":\"\",\"region\":\"Central India\",\"partitionId\":\"\",\"aadAppliedRoleAssignmentId\":\"\",\"aadPrincipalId\":\"\",\"authTokenType\":\"PrimaryMasterKey\",\"keyType\":\"PrimaryMasterKey\",\"connectionMode\":\"Gateway\",\"subscriptionId\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"databaseName\":\"\",\"collectionName\":\"\"}}"; final JsonObject CosmosJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record = Parser.parseRecord(CosmosJson); + UCRecord record = Parser.parseRecord(CosmosJson); assertEquals("20.193.136.102",record.getSessionLocator().getClientIp()); } @@ -35,7 +35,7 @@ public void testparseClientip() throws Exception { public void testQuery_select() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T06:03:28.9493677Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083FE1FC-CD4D-5B6C-895B-2B5AF1D082F4\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"f1810797-e32e-406d-af59-2280fea8001e\",\"databasename\":\"FamiliesDatabase\",\"collectionname\":\"Families\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083fe1fc-cd4d-5b6c-895b-2b5af1d082f4\",\"resourcegroupname\":\"Azure-cosmos\",\"partialipaddress\":\"52.140.110.66\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"2\",\"signature\":\"-1661408583400352360\",\"shapesignature\":\"8235320023077058687\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT f._rid, [{\\\\\\\"item\\\\\\\": f.address.city}] AS orderByItems, {\\\\\\\"givenName\\\\\\\": c.givenName} AS payload\\\\nFROM Families AS f\\\\nJOIN c IN f.children\\\\nWHERE ((f.id = \\\\\\\"WakefieldFamily\\\\\\\") AND (true))\\\\nORDER BY f.address.city ASC\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select", record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("f.children",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -44,7 +44,7 @@ public void testQuery_select() throws Exception { public void testparseINKeyword() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM Families WHERE Families.id IN ('AndersenFamily', 'WakefieldFamily')\\\" ,\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).getName()); } @@ -53,7 +53,7 @@ public void testparseINKeyword() throws Exception { public void testparseWHERE() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT c.givenName FROM Families f JOIN c IN f.children WHERE f.id = 'WakefieldFamily' ORDER BY f.address.city ASC\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -62,7 +62,7 @@ public void testparseWHERE() throws Exception { public void testparseCOUNT() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT TOP 5 f.id, (SELECT VALUE Count(1) FROM n IN f.nutrients WHERE n.units = 'mg') AS count_mg FROM food f\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("food",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); assertEquals("f.nutrients",record.getData().getConstruct().getSentences().get(0).getDescendants().get(0).getObjects().get(0).name); @@ -72,7 +72,7 @@ public void testparseCOUNT() throws Exception { public void testparseCONCAT() throws Exception { final String CosmoString="{\"time\":\"2023-03-29T13:15:47.5292582Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"ac76039d-7de4-49c1-884c-9de2e073a088\",\"databasename\":\"cosmoDB\",\"collectionname\":\"Families\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"0\",\"signature\":\"7836615225522989813\",\"shapesignature\":\"-1520510819878011583\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT TOP 5 (SELECT VALUE Concat('id_', f.id)) AS id FROM food f\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("food",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -81,7 +81,7 @@ public void testparseCONCAT() throws Exception { public void testparseENDSWITH() throws Exception { final String CosmoString="{\"time\":\"2023-03-30T06:36:25.1036312Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"1b93a44b-ffbc-4c0f-9466-37934e81b5c9\",\"databasename\":\"cosmoDB\",\"collectionname\":\"Families\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"2\",\"signature\":\"3330002102473822776\",\"shapesignature\":\"-1026639395066501040\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT ENDSWITH(\\\\\\\"abc\\\\\\\", \\\\\\\"b\\\\\\\", false) AS e1, ENDSWITH(\\\\\\\"abc\\\\\\\", \\\\\\\"bC\\\\\\\", false) AS e2, ENDSWITH(\\\\\\\"abc\\\\\\\", \\\\\\\"bC\\\\\\\", true) AS e3 from myhome\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("myhome",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -89,7 +89,7 @@ public void testparseENDSWITH() throws Exception { @Test public void testparseaddress() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM Families.address.state\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families.address.state",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8:COSMOS-DATABASE:cosmoDB",record.getDbName()); @@ -99,7 +99,7 @@ public void testparseaddress() throws Exception { public void testparsepayload() throws Exception { final String CosmoString="{\"time\":\"2023-03-29T12:55:56.2461944Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"0b76d57d-d22d-4cb2-b912-7726e24b69ba\",\"databasename\":\"cosmoDB\",\"collectionname\":\"Families\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"2363625393322487707\",\"shapesignature\":\"7572324026122958197\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT {\\\\\\\"Count\\\\\\\": {\\\\\\\"item\\\\\\\": Count(1)}} AS payload\\\\nFROM c\\\\nJOIN t IN c.tags\\\\nJOIN n IN c.nutrients\\\\nJOIN s IN c.servings\\\\nWHERE (((t.name = \\\\\\\"infant formula\\\\\\\") AND ((n.nutritionValue > 0) AND (n.nutritionValue < 10))) AND (s.amount > 1))\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -108,7 +108,7 @@ public void testparsepayload() throws Exception { public void testparseItems() throws Exception { final String CosmoString="{\"time\":\"2023-03-29T12:51:33.8058662Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"2ff43f42-bea8-441d-b46e-cc53219355b4\",\"databasename\":\"cosmoDB\",\"collectionname\":\"Families\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"0\",\"signature\":\"-1661408583400352360\",\"shapesignature\":\"8235320023077058687\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT f._rid, [{\\\\\\\"item\\\\\\\": f.address.city}] AS orderByItems, {\\\\\\\"givenName\\\\\\\": c.givenName} AS payload\\\\nFROM Families AS f\\\\nJOIN c IN f.children\\\\nWHERE ((f.id = \\\\\\\"WakefieldFamily\\\\\\\") AND (true))\\\\nORDER BY f.address.city ASC\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("f.children",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -117,7 +117,7 @@ public void testparseItems() throws Exception { public void testparsepersonId() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceIds\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT p.FirstName, p.LastName, a.City, cd.Detail FROM Person p JOIN ContactDetail cd ON cd.PersonId = p.Id JOIN ContactDetailType cdt ON cdt.Id = cd.TypeId JOIN Address a ON a.PersonId = p.Id\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("ContactDetail",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -125,7 +125,7 @@ public void testparsepersonId() throws Exception { public void testparseControlPlane() throws Exception { final String CosmoString="{ \"time\": \"2023-03-13T09:56:41.5889464Z\", \"resourceId\": \"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8/RESOURCEGROUPS/AZURE-COSMO/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/COSMOS-DATABASE\", \"subscriptionId\": \"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\", \"operationName\": \"SqlContainersDelete\", \"category\": \"ControlPlaneRequests\", \"properties\": {\"activityId\": \"5520ee10-c185-11ed-8bc3-12f484077d92\",\"httpstatusCode\": \"204\",\"result\": \"OK\",\"httpMethod\": \"DELETE\",\"apiKind\": \"Sql\",\"apiKindResourceType\": \"Containers\",\"operationType\": \"Delete\",\"resourceUri\": \"sqlDatabases/MyDatabase/containers/products\",\"resourceDetails\": \"\"}}"; final JsonObject CosmosJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record = Parser.parseRecord(CosmosJson); + UCRecord record = Parser.parseRecord(CosmosJson); assertEquals("SqlContainersDelete",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("sqlDatabases/MyDatabase/containers/products",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); assertEquals("0.0.0.0",record.getSessionLocator().getClientIp()); @@ -135,7 +135,7 @@ public void testparseControlPlane() throws Exception { public void testparseControlPlaneResourceUri() throws Exception { final String CosmoString="{ \"time\": \"2023-03-13T09:56:41.5889464Z\", \"resourceId\": \"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8/RESOURCEGROUPS/AZURE-COSMO/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/COSMOS-DATABASE\", \"subscriptionId\": \"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\", \"operationName\": \"SqlContainersDelete\", \"category\": \"ControlPlaneRequests\", \"properties\": {\"activityId\": \"5520ee10-c185-11ed-8bc3-12f484077d92\",\"httpstatusCode\": \"204\",\"result\": \"OK\",\"httpMethod\": \"DELETE\",\"apiKind\": \"Sql\",\"apiKindResourceType\": \"Containers\",\"operationType\": \"Delete\",\"resourceUri\": \"sqlDatabases/MyDatabase/containers/products\",\"resourceDetails\": \"\"}}"; final JsonObject CosmosJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record = Parser.parseRecord(CosmosJson); + UCRecord record = Parser.parseRecord(CosmosJson); assertEquals("SqlContainersDelete",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("sqlDatabases/MyDatabase/containers/products",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); assertEquals("0.0.0.0",record.getSessionLocator().getClientIp()); @@ -144,7 +144,7 @@ public void testparseControlPlaneResourceUri() throws Exception { public void testparseDataPlane() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T11:37:17.0556567Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"DataPlaneRequests\",\"operationName\":\"Create\",\"properties\":{\"activityId\":\"880d1d92-159c-4134-ae35-9c4e48807fd3\",\"requestResourceType\":\"DatabaseFeed\",\"requestResourceId\":\"\\/dbs\",\"collectionRid\":\"\",\"databaseRid\":\"\",\"statusCode\":\"201\",\"duration\":\"444.264900\",\"userAgent\":\"Microsoft.Azure.Documents.Common\\/2.14.0\",\"clientIpAddress\":\"20.193.136.102\",\"requestCharge\":\"1.000000\",\"requestLength\":\"25\",\"responseLength\":\"175\",\"resourceTokenPermissionId\":\"\",\"resourceTokenPermissionMode\":\"\",\"resourceTokenUserRid\":\"\",\"region\":\"Central India\",\"partitionId\":\"\",\"aadAppliedRoleAssignmentId\":\"\",\"aadPrincipalId\":\"\",\"authTokenType\":\"PrimaryMasterKey\",\"keyType\":\"PrimaryMasterKey\",\"connectionMode\":\"Gateway\",\"subscriptionId\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"databaseName\":\"\",\"collectionName\":\"\"}}"; final JsonObject CosmosJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record = Parser.parseRecord(CosmosJson); + UCRecord record = Parser.parseRecord(CosmosJson); assertEquals("Create",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("/dbs",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); assertEquals("20.193.136.102",record.getSessionLocator().getClientIp()); @@ -153,7 +153,7 @@ public void testparseDataPlane() throws Exception { public void testparseNestedQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT COUNT(UniqueLastNames)FROM (SELECT AVG(film.age) FROM film GROUP BY film.lastName) AS UniqueLastNames\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -161,7 +161,7 @@ public void testparseNestedQuery() throws Exception { public void testparseGroupBy() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT COUNT(1)FROM (SELECT AVG(f.age)FROM f GROUP BY f.lastName)\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -169,7 +169,7 @@ public void testparseGroupBy() throws Exception { public void testparseExists() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT TOP 5 f.id, f.tagsFROM food f WHERE EXISTS(SELECT VALUE t FROM t IN f.tags WHERE t.name = 'orange')\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -177,7 +177,7 @@ public void testparseExists() throws Exception { public void testparseStartsWith() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM products p WHERE STARTSWITH(p.tags[0].slug, \'color-group-\')\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("products",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -186,7 +186,7 @@ public void testparseStartsWith() throws Exception { public void testparseSpatialfunc() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT f.id FROM Families f WHERE ST_DISTANCE(f.location, {'type': 'Point', 'coordinates':[31.9, -4.8]}) < 30000\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -195,7 +195,7 @@ public void testparseSpatialfunc() throws Exception { public void testparseSpatialfunc1() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\" SELECT a.id FROM Areas a WHERE ST_INTERSECTS(a.location, { 'type':'Polygon','coordinates': [[[31.8, -5], [32, -5], [32, -4.7], [31.8, -4.7], [31.8, -5]]] })\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Areas",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -205,7 +205,7 @@ public void testparseSpatialfunc1() throws Exception { public void testparseBitwiseOperator() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\" SELECT (100 >> 2) AS rightShift,(100 << 2) AS leftShift,(100 >>> 0) AS zeroFillRightShift,(100 & 1000) AS logicalAnd,(100 | 1000) AS logicalOr,(100 ^ 1000) AS logicalExclusiveOr\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -213,7 +213,7 @@ public void testparseBitwiseOperator() throws Exception { public void testparseOffsetLimit() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT f.id, f.address.city FROM Families f ORDER BY f.address.city OFFSET 1 LIMIT 1\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -223,7 +223,7 @@ public void testparseOffsetLimit() throws Exception { public void testparseMathfunc() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT ABS(-1) AS abs1, ABS(0) AS abs2, ABS(1) AS abs3\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -231,7 +231,7 @@ public void testparseMathfunc() throws Exception { public void testparseNormalQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"select * from ABC\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("ABC",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -240,7 +240,7 @@ public void testparseNormalQuery() throws Exception { public void testparseLikekeyword() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM c WHERE c.description LIKE \\\'%fruit%\\\'\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -249,7 +249,7 @@ public void testparseLikekeyword() throws Exception { public void testparseNotLikekeyword() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM c WHERE c.description NOT LIKE \\\'%fruit%\\\'\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -258,7 +258,7 @@ public void testparseNotLikekeyword() throws Exception { public void testparseEscapeClause() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM c WHERE c.description LIKE '%20-30!%%' ESCAPE '!'\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -268,7 +268,7 @@ public void testparseEscapeClause() throws Exception { public void testparseUDF() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT Families.id, Families.address.city FROM Families WHERE udf.REGEX_MATCH(Families.address.city, \'.*eattle\')\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -277,7 +277,7 @@ public void testparseUDF() throws Exception { public void testparseBetween() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT (c.grade BETWEEN 0 AND 10)FROM Families.children[0] c\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families.children[0]",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -286,7 +286,7 @@ public void testparseBetween() throws Exception { public void testparseAggregate() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT AVG(c.propertyA)FROM c\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -295,7 +295,7 @@ public void testparseAggregate() throws Exception { public void testparseMin() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT MIN(cities.propertyA)FROM cities\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("cities",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -304,7 +304,7 @@ public void testparseMin() throws Exception { public void testparseMax() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT MAX(c.propertyA)FROM c\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -313,7 +313,7 @@ public void testparseMax() throws Exception { public void testparseArrayQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT c.InvoiceNumber,c.Customer.Name FROM c WHERE ARRAY_CONTAINS(c.CustomerComments, \'Superb\')\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -322,7 +322,7 @@ public void testparseArrayQuery() throws Exception { public void testparseParamQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\" SELECT * FROM Families f WHERE f.lastName = @lastName AND f.address.state = @addressState\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -331,7 +331,7 @@ public void testparseParamQuery() throws Exception { public void testparseValueQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT VALUE child FROM child IN Parents.children\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Parents.children",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -340,14 +340,14 @@ public void testparseValueQuery() throws Exception { public void testparseQueryRuntimeStatics() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT *\\\\r\\\\n FROM cosmosDB collection\\\\r\\\\n WHERE collection.id = 'AndersenFamily'\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmosJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record = Parser.parseRecord(CosmosJson); + UCRecord record = Parser.parseRecord(CosmosJson); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8:COSMOS-DATABASE:cosmoDB", record.getDbName()); } @Test public void testparseGrade() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT * FROM Families f WHERE ({grade: f.children[0].grade}.grade > 3)\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -356,7 +356,7 @@ public void testparseGrade() throws Exception { public void testparseValueGrade() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\" SELECT VALUE {\'name\':f.children[0].familyName,\'grade\': f.children[0].grade + 3 } FROM Families123 f\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("Families123",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -365,7 +365,7 @@ public void testparseValueGrade() throws Exception { public void testparseNutrition() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT TOP 1000 c.id, m.MaxNutritionValue FROM cJOIN (SELECT udf.GetMaxNutritionValue(c.nutrients) AS MaxNutritionValue) m WHERE m.MaxNutritionValue > 100\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("cJOIN",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -374,7 +374,7 @@ public void testparseNutrition() throws Exception { public void testparse3obj() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT Count(1) AS Count FROM c JOIN t IN c.tags JOIN n IN c.nutrients JOIN s IN c.servings WHERE t.name = 'infant formula' AND (n.nutritionValue > 0 AND n.nutritionValue < 10) AND s.amount > 1\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c.nutrients",record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); } @@ -383,7 +383,7 @@ public void testparse3obj() throws Exception { public void testparseDescsobj() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT a.Name,{\'Make\': a.Make, \'Model\': a.Model, \'SellingPrice\': a.SellingPrice} AS InvoiceDetails FROM (SELECT c.InvoiceNumber,c.Customer.Name,cx.LineItem,cx.Make,cx.Model,cx.SellingPrice FROM c JOIN cx IN c.Salesdetails) a\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("c",record.getData().getConstruct().getSentences().get(0).getDescendants().get(0).getObjects().get(0).name); } @@ -392,7 +392,7 @@ public void testparseDescsobj() throws Exception { public void testparseCurrentTime() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT GetCurrentDateTime() AS currentUtcDateTime\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -400,7 +400,7 @@ public void testparseCurrentTime() throws Exception { public void testparseIndexQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT INDEX_OF(\'abc\', \'ab\') AS index_of_prefix,INDEX_OF(\'abc\', \'b\') AS index_of_middle,INDEX_OF(\'abc\', \'c\') AS index_of_last,INDEX_OF(\'abc\', \'d\') AS index_of_missing\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -408,7 +408,7 @@ public void testparseIndexQuery() throws Exception { public void testparseReplaceQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT REPLACE(\'This is a Test\', \'Test\', \'desk\') AS replace\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8:COSMOS-DATABASE:cosmoDB",record.getDbName()); } @@ -417,7 +417,7 @@ public void testparseReplaceQuery() throws Exception { public void testparseReverseQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT REVERSE(\'Abc\') AS reverse\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8:COSMOS-DATABASE:cosmoDB",record.getDbName()); assertEquals(1680004089768L,record.getTime().getTimstamp()); @@ -427,7 +427,7 @@ public void testparseReverseQuery() throws Exception { public void testparseRTRIM() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\" SELECT RTRIM(\' abc\') AS t1, RTRIM(\' abc \') AS t2, RTRIM(\'abc \') AS t3, RTRIM(\'abc\') AS t4,RTRIM(\'abc\', \'bc\') AS t5,RTRIM(\'abc\', \'abc\') AS t6\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -435,7 +435,7 @@ public void testparseRTRIM() throws Exception { public void testparseLeftQuery() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT LEFT(\'abc\', 1) AS l1, LEFT(\'abc\', 2) AS l2\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -443,7 +443,7 @@ public void testparseLeftQuery() throws Exception { public void testparseStringToBoolean() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT StringToBoolean(\'true\') AS b1, StringToBoolean(\' false\') AS b2,StringToBoolean(\'false \') AS b3\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8:COSMOS-DATABASE:cosmoDB",record.getDbName()); } @@ -452,7 +452,7 @@ public void testparseStringToBoolean() throws Exception { public void testparseStringToNull() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT StringToNull(\'null\') AS n1, StringToNull(\' null \') AS n2, IS_NULL(StringToNull(\'null \')) AS n3\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -460,7 +460,7 @@ public void testparseStringToNull() throws Exception { public void testparseStringToNumber() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT StringToNumber(\'1.000000\') AS num1, StringToNumber(\'3.14\') AS num2,StringToNumber(\' 60 \') AS num3, StringToNumber(\'-1.79769e+308\') AS num4\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); } @@ -468,7 +468,7 @@ public void testparseStringToNumber() throws Exception { public void testparseSubString() throws Exception { final String CosmoString="{\"time\":\"2023-03-28T11:48:09.7683235Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8\\/RESOURCEGROUPS\\/AZURE-COSMO\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/COSMOS-DATABASE\",\"category\":\"QueryRuntimeStatistics\",\"properties\":{\"activityId\":\"a4081ca7-70b8-4d73-aca9-4e92044cbe4d\",\"databasename\":\"cosmoDB\",\"collectionname\":\"collection\",\"partitionkeyrangeid\":\"0\",\"useragent\":\"Microsoft.Azure.Documents.Common\\/2.14.0RoutingGateway\",\"subscriptionid\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"resourcegroupname\":\"azure-cosmo\",\"partialipaddress\":\"40.80.50.2\",\"regionname\":\"Central India\",\"authtype\":\"1\",\"numberofrowsreturned\":\"1\",\"signature\":\"-4576541951102199744\",\"shapesignature\":\"-8612658657970479756\",\"queryexecutionstatus\":\"Finished\",\"querytext\":\"{\\\"query\\\":\\\"SELECT SUBSTRING(\'abc\', 1, 1) AS substring\\\",\\\"parameters\\\":[]}\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("select",record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8-COSMOS-DATABASE.azure.com",record.getAccessor().getServerHostName()); } @@ -477,7 +477,7 @@ public void testparseSubString() throws Exception { public void testparseIpv6() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T11:37:17.0556567Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"DataPlaneRequests\",\"operationName\":\"Create\",\"properties\":{\"activityId\":\"880d1d92-159c-4134-ae35-9c4e48807fd3\",\"requestResourceType\":\"DatabaseFeed\",\"requestResourceId\":\"\\/dbs\",\"collectionRid\":\"\",\"databaseRid\":\"\",\"statusCode\":\"201\",\"duration\":\"444.264900\",\"userAgent\":\"Microsoft.Azure.Documents.Common\\/2.14.0\",\"clientIpAddress\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\",\"requestCharge\":\"1.000000\",\"requestLength\":\"25\",\"responseLength\":\"175\",\"resourceTokenPermissionId\":\"\",\"resourceTokenPermissionMode\":\"\",\"resourceTokenUserRid\":\"\",\"region\":\"Central India\",\"partitionId\":\"\",\"aadAppliedRoleAssignmentId\":\"\",\"aadPrincipalId\":\"\",\"authTokenType\":\"PrimaryMasterKey\",\"keyType\":\"PrimaryMasterKey\",\"connectionMode\":\"Gateway\",\"subscriptionId\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"databaseName\":\"\",\"collectionName\":\"\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("0000:0000:0000:0000:0000:FFFF:0000:0000",record.getSessionLocator().getServerIpv6()); assertEquals("2001:0db8:85a3:0000:0000:8a2e:0370:7334",record.getSessionLocator().getClientIpv6()); } @@ -486,7 +486,7 @@ public void testparseIpv6() throws Exception { public void testparseServerHostName() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T11:37:17.0556567Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"DataPlaneRequests\",\"operationName\":\"Create\",\"properties\":{\"activityId\":\"880d1d92-159c-4134-ae35-9c4e48807fd3\",\"requestResourceType\":\"DatabaseFeed\",\"requestResourceId\":\"\\/dbs\",\"collectionRid\":\"\",\"databaseRid\":\"\",\"statusCode\":\"201\",\"duration\":\"444.264900\",\"userAgent\":\"Microsoft.Azure.Documents.Common\\/2.14.0\",\"clientIpAddress\":\"20.193.136.102\",\"requestCharge\":\"1.000000\",\"requestLength\":\"25\",\"responseLength\":\"175\",\"resourceTokenPermissionId\":\"\",\"resourceTokenPermissionMode\":\"\",\"resourceTokenUserRid\":\"\",\"region\":\"Central India\",\"partitionId\":\"\",\"aadAppliedRoleAssignmentId\":\"\",\"aadPrincipalId\":\"\",\"authTokenType\":\"PrimaryMasterKey\",\"keyType\":\"PrimaryMasterKey\",\"connectionMode\":\"Gateway\",\"subscriptionId\":\"\",\"databaseName\":\"\",\"collectionName\":\"\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("cosmos.azure.com",record.getAccessor().getServerHostName()); } @@ -494,7 +494,7 @@ public void testparseServerHostName() throws Exception { public void testparseException() throws Exception { final String CosmoString="{\"time\":\"2023-02-21T11:37:17.0556567Z\",\"resourceId\":\"\\/SUBSCRIPTIONS\\/083DE1FB-CD2D-4B7C-895A-2B5AF1D09E8\\/RESOURCEGROUPS\\/AZURE-COSMOS\\/PROVIDERS\\/MICROSOFT.DOCUMENTDB\\/DATABASEACCOUNTS\\/DEV-COSMO\",\"category\":\"DataPlaneRequests\",\"operationName\":\"Create\",\"properties\":{\"activityId\":\"880d1d92-159c-4134-ae35-9c4e48807fd3\",\"requestResourceType\":\"DatabaseFeed\",\"requestResourceId\":\"\\/dbs\",\"collectionRid\":\"\",\"databaseRid\":\"\",\"statusCode\":\"400\",\"duration\":\"444.264900\",\"userAgent\":\"Microsoft.Azure.Documents.Common\\/2.14.0\",\"clientIpAddress\":\"20.193.136.102\",\"requestCharge\":\"1.000000\",\"requestLength\":\"25\",\"responseLength\":\"175\",\"resourceTokenPermissionId\":\"\",\"resourceTokenPermissionMode\":\"\",\"resourceTokenUserRid\":\"\",\"region\":\"Central India\",\"partitionId\":\"\",\"aadAppliedRoleAssignmentId\":\"\",\"aadPrincipalId\":\"\",\"authTokenType\":\"PrimaryMasterKey\",\"keyType\":\"PrimaryMasterKey\",\"connectionMode\":\"Gateway\",\"subscriptionId\":\"083de1fb-cd2d-4b7c-895a-2b5af1d09e8\",\"databaseName\":\"\",\"collectionName\":\"\"}}"; final JsonObject CosmoJson = JsonParser.parseString(CosmoString).getAsJsonObject(); - Record record=Parser.parseRecord(CosmoJson); + UCRecord record=Parser.parseRecord(CosmoJson); assertEquals("Error (400)",record.getException().getDescription()); assertEquals("SQL_ERROR",record.getException().getExceptionTypeId()); diff --git a/filter-plugin/logstash-filter-couchbasedb-guardium/build.gradle b/filter-plugin/logstash-filter-couchbasedb-guardium/build.gradle index d024fa980..abcb17244 100644 --- a/filter-plugin/logstash-filter-couchbasedb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-couchbasedb-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "CouchbasedbGuardiumPluginFilter" pluginInfo.pluginName = "couchbasedb_guardium_plugin_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-couchbasedb-guardium/gradlew b/filter-plugin/logstash-filter-couchbasedb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilter.java b/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilter.java index 3ab44bd74..4d039f6a5 100644 --- a/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilter.java @@ -14,7 +14,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -67,7 +67,7 @@ public Collection filter(Collection events, FilterMatchListener ma if(e.getField(Constants.SERVER_HOSTNAME) instanceof String) { inputJSON.addProperty(Constants.SERVER_HOSTNAME, e.getField(Constants.SERVER_HOSTNAME).toString()); } - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/Parser.java b/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/Parser.java index b0503b07b..0dfe6210b 100644 --- a/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/Parser.java +++ b/filter-plugin/logstash-filter-couchbasedb-guardium/src/main/java/com/ibm/guardium/couchbasedb/Parser.java @@ -4,20 +4,12 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import com.ibm.guardium.universalconnector.commons.structures.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.commons.validator.routines.InetAddressValidator; import com.google.gson.JsonObject; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; public class Parser { @@ -32,9 +24,9 @@ public static Boolean checkForUIGeneratedQueries(final JsonObject data) { return isUIGeneratedQuery; } - public static Record parseRecord(final JsonObject data) throws ParseException { - - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws ParseException { + + UCRecord record = new UCRecord(); record.setSessionId(parseSessionID(data)); @@ -53,7 +45,7 @@ public static Record parseRecord(final JsonObject data) throws ParseException { return record; } - public static void setExceptionOrDataPart(final Record record,final JsonObject data){ + public static void setExceptionOrDataPart(final UCRecord record,final JsonObject data){ if(record.getAccessor().getDataType().equals(Constants.TEXT)) { diff --git a/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilterTest.java b/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilterTest.java index cc989b056..fdabb5043 100644 --- a/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilterTest.java +++ b/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/CouchbasedbGuardiumPluginFilterTest.java @@ -10,12 +10,10 @@ import org.junit.Assert; import org.junit.Test; -//import org.logstash.plugins.ConfigurationImpl; import org.logstash.plugins.ContextImpl; import com.ibm.guardium.universalconnector.commons.GuardConstants; -//import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; import co.elastic.logstash.api.FilterMatchListener; diff --git a/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/ParserTest.java b/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/ParserTest.java index 15cc0f703..96ed33fe6 100644 --- a/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/ParserTest.java +++ b/filter-plugin/logstash-filter-couchbasedb-guardium/src/test/java/com/ibm/guardium/couchbasedb/ParserTest.java @@ -6,16 +6,12 @@ import java.text.ParseException; +import com.ibm.guardium.universalconnector.commons.structures.*; import org.junit.Assert; import org.junit.Test; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; public class ParserTest { @@ -28,7 +24,7 @@ public class ParserTest { public void testForAdminRestAPI() throws ParseException { final String couchbaseString = "{\"description\":\"An HTTP request was made to the API at /admin/config.\",\"httpMethod\":\"GET\",\"httpResultCode\":200,\"id\":28698,\"name\":\"/admin/config API request\",\"real_userid\":{\"domain\":\"builtin\",\"user\":\"Administrator\"},\"remote\":{\"ip\":\"172.17.0.1\",\"port\":49480},\"timestamp\":\"2021-05-26T10:00:46.406Z\",\"serverHostname\":\"test.couchbase.com\", \"serverIP\":\"0.0.0.0\"}"; final JsonObject couchbaseJson = JsonParser.parseString(couchbaseString).getAsJsonObject(); - final Record record = Parser.parseRecord(couchbaseJson); + final UCRecord record = Parser.parseRecord(couchbaseJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -43,7 +39,7 @@ public void testForN1QLRestAPI() throws ParseException { final String couchbaseString = "{\"description\":\"A N1QL SELECT statement was executed\",\"id\":28672,\"isAdHoc\":true,\"metrics\":{\"elapsedTime\":\"68.6619ms\",\"executionTime\":\"68.5632ms\",\"resultCount\":5,\"resultSize\":82},\"name\":\"SELECT statement\",\"node\":\"127.0.0.1:8091\",\"real_userid\":{\"domain\":\"local\",\"user\":\"Administrator\"},\"remote\":{\"ip\":\"172.17.0.1\",\"port\":58438},\"requestId\":\"3e7e21ab-5530-4a99-8738-c8f9d3d00485\",\"statement\":\"SELECT distinct city FROM `travel-sample` LIMIT 5\",\"status\":\"success\",\"timestamp\":\"2021-05-25T15:05:59.334Z\",\"userAgent\":\"curl/7.55.1\",\"serverHostname\":\"test.couchbase.com\", \"serverIP\":\"0.0.0.0\"}"; final JsonObject couchbaseJson = JsonParser.parseString(couchbaseString).getAsJsonObject(); - final Record record = Parser.parseRecord(couchbaseJson); + final UCRecord record = Parser.parseRecord(couchbaseJson); Assert.assertEquals(Constants.TEXT, record.getAccessor().getDataType()); Assert.assertEquals(null, record.getException()); @@ -56,7 +52,7 @@ public void testForErrorHandling() throws ParseException { final String couchbaseString = "{\"clientContextId\":\"79f105ab-075b-41ff-b9d9-2f898ee2be31\",\"description\":\"An unrecognized statement was received by the N1QL query engine\",\"id\":28687,\"isAdHoc\":true,\"metrics\":{\"elapsedTime\":\"1.378ms\",\"errorCount\":1,\"executionTime\":\"1.1121ms\",\"resultCount\":0,\"resultSize\":0},\"name\":\"UNRECOGNIZED statement\",\"node\":\"127.0.0.1:8091\",\"real_userid\":{\"domain\":\"builtin\",\"user\":\"Administrator\"},\"remote\":{\"ip\":\"127.0.0.1\",\"port\":35563},\"requestId\":\"142d2fce-c4fd-48df-99f7-be91232a8e7b\",\"statement\":\"SELECT * FROM beer-sample` limit 5;\",\"status\":\"fatal\",\"timestamp\":\"2021-06-21T12:13:43.492Z\",\"userAgent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36 (Couchbase Query Workbench (6.6.2-9600-enterprise))\",\"serverHostname\":\"test.couchbase.com\", \"serverIP\":\"0.0.0.0\"}"; final JsonObject couchbaseJson = JsonParser.parseString(couchbaseString).getAsJsonObject(); - final Record record = Parser.parseRecord(couchbaseJson); + final UCRecord record = Parser.parseRecord(couchbaseJson); Assert.assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); Assert.assertEquals("An unrecognized statement was received by the N1QL query engine", record.getException().getDescription()); @@ -67,7 +63,7 @@ public void testForErrorHandling() throws ParseException { public void testForErrorHandling2() throws ParseException { final String couchbaseString = "{\"clientContextId\":\"50b52e66-5627-4fc5-a54a-89f02075b8a5\",\"description\":\"A N1QL INSERT statement was executed\",\"id\":28676,\"isAdHoc\":true,\"metrics\":{\"elapsedTime\":\"10.2109ms\",\"errorCount\":1,\"executionTime\":\"10.066ms\",\"resultCount\":0,\"resultSize\":0},\"name\":\"INSERT statement\",\"node\":\"127.0.0.1:8091\",\"real_userid\":{\"domain\":\"builtin\",\"user\":\"Administrator\"},\"remote\":{\"ip\":\"127.0.0.1\",\"port\":48977},\"requestId\":\"4daa776c-37cb-473a-9fc2-f6f65709d06d\",\"statement\":\"INSERT INTO `travel-sample` (KEY, VALUE) VALUES ( \\\"airline::432\\\", { \\\"callsign\\\": \\\"\\\", \\\"country\\\" : \\\"USA\\\", \\\"type\\\" : \\\"airline\\\"} ) RETURNING META().id as docid;\",\"status\":\"errors\",\"timestamp\":\"2021-06-21T12:21:00.427Z\",\"userAgent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36 (Couchbase Query Workbench (6.6.2-9600-enterprise))\",\"serverHostname\":\"test.couchbase.com\", \"serverIP\":\"0.0.0.0\"}"; final JsonObject couchbaseJson = JsonParser.parseString(couchbaseString).getAsJsonObject(); - final Record record = Parser.parseRecord(couchbaseJson); + final UCRecord record = Parser.parseRecord(couchbaseJson); Assert.assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); Assert.assertEquals("A N1QL INSERT statement was executed", record.getException().getDescription()); diff --git a/filter-plugin/logstash-filter-couchdb-guardium/build.gradle b/filter-plugin/logstash-filter-couchdb-guardium/build.gradle index 8adb88feb..a7047c0b9 100644 --- a/filter-plugin/logstash-filter-couchdb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-couchdb-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "CouchdbGuardiumFilter" pluginInfo.pluginName = "couchdb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-couchdb-guardium/gradlew b/filter-plugin/logstash-filter-couchdb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/CouchdbGuardiumFilter.java b/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/CouchdbGuardiumFilter.java index 7e7637520..99432c799 100644 --- a/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/CouchdbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/CouchdbGuardiumFilter.java @@ -16,9 +16,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.ibm.guardium.couchdb.CouchdbGuardiumFilter; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -62,7 +61,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (isParseableEvent(event)) { try { - Record rec = Parser.parseRecord(event); + UCRecord rec = Parser.parseRecord(event); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/Parser.java b/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/Parser.java index 6b7e50874..750a43eba 100644 --- a/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/Parser.java +++ b/filter-plugin/logstash-filter-couchdb-guardium/src/main/java/com/ibm/guardium/couchdb/Parser.java @@ -15,7 +15,7 @@ import com.ibm.guardium.couchdb.Parser; import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Event; @@ -30,13 +30,13 @@ public class Parser { /*** * Parses logs and returns a Guard Record object * - * @param data + * @param event * @return * @throws Exception * @throws ParseException */ - public static Record parseRecord(Event event) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(Event event) throws Exception { + UCRecord record = new UCRecord(); try { record.setAppUserName(ApplicationConstant.UNKNOWN_STRING); record.setAccessor(parseAccessor(event)); diff --git a/filter-plugin/logstash-filter-couchdb-guardium/src/test/java/com/ibm/guardium/couchdb/ParserTest.java b/filter-plugin/logstash-filter-couchdb-guardium/src/test/java/com/ibm/guardium/couchdb/ParserTest.java index 0af16cad2..4f2c15a4a 100644 --- a/filter-plugin/logstash-filter-couchdb-guardium/src/test/java/com/ibm/guardium/couchdb/ParserTest.java +++ b/filter-plugin/logstash-filter-couchdb-guardium/src/test/java/com/ibm/guardium/couchdb/ParserTest.java @@ -8,16 +8,11 @@ import static org.junit.jupiter.api.Assertions.*; -import java.text.ParseException; - import org.junit.jupiter.api.Test; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -37,7 +32,7 @@ public void testParseRecord() throws Exception { event.setField(ApplicationConstant.STATUS, "200"); event.setField(ApplicationConstant.DESCRIPTION, "ok"); event.setField(ApplicationConstant.TIME_INTERVAL, "30"); - final Record record = Parser.parseRecord(event); + final UCRecord record = Parser.parseRecord(event); assertNotNull(record); assertEquals("", record.getAppUserName()); assertEquals("fruits", record.getDbName()); @@ -52,7 +47,7 @@ public void testParseRecordForElseCondition() throws Exception { event.setField(ApplicationConstant.DB_NAME, "fruits"); event.setField(ApplicationConstant.STATUS, "404"); event.setField(ApplicationConstant.TIMESTAMP, "2022-02-21T07:03:10.759000Z"); - final Record record = Parser.parseRecord(event); + final UCRecord record = Parser.parseRecord(event); assertNotNull(record); assertEquals("fruits", record.getDbName()); } diff --git a/filter-plugin/logstash-filter-documentdb-aws-guardium/build.gradle b/filter-plugin/logstash-filter-documentdb-aws-guardium/build.gradle index 794a07a6b..695a40114 100644 --- a/filter-plugin/logstash-filter-documentdb-aws-guardium/build.gradle +++ b/filter-plugin/logstash-filter-documentdb-aws-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "DocumentdbGuardiumFilter" pluginInfo.pluginName = "documentdb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-documentdb-aws-guardium/gradlew b/filter-plugin/logstash-filter-documentdb-aws-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilter.java b/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilter.java index c07c5b431..e23e19977 100644 --- a/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilter.java @@ -4,9 +4,6 @@ */ package com.ibm.guardium.documentdb; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -26,7 +23,7 @@ import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; import com.ibm.guardium.universalconnector.commons.Util; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import co.elastic.logstash.api.Configuration; @@ -108,7 +105,7 @@ public Collection filter(Collection events, FilterMatchListener ma skippedEvents.add(e); continue; } - Record record = Parser.parseAuditRecord(inputJSON); + UCRecord record = Parser.parseAuditRecord(inputJSON); if(e.getField("serverHostnamePrefix") !=null && e.getField("serverHostnamePrefix") instanceof String) { record.getAccessor().setServerHostName(e.getField("serverHostnamePrefix").toString()+".aws.com"); String dbName=record.getDbName(); @@ -140,7 +137,7 @@ public Collection filter(Collection events, FilterMatchListener ma skippedEvents.add(e); continue; } - Record record = Parser.parseProfilerRecord(inputJSON); + UCRecord record = Parser.parseProfilerRecord(inputJSON); if(e.getField("serverHostnamePrefix") !=null && e.getField("serverHostnamePrefix") instanceof String) { record.getAccessor().setServerHostName(e.getField("serverHostnamePrefix").toString()+".aws.com"); String dbName=record.getDbName(); @@ -184,7 +181,7 @@ public Collection filter(Collection events, FilterMatchListener ma * @param e - Logstash Event * @param record - Record after parsing. */ - private void correctIPs(Event e, Record record) { + private void correctIPs(Event e, UCRecord record) { // Override "(NONE)" IP, if not filterd, as it's internal command by DocumentDB. // Note: IP needs to be in ipv4/ipv6 format SessionLocator sessionLocator = record.getSessionLocator(); diff --git a/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/Parser.java b/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/Parser.java index fe756fd30..4e922ed15 100644 --- a/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/Parser.java +++ b/filter-plugin/logstash-filter-documentdb-aws-guardium/src/main/java/com/ibm/guardium/documentdb/Parser.java @@ -12,21 +12,14 @@ import java.util.Map.Entry; import java.util.Set; +import com.ibm.guardium.universalconnector.commons.structures.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; public class Parser { private static Logger log = LogManager.getLogger(Parser.class); @@ -51,8 +44,8 @@ public class Parser { * @return * @throws ParseException */ - public static Record parseAuditRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseAuditRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); final JsonObject param = data.get("param").getAsJsonObject(); if (param.get("error") != null) { param.get("error").getAsString(); @@ -101,8 +94,8 @@ public static Record parseAuditRecord(final JsonObject data) throws ParseExcepti * @return * @throws ParseException */ - public static Record parseProfilerRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseProfilerRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); final JsonObject param = data.get("command").getAsJsonObject(); // Setting session ID diff --git a/filter-plugin/logstash-filter-documentdb-aws-guardium/src/test/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilterTest.java b/filter-plugin/logstash-filter-documentdb-aws-guardium/src/test/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilterTest.java index 0cbacd0d1..066694588 100644 --- a/filter-plugin/logstash-filter-documentdb-aws-guardium/src/test/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilterTest.java +++ b/filter-plugin/logstash-filter-documentdb-aws-guardium/src/test/java/com/ibm/guardium/documentdb/DocumentdbGuardiumFilterTest.java @@ -13,21 +13,13 @@ import org.logstash.plugins.ContextImpl; import com.google.gson.Gson; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; import co.elastic.logstash.api.FilterMatchListener; import co.elastic.logstash.api.PluginConfigSpec; -import static org.junit.jupiter.api.Assertions.*; - -//import static org.junit.Assert.*; - -import static org.junit.jupiter.api.Assertions.*; - -//import static org.junit.Assert.*; - public class DocumentdbGuardiumFilterTest { @@ -327,7 +319,7 @@ public void testAuditWithServiceAdminLog() { assertEquals(1, results.size()); assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); assertNotNull(record); assertEquals(1, matchListener.getMatchCount()); } @@ -345,7 +337,7 @@ public void testServiceName() { e.setField("event_id", "1234567"); filter.filter(Collections.singletonList(e), matchListener); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); assertNotNull(record.getAccessor().getServiceName()); assertEquals("LP-123455556:test", record.getAccessor().getServiceName()); } @@ -360,7 +352,7 @@ public void testDbProtocol() { e.setField("message", DbString); filter.filter(Collections.singletonList(e), matchListener); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); assertNotNull(record.getAccessor().getDbProtocol()); assertEquals(Parser.DATA_PROTOCOL_STRING, record.getAccessor().getDbProtocol()); } @@ -381,7 +373,7 @@ public void testSourceProgram() { e.setField("message", DbString); filter.filter(Collections.singletonList(e), matchListener); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); assertNotNull(record.getAccessor().getSourceProgram()); } diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/build.gradle b/filter-plugin/logstash-filter-dynamodb-guardium/build.gradle index 4a66909ef..b3e03a552 100644 --- a/filter-plugin/logstash-filter-dynamodb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-dynamodb-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "DynamodbGuardiumPluginFilter" pluginInfo.pluginName = "dynamodb_guardium_plugin_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" @@ -43,8 +43,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/gradlew b/filter-plugin/logstash-filter-dynamodb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/lib/logstash-filter-dynamodb_guardium_plugin_filter_jars.rb b/filter-plugin/logstash-filter-dynamodb-guardium/lib/logstash-filter-dynamodb_guardium_plugin_filter_jars.rb deleted file mode 100644 index 1e3efb3f3..000000000 --- a/filter-plugin/logstash-filter-dynamodb-guardium/lib/logstash-filter-dynamodb_guardium_plugin_filter_jars.rb +++ /dev/null @@ -1,5 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 - -require 'jar_dependencies' -require_jar('com.ibm.guardium.dynamodb', 'logstash-filter-dynamodb_guardium_plugin_filter', '1.0.1') diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/lib/logstash/filters/dynamodb_guardium_plugin_filter.rb b/filter-plugin/logstash-filter-dynamodb-guardium/lib/logstash/filters/dynamodb_guardium_plugin_filter.rb deleted file mode 100644 index d3cb6d65b..000000000 --- a/filter-plugin/logstash-filter-dynamodb-guardium/lib/logstash/filters/dynamodb_guardium_plugin_filter.rb +++ /dev/null @@ -1,12 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 -require "logstash/filters/base" -require "logstash/namespace" -require "logstash-filter-dynamodb_guardium_plugin_filter_jars" -require "java" - -class LogStash::Filters::DynamodbGuardiumPluginFilter < LogStash::Filters::Base - config_name "dynamodb_guardium_plugin_filter" - - def self.javaClass() Java::com.ibm.guardium.dynamodb.DynamodbGuardiumPluginFilter.java_class; end -end diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/logstash-filter-dynamodb_guardium_plugin_filter.zip b/filter-plugin/logstash-filter-dynamodb-guardium/logstash-filter-dynamodb_guardium_plugin_filter.zip index 75dedf3ff..5c7146b79 100644 Binary files a/filter-plugin/logstash-filter-dynamodb-guardium/logstash-filter-dynamodb_guardium_plugin_filter.zip and b/filter-plugin/logstash-filter-dynamodb-guardium/logstash-filter-dynamodb_guardium_plugin_filter.zip differ diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/DynamodbGuardiumPluginFilter.java b/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/DynamodbGuardiumPluginFilter.java index 6e899e2f8..8a4739a4f 100644 --- a/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/DynamodbGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/DynamodbGuardiumPluginFilter.java @@ -4,27 +4,21 @@ // package com.ibm.guardium.dynamodb; -import co.elastic.logstash.api.Configuration; -import co.elastic.logstash.api.Context; -import co.elastic.logstash.api.Event; -import co.elastic.logstash.api.Filter; -import co.elastic.logstash.api.FilterMatchListener; -import co.elastic.logstash.api.LogstashPlugin; -import co.elastic.logstash.api.PluginConfigSpec; +import co.elastic.logstash.api.*; import com.google.gson.*; import com.google.gson.stream.JsonReader; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.Util; -import com.ibm.guardium.universalconnector.commons.structures.*; - +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; import java.io.File; -import java.text.ParseException; -import java.util.*; import java.io.StringReader; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; //class name must match plugin name @LogstashPlugin(name = "dynamodb_guardium_plugin_filter") @@ -127,7 +121,7 @@ else if (e.getField("message") instanceof String && !e.getField("message").toStr } private String convertEventToRecord(JsonObject inputJSON) throws ParseException { - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/Parser.java b/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/Parser.java index e6e784046..1ad00b71f 100644 --- a/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/Parser.java +++ b/filter-plugin/logstash-filter-dynamodb-guardium/src/main/java/com/ibm/guardium/dynamodb/Parser.java @@ -4,40 +4,24 @@ // package com.ibm.guardium.dynamodb; -import java.text.ParseException; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; import com.google.gson.JsonParser; -import com.ibm.guardium.universalconnector.commons.Util; import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.text.ParseException; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + public class Parser { private static Logger log = LogManager.getLogger(Parser.class); private static JsonParser jsonParser = new JsonParser(); - public static Record parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); String query = Constants.UNKNOWN_STRING; String sessionID = Constants.UNKNOWN_STRING; diff --git a/filter-plugin/logstash-filter-dynamodb-guardium/src/test/java/com/ibm/guardium/dynamodb/ParserTest.java b/filter-plugin/logstash-filter-dynamodb-guardium/src/test/java/com/ibm/guardium/dynamodb/ParserTest.java index b8df3be65..6ca8bb6b1 100644 --- a/filter-plugin/logstash-filter-dynamodb-guardium/src/test/java/com/ibm/guardium/dynamodb/ParserTest.java +++ b/filter-plugin/logstash-filter-dynamodb-guardium/src/test/java/com/ibm/guardium/dynamodb/ParserTest.java @@ -14,8 +14,6 @@ import org.junit.Test; public class ParserTest { - - Parser parser = new Parser(); final String dynamoString = "{\"eventVersion\": \"1.08\", \"userIdentity\": {\"type\": \"Root\", \"principalId\": \"\", \"arn\": \"arn:aws:iam::testAccountId:root\", \"accountId\": \"testAccountId\", \"accessKeyId\": \"\", \"sessionContext\": { \"attributes\": { \"creationDate\": \"2020-12-28T07:15:10Z\", \"mfaAuthenticated\": \"false\" } } },\"eventTime\": \"2020-12-28T07:35:21Z\",\"eventSource\": \"dynamodb.amazonaws.com\", \"eventName\": \"CreateTable\", \"awsRegion\": \"ap-south-1\", \"sourceIPAddress\": \"103.62.17.201\", \"userAgent\": \"console.mazonaws.com\", \"requestParameters\": {\"attributeDefinitions\": [{ \"attributeName\": \"Employee Number\", \"attributeType\": \"N\" }], \"tableName\": \"Employee\", \"keySchema\": [ {\"attributeName\": \"Employee Number\", \"keyType\": \"HASH\" } ],\"billingMode\": \"PROVISIONED\", \"provisionedThroughput\": { \"readCapacityUnits\": 5, \"writeCapacityUnits\": 5 }, \"sSESpecification\": { \"enabled\": false } }, \"responseElements\": { \"tableDescription\": { \"attributeDefinitions\": [ { \"attributeName\": \"Employee Number\",\"attributeType\": \"N\"} ], \"tableName\": \"Employee\", \"keySchema\": [{ \"attributeName\": \"Employee Number\", \"keyType\": \"HASH\" } ], \"tableStatus\": \"CREATING\", \"creationDateTime\": \"Dec 28, 2020, 7:35:21 AM\", \"provisionedThroughput\": { \"numberOfDecreasesToday\": 0, \"readCapacityUnits\": 5, \"writeCapacityUnits\": 5},\"tableSizeBytes\": 0,\"itemCount\": 0,\"tableArn\": \"arn:aws:dynamodb:ap-south-1:testAccountId:table/Employee\",\"tableId\": \"0bbd1d31-624b-4a0a-b804-4a7bc7351e3e\"}},\"requestID\": \"4NR3PQIDKFSKJGELV8EBNN1BNJVV4KQNSO5AEMVJF66Q9ASUAAJG\",\"eventID\": \"79151c71-058e-4031-8f2d-adbac87198a2\",\"readOnly\": false,\"resources\": [{\"accountId\": \"083406524166\",\"type\": \"AWS::DynamoDB::Table\",\"ARN\": \"arn:aws:dynamodb:ap-south-1:testAccountId:table/Employee\"}],\"eventType\": \"AwsApiCall\",\"apiVersion\": \"2012-08-10\",\"managementEvent\": true,\"recipientAccountId\": \"testAccountId\",\"eventCategory\": \"Management\"}"; final JsonObject dynamoJson = JsonParser.parseString(dynamoString).getAsJsonObject(); @@ -25,7 +23,7 @@ public void testParseRecord_CreateTable() throws ParseException { final String dynamoString = "{\"eventVersion\": \"1.08\", \"userIdentity\": {\"type\": \"Root\", \"principalId\": \"\", \"arn\": \"arn:aws:iam::testAccountId:root\", \"accountId\": \"testAccountId\", \"accessKeyId\": \"\", \"sessionContext\": { \"attributes\": { \"creationDate\": \"2020-12-28T07:15:10Z\", \"mfaAuthenticated\": \"false\" } } },\"eventTime\": \"2020-12-28T07:35:21Z\",\"eventSource\": \"dynamodb.amazonaws.com\", \"eventName\": \"CreateTable\", \"awsRegion\": \"ap-south-1\", \"sourceIPAddress\": \"103.62.17.201\", \"userAgent\": \"console.mazonaws.com\", \"requestParameters\": {\"attributeDefinitions\": [{ \"attributeName\": \"Employee Number\", \"attributeType\": \"N\" }], \"tableName\": \"Employee\", \"keySchema\": [ {\"attributeName\": \"Employee Number\", \"keyType\": \"HASH\" } ],\"billingMode\": \"PROVISIONED\", \"provisionedThroughput\": { \"readCapacityUnits\": 5, \"writeCapacityUnits\": 5 }, \"sSESpecification\": { \"enabled\": false } }, \"responseElements\": { \"tableDescription\": { \"attributeDefinitions\": [ { \"attributeName\": \"Employee Number\",\"attributeType\": \"N\"} ], \"tableName\": \"Employee\", \"keySchema\": [{ \"attributeName\": \"Employee Number\", \"keyType\": \"HASH\" } ], \"tableStatus\": \"CREATING\", \"creationDateTime\": \"Dec 28, 2020, 7:35:21 AM\", \"provisionedThroughput\": { \"numberOfDecreasesToday\": 0, \"readCapacityUnits\": 5, \"writeCapacityUnits\": 5},\"tableSizeBytes\": 0,\"itemCount\": 0,\"tableArn\": \"arn:aws:dynamodb:ap-south-1:testAccountId:table/Employee\",\"tableId\": \"0bbd1d31-624b-4a0a-b804-4a7bc7351e3e\"}},\"requestID\": \"4NR3PQIDKFSKJGELV8EBNN1BNJVV4KQNSO5AEMVJF66Q9ASUAAJG\",\"eventID\": \"79151c71-058e-4031-8f2d-adbac87198a2\",\"readOnly\": false,\"resources\": [{\"accountId\": \"testAccountId\",\"type\": \"AWS::DynamoDB::Table\",\"ARN\": \"arn:aws:dynamodb:ap-south-1:testAccountId:table/Employee\"}],\"eventType\": \"AwsApiCall\",\"apiVersion\": \"2012-08-10\",\"managementEvent\": true,\"recipientAccountId\": \"testAccountId\",\"eventCategory\": \"Management\"}"; final JsonObject dynamoJson = JsonParser.parseString(dynamoString).getAsJsonObject(); - final Record record = Parser.parseRecord(dynamoJson); + final UCRecord record = Parser.parseRecord(dynamoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -42,7 +40,7 @@ public void testParseRecord_Error() throws ParseException { final String dynamoString = "{ \"eventVersion\": \"1.08\", \"userIdentity\": { \"type\": \"IAMUser\", \"principalId\": \"\", \"arn\": \"arn:aws:iam::testAccountId:user/rasika.shete\", \"accountId\": \"testAccountId\", \"accessKeyId\": \"\", \"userName\": \"rasika.shete\" }, \"eventTime\": \"2021-01-11T18:03:56Z\", \"eventSource\": \"dynamodb.amazonaws.com\", \"eventName\": \"UpdateTable\", \"awsRegion\": \"ap-south-1\", \"sourceIPAddress\": \"103.62.16.216\", \"userAgent\": \"aws-cli/2.1.15 Python/3.7.9 Windows/10 exe/AMD64 prompt/off command/dynamodb.update-table\", \"errorCode\": \"ResourceNotFoundException\", \"errorMessage\": \"Requested resource not found: Table: Music12 not found\", \"requestParameters\": { \"tableName\": \"Music12\", \"provisionedThroughput\": { \"readCapacityUnits\": 20, \"writeCapacityUnits\": 10 } }, \"responseElements\": null, \"requestID\": \"LBQJMQUKQNU73MVN8GHAGNBDDNVV4KQNSO5AEMVJF66Q9ASUAAJG\", \"eventID\": \"e1325551-1a43-453d-a188-5f91ba136c6a\", \"readOnly\": false, \"resources\": [ { \"accountId\": \"testAccountId\", \"type\": \"AWS::DynamoDB::Table\", \"ARN\": \"arn:aws:dynamodb:ap-south-1:testAccountId:table/Music12\" } ], \"eventType\": \"AwsApiCall\", \"apiVersion\": \"2012-08-10\", \"managementEvent\": true, \"recipientAccountId\": \"testAccountId\", \"eventCategory\": \"Management\"}"; final JsonObject dynamoJson = JsonParser.parseString(dynamoString).getAsJsonObject(); - final Record record = Parser.parseRecord(dynamoJson); + final UCRecord record = Parser.parseRecord(dynamoJson); Assert.assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); Assert.assertEquals("Requested resource not found: Table: Music12 not found", record.getException().getDescription()); @@ -53,8 +51,11 @@ public void testParseRecord_Error() throws ParseException { public void testTimeParing() throws ParseException { String dateStr = "2020-12-28T07:35:21Z"; Time time = Parser.getTime(dateStr); - Assert.assertTrue("Failed to parse date, time is "+time.getTimstamp(), 1609140921000L==time.getTimstamp()); - + Assert.assertEquals( + "Failed to parse date, time is "+time.getTimstamp(), + 1609140921000L, + time.getTimstamp()) + ; } @Test @@ -113,7 +114,7 @@ public void testSessionLocator_invalidIP() { //Accessor values verified. @Test public void testParseAccessor() throws ParseException { - Record record = Parser.parseRecord(dynamoJson); + UCRecord record = Parser.parseRecord(dynamoJson); Accessor actual = record.getAccessor(); Assert.assertEquals(Constants.DATA_PROTOCOL_STRING, actual.getDbProtocol()); @@ -146,7 +147,7 @@ public void testParseRecord_LoginFailed() throws ParseException { final JsonObject dynamoJson = JsonParser.parseString(dynamoString).getAsJsonObject(); String errorMessage = dynamoJson.get(Constants.ERROR_MESSAGE).getAsString(); - final Record record = Parser.parseRecord(dynamoJson); + final UCRecord record = Parser.parseRecord(dynamoJson); Assert.assertEquals(Constants.LOGIN_ERROR, record.getException().getExceptionTypeId()); Assert.assertEquals(errorMessage, record.getException().getDescription()); @@ -191,7 +192,7 @@ public void testParseRecord_ListExports() throws ParseException { final JsonObject dynamoJson = JsonParser.parseString(dynamoString).getAsJsonObject(); dynamoJson.addProperty(Constants.ACCOUNT_ID, "testAccountId"); - final Record record = Parser.parseRecord(dynamoJson); + final UCRecord record = Parser.parseRecord(dynamoJson); //final Sentence sentence = construct.sentences.get(0); Assert.assertEquals(record.getDbName(),"testAccountId:Table_2504_1010/test"); diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/ElasticsearchOverFilebeatPackage/guardium_logstash-offline-plugins-elasticsearch.zip b/filter-plugin/logstash-filter-elasticsearch-guardium/ElasticsearchOverFilebeatPackage/guardium_logstash-offline-plugins-elasticsearch.zip index f3ddd0c9d..8ce1e072f 100644 Binary files a/filter-plugin/logstash-filter-elasticsearch-guardium/ElasticsearchOverFilebeatPackage/guardium_logstash-offline-plugins-elasticsearch.zip and b/filter-plugin/logstash-filter-elasticsearch-guardium/ElasticsearchOverFilebeatPackage/guardium_logstash-offline-plugins-elasticsearch.zip differ diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/build.gradle b/filter-plugin/logstash-filter-elasticsearch-guardium/build.gradle index e0a272e68..4df7b0649 100644 --- a/filter-plugin/logstash-filter-elasticsearch-guardium/build.gradle +++ b/filter-plugin/logstash-filter-elasticsearch-guardium/build.gradle @@ -22,8 +22,8 @@ pluginInfo.pluginName = "elasticsearch_guardium_filter" // must match the @ // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { @@ -35,7 +35,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' } } @@ -51,16 +51,16 @@ shadowJar { } dependencies { - compile group: 'commons-validator', name: 'commons-validator', version: '1.7' - compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1' - compile 'org.apache.commons:commons-lang3:3.7' - compile 'com.google.code.gson:gson:2.8.9' - compile fileTree(dir: LOGSTASH_CORE_PATH, include: "build/libs/logstash-core-*.*.*.jar") - compile fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "guardium-universalconnector-commons-master-*.*.*.jar") - testCompile 'junit:junit:4.12' - testCompile 'org.jruby:jruby-complete:9.2.7.0' - - testCompile fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "guardium-universalconnector-commons-master-*.*.*.jar") + implementation group: 'commons-validator', name: 'commons-validator', version: '1.7' + implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1' + implementation 'org.apache.commons:commons-lang3:3.7' + implementation 'com.google.code.gson:gson:2.8.9' + implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "build/libs/logstash-core-*.*.*.jar") + implementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "common-*.*.*.jar") + testImplementation 'junit:junit:4.13.1' + testImplementation 'org.jruby:jruby-complete:9.2.7.0' + + testImplementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "common-*.*.*.jar") } clean { diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/gradle/wrapper/gradle-wrapper.properties b/filter-plugin/logstash-filter-elasticsearch-guardium/gradle/wrapper/gradle-wrapper.properties index bb8b2fc26..ffed3a254 100644 --- a/filter-plugin/logstash-filter-elasticsearch-guardium/gradle/wrapper/gradle-wrapper.properties +++ b/filter-plugin/logstash-filter-elasticsearch-guardium/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/gradlew b/filter-plugin/logstash-filter-elasticsearch-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/ElasticsearchGuardiumFilter.java b/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/ElasticsearchGuardiumFilter.java index ef3acd5e3..d6a9acc44 100644 --- a/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/ElasticsearchGuardiumFilter.java +++ b/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/ElasticsearchGuardiumFilter.java @@ -13,8 +13,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.google.gson.JsonObject; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -58,7 +57,7 @@ public Collection filter(Collection events, FilterMatchListener ma String messageValue = event.getField("message").toString(); try { JsonObject inputJSON = new Gson().fromJson(messageValue, JsonObject.class); - Record record = Parser.parseRecord(inputJSON,(event.getField("totalOffset")!=null && !event.getField("totalOffset").toString().isEmpty())?event.getField("totalOffset"):0); + UCRecord record = Parser.parseRecord(inputJSON,(event.getField("totalOffset")!=null && !event.getField("totalOffset").toString().isEmpty())?event.getField("totalOffset"):0); final Gson gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create(); event.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, gson.toJson(record)); matchListener.filterMatched(event); diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/Parser.java b/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/Parser.java index 737be703d..b9b3848f2 100644 --- a/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/Parser.java +++ b/filter-plugin/logstash-filter-elasticsearch-guardium/src/main/java/com/ibm/guardium/elasticsearch/Parser.java @@ -10,17 +10,14 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; + +import com.ibm.guardium.universalconnector.commons.structures.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.gson.JsonObject; import com.ibm.guardium.elasticsearch.constant.ApplicationConstant; import com.ibm.guardium.universalconnector.commons.Util; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; public class Parser { @@ -36,8 +33,8 @@ public class Parser { * @return * @throws Exception */ - public static Record parseRecord(final JsonObject data,final Object totalOffset) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data, final Object totalOffset) throws Exception { + UCRecord record = new UCRecord(); try { record.setTime(parseTime(data,totalOffset)); record.setAppUserName(ApplicationConstant.UNKNOWN_STRING); @@ -175,7 +172,7 @@ public static Accessor parseAccessor(JsonObject data) { * @return * @throws Exception */ - public static Data parseData(final JsonObject jsonData, Record record) throws Exception { + public static Data parseData(final JsonObject jsonData, UCRecord record) throws Exception { Data data = new Data(); StringBuilder sb= new StringBuilder(); diff --git a/filter-plugin/logstash-filter-elasticsearch-guardium/src/test/java/com/ibm/guardium/elasticsearch/ParserTest.java b/filter-plugin/logstash-filter-elasticsearch-guardium/src/test/java/com/ibm/guardium/elasticsearch/ParserTest.java index 82917c415..e4e239701 100644 --- a/filter-plugin/logstash-filter-elasticsearch-guardium/src/test/java/com/ibm/guardium/elasticsearch/ParserTest.java +++ b/filter-plugin/logstash-filter-elasticsearch-guardium/src/test/java/com/ibm/guardium/elasticsearch/ParserTest.java @@ -8,10 +8,10 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Test; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.ibm.guardium.universalconnector.commons.structures.Record; public class ParserTest { @@ -19,7 +19,7 @@ public class ParserTest { public void parseRecordTest() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertEquals("-1109026561", record.getSessionId()); assertEquals("", record.getAppUserName()); @@ -34,7 +34,7 @@ public void parseRecordTest() throws Exception { public void parseRecordTestException() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_failed\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertEquals("-1109026561", record.getSessionId()); assertEquals("", record.getAppUserName()); @@ -50,7 +50,7 @@ public void parseRecordTestException() throws Exception { public void parseTimeTest() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-12-22T15:54:24,534+0530\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getTime()); assertEquals(Long.parseLong("1703240664534"), record.getTime().getTimstamp()); @@ -63,7 +63,7 @@ public void parseTimeTest() throws Exception { public void parseSessionLocatorTest() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,0); + UCRecord record = Parser.parseRecord(object,0); assertNotNull(record); assertNotNull(record.getSessionLocator()); assertEquals("117.98.4.93", record.getSessionLocator().getClientIp()); @@ -79,7 +79,7 @@ public void parseSessionLocatorTest() throws Exception { public void parseAccessorTest() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,0); + UCRecord record = Parser.parseRecord(object,0); assertNotNull(record); assertNotNull(record.getAccessor()); assertEquals("elastic", record.getAccessor().getDbUser()); @@ -105,7 +105,7 @@ public void parseAccessorTest() throws Exception { public void parseDataTest() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getData()); assertNull(record.getData().getConstruct()); @@ -117,7 +117,7 @@ public void parseDataTest() throws Exception { public void parseExceptionTest() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_failed\", \"user.name\":\"elastic\",\"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getException()); assertEquals("LOGIN_FAILED", record.getException().getExceptionTypeId()); @@ -129,7 +129,7 @@ public void parseExceptionTest() throws Exception { public void testParseSessionId() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertEquals("-1109026561", record.getSessionId()); @@ -139,7 +139,7 @@ public void testParseSessionId() throws Exception { public void testParseNoIp() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\",\"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"[::1]:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -150,7 +150,7 @@ public void testParseNoIp() throws Exception { public void testParseNoPort() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\",\"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getSessionLocator()); assertEquals(-1, record.getSessionLocator().getClientPort()); @@ -161,7 +161,7 @@ public void testParseNoPort() throws Exception { public void testParseNoUser() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\",\"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\",\"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getAccessor()); assertEquals("NA", record.getAccessor().getDbUser()); @@ -171,7 +171,7 @@ public void testParseNoUser() throws Exception { public void testParseNoServerHostName() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\",\"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\",\"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getAccessor()); assertEquals("", record.getAccessor().getServerHostName()); @@ -207,7 +207,7 @@ public void testParseNoRequestBody() throws Exception { public void testParseClientIpPort() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"[::1]:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -218,7 +218,7 @@ public void testParseClientIpPort() throws Exception { public void testParseServerIpPort() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"127.0.0.1\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"117.98.4.93:1811\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getSessionLocator()); assertEquals("127.0.0.1", record.getSessionLocator().getServerIp()); @@ -228,7 +228,7 @@ public void testParseServerIpPort() throws Exception { public void testParseServerClientIpv6() throws Exception { final String message = "{\"type\":\"audit\", \"timestamp\":\"2023-09-26T11:01:19,220+0000\", \"cluster.uuid\":\"mEtWYmxQSdGY27FoeGubIQ\", \"node.name\":\"node-1\", \"node.id\":\"RkqF7ZGKRuSlu_1EFdGXqQ\", \"host.name\":\"127.0.0.1\", \"host.ip\":\"1233:0dc8:33a3:0000:0000:9a2e:0440:8834\", \"event.type\":\"rest\", \"event.action\":\"authentication_success\", \"authentication.type\":\"REALM\", \"user.name\":\"elastic\", \"user.realm\":\"reserved\", \"origin.type\":\"rest\", \"origin.address\":\"[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:8080\", \"realm\":\"reserved\", \"url.path\":\"/_sql\", \"url.query\":\"format=txt&pretty\", \"request.method\":\"POST\", \"request.body\":\"\\n{\\n \\\"query\\\": \\\"SELECT * FROM hcltesting1\\\"\\n}\\n\", \"request.id\":\"Ol0gXgOtTO6cyIjF1Vx3aA\"}"; final JsonObject object = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(object,"+330"); + UCRecord record = Parser.parseRecord(object,"+330"); assertNotNull(record); assertNotNull(record.getSessionLocator()); assertEquals("1233:0dc8:33a3:0000:0000:9a2e:0440:8834", record.getSessionLocator().getServerIpv6()); diff --git a/filter-plugin/logstash-filter-generic-guardium/build.gradle b/filter-plugin/logstash-filter-generic-guardium/build.gradle index e63a2ae9b..c314ce13f 100644 --- a/filter-plugin/logstash-filter-generic-guardium/build.gradle +++ b/filter-plugin/logstash-filter-generic-guardium/build.gradle @@ -20,8 +20,8 @@ pluginInfo.pluginClass = "GenericGuardiumFilter" pluginInfo.pluginName = "generic_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { @@ -33,7 +33,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-generic-guardium/gradlew b/filter-plugin/logstash-filter-generic-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-generic-guardium/lib/logstash-filter-generic_guardium_filter_jars.rb b/filter-plugin/logstash-filter-generic-guardium/lib/logstash-filter-generic_guardium_filter_jars.rb deleted file mode 100644 index 70c06f082..000000000 --- a/filter-plugin/logstash-filter-generic-guardium/lib/logstash-filter-generic_guardium_filter_jars.rb +++ /dev/null @@ -1,5 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 - -require 'jar_dependencies' -require_jar('com.ibm.guardium.generic', 'logstash-filter-generic_guardium_filter', '1.0.0') diff --git a/filter-plugin/logstash-filter-generic-guardium/lib/logstash/filters/generic_guardium_filter.rb b/filter-plugin/logstash-filter-generic-guardium/lib/logstash/filters/generic_guardium_filter.rb deleted file mode 100644 index b6e753d39..000000000 --- a/filter-plugin/logstash-filter-generic-guardium/lib/logstash/filters/generic_guardium_filter.rb +++ /dev/null @@ -1,12 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 -require "logstash/filters/base" -require "logstash/namespace" -require "logstash-filter-generic_guardium_filter_jars" -require "java" - -class LogStash::Filters::GenericGuardiumFilter < LogStash::Filters::Base - config_name "generic_guardium_filter" - - def self.javaClass() Java::com.ibm.guardium.generic.GenericGuardiumFilter.java_class; end -end diff --git a/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/GenericGuardiumFilter.java b/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/GenericGuardiumFilter.java index b0e65266b..04f1be6d7 100644 --- a/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/GenericGuardiumFilter.java +++ b/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/GenericGuardiumFilter.java @@ -4,25 +4,20 @@ // package com.ibm.guardium.generic; -import co.elastic.logstash.api.Configuration; -import co.elastic.logstash.api.Context; -import co.elastic.logstash.api.Event; -import co.elastic.logstash.api.Filter; -import co.elastic.logstash.api.FilterMatchListener; -import co.elastic.logstash.api.LogstashPlugin; -import co.elastic.logstash.api.PluginConfigSpec; -import com.google.gson.*; +import co.elastic.logstash.api.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.Util; -import com.ibm.guardium.universalconnector.commons.structures.*; - -import org.apache.commons.validator.routines.InetAddressValidator; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; // class name must match plugin name @LogstashPlugin(name = "generic_guardium_filter") @@ -59,8 +54,8 @@ public Collection filter(Collection events, FilterMatchListener ma try { JsonObject inputData = inputData(e); //log.error("Actual message "+inputData.getAsString()); - - Record record = Parser.parseRecord(inputData); + + UCRecord record = Parser.parseRecord(inputData); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/Parser.java b/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/Parser.java index 1d2546f4b..8e8283e4a 100644 --- a/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/Parser.java +++ b/filter-plugin/logstash-filter-generic-guardium/src/main/java/com/ibm/guardium/generic/Parser.java @@ -5,25 +5,14 @@ package com.ibm.guardium.generic; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Date; - +import com.google.gson.JsonObject; +import com.ibm.guardium.universalconnector.commons.structures.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.google.gson.JsonObject; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; public class Parser { @@ -38,9 +27,9 @@ public class Parser { * dateTimeFormatterBuilder.toFormatter(); */ - public static Record parseRecord(final JsonObject data) throws ParseException { + public static UCRecord parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + UCRecord record = new UCRecord(); if (data != null) { String sessionID=setSessionID(data); @@ -310,7 +299,7 @@ public static void setUsername(final Accessor accessor,final JsonObject data) { } - public static void setExceptionOrDataPart(final Record record,final JsonObject data){ + public static void setExceptionOrDataPart(final UCRecord record,final JsonObject data){ if(record.getAccessor().getDataType().equals(Constants.TEXT)) { Data retData = new Data(); diff --git a/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/GenericGuardiumFilterTest.java b/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/GenericGuardiumFilterTest.java index c50a0e294..3578fdfaa 100644 --- a/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/GenericGuardiumFilterTest.java +++ b/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/GenericGuardiumFilterTest.java @@ -5,24 +5,19 @@ package com.ibm.guardium.generic; //import co.elastic.logstash.api.Configuration; + import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; import co.elastic.logstash.api.FilterMatchListener; - -import com.ibm.guardium.generic.Constants; -import com.ibm.guardium.generic.GenericGuardiumFilter; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; import org.junit.Assert; import org.junit.Test; -//import org.logstash.plugins.ConfigurationImpl; import org.logstash.plugins.ContextImpl; -import java.util.*; +import java.util.Collection; +import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; -import com.google.gson.Gson; - public class GenericGuardiumFilterTest { final static String postgresString = "2020-10-22 11:53:26 UTC:183.87.237.49(63661):postgres@testDB:[17796]:LOG: 00000: AUDIT: SESSION,27,1,WRITE,DELETE,,,DELETE FROM employee WHERE emp_id = 101,"; diff --git a/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/ParserTest.java b/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/ParserTest.java index af798995a..2b874d5f2 100644 --- a/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/ParserTest.java +++ b/filter-plugin/logstash-filter-generic-guardium/src/test/java/com/ibm/guardium/generic/ParserTest.java @@ -4,18 +4,16 @@ // package com.ibm.guardium.generic; -import java.text.ParseException; - -import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.ibm.guardium.generic.Constants; -import com.ibm.guardium.generic.Parser; -import com.ibm.guardium.universalconnector.commons.structures.*; - +import com.ibm.guardium.universalconnector.commons.structures.Accessor; +import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; +import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; +import java.text.ParseException; + public class ParserTest { Parser parser = new Parser(); @@ -29,7 +27,7 @@ public class ParserTest { data.addProperty(Constants.DBNAME, "testDB"); data.addProperty(Constants.SESSIONID, "17796"); - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); Assert.assertEquals("17796", record.getSessionId()); Assert.assertEquals("testDB", record.getDbName()); @@ -85,7 +83,7 @@ public void testParseAccessor() throws ParseException { data.addProperty(Constants.DBPROTOCOL, "Postgre AWS Native Audit"); data.addProperty(Constants.SERVERTYPE, "Postgre"); - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); Accessor actual = record.getAccessor(); Assert.assertEquals("Postgre AWS Native Audit", actual.getDbProtocol()); diff --git a/filter-plugin/logstash-filter-hdfs-guardium/.gitignore b/filter-plugin/logstash-filter-hdfs-guardium/.gitignore new file mode 100644 index 000000000..201246a48 --- /dev/null +++ b/filter-plugin/logstash-filter-hdfs-guardium/.gitignore @@ -0,0 +1,9 @@ +.classpath +.project +.idea +.gradle +.settings +gradle.properties +bin +build +lib \ No newline at end of file diff --git a/filter-plugin/logstash-filter-hdfs-guardium/HdfsOverFilebeatPackage/Hdfs/logstash-filter-hdfs_guardium_filter.zip b/filter-plugin/logstash-filter-hdfs-guardium/HdfsOverFilebeatPackage/Hdfs/logstash-filter-hdfs_guardium_filter.zip index a5c93b1e9..24a571585 100644 Binary files a/filter-plugin/logstash-filter-hdfs-guardium/HdfsOverFilebeatPackage/Hdfs/logstash-filter-hdfs_guardium_filter.zip and b/filter-plugin/logstash-filter-hdfs-guardium/HdfsOverFilebeatPackage/Hdfs/logstash-filter-hdfs_guardium_filter.zip differ diff --git a/filter-plugin/logstash-filter-hdfs-guardium/build.gradle b/filter-plugin/logstash-filter-hdfs-guardium/build.gradle index 1b18b3c36..b61d31024 100644 --- a/filter-plugin/logstash-filter-hdfs-guardium/build.gradle +++ b/filter-plugin/logstash-filter-hdfs-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "HdfsGuardiumFilter" pluginInfo.pluginName = "hdfs_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-hdfs-guardium/gradle.properties b/filter-plugin/logstash-filter-hdfs-guardium/gradle.properties deleted file mode 100644 index c10169ff0..000000000 --- a/filter-plugin/logstash-filter-hdfs-guardium/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -LOGSTASH_CORE_PATH=/home/marockar/oua_uc/logstash_git/logstash-core -COMMONS_PATH=/home/marockar/git/universal-connectors/common/build/libs diff --git a/filter-plugin/logstash-filter-hdfs-guardium/src/main/java/com/ibm/guardium/hdfs/HdfsGuardiumFilter.java b/filter-plugin/logstash-filter-hdfs-guardium/src/main/java/com/ibm/guardium/hdfs/HdfsGuardiumFilter.java index ba749718b..f729b3275 100644 --- a/filter-plugin/logstash-filter-hdfs-guardium/src/main/java/com/ibm/guardium/hdfs/HdfsGuardiumFilter.java +++ b/filter-plugin/logstash-filter-hdfs-guardium/src/main/java/com/ibm/guardium/hdfs/HdfsGuardiumFilter.java @@ -6,32 +6,24 @@ */ package com.ibm.guardium.hdfs; -import co.elastic.logstash.api.Configuration; -import co.elastic.logstash.api.Context; -import co.elastic.logstash.api.Event; -import co.elastic.logstash.api.Filter; -import co.elastic.logstash.api.FilterMatchListener; -import co.elastic.logstash.api.LogstashPlugin; -import co.elastic.logstash.api.PluginConfigSpec; -import com.google.gson.*; +import co.elastic.logstash.api.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; import com.ibm.guardium.universalconnector.commons.Util; import com.ibm.guardium.universalconnector.commons.structures.*; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.LoggerContext; -import java.io.File; -import java.util.*; +import java.nio.ByteBuffer; +import java.security.MessageDigest; import java.text.ParseException; import java.time.LocalDateTime; -import java.time.ZonedDateTime; import java.time.ZoneId; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; -import java.security.MessageDigest; -import java.nio.ByteBuffer; +import java.util.*; // class name must match plugin name @LogstashPlugin(name = "hdfs_guardium_filter") @@ -98,7 +90,7 @@ public Collection filter(Collection events, FilterMatchListener ma // String msg_string = e.getField("message").toString(); if (e.getField("message").toString().contains(HdfsGuardiumFilter.HDFS_AUDIT_MARK_STRING)) { try { - Record record = HdfsGuardiumFilter.parseRecord(e); + UCRecord record = HdfsGuardiumFilter.parseRecord(e); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); @@ -153,8 +145,8 @@ public String getId() { return this.id; } - public static Record parseRecord(final Event event) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final Event event) throws ParseException { + UCRecord record = new UCRecord(); record.setSessionId(HdfsGuardiumFilter.UNKNOWN_STRING); record.setDbName(HdfsGuardiumFilter.UNKNOWN_STRING); diff --git a/filter-plugin/logstash-filter-hdfs-guardium/src/test/java/com/ibm/guardium/hdfs/HdfsGuardiumFilterTest.java b/filter-plugin/logstash-filter-hdfs-guardium/src/test/java/com/ibm/guardium/hdfs/HdfsGuardiumFilterTest.java index e2b25a877..b0d309b77 100644 --- a/filter-plugin/logstash-filter-hdfs-guardium/src/test/java/com/ibm/guardium/hdfs/HdfsGuardiumFilterTest.java +++ b/filter-plugin/logstash-filter-hdfs-guardium/src/test/java/com/ibm/guardium/hdfs/HdfsGuardiumFilterTest.java @@ -6,24 +6,18 @@ */ package com.ibm.guardium.hdfs; -//import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; import co.elastic.logstash.api.FilterMatchListener; -import com.ibm.guardium.universalconnector.commons.structures.Record; import com.ibm.guardium.universalconnector.commons.GuardConstants; import org.junit.Assert; import org.junit.Test; -//import org.logstash.plugins.ConfigurationImpl; import org.logstash.plugins.ContextImpl; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; -import com.google.gson.Gson; - public class HdfsGuardiumFilterTest { @Test public void testParseOpen() { diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/.gitignore b/filter-plugin/logstash-filter-intersystems-iris-guardium/.gitignore new file mode 100644 index 000000000..8ab2121b2 --- /dev/null +++ b/filter-plugin/logstash-filter-intersystems-iris-guardium/.gitignore @@ -0,0 +1,9 @@ +.settings +.gradle +bin +build +gradle.properties +lib +.idea +.project +.classpath \ No newline at end of file diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/IntersystemsIrisoverJDBC/guardium_logstash-offline-plugin-intersystemsiris.zip b/filter-plugin/logstash-filter-intersystems-iris-guardium/IntersystemsIrisoverJDBC/guardium_logstash-offline-plugin-intersystemsiris.zip index 74ba1a880..6fff14f59 100644 Binary files a/filter-plugin/logstash-filter-intersystems-iris-guardium/IntersystemsIrisoverJDBC/guardium_logstash-offline-plugin-intersystemsiris.zip and b/filter-plugin/logstash-filter-intersystems-iris-guardium/IntersystemsIrisoverJDBC/guardium_logstash-offline-plugin-intersystemsiris.zip differ diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/build.gradle b/filter-plugin/logstash-filter-intersystems-iris-guardium/build.gradle index e2ab442c5..77d79139d 100644 --- a/filter-plugin/logstash-filter-intersystems-iris-guardium/build.gradle +++ b/filter-plugin/logstash-filter-intersystems-iris-guardium/build.gradle @@ -20,8 +20,8 @@ pluginInfo.pluginClass = "IntersystemsIRISGuardiumFilter" pluginInfo.pluginName = "intersystems_iris_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 buildscript { repositories { @@ -33,7 +33,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -49,7 +49,7 @@ apply plugin: 'com.github.johnrengelman.shadow' shadowJar { classifier = null - transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer) + // transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer) } dependencies { @@ -132,4 +132,4 @@ jacocoTestReport { }) } } -test.finalizedBy jacocoTestReport \ No newline at end of file +test.finalizedBy jacocoTestReport diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/gradlew b/filter-plugin/logstash-filter-intersystems-iris-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/IntersystemsIRISGuardiumFilter.java b/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/IntersystemsIRISGuardiumFilter.java index 5c4c82974..0bec53277 100644 --- a/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/IntersystemsIRISGuardiumFilter.java +++ b/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/IntersystemsIRISGuardiumFilter.java @@ -13,7 +13,7 @@ import co.elastic.logstash.api.PluginConfigSpec; import com.google.gson.*; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.*; @@ -51,7 +51,7 @@ public Collection filter(Collection events, FilterMatchListener ma String messageString = event.getField("message").toString(); try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final Gson gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create(); event.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, gson.toJson(record)); matchListener.filterMatched(event); diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/Parser.java b/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/Parser.java index 4c07d5788..13693e6e9 100644 --- a/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/Parser.java +++ b/filter-plugin/logstash-filter-intersystems-iris-guardium/src/main/java/com/ibm/guardium/intersystemsiris/Parser.java @@ -15,20 +15,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.ibm.guardium.universalconnector.commons.structures.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.Util; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; public class Parser { private static Logger log = LogManager.getLogger(Parser.class); @@ -37,13 +29,13 @@ public class Parser { /** * Method to parse data from JsonObject and set to record object * - * @param records + * @param data * @return * @throws Exception */ - public static Record parseRecord(final JsonObject data) throws Exception { + public static UCRecord parseRecord(final JsonObject data) throws Exception { - Record record = new Record(); + UCRecord record = new UCRecord(); try { record.setTime(parseTime(data)); record.setAppUserName(Constants.UNKNOWN_STRING); diff --git a/filter-plugin/logstash-filter-intersystems-iris-guardium/src/test/java/com/ibm/guardium/intersystemsiris/ParserTest.java b/filter-plugin/logstash-filter-intersystems-iris-guardium/src/test/java/com/ibm/guardium/intersystemsiris/ParserTest.java index 67f8e557e..aa6f06f56 100644 --- a/filter-plugin/logstash-filter-intersystems-iris-guardium/src/test/java/com/ibm/guardium/intersystemsiris/ParserTest.java +++ b/filter-plugin/logstash-filter-intersystems-iris-guardium/src/test/java/com/ibm/guardium/intersystemsiris/ParserTest.java @@ -1,26 +1,20 @@ package com.ibm.guardium.intersystemsiris; -import static org.junit.Assert.*; - -import java.util.Collection; -import java.util.Collections; - import com.google.gson.JsonObject; import com.google.gson.JsonParser; - -import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import co.elastic.logstash.api.Event; - +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class ParserTest { @Test public void testparseTime() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals(Long.parseLong("1686209101250"), record.getTime().getTimstamp()); assertEquals(0, record.getTime().getMinDst()); assertEquals(0, record.getTime().getMinOffsetFromGMT()); @@ -31,7 +25,7 @@ public void testparseTime() throws Exception { public void testparseNullClientIp() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":null,\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); assertNotNull(record); } @@ -40,7 +34,7 @@ public void testparseNullClientIp() throws Exception { public void testparseSessionLocator() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getSessionLocator().getClientIpv6()); assertEquals("", record.getSessionLocator().getServerIpv6()); assertEquals(-1, record.getSessionLocator().getServerPort()); @@ -52,7 +46,7 @@ public void testparseSessionLocator() throws Exception { public void testparseSessionId() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("-1211128616", record.getSessionId()); assertNotNull(record); } @@ -61,7 +55,7 @@ public void testparseSessionId() throws Exception { public void testparseClientIp() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("20.204.110.141", record.getSessionLocator().getClientIp()); assertNotNull(record); } @@ -70,7 +64,7 @@ public void testparseClientIp() throws Exception { public void testparseEmptyClientIp() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); @@ -80,7 +74,7 @@ public void testparseEmptyClientIp() throws Exception { public void testparseNoIp() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); @@ -90,7 +84,7 @@ public void testparseNoIp() throws Exception { public void testparseServerIp() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"Server_ip\":\"80.104.110.181\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("80.104.110.181", record.getSessionLocator().getServerIp()); assertNotNull(record); } @@ -99,7 +93,7 @@ public void testparseServerIp() throws Exception { public void testparseNullServerIp() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"serveripaddress\":null,\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); } @@ -108,7 +102,7 @@ public void testparseNullServerIp() throws Exception { public void testparseEmptyServerIp() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"serveripaddress\":\"\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); } @@ -117,7 +111,7 @@ public void testparseEmptyServerIp() throws Exception { public void testparseNoServerIp() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); } @@ -126,7 +120,7 @@ public void testparseNoServerIp() throws Exception { public void testServerClientIpv6() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\",\"Server_ip\":\"1233:0dc8:33a3:0000:0000:9a2e:0440:8834\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("2001:0db8:85a3:0000:0000:8a2e:0370:7334", record.getSessionLocator().getClientIpv6()); assertEquals("1233:0dc8:33a3:0000:0000:9a2e:0440:8834", record.getSessionLocator().getServerIpv6()); assertEquals(-1, record.getSessionLocator().getServerPort()); @@ -138,7 +132,7 @@ public void testServerClientIpv6() throws Exception { public void testparseDbname() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("%SYS", record.getDbName()); assertNotNull(record); } @@ -147,7 +141,7 @@ public void testparseDbname() throws Exception { public void testparseEmptyDbname() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getDbName()); assertNotNull(record); } @@ -156,7 +150,7 @@ public void testparseEmptyDbname() throws Exception { public void testparseNoDbname() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getDbName()); assertNotNull(record); } @@ -165,7 +159,7 @@ public void testparseNoDbname() throws Exception { public void testparseDbuser() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("UnknownUser", record.getAccessor().getDbUser()); assertNotNull(record); } @@ -174,7 +168,7 @@ public void testparseDbuser() throws Exception { public void testparseEmptyDbuser() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("NA", record.getAccessor().getDbUser()); assertNotNull(record); } @@ -183,7 +177,7 @@ public void testparseEmptyDbuser() throws Exception { public void testparseNoDbuser() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("NA", record.getAccessor().getDbUser()); assertNotNull(record); } @@ -192,7 +186,7 @@ public void testparseNoDbuser() throws Exception { public void testparseServerhostname() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("ip-172-31-91-96:IRIS", record.getAccessor().getServerHostName()); assertNotNull(record); } @@ -201,7 +195,7 @@ public void testparseServerhostname() throws Exception { public void testparseEmptyServerhostname() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getAccessor().getServerHostName()); assertNotNull(record); } @@ -210,7 +204,7 @@ public void testparseEmptyServerhostname() throws Exception { public void testparseNoServerhostname() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getAccessor().getServerHostName()); assertNotNull(record); } @@ -219,7 +213,7 @@ public void testparseNoServerhostname() throws Exception { public void testparseOsUsername() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("vaishnavi.g", record.getAccessor().getOsUser()); assertNotNull(record); } @@ -228,7 +222,7 @@ public void testparseOsUsername() throws Exception { public void testparseEmptyOsUsername() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getAccessor().getOsUser()); assertNotNull(record); } @@ -237,7 +231,7 @@ public void testparseEmptyOsUsername() throws Exception { public void testparseNoOsUsername() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getAccessor().getOsUser()); assertNotNull(record); } @@ -246,7 +240,7 @@ public void testparseNoOsUsername() throws Exception { public void testparseProtocolServer() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("IRIS", record.getAccessor().getDbProtocol()); assertEquals("IRIS", record.getAccessor().getServerType()); assertNotNull(record); @@ -256,7 +250,7 @@ public void testparseProtocolServer() throws Exception { public void testparseAccesor() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("", record.getAccessor().getClientHostName()); assertEquals("", record.getAccessor().getClientOs()); assertEquals("", record.getAccessor().getSourceProgram()); @@ -273,7 +267,7 @@ public void testparseAccesor() throws Exception { public void testparseLanguage() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertNotNull(record); } @@ -282,7 +276,7 @@ public void testparseLanguage() throws Exception { public void testparseDatatype() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertNotNull(record); } @@ -291,7 +285,7 @@ public void testparseDatatype() throws Exception { public void testparseException() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"LoginFailure\",\"namespace\":\"%SYS\",\"clientipaddress\":\"103.149.70.62\",\"@timestamp\":\"2023-06-08T10:39:02.992Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"guardium_dev\",\"mytimestamp\":\"2023-06-08 10:41:11.842\",\"eventdata\":\"Error message: ERROR #798: Password login failed\\r\\nERROR #952: Invalid password\\r\\nWeb Application: /csp/sys\\r\\n$I: |TCP|1972|1689\\r\\n$P: |TCP|1972|1689\\r\\n\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("Error message: ERROR #798: Password login failed\r\nERROR #952: Invalid password\r\nWeb Application: /csp/sys\r\n$I: |TCP|1972|1689\r\n$P: |TCP|1972|1689\r\n",record.getException().getDescription()); assertEquals("LOGIN_FAILED", record.getException().getExceptionTypeId()); assertEquals("NA", record.getException().getSqlString()); @@ -302,7 +296,7 @@ public void testparseException() throws Exception { public void testparseEmptyExceptionMessage() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"LoginFailure\",\"namespace\":\"%SYS\",\"clientipaddress\":\"103.149.70.62\",\"@timestamp\":\"2023-06-08T10:39:02.992Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"guardium_dev\",\"mytimestamp\":\"2023-06-08 10:41:11.842\",\"eventdata\":\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("NA", record.getException().getDescription()); assertEquals("LOGIN_FAILED", record.getException().getExceptionTypeId()); assertEquals("NA", record.getException().getSqlString()); @@ -313,7 +307,7 @@ public void testparseEmptyExceptionMessage() throws Exception { public void testparseNoExceptionMessage() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"LoginFailure\",\"namespace\":\"%SYS\",\"clientipaddress\":\"103.149.70.62\",\"@timestamp\":\"2023-06-08T10:39:02.992Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"guardium_dev\",\"mytimestamp\":\"2023-06-08 10:41:11.842\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("NA", record.getException().getDescription()); assertEquals("LOGIN_FAILED", record.getException().getExceptionTypeId()); assertEquals("NA", record.getException().getSqlString()); @@ -324,7 +318,7 @@ public void testparseNoExceptionMessage() throws Exception { public void testparseNoEventtype() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"clientipaddress\":\"103.149.70.62\",\"event\":\"DynamicStatement\",\"@timestamp\":\"2023-06-08T10:39:02.992Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"guardium_dev\",\"mytimestamp\":\"2023-06-08 10:41:11.842\",\"eventdata\":\" \\r\\nDROP TABLE soumalya\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("DROP TABLE", record.getData().getConstruct().getSentences().get(0).getVerb()); assertEquals("soumalya", record.getData().getConstruct().getSentences().get(0).getObjects().get(0).name); assertNotNull(record); @@ -334,7 +328,7 @@ public void testparseNoEventtype() throws Exception { public void testparseCreateTable() throws Exception { final String message = "{\"@timestamp\":\"2023-06-08T07:23:04.607Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"@version\":\"1\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"username\":\"guardium_dev\",\"eventdata\":\"CREATE TABLE sample_Tab(ID int, FirstName varchar(255), LastName varchar(255)) /*#OPTIONS {\\\"xDBC\\\":1} */\",\"event\":\"XDBCStatement\",\"mytimestamp\":\"2023-06-08 07:25:01.250\",\"type\":\"test\",\"osusername\":\"vaishnavi.g\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("CREATE TABLE", record.getData().getConstruct().getSentences().get(0).getVerb()); @@ -345,7 +339,7 @@ public void testparseCreateTable() throws Exception { public void testparseInsertTable() throws Exception { final String message = "{\"@version\":\"1\",\"osusername\":\"CSP Gateway\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"clientipaddress\":\"20.204.110.141\",\"@timestamp\":\"2023-06-08T10:35:06.410Z\",\"systemid\":\"ip-172-31-91-96:IRIS\",\"username\":\"UnknownUser\",\"mytimestamp\":\"2023-06-08 10:07:53.452\",\"eventdata\":\" INSERT INTO samples1 VALUES ( ? , ? , ? ) /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10,1,1\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=1\\r\\n%CallArgs(2)=\\\"Vaishu\\\"\\r\\n%CallArgs(3)=\\\"Gopi\\\"\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("INSERT", record.getData().getConstruct().getSentences().get(0).getVerb()); @@ -356,7 +350,7 @@ public void testparseInsertTable() throws Exception { public void testparseDropTable() throws Exception { final String message = "{\"osusername\":\"CSP Gateway\",\"@timestamp\":\"2023-06-29T08:11:07.314Z\",\"mytimestamp\":\"2023-06-29 08:09:13.953\",\"username\":\"UnknownUser\",\"namespace\":\"IRISDB2605\",\"type\":\"test\",\"eventdata\":\" \\r\\nDROP TABLE soumalya\",\"@version\":\"1\",\"clientipaddress\":\"20.204.110.141\",\"event\":\"DynamicStatement\",\"systemid\":\"ip-172-31-33-219:IRIS\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("DROP TABLE", record.getData().getConstruct().getSentences().get(0).getVerb()); @@ -367,7 +361,7 @@ public void testparseDropTable() throws Exception { public void testparseUpdateTable() throws Exception { final String message = "{\"clientipaddress\":\"20.204.110.141\",\"event\":\"DynamicStatement\",\"@timestamp\":\"2023-06-29T08:32:07.068Z\",\"mytimestamp\":\"2023-06-29 08:29:59.104\",\"username\":\"UnknownUser\",\"eventdata\":\" UPDATE soumalya SET FirstName = ? WHERE ID = ? /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"1,10\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=\\\"Nitin\\\"\\r\\n%CallArgs(2)=1\",\"type\":\"test\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"namespace\":\"IRISDB2605\",\"@version\":\"1\",\"osusername\":\"CSP Gateway\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("UPDATE", record.getData().getConstruct().getSentences().get(0).getVerb()); @@ -378,7 +372,7 @@ public void testparseUpdateTable() throws Exception { public void testparseSelect() throws Exception { final String message = "{\"eventdata\":\" SELECT * FROM demotable4\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"IRISDB2605\",\"mytimestamp\":\"2023-07-04 05:45:37.822\",\"@timestamp\":\"2023-07-04T05:45:11.664Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -390,7 +384,7 @@ public void testparseSelect() throws Exception { public void testparseNestedSelect() throws Exception { final String message = "{\"eventdata\":\"SELECT Name,Salary,Home_State FROM Sample.Employee WHERE Salary > 75000 AND Home_State = ANY (SELECT State FROM Sample.USZipCode WHERE Longitude < -93) ORDER BY Home_State\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"IRISDB2605\",\"mytimestamp\":\"2023-07-04 05:45:37.822\",\"@timestamp\":\"2023-07-04T05:45:11.664Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -402,7 +396,7 @@ public void testparseNestedSelect() throws Exception { public void testparseDelete() throws Exception { final String message = "{\"eventdata\":\" DELETE FROM Employee1 WHERE EmpNum = ? /*#OPTIONS {\\\"DynamicSQLTypeList\\\":\\\"10\\\"} */\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\\r\\nParameter values:\\r\\n%CallArgs(1)=12\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"IRISDB2605\",\"mytimestamp\":\"2023-07-04 05:54:37.940\",\"@timestamp\":\"2023-07-04T05:54:06.877Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -414,7 +408,7 @@ public void testparseDelete() throws Exception { public void testparseTruncate() throws Exception { final String message = "{\"eventdata\":\" TRUNCATE TABLE Employee1\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"IRISDB2605\",\"mytimestamp\":\"2023-07-04 05:57:28.458\",\"@timestamp\":\"2023-07-04T05:57:05.222Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -426,7 +420,7 @@ public void testparseTruncate() throws Exception { public void testparseCreateProcedure() throws Exception { final String message ="{\"eventdata\":\"CREATE PROCEDURE UpdatePaySP (IN Salary INTEGER DEFAULT 0, IN Name VARCHAR(50), INOUT PayBracket VARCHAR(50) DEFAULT 'NULL') BEGIN UPDATE Sample.Person SET Salary = :Salary WHERE Name=:Name ; END\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"mytimestamp\":\"2023-07-04 06:32:25.931\",\"@timestamp\":\"2023-07-04T06:32:02.378Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -438,7 +432,7 @@ public void testparseCreateProcedure() throws Exception { public void testparseExplain() throws Exception { final String message = "{\"clientipaddress\":null,\"mytimestamp\":\"2023-07-04 09:42:03.016\",\"@timestamp\":\"2023-07-04T09:42:01.401Z\",\"osusername\":\"CSP Gateway\",\"username\":\"UnknownUser\",\"type\":\"test\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"event\":\"DynamicStatement\",\"namespace\":\"%SYS\",\"eventdata\":\"SELECT %SYSTEM.QUERY_PLAN('SELECT * FROM Emp ',0,'ShowPlan') AS Plan\\r\\n /*#OPTIONS { \\\"IsolationLevel\\\":0 } */\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -450,7 +444,7 @@ public void testparseExplain() throws Exception { public void testparseLockTable() throws Exception { final String message = "{\"eventdata\":\" \\r\\nLOCK TABLE Emp IN SHARE MODE \\r\\n\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"mytimestamp\":\"2023-07-04 06:43:34.577\",\"@timestamp\":\"2023-07-04T06:43:02.496Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -462,7 +456,7 @@ public void testparseLockTable() throws Exception { public void testparseCreateUser() throws Exception { final String message = "{\"eventdata\":\" \\r\\nCREATE USER DEMOUSER identified by 12345 \",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"mytimestamp\":\"2023-07-04 07:02:19.129\",\"@timestamp\":\"2023-07-04T07:02:01.681Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -474,7 +468,7 @@ public void testparseCreateUser() throws Exception { public void testparseCreateRole() throws Exception { final String message = "{\"eventdata\":\" \\r\\nCREATE ROLE role1\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"mytimestamp\":\"2023-07-04 07:03:41.324\",\"@timestamp\":\"2023-07-04T07:04:04.079Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -486,7 +480,7 @@ public void testparseCreateRole() throws Exception { public void testparseGrant() throws Exception { final String message = "{\"eventdata\":\" \\r\\nGRANT role1 to DEMOUSER\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"mytimestamp\":\"2023-07-04 07:05:34.261\",\"@timestamp\":\"2023-07-04T07:05:02.506Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -498,7 +492,7 @@ public void testparseGrant() throws Exception { public void testparseRevoke() throws Exception { final String message = "{\"eventdata\":\" \\r\\nREVOKE role1 from DEMOUSER\",\"event\":\"DynamicStatement\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"namespace\":\"%SYS\",\"mytimestamp\":\"2023-07-04 07:07:15.311\",\"@timestamp\":\"2023-07-04T07:07:01.432Z\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"@version\":\"1\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -510,7 +504,7 @@ public void testparseRevoke() throws Exception { public void testparseCreateMLConfig() throws Exception { final String message = "{\"namespace\":\"%SYS\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"eventdata\":\" \\r\\nCREATE ML CONFIGURATION autoML_config PROVIDER AutoML %DESCRIPTION 'my AutoML configuration!'\",\"mytimestamp\":\"2023-07-05 06:13:32.013\",\"username\":\"UnknownUser\",\"@timestamp\":\"2023-07-05T06:26:05.660Z\",\"@version\":\"1\",\"clientipaddress\":null,\"systemid\":\"ip-172-31-33-219:IRIS\",\"event\":\"DynamicStatement\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -522,7 +516,7 @@ public void testparseCreateMLConfig() throws Exception { public void testparseCreateSchema() throws Exception { final String message = "{\"namespace\":\"%SYS\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"eventdata\":\" \\r\\nCREATE SCHEMA DEMOSCHEMA\",\"mytimestamp\":\"2023-07-05 06:27:26.516\",\"username\":\"UnknownUser\",\"@timestamp\":\"2023-07-05T06:27:05.317Z\",\"@version\":\"1\",\"clientipaddress\":null,\"systemid\":\"ip-172-31-33-219:IRIS\",\"event\":\"DynamicStatement\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -534,7 +528,7 @@ public void testparseCreateSchema() throws Exception { public void testparseAlterUser() throws Exception { final String message = "{\"namespace\":\"%SYS\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"eventdata\":\" \\r\\nALTER USER DEMOUSER IDENTIFY BY 54321\",\"mytimestamp\":\"2023-07-05 06:31:57.318\",\"username\":\"UnknownUser\",\"@timestamp\":\"2023-07-05T06:32:03.628Z\",\"@version\":\"1\",\"clientipaddress\":null,\"systemid\":\"ip-172-31-33-219:IRIS\",\"event\":\"DynamicStatement\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -546,7 +540,7 @@ public void testparseAlterUser() throws Exception { public void testparseCreateAggregateFunc() throws Exception { final String message = "{\"namespace\":\"%SYS\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"eventdata\":\" \\r\\nCREATE AGGREGATE Sample.SumAddSub(arg NUMERIC(4,1)) ITERATE WITH Sample.AddSub\",\"mytimestamp\":\"2023-07-05 06:38:50.424\",\"username\":\"UnknownUser\",\"@timestamp\":\"2023-07-05T06:39:02.071Z\",\"@version\":\"1\",\"clientipaddress\":null,\"systemid\":\"ip-172-31-33-219:IRIS\",\"event\":\"DynamicStatement\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -558,7 +552,7 @@ public void testparseCreateAggregateFunc() throws Exception { public void testparseDropAggregateFunc() throws Exception { final String message = "{\"namespace\":\"%SYS\",\"type\":\"test\",\"osusername\":\"CSP Gateway\",\"eventdata\":\" \\r\\nDROP AGGREGATE Sample.SumAddSub\",\"mytimestamp\":\"2023-07-05 06:44:52.656\",\"username\":\"UnknownUser\",\"@timestamp\":\"2023-07-05T06:44:28.219Z\",\"@version\":\"1\",\"clientipaddress\":null,\"systemid\":\"ip-172-31-33-219:IRIS\",\"event\":\"DynamicStatement\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); @@ -570,7 +564,7 @@ public void testparseDropAggregateFunc() throws Exception { public void testparseCreateModel() throws Exception { final String message ="{\"eventdata\":\" \\r\\nCREATE MODEL SpamFilter PREDICTING (IsSpam) WITH (email_length int, subject_title varchar) \\r\\n\",\"mytimestamp\":\"2023-07-05 07:27:00.858\",\"namespace\":\"%SYS\",\"osusername\":\"CSP Gateway\",\"clientipaddress\":null,\"username\":\"UnknownUser\",\"event\":\"DynamicStatement\",\"systemid\":\"ip-172-31-33-219:IRIS\",\"@timestamp\":\"2023-07-05T07:29:04.424Z\",\"@version\":\"1\",\"type\":\"test\"}"; final JsonObject irisJson = JsonParser.parseString(message).getAsJsonObject(); - Record record = Parser.parseRecord(irisJson); + UCRecord record = Parser.parseRecord(irisJson); assertEquals("CONSTRUCT", record.getAccessor().getDataType()); assertEquals("FREE_TEXT", record.getAccessor().getLanguage()); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); diff --git a/filter-plugin/logstash-filter-mariadb-aws-guardium/.gitignore b/filter-plugin/logstash-filter-mariadb-aws-guardium/.gitignore index abf907260..db6188562 100644 --- a/filter-plugin/logstash-filter-mariadb-aws-guardium/.gitignore +++ b/filter-plugin/logstash-filter-mariadb-aws-guardium/.gitignore @@ -12,3 +12,4 @@ build/ Gemfile* gradle.properties .settings/ +.idea/ diff --git a/filter-plugin/logstash-filter-mariadb-aws-guardium/build.gradle b/filter-plugin/logstash-filter-mariadb-aws-guardium/build.gradle index a0530ae6b..5a5ae814b 100644 --- a/filter-plugin/logstash-filter-mariadb-aws-guardium/build.gradle +++ b/filter-plugin/logstash-filter-mariadb-aws-guardium/build.gradle @@ -22,10 +22,10 @@ pluginInfo.pluginName = "awsmariadb_guardium_filter" // must match the @Log // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -43,8 +43,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-mariadb-aws-guardium/gradlew b/filter-plugin/logstash-filter-mariadb-aws-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/AWSMariaDBGuardiumFilter.java b/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/AWSMariaDBGuardiumFilter.java index d00ed9880..793d7ef0f 100644 --- a/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/AWSMariaDBGuardiumFilter.java +++ b/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/AWSMariaDBGuardiumFilter.java @@ -16,7 +16,7 @@ import com.google.gson.GsonBuilder; import com.ibm.guardium.awsmariadb.constant.ApplicationConstant; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -58,7 +58,7 @@ public Collection> configSchema() { @Override public Collection filter(Collection events, FilterMatchListener matchListener) { ArrayList skippedEvents = new ArrayList<>(); - Record rec = null; + UCRecord rec = null; GsonBuilder builder = null; Gson gson = null; for (Event event : events) { diff --git a/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/ParserHelper.java b/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/ParserHelper.java index d6c57003b..b887b0e37 100644 --- a/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/ParserHelper.java +++ b/filter-plugin/logstash-filter-mariadb-aws-guardium/src/main/java/com/ibm/guardium/awsmariadb/ParserHelper.java @@ -5,8 +5,13 @@ package com.ibm.guardium.awsmariadb; +import co.elastic.logstash.api.Event; +import com.ibm.guardium.awsmariadb.constant.ApplicationConstant; +import com.ibm.guardium.universalconnector.commons.structures.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -14,19 +19,6 @@ import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.StringJoiner; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.ibm.guardium.awsmariadb.constant.ApplicationConstant; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; -import co.elastic.logstash.api.Event; /** * Parser Class will perform operation on parsing events and messages from the @@ -51,8 +43,8 @@ public class ParserHelper { * @param event * @return record */ - public static Record parseRecord(final Event event) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(final Event event) throws Exception { + UCRecord record = new UCRecord(); try { record.setSessionLocator(parseSessionLocator(event)); record.setTime(parseTime(event)); @@ -121,7 +113,7 @@ public static String getSessionId(final Event event) { * @param event * @return accessor */ - public static Accessor parseAccessor(final Event event, final Record record) { + public static Accessor parseAccessor(final Event event, final UCRecord record) { Accessor accessor = new Accessor(); try { accessor.setServerHostName(event.getField(ApplicationConstant.SERVERHOSTNAMEPREFIX_KEY) != null && !event.getField(ApplicationConstant.SERVERHOSTNAMEPREFIX_KEY).toString().trim().isEmpty() @@ -214,7 +206,6 @@ public static Data parseData(final Event event) throws Exception { * * @param event * @return SessionLocator - * @throws ParseException */ public static SessionLocator parseSessionLocator(final Event event) { SessionLocator sessionLocator = new SessionLocator(); diff --git a/filter-plugin/logstash-filter-mariadb-aws-guardium/src/test/java/com/ibm/guardium/awsmariadb/ParserHelperTest.java b/filter-plugin/logstash-filter-mariadb-aws-guardium/src/test/java/com/ibm/guardium/awsmariadb/ParserHelperTest.java index 0eb599cad..975d66ca3 100644 --- a/filter-plugin/logstash-filter-mariadb-aws-guardium/src/test/java/com/ibm/guardium/awsmariadb/ParserHelperTest.java +++ b/filter-plugin/logstash-filter-mariadb-aws-guardium/src/test/java/com/ibm/guardium/awsmariadb/ParserHelperTest.java @@ -4,20 +4,13 @@ */ package com.ibm.guardium.awsmariadb; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - +import com.ibm.guardium.awsmariadb.constant.ApplicationConstant; +import com.ibm.guardium.universalconnector.commons.structures.*; import org.junit.jupiter.api.Test; import org.logstash.Event; -import com.ibm.guardium.awsmariadb.ParserHelper; -import com.ibm.guardium.awsmariadb.constant.ApplicationConstant; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ParserHelperTest { @Test @@ -32,7 +25,7 @@ public void parseRecordTest() throws Exception { event.setField(ApplicationConstant.SERVERHOSTNAMEPREFIX_KEY, "979326520502-database-mariadbtest"); event.setField(ApplicationConstantTest.OPERATION_KEY, "QUERY"); event.setField("timestamp", "20220204 15:47:44"); - Record actualResponse = ParserHelper.parseRecord(event); + UCRecord actualResponse = ParserHelper.parseRecord(event); assertNotNull(actualResponse); // assertEquals("231", actualResponse.getSessionId()); assertEquals("331346110", actualResponse.getSessionId()); @@ -57,7 +50,7 @@ public void parseRecordForElseConditionTest() throws Exception { event.setField(ApplicationConstantTest.OPERATION_KEY, "QUERY"); event.setField("timestamp", "20220524 03:22:54"); event.setField("totalOffset", "-330"); - Record actualResponse = ParserHelper.parseRecord(event); + UCRecord actualResponse = ParserHelper.parseRecord(event); assertNotNull(actualResponse); // assertEquals("7", actualResponse.getSessionId()); assertEquals("-1157520155", actualResponse.getSessionId()); @@ -81,7 +74,7 @@ public void parseRecordForElseCondition1Test() throws Exception { event.setField(ApplicationConstantTest.OPERATION_KEY, "QUERY"); event.setField("timestamp", "20220524 03:22:54"); event.setField("totalOffset", "-330"); - Record actualResponse = ParserHelper.parseRecord(event); + UCRecord actualResponse = ParserHelper.parseRecord(event); assertNotNull(actualResponse); } @@ -89,7 +82,7 @@ public void parseRecordForElseCondition1Test() throws Exception { @Test public void parseRecordExceptionTest() throws Exception { try { - Record accessorexception = ParserHelper.parseRecord(null); + UCRecord accessorexception = ParserHelper.parseRecord(null); } catch (Exception e) { } @@ -98,7 +91,7 @@ public void parseRecordExceptionTest() throws Exception { @Test public void parseAccessorTest() { Event event = new org.logstash.Event(); - Record record = new Record(); + UCRecord record = new UCRecord(); event.setField(ApplicationConstant.HOSTNAME_KEY, ApplicationConstantTest.HOSTNAME_VALUE); event.setField(ApplicationConstant.SERVERHOSTNAMEPREFIX_KEY, "979326520502-database-mariadbtest"); event.setField(ApplicationConstant.USERNAME_KEY, ApplicationConstantTest.USERNAME_VALUE); @@ -116,7 +109,7 @@ public void parseAccessorTest() { @Test public void parseAccessor1Test() { Event event = new org.logstash.Event(); - Record record = new Record(); + UCRecord record = new UCRecord(); event.setField(ApplicationConstant.HOSTNAME_KEY, null); event.setField(ApplicationConstant.SERVERHOST_KEY, null); event.setField(ApplicationConstant.USERNAME_KEY, null); @@ -129,7 +122,7 @@ public void parseAccessor1Test() { @Test public void parseAccessorExceptionTest() throws Exception { - Record record = new Record(); + UCRecord record = new UCRecord(); try { Accessor accessorexception = ParserHelper.parseAccessor(null, record); diff --git a/filter-plugin/logstash-filter-mariadb-guardium/.gitignore b/filter-plugin/logstash-filter-mariadb-guardium/.gitignore new file mode 100644 index 000000000..de7abf18d --- /dev/null +++ b/filter-plugin/logstash-filter-mariadb-guardium/.gitignore @@ -0,0 +1,8 @@ +.idea +build +.gradle +.settings +bin +.classpath +.project +gradle.properties diff --git a/filter-plugin/logstash-filter-mariadb-guardium/build.gradle b/filter-plugin/logstash-filter-mariadb-guardium/build.gradle index c868c1dfd..1a5c72d0e 100644 --- a/filter-plugin/logstash-filter-mariadb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-mariadb-guardium/build.gradle @@ -19,10 +19,10 @@ pluginInfo.pluginClass = "MariadbGuardiumFilter" pluginInfo.pluginName = "mariadb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -40,8 +40,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-mariadb-guardium/gradlew b/filter-plugin/logstash-filter-mariadb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/MariadbGuardiumFilter.java b/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/MariadbGuardiumFilter.java index 31d2ed562..f5de8421f 100644 --- a/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/MariadbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/MariadbGuardiumFilter.java @@ -16,7 +16,7 @@ import com.google.gson.GsonBuilder; import com.ibm.guardium.mariadb.constant.ApplicationConstant; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -58,7 +58,7 @@ public Collection> configSchema() { @Override public Collection filter(Collection events, FilterMatchListener matchListener) { ArrayList skippedEvents = new ArrayList<>(); - Record rec = null; + UCRecord rec = null; GsonBuilder builder = null; Gson gson = null; for (Event event : events) { diff --git a/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/ParserHelper.java b/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/ParserHelper.java index 81d85af79..861cd27d8 100644 --- a/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/ParserHelper.java +++ b/filter-plugin/logstash-filter-mariadb-guardium/src/main/java/com/ibm/guardium/mariadb/ParserHelper.java @@ -21,7 +21,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; import co.elastic.logstash.api.Event; @@ -48,8 +48,8 @@ public class ParserHelper { * @param event * @return record */ - public static Record parseRecord(final Event event) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(final Event event) throws Exception { + UCRecord record = new UCRecord(); try { record.setAccessor(parseAccessor(event)); record.setSessionLocator(parseSessionLocator(event)); @@ -68,7 +68,7 @@ public static Record parseRecord(final Event event) throws Exception { && Integer.parseInt(event.getField(ApplicationConstant.RETCODE_KEY).toString().trim()) != 0) { record.setException(parseExceptionRecord(event)); } else { - throw new Exception("Invalid Record : "); + throw new Exception("Invalid UCRecord : "); } } catch (Exception e) { diff --git a/filter-plugin/logstash-filter-mariadb-guardium/src/test/java/com/ibm/guardium/mariadb/ParserHelperTest.java b/filter-plugin/logstash-filter-mariadb-guardium/src/test/java/com/ibm/guardium/mariadb/ParserHelperTest.java index 750f7b7df..3d214e5d5 100644 --- a/filter-plugin/logstash-filter-mariadb-guardium/src/test/java/com/ibm/guardium/mariadb/ParserHelperTest.java +++ b/filter-plugin/logstash-filter-mariadb-guardium/src/test/java/com/ibm/guardium/mariadb/ParserHelperTest.java @@ -15,7 +15,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -33,7 +33,7 @@ public void parseRecordTest() throws Exception { event.setField(ApplicationConstantTest.OPERATION_KEY, "QUERY"); event.setField("timestamp", "20220204 15:47:44"); event.setField("totalOffset", "-330"); - Record actualResponse = ParserHelper.parseRecord(event); + UCRecord actualResponse = ParserHelper.parseRecord(event); assertNotNull(actualResponse); assertEquals("-105977793", actualResponse.getSessionId()); assertEquals("mariadb", actualResponse.getDbName()); @@ -58,7 +58,7 @@ public void parseRecordForElseConditionTest() throws Exception { event.setField(ApplicationConstantTest.OPERATION_KEY, "QUERY"); event.setField("timestamp", "20220204 15:47:44"); event.setField("totalOffset", "-330"); - Record actualResponse = ParserHelper.parseRecord(event); + UCRecord actualResponse = ParserHelper.parseRecord(event); assertNotNull(actualResponse); assertEquals("-105977793", actualResponse.getSessionId()); assertEquals("mariadb", actualResponse.getDbName()); @@ -81,7 +81,7 @@ public void parseRecordForElseCondition1Test() throws Exception { event.setField(ApplicationConstantTest.OPERATION_KEY, "QUERY"); event.setField("timestamp", "20220204 15:47:44"); event.setField("totalOffset", "-330"); - Record actualResponse = ParserHelper.parseRecord(event); + UCRecord actualResponse = ParserHelper.parseRecord(event); assertNotNull(actualResponse); } @@ -89,7 +89,7 @@ public void parseRecordForElseCondition1Test() throws Exception { @Test public void parseRecordExceptionTest() throws Exception { try { - Record accessorexception = ParserHelper.parseRecord(null); + UCRecord accessorexception = ParserHelper.parseRecord(null); } catch (Exception e) { } diff --git a/filter-plugin/logstash-filter-mongodb-guardium/MongoDBOverIBMCloudKafkaStreams/guardium_logstash-offline-plugins-mongo.zip b/filter-plugin/logstash-filter-mongodb-guardium/MongoDBOverIBMCloudKafkaStreams/guardium_logstash-offline-plugins-mongo.zip index c6d81e493..aca219a9c 100644 Binary files a/filter-plugin/logstash-filter-mongodb-guardium/MongoDBOverIBMCloudKafkaStreams/guardium_logstash-offline-plugins-mongo.zip and b/filter-plugin/logstash-filter-mongodb-guardium/MongoDBOverIBMCloudKafkaStreams/guardium_logstash-offline-plugins-mongo.zip differ diff --git a/filter-plugin/logstash-filter-mongodb-guardium/build.gradle b/filter-plugin/logstash-filter-mongodb-guardium/build.gradle index 70f682988..98f0cde52 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-mongodb-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "MongodbGuardiumFilter" pluginInfo.pluginName = "mongodb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/MongodbGuardiumFilter.java b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/MongodbGuardiumFilter.java index 61f88e96e..54062ac2b 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/MongodbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/MongodbGuardiumFilter.java @@ -90,7 +90,7 @@ public Collection filter(Collection events, FilterMatchListener ma // filter internal and not parsed events BaseParser parser = ParserFactory.getParser(inputJSON); - Record record = parser.parseRecord(inputJSON); + UCRecord record = parser.parseRecord(inputJSON); if (record==null){ e.tag(LOGSTASH_TAG_SKIP); skippedEvents.add(e); @@ -169,7 +169,7 @@ private int getAuditMsgStartIndex(String messageString){ * @param e - Logstash Event * @param record - Record after parsing. */ - private void correctIPs(Event e, Record record) { + private void correctIPs(Event e, UCRecord record) { // Override "(NONE)" IP, if not filterd, as it's internal command by MongoDB. // Note: IP needs to be in ipv4/ipv6 format SessionLocator sessionLocator = record.getSessionLocator(); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/Parser.java b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/Parser.java index 53fc3db69..1f834c8bc 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/Parser.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/Parser.java @@ -188,8 +188,8 @@ protected static SentenceObject parseSentenceObject(JsonObject args, String comm } - public static Record parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); final JsonObject param = data.get("param").getAsJsonObject(); final JsonObject args = param.getAsJsonObject("args"); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/BaseParser.java b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/BaseParser.java index bce72beff..640f50d49 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/BaseParser.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/BaseParser.java @@ -56,13 +56,13 @@ public boolean validate(JsonObject data){ return true; } - public Record parseRecord(final JsonObject data){ + public UCRecord parseRecord(final JsonObject data){ if (!validate(data)){ return null; } - Record record = new Record(); + UCRecord record = new UCRecord(); final JsonObject param = data.get("param").getAsJsonObject(); final JsonObject args = param==null ? null : param.getAsJsonObject("args"); @@ -99,7 +99,7 @@ public Record parseRecord(final JsonObject data){ return record; } - private void fixSessionId(Record record) { + private void fixSessionId(UCRecord record) { String sessionId = record.getSessionId(); if (sessionId==null || sessionId.trim().length()==0){ // must generate unique value that could identify session and we are not provided with real session id value diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/LoginParser.java b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/LoginParser.java index ed085d867..c3f66b6fb 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/LoginParser.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/main/java/com/ibm/guardium/mongodb/parsersbytype/LoginParser.java @@ -1,21 +1,14 @@ package com.ibm.guardium.mongodb.parsersbytype; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Optional; - import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.ibm.guardium.mongodb.AType; -import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Construct; -import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import com.ibm.guardium.universalconnector.commons.structures.Sentence; -import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; -import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; -import com.ibm.guardium.universalconnector.commons.structures.Time; +import com.ibm.guardium.universalconnector.commons.structures.*; + +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Optional; public class LoginParser extends BaseParser { @@ -34,8 +27,8 @@ public boolean validate(JsonObject data) { } @Override - public Record parseRecord(JsonObject data) { - Record record = new Record(); + public UCRecord parseRecord(JsonObject data) { + UCRecord record = new UCRecord(); String sessionId = getSessionID(data); String dbName = getInitialUser(data).get("db").getAsString(); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongoDbIpaTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongoDbIpaTest.java index 8507b5a56..0b8169420 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongoDbIpaTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongoDbIpaTest.java @@ -8,7 +8,7 @@ import co.elastic.logstash.api.Event; import com.google.gson.Gson; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -87,7 +87,7 @@ public void testFieldGuardRecord_ip_local_filebeatIpV6() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIpv6().equals(serverIpFromFilebeat)); Assert.assertTrue(record.getSessionLocator().getServerIpv6().equals(serverIpFromFilebeat)); @@ -114,7 +114,7 @@ public void testFieldGuardRecord_ip_local_filebeatIpV4() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals(serverIpFromFilebeat)); Assert.assertTrue(record.getSessionLocator().getServerIp().equals(serverIpFromFilebeat)); @@ -141,7 +141,7 @@ public void testFieldGuardRecord_ip_NONE_filebeatIpV4() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals(serverIpFromFilebeat)); Assert.assertTrue(record.getSessionLocator().getServerIp().equals(serverIpFromFilebeat)); @@ -167,7 +167,7 @@ public void testFieldGuardRecord_ip_NONE_filebeatIpV6() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals(serverIpFromFilebeat)); Assert.assertTrue(record.getSessionLocator().getServerIp().equals(serverIpFromFilebeat)); @@ -195,7 +195,7 @@ public void testFieldGuardRecord_ip_NONE_filebeatInvalid() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals("0.0.0.0")); Assert.assertTrue(record.getSessionLocator().getServerIp().equals("0.0.0.0")); @@ -222,7 +222,7 @@ public void testFieldGuardRecord_ip_local_filebeatInvalid() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals("127.0.0.1")); Assert.assertTrue(record.getSessionLocator().getServerIp().equals("127.0.0.1")); @@ -252,7 +252,7 @@ public void testFieldGuardRecord_ip_local_no_filebeat_ip() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals("127.0.0.1")); Assert.assertTrue(record.getSessionLocator().getServerIp().equals("127.0.0.1")); @@ -283,7 +283,7 @@ public void testFieldGuardRecord_ip_NONE_no_filebeat_ip() { Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); String recordStr = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = new Gson().fromJson(recordStr, Record.class); + UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); Assert.assertTrue(record.getSessionLocator().getClientIp().equals("0.0.0.0")); Assert.assertTrue(record.getSessionLocator().getServerIp().equals("0.0.0.0")); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongodbGuardiumFilterTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongodbGuardiumFilterTest.java index e86a2b4b6..3333c98c2 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongodbGuardiumFilterTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/MongodbGuardiumFilterTest.java @@ -5,20 +5,17 @@ package com.ibm.guardium.mongodb; //import co.elastic.logstash.api.Configuration; + import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; -import co.elastic.logstash.api.FilterMatchListener; +import com.google.gson.Gson; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; -//import org.logstash.plugins.ConfigurationImpl; import org.logstash.plugins.ContextImpl; import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; - -import com.google.gson.Gson; import static com.ibm.guardium.mongodb.MongodbGuardiumFilter.LOGSTASH_TAG_SKIP_NOT_MONGODB; @@ -78,7 +75,7 @@ public void testParseICDMongo_dbname_prefix_Empty() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals("testdatabase",record.getDbName()); } @@ -99,7 +96,7 @@ public void testParseICDMongo_DbName_NotAvailable() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals("testid44505a917e8fcb952c4ce-test75b-776c-486e-8ee7-f6a0ddd5a1cb",record.getDbName() ); } @@ -120,7 +117,7 @@ public void testParseICDMongo_authenticate_LoginFailedLog() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals(Parser.EXCEPTION_TYPE_AUTHENTICATION_STRING, record.getException().getExceptionTypeId()); Assert.assertEquals("admin IBMuser",record.getAccessor().getDbUser()); @@ -142,7 +139,7 @@ public void testParseICDMongo_IPV6() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals(true,record.getSessionLocator().isIpv6()); } @@ -163,7 +160,7 @@ public void testParseICDMongo_authenticate_UnknownErrorLog() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals(Parser.EXCEPTION_TYPE_AUTHORIZATION_STRING, record.getException().getExceptionTypeId()); Assert.assertEquals("Error (20)", record.getException().getDescription()); @@ -185,7 +182,7 @@ public void testParseICDMongo_IPNotAvailable() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals("", record.getSessionLocator().getClientIp()); Assert.assertEquals(-1, record.getSessionLocator().getClientPort()); @@ -389,7 +386,7 @@ public void testParseMongoSyslog_localhostIPs_remain() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals( @@ -420,7 +417,7 @@ public void testParseMongoSyslog_localhostIP_override() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals( @@ -447,7 +444,7 @@ public void testParseMongoSyslog_doNotInjectHost() { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); Assert.assertNotNull(record); Assert.assertEquals( diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/ParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/ParserTest.java index 9282805f6..9cc38869d 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/ParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/ParserTest.java @@ -4,16 +4,15 @@ // package com.ibm.guardium.mongodb; -import java.text.ParseException; - import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.structures.*; - import org.junit.Assert; import org.junit.Test; +import java.text.ParseException; + public class ParserTest { Parser parser = new Parser(); @@ -187,7 +186,7 @@ public void testParseAsConstruct_Aggregate_graphLookup() { public void testParseRecord_createIndex() throws ParseException { final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-06-03T07:48:55.762-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 41112 }, \"users\" : [ { \"user\" : \"realAdmin\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"readWriteAnyDatabase\", \"db\" : \"admin\" }, { \"role\" : \"userAdminAnyDatabase\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"createIndexes\", \"ns\" : \"newDB01.newCollecti\", \"args\" : { \"createIndexes\" : \"newCollecti\", \"indexes\" : [ { \"key\" : { \"category\" : 1 }, \"name\" : \"testIDX1\" } ], \"lsid\" : { \"id\" : { \"$binary\" : \"T52tf2+yRbu31sZ5kq9R7Q==\", \"$type\" : \"04\" } }, \"$db\" : \"newDB01\" } }, \"result\" : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -201,7 +200,7 @@ public void testParseRecord_createCollection() throws ParseException { // skipping dedicated log messages "{ \"atype\" : \"createCollection\", \"ts\" : { \"$date\" : \"2020-05-11T06:24:38.168-0400\" } , \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 } , \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 48458 } , \"users\" : [], \"roles\" : [], \"param\" : { \"ns\" : \"test.collection3\" } , \"result\" : 0 }"; final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-06-03T03:40:30.888-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 40426 }, \"users\" : [ { \"user\" : \"realAdmin\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"readWriteAnyDatabase\", \"db\" : \"admin\" }, { \"role\" : \"userAdminAnyDatabase\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"create\", \"ns\" : \"newDB01.newCollection01\", \"args\" : { \"create\" : \"newCollection01\", \"lsid\" : { \"id\" : { \"$binary\" : \"CsTWBZwaQnOweCDDbiJWng==\", \"$type\" : \"04\" } }, \"$db\" : \"newDB01\" } }, \"result\" : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -216,7 +215,7 @@ public void testParseRecord_createCollection_v4_4() throws ParseException { // skipping dedicated log messages "{ \"atype\" : \"createCollection\", \"ts\" : { \"$date\" : \"2020-05-11T06:24:38.168-0400\" } , \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 } , \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 48458 } , \"users\" : [], \"roles\" : [], \"param\" : { \"ns\" : \"test.collection3\" } , \"result\" : 0 }"; final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-08-30T07:22:46.361-04:00\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 49990 }, \"users\" : [ { \"user\" : \"admin\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"root\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"create\", \"ns\" : \"test.newCollection01tal\", \"args\" : { \"create\" : \"newCollection01tal\", \"lsid\" : { \"id\" : { \"$binary\" : \"nWP0p95qTgKYH2VwpukLcQ==\", \"$type\" : \"04\" } }, \"$db\" : \"test\" } }, \"result\" : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -243,7 +242,7 @@ public void testParseRecord_AuthorizationError() throws ParseException { final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-05-17T11:29:02.773-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 29360 }, \"users\" : [ { \"user\" : \"readerUser\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"read\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"insert\", \"ns\" : \"admin.USERS\", \"args\" : { \"insert\" : \"USERS\", \"ordered\" : true, \"lsid\" : { \"id\" : { \"$binary\" : \"EQSjmxPcSxyNN6Vw7Wy1pQ==\", \"$type\" : \"04\" } }, \"$db\" : \"admin\", \"documents\" : [ { \"_id\" : { \"$oid\" : \"5ec1583e3a55d1ed961be47e\" }, \"uid\" : 2, \"name\" : \"Tal\" } ] } }, \"result\" : 13 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - final Record record = Parser.parseRecord(mongoJson); + final UCRecord record = Parser.parseRecord(mongoJson); Assert.assertEquals( Parser.EXCEPTION_TYPE_AUTHORIZATION_STRING, @@ -261,7 +260,7 @@ public void testParseRecord_AuthenticationError() throws ParseException { final String mongoString = "{ \"atype\" : \"authenticate\", \"ts\" : { \"$date\" : \"2020-05-17T11:37:30.421-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 29398 }, \"users\" : [], \"roles\" : [], \"param\" : { \"user\" : \"readerUser\", \"db\" : \"admin\", \"mechanism\" : \"SCRAM-SHA-256\" }, \"result\" : 18 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); // final String actualResult = Parser.Parse(mongoJson); - final Record record = Parser.parseRecord(mongoJson); + final UCRecord record = Parser.parseRecord(mongoJson); Assert.assertEquals("readerUser", record.getAccessor().getDbUser().trim()); @@ -331,7 +330,7 @@ public void testRedactData_aggregate() { @Test public void testParseRecord() throws ParseException { - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); Assert.assertEquals("2WoIDPhSTcKHrdJW4azoow==", record.getSessionId()); Assert.assertEquals("test", record.getDbName()); Assert.assertEquals(Parser.UNKOWN_STRING, record.getAppUserName()); @@ -350,7 +349,7 @@ public void testParseData() { @Test public void testParseSessionLocator() throws ParseException { - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); SessionLocator actual = record.getSessionLocator(); Assert.assertEquals("127.0.0.1", actual.getServerIp()); @@ -365,7 +364,7 @@ public void testParseSessionLocator_IPv6() throws ParseException { final String mongoIPv6String = "{ \"atype\": \"authCheck\", \"ts\": { \"$date\": \"2020-01-26T09:58:44.547-0500\" }, \"local\": { \"ip\": \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\", \"port\": 27017 }, \"remote\": { \"ip\": \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\", \"port\": 56984 }, \"users\": [], \"roles\": [], \"param\": { \"command\": \"aggregate\", \"ns\": \"test.travelers\", \"args\": { \"aggregate\": \"travelers\", \"pipeline\": [ { \"$graphLookup\": { \"from\": \"airports\", \"startWith\": \"$nearestAirport\", \"connectFromField\": \"connects\", \"connectToField\": \"airport\", \"maxDepth\": 2, \"depthField\": \"numConnections\", \"as\": \"destinations\" } } ], \"cursor\": {}, \"lsid\": { \"id\": { \"$binary\": \"2WoIDPhSTcKHrdJW4azoow==\", \"$type\": \"04\" } }, \"$db\": \"test\" } }, \"result\": 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoIPv6String).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); SessionLocator actual = record.getSessionLocator(); Assert.assertTrue("sessionLocator should mark that IPs are in IPv6", actual.isIpv6()); @@ -378,7 +377,7 @@ public void testParseSessionLocator_IPv6() throws ParseException { @Test public void testParseAccessor() throws ParseException { - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); Accessor actual = record.getAccessor(); Assert.assertEquals(Parser.DATA_PROTOCOL_STRING, actual.getDbProtocol()); Assert.assertEquals(Parser.SERVER_TYPE_STRING, actual.getServerType()); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/CollectionParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/CollectionParserTest.java index c0ab2afe4..21a860746 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/CollectionParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/CollectionParserTest.java @@ -7,7 +7,7 @@ import com.ibm.guardium.mongodb.MongodbGuardiumFilter; import com.ibm.guardium.mongodb.TestMatchListener; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -51,7 +51,7 @@ public void test_createCollection() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -84,7 +84,7 @@ public void test_dropCollection() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -115,7 +115,7 @@ public void test_renameCollection() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/DatabaseParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/DatabaseParserTest.java index dc80325ff..fc936a9cc 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/DatabaseParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/DatabaseParserTest.java @@ -9,7 +9,7 @@ import com.ibm.guardium.mongodb.parsersbytype.BaseParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -41,7 +41,7 @@ public static String buildTestCaseMessage(String input) throws URISyntaxExceptio } - private void validateSessionDetails(JsonObject source, Record record) { + private void validateSessionDetails(JsonObject source, UCRecord record) { Assert.assertEquals("serverIp", source.get("local").getAsJsonObject().get("ip").getAsString(), record.getSessionLocator().getServerIp()); Assert.assertEquals("serverPort", source.get("local").getAsJsonObject().get("port").getAsInt(), record.getSessionLocator().getServerPort()); @@ -52,7 +52,7 @@ private void validateSessionDetails(JsonObject source, Record record) { } - private void validateAccessor(JsonObject source, Record record) { + private void validateAccessor(JsonObject source, UCRecord record) { Assert.assertEquals("user", source.get("users").getAsJsonArray().get(0).getAsJsonObject().get("user").getAsString(), record.getAccessor().getDbUser()); String dbName = source.get("param").getAsJsonObject().get("ns") !=null ? source.get("param").getAsJsonObject().get("ns").getAsString() : @@ -80,7 +80,7 @@ public void test_createDatabase() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -112,7 +112,7 @@ public void test_dropDatabase() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -144,7 +144,7 @@ public void testParseMongoSyslog_dropAllRolesOnDatabase() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/GeneralParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/GeneralParserTest.java index 007e747ea..bee1c0291 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/GeneralParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/GeneralParserTest.java @@ -8,10 +8,9 @@ import com.ibm.guardium.mongodb.TestMatchListener; import com.ibm.guardium.mongodb.parsersbytype.BaseParser; import com.ibm.guardium.mongodb.parsersbytype.IndexParser; -import com.ibm.guardium.mongodb.parsersbytype.ParserUtils; import com.ibm.guardium.universalconnector.commons.GuardConstants; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -43,7 +42,7 @@ public static String buildTestCaseMessage(String input) throws URISyntaxExceptio } - private void validateSessionDetails(JsonObject source, Record record) { + private void validateSessionDetails(JsonObject source, UCRecord record) { Assert.assertEquals("serverIp", source.get("local").getAsJsonObject().get("ip").getAsString(), record.getSessionLocator().getServerIp()); Assert.assertEquals("serverPort", source.get("local").getAsJsonObject().get("port").getAsInt(), record.getSessionLocator().getServerPort()); @@ -54,7 +53,7 @@ private void validateSessionDetails(JsonObject source, Record record) { } - private void validateAccessor(JsonObject source, Record record) { + private void validateAccessor(JsonObject source, UCRecord record) { String user = source.get("users")!=null && source.get("users").getAsJsonArray().size()>0 ? source.get("users").getAsJsonArray().get(0).getAsJsonObject().get("user").getAsString() : IndexParser.USER_NOT_AVAILABLE; @@ -81,7 +80,7 @@ public void test_applicationMessage() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/IndexParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/IndexParserTest.java index 06ffc640c..0494d738b 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/IndexParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/IndexParserTest.java @@ -10,7 +10,7 @@ import com.ibm.guardium.mongodb.parsersbytype.IndexParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -42,7 +42,7 @@ public static String buildTestCaseMessage(String input) throws URISyntaxExceptio } - private void validateSessionDetails(JsonObject source, Record record) { + private void validateSessionDetails(JsonObject source, UCRecord record) { Assert.assertEquals("serverIp", source.get("local").getAsJsonObject().get("ip").getAsString(), record.getSessionLocator().getServerIp()); Assert.assertEquals("serverPort", source.get("local").getAsJsonObject().get("port").getAsInt(), record.getSessionLocator().getServerPort()); @@ -53,7 +53,7 @@ private void validateSessionDetails(JsonObject source, Record record) { } - private void validateAccessor(JsonObject source, Record record) { + private void validateAccessor(JsonObject source, UCRecord record) { String user = source.get("users")!=null && source.get("users").getAsJsonArray().size()>0 ? source.get("users").getAsJsonArray().get(0).getAsJsonObject().get("user").getAsString() : IndexParser.USER_NOT_AVAILABLE; @@ -82,7 +82,7 @@ public void test_createIndex() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -116,7 +116,7 @@ public void test_createIndex2() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -150,7 +150,7 @@ public void test_dropIndex() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/LoginParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/LoginParserTest.java index ed4015318..989414984 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/LoginParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/LoginParserTest.java @@ -1,12 +1,9 @@ package com.ibm.guardium.mongodb.parsers; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.ibm.guardium.mongodb.parsersbytype.BaseParser; import com.ibm.guardium.mongodb.parsersbytype.LoginParser; import com.ibm.guardium.universalconnector.commons.structures.*; - import org.junit.Assert; import org.junit.Test; @@ -33,7 +30,7 @@ public void tesParseRecord() { JsonObject event = JsonParser.parseString(eventString).getAsJsonObject(); LoginParser parser = new LoginParser(); - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); Time time = record.getTime(); Accessor accessor = record.getAccessor(); SessionLocator locator = record.getSessionLocator(); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/ParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/ParserTest.java index c5c4c780c..2fdac93bf 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/ParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/ParserTest.java @@ -4,18 +4,17 @@ // package com.ibm.guardium.mongodb.parsers; -import java.text.ParseException; - import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ibm.guardium.mongodb.Parser; import com.ibm.guardium.mongodb.parsersbytype.AuthCheckParser; import com.ibm.guardium.universalconnector.commons.structures.*; - import org.junit.Assert; import org.junit.Test; +import java.text.ParseException; + public class ParserTest { Parser parser = new Parser(); @@ -201,7 +200,7 @@ public void testParseAsConstruct_Aggregate_graphLookup() { public void testParseRecord_createIndex() throws ParseException { final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-06-03T07:48:55.762-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 41112 }, \"users\" : [ { \"user\" : \"realAdmin\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"readWriteAnyDatabase\", \"db\" : \"admin\" }, { \"role\" : \"userAdminAnyDatabase\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"createIndexes\", \"ns\" : \"newDB01.newCollecti\", \"args\" : { \"createIndexes\" : \"newCollecti\", \"indexes\" : [ { \"key\" : { \"category\" : 1 }, \"name\" : \"testIDX1\" } ], \"lsid\" : { \"id\" : { \"$binary\" : \"T52tf2+yRbu31sZ5kq9R7Q==\", \"$type\" : \"04\" } }, \"$db\" : \"newDB01\" } }, \"result\" : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -215,7 +214,7 @@ public void testParseRecord_createCollection() throws ParseException { // skipping dedicated log messages "{ \"atype\" : \"createCollection\", \"ts\" : { \"$date\" : \"2020-05-11T06:24:38.168-0400\" } , \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 } , \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 48458 } , \"users\" : [], \"roles\" : [], \"param\" : { \"ns\" : \"test.collection3\" } , \"result\" : 0 }"; final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-06-03T03:40:30.888-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 40426 }, \"users\" : [ { \"user\" : \"realAdmin\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"readWriteAnyDatabase\", \"db\" : \"admin\" }, { \"role\" : \"userAdminAnyDatabase\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"create\", \"ns\" : \"newDB01.newCollection01\", \"args\" : { \"create\" : \"newCollection01\", \"lsid\" : { \"id\" : { \"$binary\" : \"CsTWBZwaQnOweCDDbiJWng==\", \"$type\" : \"04\" } }, \"$db\" : \"newDB01\" } }, \"result\" : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -228,7 +227,7 @@ public void testParseRecord_createCollection() throws ParseException { public void testParseICDMongoRecord_IPNotAvailable() throws ParseException { final String mongoString = "{ 'atype' : 'createCollection', 'ts' : { '$date' : '2022-12-15T06:19:23.284+00:00' }, 'users' : [ { 'user' : 'admin', 'db' : 'admin' } ], 'roles' : [ { 'role' : 'dbAdminAnyDatabase', 'db' : 'admin' }, { 'role' : 'readWriteAnyDatabase', 'db' : 'admin' }, { 'role' : 'userAdminAnyDatabase', 'db' : 'admin' } ], 'param' : { 'ns' : 'testdatabase.testcollection1' }, 'result' : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); SessionLocator sessionLocator = record.getSessionLocator(); Assert.assertEquals("", sessionLocator.getClientIp()); @@ -241,7 +240,7 @@ public void testParseICDMongoRecord_IPNotAvailable() throws ParseException { public void testParseICDMongoRecord_Unknown_error_log() throws ParseException { final String mongoString ="{ 'atype' : 'authenticate', 'ts' : { '$date' : '2022-12-16T08:47:36.788+00:00' }, 'local' : { 'ip' : '172.30.93.219', 'port' : 32298 }, 'remote' : { 'ip' : '172.30.28.157', 'port' : 45730 }, 'users' : [], 'roles' : [], 'param' : { 'user' : 'admin', 'db' : 'admin', 'mechanism' : 'SCRAM-SHA-256' }, 'result' : 20 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); ExceptionRecord exceptionRecord = record.getException(); Accessor accessor = record.getAccessor(); @@ -257,7 +256,7 @@ public void testParseRecord_createCollection_v4_4() throws ParseException { // skipping dedicated log messages "{ \"atype\" : \"createCollection\", \"ts\" : { \"$date\" : \"2020-05-11T06:24:38.168-0400\" } , \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 } , \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 48458 } , \"users\" : [], \"roles\" : [], \"param\" : { \"ns\" : \"test.collection3\" } , \"result\" : 0 }"; final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-08-30T07:22:46.361-04:00\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 49990 }, \"users\" : [ { \"user\" : \"admin\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"root\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"create\", \"ns\" : \"test.newCollection01tal\", \"args\" : { \"create\" : \"newCollection01tal\", \"lsid\" : { \"id\" : { \"$binary\" : \"nWP0p95qTgKYH2VwpukLcQ==\", \"$type\" : \"04\" } }, \"$db\" : \"test\" } }, \"result\" : 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); final Construct construct = record.getData().getConstruct(); final Sentence sentence = construct.sentences.get(0); @@ -282,7 +281,7 @@ public void testParseRecord_AuthorizationError() throws ParseException { final String mongoString = "{ \"atype\" : \"authCheck\", \"ts\" : { \"$date\" : \"2020-05-17T11:29:02.773-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 29360 }, \"users\" : [ { \"user\" : \"readerUser\", \"db\" : \"admin\" } ], \"roles\" : [ { \"role\" : \"read\", \"db\" : \"admin\" } ], \"param\" : { \"command\" : \"insert\", \"ns\" : \"admin.USERS\", \"args\" : { \"insert\" : \"USERS\", \"ordered\" : true, \"lsid\" : { \"id\" : { \"$binary\" : \"EQSjmxPcSxyNN6Vw7Wy1pQ==\", \"$type\" : \"04\" } }, \"$db\" : \"admin\", \"documents\" : [ { \"_id\" : { \"$oid\" : \"5ec1583e3a55d1ed961be47e\" }, \"uid\" : 2, \"name\" : \"Tal\" } ] } }, \"result\" : 13 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); - final Record record = Parser.parseRecord(mongoJson); + final UCRecord record = Parser.parseRecord(mongoJson); Assert.assertEquals( Parser.EXCEPTION_TYPE_AUTHORIZATION_STRING, @@ -300,7 +299,7 @@ public void testParseRecord_AuthenticationError() throws ParseException { final String mongoString = "{ \"atype\" : \"authenticate\", \"ts\" : { \"$date\" : \"2020-05-17T11:37:30.421-0400\" }, \"local\" : { \"ip\" : \"127.0.0.1\", \"port\" : 27017 }, \"remote\" : { \"ip\" : \"127.0.0.1\", \"port\" : 29398 }, \"users\" : [], \"roles\" : [], \"param\" : { \"user\" : \"readerUser\", \"db\" : \"admin\", \"mechanism\" : \"SCRAM-SHA-256\" }, \"result\" : 18 }"; final JsonObject mongoJson = JsonParser.parseString(mongoString).getAsJsonObject(); // final String actualResult = Parser.Parse(mongoJson); - final Record record = Parser.parseRecord(mongoJson); + final UCRecord record = Parser.parseRecord(mongoJson); Assert.assertEquals("readerUser", record.getAccessor().getDbUser().trim()); @@ -371,7 +370,7 @@ public void testRedactData_aggregate() { @Test public void testParseRecord() throws ParseException { - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); Assert.assertEquals("2WoIDPhSTcKHrdJW4azoow==", record.getSessionId()); Assert.assertEquals("test", record.getDbName()); Assert.assertEquals(Parser.UNKOWN_STRING, record.getAppUserName()); @@ -390,7 +389,7 @@ public void testParseData() { @Test public void testParseSessionLocator() throws ParseException { - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); SessionLocator actual = record.getSessionLocator(); Assert.assertEquals("127.0.0.1", actual.getServerIp()); @@ -405,7 +404,7 @@ public void testParseSessionLocator_IPv6() throws ParseException { final String mongoIPv6String = "{ \"atype\": \"authCheck\", \"ts\": { \"$date\": \"2020-01-26T09:58:44.547-0500\" }, \"local\": { \"ip\": \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\", \"port\": 27017 }, \"remote\": { \"ip\": \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\", \"port\": 56984 }, \"users\": [], \"roles\": [], \"param\": { \"command\": \"aggregate\", \"ns\": \"test.travelers\", \"args\": { \"aggregate\": \"travelers\", \"pipeline\": [ { \"$graphLookup\": { \"from\": \"airports\", \"startWith\": \"$nearestAirport\", \"connectFromField\": \"connects\", \"connectToField\": \"airport\", \"maxDepth\": 2, \"depthField\": \"numConnections\", \"as\": \"destinations\" } } ], \"cursor\": {}, \"lsid\": { \"id\": { \"$binary\": \"2WoIDPhSTcKHrdJW4azoow==\", \"$type\": \"04\" } }, \"$db\": \"test\" } }, \"result\": 0 }"; final JsonObject mongoJson = JsonParser.parseString(mongoIPv6String).getAsJsonObject(); - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); SessionLocator actual = record.getSessionLocator(); Assert.assertTrue("sessionLocator should mark that IPs are in IPv6", actual.isIpv6()); @@ -418,7 +417,7 @@ public void testParseSessionLocator_IPv6() throws ParseException { @Test public void testParseAccessor() throws ParseException { - Record record = Parser.parseRecord(mongoJson); + UCRecord record = Parser.parseRecord(mongoJson); Accessor actual = record.getAccessor(); Assert.assertEquals(Parser.DATA_PROTOCOL_STRING, actual.getDbProtocol()); Assert.assertEquals(Parser.SERVER_TYPE_STRING, actual.getServerType()); diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/RoleParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/RoleParserTest.java index e1ed69dd5..a6a387961 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/RoleParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/RoleParserTest.java @@ -9,9 +9,9 @@ import com.ibm.guardium.mongodb.TestMatchListener; import com.ibm.guardium.mongodb.parsersbytype.RoleParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -54,7 +54,7 @@ public void test_createRole_db() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -87,7 +87,7 @@ public void test_createRole_cluster() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -120,7 +120,7 @@ public void test_dropRole() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -148,7 +148,7 @@ public void test_revokeRole() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -178,7 +178,7 @@ public void updateRole() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -196,7 +196,7 @@ public void updateRole() throws Exception { } - private void validateRoles(JsonObject source, Record record, boolean isRequired){ + private void validateRoles(JsonObject source, UCRecord record, boolean isRequired){ ArrayList allSentences = record.getData().getConstruct().getSentences().get(0).getDescendants(); Sentence rolesSentence = null; for (Sentence sentence : allSentences) { @@ -225,7 +225,7 @@ private void validateRoles(JsonObject source, Record record, boolean isRequired) } } - private void validatePrivileges(Record record, String db, String collection, String type, Collection actions, boolean isRequired){ + private void validatePrivileges(UCRecord record, String db, String collection, String type, Collection actions, boolean isRequired){ ArrayList allSentences = record.getData().getConstruct().getSentences().get(0).getDescendants(); Sentence privilegesSentence = null; for (Sentence sentence : allSentences) { diff --git a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/UserParserTest.java b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/UserParserTest.java index 453f4018e..42e9ccdc6 100644 --- a/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/UserParserTest.java +++ b/filter-plugin/logstash-filter-mongodb-guardium/src/test/java/com/ibm/guardium/mongodb/parsers/UserParserTest.java @@ -7,12 +7,11 @@ import com.google.gson.JsonObject; import com.ibm.guardium.mongodb.MongodbGuardiumFilter; import com.ibm.guardium.mongodb.TestMatchListener; -import com.ibm.guardium.mongodb.parsersbytype.CollectionParser; import com.ibm.guardium.mongodb.parsersbytype.RoleParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ContextImpl; @@ -20,7 +19,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; public class UserParserTest { @@ -55,7 +57,7 @@ public void test_createUser() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -85,7 +87,7 @@ public void test_dropUser() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -113,7 +115,7 @@ public void test_updateUser() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -148,7 +150,7 @@ public void test_authenticate() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -176,7 +178,7 @@ public void test_revokeUserRole() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -206,7 +208,7 @@ public void test_grantUserRole() throws Exception { Assert.assertEquals(1, results.size()); String recordString = e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME).toString(); - Record record = (new Gson()).fromJson(recordString, Record.class); + UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); JsonObject source = (new Gson()).fromJson(inputMsg, JsonObject.class); Assert.assertNotNull(record); @@ -222,7 +224,7 @@ public void test_grantUserRole() throws Exception { validateRoles( source, record, true); } - private void validateRoles(JsonObject source, Record record, boolean isRequired){ + private void validateRoles(JsonObject source, UCRecord record, boolean isRequired){ ArrayList allSentences = record.getData().getConstruct().getSentences().get(0).getDescendants(); Sentence rolesSentence = null; for (Sentence sentence : allSentences) { diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/.gitignore b/filter-plugin/logstash-filter-mysql-azure-guardium/.gitignore new file mode 100644 index 000000000..6adc4ac32 --- /dev/null +++ b/filter-plugin/logstash-filter-mysql-azure-guardium/.gitignore @@ -0,0 +1,8 @@ +.gradle +.idea +.settings +bin +build +.classpath +.project +gradle.properties \ No newline at end of file diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/AzureMySQLOverAzureEventHub/guardium_logstash-offline-plugins-azure-mysql.zip b/filter-plugin/logstash-filter-mysql-azure-guardium/AzureMySQLOverAzureEventHub/guardium_logstash-offline-plugins-azure-mysql.zip index ba2da2659..e0693d598 100644 Binary files a/filter-plugin/logstash-filter-mysql-azure-guardium/AzureMySQLOverAzureEventHub/guardium_logstash-offline-plugins-azure-mysql.zip and b/filter-plugin/logstash-filter-mysql-azure-guardium/AzureMySQLOverAzureEventHub/guardium_logstash-offline-plugins-azure-mysql.zip differ diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/build.gradle b/filter-plugin/logstash-filter-mysql-azure-guardium/build.gradle index d9562de63..1f45fedce 100644 --- a/filter-plugin/logstash-filter-mysql-azure-guardium/build.gradle +++ b/filter-plugin/logstash-filter-mysql-azure-guardium/build.gradle @@ -20,8 +20,8 @@ pluginInfo.pluginClass = "AzureMysqlGuardiumFilter" pluginInfo.pluginName = "azure_mysql_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { @@ -33,7 +33,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -130,4 +130,4 @@ jacocoTestReport { }) } } -test.finalizedBy jacocoTestReport \ No newline at end of file +test.finalizedBy jacocoTestReport diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/gradlew b/filter-plugin/logstash-filter-mysql-azure-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilter.java b/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilter.java index 1cb9b9b23..768464006 100644 --- a/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilter.java +++ b/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilter.java @@ -4,25 +4,17 @@ */ package com.ibm.guardium.azuremysql; -import co.elastic.logstash.api.Configuration; -import co.elastic.logstash.api.Context; -import co.elastic.logstash.api.Event; -import co.elastic.logstash.api.Filter; -import co.elastic.logstash.api.FilterMatchListener; -import co.elastic.logstash.api.LogstashPlugin; -import co.elastic.logstash.api.PluginConfigSpec; -import com.google.gson.*; -import com.ibm.guardium.azuremysql.Parser; -import com.ibm.guardium.azuremysql.Constants; +import co.elastic.logstash.api.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.Record; - +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.LoggerContext; -import java.io.File; -import java.util.*; + +import java.util.Collection; +import java.util.Collections; /** * This class is used to convert log events into guardium object as per @@ -54,7 +46,7 @@ public Collection filter(Collection events, FilterMatchListener ma String messagevalue = event.getField("message").toString(); try { JsonObject inputJSON = new Gson().fromJson(messagevalue, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final Gson gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create(); event.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, gson.toJson(record)); matchListener.filterMatched(event); diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/Parser.java b/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/Parser.java index 81867d821..2435867e2 100644 --- a/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/Parser.java +++ b/filter-plugin/logstash-filter-mysql-azure-guardium/src/main/java/com/ibm/guardium/azuremysql/Parser.java @@ -4,29 +4,16 @@ */ package com.ibm.guardium.azuremysql; -import java.sql.Date; -import java.text.SimpleDateFormat; -import com.ibm.guardium.universalconnector.commons.Util; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Arrays; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import com.google.gson.Gson; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.ibm.guardium.azuremysql.Constants; +import com.ibm.guardium.universalconnector.commons.Util; import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.Record; -import co.elastic.logstash.api.Event; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; + public class Parser { private static Logger log = LogManager.getLogger(Parser.class); @@ -38,8 +25,8 @@ public class Parser { * @return * @throws Exception */ - public static Record parseRecord(final JsonObject data) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws Exception { + UCRecord record = new UCRecord(); try { JsonObject properties = data.get(Constants.PROPERTIES).getAsJsonObject(); record.setSessionId(getSessionId(data, properties)); @@ -113,7 +100,6 @@ public static String getSubscriptionID(JsonObject data) { * Method to get the server name from the JsonObject * * @param data - * @param Property * @return */ public static String getServerName(JsonObject data) { @@ -207,7 +193,7 @@ public static String getSessionId(JsonObject data, JsonObject Property) { * and then return the value as response * * @param data - * @param records + * @param Property * @return */ diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilterTest.java b/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilterTest.java index f4c198781..877e7f67d 100644 --- a/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilterTest.java +++ b/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/AzureMysqlGuardiumFilterTest.java @@ -4,24 +4,19 @@ */ package com.ibm.guardium.azuremysql; -import static org.junit.Assert.*; +import co.elastic.logstash.api.Context; +import co.elastic.logstash.api.Event; +import co.elastic.logstash.api.FilterMatchListener; +import com.ibm.guardium.universalconnector.commons.GuardConstants; +import org.junit.Test; +import org.logstash.plugins.ContextImpl; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; -import org.logstash.plugins.ContextImpl; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; - -import co.elastic.logstash.api.Context; -import co.elastic.logstash.api.Event; -import co.elastic.logstash.api.FilterMatchListener; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public class AzureMysqlGuardiumFilterTest { final static Context context = new ContextImpl(null, null); diff --git a/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/ParserTest.java b/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/ParserTest.java index 676429c1d..7ef712a47 100644 --- a/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/ParserTest.java +++ b/filter-plugin/logstash-filter-mysql-azure-guardium/src/test/java/com/ibm/guardium/azuremysql/ParserTest.java @@ -7,7 +7,7 @@ import static org.junit.Assert.*; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Test; public class ParserTest { @@ -15,7 +15,7 @@ public class ParserTest { public void testparseCreatetable() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"create table subratotable55(ID int, phone int)\",\"event_time\":\"2023-04-17T09:59:26Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("create table subratotable55(ID int, phone int)", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -24,7 +24,7 @@ public void testparseCreatetable() throws Exception { public void testparseInsert() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test[test] @ [20.204.110.141]\",\"sql_text\":\"insert into resourcetable(id) values(22)\",\"event_time\":\"2023-04-17T07:37:31Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("insert into resourcetable(id) values(22)", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -33,7 +33,7 @@ public void testparseInsert() throws Exception { public void testparseShowdatabase() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test[test] @ [20.204.110.141]\",\"sql_text\":\"show databases\",\"event_time\":\"2023-04-17T07:37:31Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("show databases", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -42,7 +42,7 @@ public void testparseShowdatabase() throws Exception { public void testparseShowtable() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test[test] @ [20.204.110.141]\",\"sql_text\":\"show tables\",\"event_time\":\"2023-04-17T07:37:31Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("show tables", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -51,7 +51,7 @@ public void testparseShowtable() throws Exception { public void testparseResourcetable() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test[test] @ [20.204.110.141]\",\"sql_text\":\"select * from resourcetable\",\"event_time\":\"2023-04-17T08:13:46Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("select * from resourcetable", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -60,7 +60,7 @@ public void testparseResourcetable() throws Exception { public void testparseincorrectusername() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from resourcetable\",\"event_time\":\"2023-04-17T08:13:46Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("test", record.getAccessor().getDbUser()); assertNotNull(record); } @@ -69,7 +69,7 @@ public void testparseincorrectusername() throws Exception { public void testparseAltertable() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"Alter table subratotable1 add (Name varchar(20))\",\"event_time\":\"2023-04-17T08:13:46Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("Alter table subratotable1 add (Name varchar(20))", record.getData().getOriginalSqlCommand()); assertEquals("20.204.110.141", record.getSessionLocator().getClientIp()); assertNotNull(record); @@ -79,7 +79,7 @@ public void testparseAltertable() throws Exception { public void testparseSelect() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subratotable\",\"event_time\":\"2023-04-17T07:37:47Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("select * from subratotable", record.getData().getOriginalSqlCommand()); assertEquals("1669962420", record.getSessionId()); assertNotNull(record); @@ -89,7 +89,7 @@ public void testparseSelect() throws Exception { public void testparseDroptable() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"drop table subratotable\",\"event_time\":\"2023-04-17T08:13:46Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("drop table subratotable", record.getData().getOriginalSqlCommand()); assertEquals("test", record.getAccessor().getDbUser()); assertNotNull(record); @@ -99,7 +99,7 @@ public void testparseDroptable() throws Exception { public void testparseComment() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select @@version_comment limit 1\",\"event_time\":\"2023-04-17T08:13:46Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("select @@version_comment limit 1", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -108,7 +108,7 @@ public void testparseComment() throws Exception { public void testparseDatabase() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"SELECT DATABASE()\",\"event_time\":\"2023-04-17T08:13:46Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("SELECT DATABASE()", record.getData().getOriginalSqlCommand()); assertNotNull(record); } @@ -117,7 +117,7 @@ public void testparseDatabase() throws Exception { public void testparseError() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); assertEquals("Error Occured (1146)", record.getException().getDescription()); assertNotNull(record); @@ -127,7 +127,7 @@ public void testparseError() throws Exception { public void testparseErrorWithoutErrorcode() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); assertEquals("Error Occured ()", record.getException().getDescription()); assertNotNull(record); @@ -137,7 +137,7 @@ public void testparseErrorWithoutErrorcode() throws Exception { public void testparseErrorWithoutSqltext() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); assertEquals("Error Occured (1146)", record.getException().getDescription()); assertEquals("", record.getException().getSqlString()); @@ -148,7 +148,7 @@ public void testparseErrorWithoutSqltext() throws Exception { public void testparseDBname() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from sub\",\"event_time\":\"2023-04-17T09:25:28Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8:MYSQL-TEST-GUARDIUM", record.getDbName()); assertNotNull(record); } @@ -157,7 +157,7 @@ public void testparseDBname() throws Exception { public void testparseServiceName() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8:MYSQL-TEST-GUARDIUM", record.getAccessor().getServiceName()); assertNotNull(record); } @@ -166,7 +166,7 @@ public void testparseServiceName() throws Exception { public void testparseDbuser() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("test", record.getAccessor().getDbUser()); assertNotNull(record); } @@ -175,7 +175,7 @@ public void testparseDbuser() throws Exception { public void testparseServerHostName() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8-MYSQL-TEST-GUARDIUM.azure.com", record.getAccessor().getServerHostName()); assertNotNull(record); @@ -185,7 +185,7 @@ public void testparseServerHostName() throws Exception { public void testparseDbprotocol() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("MYSQL", record.getAccessor().getDbProtocol()); assertEquals("MySql", record.getAccessor().getServerType()); assertNotNull(record); @@ -195,7 +195,7 @@ public void testparseDbprotocol() throws Exception { public void testparseDatatype() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("TEXT", record.getAccessor().getDataType()); assertEquals("MYSQL", record.getAccessor().getLanguage()); assertNotNull(record); @@ -205,7 +205,7 @@ public void testparseDatatype() throws Exception { public void testparseSessionid() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("1359540437", record.getSessionId()); assertNotNull(record); } @@ -214,7 +214,7 @@ public void testparseSessionid() throws Exception { public void testparsegetIP() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("20.219.48.223", record.getSessionLocator().getClientIp()); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); @@ -224,7 +224,7 @@ public void testparsegetIP() throws Exception { public void testparsegetIPV6() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("2001:0db8:85a3:0000:0000:8a2e:0370:7334", record.getSessionLocator().getClientIpv6()); assertEquals("0000:0000:0000:0000:0000:FFFF:0000:0000", record.getSessionLocator().getServerIpv6()); assertNotNull(record); @@ -234,7 +234,7 @@ public void testparsegetIPV6() throws Exception { public void testparsegetNoIP() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("0.0.0.0", record.getSessionLocator().getClientIp()); assertEquals("0.0.0.0", record.getSessionLocator().getServerIp()); assertNotNull(record); @@ -244,7 +244,7 @@ public void testparsegetNoIP() throws Exception { public void testparsegetPort() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"ERROR\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":1146,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"select * from subrato\",\"event_time\":\"2023-04-17T09:27:22Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals(-1, record.getSessionLocator().getClientPort()); assertEquals(-1, record.getSessionLocator().getServerPort()); assertNotNull(record); @@ -254,7 +254,7 @@ public void testparsegetPort() throws Exception { public void testparseTimestamp() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":21,\"ip\":\"20.204.110.141\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"show databases\",\"event_time\":\"2023-04-17T07:37:31Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals(Long.parseLong("1681717051000"), record.getTime().getTimstamp()); assertEquals(0, record.getTime().getMinDst()); assertEquals(0, record.getTime().getMinOffsetFromGMT()); @@ -265,7 +265,7 @@ public void testparseTimestamp() throws Exception { public void testparseConnect() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"replication_set_role\":\"single\",\"event_subclass\":\"CONNECT\",\"connection_id\":41,\"ip\":\"192.8.218.211\",\"host\":\"\",\"event_class\":\"connection_log\",\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"db\":\"\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8:MYSQL-TEST-GUARDIUM", record.getDbName()); assertEquals("CONNECT", record.getData().getOriginalSqlCommand()); assertNotNull(record); @@ -275,7 +275,7 @@ public void testparseConnect() throws Exception { public void testparsedbnameConnect() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"replication_set_role\":\"single\",\"event_subclass\":\"CONNECT\",\"connection_id\":41,\"ip\":\"192.8.218.211\",\"host\":\"\",\"event_class\":\"connection_log\",\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"db\":\"demodb\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8:MYSQL-TEST-GUARDIUM:demodb", record.getDbName()); assertEquals("CONNECT", record.getData().getOriginalSqlCommand()); assertNotNull(record); @@ -285,7 +285,7 @@ public void testparsedbnameConnect() throws Exception { public void testparsedbnameDisConnect() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"replication_set_role\":\"single\",\"event_subclass\":\"DISCONNECT\",\"connection_id\":41,\"ip\":\"192.8.218.211\",\"host\":\"\",\"event_class\":\"connection_log\",\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"db\":\"demodatabase\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals("DISCONNECT", record.getData().getOriginalSqlCommand()); assertEquals("083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8:MYSQL-TEST-GUARDIUM:demodatabase", record.getDbName()); assertNotNull(record); @@ -295,7 +295,7 @@ public void testparsedbnameDisConnect() throws Exception { public void testparseSessionLocatorIpv6() throws Exception { final String mysqlString = "{\"ServerType\":\"MySQL\",\"resourceId\":\"/SUBSCRIPTIONS/083DE1FB-CD2D-4B7C-895A-2B5AF1D091E8/RESOURCEGROUPS/NEWRESOURCEGUARDIUM/PROVIDERS/MICROSOFT.DBFORMYSQL/FLEXIBLESERVERS/MYSQL-TEST-GUARDIUM\",\"category\":\"MySqlAuditLogs\",\"properties\":{\"event_subclass\":\"LOG\",\"replication_set_role\":\"single\",\"thread_id\":27,\"ip\":\"20.219.48.223\",\"host\":\"\",\"event_class\":\"general_log\",\"error_code\":0,\"category\":\"MySqlAuditLogs\",\"user\":\"test\",\"sql_text\":\"SELECT DATABASE()\",\"event_time\":\"2023-04-17T09:25:41Z\"}}"; final JsonObject mysqlJson = JsonParser.parseString(mysqlString).getAsJsonObject(); - Record record = Parser.parseRecord(mysqlJson); + UCRecord record = Parser.parseRecord(mysqlJson); assertEquals(false, record.getSessionLocator().isIpv6()); assertNotNull(record); } diff --git a/filter-plugin/logstash-filter-mysql-guardium/build.gradle b/filter-plugin/logstash-filter-mysql-guardium/build.gradle index c48812e74..fb97cd4fa 100644 --- a/filter-plugin/logstash-filter-mysql-guardium/build.gradle +++ b/filter-plugin/logstash-filter-mysql-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "MySqlFilterGuardium" pluginInfo.pluginName = "mysql_filter_guardium" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-mysql-guardium/logstash-filter-mysql_filter_guardium.zip b/filter-plugin/logstash-filter-mysql-guardium/logstash-filter-mysql_filter_guardium.zip index 5f82fc2f6..56668b3d6 100644 Binary files a/filter-plugin/logstash-filter-mysql-guardium/logstash-filter-mysql_filter_guardium.zip and b/filter-plugin/logstash-filter-mysql-guardium/logstash-filter-mysql_filter_guardium.zip differ diff --git a/filter-plugin/logstash-filter-mysql-guardium/src/main/java/org/logstashplugins/MySqlFilterGuardium.java b/filter-plugin/logstash-filter-mysql-guardium/src/main/java/org/logstashplugins/MySqlFilterGuardium.java index 6b948ba9d..b07d30bac 100644 --- a/filter-plugin/logstash-filter-mysql-guardium/src/main/java/org/logstashplugins/MySqlFilterGuardium.java +++ b/filter-plugin/logstash-filter-mysql-guardium/src/main/java/org/logstashplugins/MySqlFilterGuardium.java @@ -125,7 +125,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (class_type.equals(CLASS_TYPE_CONNECTION) || class_type.equals(CLASS_TYPE_GENERAL)) { - Record record = new Record(); + UCRecord record = new UCRecord(); boolean validRecord = false; record.setDbName(UNKNOWN_STRING); @@ -204,7 +204,7 @@ public Collection filter(Collection events, FilterMatchListener ma return events; } - private void updateRecord(Event e, JsonObject inputJSON, Record record, String timestamp) throws ParseException { + private void updateRecord(Event e, JsonObject inputJSON, UCRecord record, String timestamp) throws ParseException { final int connection_id; if (inputJSON.has("connection_id") && !(inputJSON.get("connection_id").isJsonNull())) { connection_id = inputJSON.get("connection_id").getAsInt(); @@ -365,7 +365,7 @@ private static String logEvent(Event event) { } } - private void correctIPs(Event e, Record record) { + private void correctIPs(Event e, UCRecord record) { // Note: IP needs to be in ipv4/ipv6 format SessionLocator sessionLocator = record.getSessionLocator(); diff --git a/filter-plugin/logstash-filter-mysql-guardium/src/test/java/org/logstashplugins/MySqlFilterGuardiumTest.java b/filter-plugin/logstash-filter-mysql-guardium/src/test/java/org/logstashplugins/MySqlFilterGuardiumTest.java index 6534ce684..eb087f830 100644 --- a/filter-plugin/logstash-filter-mysql-guardium/src/test/java/org/logstashplugins/MySqlFilterGuardiumTest.java +++ b/filter-plugin/logstash-filter-mysql-guardium/src/test/java/org/logstashplugins/MySqlFilterGuardiumTest.java @@ -11,7 +11,7 @@ import co.elastic.logstash.api.Event; import co.elastic.logstash.api.FilterMatchListener; import com.google.gson.Gson; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.plugins.ConfigurationImpl; @@ -61,7 +61,7 @@ public void testParseExceptionNoUserMySqlSyslog() { Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); Assert.assertEquals(1, matchListener.getMatchCount()); - Record record = new Gson().fromJson((String)e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME), Record.class); + UCRecord record = new Gson().fromJson((String)e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME), UCRecord.class); Assert.assertEquals("NA", record.getAccessor().getDbUser()); } diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/.gitignore b/filter-plugin/logstash-filter-mysql-percona-guardium/.gitignore new file mode 100644 index 000000000..fc18ff6bf --- /dev/null +++ b/filter-plugin/logstash-filter-mysql-percona-guardium/.gitignore @@ -0,0 +1,4 @@ +.project +.settings +.gradle +.idea \ No newline at end of file diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/MysqlPerconaOverFilebeatPackage/MysqlPercona/logstash-filter-mysql_percona_filter.zip b/filter-plugin/logstash-filter-mysql-percona-guardium/MysqlPerconaOverFilebeatPackage/MysqlPercona/logstash-filter-mysql_percona_filter.zip index 93138c508..d173ce847 100644 Binary files a/filter-plugin/logstash-filter-mysql-percona-guardium/MysqlPerconaOverFilebeatPackage/MysqlPercona/logstash-filter-mysql_percona_filter.zip and b/filter-plugin/logstash-filter-mysql-percona-guardium/MysqlPerconaOverFilebeatPackage/MysqlPercona/logstash-filter-mysql_percona_filter.zip differ diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/build.gradle b/filter-plugin/logstash-filter-mysql-percona-guardium/build.gradle index 7a35e4560..06cba029d 100644 --- a/filter-plugin/logstash-filter-mysql-percona-guardium/build.gradle +++ b/filter-plugin/logstash-filter-mysql-percona-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "MySqlPerconaFilter" pluginInfo.pluginName = "mysql_percona_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/gradle.properties b/filter-plugin/logstash-filter-mysql-percona-guardium/gradle.properties index 3cc540249..804656748 100644 --- a/filter-plugin/logstash-filter-mysql-percona-guardium/gradle.properties +++ b/filter-plugin/logstash-filter-mysql-percona-guardium/gradle.properties @@ -1,4 +1,4 @@ LOGSTASH_CORE_PATH=C:/Guard/DSM/OferExample/logstash-master/logstash-core GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH=../../common/build/libs org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_201 -UC_ETC=C:/Guard/Git/universal-connector/logstash-filter-mysql-percona-guardium \ No newline at end of file +UC_ETC=C:/Guard/Git/universal-connector/logstash-filter-mysql-percona-guardium diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/gradlew b/filter-plugin/logstash-filter-mysql-percona-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/logstash-filter-mysql_percona_filter.zip b/filter-plugin/logstash-filter-mysql-percona-guardium/logstash-filter-mysql_percona_filter.zip index 93138c508..d173ce847 100644 Binary files a/filter-plugin/logstash-filter-mysql-percona-guardium/logstash-filter-mysql_percona_filter.zip and b/filter-plugin/logstash-filter-mysql-percona-guardium/logstash-filter-mysql_percona_filter.zip differ diff --git a/filter-plugin/logstash-filter-mysql-percona-guardium/src/main/java/com/ibm/guardium/mysql/percona/MySqlPerconaFilter.java b/filter-plugin/logstash-filter-mysql-percona-guardium/src/main/java/com/ibm/guardium/mysql/percona/MySqlPerconaFilter.java index 9b956e99d..199544d33 100755 --- a/filter-plugin/logstash-filter-mysql-percona-guardium/src/main/java/com/ibm/guardium/mysql/percona/MySqlPerconaFilter.java +++ b/filter-plugin/logstash-filter-mysql-percona-guardium/src/main/java/com/ibm/guardium/mysql/percona/MySqlPerconaFilter.java @@ -109,7 +109,7 @@ public Collection filter(Collection events, FilterMatchListener ma JsonObject messageJson = (JsonObject) JsonParser.parseString(mysqlMsgString); JsonObject audit_record = messageJson.get("audit_record").getAsJsonObject(); boolean validRecord = false; - Record record = new Record(); + UCRecord record = new UCRecord(); String status = getFieldAsString(audit_record, "status", "-1"); if ("0".equals(status)) { @@ -285,7 +285,7 @@ private static String logEvent(Event event){ } } - private void correctIPs(Event e, Record record) { + private void correctIPs(Event e, UCRecord record) { // Note: IP needs to be in ipv4/ipv6 format SessionLocator sessionLocator = record.getSessionLocator(); diff --git a/filter-plugin/logstash-filter-neo4j-guardium/.gitignore b/filter-plugin/logstash-filter-neo4j-guardium/.gitignore new file mode 100644 index 000000000..7775f8692 --- /dev/null +++ b/filter-plugin/logstash-filter-neo4j-guardium/.gitignore @@ -0,0 +1,7 @@ +.idea +.gradle +.settings +bin +.classpath +.project +gradle.properties diff --git a/filter-plugin/logstash-filter-neo4j-guardium/build.gradle b/filter-plugin/logstash-filter-neo4j-guardium/build.gradle index afedb8349..4e881dea5 100644 --- a/filter-plugin/logstash-filter-neo4j-guardium/build.gradle +++ b/filter-plugin/logstash-filter-neo4j-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginName = "neodb_guardium_filter" // must match the @Logstash // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-neo4j-guardium/gradlew b/filter-plugin/logstash-filter-neo4j-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/NeodbGuardiumFilter.java b/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/NeodbGuardiumFilter.java index ab596918a..22c0814b8 100644 --- a/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/NeodbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/NeodbGuardiumFilter.java @@ -18,7 +18,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -72,7 +72,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (isNotSystemGeneratedEvent(inputData)) { - Record record = Parser.parseRecord(inputData); + UCRecord record = Parser.parseRecord(inputData); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); diff --git a/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/Parser.java b/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/Parser.java index c7874a1b1..6f993b32c 100644 --- a/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/Parser.java +++ b/filter-plugin/logstash-filter-neo4j-guardium/src/main/java/com/ibm/guardium/neodb/Parser.java @@ -24,7 +24,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -43,8 +43,8 @@ public class Parser { static LinkedHashMap variables = null; static Character randomValue = 65; - public static Record parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); if (data != null) { @@ -86,7 +86,7 @@ public static Record parseRecord(final JsonObject data) throws ParseException { // ---------------------- Session Id ----------------------- - public static void parseSessionId(Record record) { + public static void parseSessionId(UCRecord record) { Integer hashCode = (record.getSessionLocator().getClientIp() + record.getSessionLocator().getClientPort() + record.getDbName()).hashCode(); diff --git a/filter-plugin/logstash-filter-neptune-aws-guardium/build.gradle b/filter-plugin/logstash-filter-neptune-aws-guardium/build.gradle index 1f0182677..8892f9e09 100644 --- a/filter-plugin/logstash-filter-neptune-aws-guardium/build.gradle +++ b/filter-plugin/logstash-filter-neptune-aws-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "NeptuneGuardiumFilter" pluginInfo.pluginName = "neptune_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } @@ -82,13 +82,13 @@ dependencies { implementation group: 'org.apache.tinkerpop', name: 'tinkergraph-gremlin', version: versions.dependencies.tinkergraphGremlin implementation group: 'org.eclipse.rdf4j', name: 'rdf4j-queryparser-sparql', version: versions.dependencies.rdf4jQueryparserSparql - implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "build/libs/logstash-core-*.*.*.jar") - implementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "guardium-universalconnector-commons-*.*.*.jar") + implementation fileTree(dir: LOGSTASH_CORE_PATH, include: "lib/jars/logstash-core.jar") + implementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "common-*.*.*.jar") testImplementation 'org.junit.jupiter:junit-jupiter:' + versions.dependencies.junitJupiter testImplementation 'org.jruby:jruby-complete:' + versions.dependencies.jrubyComplete - testImplementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "guardium-universalconnector-commons-*.*.*.jar") + testImplementation fileTree(dir: GUARDIUM_UNIVERSALCONNECTOR_COMMONS_PATH, include: "common-*.*.*.jar") } diff --git a/filter-plugin/logstash-filter-neptune-aws-guardium/gradlew b/filter-plugin/logstash-filter-neptune-aws-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-neptune-aws-guardium/logstash-filter-neptune_guardium_filter.zip b/filter-plugin/logstash-filter-neptune-aws-guardium/logstash-filter-neptune_guardium_filter.zip index 17bc06bde..6b14340c2 100644 Binary files a/filter-plugin/logstash-filter-neptune-aws-guardium/logstash-filter-neptune_guardium_filter.zip and b/filter-plugin/logstash-filter-neptune-aws-guardium/logstash-filter-neptune_guardium_filter.zip differ diff --git a/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/NeptuneGuardiumFilter.java b/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/NeptuneGuardiumFilter.java index ffa8123bc..7427bfe37 100644 --- a/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/NeptuneGuardiumFilter.java +++ b/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/NeptuneGuardiumFilter.java @@ -18,7 +18,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.neptune.connector.constant.ApplicationConstants; import co.elastic.logstash.api.Configuration; @@ -56,7 +56,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (log == null) { log = LogManager.getLogger(NeptuneGuardiumFilter.class); } - Record record = null; + UCRecord record = null; for (Event event : events) { if(log.isDebugEnabled()){ log.debug("Event Now: {}", event.getField(ApplicationConstants.MESSAGE)); @@ -67,7 +67,7 @@ public Collection filter(Collection events, FilterMatchListener ma || event.getField(ApplicationConstants.MESSAGE).toString() .contains(ApplicationConstants.QUERY_TYPE_SPARQL)) { - record = new Record(); + record = new UCRecord(); try { if (event.getField(ApplicationConstants.MESSAGE) instanceof String) { diff --git a/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/ParserHelper.java b/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/ParserHelper.java index f4263d8d1..50352b3f8 100644 --- a/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/ParserHelper.java +++ b/filter-plugin/logstash-filter-neptune-aws-guardium/src/main/java/com/ibm/neptune/connector/ParserHelper.java @@ -14,7 +14,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -25,18 +25,18 @@ public class ParserHelper { + private static final Logger LOG = LogManager.getLogger(ParserHelper.class); + /** * This method get the event data as input, overrides the properties which are * not in standard format. Creates the Guardium Object and returns it. * * @param event * @param record - * @return Record + * @return UCRecord * @throws Exception */ - private static final Logger LOG = LogManager.getLogger(ParserHelper.class); - - public static Record parseRecord(Event event, Record record) throws Exception { + public static UCRecord parseRecord(Event event, UCRecord record) throws Exception { String fullSQL = null; try { @@ -74,8 +74,8 @@ record = prepareGuardRecordData(event, record); record.getAccessor().setServiceName(record.getDbName()); - Integer serverPort = new Integer(record.getSessionLocator().getServerPort()); - Integer clientPort = new Integer(record.getSessionLocator().getClientPort()); + Integer serverPort = record.getSessionLocator().getServerPort(); + Integer clientPort = record.getSessionLocator().getClientPort(); Integer hashCode = (record.getSessionLocator().getServerIp() + record.getSessionLocator().getClientIp() + serverPort.toString() + clientPort.toString() + record.getDbName()).hashCode(); record.setSessionId(hashCode.toString()); @@ -92,11 +92,11 @@ record = prepareGuardRecordData(event, record); * It prepares the Accessor data and set it in the Guardium Object. It accepts * HttpHeaders as input and parses the information to get accessor data. * - * @param httpHeaders + * @param event * @param record * @return record */ - public static Accessor parseAccessor(Event event, Record record) throws Exception { + public static Accessor parseAccessor(Event event, UCRecord record) throws Exception { Accessor accessor = new Accessor(); @@ -159,12 +159,11 @@ public static Accessor parseAccessor(Event event, Record record) throws Exceptio /** * This methods prepares the SessionLocator Data for Guardium Object, which - * takes client and server infos and set it in the Record Object. + * takes client and server infos and set it in the UCRecord Object. * * @param client * @param server - * @param record - * @return Record + * @return UCRecord */ public static SessionLocator parseSessionLocator(final String client, final String server) throws Exception { SessionLocator sessionLocator = new SessionLocator(); @@ -238,14 +237,14 @@ public static SessionLocator parseSessionLocator(final String client, final Stri } /** - * It Prepares the Data object and set it in the Data part of Guardium Record + * It Prepares the Data object and set it in the Data part of Guardium UCRecord * Object. * - * @param payload + * @param event * @param record - * @return Record + * @return UCRecord */ - public static Data parseData(Event event, Record record) throws Exception { + public static Data parseData(Event event, UCRecord record) throws Exception { Data data = new Data(); Construct construct; try { @@ -258,7 +257,7 @@ public static Data parseData(Event event, Record record) throws Exception { return data; } - public static Construct parseConstruct(Event event, Record record) throws Exception { + public static Construct parseConstruct(Event event, UCRecord record) throws Exception { Construct construct = new Construct(); try { @@ -287,7 +286,7 @@ public static Construct parseConstruct(Event event, Record record) throws Except } - public static Sentence parseSentence(Event event, Record record) throws Exception { + public static Sentence parseSentence(Event event, UCRecord record) throws Exception { Sentence sentence = new Sentence(ApplicationConstants.VERB); Map> map = null; @@ -370,11 +369,10 @@ private static void parseSentenceObject(Sentence sentence, Map response = FILTER.filter(events, matchListener); - assertNotNull(event.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); assertEquals(1, response.size()); assertEquals(1, matchListener.getMatchCount()); diff --git a/filter-plugin/logstash-filter-neptune-aws-guardium/src/test/java/com/ibm/neptune/connector/ParserHelperTest.java b/filter-plugin/logstash-filter-neptune-aws-guardium/src/test/java/com/ibm/neptune/connector/ParserHelperTest.java index 3e8e8ee74..d53cc45ae 100644 --- a/filter-plugin/logstash-filter-neptune-aws-guardium/src/test/java/com/ibm/neptune/connector/ParserHelperTest.java +++ b/filter-plugin/logstash-filter-neptune-aws-guardium/src/test/java/com/ibm/neptune/connector/ParserHelperTest.java @@ -14,7 +14,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; import com.ibm.neptune.connector.constant.ApplicationConstantTest; @@ -23,11 +23,11 @@ public class ParserHelperTest { - private Record record; + private UCRecord record; @BeforeEach public void beforeEachTest() { - record = new Record(); + record = new UCRecord(); record.setDbName(ApplicationConstantTest.DBNAME_PREFIX.split(ApplicationConstantTest.DOT)[0]); } @@ -94,7 +94,7 @@ public void parseRecordTest1() throws Exception { ApplicationConstantTest.SERVER_HOSTNAME_PREFIX); event.setField(ApplicationConstantTest.DBNAME_PREFIX_KEY, ApplicationConstantTest.DBNAME_PREFIX); - Record actualResponse = ParserHelper.parseRecord(event, record); + UCRecord actualResponse = ParserHelper.parseRecord(event, record); assertNotNull(actualResponse); assertEquals(record.getDbName(), actualResponse.getAccessor().getServiceName()); @@ -127,7 +127,7 @@ public void parseRecordTest2() throws Exception { ApplicationConstantTest.SERVER_HOSTNAME_PREFIX); event.setField(ApplicationConstantTest.DBNAME_PREFIX_KEY, ApplicationConstantTest.DBNAME_PREFIX); - Record actualResponse = ParserHelper.parseRecord(event, record); + UCRecord actualResponse = ParserHelper.parseRecord(event, record); assertNotNull(actualResponse); assertEquals(record.getDbName(), actualResponse.getAccessor().getServiceName()); @@ -158,7 +158,7 @@ public void decodeContenTest() { public void prepareGuardRecordDataTest() { Event event = new org.logstash.Event(); - Record actual = null; + UCRecord actual = null; try { actual = ParserHelper.parseRecord(event, record); } catch (Exception e) { diff --git a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/build.gradle b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/build.gradle index 38a45322c..a33abec48 100644 --- a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/build.gradle @@ -22,10 +22,10 @@ pluginInfo.pluginClass = "GreenplumdbGuardiumFilter" pluginInfo.pluginName = "greenplumdb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -43,8 +43,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/gradlew b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/GreenplumdbGuardiumFilter.java b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/GreenplumdbGuardiumFilter.java index d1c134a61..486246126 100644 --- a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/GreenplumdbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/GreenplumdbGuardiumFilter.java @@ -15,7 +15,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -79,7 +79,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (LOGGER == null) { LOGGER = LogManager.getLogger(GreenplumdbGuardiumFilter.class); } - Record record = null; + UCRecord record = null; for (Event event : events) { if (event.getField(ApplicationConstant.MESSAGE) != null && (event.getField(ApplicationConstant.MESSAGE) .toString().contains(ApplicationConstant.POSTGRES) diff --git a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/Parser.java b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/Parser.java index 6d0ffad06..a46a428ae 100644 --- a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/Parser.java +++ b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/main/java/com/ibm/guardium/greenplumdb/Parser.java @@ -14,7 +14,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -37,9 +37,9 @@ public class Parser { * @return * @throws Exception */ - public static Record parseRecord(final Event event) throws Exception { + public static UCRecord parseRecord(final Event event) throws Exception { - final Record record = new Record(); + final UCRecord record = new UCRecord(); try { String fullSQl = event.getField(ApplicationConstant.QUERY) != null @@ -91,7 +91,7 @@ public static Record parseRecord(final Event event) throws Exception { * @param event * @return */ - private static String parseSessionID(final Record record, final Event event) { + private static String parseSessionID(final UCRecord record, final Event event) { final String processID = event.getField(ApplicationConstant.PROCESS_ID) != null ? event.getField(ApplicationConstant.PROCESS_ID).toString() @@ -174,7 +174,7 @@ private static String parseQuery(final Event event) throws Exception { * @return * @throws Exception */ - public static Accessor parseAccessor(final Event event, final Record record) throws Exception { + public static Accessor parseAccessor(final Event event, final UCRecord record) throws Exception { Accessor accessor = new Accessor(); try { diff --git a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/test/java/com/ibm/guardium/greenplumdb/ParserTest.java b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/test/java/com/ibm/guardium/greenplumdb/ParserTest.java index 0fb1ba786..645979002 100644 --- a/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/test/java/com/ibm/guardium/greenplumdb/ParserTest.java +++ b/filter-plugin/logstash-filter-onPremGreenplumdb-guardium/src/test/java/com/ibm/guardium/greenplumdb/ParserTest.java @@ -13,7 +13,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -44,7 +44,7 @@ public void parserRecordTest1() throws Exception { event.setField(ApplicationConstantTest.QUERY, "DELETE FROM products5 where prod_id = 10;"); event.setField(ApplicationConstantTest.SERVER_HOSTNAME, "ip-172-31-7-158.ap-south-1.compute.internal"); event.setField(ApplicationConstant.EVENT_SEVERITY, "LOG"); - Record actualResponse = Parser.parseRecord(event); + UCRecord actualResponse = Parser.parseRecord(event); assertNotNull(actualResponse); assertNotNull(actualResponse.getTime()); assertNotNull(actualResponse.getSessionLocator()); @@ -63,7 +63,7 @@ public void parseRecordTest2() throws Exception { event.setField(ApplicationConstantTest.QUERY, "DELETE FROM products5 where prod_id = 10;"); event.setField(ApplicationConstantTest.SERVER_HOSTNAME, "ip-172-31-7-158.ap-south-1.compute.internal"); event.setField(ApplicationConstant.EVENT_SEVERITY, "LOG"); - Record record = Parser.parseRecord(event); + UCRecord record = Parser.parseRecord(event); assertNotNull(record); assertEquals(ApplicationConstant.EMPTY, record.getDbName()); } @@ -84,7 +84,7 @@ public void parseTimeTest() throws Exception { @Test public void parseAccessorTest() throws Exception { Event event = new org.logstash.Event(); - Record record = new Record(); + UCRecord record = new UCRecord(); record.setDbName("test1"); Accessor actual = Parser.parseAccessor(event, record); assertNotNull(actual); diff --git a/filter-plugin/logstash-filter-oua-guardium/build.gradle b/filter-plugin/logstash-filter-oua-guardium/build.gradle index 3051b47dd..4c7a1bab9 100644 --- a/filter-plugin/logstash-filter-oua-guardium/build.gradle +++ b/filter-plugin/logstash-filter-oua-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginClass = "OuaFilter" pluginInfo.pluginName = "oua_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.0" + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -179,4 +179,4 @@ jacocoTestCoverageVerification { })) } } -project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) \ No newline at end of file +project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) diff --git a/filter-plugin/logstash-filter-oua-guardium/src/main/java/com/ibm/guardium/OuaFilter.java b/filter-plugin/logstash-filter-oua-guardium/src/main/java/com/ibm/guardium/OuaFilter.java index e14a4eb69..0354ad265 100644 --- a/filter-plugin/logstash-filter-oua-guardium/src/main/java/com/ibm/guardium/OuaFilter.java +++ b/filter-plugin/logstash-filter-oua-guardium/src/main/java/com/ibm/guardium/OuaFilter.java @@ -102,7 +102,7 @@ public Collection filter(Collection events, FilterMatchListener ma } if (return_code == 0 || !OuaFilter.isLoginFailedReturnCode(return_code)) { - Record record = OuaFilter.parseRecord(e); + UCRecord record = OuaFilter.parseRecord(e); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); @@ -110,7 +110,7 @@ public Collection filter(Collection events, FilterMatchListener ma e.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, gson.toJson(record)); if (log.isDebugEnabled()) { - log.debug("Record Event: "+logEvent(e)); + log.debug("UCRecord Event: "+logEvent(e)); } matchListener.filterMatched(e); // Flag OK for filter input/parsing/out outputEvents.add(e); @@ -118,7 +118,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (return_code != 0) { Event exception_event = e.clone(); - Record exception_record = OuaFilter.parseExceptionRecord(exception_event); + UCRecord exception_record = OuaFilter.parseExceptionRecord(exception_event); final GsonBuilder exception_builder = new GsonBuilder(); exception_builder.serializeNulls(); @@ -126,7 +126,7 @@ public Collection filter(Collection events, FilterMatchListener ma exception_event.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, exception_gson.toJson(exception_record)); if (log.isDebugEnabled()) { - log.debug("Record Event: "+logEvent(exception_event)); + log.debug("UCRecord Event: "+logEvent(exception_event)); } matchListener.filterMatched(exception_event); // Flag OK for filter input/parsing/out outputEvents.add(exception_event); @@ -143,8 +143,8 @@ public Collection filter(Collection events, FilterMatchListener ma return outputEvents; } - public static Record parseRecord(final Event event) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final Event event) throws ParseException { + UCRecord record = new UCRecord(); if (event.getField(OuaFilter.DB_NAME_TAG) instanceof String) { record.setDbName(event.getField(OuaFilter.DB_NAME_TAG).toString()); @@ -168,8 +168,8 @@ public static Record parseRecord(final Event event) throws ParseException { return record; } - public static Record parseExceptionRecord(final Event event) throws ParseException { - Record record = new Record(); + public static UCRecord parseExceptionRecord(final Event event) throws ParseException { + UCRecord record = new UCRecord(); if (event.getField(OuaFilter.DB_NAME_TAG) instanceof String) { record.setDbName(event.getField(OuaFilter.DB_NAME_TAG).toString()); diff --git a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/IcdPostgresOverKafkaEvent/guardium_logstash-offline-plugin-icd-postgresql.zip b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/IcdPostgresOverKafkaEvent/guardium_logstash-offline-plugin-icd-postgresql.zip index 439b31720..60098fe4c 100644 Binary files a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/IcdPostgresOverKafkaEvent/guardium_logstash-offline-plugin-icd-postgresql.zip and b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/IcdPostgresOverKafkaEvent/guardium_logstash-offline-plugin-icd-postgresql.zip differ diff --git a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/build.gradle b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/build.gradle index f91e321d3..44f061d88 100644 --- a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/build.gradle +++ b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/build.gradle @@ -22,8 +22,8 @@ pluginInfo.pluginType = "filter" pluginInfo.pluginClass = "ICDPostgresqlGuardiumFilter" pluginInfo.pluginName = "icd_postgresql_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { mavenCentral() @@ -34,7 +34,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -160,4 +160,4 @@ jacocoTestReport { }) } } -test.finalizedBy jacocoTestReport \ No newline at end of file +test.finalizedBy jacocoTestReport diff --git a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/gradlew b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/ICDPostgresqlGuardiumFilter.java b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/ICDPostgresqlGuardiumFilter.java index b0b629012..53d77a7a3 100644 --- a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/ICDPostgresqlGuardiumFilter.java +++ b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/ICDPostgresqlGuardiumFilter.java @@ -14,7 +14,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -58,7 +58,7 @@ public Collection filter(Collection events, FilterMatchListener ma if (isMultilineEvent(event)) { multilineEventParser.prepareEventForMultiLineLogs(event); } - Record rec = Parser.parseRecord(event); + UCRecord rec = Parser.parseRecord(event); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/Parser.java b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/Parser.java index 5aa749346..52f679e89 100644 --- a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/Parser.java +++ b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/main/java/com/ibm/guardium/icd/postgresql/Parser.java @@ -23,7 +23,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; import co.elastic.logstash.api.Event; @@ -33,15 +33,15 @@ public class Parser { private static Logger log = LogManager.getLogger(Parser.class); /*** - * Parses logs and returns a Guard Record object + * Parses logs and returns a Guard UCRecord object * * @param event * @return * @throws Exception * @throws ParseException */ - public static Record parseRecord(Event event) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(Event event) throws Exception { + UCRecord record = new UCRecord(); try { record.setAppUserName(event.getField(ApplicationConstant.USER_NAME) != null ? event.getField(ApplicationConstant.USER_NAME).toString() diff --git a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/test/java/com/ibm/guardium/icd/postgresql/ParserTest.java b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/test/java/com/ibm/guardium/icd/postgresql/ParserTest.java index e808908b9..ee2fd0978 100644 --- a/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/test/java/com/ibm/guardium/icd/postgresql/ParserTest.java +++ b/filter-plugin/logstash-filter-postgres-ibmcloud-guardium/src/test/java/com/ibm/guardium/icd/postgresql/ParserTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; import com.ibm.guardium.icd.postgresql.Parser; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Event; @@ -27,7 +27,7 @@ public void testParseRecord() throws Exception { e.setField("clientIP", "172.30.216.75"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); e.setField("sqlquery", "\\\"create table sst20_report(Roll_No int,Name varchar(20),Marks int);\\\""); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("admin", record.getAppUserName()); assertEquals("2212c4a700f44505a917e8fcb952c4ce:f90dcc7d-68aa-4c85-8740-21929b237bfc:ibmclouddb", @@ -46,7 +46,7 @@ public void testParsesql() throws Exception { e.setField("clientIP", "172.30.216.75"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); e.setField("sqlquery", "\\\"create table sst20_report(Roll_No int,Name varchar(20),Marks int);\\\""); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("create table sst20_report(Roll_No int,Name varchar(20),Marks int);", record.getData().getOriginalSqlCommand()); @@ -63,7 +63,7 @@ public void testParseNouser() throws Exception { e.setField("clientIP", "172.30.216.75"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); e.setField("sqlquery", "\\\"create table sst20_report(Roll_No int,Name varchar(20),Marks int);\\\""); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("", record.getAccessor().getDbUser()); } @@ -81,7 +81,7 @@ public void testParsenoSQLError() throws Exception { e.setField("statement", "STATEMENT"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); e.setField("ID1", "48p01"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("48p01", record.getException().getDescription()); assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); @@ -101,7 +101,7 @@ public void testParseSQLError() throws Exception { e.setField("statement", "STATEMENT"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); e.setField("ID1", "48p01"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("48p01", record.getException().getDescription()); assertEquals("SQL_ERROR", record.getException().getExceptionTypeId()); @@ -119,7 +119,7 @@ public void testParsenull() throws Exception { e.setField("clientIP", null); e.setField("sqlquery", "drop table sst_report;"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("NA", record.getAccessor().getDbUser()); assertEquals("", record.getAccessor().getServerHostName()); @@ -137,7 +137,7 @@ public void testParsothertime() throws Exception { e.setField("clientIP", "172.30.216.75"); e.setField("detail", ":f90dcc7d-68aa-4c85-8740-21929b237bfc"); e.setField("sqlquery", "\\\"create table sst20_report(Roll_No int,Name varchar(20),Marks int);\\\""); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("create table sst20_report(Roll_No int,Name varchar(20),Marks int);", record.getData().getOriginalSqlCommand()); diff --git a/filter-plugin/logstash-filter-progressdb-guardium/.gitignore b/filter-plugin/logstash-filter-progressdb-guardium/.gitignore new file mode 100644 index 000000000..cd051d0d6 --- /dev/null +++ b/filter-plugin/logstash-filter-progressdb-guardium/.gitignore @@ -0,0 +1,6 @@ +build +.idea +.settings +bin +gradle.properties +lib \ No newline at end of file diff --git a/filter-plugin/logstash-filter-progressdb-guardium/Gemfile b/filter-plugin/logstash-filter-progressdb-guardium/Gemfile deleted file mode 100644 index ea0d321ef..000000000 --- a/filter-plugin/logstash-filter-progressdb-guardium/Gemfile +++ /dev/null @@ -1,12 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -source 'https://rubygems.org' - -gemspec - -logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash" -use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1" - -if Dir.exist?(logstash_path) && use_logstash_source - gem 'logstash-core', :path => "#{logstash_path}/logstash-core" - gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api" -end diff --git a/filter-plugin/logstash-filter-progressdb-guardium/ProgressOverJdbcPackage/logstash-filter-progress_guardium_plugin_filter.zip b/filter-plugin/logstash-filter-progressdb-guardium/ProgressOverJdbcPackage/logstash-filter-progress_guardium_plugin_filter.zip index e69de29bb..c010a9ba3 100644 Binary files a/filter-plugin/logstash-filter-progressdb-guardium/ProgressOverJdbcPackage/logstash-filter-progress_guardium_plugin_filter.zip and b/filter-plugin/logstash-filter-progressdb-guardium/ProgressOverJdbcPackage/logstash-filter-progress_guardium_plugin_filter.zip differ diff --git a/filter-plugin/logstash-filter-progressdb-guardium/build.gradle b/filter-plugin/logstash-filter-progressdb-guardium/build.gradle index 569b1af9f..09c910006 100644 --- a/filter-plugin/logstash-filter-progressdb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-progressdb-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "ProgressGuardiumPluginFilter" pluginInfo.pluginName = "progress_guardium_plugin_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-progressdb-guardium/lib/logstash-filter-progress_guardium_plugin_filter_jars.rb b/filter-plugin/logstash-filter-progressdb-guardium/lib/logstash-filter-progress_guardium_plugin_filter_jars.rb deleted file mode 100644 index ecc28a7a3..000000000 --- a/filter-plugin/logstash-filter-progressdb-guardium/lib/logstash-filter-progress_guardium_plugin_filter_jars.rb +++ /dev/null @@ -1,5 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 - -require 'jar_dependencies' -require_jar('com.ibm.guardium.progress', 'logstash-filter-progress_guardium_plugin_filter', '1.0.1') diff --git a/filter-plugin/logstash-filter-progressdb-guardium/lib/logstash/filters/progress_guardium_plugin_filter.rb b/filter-plugin/logstash-filter-progressdb-guardium/lib/logstash/filters/progress_guardium_plugin_filter.rb deleted file mode 100644 index 84f92983a..000000000 --- a/filter-plugin/logstash-filter-progressdb-guardium/lib/logstash/filters/progress_guardium_plugin_filter.rb +++ /dev/null @@ -1,12 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 -require "logstash/filters/base" -require "logstash/namespace" -require "logstash-filter-progress_guardium_plugin_filter_jars" -require "java" - -class LogStash::Filters::ProgressGuardiumPluginFilter < LogStash::Filters::Base - config_name "progress_guardium_plugin_filter" - - def self.javaClass() Java::com.ibm.guardium.progress.ProgressGuardiumPluginFilter.java_class; end -end diff --git a/filter-plugin/logstash-filter-progressdb-guardium/logstash-filter-progress_guardium_plugin_filter.gemspec b/filter-plugin/logstash-filter-progressdb-guardium/logstash-filter-progress_guardium_plugin_filter.gemspec deleted file mode 100644 index a574a9003..000000000 --- a/filter-plugin/logstash-filter-progressdb-guardium/logstash-filter-progress_guardium_plugin_filter.gemspec +++ /dev/null @@ -1,22 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -Gem::Specification.new do |s| - s.name = 'logstash-filter-progress_guardium_plugin_filter' - s.version = ::File.read('VERSION').split('\n').first - s.licenses = ['Apache-2.0'] - s.summary = 'progress-Guardium filter plugin' - s.description = 'This gem is a Logstash saphana filter plugin required to be installed as part of IBM Security Guardium, Guardium Universal connector configuration. This gem is not a stand-alone program.' - s.authors = ['IBM'] - s.email = [''] - s.homepage = 'http://www.elastic.co/guide/en/logstash/current/index.html' - s.require_paths = ['lib', 'vendor/jar-dependencies'] - - s.files = Dir["lib/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"] - - # Special flag to let us know this is actually a logstash plugin - s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'filter', 'java_plugin' => 'true'} - - # Gem dependencies - s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99" - s.add_runtime_dependency 'jar-dependencies' - s.add_development_dependency 'logstash-devutils' -end diff --git a/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/Parser.java b/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/Parser.java index 49c4cd2c4..3c0f3c440 100644 --- a/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/Parser.java +++ b/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/Parser.java @@ -20,8 +20,8 @@ public class Parser { private static final Logger log = LogManager.getLogger(Parser.class); - public static Record parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final JsonObject data) throws ParseException { + UCRecord record = new UCRecord(); if (data != null) { //database name diff --git a/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/ProgressGuardiumPluginFilter.java b/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/ProgressGuardiumPluginFilter.java index aafc23cb5..1c069489a 100644 --- a/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/ProgressGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-progressdb-guardium/src/main/java/com/ibm/guardium/progress/ProgressGuardiumPluginFilter.java @@ -16,7 +16,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; @@ -69,7 +69,7 @@ public Collection filter(Collection events, FilterMatchListener ma try { JsonObject inputData = inputData(e); - Record record = Parser.parseRecord(inputData); + UCRecord record = Parser.parseRecord(inputData); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); diff --git a/filter-plugin/logstash-filter-progressdb-guardium/src/test/java/com/ibm/guardium/progress/ParserTest.java b/filter-plugin/logstash-filter-progressdb-guardium/src/test/java/com/ibm/guardium/progress/ParserTest.java index 66add037e..57f71c9b1 100644 --- a/filter-plugin/logstash-filter-progressdb-guardium/src/test/java/com/ibm/guardium/progress/ParserTest.java +++ b/filter-plugin/logstash-filter-progressdb-guardium/src/test/java/com/ibm/guardium/progress/ParserTest.java @@ -36,7 +36,7 @@ public void testParseRecord() throws ParseException { data.addProperty(Constants.EVENT_CONTEXT, "PUB._fileSTUDENTPUB"); - final Record record = Parser.parseRecord(data); + final UCRecord record = Parser.parseRecord(data); assertEquals("Demo", record.getDbName()); assertEquals("t+3ZR8SvMLygFMida3OP4w", record.getSessionId()); @@ -61,7 +61,7 @@ public void testParseAccessor() throws ParseException { data.addProperty(Constants.EVENT_CONTEXT, "PUB._Field4273_Db-guid"); - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); Accessor actual = record.getAccessor(); assertEquals(Constants.DB_PROTOCOL, actual.getDbProtocol()); @@ -90,7 +90,7 @@ public void testParseSessionLocator() throws ParseException { data.addProperty(Constants.CLIENT_IP, "0.0.0.0"); data.addProperty(Constants.SERVER_IP, "0.0.0.0"); - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); SessionLocator session = record.getSessionLocator(); assertEquals(-1, session.getClientPort()); diff --git a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/build.gradle b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/build.gradle index 6bead5ce7..251c27e3f 100644 --- a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/build.gradle +++ b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/build.gradle @@ -21,10 +21,10 @@ pluginInfo.pluginClass = "ApacheSolrGcpConnector" pluginInfo.pluginName = "apache_solr_gcp_connector" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -42,8 +42,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/gradlew b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrGcpConnector.java b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrGcpConnector.java index 47bf70548..f910b2f66 100644 --- a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrGcpConnector.java +++ b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/ApacheSolrGcpConnector.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ package com.ibm.guardium.apachesolrdb; @@ -17,7 +17,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -77,7 +77,7 @@ public Collection filter(Collection events, FilterMatchListener ma } try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseQtpRecord(inputJSON); + UCRecord record = Parser.parseQtpRecord(inputJSON); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java index a4a97e2e7..0a79c52ed 100644 --- a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java +++ b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/main/java/com/ibm/guardium/apachesolrdb/Parser.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ package com.ibm.guardium.apachesolrdb; @@ -26,7 +26,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -47,14 +47,14 @@ public class Parser { /** * this method parse solr qtp logs ,converts into jsonObject data and extracts - * required fields from it and sets into Record object. + * required fields from it and sets into UCRecord object. * * @param JsonObject data * @return record * @throws Exception */ - public static Record parseQtpRecord(JsonObject data) throws Exception { - Record record = new Record(); + public static UCRecord parseQtpRecord(JsonObject data) throws Exception { + UCRecord record = new UCRecord(); try { Map map = new HashMap<>(); getCommonDetails(data, map, ApplicationConstant.lOG_TYPE); diff --git a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java index cbec290c0..4694ce654 100644 --- a/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java +++ b/filter-plugin/logstash-filter-pubsub-apachesolr-guardium/src/test/java/com/ibm/guardium/apachesolrdb/ParserTest.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ package com.ibm.guardium.apachesolrdb; @@ -13,7 +13,7 @@ import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -32,7 +32,7 @@ public void testParseTimestamp() throws Exception { public void testParseQtpConstruct_update() throws Exception { final String solrString = "{\"insertId\":\"epzzqmg1c6000v\",\"jsonPayload\":{\"message\":\"2022-02-10 12:42:05.050 INFO (qtp672313607-16) [ x:first_core] o.a.s.u.p.LogUpdateProcessorFactory [first_core] webapp=\\/solr path=\\/update params={commitWithin=1000&overwrite=true&wt=json&_=1644496890256}{add=[7698 (1724380007675985920)]} 0 6\"},\"resource\":{\"type\":\"gce_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"zone\":\"asia-south2-a\",\"instance_id\":\"2639899388249855782\"}},\"timestamp\":\"2022-02-10T12:42:05.050746475Z\",\"logName\":\"projects\\/project-sccd\\/logs\\/files\",\"receiveTimestamp\":\"2022-02-10T12:42:05.438339552Z\"}"; final JsonObject solrJson = JsonParser.parseString(solrString).getAsJsonObject(); - Record record = Parser.parseQtpRecord(solrJson); + UCRecord record = Parser.parseQtpRecord(solrJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); Assert.assertNotNull(sentence); Assert.assertNotNull(record); @@ -45,7 +45,7 @@ public void testParseQtpConstruct_update() throws Exception { public void testParseQtpConstruct_Find() throws Exception { final String solrString = "{\"insertId\":\"epzzqmg1c6dwlg\",\"jsonPayload\":{\"message\":\"2022-02-10 12:44:20.243 INFO (qtp672313607-18) [ x:first_core] o.a.s.c.S.Request [first_core] webapp=\\/solr path=\\/select params={q=id:7698&_=1644497065596} hits=1 status=0 QTime=1\"},\"resource\":{\"type\":\"gce_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"instance_id\":\"2639899388249855782\",\"zone\":\"asia-south2-a\"}},\"timestamp\":\"2022-02-10T12:44:20.244030006Z\",\"logName\":\"projects\\/project-sccd\\/logs\\/files\",\"receiveTimestamp\":\"2022-02-10T12:44:20.439608402Z\"}"; final JsonObject solrJson = JsonParser.parseString(solrString).getAsJsonObject(); - Record record = Parser.parseQtpRecord(solrJson); + UCRecord record = Parser.parseQtpRecord(solrJson); final Sentence sentence = record.getData().getConstruct().getSentences().get(0); Assert.assertNotNull(sentence); Assert.assertEquals("select", sentence.getVerb()); @@ -57,7 +57,7 @@ public void testParseQtpConstruct_Find() throws Exception { public void testParseAccessor() throws Exception { final String solrString = "{\"insertId\":\"epzzqmg1c6dwlg\",\"jsonPayload\":{\"message\":\"2022-02-10 12:44:20.243 INFO (qtp672313607-18) [ x:first_core] o.a.s.c.S.Request [first_core] webapp=\\/solr path=\\/select params={q=id:7698&_=1644497065596} hits=1 status=0 QTime=1\"},\"resource\":{\"type\":\"gce_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"instance_id\":\"2639899388249855782\",\"zone\":\"asia-south2-a\"}},\"timestamp\":\"2022-02-10T12:44:20.244030006Z\",\"logName\":\"projects\\/project-sccd\\/logs\\/files\",\"receiveTimestamp\":\"2022-02-10T12:44:20.439608402Z\"}"; final JsonObject solrJson = JsonParser.parseString(solrString).getAsJsonObject(); - Record record = Parser.parseQtpRecord(solrJson); + UCRecord record = Parser.parseQtpRecord(solrJson); final Accessor accessor = record.getAccessor(); Assert.assertNotNull(accessor); Assert.assertEquals("ApacheSolrGCP", accessor.getDbProtocol().toString()); @@ -71,7 +71,7 @@ public void testParseAccessor() throws Exception { public void testParseSessionLocator() throws Exception { final String solrString = "{\"insertId\":\"epzzqmg1c6dwlg\",\"jsonPayload\":{\"message\":\"2022-02-10 12:44:20.243 INFO (qtp672313607-18) [ x:first_core] o.a.s.c.S.Request [first_core] webapp=\\/solr path=\\/select params={q=id:7698&_=1644497065596} hits=1 status=0 QTime=1\"},\"resource\":{\"type\":\"gce_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"instance_id\":\"2639899388249855782\",\"zone\":\"asia-south2-a\"}},\"timestamp\":\"2022-02-10T12:44:20.244030006Z\",\"logName\":\"projects\\/project-sccd\\/logs\\/files\",\"receiveTimestamp\":\"2022-02-10T12:44:20.439608402Z\"}"; final JsonObject solrJson = JsonParser.parseString(solrString).getAsJsonObject(); - Record record = Parser.parseQtpRecord(solrJson); + UCRecord record = Parser.parseQtpRecord(solrJson); final SessionLocator sessionLocator = record.getSessionLocator(); Assert.assertNotNull(sessionLocator); Assert.assertEquals("0.0.0.0", sessionLocator.getClientIp().toString()); @@ -84,7 +84,7 @@ public void testParseSessionLocator() throws Exception { public void testParseException() throws Exception { final String solrString = "{\"insertId\":\"17u90yhf9nmdte\",\"jsonPayload\":{\"message\":\"2022-02-10 14:04:38.542 ERROR (qtp672313607-17) [ x:first_core] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: Cannot parse provided JSON: Unexpected EOF: char=(EOF),position=20 AFTER=''\"},\"resource\":{\"type\":\"gce_instance\",\"labels\":{\"instance_id\":\"2639899388249855782\",\"zone\":\"asia-south2-a\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-02-10T14:04:38.543314031Z\",\"logName\":\"projects\\/project-sccd\\/logs\\/files\",\"receiveTimestamp\":\"2022-02-10T14:04:39.447195015Z\"}"; final JsonObject solrJson = JsonParser.parseString(solrString).getAsJsonObject(); - Record record = Parser.parseQtpRecord(solrJson); + UCRecord record = Parser.parseQtpRecord(solrJson); final ExceptionRecord exceptionRecord = record.getException(); Assert.assertNotNull(exceptionRecord); Assert.assertEquals(ApplicationConstant.EXCEPTION_TYPE_AUTHORIZATION_STRING, @@ -98,7 +98,7 @@ public void testParseException() throws Exception { public void testRedacted() throws Exception { final String solrString = "{\"insertId\":\"1lzqgspg20hyho1\",\"jsonPayload\":{\"message\":\"2022-06-03 11:27:38.004 INFO (qtp2005169944-19) [ ] o.a.s.s.HttpSolrCall [admin] webapp=null path=\\/admin\\/cores params={core=firstCore&other=secondCore&action=SWAP} status=0 QTime=207\"},\"resource\":{\"type\":\"gce_instance\",\"labels\":{\"zone\":\"asia-south2-a\",\"instance_id\":\"6290282768426383618\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-30T08:50:36.941752806Z\",\"labels\":{\"compute.googleapis.com\\/resource_name\":\"apachesolrqa\"},\"logName\":\"projects\\/project-sccd\\/logs\\/files\",\"receiveTimestamp\":\"2022-05-30T08:50:37.641620487Z\"}"; final JsonObject solrJson = JsonParser.parseString(solrString).getAsJsonObject(); - Record record = Parser.parseQtpRecord(solrJson); + UCRecord record = Parser.parseQtpRecord(solrJson); String redacted = record.getData().getConstruct().getRedactedSensitiveDataSql(); Assert.assertNotNull(redacted); Assert.assertNotNull(record); diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/build.gradle b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/build.gradle index 53ca23a44..2a1b05b09 100644 --- a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/build.gradle +++ b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/build.gradle @@ -24,10 +24,10 @@ pluginInfo.pluginClass = "BigQueryGuardiumFilter" pluginInfo.pluginName = "big_query_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -45,8 +45,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.0" + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -195,4 +195,4 @@ jacocoTestCoverageVerification { })) } } -project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) \ No newline at end of file +project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/guardium_logstash-offline-plugins-ps-bigQuery.zip b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/guardium_logstash-offline-plugins-ps-bigQuery.zip index 00057a2a6..7501f7578 100644 Binary files a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/guardium_logstash-offline-plugins-ps-bigQuery.zip and b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/guardium_logstash-offline-plugins-ps-bigQuery.zip differ diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/logstash-filter-big_query_guardium_filter.zip b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/logstash-filter-big_query_guardium_filter.zip index e2fb04317..d98f3afbb 100644 Binary files a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/logstash-filter-big_query_guardium_filter.zip and b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/logstash-filter-big_query_guardium_filter.zip differ diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilter.java b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilter.java index 626f6ed0a..2038cc537 100644 --- a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilter.java +++ b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilter.java @@ -16,7 +16,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -101,7 +101,7 @@ public Collection filter(Collection events, FilterMatchListener fi } try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final Gson gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create(); e.setField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME, gson.toJson(record)); filterMatchListener.filterMatched(e); diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/Parser.java b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/Parser.java index 3bd044f4e..50a971a66 100644 --- a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/Parser.java +++ b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/main/java/com/ibm/guardium/bigquery/Parser.java @@ -24,7 +24,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -65,19 +65,19 @@ public class Parser { /** * parseRecord() method will perform operation on JsonObject input, convert - * JsonObject into Record Object and then return the value as response + * JsonObject into UCRecord Object and then return the value as response * * @param JsonObject inputJson * @methodName @parseRecord - * @return Record GUARDIUM Object + * @return UCRecord GUARDIUM Object * @throws Exception * */ - public static Record parseRecord(JsonObject inputJson) { + public static UCRecord parseRecord(JsonObject inputJson) { JsonObject protoPayload = null; JsonObject metaDataJson = null; - Record record = new Record(); + UCRecord record = new UCRecord(); if(inputJson.has(ApplicationConstants.PROTO_PAYLOAD) && inputJson.get(ApplicationConstants.PROTO_PAYLOAD).getAsJsonObject() != null && !inputJson.get(ApplicationConstants.PROTO_PAYLOAD).getAsJsonObject().entrySet().isEmpty()); { diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilterTest.java b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilterTest.java index 89e2ee48a..aef0de63e 100644 --- a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilterTest.java +++ b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/BigQueryGuardiumFilterTest.java @@ -17,7 +17,7 @@ import org.logstash.plugins.ConfigurationImpl; import org.logstash.plugins.ContextImpl; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; @@ -72,7 +72,7 @@ public void filterHTTPPrototypeTest() { public void filterCreateSchemaTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.55\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36 Edg\\/94.0.992.50,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.DatasetService.InsertDataset\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.datasets.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/babynames\",\"metadata\":{\"datasetCreation\":{\"reason\":\"CREATE\",\"dataset\":{\"createTime\":\"2021-10-22T08:23:25.239Z\",\"acl\":{\"policy\":{\"bindings\":[{\"role\":\"roles\\/bigquery.dataEditor\",\"members\":[\"projectEditor:project-sccd\"]},{\"role\":\"roles\\/bigquery.dataOwner\",\"members\":[\"projectOwner:project-sccd\",\"user:user@test.com\"]},{\"members\":[\"projectViewer:project-sccd\"],\"role\":\"roles\\/bigquery.dataViewer\"}]}},\"datasetName\":\"projects\\/project-sccd\\/datasets\\/babynames\",\"updateTime\":\"2021-10-22T08:23:25.239Z\"}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"vmzwgld2yry\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"project_id\":\"project-sccd\",\"dataset_id\":\"babynames\"}},\"timestamp\":\"2021-10-22T08:23:25.306328Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2021-10-22T08:23:25.690839506Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("create schema babynames", sqlquery.getData().getConstruct().fullSql); assertEquals("project-sccd:babynames", sqlquery.getDbName()); assertEquals("create schema", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -84,7 +84,7 @@ public void filterCreateSchemaTest() { public void filterOuterProtoPayloadDataTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.55\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36 Edg\\/94.0.992.50,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.InsertTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/babynames\",\"permission\":\"bigquery.tables.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/babynames\\/tables\\/person\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableCreation\":{\"table\":{\"createTime\":\"2021-10-22T08:27:29.578Z\",\"updateTime\":\"2021-10-22T08:27:29.622Z\",\"schemaJson\":\"{\\n \\\"fields\\\": [{\\n \\\"name\\\": \\\"id\\\",\\n \\\"type\\\": \\\"BIGNUMERIC\\\",\\n \\\"mode\\\": \\\"REQUIRED\\\"\\n }, {\\n \\\"name\\\": \\\"first_name\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"last_name\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"age\\\",\\n \\\"type\\\": \\\"INTEGER\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }]\\n}\",\"tableName\":\"projects\\/project-sccd\\/datasets\\/babynames\\/tables\\/person\"},\"reason\":\"TABLE_INSERT_REQUEST\"}}},\"insertId\":\"yp5msqd3d7i\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"project_id\":\"project-sccd\",\"dataset_id\":\"babynames\"}},\"timestamp\":\"2021-10-22T08:27:29.659395Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2021-10-22T08:27:30.126085723Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("create table babynames.person", sqlquery.getData().getConstruct().fullSql); assertEquals("project-sccd:babynames", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); @@ -98,7 +98,7 @@ public void filterProtoPayloadDbNameTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{},\"requestMetadata\":{\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/97.0.4692.71 Safari\\/537.36 Edg\\/97.0.1072.62,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_8e8a6ad_17e901567d3\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_8e8a6ad_17e901567d3\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"alter table `project-sccd.BigQueryQADS.userdetail` ADD COLUMN phone_num varchar(50);\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"ALTER_TABLE\"}},\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"createTime\":\"2022-01-25T07:13:49.369Z\",\"startTime\":\"2022-01-25T07:13:49.472Z\",\"queryStats\":{}}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"kb670e1rdar\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-01-25T07:13:49.519016Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1643094829369-project-sccd:bquxjob_8e8a6ad_17e901567d3\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-01-25T07:13:50.116494531Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:BigQueryQADS", sqlquery.getDbName()); TestMatchListener matchListener = new TestMatchListener(); assertEquals(0, matchListener.getMatchCount()); @@ -110,7 +110,7 @@ public void filterProtoPayloadEmptyMetadataTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.55\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36 Edg\\/94.0.992.50,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.InsertTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/babynames\",\"permission\":\"bigquery.tables.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/babynames\\/tables\\/person\",\"metadata\":{}},\"insertId\":\"yp5msqd3d7i\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"project_id\":\"project-sccd\",\"dataset_id\":\"babynames\"}},\"timestamp\":\"2021-10-22T08:27:29.659395Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2021-10-22T08:27:30.126085723Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("", sqlquery.getData().getConstruct().fullSql); @@ -126,7 +126,7 @@ public void filterFieldsForTableCreationTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.166.30\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.InsertTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\",\"permission\":\"bigquery.tables.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableCreation\":{\"table\":{\"schemaJson\":\"{\\n \\\"fields\\\": [{\\n \\\"name\\\": \\\"id\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"first_name\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"last_name\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"email\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }]\\n}\",\"updateTime\":\"2021-11-02T11:40:57.440Z\",\"createTime\":\"2021-11-02T11:40:57.327Z\",\"tableName\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\"},\"reason\":\"TABLE_INSERT_REQUEST\"}}},\"insertId\":\"-iayvihdbijr\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"project_id\":\"project-sccd\",\"dataset_id\":\"big_Query_Data_Set\"}},\"timestamp\":\"2021-11-02T11:40:57.468544Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2021-11-02T11:40:58.012452163Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:big_Query_Data_Set", sqlquery.getDbName()); assertEquals("144348902", sqlquery.getSessionId()); assertEquals("create table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -156,7 +156,7 @@ public void parseNullResourceJsonForMetaDataTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"112.23.00.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"permission\":\"bigquery.tables.getData\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"metadata\":{\"tableDataRead\":{\"reason\":\"JOB\",\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j51\",\"resource\":{},\"timestamp\":\"2021-11-04T01:45:52.859567Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"receiveTimestamp\":\"2021-11-04T01:45:52.924677259Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals(null, sqlquery.getData().getOriginalSqlCommand()); assertEquals("112.23.00.11", sqlquery.getSessionLocator().getClientIp()); assertEquals(-1, sqlquery.getSessionLocator().getClientPort()); @@ -170,7 +170,7 @@ public void eventObjectAndVerbTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"136.185.149.223\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1b12d4043516e7fe556c67c37894adb7c0c3588b\\/tables\\/anon0d36a80a5698fbaec071061444ad0e4a4d2d2e24\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"query\":\"select * from project-sccd.Newdatademo.demoibm LIMIT 1000;\"},\"type\":\"QUERY\"},\"jobStats\":{\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/Newdatademo\\/tables\\/demoibm\"],\"billingTier\":1,\"totalProcessedBytes\":\"28\",\"outputRowCount\":\"2\",\"totalBilledBytes\":\"10485760\"},\"endTime\":\"2022-03-28T09:42:23.627Z\",\"createTime\":\"2022-03-28T09:42:23.237Z\",\"startTime\":\"2022-03-28T09:42:23.380Z\",\"totalSlotMs\":\"56\"}},\"after\":\"DONE\"}}},\"insertId\":\"-uso33ze1h99r\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-03-28T09:42:23.630852Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648460543237-project-sccd:bquxjob_2efa9cd5_17fcfe7b26f\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-03-28T09:42:23.997320883Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:Newdatademo", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("select", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -214,7 +214,7 @@ public void eventObjectAndVerbCreateTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.86\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_787f3164_1804a2c3db5\",\"metadata\":{\"jobInsertion\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobStats\":{\"createTime\":\"2022-04-21T03:32:06.081Z\",\"startTime\":\"2022-04-21T03:32:06.185Z\",\"queryStats\":{}},\"jobConfig\":{\"queryConfig\":{\"priority\":\"QUERY_INTERACTIVE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/testOne\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"query\":\"create table `project-sccd.BigQueryQADS.testOne` (\\r\\n SingerId INT64 NOT NULL,\\r\\n FirstName STRING(1024),\\r\\n LastName STRING(1024),\\r\\n BirthDate DATE,\\r\\n);\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"CREATE_TABLE\"},\"type\":\"QUERY\"},\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_787f3164_1804a2c3db5\"}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-wq3ig5dhf0p\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T03:32:06.236284Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650511926081-project-sccd:bquxjob_787f3164_1804a2c3db5\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T03:32:06.413809027Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:BigQueryQADS", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("create table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -238,7 +238,7 @@ public void event() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.41\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.75 Safari\\/537.36 Edg\\/100.0.1185.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_59173dd3_1803b96a7ba\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobInsertion\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_59173dd3_1803b96a7ba\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"writeDisposition\":\"WRITE_TRUNCATE\",\"statementType\":\"SELECT\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonafe3be657fddb83f57bf753a081c1535d35a9c85\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"query\":\"select * from `project-sccd.BigQueryE2E.Employee` LIMIT 1000\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobStats\":{\"createTime\":\"2022-04-18T07:35:47.545Z\",\"queryStats\":{},\"startTime\":\"2022-04-18T07:35:47.722Z\"}}}}},\"insertId\":\"-wq87age2wvch\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-18T07:35:47.961913Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650267347545-project-sccd:bquxjob_59173dd3_1803b96a7ba\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-18T07:35:48.786537635Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:BigQueryE2E", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("-1198440991", sqlquery.getSessionId()); @@ -269,7 +269,7 @@ public void filterProtoPayloadTableChangeTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.27\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"tableservice.insert\",\"authorizationInfo\":[{\"resource\":\"projects\\/bigqueryproject-330206\\/datasets\\/bigQuery_DataSet\",\"permission\":\"bigquery.tables.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/bigqueryproject-330206\\/datasets\\/bigQuery_DataSet\\/tables\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.bigquery.logging.v1.AuditData\",\"tableChange\":{\"resource\":{\"tableName\":{\"projectId\":\"bigqueryproject-330206\",\"datasetId\":\"bigQuery_DataSet\",\"tableId\":\"person\"},\"info\":{},\"view\":{\"query\":\"select * from tableName\"},\"expireTime\":\"2021-12-25T06:39:34.754Z\",\"createTime\":\"2021-10-26T06:39:34.754Z\",\"schemaJson\":\"{\\n \\\"fields\\\": [{\\n \\\"name\\\": \\\"id\\\",\\n \\\"type\\\": \\\"NUMERIC\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"first_name\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"last_name\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"age\\\",\\n \\\"type\\\": \\\"NUMERIC\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }]\\n}\",\"updateTime\":\"2021-10-26T06:39:34.794Z\"}}}},\"insertId\":\"-w646o2dacdo\",\"resource\":{\"type\":\"bigquery_resource\",\"labels\":{\"project_id\":\"bigqueryproject-330206\"}},\"timestamp\":\"2021-10-26T06:39:34.836392Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/bigqueryproject-330206\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2021-10-26T06:39:35.675223426Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("bigqueryproject-330206:", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("select", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -283,7 +283,7 @@ public void filterProtoPayloadErrorwithoutDescriptionTEST() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.187.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_68d3c23e_18049d458fc\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobConfig\":{\"queryConfig\":{\"query\":\"create schema `BigQueryQADS`;\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"writeDisposition\":\"WRITE_EMPTY\"},\"type\":\"QUERY\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"queryStats\":{},\"endTime\":\"2022-04-21T01:56:06.823Z\",\"createTime\":\"2022-04-21T01:56:06.803Z\",\"startTime\":\"2022-04-21T01:56:06.823Z\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_68d3c23e_18049d458fc\"},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-oomtnhddawf\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T01:56:06.875742Z\",\"severity\":\"ERROR\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650506166803-project-sccd:bquxjob_68d3c23e_18049d458fc\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T01:56:06.916288378Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); Collection events = getEvents(gcpString2); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals("-955314875", sqlquery.getSessionId()); assertEquals("SQL_ERROR", sqlquery.getException().getExceptionTypeId()); @@ -298,7 +298,7 @@ public void filterProtoPayloadErrorwithoutDescriptionTEST() { public void filterProtoPayloadErrorwithDescriptionTEST() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.187.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_68d3c23e_18049d458fc\",\"metadata\":{\"jobChange\":{\"job\":{\"jobConfig\":{\"queryConfig\":{\"query\":\"create schema `project-sccd.BigQueryQADS.userdetailQW`;\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"writeDisposition\":\"WRITE_EMPTY\"},\"type\":\"QUERY\"},\"jobStatus\":{\"errors\":[{\"code\":3,\"message\":\"Invalid project ID 'project-sccd.BigQueryQADS'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. Some project IDs also include domain name separated by a colon. IDs must start with a letter and may not end with a dash.\"}],\"errorResult\":{\"message\":\"Invalid project ID 'project-sccd.BigQueryQADS'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. Some project IDs also include domain name separated by a colon. IDs must start with a letter and may not end with a dash.\",\"code\":3},\"jobState\":\"DONE\"},\"jobStats\":{\"queryStats\":{},\"endTime\":\"2022-04-21T01:56:06.823Z\",\"createTime\":\"2022-04-21T01:56:06.803Z\",\"startTime\":\"2022-04-21T01:56:06.823Z\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_68d3c23e_18049d458fc\"},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-oomtnhddawf\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T01:56:06.875742Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650506166803-project-sccd:bquxjob_68d3c23e_18049d458fc\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T01:56:06.916288378Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals(Long.parseLong("1650506166875"), sqlquery.getTime().getTimstamp()); assertEquals(0, sqlquery.getTime().getMinOffsetFromGMT()); @@ -313,7 +313,7 @@ public void filterProtoPayloadErrorTEST() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.187.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_68d3c23e_18049d458fc\",\"metadata\":{\"jobChange\":{\"job\":{\"jobConfig\":{\"queryConfig\":{\"query\":\"create schema `project-sccd.BigQueryQADS.userdetailQW`;\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"writeDisposition\":\"WRITE_EMPTY\"},\"type\":\"QUERY\"},\"jobStatus\":{\"errors\":[{\"code\":3,\"message\":\"Invalid project ID 'project-sccd.BigQueryQADS'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. Some project IDs also include domain name separated by a colon. IDs must start with a letter and may not end with a dash.\"}],\"errorResult\":{},\"jobState\":\"DONE\"},\"jobStats\":{\"queryStats\":{},\"endTime\":\"2022-04-21T01:56:06.823Z\",\"createTime\":\"2022-04-21T01:56:06.803Z\",\"startTime\":\"2022-04-21T01:56:06.823Z\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_68d3c23e_18049d458fc\"},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-oomtnhddawf\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T01:56:06.875742Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650506166803-project-sccd:bquxjob_68d3c23e_18049d458fc\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T01:56:06.916288378Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("SQL_ERROR", sqlquery.getException().getExceptionTypeId()); @@ -327,7 +327,7 @@ public void filterProtoPayloadErrorTEST() { public void filterSQLWithSlashTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"122.177.51.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3a9bcd2e_17fdef9a82a\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStats\":{\"queryStats\":{\"cacheHit\":true},\"createTime\":\"2022-03-31T07:56:16.896Z\",\"endTime\":\"2022-03-31T07:56:17.088Z\",\"startTime\":\"2022-03-31T07:56:17.035Z\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3a9bcd2e_17fdef9a82a\",\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1b12d4043516e7fe556c67c37894adb7c0c3588b\\/tables\\/anon8a04e12e525797da397d67d2135c12d9cc4f325c\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"query\":\"select * from `project-sccd.BigQueryQADS.empDetails` where name =\\\"sandeep\\\";\\r\\n\",\"statementType\":\"SELECT\"},\"type\":\"QUERY\"}},\"after\":\"DONE\"}}},\"insertId\":\"-bn7puve3k0vp\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-03-31T07:56:17.091042Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648713376896-project-sccd:bquxjob_3a9bcd2e_17fdef9a82a\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-03-31T07:56:17.339111864Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:BigQueryQADS", sqlquery.getDbName()); assertEquals("select", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -341,7 +341,7 @@ public void testParseRecordMetaDataWithOperators() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.241\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5121cbab_180ac7c8144\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobStats\":{\"createTime\":\"2022-05-10T05:44:39.493Z\",\"totalSlotMs\":\"13\",\"startTime\":\"2022-05-10T05:44:39.559Z\",\"queryStats\":{\"billingTier\":1,\"totalProcessedBytes\":\"80\",\"outputRowCount\":\"4\",\"totalBilledBytes\":\"10485760\",\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/regions\"]},\"endTime\":\"2022-05-10T05:44:39.737Z\"},\"jobConfig\":{\"queryConfig\":{\"query\":\"SELECT * FROM `project-sccd.SampleBigquery.regions` TABLESAMPLE SYSTEM (10 PERCENT)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon07bece15_8015_4321_bfa1_0688770bb158\",\"statementType\":\"SELECT\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\"},\"type\":\"QUERY\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5121cbab_180ac7c8144\"}}}},\"insertId\":\"opa31yet3qtg\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-10T05:44:39.779888Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652161479493-project-sccd:bquxjob_5121cbab_180ac7c8144\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-10T05:44:40.356367737Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("-994385949", sqlquery.getSessionId()); assertEquals("select", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -386,7 +386,7 @@ public void testParseRecordMetaDataWithIntersectDistinct() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.26\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.47,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_aaffd9_180e10a87dd\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_aaffd9_180e10a87dd\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE TABLE BigQueryE2E.Student (id INT64, first_name STRING(8), last_name STRING(9));\\r\\nCREATE TABLE BigQueryE2E.Course (id INT64, name STRING(16), teacher_id INT64);\\r\\nCREATE TABLE BigQueryE2E.Student_Course (id INT64, student_id INT64,ccourse_id INT64);\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SCRIPT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-20T10:40:11.275Z\",\"startTime\":\"2022-05-20T10:40:11.335Z\",\"endTime\":\"2022-05-20T10:40:13.551Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"ldhm7ve6dr9p\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-20T10:40:13.560531Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1653043211275-project-sccd:bquxjob_aaffd9_180e10a87dd\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-20T10:40:14.417906660Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); Collection events = getEvents(gcpString2); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:BigQueryE2E", sqlquery.getDbName()); assertEquals("1437565344", sqlquery.getSessionId()); assertEquals("user@test.com", sqlquery.getAppUserName()); @@ -404,7 +404,7 @@ public void testParseRecordMetaDataWithTable() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.202\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_66d45f65_180bb95d0e0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_66d45f65_180bb95d0e0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE table testInfo.Customertables\\r\\n(\\r\\nx INT64 OPTIONS(description=\\\"An optional INTEGER field\\\"),\\r\\ny STRUCT<\\r\\nb BOOL\\r\\n>\\r\\n)\\r\\nOPTIONS(\\r\\nexpiration_timestamp=TIMESTAMP \\\"2023-01-01 00:00:00 UTC\\\",\\r\\ndescription=\\\"a table that expires in 2023\\\",\\r\\nlabels=[(\\\"org_unit\\\", \\\"development\\\")]\\r\\n)\\r\\n\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/testInfo\\/tables\\/CustomerRegion\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-13T04:06:40.926Z\",\"startTime\":\"2022-05-13T04:06:41.018Z\",\"endTime\":\"2022-05-13T04:06:41.184Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-wql3brdxnoq\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-05-13T04:06:41.192811Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652414800926-project-sccd:bquxjob_66d45f65_180bb95d0e0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-13T04:06:41.959826021Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:testInfo", sqlquery.getDbName()); assertEquals("create table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -421,7 +421,7 @@ public void testParseRecordMetaDataWithFunction() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3365572a_180796b3fe1\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3365572a_180796b3fe1\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE FUNCTION `project-sccd.SampleBigquery.regions`(arr ANY TYPE) AS (\\r\\n (\\r\\n SELECT\\r\\n IF(\\r\\n MOD(ARRAY_LENGTH(arr), 2) = 0,\\r\\n (arr[OFFSET(DIV(ARRAY_LENGTH(arr), 2) - 1)] + arr[OFFSET(DIV(ARRAY_LENGTH(arr), 2))]) \\/ 2,\\r\\n arr[OFFSET(DIV(ARRAY_LENGTH(arr), 2))]\\r\\n )\\r\\n FROM (SELECT ARRAY_AGG(x ORDER BY x) AS arr FROM UNNEST(arr) AS x)\\r\\n )\\r\\n);\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_FUNCTION\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T07:45:02.421Z\",\"startTime\":\"2022-04-30T07:45:02.525Z\",\"endTime\":\"2022-04-30T07:45:02.622Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-iayzcie3ivrt\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T07:45:02.631459Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651304702421-project-sccd:bquxjob_3365572a_180796b3fe1\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T07:45:03.355019668Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("create function", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -437,7 +437,7 @@ public void testParseRecordMetaDataWithProcedure() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/script_job_a68c7cdc16ba1b476fd55a442d3a1448_0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/script_job_a68c7cdc16ba1b476fd55a442d3a1448_0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE PROCEDURE `project-sccd.SampleBigquery.myproc`()\\r\\nBEGIN\\r\\n SELECT\\r\\n fileName AS unique_id,\\r\\n historyStatus AS latest_status,\\r\\n lastUpdatedTimestamp AS last_update,\\r\\n ROW_NUMBER() OVER (PARTITION BY fileName ORDER BY lastUpdatedTimestamp DESC) AS row_number\\r\\nFROM `bigquery-public-data.fcc_political_ads.file_history`\\r\\nORDER BY\\r\\n 1,\\r\\n 3 DESC;\\r\\nEND\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_PROCEDURE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T08:27:36.137Z\",\"startTime\":\"2022-04-30T08:27:36.204Z\",\"endTime\":\"2022-04-30T08:27:36.356Z\",\"queryStats\":{},\"parentJobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6ae18a5d_18079923909\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-skdehtehvnj2\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T08:27:36.372161Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651307256137-project-sccd:script_job_a68c7cdc16ba1b476fd55a442d3a1448_0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T08:27:36.713485373Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("-376165729", sqlquery.getSessionId()); assertEquals("create procedure", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -453,7 +453,7 @@ public void testParseRecordMetaDataWithMaterialized() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_aae3c3b_180791373f6\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_aae3c3b_180791373f6\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE MATERIALIZED VIEW `SampleBigquery. Mview` AS SELECT country_id,country_name, COUNT(region_id) as count\\r\\nFROM `project-sccd.SampleBigquery.countries` group by country_id, country_name;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mview\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_MATERIALIZED_VIEW\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T06:09:07.675Z\",\"startTime\":\"2022-04-30T06:09:07.783Z\",\"endTime\":\"2022-04-30T06:09:08.134Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-mqr2tve3vkkk\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T06:09:08.143896Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651298947675-project-sccd:bquxjob_aae3c3b_180791373f6\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T06:09:08.934935711Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("create materialized view", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -470,7 +470,7 @@ public void testParseRecordMetaDataWithAlterMaterialized() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_aae3c3b_180791373f6\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_aae3c3b_180791373f6\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"ALTER MATERIALIZED VIEW `SampleBigquery. Mview` AS SELECT country_id,country_name, COUNT(region_id) as count\\r\\nFROM `project-sccd.SampleBigquery.countries` group by country_id, country_name;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mview\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_MATERIALIZED_VIEW\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T06:09:07.675Z\",\"startTime\":\"2022-04-30T06:09:07.783Z\",\"endTime\":\"2022-04-30T06:09:08.134Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-mqr2tve3vkkk\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T06:09:08.143896Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651298947675-project-sccd:bquxjob_aae3c3b_180791373f6\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T06:09:08.934935711Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("-376165729", sqlquery.getSessionId()); assertEquals("alter materialized view", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); @@ -486,7 +486,7 @@ public void testParseRecordMetaDataWithView() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_547cee3a_180791126ca\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_547cee3a_180791126ca\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE VIEW `project-sccd.SampleBigquery.groups`(name, count) AS SELECT country_name, COUNT(*) as count\\r\\nFROM `project-sccd.SampleBigquery.countries`\\r\\ngroup by country_name having count > 1;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/groups\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_VIEW\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T06:06:37.551Z\",\"startTime\":\"2022-04-30T06:06:37.651Z\",\"endTime\":\"2022-04-30T06:06:37.816Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"ajoyg3e2y8sn\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T06:06:37.823543Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651298797551-project-sccd:bquxjob_547cee3a_180791126ca\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T06:06:38.183637403Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("create view", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -518,7 +518,7 @@ public void testParseRecordMetaDataWithSnapshot() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.166.232\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7d79c6a8_18079a45a9d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7d79c6a8_18079a45a9d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"DROP SNAPSHOT TABLE SampleBigquery.mytablesnapshot\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/mytablesnapshot\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DROP_SNAPSHOT_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T08:47:24.588Z\",\"startTime\":\"2022-04-30T08:47:24.695Z\",\"endTime\":\"2022-04-30T08:47:24.861Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"j5lj0ue29qxt\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-30T08:47:24.867896Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651308444588-project-sccd:bquxjob_7d79c6a8_18079a45a9d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T08:47:25.055265124Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:SampleBigquery", sqlquery.getDbName()); assertEquals("drop snapshot table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -535,7 +535,7 @@ public void testParseRecordMetaDataWithSchema() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.202\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_66d45f65_180bb95d0e0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_66d45f65_180bb95d0e0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE schema testInfo.Customertables\\r\\n(\\r\\nx INT64 OPTIONS(description=\\\"An optional INTEGER field\\\"),\\r\\ny STRUCT<\\r\\nb BOOL\\r\\n>\\r\\n)\\r\\nOPTIONS(\\r\\nexpiration_timestamp=TIMESTAMP \\\"2023-01-01 00:00:00 UTC\\\",\\r\\ndescription=\\\"a table that expires in 2023\\\",\\r\\nlabels=[(\\\"org_unit\\\", \\\"development\\\")]\\r\\n)\\r\\n\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/testInfo\\/tables\\/CustomerRegion\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-13T04:06:40.926Z\",\"startTime\":\"2022-05-13T04:06:41.018Z\",\"endTime\":\"2022-05-13T04:06:41.184Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-wql3brdxnoq\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-05-13T04:06:41.192811Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652414800926-project-sccd:bquxjob_66d45f65_180bb95d0e0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-13T04:06:41.959826021Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:Customertables", sqlquery.getDbName()); assertEquals("create schema", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -565,7 +565,7 @@ public void testParseRecordMetaDataWithNot() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{\"code\":5,\"message\":\"Not found: Table project-sccd:BigQueryE2E.Customer1\"},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.166.41\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.63 Safari\\/537.36 Edg\\/102.0.1245.39,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6cc6c6a7_1816192f2d4\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6cc6c6a7_1816192f2d4\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"Drop table BigQueryE2E.Customer1\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Customer1\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DROP_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\",\"errorResult\":{\"code\":5,\"message\":\"Not found: Table project-sccd:BigQueryE2E.Customer1\"},\"errors\":[{\"code\":5,\"message\":\"Not found: Table project-sccd:BigQueryE2E.Customer1\"}]},\"jobStats\":{\"createTime\":\"2022-06-14T09:40:55.903Z\",\"startTime\":\"2022-06-14T09:40:55.981Z\",\"endTime\":\"2022-06-14T09:40:56.084Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-ef7z5ee4unnu\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-14T09:40:56.089285Z\",\"severity\":\"ERROR\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655199655903-project-sccd:bquxjob_6cc6c6a7_1816192f2d4\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-14T09:40:56.337931474Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals("SQL_ERROR", sqlquery.getException().getExceptionTypeId()); assertEquals("Not found: Table project-sccd:BigQueryE2E.Customer1", sqlquery.getException().getDescription()); @@ -580,7 +580,7 @@ public void testParseRecordMetaDataWith() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"136.185.149.223\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1b12d4043516e7fe556c67c37894adb7c0c3588b\\/tables\\/anon0d36a80a5698fbaec071061444ad0e4a4d2d2e24\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"query\":\"WITH Values AS ( SELECT 1 x, 'a' y UNION ALL SELECT 1 x, 'b' y UNION ALL SELECT 2 x, 'a' y UNION ALL SELECT 2 x, 'c' y ) SELECT x, ARRAY_AGG(y) as array_agg FROM Values GROUP BY x\"},\"type\":\"QUERY\"},\"jobStats\":{\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/Newdatademo\\/tables\\/demoibm\"],\"billingTier\":1,\"totalProcessedBytes\":\"28\",\"outputRowCount\":\"2\",\"totalBilledBytes\":\"10485760\"},\"endTime\":\"2022-03-28T09:42:23.627Z\",\"createTime\":\"2022-03-28T09:42:23.237Z\",\"startTime\":\"2022-03-28T09:42:23.380Z\",\"totalSlotMs\":\"56\"}},\"after\":\"DONE\"}}},\"insertId\":\"-uso33ze1h99r\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-03-28T09:42:23.630852Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648460543237-project-sccd:bquxjob_2efa9cd5_17fcfe7b26f\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-03-28T09:42:23.997320883Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals("with ", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -596,7 +596,7 @@ public void testParseRecordUNNEST() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"136.185.149.223\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1b12d4043516e7fe556c67c37894adb7c0c3588b\\/tables\\/anon0d36a80a5698fbaec071061444ad0e4a4d2d2e24\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"query\":\"Select ANY_VALUE(fruit) as any_value from UNNEST([\\\"apple\\\",\\\"banana\\\",\\\"pear\\\"]) as fruit\"},\"type\":\"QUERY\"},\"jobStats\":{\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/Newdatademo\\/tables\\/demoibm\"],\"billingTier\":1,\"totalProcessedBytes\":\"28\",\"outputRowCount\":\"2\",\"totalBilledBytes\":\"10485760\"},\"endTime\":\"2022-03-28T09:42:23.627Z\",\"createTime\":\"2022-03-28T09:42:23.237Z\",\"startTime\":\"2022-03-28T09:42:23.380Z\",\"totalSlotMs\":\"56\"}},\"after\":\"DONE\"}}},\"insertId\":\"-uso33ze1h99r\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-03-28T09:42:23.630852Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648460543237-project-sccd:bquxjob_2efa9cd5_17fcfe7b26f\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-03-28T09:42:23.997320883Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:", sqlquery.getDbName()); assertEquals("user@test.com", sqlquery.getAppUserName()); assertEquals("Select ANY_VALUE(fruit) as any_value from UNNEST([ \"apple \", \"banana \", \"pear \"]) as fruit", sqlquery.getData().getConstruct().fullSql); @@ -611,7 +611,7 @@ public void testParseRecordCreateSchema() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"136.185.149.223\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2efa9cd5_17fcfe7b26f\",\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1b12d4043516e7fe556c67c37894adb7c0c3588b\\/tables\\/anon0d36a80a5698fbaec071061444ad0e4a4d2d2e24\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"query\":\"CREATE SCHEMA `project-sccd.my9dataset` OPTIONS( location= \\\"us \\\", default_table_expiration_days=3.75, labels=[( \\\"label1 \\\", \\\"value1 \\\"),(\\\"label2 \\\", \\\"value2\\\")])\"},\"type\":\"QUERY\"},\"jobStats\":{\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/Newdatademo\\/tables\\/demoibm\"],\"billingTier\":1,\"totalProcessedBytes\":\"28\",\"outputRowCount\":\"2\",\"totalBilledBytes\":\"10485760\"},\"endTime\":\"2022-03-28T09:42:23.627Z\",\"createTime\":\"2022-03-28T09:42:23.237Z\",\"startTime\":\"2022-03-28T09:42:23.380Z\",\"totalSlotMs\":\"56\"}},\"after\":\"DONE\"}}},\"insertId\":\"-uso33ze1h99r\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-03-28T09:42:23.630852Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648460543237-project-sccd:bquxjob_2efa9cd5_17fcfe7b26f\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-03-28T09:42:23.997320883Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("CREATE SCHEMA `project-sccd.my9dataset` OPTIONS( location= \"us \", default_table_expiration_days=3.75, labels=[( \"label1 \", \"value1 \"),( \"label2 \", \"value2 \")])", sqlquery.getData().getConstruct().fullSql); assertEquals("CREATE SCHEMA `project-sccd.my9dataset` OPTIONS( location= ?, default_table_expiration_days=?.?, labels=[( ?, ?),( ?, ?)])", sqlquery.getData().getConstruct().redactedSensitiveDataSql); assertEquals("project-sccd:my9dataset", sqlquery.getDbName()); @@ -647,7 +647,7 @@ public void testParseRecordMetaDataWithTableInsertrequest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.173\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.InsertTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/9622Dataset\",\"permission\":\"bigquery.tables.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/9622Dataset\\/tables\\/9622Table\",\"metadata\":{\"tableCreation\":{\"table\":{\"schemaJson\":\"{\\n}\",\"updateTime\":\"2022-09-06T09:33:48.043Z\",\"tableName\":\"projects\\/project-sccd\\/datasets\\/9622Dataset\\/tables\\/9622Table\",\"createTime\":\"2022-09-06T09:33:47.931Z\"},\"reason\":\"TABLE_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-iv71qld7oer\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"dataset_id\":\"9622Dataset\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-09-06T09:33:48.071213Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2022-09-06T09:33:48.937954238Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:9622Dataset", sqlquery.getDbName()); assertEquals("create table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -663,7 +663,7 @@ public void testParseRecordMetaDataWithDeleteTableRequest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.173\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.DeleteTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/9622Dataset\\/tables\\/9622Table\",\"permission\":\"bigquery.tables.delete\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/9622Dataset\\/tables\\/9622Table\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableDeletion\":{\"reason\":\"TABLE_DELETE_REQUEST\"}}},\"insertId\":\"-naw5i4d7vsk\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"dataset_id\":\"9622Dataset\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-09-06T09:34:01.912415Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2022-09-06T09:34:02.837090160Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); Collection events = getEvents(gcpString2); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:9622Dataset", sqlquery.getDbName()); assertEquals("drop table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -679,7 +679,7 @@ public void testParseRecordUploadCsvCreateTableLog() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"jobConfig\":{\"type\":\"IMPORT\",\"loadConfig\":{\"schemaJson\":\"{\\n}\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/mydataset\\/tables\\/oldtable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-09-06T05:42:28.990Z\",\"startTime\":\"2022-09-06T05:42:29.270Z\",\"endTime\":\"2022-09-06T05:42:30.621Z\",\"loadStats\":{\"totalOutputBytes\":\"216\"},\"totalSlotMs\":\"103\",\"reservationUsage\":[{\"name\":\"default-pipeline\",\"slotMs\":\"103\"}]}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-eovwo0dsdv8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"us-central1\"}},\"timestamp\":\"2022-09-06T05:42:30.670452Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1662442948990-project-sccd:bquxjob_29acf1c6_18311523980\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-09-06T05:42:31.078574953Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("project-sccd:mydataset", sqlquery.getDbName()); assertEquals("create table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); @@ -696,7 +696,7 @@ public void testfilterSessionLocator() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"112.155.11.12\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"jobConfig\":{\"type\":\"IMPORT\",\"loadConfig\":{\"schemaJson\":\"{\\n}\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/mydataset\\/tables\\/oldtable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-09-06T05:42:28.990Z\",\"startTime\":\"2022-09-06T05:42:29.270Z\",\"endTime\":\"2022-09-06T05:42:30.621Z\",\"loadStats\":{\"totalOutputBytes\":\"216\"},\"totalSlotMs\":\"103\",\"reservationUsage\":[{\"name\":\"default-pipeline\",\"slotMs\":\"103\"}]}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-eovwo0dsdv8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"us-central1\"}},\"timestamp\":\"2022-09-06T05:42:30.670452Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1662442948990-project-sccd:bquxjob_29acf1c6_18311523980\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-09-06T05:42:31.078574953Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("112.155.11.12", sqlquery.getSessionLocator().getClientIp()); assertEquals(-1, sqlquery.getSessionLocator().getClientPort()); assertEquals("0.0.0.0", sqlquery.getSessionLocator().getServerIp()); @@ -711,7 +711,7 @@ public void testfilterSessionLocatorwithIpv6() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"2409:4064:2291:455c:e189:21f3:2d20:6ec5\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobChange\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals(true, sqlquery.getSessionLocator().isIpv6()); assertEquals("2409:4064:2291:455c:e189:21f3:2d20:6ec5", sqlquery.getSessionLocator().getClientIpv6()); assertEquals("0000:0000:0000:0000:0000:FFFF:0000:0000", sqlquery.getSessionLocator().getServerIpv6()); @@ -725,7 +725,7 @@ public void testfilterAccessor() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"jobConfig\":{\"type\":\"IMPORT\",\"loadConfig\":{\"schemaJson\":\"{\\n}\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/mydataset\\/tables\\/oldtable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-09-06T05:42:28.990Z\",\"startTime\":\"2022-09-06T05:42:29.270Z\",\"endTime\":\"2022-09-06T05:42:30.621Z\",\"loadStats\":{\"totalOutputBytes\":\"216\"},\"totalSlotMs\":\"103\",\"reservationUsage\":[{\"name\":\"default-pipeline\",\"slotMs\":\"103\"}]}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-eovwo0dsdv8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"us-central1\"}},\"timestamp\":\"2022-09-06T05:42:30.670452Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1662442948990-project-sccd:bquxjob_29acf1c6_18311523980\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-09-06T05:42:31.078574953Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("user@test.com", sqlquery.getAccessor().getDbUser()); assertEquals("project-sccd_bigquery.googleapis.com", sqlquery.getAccessor().getServerHostName()); assertEquals("BigQuery(GCP)", sqlquery.getAccessor().getDbProtocol()); @@ -743,7 +743,7 @@ public void testfilterTimstamp() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"jobConfig\":{\"type\":\"IMPORT\",\"loadConfig\":{\"schemaJson\":\"{\\n}\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/mydataset\\/tables\\/oldtable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-09-06T05:42:28.990Z\",\"startTime\":\"2022-09-06T05:42:29.270Z\",\"endTime\":\"2022-09-06T05:42:30.621Z\",\"loadStats\":{\"totalOutputBytes\":\"216\"},\"totalSlotMs\":\"103\",\"reservationUsage\":[{\"name\":\"default-pipeline\",\"slotMs\":\"103\"}]}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-eovwo0dsdv8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"us-central1\"}},\"timestamp\":\"2022-09-06T05:42:30.670452Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1662442948990-project-sccd:bquxjob_29acf1c6_18311523980\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-09-06T05:42:31.078574953Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals(Long.parseLong("1662442950670"), sqlquery.getTime().getTimstamp()); assertEquals(0, sqlquery.getTime().getMinDst()); assertEquals(0, sqlquery.getTime().getMinOffsetFromGMT()); @@ -757,7 +757,7 @@ public void testfilterDataConstruct() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/105.0.0.0 Safari\\/537.36,gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_29acf1c6_18311523980\",\"jobConfig\":{\"type\":\"IMPORT\",\"loadConfig\":{\"schemaJson\":\"{\\n}\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/mydataset\\/tables\\/oldtable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-09-06T05:42:28.990Z\",\"startTime\":\"2022-09-06T05:42:29.270Z\",\"endTime\":\"2022-09-06T05:42:30.621Z\",\"loadStats\":{\"totalOutputBytes\":\"216\"},\"totalSlotMs\":\"103\",\"reservationUsage\":[{\"name\":\"default-pipeline\",\"slotMs\":\"103\"}]}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-eovwo0dsdv8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"us-central1\"}},\"timestamp\":\"2022-09-06T05:42:30.670452Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1662442948990-project-sccd:bquxjob_29acf1c6_18311523980\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-09-06T05:42:31.078574953Z\"}"; Collection events = getEvents(gcpString2); final JsonObject BigqueryJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertEquals("create table", sqlquery.getData().getConstruct().sentences.get(0).getVerb()); assertEquals("collection", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getType()); assertEquals("oldtable", sqlquery.getData().getConstruct().sentences.get(0).getObjects().get(0).getName()); diff --git a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/ParserTest.java b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/ParserTest.java index 62d75f9fe..44565f2e2 100644 --- a/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/ParserTest.java +++ b/filter-plugin/logstash-filter-pubsub-bigquery-guardium/src/test/java/com/ibm/guardium/bigquery/ParserTest.java @@ -21,7 +21,7 @@ import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -31,7 +31,7 @@ public class ParserTest { @Test public void testParseRecord() { - Record record = Parser.parseRecord(bigQueryJson); + UCRecord record = Parser.parseRecord(bigQueryJson); assertEquals("user@test.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); assertNotNull(record.getAccessor()); @@ -44,7 +44,7 @@ public void testParseRecord() { public void testParse1RecordWithInsertStatement() { final String gcpString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.86\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_60b6e75c_1804a2534f5\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_60b6e75c_1804a2534f5\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"insert into empDetails34(id, name, lastname) VALUES (88, (SELECT username FROM userdetail where userid =1), (SELECT username FROM userdetail where userid =1));\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/empDetails\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-21T03:24:25.024Z\",\"startTime\":\"2022-04-21T03:24:25.152Z\",\"endTime\":\"2022-04-21T03:24:26.960Z\",\"queryStats\":{\"totalProcessedBytes\":\"50\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/empDetails\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"3854\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"31xgemde7o3\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T03:24:26.966454Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650511465024-project-sccd:bquxjob_60b6e75c_1804a2534f5\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-21T03:24:27.203011948Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpString).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertEquals("user@test.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); assertNotNull(record.getAccessor()); @@ -57,7 +57,7 @@ public void testParse1RecordWithInsertStatement() { public void testParse2Record() { final String gcpString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{\"code\":5,\"message\":\"syntax error\"},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.186.28\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_749ce0d9_1803b9d5d2a\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_749ce0d9_1803b9d5d2a\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"select *,userid FROM `project-sccd.BigQueryQADS.userdetail` LIMIT 465\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_f1bc17f8c4019d144c46cb14c6a5d1451b89feaf\\/tables\\/anon385493efef366d215281cd21b5dd6059410a48af\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-18T07:41:17.504Z\",\"startTime\":\"2022-04-18T07:41:17.626Z\",\"endTime\":\"2022-04-18T07:41:17.667Z\",\"queryStats\":{\"cacheHit\":true}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"tewhbneqxfpr\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-18T07:41:17.671191Z\",\"severity\":\"ERROR\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650267677504-project-sccd:bquxjob_749ce0d9_1803b9d5d2a\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-18T07:41:18.104584861Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpString).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertEquals("user@test.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); assertNotNull(record.getAccessor()); @@ -70,7 +70,7 @@ public void testParse2Record() { public void testParse4Record() { final String gcpString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.26\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6d102561_1803c9b2b23\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6d102561_1803c9b2b23\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"insert into `project-sccd.BigQueryQADS.empDetails` VALUES (4, (SELECT username FROM `project-sccd.BigQueryQADS.userdetail` where userid = 1), (SELECT username FROM `project-sccd.BigQueryQADS.userdetail` where userid = 1));\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/empDetails\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-18T12:18:31.782Z\",\"startTime\":\"2022-04-18T12:18:31.892Z\",\"endTime\":\"2022-04-18T12:18:33.810Z\",\"queryStats\":{\"totalProcessedBytes\":\"50\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/empDetails\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"3938\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-u8hckqeptdqh\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-18T12:18:33.816462Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650284311782-project-sccd:bquxjob_6d102561_1803c9b2b23\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-18T12:18:34.588366717Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpString).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertEquals("user@test.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); assertNotNull(record.getAccessor()); @@ -83,7 +83,7 @@ public void testParse4Record() { public void testParseCreateRecord() { final String gcpStringCreate = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.86\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_787f3164_1804a2c3db5\",\"metadata\":{\"jobInsertion\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobStats\":{\"createTime\":\"2022-04-21T03:32:06.081Z\",\"startTime\":\"2022-04-21T03:32:06.185Z\",\"queryStats\":{}},\"jobConfig\":{\"queryConfig\":{\"priority\":\"QUERY_INTERACTIVE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/testOne\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"query\":\"create table `project-sccd.BigQueryQADS.testOne` (\\r\\n SingerId INT64 NOT NULL,\\r\\n FirstName STRING(1024),\\r\\n LastName STRING(1024),\\r\\n BirthDate DATE\\r\\n)\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"CREATE_TABLE\"},\"type\":\"QUERY\"},\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_787f3164_1804a2c3db5\"}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-wq3ig5dhf0p\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T03:32:06.236284Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650511926081-project-sccd:bquxjob_787f3164_1804a2c3db5\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T03:32:06.413809027Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpStringCreate).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertEquals("user@test.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); assertNotNull(record.getAccessor()); @@ -95,7 +95,7 @@ public void testParseCreateRecord() { public void testParseCreateScemaRecord() { final String gcpStringCreate = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.188.239\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7f9a933_1804a4c89b1\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7f9a933_1804a4c89b1\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"create schema `BigQueryQADSOne` \",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_SCHEMA\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-21T04:07:22.709Z\",\"startTime\":\"2022-04-21T04:07:22.789Z\",\"endTime\":\"2022-04-21T04:07:23.299Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"4g9i1ed9705\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T04:07:23.311914Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650514042709-project-sccd:bquxjob_7f9a933_1804a4c89b1\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-21T04:07:24.294332675Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpStringCreate).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertEquals("user@test.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); assertNotNull(record.getAccessor()); @@ -104,7 +104,7 @@ public void testParseCreateScemaRecord() { @Test public void testParseSessionLocator() { - Record record = Parser.parseRecord(bigQueryJson); + UCRecord record = Parser.parseRecord(bigQueryJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", actual.getServerIp()); @@ -115,7 +115,7 @@ public void testParseSessionLocator() { @Test public void testParseAccessor() { - Record record = Parser.parseRecord(bigQueryJson); + UCRecord record = Parser.parseRecord(bigQueryJson); Accessor actual = record.getAccessor(); assertNotNull(record.getAccessor()); assertEquals("project-sccd:Bigquerydataset_M_15Apr", actual.getServiceName()); @@ -146,7 +146,7 @@ public void testParseSQL() { public void testParse1Event() { final String gcpString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.214\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_4b8557f_1805e3a6c28\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_4b8557f_1805e3a6c28\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"insert into `project-sccd.BigQueryQADS.empDetails` (id, name, lastname)VALUES (48, (SELECT username FROM `project-sccd.BigQueryQADS.userdetail` where userid =1), (SELECT username FROM `project-sccd.BigQueryQADS.userdetail` where userid =1));\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/empDetails\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-25T01:00:04.187Z\",\"startTime\":\"2022-04-25T01:00:04.330Z\",\"endTime\":\"2022-04-25T01:00:05.979Z\",\"queryStats\":{\"totalProcessedBytes\":\"50\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/empDetails\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"2472\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"of6x48e5kcsr\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-25T01:00:05.984535Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650848404187-project-sccd:bquxjob_4b8557f_1805e3a6c28\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-25T01:00:06.377547135Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpString).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertNotNull(record); } @@ -154,7 +154,7 @@ public void testParse1Event() { public void testParse2Event() { final String gcpString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.214\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_17cc4127_1805e3c4bd9\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_17cc4127_1805e3c4bd9\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"create table `project-sccd.BigQueryQADS.userdetailQWO1` (\\r\\n SingerId INT64 NOT NULL,\\r\\n FirstName STRING(1024),\\r\\n LastName STRING(1024),\\r\\n BirthDate DATE\\r\\n);\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetailQWO1\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-25T01:02:07.219Z\",\"startTime\":\"2022-04-25T01:02:07.347Z\",\"endTime\":\"2022-04-25T01:02:07.514Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"jf8vo7e9uyw8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-25T01:02:07.523605Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650848527219-project-sccd:bquxjob_17cc4127_1805e3c4bd9\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-25T01:02:07.925194980Z\"}"; final JsonObject bigQueryJson1 = JsonParser.parseString(gcpString).getAsJsonObject(); - Record record = Parser.parseRecord(bigQueryJson1); + UCRecord record = Parser.parseRecord(bigQueryJson1); assertNotNull(record); } @@ -162,7 +162,7 @@ public void testParse2Event() { public void testParseRecordSessionLocatorwithIPv6() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"2409:4064:2291:455c:e189:21f3:2d20:6ec5\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobChange\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); assertEquals("2409:4064:2291:455c:e189:21f3:2d20:6ec5", sqlquery.getSessionLocator().getClientIpv6()); assertEquals(-1, sqlquery.getSessionLocator().getClientPort()); @@ -174,7 +174,7 @@ public void testParseRecordSessionLocatorwithIPv6() { public void testParseRecordFullSql() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.81\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobChange\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); assertEquals( "insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email) VALUES('36','Anand', 'Kumar', 'user@test.com')", @@ -185,7 +185,7 @@ public void testParseRecordFullSql() { public void testParseRecordException() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{},\"requestMetadata\":{\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/97.0.4692.71 Safari\\/537.36 Edg\\/97.0.1072.62,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_51029f00_17e8b285ab4\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_51029f00_17e8b285ab4\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"select\\r\\nfrom project-sccd.BigQueryQADS.empDetails LIMIT 1000;\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobStatus\":{\"jobState\":\"DONE\",\"errorResult\":{\"code\":3,\"message\":\"Syntax error: SELECT list must not be empty at [1:8]\"},\"errors\":[{\"code\":3,\"message\":\"Syntax error: SELECT list must not be empty at [1:8]\"}]},\"jobStats\":{\"createTime\":\"2022-01-24T08:16:21.691Z\",\"startTime\":\"2022-01-24T08:16:21.713Z\",\"endTime\":\"2022-01-24T08:16:21.713Z\",\"queryStats\":{}}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"qd0pm8dxm7o\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-01-24T08:16:21.766081Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1643012181691-project-sccd:bquxjob_51029f00_17e8b285ab4\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-01-24T08:16:21.984993013Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); assertEquals("SQL_ERROR", sqlquery.getException().getExceptionTypeId()); assertEquals("Syntax error: SELECT list must not be empty at [1:8]", sqlquery.getException().getDescription()); @@ -197,7 +197,7 @@ public void testParseRecordException() { public void testParseRecordSessionLocatorWithIPv4() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.81\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobInsertion\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); assertEquals(-1, sqlquery.getSessionLocator().getServerPort()); assertEquals("0.0.0.0", sqlquery.getSessionLocator().getServerIp()); @@ -210,7 +210,7 @@ public void testParseRecordSessionLocatorWithIPv4() { public void teststatementTypeParseRecordMetaData1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.81\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobInsertion\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERTED\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -219,7 +219,7 @@ public void teststatementTypeParseRecordMetaData1() { public void teststatementTypeParseRecordMetaData2() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"2409:4064:2291:455c:e189:21f3:2d20:6ec5\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobChange\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -228,7 +228,7 @@ public void teststatementTypeParseRecordMetaData2() { public void testParseRecordDataTest() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.81\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobChange\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); assertEquals( "insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email) VALUES('36','Anand', 'Kumar', 'user@test.com')", @@ -241,7 +241,7 @@ public void testParseRecordDataTest() { public void testParseRecordDataTest1() { final String sql = "{ \"protoPayload\": { \"@type\": \"type.googleapis.com/google.cloud.audit.AuditLog\", \"status\": {}, \"authenticationInfo\": { \"principalEmail\": \"user@test.com\" }, \"requestMetadata\": { \"callerIp\": \"2409:4070:2d47:fba8:5d1d:ab58:77c7:eac\", \"callerSuppliedUserAgent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36,gzip(gfe)\", \"requestAttributes\": {}, \"destinationAttributes\": {} }, \"serviceName\": \"bigquery.googleapis.com\", \"methodName\": \"google.cloud.bigquery.v2.TableService.DeleteTable\", \"authorizationInfo\": [ { \"resource\": \"projects/project-sccd/datasets/mydataset/tables/myothertable\", \"permission\": \"bigquery.tables.delete\", \"granted\": true, \"resourceAttributes\": {} } ], \"resourceName\": \"projects/project-sccd/datasets/mydataset/tables/myothertable\", \"metadata\": { \"@type\": \"type.googleapis.com/google.cloud.audit.BigQueryAuditMetadata\", \"tableDeletion\": { \"reason\": \"TABLE_DELETE_REQUEST\" } } }, \"insertId\": \"-9zgy50ddtxj\", \"resource\": { \"type\": \"bigquery_dataset\", \"labels\": { \"project_id\": \"project-sccd\", \"dataset_id\": \"mydataset\" } }, \"timestamp\": \"2022-11-07T06:39:21.719124Z\", \"severity\": \"NOTICE\", \"logName\": \"projects/project-sccd/logs/cloudaudit.googleapis.com%2Factivity\", \"receiveTimestamp\": \"2022-11-07T06:39:21.947805447Z\" }"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -375,7 +375,7 @@ public void testSpecialChar() { public void testParseRecordAccessor() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.81\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/94.0.4606.81 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"metadata\":{\"jobChange\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/big_Query_Data_Set\\/tables\\/person\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"statementType\":\"INSERT\",\"query\":\"insert into project-sccd.big_Query_Data_Set.person (id, first_name, last_name, email)\\r\\nVALUES('36','Anand', 'Kumar', 'user@test.com')\",\"priority\":\"QUERY_INTERACTIVE\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_77ace2e_17ce89f4992\",\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobStats\":{\"queryStats\":{},\"createTime\":\"2021-11-04T01:45:51.435Z\",\"startTime\":\"2021-11-04T01:45:51.532Z\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-aj7t5te11j3t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2021-11-04T01:45:51.570238Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1635990351435-project-sccd:bquxjob_77ace2e_17ce89f4992\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2021-11-04T01:45:51.713484313Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); assertEquals(ApplicationConstants.UNKOWN_STRING, sqlquery.getAccessor().getClient_mac()); assertEquals(ApplicationConstants.UNKOWN_STRING, sqlquery.getAccessor().getClientHostName()); @@ -399,7 +399,7 @@ public void testParseRecordAccessor() { public void testParseRecordMetaData1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.217\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStats\":{\"createTime\":\"2022-04-25T07:03:18.503Z\",\"queryStats\":{\"cacheHit\":true},\"endTime\":\"2022-04-25T07:03:18.675Z\",\"startTime\":\"2022-04-25T07:03:18.571Z\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"query\":\"select id from User_detail_table where first_name ='ram'\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonf1d43bd75cf4f8e9d5accd2dc18c8530e550cc66\",\"createDisposition\":\"CREATE_IF_NEEDED\"},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\"},\"after\":\"DONE\"}}},\"insertId\":\"-5jqjw5ebgxbc\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\"}},\"timestamp\":\"2022-04-25T07:03:18.719456Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650870198503-project-sccd:bquxjob_633b0f50_1805f8559cc\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-25T07:03:18.964466140Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -408,7 +408,7 @@ public void testParseRecordMetaData1() { public void testParseRecordMetaData2() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.217\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStats\":{\"createTime\":\"2022-04-25T07:03:18.503Z\",\"queryStats\":{\"cacheHit\":true},\"endTime\":\"2022-04-25T07:03:18.675Z\",\"startTime\":\"2022-04-25T07:03:18.571Z\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"query\":\"select a.id,a.name,b.salary FROM project-sccd.Bigquerydataset_M_15Apr.User_detail_table where first_name ='ram'\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonf1d43bd75cf4f8e9d5accd2dc18c8530e550cc66\",\"createDisposition\":\"CREATE_IF_NEEDED\"},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\"},\"after\":\"DONE\"}}},\"insertId\":\"-5jqjw5ebgxbc\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-25T07:03:18.719456Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650870198503-project-sccd:bquxjob_633b0f50_1805f8559cc\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-25T07:03:18.964466140Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -417,7 +417,7 @@ public void testParseRecordMetaData2() { public void testParseRecordMetaData3() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.217\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStats\":{\"createTime\":\"2022-04-25T07:03:18.503Z\",\"queryStats\":{\"cacheHit\":true},\"endTime\":\"2022-04-25T07:03:18.675Z\",\"startTime\":\"2022-04-25T07:03:18.571Z\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"query\":\"select * from name where first_name ='ram'\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonf1d43bd75cf4f8e9d5accd2dc18c8530e550cc66\",\"createDisposition\":\"CREATE_IF_NEEDED\"},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\"},\"after\":\"DONE\"}}},\"insertId\":\"-5jqjw5ebgxbc\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-25T07:03:18.719456Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650870198503-project-sccd:bquxjob_633b0f50_1805f8559cc\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-25T07:03:18.964466140Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -426,7 +426,7 @@ public void testParseRecordMetaData3() { public void testParseRecordMetaData4() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.41\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3a72f6d8_180497e260f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableCreation\":{\"table\":{\"view\":{\"query\":\"select * from `project-sccd.BigQueryQADS.userdetail` LIMIT 1000\",\"destinationTable\":{},\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"defaultDataset\":{},\"queryPriority\":\"QUERY_INTERACTIVE\"}}}}},\"insertId\":\"-3v9ahdd5axg\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T00:21:57.986466Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650500517888-project-sccd:bquxjob_3a72f6d8_180497e260f\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T00:21:58.513956910Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -435,7 +435,7 @@ public void testParseRecordMetaData4() { public void testParseRecordMetaData5() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.41\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3a72f6d8_180497e260f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableChange\":{\"table\":{\"view\":{\"query\":\"select * from `project-sccd.BigQueryQADS.userdetail` LIMIT 1000\",\"destinationTable\":{},\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"defaultDataset\":{},\"queryPriority\":\"QUERY_INTERACTIVE\"}}}}},\"insertId\":\"-3v9ahdd5axg\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T00:21:57.986466Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650500517888-project-sccd:bquxjob_3a72f6d8_180497e260f\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T00:21:58.513956910Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -444,7 +444,7 @@ public void testParseRecordMetaData5() { public void testParseRecordMetaData6() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.217\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStats\":{\"createTime\":\"2022-04-25T07:03:18.503Z\",\"queryStats\":{\"cacheHit\":true},\"endTime\":\"2022-04-25T07:03:18.675Z\",\"startTime\":\"2022-04-25T07:03:18.571Z\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"queryConfig\":{},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_633b0f50_1805f8559cc\"},\"after\":\"DONE\"}}},\"insertId\":\"-5jqjw5ebgxbc\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-25T07:03:18.719456Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650870198503-project-sccd:bquxjob_633b0f50_1805f8559cc\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-25T07:03:18.964466140Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -453,7 +453,7 @@ public void testParseRecordMetaData6() { public void testParseRecordMetaData7() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.41\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.84 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3a72f6d8_180497e260f\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableChange\":{\"table\":{\"view\":{\"queryed\":\"select * from `project-sccd.BigQueryQADS.userdetail` LIMIT 1000\",\"destinationTable\":{},\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"defaultDataset\":{},\"queryPriority\":\"QUERY_INTERACTIVE\"}}}}},\"insertId\":\"-3v9ahdd5axg\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-21T00:21:57.986466Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1650500517888-project-sccd:bquxjob_3a72f6d8_180497e260f\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-21T00:21:58.513956910Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -462,7 +462,7 @@ public void testParseRecordMetaData7() { public void testParseRecordMetaDataWithSubqueryStatement() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_406e1838_18073d7b078\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobInsertion\":{\"reason\":\"JOB_INSERT_REQUEST\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_406e1838_18073d7b078\",\"jobStats\":{\"startTime\":\"2022-04-29T05:45:43.280Z\",\"endTime\":\"2022-04-29T05:45:43.540Z\",\"createTime\":\"2022-04-29T05:45:43.222Z\",\"totalSlotMs\":\"60\",\"queryStats\":{\"outputRowCount\":\"2\",\"totalBilledBytes\":\"10485760\",\"totalProcessedBytes\":\"125\",\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\"],\"billingTier\":1}},\"jobConfig\":{\"queryConfig\":{\"statementType\":\"SELECT\",\"query\":\"select *\\r\\n from `project-sccd.BigQueryE2E.Employee`\\r\\n WHERE ID IN (CREATE ID\\r\\n FROM `project-sccd.BigQueryE2E.Employe`\\r\\n WHERE NAME = \\\"sandeep\\\") ;\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon9ad0e1ba594d00c80e88825d0ef7a43d6ad4ade6\"},\"type\":\"QUERY\"},\"jobStatus\":{\"jobState\":\"DONE\"}}}}},\"insertId\":\"ut3s3ue10omr\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-29T05:45:43.586592Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651211143222-project-sccd:bquxjob_406e1838_18073d7b078\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-29T05:45:44.594672938Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -471,7 +471,7 @@ public void testParseRecordMetaDataWithSubqueryStatement() { public void testParseRecordMetaDataWithAlter() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_1b7bfe43_18073c18a2f\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_1b7bfe43_18073c18a2f\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"\\r\\nalter\\r\\n TABLE `BigQueryE2E.Coude` ADD COLUMN phone string\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"ALTER_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-29T05:21:31.624Z\",\"startTime\":\"2022-04-29T05:21:31.736Z\",\"endTime\":\"2022-04-29T05:21:31.895Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-bwxxfode8jy\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-29T05:21:31.900736Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651209691624-project-sccd:bquxjob_1b7bfe43_18073c18a2f\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-29T05:21:32.907043240Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -480,7 +480,7 @@ public void testParseRecordMetaDataWithAlter() { public void testParseRecordMetaDataWithUpdate() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"122.177.51.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18f056f4_17fd576596c\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobConfig\":{\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"query\":\"UPDATE project-sccd.BigQueryQADS.userdetail set userid=22 where username=\\\"swe\\\";\\r\\n\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18f056f4_17fd576596c\",\"jobStats\":{\"startTime\":\"2022-03-29T11:36:16.897Z\",\"createTime\":\"2022-03-29T11:36:16.669Z\",\"queryStats\":{}}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-vmku1oe3ayk1\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-03-29T11:36:16.965770Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648553776669-project-sccd:bquxjob_18f056f4_17fd576596c\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-29T11:36:17.218515746Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -488,7 +488,7 @@ public void testParseRecordMetaDataWithUpdate() { public void testParseRecordMetaDataWithUpdate2() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"122.177.51.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18f056f4_17fd576596c\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobConfig\":{\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"query\":\"UPDATE BigQueryQADS.userdetail set userid=22 where username=\\\"swe\\\";\\r\\n\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18f056f4_17fd576596c\",\"jobStats\":{\"startTime\":\"2022-03-29T11:36:16.897Z\",\"createTime\":\"2022-03-29T11:36:16.669Z\",\"queryStats\":{}}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-vmku1oe3ayk1\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-03-29T11:36:16.965770Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648553776669-project-sccd:bquxjob_18f056f4_17fd576596c\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-29T11:36:17.218515746Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -496,7 +496,7 @@ public void testParseRecordMetaDataWithUpdate2() { public void testParseRecordMetaDataWithUpdate3() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"122.177.51.80\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.51 Safari\\/537.36 Edg\\/99.0.1150.39,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18f056f4_17fd576596c\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobStatus\":{\"jobState\":\"RUNNING\"},\"jobConfig\":{\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/userdetail\",\"query\":\"UPDATE BigQueryQADS.Order set userid=22 where username=\\\"swe\\\";\\r\\n\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"},\"type\":\"QUERY\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18f056f4_17fd576596c\",\"jobStats\":{\"startTime\":\"2022-03-29T11:36:16.897Z\",\"createTime\":\"2022-03-29T11:36:16.669Z\",\"queryStats\":{}}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-vmku1oe3ayk1\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-03-29T11:36:16.965770Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1648553776669-project-sccd:bquxjob_18f056f4_17fd576596c\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-29T11:36:17.218515746Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -504,7 +504,7 @@ public void testParseRecordMetaDataWithUpdate3() { public void testParseRecordMetaDataWithDelete() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5ae63171_18073daa7bd\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5ae63171_18073daa7bd\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"delete from `project-sccd.BigQueryE2E.Employee` where name = \\\"xyz\\\"\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DELETE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-29T05:48:57.695Z\",\"startTime\":\"2022-04-29T05:48:57.918Z\",\"endTime\":\"2022-04-29T05:48:59.731Z\",\"queryStats\":{\"totalProcessedBytes\":\"125\",\"totalBilledBytes\":\"10485760\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\"]},\"totalSlotMs\":\"2327\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-e5daece16299\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-29T05:48:59.737100Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651211337695-project-sccd:bquxjob_5ae63171_18073daa7bd\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-29T05:49:00.009896930Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -513,7 +513,7 @@ public void testParseRecordMetaDataWithDelete() { public void testParseRecordMetaDataWithDelete1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5ae63171_18073daa7bd\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5ae63171_18073daa7bd\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"delete from BigQueryE2E.ordersd where name = \\\"xyz\\\"\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DELETE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-29T05:48:57.695Z\",\"startTime\":\"2022-04-29T05:48:57.918Z\",\"endTime\":\"2022-04-29T05:48:59.731Z\",\"queryStats\":{\"totalProcessedBytes\":\"125\",\"totalBilledBytes\":\"10485760\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Employee\"]},\"totalSlotMs\":\"2327\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-e5daece16299\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-29T05:48:59.737100Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651211337695-project-sccd:bquxjob_5ae63171_18073daa7bd\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-29T05:49:00.009896930Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -522,7 +522,7 @@ public void testParseRecordMetaDataWithDelete1() { public void testParseRecordMetaDataWithExceptDistinct() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.241\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_51b11d3b_180ac9c27ed\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_51b11d3b_180ac9c27ed\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"SELECT region_id FROM SampleBigquery.regions \\r\\nEXCEPT DISTINCT\\r\\nSELECT region_id FROM SampleBigquery.countries\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anona2a8ae949a97b063a96c0eeb112bc53ddc3a6a30\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-10T06:19:13.448Z\",\"startTime\":\"2022-05-10T06:19:13.556Z\",\"endTime\":\"2022-05-10T06:19:14.080Z\",\"queryStats\":{\"totalProcessedBytes\":\"224\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/regions\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mvied\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviewed\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviddded\"],\"referencedViews\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mvied\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviewed\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviddded\"]},\"totalSlotMs\":\"13189\"}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-hgriqaespyod\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-10T06:19:14.122118Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652163553448-project-sccd:bquxjob_51b11d3b_180ac9c27ed\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-10T06:19:14.281073815Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -531,7 +531,7 @@ public void testParseRecordMetaDataWithExceptDistinct() { public void testParseRecordMetaDataWithIntersectDistinct() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.241\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5f531df8_180ac9c3d3b\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5f531df8_180ac9c3d3b\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"SELECT region_id FROM `project-sccd.SampleBigquery.regions` \\r\\nINTERSECT DISTINCT\\r\\nSELECT region_id FROM `project-sccd.SampleBigquery.countries`\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon0a064c6421481e832e19f523be937ae60d87f83f\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-10T06:19:18.926Z\",\"startTime\":\"2022-05-10T06:19:19.038Z\",\"endTime\":\"2022-05-10T06:19:19.653Z\",\"queryStats\":{\"totalProcessedBytes\":\"224\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/regions\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviddded\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mvied\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviewed\"],\"referencedViews\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviddded\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mvied\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/Mviewed\"],\"outputRowCount\":\"4\"},\"totalSlotMs\":\"16159\"}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"yosxetecxvbu\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-05-10T06:19:19.703049Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652163558926-project-sccd:bquxjob_5f531df8_180ac9c3d3b\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-10T06:19:20.676685292Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -540,7 +540,7 @@ public void testParseRecordMetaDataWithIntersectDistinct() { public void testParseRecordMetaDataWithTruncate() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_266c3f83_180740997f2\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_266c3f83_180740997f2\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"truncate table BigQueryQADS.TestPrf\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/TestPrf\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"TRUNCATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-29T06:40:13.884Z\",\"startTime\":\"2022-04-29T06:40:14.148Z\",\"endTime\":\"2022-04-29T06:40:15.057Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/TestPrf\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"i1qxmudzz1z\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-29T06:40:15.062826Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651214413884-project-sccd:bquxjob_266c3f83_180740997f2\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-29T06:40:15.950274800Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -549,7 +549,7 @@ public void testParseRecordMetaDataWithTruncate() { public void testParseRecordMetaDataWithDrop() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.11\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3b65ef0_180740a3dd1\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3b65ef0_180740a3dd1\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"drop table BigQueryE2E.newtable;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryQADS\\/tables\\/TestProf\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DROP_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-29T06:40:56.208Z\",\"startTime\":\"2022-04-29T06:40:56.280Z\",\"endTime\":\"2022-04-29T06:40:56.415Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-s0ioxve1d2k5\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-29T06:40:56.419841Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651214456208-project-sccd:bquxjob_3b65ef0_180740a3dd1\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-29T06:40:56.702975881Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -558,7 +558,7 @@ public void testParseRecordMetaDataWithDrop() { public void testParseRecordMetaDataWithJoin() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.166.232\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6442c9b3_18079d155ab\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6442c9b3_18079d155ab\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"SELECT R.region_name,COUNT(C.region_id) AS COUNT FROM \\r\\n SampleBigquery.regions R \\r\\nINNER Join SampleBigquery.countries C ON R.region_id = C.region_id\\r\\nGROUP BY ROLLUP(R.region_name)\\r\\nHaving count > 1\\r\\nORDER BY R.region_name\\r\\n\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon11e60e3ca775a0fb8515dd4343f5aa1308472d16\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T09:36:31.639Z\",\"startTime\":\"2022-04-30T09:36:31.752Z\",\"endTime\":\"2022-04-30T09:36:32.286Z\",\"queryStats\":{\"totalProcessedBytes\":\"272\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/regions\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/MviewOp\"],\"referencedViews\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/MviewOp\"],\"outputRowCount\":\"5\"},\"totalSlotMs\":\"287\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-il8apme37irb\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-30T09:36:32.293359Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651311391639-project-sccd:bquxjob_6442c9b3_18079d155ab\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T09:36:32.324985061Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -567,7 +567,7 @@ public void testParseRecordMetaDataWithJoin() { public void testParseRecordMetaDataWithClauses() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.166.232\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6442c9b3_18079d155ab\",\"metadata\":{\"jobInsertion\":{\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6442c9b3_18079d155ab\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"SELECT R.region_name,COUNT(C.region_id) AS COUNT FROM `project-sccd.SampleBigquery.regions` R \\r\\nINNER Join `project-sccd.SampleBigquery.countries` C ON R.region_id = C.region_id\\r\\nGROUP BY ROLLUP(R.region_name)\\r\\nHaving count > 1\\r\\nORDER BY R.region_name\\r\\n;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon11e60e3ca775a0fb8515dd4343f5aa1308472d16\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T09:36:31.639Z\",\"startTime\":\"2022-04-30T09:36:31.752Z\",\"endTime\":\"2022-04-30T09:36:32.286Z\",\"queryStats\":{\"totalProcessedBytes\":\"272\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/regions\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\",\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/MviewOp\"],\"referencedViews\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/MviewOp\"],\"outputRowCount\":\"5\"},\"totalSlotMs\":\"287\"}},\"reason\":\"JOB_INSERT_REQUEST\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-il8apme37irl\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T09:36:32.326943Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651311391639-project-sccd:bquxjob_6442c9b3_18079d155ab\",\"producer\":\"bigquery.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-30T09:36:32.885700298Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -576,7 +576,7 @@ public void testParseRecordMetaDataWithClauses() { public void testParseRecordMetaDataWithWindow() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_1d6e8072_180796104fe\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_1d6e8072_180796104fe\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"SELECT\\r\\n fileName AS unique_id,\\r\\n historyStatus AS latest_status,\\r\\n lastUpdatedTimestamp AS last_update,\\r\\n ROW_NUMBER() OVER (PARTITION BY fileName ORDER BY lastUpdatedTimestamp DESC) AS row_number\\r\\nFROM\\r\\n `bigquery-public-data.fcc_political_ads.file_history`\\r\\nORDER BY\\r\\n 1,\\r\\n 3 DESC\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonbb0a98f2f0755bc674db7a4be07c8c60c902d8ac\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T07:33:51.770Z\",\"startTime\":\"2022-04-30T07:33:51.825Z\",\"endTime\":\"2022-04-30T07:34:01.119Z\",\"queryStats\":{\"totalProcessedBytes\":\"77340422\",\"totalBilledBytes\":\"77594624\",\"billingTier\":1,\"referencedTables\":[\"projects\\/bigquery-public-data\\/datasets\\/fcc_political_ads\\/tables\\/file_history\"],\"outputRowCount\":\"1553461\"},\"totalSlotMs\":\"25782\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-8l4nprekv0ao\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-30T07:34:01.123224Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651304031770-project-sccd:bquxjob_1d6e8072_180796104fe\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T07:34:01.213773282Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -585,7 +585,7 @@ public void testParseRecordMetaDataWithWindow() { public void testParseRecordMetaDataWithCFunction() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.86\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2d7bdc1e_180881e8685\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2d7bdc1e_180881e8685\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"create procedure ndjv.addfour(x INT64, y INT64)RETURNS FLOAT64 AS ((x + 4)\\/y);\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_FUNCTION\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-03T04:15:36.513Z\",\"startTime\":\"2022-05-03T04:15:36.607Z\",\"endTime\":\"2022-05-03T04:15:36.728Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"7s8zuqdr2w6\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-03T04:15:36.746227Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651551336513-project-sccd:bquxjob_2d7bdc1e_180881e8685\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-03T04:15:37.403816711Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -594,7 +594,7 @@ public void testParseRecordMetaDataWithCFunction() { public void testParseRecordMetaDataWithsnapsnot() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.71\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_23e17310_18078cf16a6\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_23e17310_18078cf16a6\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE SNAPSHOT TABLE dmldataset.mytablesnapshot\\r\\nCLONE `SampleBigquery.sampletable`\\r\\nOPTIONS(\\r\\n expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 48 HOUR),\\r\\n friendly_name=\\\"my_table_snapshot\\\",\\r\\n description=\\\"A table snapshot that expires in 2 days\\\",\\r\\n labels=[(\\\"org_unit\\\", \\\"development\\\")];\\r\\n)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/mytablesnapshot\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_SNAPSHOT_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T04:54:27.837Z\",\"startTime\":\"2022-04-30T04:54:27.978Z\",\"endTime\":\"2022-04-30T04:54:28.777Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/sampletable\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-lwotzxe2yzt5\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T04:54:28.786926Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651294467837-project-sccd:bquxjob_23e17310_18078cf16a6\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T04:54:29.552954383Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -603,7 +603,7 @@ public void testParseRecordMetaDataWithsnapsnot() { public void testParseRecordMetaDataWithView() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_35690086_18079124cc0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_35690086_18079124cc0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE procedure fdndndn.SampleBigquery.grouped(name, count) AS SELECT country_name, COUNT(*) as count\\r\\nFROM `SampleBigquery.countries.ebvhu`\\r\\ngroup by country_name;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/grouped\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_VIEW\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T06:07:52.881Z\",\"startTime\":\"2022-04-30T06:07:52.993Z\",\"endTime\":\"2022-04-30T06:07:53.167Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\"]}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"ajil5e3cncn\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-30T06:07:53.176764Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651298872881-project-sccd:bquxjob_35690086_18079124cc0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T06:07:53.869493480Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -612,7 +612,7 @@ public void testParseRecordMetaDataWithView() { public void testParseRecordMetaDataWithInsert() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/script_job_c3ac8b335ad20279f834ad7253dc56f9_11\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/script_job_c3ac8b335ad20279f834ad7253dc56f9_11\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT INTO SampleBigquery.ordertt.dhamu(country_id,country_name,region_id) VALUES ('HK','HongKong',3);\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T05:34:02.175Z\",\"startTime\":\"2022-04-30T05:34:02.275Z\",\"endTime\":\"2022-04-30T05:34:03.734Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"4173\",\"parentJobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_92ef175_18078f2af08\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"qxen09ef9llm\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-30T05:34:03.742265Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651296842175-project-sccd:script_job_c3ac8b335ad20279f834ad7253dc56f9_11\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T05:34:04.042222Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -621,7 +621,7 @@ public void testParseRecordMetaDataWithInsert() { public void testParseRecordMetaDataWithInsert1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/script_job_c3ac8b335ad20279f834ad7253dc56f9_11\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/script_job_c3ac8b335ad20279f834ad7253dc56f9_11\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT INTO `SampleBigquery.order`(country_id,country_name,region_id) VALUES ('HK','HongKong',3);\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-04-30T05:34:02.175Z\",\"startTime\":\"2022-04-30T05:34:02.275Z\",\"endTime\":\"2022-04-30T05:34:03.734Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/SampleBigquery\\/tables\\/countries\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"4173\",\"parentJobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_92ef175_18078f2af08\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"qxen09ef9llm\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-04-30T05:34:03.742265Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1651296842175-project-sccd:script_job_c3ac8b335ad20279f834ad7253dc56f9_11\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-04-30T05:34:04.042222Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -630,7 +630,7 @@ public void testParseRecordMetaDataWithInsert1() { public void testParseRecordMetaDataWithQualify() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.77.26\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6afbacb6_180b7a0e192\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6afbacb6_180b7a0e192\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"\\r\\nCREATE external table abcde.Call\\r\\n (\\r\\n x INT64 OPTIONS(description=\\\"An optional INTEGER field\\\"),\\r\\n y STRUCT<\\r\\n a ARRAY OPTIONS(description=\\\"A repeated STRING field\\\"),\\r\\n b BOOL\\r\\n >\\r\\n )\\r\\n OPTIONS(\\r\\n expiration_timestamp=TIMESTAMP \\\"2023-01-01 00:00:00 UTC\\\",\\r\\n description=\\\"a table that expires in 2023\\\",\\r\\n labels=[(\\\"org_unit\\\", \\\"development\\\")]\\r\\n )\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/abcde\\/tables\\/Call\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-12T09:36:55.922Z\",\"startTime\":\"2022-05-12T09:36:56.003Z\",\"endTime\":\"2022-05-12T09:36:56.159Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-3bl3igewbd5t\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-05-12T09:36:56.166002Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652348215922-project-sccd:bquxjob_6afbacb6_180b7a0e192\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-12T09:36:56.370481791Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -639,7 +639,7 @@ public void testParseRecordMetaDataWithQualify() { public void testParseRecordMetaDataWithInsertInt() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.86\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.41 Safari\\/537.36 Edg\\/101.0.1210.32,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7022cdce_180bc1ee161\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7022cdce_180bc1ee161\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"create table BigQueryE2E.Meenakshi(OrderID int,Customername string(100),CustomerID int);\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/Meenakshi\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-13T06:36:23.126Z\",\"startTime\":\"2022-05-13T06:36:23.207Z\",\"endTime\":\"2022-05-13T06:36:23.347Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"skvi3ae4rwdi\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-13T06:36:23.355228Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1652423783126-project-sccd:bquxjob_7022cdce_180bc1ee161\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-13T06:36:23.658333429Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -648,7 +648,7 @@ public void testParseRecordMetaDataWithInsertInt() { public void testParseRecordMetaDataWithselect() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.26\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.47,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7be5aa5c_180e149e407\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_7be5aa5c_180e149e407\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"SELECT * FROM `BigQueryE2E.order`;\\r\\nSELECT * FROM `BigQueryE2E.Coursed`;\\r\\nSELECT * FROM BigQueryE2E.Student_Coursed;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anoncefaa45dd9d115a8b55aa42f023cae5f90e752ee\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SCRIPT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-05-20T11:49:23.974Z\",\"startTime\":\"2022-05-20T11:49:24.041Z\",\"endTime\":\"2022-05-20T11:49:25.390Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"287t08ewy2na\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-05-20T11:49:25.393878Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1653047363974-project-sccd:bquxjob_7be5aa5c_180e149e407\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-20T11:49:25.526409913Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -657,7 +657,7 @@ public void testParseRecordMetaDataWithselect() { public void testParseRecordMetaData() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.131\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3523f7d7_180fb2d55fc\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon7a5d84424b32d0ff95bb57bc8ae8c3bf55b424ac\",\"query\":\"SELECT A.name, item\\r\\nFROM\\r\\nUNNEST(\\r\\n[\\r\\nSTRUCT(\\r\\n'first' AS name,\\r\\n[1, 2, 3, 4] AS items),\\r\\nSTRUCT(\\r\\n'second' AS name,\\r\\n[] AS items)]) AS A\\r\\nCROSS JOIN\\r\\nA.items AS item\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3523f7d7_180fb2d55fc\",\"jobStats\":{\"startTime\":\"2022-05-25T12:28:24.639Z\",\"createTime\":\"2022-05-25T12:28:24.623Z\",\"endTime\":\"2022-05-25T12:28:24.702Z\",\"queryStats\":{\"cacheHit\":true}}},\"after\":\"DONE\"}}},\"insertId\":\"3m8gume34x29\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-05-25T12:28:24.742150Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1653481704623-project-sccd:bquxjob_3523f7d7_180fb2d55fc\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-25T12:28:25.455584435Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -666,7 +666,7 @@ public void testParseRecordMetaData() { public void testParseRecordMetaDataUnnest() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.7.87\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3c410347_1810377dccc\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon3f6a9037a6e54b3e1953d443f8c5d437bd5369ba\",\"statementType\":\"SELECT\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"query\":\"SELECT ARRAY_AGG(DISTINCT x) AS array_agg FROM UNNEST([2, 1, -2, 3, -2, 1, 2]) AS x\"}},\"jobStats\":{\"queryStats\":{\"outputRowCount\":\"1\"},\"totalSlotMs\":\"456\",\"createTime\":\"2022-05-27T03:06:48.448Z\",\"startTime\":\"2022-05-27T03:06:48.465Z\",\"endTime\":\"2022-05-27T03:06:48.784Z\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3c410347_1810377dccc\"}}}},\"insertId\":\"gxq641e8wkm1\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-27T03:06:48.822741Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1653620808448-project-sccd:bquxjob_3c410347_1810377dccc\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-27T03:06:49.632553139Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -675,7 +675,7 @@ public void testParseRecordMetaDataUnnest() { public void testParseRecordMetaDataUnnest1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.86\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3f9feca3_180fecab4cb\",\"metadata\":{\"jobChange\":{\"job\":{\"jobStatus\":{\"jobState\":\"DONE\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3f9feca3_180fecab4cb\",\"jobStats\":{\"endTime\":\"2022-05-26T05:19:10.023Z\",\"totalSlotMs\":\"90\",\"queryStats\":{\"outputRowCount\":\"1\"},\"startTime\":\"2022-05-26T05:19:09.825Z\",\"createTime\":\"2022-05-26T05:19:09.810Z\"},\"jobConfig\":{\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonaa580b59aea559406f8e669d8941b8f0ffc3b12a\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\",\"query\":\"SELECT SUM(x) AS sum FROM UNNEST([]) AS x\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_TRUNCATE\"},\"type\":\"QUERY\"}},\"after\":\"DONE\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-m6ksu1e79wkd\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-26T05:19:10.052755Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1653542349810-project-sccd:bquxjob_3f9feca3_180fecab4cb\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-05-26T05:19:11.167821796Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -684,7 +684,7 @@ public void testParseRecordMetaDataUnnest1() { public void testParseRecordMetaDataUnnest2() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.202\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_4e862711_18125427ac7\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"writeDisposition\":\"WRITE_TRUNCATE\",\"statementType\":\"SELECT\",\"query\":\"SELECT ARRAY_AGG(DISTINCT x) AS array_agg FROM UNNEST([2, 1, -2, 3, -2, 1, 2]) AS x\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon3f6a9037a6e54b3e1953d443f8c5d437bd5369ba\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_4e862711_18125427ac7\",\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"queryStats\":{\"outputRowCount\":\"1\"},\"createTime\":\"2022-06-02T16:35:39.889Z\",\"startTime\":\"2022-06-02T16:35:39.922Z\",\"totalSlotMs\":\"112\",\"endTime\":\"2022-06-02T16:35:40.216Z\"}}}}},\"insertId\":\"tf038ue2sgei\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-02T16:35:40.268654Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1654187739889-project-sccd:bquxjob_4e862711_18125427ac7\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-02T16:35:40.292430920Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -693,7 +693,7 @@ public void testParseRecordMetaDataUnnest2() { public void testParseRecordMetaDataQuery() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.71\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_30ac3e17_1811eb9c2d7\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_30ac3e17_1811eb9c2d7\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"drop table `project-sccd.fruitsndvegetab`\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_SCHEMA\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-01T10:08:35.224Z\",\"startTime\":\"2022-06-01T10:08:35.294Z\",\"endTime\":\"2022-06-01T10:08:35.804Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-b3jeibell6s9\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-01T10:08:35.816547Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1654078115224-project-sccd:bquxjob_30ac3e17_1811eb9c2d7\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-01T10:08:36.557182078Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -702,7 +702,7 @@ public void testParseRecordMetaDataQuery() { public void testParseRecordMetaDataQueryDrop() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.77.26\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.61 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_15c2dc39_1811ed72661\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_15c2dc39_1811ed72661\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"drop table unnest.Customtable\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/testInfo\\/tables\\/Custom1\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DROP_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-01T10:37:07.441Z\",\"startTime\":\"2022-06-01T10:37:07.529Z\",\"endTime\":\"2022-06-01T10:37:07.703Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"502q0ue206ht\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-01T10:37:07.709635Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1654079827441-project-sccd:bquxjob_15c2dc39_1811ed72661\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-01T10:37:07.758524466Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -711,7 +711,7 @@ public void testParseRecordMetaDataQueryDrop() { public void testParseRecordMetaDataInsert() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.71\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.63 Safari\\/537.36 Edg\\/102.0.1245.39,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_75cbe4db_1815b0a1ae0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_75cbe4db_1815b0a1ae0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"insert fruitsndvegetables.Vegetable(Veg_name,Colour,Quantityinkilos) select * from unnest([('Potato','Brown',2), ('Tomato','Red',3)])\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-13T03:13:42.301Z\",\"startTime\":\"2022-06-13T03:13:42.421Z\",\"endTime\":\"2022-06-13T03:13:44.356Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\"],\"outputRowCount\":\"2\"},\"totalSlotMs\":\"3616\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"j5l39ie1zmq8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-13T03:13:44.362807Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655090022301-project-sccd:bquxjob_75cbe4db_1815b0a1ae0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-13T03:13:45.279820332Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -720,7 +720,7 @@ public void testParseRecordMetaDataInsert() { public void testParseRecordMetaDataInsert1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.131\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.63 Safari\\/537.36 Edg\\/102.0.1245.39,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5b52aac5_1815ceecc03\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5b52aac5_1815ceecc03\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT fruitsndvegetables.fruits VALUES('Orange','Orange',2), ('Lime','Green',4)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-13T12:03:07.557Z\",\"startTime\":\"2022-06-13T12:03:07.693Z\",\"endTime\":\"2022-06-13T12:03:11.431Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\"],\"outputRowCount\":\"2\"},\"totalSlotMs\":\"7409\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"suw39fe3809u\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-13T12:03:11.439106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655121787557-project-sccd:bquxjob_5b52aac5_1815ceecc03\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-13T12:03:11.751241089Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -729,7 +729,7 @@ public void testParseRecordMetaDataInsert1() { public void testParseRecordMetaDataDelete() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.51\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18dafcf6_1815926f205\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_18dafcf6_1815926f205\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"DELETE fruitsndvegetables.Vegetable\\r\\nWHERE Veg_name = 'Tomato'\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DELETE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-12T18:22:14.162Z\",\"startTime\":\"2022-06-12T18:22:14.436Z\",\"endTime\":\"2022-06-12T18:22:16.123Z\",\"queryStats\":{\"totalProcessedBytes\":\"420\",\"totalBilledBytes\":\"10485760\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\"]},\"totalSlotMs\":\"2771\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-31oof2e28xey\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-12T18:22:16.130406Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655058134162-project-sccd:bquxjob_18dafcf6_1815926f205\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-12T18:22:16.314076661Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -738,7 +738,7 @@ public void testParseRecordMetaDataDelete() { public void testParseRecordMetaDataUpdate() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.51\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3d1f064e_1815b272c5d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3d1f064e_1815b272c5d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE fruitsndvegetables.Vegetable i\\r\\nSET Quantityinkilos = i.Quantityinkilos + n.Quantityinkilos\\r\\nFROM fruitsndvegetables.fruits n\\r\\nWHERE i.Veg_name = n.Fruit_name\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-13T03:41:43.597Z\",\"startTime\":\"2022-06-13T03:41:43.922Z\",\"endTime\":\"2022-06-13T03:41:45.913Z\",\"queryStats\":{\"totalProcessedBytes\":\"367\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\",\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\"]},\"totalSlotMs\":\"5076\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"nlgzrfe23b30\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-13T03:41:45.920560Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655091703597-project-sccd:bquxjob_3d1f064e_1815b272c5d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-13T03:41:46.638001868Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -747,7 +747,7 @@ public void testParseRecordMetaDataUpdate() { public void testParseRecordMetaDataSubDelete() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.26\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.63 Safari\\/537.36 Edg\\/102.0.1245.39,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_4e4f2b73_18160f3c72f\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_4e4f2b73_18160f3c72f\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"DELETE fruitsndvegetables.Vegetable\\r\\nWHERE NOT EXISTS\\r\\n(SELECT * from fruitsndvegetables.fruits\\r\\nWHERE Vegetable.Veg_name = fruits.Fruit_name)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DELETE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-14T06:47:04.417Z\",\"startTime\":\"2022-06-14T06:47:04.673Z\",\"endTime\":\"2022-06-14T06:47:07.072Z\",\"queryStats\":{\"totalProcessedBytes\":\"205\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\",\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/Vegetable\"]},\"totalSlotMs\":\"5222\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-sue3v9e4m86q\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-14T06:47:07.077689Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655189224417-project-sccd:bquxjob_4e4f2b73_18160f3c72f\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-14T06:47:07.390209161Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -756,7 +756,7 @@ public void testParseRecordMetaDataSubDelete() { public void testParseRecordMetaDataIndex() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.51\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/script_job_5a5d777367ebea8ed9246ea265335626_0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/script_job_5a5d777367ebea8ed9246ea265335626_0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE SEARCH INDEX my_index ON fruitsndvegetables.fruits(names ARRAY)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits1\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-12T17:44:23.687Z\",\"startTime\":\"2022-06-12T17:44:23.768Z\",\"endTime\":\"2022-06-12T17:44:23.906Z\",\"queryStats\":{},\"parentJobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3b631a52_18159044bc8\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"6o5cnfe5yonm\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-12T17:44:23.913357Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655055863687-project-sccd:script_job_5a5d777367ebea8ed9246ea265335626_0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-12T17:44:24.226658526Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -765,7 +765,7 @@ public void testParseRecordMetaDataIndex() { public void testParseRecordMetaDataSingleComment() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.91\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_e99c2cf_1818aa96dbb\",\"metadata\":{\"jobChange\":{\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_e99c2cf_1818aa96dbb\",\"jobStats\":{\"totalSlotMs\":\"23\",\"endTime\":\"2022-06-22T09:10:01.834Z\",\"startTime\":\"2022-06-22T09:10:01.509Z\",\"queryStats\":{\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\"],\"outputRowCount\":\"20\",\"totalProcessedBytes\":\"306\",\"totalBilledBytes\":\"10485760\"},\"createTime\":\"2022-06-22T09:10:01.425Z\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"writeDisposition\":\"WRITE_TRUNCATE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon385e32ea27929309446037a7dcca2f009b247ea4\",\"query\":\"select Fruit_name, ----------it will display first name \r\nColour from fruitsndvegetables.fruits\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"statementType\":\"SELECT\",\"priority\":\"QUERY_INTERACTIVE\"}}},\"after\":\"DONE\"},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"vn4ffze4phn2\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-22T09:10:01.906513Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655889001425-project-sccd:bquxjob_e99c2cf_1818aa96dbb\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-22T09:10:02.531136627Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -774,7 +774,7 @@ public void testParseRecordMetaDataSingleComment() { public void testParseRecordMetaDataInsertEncoded() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.131\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_9cbc919_18184759208\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_9cbc919_18184759208\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT\\u00a0fruitsndvegetables.fruits VALUES('SweetLime','Green',2),\\u00a0('Chikoo','Brown',4);\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-21T04:11:48.687Z\",\"startTime\":\"2022-06-21T04:11:48.827Z\",\"endTime\":\"2022-06-21T04:11:50.722Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits\"],\"outputRowCount\":\"2\"},\"totalSlotMs\":\"4182\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-uicuvne396qc\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-21T04:11:50.729262Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655784708687-project-sccd:bquxjob_9cbc919_18184759208\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-21T04:11:51.010315404Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -783,7 +783,7 @@ public void testParseRecordMetaDataInsertEncoded() { public void testParseRecordMetaDataWithCreate() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.91\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5547e58b_1818b0d7d97\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5547e58b_1818b0d7d97\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE\\r\\n or replace TABLE\\r\\n BigQueryE2E.newtable if not exists\\r\\n(\\r\\n x INT64 OPTIONS(description=\\\"An optional INTEGER field\\\"),\\r\\n y STRUCT<\\r\\n a ARRAY OPTIONS(description=\\\"A repeated STRING field\\\"),\\r\\n b BOOL\\r\\n >\\r\\n)\\r\\nPARTITION BY _PARTITIONDATE\\r\\nOPTIONS(\\r\\n expiration_timestamp=TIMESTAMP \\\"2025-01-01 00:00:00 UTC\\\",\\r\\n partition_expiration_days=1,\\r\\n description=\\\"a table that expires in 2025, with each partition living for 24 hours\\\",\\r\\n labels=[(\\\"org_unit\\\", \\\"development\\\")]\\r\\n) \",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQueryE2E\\/tables\\/newtable\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-22T10:59:19.027Z\",\"startTime\":\"2022-06-22T10:59:19.104Z\",\"endTime\":\"2022-06-22T10:59:19.251Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-4zdp3le4va91\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-22T10:59:19.258557Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655895559027-project-sccd:bquxjob_5547e58b_1818b0d7d97\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-22T10:59:19.781169820Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -792,7 +792,7 @@ public void testParseRecordMetaDataWithCreate() { public void testParseRecordMetaDataWithCreateIfNotExists() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.51\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/script_job_5a5d777367ebea8ed9246ea265335626_0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/script_job_5a5d777367ebea8ed9246ea265335626_0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE TABLE IF NOT EXISTS jvwegvfd.fruitsndvegetables.fruits1 (names ARRAY)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits1\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-12T17:44:23.687Z\",\"startTime\":\"2022-06-12T17:44:23.768Z\",\"endTime\":\"2022-06-12T17:44:23.906Z\",\"queryStats\":{},\"parentJobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3b631a52_18159044bc8\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"6o5cnfe5yonm\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-12T17:44:23.913357Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655055863687-project-sccd:script_job_5a5d777367ebea8ed9246ea265335626_0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-12T17:44:24.226658526Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -801,7 +801,7 @@ public void testParseRecordMetaDataWithCreateIfNotExists() { public void testParseRecordMetaDataWithEncoded() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.131\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2266d583_1818402d4be\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_2266d583_1818402d4be\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"drop\\u00a0Table projectid.fruitsndvegetables.fruits1;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/fruitsndvegetables\\/tables\\/fruits1\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"DROP_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-21T02:06:29.023Z\",\"startTime\":\"2022-06-21T02:06:29.146Z\",\"endTime\":\"2022-06-21T02:06:29.343Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-iau1g6e5ckhl\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-21T02:06:29.351462Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1655777189023-project-sccd:bquxjob_2266d583_1818402d4be\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-21T02:06:29.548620358Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -810,7 +810,7 @@ public void testParseRecordMetaDataWithEncoded() { public void testParseRecordMetaDataWithschema() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.79.131\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6b04d02e_18195afc934\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6b04d02e_18195afc934\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"drop SCHEMA FinalBuild1\\r\\nOPTIONS(\\r\\n location=\\\"us\\\",\\r\\n default_table_expiration_days=3.75,\\r\\n labels=[(\\\"build1\\\",\\\"version1\\\"),(\\\"build2\\\",\\\"version2\\\")]\\r\\n )\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_SCHEMA\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-24T12:28:55.421Z\",\"startTime\":\"2022-06-24T12:28:55.496Z\",\"endTime\":\"2022-06-24T12:28:56.084Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g2rt6edyzv4\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-24T12:28:56.104867Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656073735421-project-sccd:bquxjob_6b04d02e_18195afc934\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-24T12:28:56.120618505Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -819,7 +819,7 @@ public void testParseRecordMetaDataWithschema() { public void testParseRecordMetaDataWithschemaifNotExists() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.192\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_144a6c2d_181bd8f9b2e\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobStats\":{\"startTime\":\"2022-07-02T06:22:35.741Z\",\"queryStats\":{\"outputRowCount\":\"1\"},\"createTime\":\"2022-07-02T06:22:35.723Z\",\"totalSlotMs\":\"61\",\"endTime\":\"2022-07-02T06:22:35.903Z\"},\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"createDisposition\":\"CREATE_IF_NEEDED\",\"priority\":\"QUERY_INTERACTIVE\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anonc20cbe2d_3b22_49a9_ae5d_c97427c8273b\",\"query\":\"CREATE TEMPorary FUNCTION multiplyInputs(x FLOAT64, y FLOAT64) RETURNS FLOAT64 LANGUAGE js AS r\\\"\\\"\\\" return x*y; \\\"\\\"\\\"; SELECT multiplyInputs(a, b) FROM (SELECT 3 as a, 2 as b);\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"statementType\":\"SELECT\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_144a6c2d_181bd8f9b2e\",\"jobStatus\":{\"jobState\":\"DONE\"}}}}},\"insertId\":\"-6n950oe580et\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T06:22:35.939056Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656742955723-project-sccd:bquxjob_144a6c2d_181bd8f9b2e\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T06:22:36.559608645Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -828,7 +828,7 @@ public void testParseRecordMetaDataWithschemaifNotExists() { public void testParseRecordMetaDataWithschemaWith() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.168.80.102\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_c698ecd_181af4db532\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_3c89f6d7c8c4152e3a1a5c0ab5f855fb2bd8b6af\\/tables\\/anon2010cf7656da4da8d09be4370104eaa20884edd6\",\"priority\":\"QUERY_INTERACTIVE\",\"query\":\"WITH tmp AS (\\r\\n SELECT id, name AS ts_hour, *\\r\\n FROM BigQ_DatasetId_29June.fruits\\r\\n)\\r\\nSELECT ts_hour, COUNT(*) AS cnt\\r\\nFROM tmp\\r\\nGROUP BY ts_hour;\",\"writeDisposition\":\"WRITE_TRUNCATE\",\"statementType\":\"SELECT\",\"createDisposition\":\"CREATE_IF_NEEDED\"}},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_c698ecd_181af4db532\",\"jobStats\":{\"createTime\":\"2022-06-29T11:51:54.858Z\",\"endTime\":\"2022-06-29T11:51:55.192Z\",\"totalSlotMs\":\"113\",\"startTime\":\"2022-06-29T11:51:54.903Z\",\"queryStats\":{\"totalBilledBytes\":\"10485760\",\"totalProcessedBytes\":\"15\",\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigQ_DatasetId_29June\\/tables\\/fruits\"],\"billingTier\":1,\"outputRowCount\":\"2\"}},\"jobStatus\":{\"jobState\":\"DONE\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"9zsetseh9vts\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-29T11:51:55.227178Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656503514858-project-sccd:bquxjob_c698ecd_181af4db532\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-29T11:51:55.690645908Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -837,7 +837,7 @@ public void testParseRecordMetaDataWithschemaWith() { public void testParseRecordMetaDataIf() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.168.80.41\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6ad67f80_181ae8a5792\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6ad67f80_181ae8a5792\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE capacity BigQ_DatasetId_29June.top_words\\r\\nOPTIONS(\\r\\n description=\\\"Top ten words per Shakespeare corpus\\\"\\r\\n) AS\\r\\nSELECT\\r\\n corpus,\\r\\n ARRAY_AGG(STRUCT(word, word_count) ORDER BY word_count DESC LIMIT 10) AS top_words\\r\\nFROM bigquery-public-data.samples.shakespeare\\r\\nGROUP BY corpus;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigQ_DatasetId_29June\\/tables\\/top_words\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE_AS_SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-29T08:18:29.999Z\",\"startTime\":\"2022-06-29T08:18:30.107Z\",\"endTime\":\"2022-06-29T08:18:31.935Z\",\"queryStats\":{\"totalProcessedBytes\":\"5114816\",\"totalBilledBytes\":\"10485760\",\"billingTier\":1,\"referencedTables\":[\"projects\\/bigquery-public-data\\/datasets\\/samples\\/tables\\/shakespeare\"],\"outputRowCount\":\"42\"},\"totalSlotMs\":\"6216\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-skjaf4e4mfgj\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-29T08:18:31.944047Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656490709999-project-sccd:bquxjob_6ad67f80_181ae8a5792\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-29T08:18:32.707542098Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -846,7 +846,7 @@ public void testParseRecordMetaDataIf() { public void testParseRecordMetaDataTemporary() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.38\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true},{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true},{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/script_job_a225dceff694315f8d835bb0a5549a4f_0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/script_job_a225dceff694315f8d835bb0a5549a4f_0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE TEMP function temp_name(name STRING)\\r\\nAS\\r\\n SELECT name\\r\\n FROM `bigquery-public-data`.usa_names.usa_1910_current\\r\\n WHERE year = 2017\\r\\n ORDER BY number DESC LIMIT 100\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_script2f462ebd6458c2a75f144226341b49a2fccfea6b\\/tables\\/temp_name\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE_AS_SELECT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-30T08:17:40.981Z\",\"startTime\":\"2022-06-30T08:17:41.126Z\",\"endTime\":\"2022-06-30T08:17:42.991Z\",\"queryStats\":{\"totalProcessedBytes\":\"150693282\",\"totalBilledBytes\":\"150994944\",\"billingTier\":1,\"referencedTables\":[\"projects\\/bigquery-public-data\\/datasets\\/usa_names\\/tables\\/usa_1910_current\"],\"outputRowCount\":\"100\"},\"totalSlotMs\":\"366\",\"parentJobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6b302ea3_181b3aff099\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"hrdjxqepfaqo\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-30T08:17:43.001434Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656577060981-project-sccd:script_job_a225dceff694315f8d835bb0a5549a4f_0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-30T08:17:43.110274929Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -855,7 +855,7 @@ public void testParseRecordMetaDataTemporary() { public void testParseRecordMetaDataGrant() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.36\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_73379873_181b4dfe8e0\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_73379873_181b4dfe8e0\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"GRANT `roles\\/bigquery.dataViewer` ON table `ddldataset.nfjfj`\\r\\nTO \\\"user:user@test.com\\\", \\\"user:user@test.com\\\"\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"GRANT_ON_SCHEMA\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-30T13:49:41.929Z\",\"startTime\":\"2022-06-30T13:49:41.977Z\",\"endTime\":\"2022-06-30T13:49:42.594Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-eeu3ygecjkj3\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-06-30T13:49:42.612593Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656596981929-project-sccd:bquxjob_73379873_181b4dfe8e0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-30T13:49:43.321440107Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -864,7 +864,7 @@ public void testParseRecordMetaDataGrant() { public void testParseRecordMetaDataRevoke() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.165.15.36\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_1890b936_181b4e12279\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_1890b936_181b4e12279\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"revoke `roles\\/bigquery.dataViewer` ON schema `ddldataset`\\r\\nFROM \\\"user@test.com\\\", \\\"serviceAccount:user@project-sccd.iam.gserviceaccount.com\\\"\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"REVOKE_ON_SCHEMA\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-06-30T13:51:02.226Z\",\"startTime\":\"2022-06-30T13:51:02.266Z\",\"endTime\":\"2022-06-30T13:51:02.832Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-c7b411cyy0\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-06-30T13:51:02.846951Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656597062226-project-sccd:bquxjob_1890b936_181b4e12279\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-06-30T13:51:03.291354757Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -873,7 +873,7 @@ public void testParseRecordMetaDataRevoke() { public void testParseRecordMetaDataWithInsertCurrent() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"157.48.152.241\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_782ca949_181c9a17bb4\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_782ca949_181c9a17bb4\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT ddldataset.DetailedInventory\\r\\nVALUES('top load washer', 10, FALSE, [(CURRENT_DATE(), \\\"comment1\\\")], (\\\"white\\\",\\\"1 year\\\",(30,40,28))),\\r\\n ('front load washer', 20, FALSE, [(CURRENT_DATE(), \\\"comment1\\\")], (\\\"beige\\\",\\\"1 year\\\",(35,45,30)))\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-04T14:33:32.090Z\",\"startTime\":\"2022-07-04T14:33:32.240Z\",\"endTime\":\"2022-07-04T14:33:33.697Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventory\"],\"outputRowCount\":\"2\"},\"totalSlotMs\":\"3757\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-nuu0nge58x5e\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-04T14:33:33.702227Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656945212090-project-sccd:bquxjob_782ca949_181c9a17bb4\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-04T14:33:34.186353651Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -882,7 +882,7 @@ public void testParseRecordMetaDataWithInsertCurrent() { public void testParseRecordMetaDataWithStructInsert() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3d62388c_181fb84c97e\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3d62388c_181fb84c97e\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT INTO project-sccd.BigqueryDemo.studented (rollNo, info) VALUES (1,STRUCT(\\\"Yash\\\",26,\\\"Mechanical Engineering\\\"))\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/studented\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-14T07:07:21.049Z\",\"startTime\":\"2022-07-14T07:07:21.173Z\",\"endTime\":\"2022-07-14T07:07:22.902Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/studented\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"3905\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"b3zablefdfgy\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-14T07:07:22.907682Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1657782441049-project-sccd:bquxjob_3d62388c_181fb84c97e\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-14T07:07:22.975022183Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -891,7 +891,7 @@ public void testParseRecordMetaDataWithStructInsert() { public void testParseRecordMetaDataWithStructCreate() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6b7df308_181fb7fa8de\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_6b7df308_181fb7fa8de\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"CREATE TABLE project-sccd.BigqueryDemo.students\\r\\n (\\r\\n rollNo INT OPTIONS(description=\\\"The identifier for each student\\\"),\\r\\n info STRUCT<\\r\\n name STRING,\\r\\n age INT,\\r\\n department STRING\\r\\n >\\r\\n )\\r\\n OPTIONS(\\r\\n expiration_timestamp=TIMESTAMP \\\"2021-10-07 00:00:00 UTC\\\",\\r\\n description=\\\"Table with a struct column\\\"\\r\\n )\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/students\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"CREATE_TABLE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-14T07:01:45.070Z\",\"startTime\":\"2022-07-14T07:01:45.156Z\",\"endTime\":\"2022-07-14T07:01:45.293Z\",\"queryStats\":{}}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-9f7ermepy4gp\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-14T07:01:45.301077Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1657782105070-project-sccd:bquxjob_6b7df308_181fb7fa8de\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-14T07:01:46.008461524Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -900,7 +900,7 @@ public void testParseRecordMetaDataWithStructCreate() { public void testParseRecordMetaDataWithStructSelect() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_990c91d_181fbb313a0\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobConfig\":{\"queryConfig\":{\"writeDisposition\":\"WRITE_TRUNCATE\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/_1f1c36c3ea0388eeb7a982fdeb3f5cbaed5b427a\\/tables\\/anon3829c73782de65298190525924138456789a5cb2\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"SELECT\",\"query\":\" with a as (\\r\\nselect [struct(\\\"current\\\" as status,\\\"London\\\" as address, \\\"ABC123D\\\" as postcode, struct(\\\"yes\\\" as owner, \\\"no\\\" as tenant) as resident, \\r\\n [\\\"3 bedroom\\\",\\\"kitchen\\\",\\\"living room\\\",\\\"garden\\\"] as rooms),\\r\\n struct(\\\"previous\\\" as status,\\\"New Delhi\\\" as address, \\\"738497\\\" as postcode, struct(\\\"yes\\\" as owner, \\\"no\\\" as tenant) as resident, \\r\\n [\\\"2 bedroom\\\",\\\"kitchen\\\",\\\"living room\\\"] as rooms),\\r\\n struct(\\\"birth\\\" as status,\\\"New York\\\" as address, \\\"SHI747H\\\" as postcode, struct(\\\"yes\\\" as owner, \\\"no\\\" as tenant) as resident, \\r\\n [\\\"4 bedroom\\\",\\\"kitchen\\\",\\\"living room\\\"] as rooms)]as address_history\\r\\n)\\r\\nselect status,postcode, resident, rooms\\r\\nfrom a,\\r\\nunnest (address_history) as addr,\\r\\nunnest (rooms) as rooms;\"},\"type\":\"QUERY\"},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"totalSlotMs\":\"59\",\"startTime\":\"2022-07-14T07:57:54.746Z\",\"queryStats\":{\"outputRowCount\":\"10\"},\"createTime\":\"2022-07-14T07:57:54.731Z\",\"endTime\":\"2022-07-14T07:57:54.914Z\"},\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_990c91d_181fbb313a0\"}}}},\"insertId\":\"-vwhqcme1m1vp\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-07-14T07:57:54.959974Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1657785474731-project-sccd:bquxjob_990c91d_181fbb313a0\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-14T07:57:55.392443271Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -909,7 +909,7 @@ public void testParseRecordMetaDataWithStructSelect() { public void testParseRecordMetaDataWithNestedInsert() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3f70dea9_181fc059130\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_3f70dea9_181fc059130\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT INTO project-sccd.BigqueryDemo.nestedquery VALUES (1,STRUCT(\\\"Yash\\\",26,STRUCT(\\\"Mechanical Engineering\\\",101)))\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/nestedquery\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-14T09:28:00.983Z\",\"startTime\":\"2022-07-14T09:28:01.114Z\",\"endTime\":\"2022-07-14T09:28:02.520Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/nestedquery\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"3076\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-f8x22ueacge3\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-07-14T09:28:02.526171Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1657790880983-project-sccd:bquxjob_3f70dea9_181fc059130\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-14T09:28:03.541779251Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -918,7 +918,7 @@ public void testParseRecordMetaDataWithNestedInsert() { public void testParseRecordMetaDataWithNested() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_477d693e_181fc181437\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_477d693e_181fc181437\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"INSERT INTO project-sccd.BigqueryDemo.nestedinser VALUES (1,STRUCT(\\\"Yash\\\",26,STRUCT(\\\"Mechanical Engineering\\\",101,STRUCT(\\\"CSV\\\",102))))\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/nestedinser\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"INSERT\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-14T09:48:14.191Z\",\"startTime\":\"2022-07-14T09:48:14.322Z\",\"endTime\":\"2022-07-14T09:48:15.880Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/nestedinser\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"3888\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-jys4qmeidlmu\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-07-14T09:48:15.886107Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1657792094191-project-sccd:bquxjob_477d693e_181fc181437\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-14T09:48:15.940596919Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -927,7 +927,7 @@ public void testParseRecordMetaDataWithNested() { public void testParseRecordMetaDataWithStructUpdate() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_ecc994_181fc758f34\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_ecc994_181fc758f34\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE BigqueryDemo.studented\\r\\nSET info = struct(\\\"dhamodhar\\\",33,\\\"CSE\\\")\\r\\nWHERE rollNo = 2\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/studented\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-14T11:30:20.438Z\",\"startTime\":\"2022-07-14T11:30:20.785Z\",\"endTime\":\"2022-07-14T11:30:22.644Z\",\"queryStats\":{\"totalProcessedBytes\":\"162\",\"totalBilledBytes\":\"10485760\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/studented\"],\"outputRowCount\":\"1\"},\"totalSlotMs\":\"3292\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"hrgdy7eo6fis\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-14T11:30:22.649190Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1657798220438-project-sccd:bquxjob_ecc994_181fc758f34\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-14T11:30:23.586527422Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -936,7 +936,7 @@ public void testParseRecordMetaDataWithStructUpdate() { public void testParseRecordMetaDataWithUpdateStruct() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.105\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.5060.114 Safari\\/537.36 Edg\\/103.0.1264.49,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_12836584_1820aa5bbad\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_12836584_1820aa5bbad\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE ddldataset.DetailedInventoryss\\r\\nSET specifications = ARRAY>>\\r\\n [('white', '1 year', NULL)]\\r\\nWHERE product like '%washer%'\\r\\n\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventoryss\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-17T05:37:41.939Z\",\"startTime\":\"2022-07-17T05:37:42.174Z\",\"endTime\":\"2022-07-17T05:37:43.786Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventoryss\"]},\"totalSlotMs\":\"3046\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"uss5ksecuur8\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-07-17T05:37:43.802127Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1658036261939-project-sccd:bquxjob_12836584_1820aa5bbad\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-17T05:37:44.291494915Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -945,7 +945,7 @@ public void testParseRecordMetaDataWithUpdateStruct() { public void testParseRecordMetaDataWithUpdateStruct1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.105\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.5060.114 Safari\\/537.36 Edg\\/103.0.1264.49,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5a6d1a6d_1820a9f0e72\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_5a6d1a6d_1820a9f0e72\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE ddldataset.DetailedInventorys\\r\\nSET comments = STRUCT('2016-01-01', 'comment1')\\r\\nWHERE product like '%washer%'\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventorys\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-17T05:30:24.445Z\",\"startTime\":\"2022-07-17T05:30:24.692Z\",\"endTime\":\"2022-07-17T05:30:26.332Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventorys\"]},\"totalSlotMs\":\"2639\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-sunt4eeezokw\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-07-17T05:30:26.337529Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1658035824445-project-sccd:bquxjob_5a6d1a6d_1820a9f0e72\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-17T05:30:26.464719761Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -954,7 +954,7 @@ public void testParseRecordMetaDataWithUpdateStruct1() { public void testParseRecordMetaDataWithUpdateStruct2() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.105\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.5060.114 Safari\\/537.36 Edg\\/103.0.1264.49,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_546de820_1820a91cfb6\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_546de820_1820a91cfb6\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE ddldataset.DetailedInventory\\r\\nSET specifications = STRUCT>(\\\"white\\\", \\\"1 year\\\", (30,40,28)) WHERE product like '%washer%'\\r\\n\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-17T05:15:55.822Z\",\"startTime\":\"2022-07-17T05:15:56.108Z\",\"endTime\":\"2022-07-17T05:15:57.769Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventory\"]},\"totalSlotMs\":\"3900\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-t4plooe7bsvx\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-17T05:15:57.777400Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1658034955822-project-sccd:bquxjob_546de820_1820a91cfb6\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-17T05:15:57.928459682Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -963,7 +963,7 @@ public void testParseRecordMetaDataWithUpdateStruct2() { public void testParseRecordMetaDataWithUpdateStruct3() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.105\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.5060.114 Safari\\/537.36 Edg\\/103.0.1264.49,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_24cb87c8_1820a92d59d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_24cb87c8_1820a92d59d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE ddldataset.DetailedInventory\\r\\nSET comments = ARRAY>[(CAST('2016-01-01' AS DATE), 'comment1')]\\r\\nWHERE product like '%washer%'\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-17T05:17:02.706Z\",\"startTime\":\"2022-07-17T05:17:02.961Z\",\"endTime\":\"2022-07-17T05:17:04.578Z\",\"queryStats\":{\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/DetailedInventory\"]},\"totalSlotMs\":\"3236\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"opim08e2nzuk\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"US\"}},\"timestamp\":\"2022-07-17T05:17:04.584543Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1658035022706-project-sccd:bquxjob_24cb87c8_1820a92d59d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-17T05:17:04.975020207Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -972,7 +972,7 @@ public void testParseRecordMetaDataWithUpdateStruct3() { public void testParseRecordMetaDataWithMerge1() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory USING nfnfnf.jnjnd\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\nupdate SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\nINSERT (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -981,7 +981,7 @@ public void testParseRecordMetaDataWithMerge1() { public void testParseRecordMetaDataWithMerge2() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE dataset.Inventory as t USING ( select * from unnest)\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\ninsert SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\ndelete (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -990,7 +990,7 @@ public void testParseRecordMetaDataWithMerge2() { public void testParseRecordMetaDataWithMerge3() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory \\r\\nUSING nfnfnf.jnjnd\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\nUPDATE SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\ndelete (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -999,7 +999,7 @@ public void testParseRecordMetaDataWithMerge3() { public void testParseRecordMetaDataWithMerge4() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory t USING ( select * from hfhhf)\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\nUPDATE SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\ndelete (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1008,7 +1008,7 @@ public void testParseRecordMetaDataWithMerge4() { public void testParseRecordMetaDataWithMerge5() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory T\\r\\nUSING nfnfnf.jnjnd\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\ninsert SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\ndelete (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1016,7 +1016,7 @@ public void testParseRecordMetaDataWithMerge5() { public void testParseRecordMetaDataWithMerge6() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory \\r\\nUSING (select * from hfhhf)\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\ninsert SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\ndelete (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1025,7 +1025,7 @@ public void testParseRecordMetaDataWithMerge6() { public void testParseRecordMetaDataWithMerge7() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE into ddldataset.Inventory as t USING nfnfnf.jnjnd\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\ninsert SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\n (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1033,7 +1033,7 @@ public void testParseRecordMetaDataWithMerge7() { public void testParseRecordMetaDataWithMerge8() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory as t USING ( select * from hfhhf)\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\ninsert SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\n (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1042,7 +1042,7 @@ public void testParseRecordMetaDataWithMerge8() { public void testParseRecordMetaDataWithMerge9() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory t USING nfnfnf.jnjnd\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\nupdate SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\n (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1050,7 +1050,7 @@ public void testParseRecordMetaDataWithMerge9() { public void testParseRecordMetaDataWithMerge10() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory \\r\\nUSING ( select * from )\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\n SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\n (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1059,7 +1059,7 @@ public void testParseRecordMetaDataWithMerge10() { public void testParseRecordMetaDataWithMerge11() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.165.1\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_779d6a8b_181bcb2a44d\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"MERGE ddldataset.Inventory \\r\\nUSING rjrjrj.jnjnf\\r\\nON T.product = S.product\\r\\nWHEN MATCHED THEN\\r\\n SET quantity = T.quantity + S.quantity\\r\\nWHEN NOT MATCHED THEN\\r\\n (product, quantity) VALUES(product, quantity)\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"MERGE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-07-02T02:21:15.251Z\",\"startTime\":\"2022-07-02T02:21:15.492Z\",\"endTime\":\"2022-07-02T02:21:17.869Z\",\"queryStats\":{\"totalProcessedBytes\":\"196\",\"totalBilledBytes\":\"20971520\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/Inventory\",\"projects\\/project-sccd\\/datasets\\/ddldataset\\/tables\\/NewArrivals\"],\"outputRowCount\":\"3\"},\"totalSlotMs\":\"11325\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"-g3adezdulco\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-02T02:21:17.874106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1656728475251-project-sccd:bquxjob_779d6a8b_181bcb2a44d\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-07-02T02:21:18.499328981Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1068,7 +1068,7 @@ public void testParseRecordMetaDataWithMerge11() { public void testParseRecordMetaDataWithTableInsert() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"serviceaccount-vikas@project-sccd.iam.gserviceaccount.com\",\"serviceAccountKeyName\":\"\\/\\/iam.googleapis.com\\/projects\\/project-sccd\\/serviceAccounts\\/serviceaccount-vikas@project-sccd.iam.gserviceaccount.com\\/keys\\/d42132726c84b24e4f7a6e8d1664c440f79fd99d\"},\"requestMetadata\":{\"callerIp\":\"129.41.87.5\",\"callerSuppliedUserAgent\":\"gcloud-java\\/2.0.0 Google-API-Java-Client\\/1.33.1 Google-HTTP-Java-Client\\/1.41.4 (gzip),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.InsertTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/BigQuery_AutomationDataset\",\"permission\":\"bigquery.tables.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/BigQuery_AutomationDataset\\/tables\\/BigQuery_AutomationTable\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableCreation\":{\"reason\":\"TABLE_INSERT_REQUEST\",\"table\":{\"createTime\":\"2022-07-11T11:30:41.656Z\",\"schemaJson\":\"{\\n \\\"fields\\\": [{\\n \\\"name\\\": \\\"ID\\\",\\n \\\"type\\\": \\\"STRING\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"isPresent\\\",\\n \\\"type\\\": \\\"BOOLEAN\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }, {\\n \\\"name\\\": \\\"accountNumber\\\",\\n \\\"type\\\": \\\"INTEGER\\\",\\n \\\"mode\\\": \\\"NULLABLE\\\"\\n }]\\n}\",\"updateTime\":\"2022-07-11T11:30:41.691Z\",\"tableName\":\"projects\\/project-sccd\\/datasets\\/BigQuery_AutomationDataset\\/tables\\/BigQuery_AutomationTable\"}}}},\"insertId\":\"-qmhzpwd9f7o\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"project_id\":\"project-sccd\",\"dataset_id\":\"BigQuery_AutomationDataset\"}},\"timestamp\":\"2022-07-11T11:30:41.731439Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2022-07-11T11:30:42.512973757Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1077,7 +1077,7 @@ public void testParseRecordMetaDataWithTableInsert() { public void testParseRecordMetaDataWithTableDelete() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"223.233.64.98\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/103.0.0.0 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.TableService.DeleteTable\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/Channels\",\"permission\":\"bigquery.tables.delete\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/BigqueryDemo\\/tables\\/Channels\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"tableDeletion\":{\"reason\":\"TABLE_DELETE_REQUEST\"}}},\"insertId\":\"-ooj6w2df9md\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"dataset_id\":\"BigqueryDemo\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-11T10:29:40.350784Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2022-07-11T10:29:40.629050688Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1086,7 +1086,7 @@ public void testParseRecordMetaDataWithTableDelete() { public void testParseRecordMetaDataWithDatasetCreation() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"serviceaccount-vikas@project-sccd.iam.gserviceaccount.com\",\"serviceAccountKeyName\":\"\\/\\/iam.googleapis.com\\/projects\\/project-sccd\\/serviceAccounts\\/serviceaccount-vikas@project-sccd.iam.gserviceaccount.com\\/keys\\/d42132726c84b24e4f7a6e8d1664c440f79fd99d\"},\"requestMetadata\":{\"callerIp\":\"129.41.87.5\",\"callerSuppliedUserAgent\":\"gcloud-java\\/2.0.0 Google-API-Java-Client\\/1.33.1 Google-HTTP-Java-Client\\/1.41.4 (gzip),gzip(gfe)\",\"requestAttributes\":{},\"destinationAttributes\":{}},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.DatasetService.InsertDataset\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.datasets.create\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/project-sccd\\/datasets\\/BigQuery_AutomationDataset\",\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\",\"datasetCreation\":{\"reason\":\"CREATE\",\"dataset\":{\"updateTime\":\"2022-07-11T11:30:41.137Z\",\"createTime\":\"2022-07-11T11:30:41.137Z\",\"datasetName\":\"projects\\/project-sccd\\/datasets\\/BigQuery_AutomationDataset\",\"acl\":{\"policy\":{\"bindings\":[{\"members\":[\"projectEditor:project-sccd\"],\"role\":\"roles\\/bigquery.dataEditor\"},{\"members\":[\"projectOwner:project-sccd\",\"serviceAccount:serviceaccount-vikas@project-sccd.iam.gserviceaccount.com\"],\"role\":\"roles\\/bigquery.dataOwner\"},{\"members\":[\"projectViewer:project-sccd\"],\"role\":\"roles\\/bigquery.dataViewer\"}]}}}}}},\"insertId\":\"-ooouh2d45c8\",\"resource\":{\"type\":\"bigquery_dataset\",\"labels\":{\"dataset_id\":\"BigQuery_AutomationDataset\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-07-11T11:30:41.204965Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"receiveTimestamp\":\"2022-07-11T11:30:41.870795018Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } @@ -1095,7 +1095,7 @@ public void testParseRecordMetaDataWithDatasetCreation() { public void testParseRecordMetaDataWithDatasetDeletion() { final String sql = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"103.168.81.160\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/107.0.0.0 Safari\\/537.36,gzip(gfe),gzip(gfe)\"},\"serviceName\":\"bigquery.googleapis.com\",\"methodName\":\"google.cloud.bigquery.v2.JobService.InsertJob\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\",\"permission\":\"bigquery.jobs.create\",\"granted\":true}],\"resourceName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_35ae7ecb_1845206c981\",\"metadata\":{\"jobChange\":{\"after\":\"DONE\",\"job\":{\"jobName\":\"projects\\/project-sccd\\/jobs\\/bquxjob_35ae7ecb_1845206c981\",\"jobConfig\":{\"type\":\"QUERY\",\"queryConfig\":{\"query\":\"UPDATE dataset.DetailedInventory SET comments = ARRAY( SELECT c FROM UNNEST(comments) AS c WHERE c.comment NOT LIKE '%comment2%' ) WHERE true;\",\"destinationTable\":\"projects\\/project-sccd\\/datasets\\/dataset\\/tables\\/DetailedInventory\",\"createDisposition\":\"CREATE_IF_NEEDED\",\"writeDisposition\":\"WRITE_EMPTY\",\"priority\":\"QUERY_INTERACTIVE\",\"statementType\":\"UPDATE\"}},\"jobStatus\":{\"jobState\":\"DONE\"},\"jobStats\":{\"createTime\":\"2022-11-07T12:18:07.707Z\",\"startTime\":\"2022-11-07T12:18:08.017Z\",\"endTime\":\"2022-11-07T12:18:10.227Z\",\"queryStats\":{\"totalProcessedBytes\":\"298\",\"totalBilledBytes\":\"10485760\",\"billingTier\":1,\"referencedTables\":[\"projects\\/project-sccd\\/datasets\\/dataset\\/tables\\/DetailedInventory\"],\"outputRowCount\":\"14\"},\"totalSlotMs\":\"4105\"}}},\"@type\":\"type.googleapis.com\\/google.cloud.audit.BigQueryAuditMetadata\"}},\"insertId\":\"nv235ie8z18x\",\"resource\":{\"type\":\"bigquery_project\",\"labels\":{\"location\":\"US\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-11-07T12:18:10.232333Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"1667823487707-project-sccd:bquxjob_35ae7ecb_1845206c981\",\"producer\":\"bigquery.googleapis.com\",\"last\":true},\"receiveTimestamp\":\"2022-11-07T12:18:10.570748804Z\"}"; final JsonObject BigqueryJson = JsonParser.parseString(sql).getAsJsonObject(); - Record sqlquery = Parser.parseRecord(BigqueryJson); + UCRecord sqlquery = Parser.parseRecord(BigqueryJson); assertNotNull(sqlquery); } diff --git a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/build.gradle b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/build.gradle index 200a3733b..1a11a2aa7 100644 --- a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/build.gradle +++ b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "FireBaseGuardiumFilter" pluginInfo.pluginName = "fire_base_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/gradlew b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/FireBaseGuardiumFilter.java b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/FireBaseGuardiumFilter.java index c3d3cd3e2..e1d5c5a47 100644 --- a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/FireBaseGuardiumFilter.java +++ b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/FireBaseGuardiumFilter.java @@ -1,6 +1,6 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -17,7 +17,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -86,7 +86,7 @@ public Collection filter(Collection events, FilterMatchListener fi try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/Parser.java b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/Parser.java index 223d4069b..02ed6db64 100644 --- a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/Parser.java +++ b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/main/java/com/ibm/guardium/firebase/Parser.java @@ -16,7 +16,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -36,14 +36,14 @@ public class Parser { /** * parseRecord() method will perform operation on JsonObject input, convert - * JsonObject into Record Object and then return the value as response + * JsonObject into UCRecord Object and then return the value as response * * @param JsonObject inputJson * @methodName @parseRecord - * @return Record GUARDIUM Object + * @return UCRecord GUARDIUM Object */ - public static Record parseRecord(JsonObject inputJson) { - Record record = new Record(); + public static UCRecord parseRecord(JsonObject inputJson) { + UCRecord record = new UCRecord(); JsonObject protoPayload = inputJson.get(ApplicationConstants.PROTO_PAYLOAD).getAsJsonObject(); String databaseId = getDatabaseName(protoPayload); diff --git a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/test/java/com/ibm/guardium/firebase/ParserTest.java b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/test/java/com/ibm/guardium/firebase/ParserTest.java index ef63b6853..e2004facd 100644 --- a/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/test/java/com/ibm/guardium/firebase/ParserTest.java +++ b/filter-plugin/logstash-filter-pubsub-firebase-realtime-guardium/src/test/java/com/ibm/guardium/firebase/ParserTest.java @@ -1,6 +1,6 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -14,7 +14,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; public class ParserTest { @@ -24,7 +24,7 @@ public class ParserTest { @Test public void testParseRecord() { - Record record = Parser.parseRecord(fireBaseJson); + UCRecord record = Parser.parseRecord(fireBaseJson); assertEquals("1393994353", record.getSessionId()); assertEquals("meenakshi_b@hcl.com", record.getAppUserName()); assertNotNull(record.getSessionLocator()); @@ -34,7 +34,7 @@ public void testParseRecord() { @Test public void testParseSessionLocator() { - Record record = Parser.parseRecord(fireBaseJson); + UCRecord record = Parser.parseRecord(fireBaseJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", actual.getServerIp()); @@ -47,7 +47,7 @@ public void testParseSessionLocator() { public void testParseSessionLocator_Ipv6() { final String fireStoreLogsString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"brijeshyadav1979@gmail.com\"},\"requestMetadata\":{\"callerIp\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/97.0.4692.99 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-02-07T18:22:40.885763Z\",\"reason\":\"8uSywAYxWi9GaXJlc3RvcmUgd2F0Y2ggZm9yIGxvbmcgcnVubmluZyBzdHJlYW1pbmcgcnBjLg\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"firestore.googleapis.com\",\"methodName\":\"google.firestore.v1.Firestore.Listen\",\"authorizationInfo\":[{\"resource\":\"projects\\/guarduim\\/databases\\/\",\"permission\":\"datastore.entities.get\",\"granted\":true,\"resourceAttributes\":{}},{\"resource\":\"projects\\/guarduim\\/databases\\/\",\"permission\":\"datastore.entities.list\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/guarduim\\/databases\\/(default)\",\"request\":{\"addTarget\":{\"query\":{\"parent\":\"projects\\/guarduim\\/databases\\/(default)\\/documents\",\"structuredQuery\":{\"from\":[{\"collectionId\":\"collection55\"}],\"orderBy\":[{\"field\":{\"fieldPath\":\"__name__\"},\"direction\":\"ASCENDING\"}]}},\"targetId\":50},\"@type\":\"type.googleapis.com\\/google.firestore.v1.ListenRequest\"},\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.DatastoreServiceData\"}},\"insertId\":\"-4flla8df63i\",\"resource\":{\"type\":\"audited_resource\",\"labels\":{\"service\":\"firestore.googleapis.com\",\"method\":\"google.firestore.v1.Firestore.Listen\",\"project_id\":\"guarduim\"}},\"timestamp\":\"2022-02-07T18:22:40.874854Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/guarduim\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"381d996b-ef01-4267-bbb3-0b13c7b2cdc1\",\"producer\":\"firestore.googleapis.com\"},\"receiveTimestamp\":\"2022-02-07T18:22:41.231100438Z\"}"; final JsonObject spannerJson = JsonParser.parseString(fireStoreLogsString).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertEquals(-1, actual.getServerPort()); assertEquals(-1, actual.getClientPort()); @@ -57,7 +57,7 @@ public void testParseSessionLocator_Ipv6() { @Test public void testParseAccessor() { - Record record = Parser.parseRecord(fireBaseJson); + UCRecord record = Parser.parseRecord(fireBaseJson); Accessor actual = record.getAccessor(); assertNotNull(record.getAccessor()); assertEquals("project-sccd:project-sccd-3b9f0", actual.getServiceName()); diff --git a/filter-plugin/logstash-filter-pubsub-firestore-guardium/build.gradle b/filter-plugin/logstash-filter-pubsub-firestore-guardium/build.gradle index 343af305e..bc6776764 100644 --- a/filter-plugin/logstash-filter-pubsub-firestore-guardium/build.gradle +++ b/filter-plugin/logstash-filter-pubsub-firestore-guardium/build.gradle @@ -19,10 +19,10 @@ pluginInfo.pluginType = "filter" pluginInfo.pluginClass = "FireStoreGuardiumFilter" pluginInfo.pluginName = "fire_store_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -40,8 +40,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-pubsub-firestore-guardium/gradlew b/filter-plugin/logstash-filter-pubsub-firestore-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/FireStoreGuardiumFilter.java b/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/FireStoreGuardiumFilter.java index 9365f84f4..0cd587b91 100644 --- a/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/FireStoreGuardiumFilter.java +++ b/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/FireStoreGuardiumFilter.java @@ -1,6 +1,6 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -17,7 +17,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -84,7 +84,7 @@ public Collection filter(Collection events, FilterMatchListener fi } try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/Parser.java b/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/Parser.java index dd74ff1cd..24c42d430 100644 --- a/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/Parser.java +++ b/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/main/java/com/ibm/guardium/firestore/Parser.java @@ -1,6 +1,6 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -24,7 +24,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -46,15 +46,15 @@ public class Parser { /** * * parseRecord() method will perform operation on JsonObject input, convert - * JsonObject into Record Object and then return the value as response + * JsonObject into UCRecord Object and then return the value as response * * @param JsonObject inputJson * @methodName @parseRecord - * @return Record GUARDIUM Object + * @return UCRecord GUARDIUM Object * */ - public static Record parseRecord(JsonObject inputJson) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(JsonObject inputJson) throws Exception { + UCRecord record = new UCRecord(); String serverHostName = ApplicationConstants.SERVER_HOST_NAME_STRING; String projectId = StringUtils.EMPTY; JsonObject protoPayload = inputJson.get(ApplicationConstants.PROTO_PAYLOAD).getAsJsonObject(); diff --git a/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/test/java/com/ibm/guardium/firestore/ParserTest.java b/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/test/java/com/ibm/guardium/firestore/ParserTest.java index 44ecf1b48..d29d10263 100644 --- a/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/test/java/com/ibm/guardium/firestore/ParserTest.java +++ b/filter-plugin/logstash-filter-pubsub-firestore-guardium/src/test/java/com/ibm/guardium/firestore/ParserTest.java @@ -1,6 +1,6 @@ /* -© Copyright IBM Corp. 2021, 2022 All rights reserved. +� Copyright IBM Corp. 2021, 2022 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -14,7 +14,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; public class ParserTest { @@ -24,7 +24,7 @@ public class ParserTest { @Test public void testParseRecord() throws Exception { - Record record = Parser.parseRecord(fireStoreJson); + UCRecord record = Parser.parseRecord(fireStoreJson); assertEquals("1iy4kipbco", record.getSessionId()); // assertEquals("(default)", record.getDbName()); assertEquals("aabbcc.abc@hcl.com", record.getAppUserName()); @@ -35,7 +35,7 @@ public void testParseRecord() throws Exception { @Test public void testParseSessionLocator() throws Exception { - Record record = Parser.parseRecord(fireStoreJson); + UCRecord record = Parser.parseRecord(fireStoreJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", actual.getServerIp()); @@ -48,14 +48,14 @@ public void testParseSessionLocator() throws Exception { public void testParseSessionLocator_Ipv6() throws Exception { final String fireStoreLogsString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"status\":{},\"authenticationInfo\":{\"principalEmail\":\"brijeshyadav1979@gmail.com\"},\"requestMetadata\":{\"callerIp\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/97.0.4692.99 Safari\\/537.36,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-02-07T18:22:40.885763Z\",\"reason\":\"8uSywAYxWi9GaXJlc3RvcmUgd2F0Y2ggZm9yIGxvbmcgcnVubmluZyBzdHJlYW1pbmcgcnBjLg\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"firestore.googleapis.com\",\"methodName\":\"google.firestore.v1.Firestore.Listen\",\"authorizationInfo\":[{\"resource\":\"projects\\/guarduim\\/databases\\/\",\"permission\":\"datastore.entities.get\",\"granted\":true,\"resourceAttributes\":{}},{\"resource\":\"projects\\/guarduim\\/databases\\/\",\"permission\":\"datastore.entities.list\",\"granted\":true,\"resourceAttributes\":{}}],\"resourceName\":\"projects\\/guarduim\\/databases\\/(default)\",\"request\":{\"addTarget\":{\"query\":{\"parent\":\"projects\\/guarduim\\/databases\\/(default)\\/documents\",\"structuredQuery\":{\"from\":[{\"collectionId\":\"collection55\"}],\"orderBy\":[{\"field\":{\"fieldPath\":\"__name__\"},\"direction\":\"ASCENDING\"}]}},\"targetId\":50},\"@type\":\"type.googleapis.com\\/google.firestore.v1.ListenRequest\"},\"metadata\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.DatastoreServiceData\"}},\"insertId\":\"-4flla8df63i\",\"resource\":{\"type\":\"audited_resource\",\"labels\":{\"service\":\"firestore.googleapis.com\",\"method\":\"google.firestore.v1.Firestore.Listen\",\"project_id\":\"guarduim\"}},\"timestamp\":\"2022-02-07T18:22:40.874854Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/guarduim\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"381d996b-ef01-4267-bbb3-0b13c7b2cdc1\",\"producer\":\"firestore.googleapis.com\"},\"receiveTimestamp\":\"2022-02-07T18:22:41.231100438Z\"}"; final JsonObject spannerJson = JsonParser.parseString(fireStoreLogsString).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertEquals("0000:0000:0000:0000:0000:FFFF:0000:0000", actual.getServerIpv6()); } @Test public void testParseAccessor() throws Exception { - Record record = Parser.parseRecord(fireStoreJson); + UCRecord record = Parser.parseRecord(fireStoreJson); Accessor actual = record.getAccessor(); assertNotNull(record.getAccessor()); assertEquals("project-sccd-(default)", actual.getServiceName()); diff --git a/filter-plugin/logstash-filter-pubsub-spanner-guardium/build.gradle b/filter-plugin/logstash-filter-pubsub-spanner-guardium/build.gradle index d2a8b36af..a50dca583 100644 --- a/filter-plugin/logstash-filter-pubsub-spanner-guardium/build.gradle +++ b/filter-plugin/logstash-filter-pubsub-spanner-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "SpannerDBGuardiumFilter" pluginInfo.pluginName = "spanner_db_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-pubsub-spanner-guardium/gradlew b/filter-plugin/logstash-filter-pubsub-spanner-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/Parser.java b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/Parser.java index 4ddef4c78..77364d482 100644 --- a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/Parser.java +++ b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/Parser.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. +� Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -25,7 +25,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -48,17 +48,17 @@ private Parser() { /** * parseRecord() method will perform operation on JsonObject input, convert - * JsonObject into Record Object and then return the value as response + * JsonObject into UCRecord Object and then return the value as response * * @param JsonObject inputJson - * @return Record GUARDIUM Object + * @return UCRecord GUARDIUM Object * @throws Exception * */ - public static Record parseRecord(JsonObject inputJson) { + public static UCRecord parseRecord(JsonObject inputJson) { JsonObject protoPayloadJsonObject = inputJson.get(ApplicationConstants.PROTO_PAYLOAD).getAsJsonObject(); - Record record = new Record(); + UCRecord record = new UCRecord(); JsonObject resourceJsonObject = inputJson.get(ApplicationConstants.RESOURCES).getAsJsonObject(); record.setSessionId(getSessionId(protoPayloadJsonObject, resourceJsonObject)); diff --git a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/SpannerDBGuardiumFilter.java b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/SpannerDBGuardiumFilter.java index 664a78c48..dc8daba9a 100644 --- a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/SpannerDBGuardiumFilter.java +++ b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/main/java/com/ibm/guardium/spanner/SpannerDBGuardiumFilter.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. +� Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -16,7 +16,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -81,7 +81,7 @@ public Collection filter(Collection events, FilterMatchListener fi } try { JsonObject inputJSON = new Gson().fromJson(messageString, JsonObject.class); - Record record = Parser.parseRecord(inputJSON); + UCRecord record = Parser.parseRecord(inputJSON); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/ParserTest.java b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/ParserTest.java index 4fbe78659..8c8128fb6 100644 --- a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/ParserTest.java +++ b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/ParserTest.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. +� Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -14,7 +14,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -25,7 +25,7 @@ public class ParserTest { @Test public void testParseRecord() { - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); assertEquals("2097373799", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); assertNotNull(record.getSessionLocator()); @@ -34,7 +34,7 @@ public void testParseRecord() { @Test public void testParseSessionLocator() { - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", actual.getServerIp()); @@ -47,7 +47,7 @@ public void testParseSessionLocator() { public void testParseSessionLocator_Ipv6() { final String spannerString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"pankaj-g766@hcl.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"2222:a00:222:4444:b0:222:db5c:f555\",\"callerSuppliedUserAgent\":\"grpc-c++\\/1.45.0-dev grpc-c\\/22.0.0 (linux; chttp2),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-02-25T09:35:01.505018272Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x94O_jIlXA2ed_pbzYxdsI071emhpt0lrXzUqcnftd0BLjqnmR_wRX-3w\",\"request\":{\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x94O_jIlXA2ed_pbzYxdsI071emhpt0lrXzUqcnftd0BLjqnmR_wRX-3w\",\"sql\":\"SELECT t0.LastName FROM (select Info,LastName from Users) AS t0 GROUP BY t0.LastName LIMIT 100;\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.spanner.v1.ResultSet\"}},\"insertId\":\"14inpo5e34435\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"location\":\"asia-south1\",\"instance_config\":\"\",\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-02-25T09:35:01.497225106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"receiveTimestamp\":\"2022-02-25T09:35:03.181856942Z\"}"; final JsonObject spannerJson = JsonParser.parseString(spannerString).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0000:0000:0000:0000:0000:FFFF:0000:0000", actual.getServerIpv6()); @@ -59,7 +59,7 @@ public void testParseSessionLocator_Ipv6() { @Test public void testParseAccessor() { - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Accessor actual = record.getAccessor(); assertNotNull(record.getAccessor()); assertEquals("project-sccd:spanner-test:test", actual.getServiceName()); @@ -69,7 +69,7 @@ public void testParseAccessor() { @Test public void testParseConstruct() { - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertNotNull(sentence); assertNotNull(record); diff --git a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/SpannerFilterConnectorTest.java b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/SpannerFilterConnectorTest.java index c96bd69a0..de8833aa2 100644 --- a/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/SpannerFilterConnectorTest.java +++ b/filter-plugin/logstash-filter-pubsub-spanner-guardium/src/test/java/com/ibm/guardium/spanner/SpannerFilterConnectorTest.java @@ -1,5 +1,5 @@ /* -© Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. +� Copyright IBM Corp. 2021, 2022, 2023 All rights reserved. SPDX-License-Identifier: Apache-2.0 */ @@ -24,7 +24,7 @@ import com.google.gson.JsonParser; import com.ibm.guardium.universalconnector.commons.GuardConstants; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -86,7 +86,7 @@ public void filterInvalidJSONTest() { public void filterTestCheck() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.188.229\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/98.0.4758.102 Safari\\/537.36 Edg\\/98.0.1108.62,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-03-06T10:03:43.817387774Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x_3xb7nwA0H7S6B8hLV3AzHNPVKl7PzemyrtB21HA3RoJOaQxccdeqoAw\",\"request\":{\"sql\":\"WITH Values AS (\\n SELECT 1 x, 'a' y UNION ALL \\n SELECT 1 x, #getting offset value \\n 'b' y UNION ALL \\n SELECT 2 x, 'a' y UNION ALL \\n SELECT 2 x, 'c' y \\n ) SELECT x, ARRAY_AGG(y) as array_agg FROM Values GROUP BY x;\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"queryMode\":\"PROFILE\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x_3xb7nwA0H7S6B8hLV3AzHNPVKl7PzemyrtB21HA3RoJOaQxccdeqoAw\"}},\"insertId\":\"1snxb5rdflup\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-03-06T10:03:43.817102127Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"13710611471873755832\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-06T10:03:44.673334332Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1875025146", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -99,7 +99,7 @@ public void filterTestCheck() { public void filterTestRecord() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.209\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/98.0.4758.102 Safari\\/537.36 Edg\\/98.0.1108.62,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-03-07T04:17:51.801797793Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x8SgFA0zcqVGRh4iari_Ve9m88l6J-w1F-Gk4AHOWy7JHBekHq_eloh2w\",\"request\":{\"queryMode\":\"PROFILE\",\"sql\":\"select Firstname,DOB From Users where id=2\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x8SgFA0zcqVGRh4iari_Ve9m88l6J-w1F-Gk4AHOWy7JHBekHq_eloh2w\"}},\"insertId\":\"1snxb5rdfzg7\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-03-07T04:17:51.801593049Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"7945483215916040071\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-07T04:17:53.543048234Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-1979925154", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -116,7 +116,7 @@ public void filterTestRecord() { public void filterTestGrant() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:vejalla.indrani@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"117.209.13.187\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/108.0.0.0 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-12-15T15:17:10.764878109Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"request\":{\"database\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\",\"statements\":[\"GRANT INSERT(SingerId, FirstName, LastName, SingerInfo) ON TABLE Singers TO ROLE span_qa\",\"GRANT SELECT(name, level, location), UPDATE(location) ON TABLE employees, contractors TO ROLE hr_manager\"]},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"kskofjncebo\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"location\":\"asia-south1\",\"instance_config\":\"\",\"instance_id\":\"test-span\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-12-15T15:17:10.759430837Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\\/operations\\/_auto_op_36c1cf6cc65bd52f\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-12-15T15:17:14.475070376Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1716037752", record.getSessionId()); assertEquals("project-sccd:test-span:test-database", record.getDbName()); @@ -129,7 +129,7 @@ public void filterTestGrant() { public void filterTestRevoke() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:vejalla.indrani@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"117.209.13.187\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/108.0.0.0 Safari\\/537.36,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-12-15T15:17:10.764878109Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"request\":{\"database\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\",\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\",\"statements\":[\"REVOKE SELECT ON TABLE Albums FROM ROLE hr_rep\",\"DROP TABLE TEST\"]},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"kskofjncebo\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"location\":\"asia-south1\",\"instance_config\":\"\",\"instance_id\":\"test-span\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-12-15T15:17:10.759430837Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/test-span\\/databases\\/test-database\\/operations\\/_auto_op_36c1cf6cc65bd52f\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-12-15T15:17:14.475070376Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1716037752", record.getSessionId()); assertEquals("project-sccd:test-span:test-database", record.getDbName()); @@ -215,7 +215,7 @@ public void filterRequestMetadataNegTest() { public void filterInstanceAndProjectIdNegTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.43\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-26T08:22:55.134992665Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ8vg7Vm3kk4tcbM2541S-7e2wGqwfu6tXg20TUTKsL9Gwdae1KW2ULmFw\",\"request\":{\"queryMode\":\"PROFILE\",\"sql\":\"SELECT a.SingerId FROM Albums AS a WHERE STARTS_WITH(a.AlbumTitle, \\\"T\\\") AND a.MarketingBudget <= 5000;\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ8vg7Vm3kk4tcbM2541S-7e2wGqwfu6tXg20TUTKsL9Gwdae1KW2ULmFw\"}},\"insertId\":\"4zyb0zd80dn\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"asia-south1\"}},\"timestamp\":\"2022-05-26T08:22:55.129354923Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"10361143198256964072\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-26T08:22:56.043074091Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-1050474491", record.getSessionId()); assertEquals(":test", record.getDbName()); @@ -228,7 +228,7 @@ public void filterInstanceAndProjectIdNegTest() { public void filterSessionLocatorTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"111.11.11.111\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/98.0.4758.102 Safari\\/537.36 Edg\\/98.0.1108.62,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-03-07T04:17:51.801797793Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x8SgFA0zcqVGRh4iari_Ve9m88l6J-w1F-Gk4AHOWy7JHBekHq_eloh2w\",\"request\":{\"queryMode\":\"PROFILE\",\"sql\":\"select Firstname,DOB From Users where id=2\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x8SgFA0zcqVGRh4iari_Ve9m88l6J-w1F-Gk4AHOWy7JHBekHq_eloh2w\"}},\"insertId\":\"1snxb5rdfzg7\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-03-07T04:17:51.801593049Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"7945483215916040071\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-07T04:17:53.543048234Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0.0.0.0", actual.getServerIp()); @@ -241,7 +241,7 @@ public void filterSessionLocatorTest() { public void filterIpv6Test() { final String spannerString = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"1111:a11:222:4444:b0:111:db0c:f111\",\"callerSuppliedUserAgent\":\"grpc-c++\\/1.45.0-dev grpc-c\\/22.0.0 (linux; chttp2),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-02-25T09:35:01.505018272Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x94O_jIlXA2ed_pbzYxdsI071emhpt0lrXzUqcnftd0BLjqnmR_wRX-3w\",\"request\":{\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x94O_jIlXA2ed_pbzYxdsI071emhpt0lrXzUqcnftd0BLjqnmR_wRX-3w\",\"sql\":\"SELECT t0.LastName FROM (select Info,LastName from Users) AS t0 GROUP BY t0.LastName LIMIT 100;\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.spanner.v1.ResultSet\"}},\"insertId\":\"14inpo5e34435\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"location\":\"asia-south1\",\"instance_config\":\"\",\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-02-25T09:35:01.497225106Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"receiveTimestamp\":\"2022-02-25T09:35:03.181856942Z\"}"; final JsonObject spannerJson = JsonParser.parseString(spannerString).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertNotNull(record.getSessionLocator()); assertEquals("0000:0000:0000:0000:0000:FFFF:0000:0000", actual.getServerIpv6()); @@ -255,7 +255,7 @@ public void filterIpv6Test() { public void filterAccessorTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.209\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/98.0.4758.102 Safari\\/537.36 Edg\\/98.0.1108.62,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-03-07T04:17:51.801797793Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x8SgFA0zcqVGRh4iari_Ve9m88l6J-w1F-Gk4AHOWy7JHBekHq_eloh2w\",\"request\":{\"queryMode\":\"PROFILE\",\"sql\":\"select Firstname,DOB From Users where id=2\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x8SgFA0zcqVGRh4iari_Ve9m88l6J-w1F-Gk4AHOWy7JHBekHq_eloh2w\"}},\"insertId\":\"1snxb5rdfzg7\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-03-07T04:17:51.801593049Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"7945483215916040071\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-07T04:17:53.543048234Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Accessor actual = record.getAccessor(); assertNotNull(record.getAccessor()); assertEquals("project-sccd:spanner-test:test", actual.getServiceName()); @@ -269,7 +269,7 @@ public void filterAccessorTest() { public void filterSqlParserTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.12.209\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/98.0.4758.102 Safari\\/537.36 Edg\\/98.0.1108.62,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-03-07T04:50:54.292832567Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x-sZNP9yGownes7w4LpVxd8RuobRkz5lFKTxwOSy2O_mZ4lz4c5Ms0bvA\",\"request\":{\"sql\":\"select * from Employee;\",\"queryMode\":\"PROFILE\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x-sZNP9yGownes7w4LpVxd8RuobRkz5lFKTxwOSy2O_mZ4lz4c5Ms0bvA\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\"}},\"insertId\":\"1snxb5rdfzrm\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-03-07T04:50:54.292645291Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"16835646549553829817\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-07T04:50:55.393220752Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-1979925154", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -297,7 +297,7 @@ public void filterSqlParserTest2() { public void filterCreateDbTest() { final String gcpString2 = "{\"insertId\":\"1xxqxsxcnww\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"first\":true,\"id\":\"projects\\/project-sccd\\/instances\\/spanner-plugin\\/databases\\/spanner-db\\/operations\\/_auto_op_9076614e440f9535\",\"last\":true,\"producer\":\"spanner.googleapis.com\"},\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"anandkumar.saini778@hcl.com\",\"principalSubject\":\"user:anandkumar.saini778@hcl.com\"},\"authorizationInfo\":[{\"granted\":true,\"permission\":\"spanner.databases.create\",\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-plugin\",\"resourceAttributes\":{\"name\":\"projects\\/project-sccd\\/instances\\/spanner-plugin\\/databases\\/spanner-db\",\"service\":\"spanner\",\"type\":\"spanner.databases\"}}],\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase\",\"request\":{\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.CreateDatabaseRequest\",\"createStatement\":\"CREATE DATABASE `spanner-db`\",\"parent\":\"projects\\/project-sccd\\/instances\\/spanner-plugin\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.69\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/93.0.4577.82 Safari\\/537.36,gzip(gfe)\",\"destinationAttributes\":{},\"requestAttributes\":{\"auth\":{},\"time\":\"2021-09-22T05:18:43.475279952Z\"}},\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-plugin\\/databases\\/spanner-db\",\"response\":{\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.Database\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-plugin\\/databases\\/spanner-db\"},\"serviceName\":\"spanner.googleapis.com\",\"status\":{}},\"receiveTimestamp\":\"2021-09-22T05:18:50.888616258Z\",\"resource\":{\"labels\":{\"instance_config\":\"\",\"instance_id\":\"spanner-plugin\",\"location\":\"asia-southeast1\",\"project_id\":\"project-sccd\"},\"type\":\"spanner_instance\"},\"severity\":\"NOTICE\",\"timestamp\":\"2021-09-22T05:18:43.470573031Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("51684807", record.getSessionId()); assertEquals("project-sccd:spanner-plugin:spanner-db", record.getDbName()); @@ -310,7 +310,7 @@ public void filterCreateDbTest() { public void filterCreateTableParserTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.189.18\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/99.0.4844.74 Safari\\/537.36 Edg\\/99.0.1150.55,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-04-06T05:04:40.500711551Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"statements\":[\"CREATE TABLE Singers (\\r\\n SingerId INT64 NOT NULL, FirstName STRING(1024),\\r\\n LastName STRING(1024),\\r\\n BirthDate DATE,\\r\\n LastUpdated TIMESTAMP \\r\\n) PRIMARY KEY(SingerId)\"],\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"1u1ppuad9hfv\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-04-06T05:04:40.500451180Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_f5cc4877dc787659\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-06T05:04:44.336426139Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1479311085", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -338,7 +338,7 @@ public void filterCreateTable2Test() { public void filterCreateTableMulitipleQueriesTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.18\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.47,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-20T06:34:40.726294409Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\",\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"statements\":[\"CREATE TABLE Student2 (id INT64, first_name STRING(8), last_name STRING(9)) PRIMARY KEY(id)\",\"CREATE TABLE Course2 (id INT64, name STRING(16), teacher_id INT64) PRIMARY KEY(id)\",\"CREATE TABLE Student_Course2 (id INT64, student_id INT64,ccourse_id INT64) PRIMARY KEY(id)\"]},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"4q77ttd2tkm\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"instance_config\":\"\",\"instance_id\":\"spanner-test\",\"location\":\"asia-south1\"}},\"timestamp\":\"2022-05-20T06:34:40.721072488Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_f170d20887b0fab1\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-20T06:34:45.338515375Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("214548392", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -351,7 +351,7 @@ public void filterCreateTableMulitipleQueriesTest() { public void filterDropTableMulitipleQueriesTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.33\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.47,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-21T05:54:41.851790255Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\",\"statements\":[\"DROP TABLE Student3\",\"DROP TABLE Course3\",\"DROP TABLE Student_Course3\"],\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"1o7uzcod8220\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\",\"instance_config\":\"\",\"location\":\"asia-south1\"}},\"timestamp\":\"2022-05-21T05:54:41.847332270Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_347090d341a0617c\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-21T05:54:45.060197542Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1936537039", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -364,7 +364,7 @@ public void filterDropTableMulitipleQueriesTest() { public void filterDropTableTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.39\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-06T08:46:06.985225527Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\",\"statements\":[\"DROP TABLE Songs2\"]},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"of21i9ddpjz\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\",\"location\":\"asia-south1\"}},\"timestamp\":\"2022-05-06T08:46:06.981176953Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_083d1418844a9074\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-06T08:46:11.839441524Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("83340809", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -437,7 +437,7 @@ public void filterSqlWithoutObjTest() { public void filterJoinSqlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.43\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-26T08:59:22.712893673Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ_VBi3iJps_wB62vfVcUecmWo42wksR6UwdBjpYyQD7WnmXdlKQRucDkA\",\"request\":{\"queryMode\":\"PROFILE\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ_VBi3iJps_wB62vfVcUecmWo42wksR6UwdBjpYyQD7WnmXdlKQRucDkA\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"sql\":\"SELECT s.FirstName, a.MarketingBudget\\nFROM Singers AS s JOIN Albums AS a ON s.SingerId = a.SingerId;\"}},\"insertId\":\"10mu3rld3j2z\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-test\",\"location\":\"asia-south1\",\"instance_config\":\"\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-26T08:59:22.708364199Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"7805286887883402045\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-26T08:59:23.605988325Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("235796560", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -450,7 +450,7 @@ public void filterJoinSqlTest() { public void filterInnerJoinSqlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.18\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-04T07:46:30.260464604Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0ajRzXJkOqs6YmKFH_lQve72ysAKd9DPLNCZf3sLh61zOiH2f5NugyESQ\",\"request\":{\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0ajRzXJkOqs6YmKFH_lQve72ysAKd9DPLNCZf3sLh61zOiH2f5NugyESQ\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"sql\":\"SELECT Singers.FirstName,AckworthSingers.LastName\\nFROM Singers JOIN AckworthSingers ON Singers.SingerId = AckworthSingers.SingerId;\",\"queryMode\":\"PROFILE\"}},\"insertId\":\"1typdnsz0\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\",\"location\":\"asia-south1\"}},\"timestamp\":\"2022-05-04T07:46:30.255993168Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"16343214564427054759\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-04T07:46:30.668678045Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("214548392", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -478,7 +478,7 @@ public void filterBlanlkSqlTest() { public void filterAlterTableTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.182.37\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-11T05:17:18.770782310Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"statements\":[\"ALTER TABLE Singers ADD column Email STRING(1024)\"],\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"1b67srne128md\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\",\"location\":\"asia-south1\",\"instance_config\":\"\"}},\"timestamp\":\"2022-05-11T05:17:18.765979068Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_d2c83ca9d0c89699\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-11T05:17:24.055109071Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-1809150263", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -491,7 +491,7 @@ public void filterAlterTableTest() { public void filterCreateIndexDDlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.39\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-06T07:27:44.431316422Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"statements\":[\"CREATE INDEX SingersByFirstLastName4 ON singers(FirstName, LastName)\"],\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"1rtjo6hda5jn\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"project_id\":\"project-sccd\",\"location\":\"asia-south1\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-05-06T07:27:44.427428445Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_59d518eec4e446db\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-06T07:27:48.124308859Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("83340809", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -504,7 +504,7 @@ public void filterCreateIndexDDlTest() { public void filterIndexWithOptionalDDlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.127\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-06-23T09:55:03.065385347Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"request\":{\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\",\"statements\":[\"CREATE UNIQUE NULL_FILTERED INDEX SingersByFirstLastName2 ON singers(FirstName, LastName)\"],\"database\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"xky932cgab\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-dev\",\"project_id\":\"project-sccd\",\"instance_config\":\"\",\"location\":\"asia-south1\"}},\"timestamp\":\"2022-06-23T09:55:03.062462909Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\\/operations\\/_auto_op_8f26e22fddd24b91\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-06-23T09:55:06.632922036Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("619635321", record.getSessionId()); assertEquals("project-sccd:spanner-dev:first-db", record.getDbName()); @@ -517,7 +517,7 @@ public void filterIndexWithOptionalDDlTest() { public void filterCreateViewDDlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.39\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-06T07:30:27.886132419Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"statements\":[\"Create VIEW ByDiscountSale SQL SECURITY INVOKER AS Select O.customerNumber, O.orderNumber from QAOrders O where O.discounT=20\"],\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"1rtjo6hda5kx\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"location\":\"asia-south1\",\"instance_config\":\"\",\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-06T07:30:27.883542030Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_87e6488fec576fea\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-06T07:30:31.139264583Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("83340809", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -530,7 +530,7 @@ public void filterCreateViewDDlTest() { public void filterCreateOrReplaceViewDDlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.127\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.124 Safari\\/537.36 Edg\\/102.0.1245.44,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-06-23T11:53:07.175897019Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"request\":{\"database\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\",\"statements\":[\"CREATE OR REPLACE view ByDiscount SQL SECURITY INVOKER AS Select O.customerNumber, O.orderNumber from QAOrders O where O.discounT=20\"],\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"au5jc4d74cz\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"project_id\":\"project-sccd\",\"location\":\"asia-south1\",\"instance_id\":\"spanner-dev\"}},\"timestamp\":\"2022-06-23T11:53:07.173119353Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-dev\\/databases\\/first-db\\/operations\\/_auto_op_bd874c7f73dd6a31\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-06-23T11:53:12.171737967Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("619635321", record.getSessionId()); assertEquals("project-sccd:spanner-dev:first-db", record.getDbName()); @@ -543,7 +543,7 @@ public void filterCreateOrReplaceViewDDlTest() { public void filterCollateQueriesTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.82\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-10T07:13:10.687396097Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0aEcFvL2eHfBo2Xb1x8L-VHynaYYxVJ440BJGefVAXFwwsBhKf5EHvoYw\",\"request\":{\"sql\":\"SELECT FirstName FROM Singers ORDER BY FirstName COLLATE \\\"en_CA\\\"\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0aEcFvL2eHfBo2Xb1x8L-VHynaYYxVJ440BJGefVAXFwwsBhKf5EHvoYw\",\"queryMode\":\"PROFILE\"}},\"insertId\":\"1vzd1fidlwiu\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"location\":\"asia-south1\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\",\"instance_config\":\"\"}},\"timestamp\":\"2022-05-10T07:13:10.687149481Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"9563794440567017670\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-10T07:13:10.769721099Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-1247504139", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -571,7 +571,7 @@ public void filterComplexJoinTest() { public void filterDropViewDDlTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\",\"principalSubject\":\"user:pankaj-g766@hcl.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.39\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-06T07:31:18.063748131Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.updateDdl\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"request\":{\"statements\":[\"DROP VIEW ByDiscountSale\"],\"database\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"@type\":\"type.googleapis.com\\/google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.longrunning.Operation\"}},\"insertId\":\"1rtjo6hda5l7\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"location\":\"asia-south1\",\"instance_id\":\"spanner-test\",\"instance_config\":\"\"}},\"timestamp\":\"2022-05-06T07:31:18.059626861Z\",\"severity\":\"NOTICE\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Factivity\",\"operation\":{\"id\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/operations\\/_auto_op_f0022701e52b7ade\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-06T07:31:21.142940626Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("83340809", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -599,7 +599,7 @@ public void filterIntersectAllTest() { public void filterTableSampleTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.82\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-10T07:11:03.695302378Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0Z7s9pt2thmUipqygXVXNeBscdpoPEctPim8HT_melLsI_Gn0XBXw8XJA\",\"request\":{\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0Z7s9pt2thmUipqygXVXNeBscdpoPEctPim8HT_melLsI_Gn0XBXw8XJA\",\"queryMode\":\"PROFILE\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"sql\":\"SELECT SingerId FROM Singers TABLESAMPLE BERNOULLI (0.1 PERCENT)\"}},\"insertId\":\"1vzd1fidlwh4\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"project_id\":\"project-sccd\",\"instance_config\":\"\",\"location\":\"asia-south1\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-05-10T07:11:03.695081824Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"9581259756418334896\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-10T07:11:04.027739630Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-1247504139", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -671,7 +671,7 @@ public void filterTimestampTest() { public void filterSelectCustomParserTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.73\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/100.0.4896.127 Safari\\/537.36 Edg\\/100.0.1185.50,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-04-26T12:02:34.853241708Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0ZRnChs6K4dbngNt3ICWHWlM7PEK_0zGralREXja09C-tbna2rqiPl9yQ\",\"request\":{\"queryMode\":\"PROFILE\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AH-i_0ZRnChs6K4dbngNt3ICWHWlM7PEK_0zGralREXja09C-tbna2rqiPl9yQ\",\"sql\":\"SELECT SingerId FROM Singers MATERIALIZED BERNOULLI (0.1 PERCENT)\"}},\"insertId\":\"1lpovsaf2u0n15\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-test\",\"project_id\":\"project-sccd\",\"instance_config\":\"\",\"location\":\"us-central1\"}},\"timestamp\":\"2022-04-26T12:02:34.852924678Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"12631762209399029108\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-04-26T12:02:36.143153614Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-571457581", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -698,7 +698,7 @@ public void filterSelectCustomParserTest2() { public void filterLikeOperatorTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.188.229\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/98.0.4758.102 Safari\\/537.36 Edg\\/98.0.1108.62,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-03-06T10:03:43.817387774Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x_3xb7nwA0H7S6B8hLV3AzHNPVKl7PzemyrtB21HA3RoJOaQxccdeqoAw\",\"request\":{\"sql\":\"select * from Employees where LastName 'LIKE A%'\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"queryMode\":\"PROFILE\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AN4G3x_3xb7nwA0H7S6B8hLV3AzHNPVKl7PzemyrtB21HA3RoJOaQxccdeqoAw\"}},\"insertId\":\"1snxb5rdflup\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"location\":\"us-central1\",\"project_id\":\"project-sccd\",\"instance_id\":\"spanner-test\"}},\"timestamp\":\"2022-03-06T10:03:43.817102127Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"13710611471873755832\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-03-06T10:03:44.673334332Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1875025146", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -772,7 +772,7 @@ public void filterUnnestTestNeg() { public void filterUnnestTest2Neg() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.7\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-27T04:54:05.871373724Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ9Xe3okitfV6P2Hyd9czr-UnqoK1PhETnz74NTUZyEb8KTmV-uV6HObFg\",\"request\":{\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ9Xe3okitfV6P2Hyd9czr-UnqoK1PhETnz74NTUZyEb8KTmV-uV6HObFg\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"queryMode\":\"PROFILE\",\"sql\":\"SELECT SUM(DISTINCT x) AS sum FROM UNNEST([1, 2, 3, 4, 5, 4, 3, 2, 1]) AS x;\"}},\"insertId\":\"10mu3rld3xxq\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-test\",\"instance_config\":\"\",\"location\":\"asia-south1\",\"project_id\":\"project-sccd\"}},\"timestamp\":\"2022-05-27T04:54:05.866550897Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"3061561076673982531\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-27T04:54:06.221777470Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("1877432704", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -783,7 +783,7 @@ public void filterUnnestTest2Neg() { public void filterJoinOrderTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"168.149.184.43\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/101.0.4951.64 Safari\\/537.36 Edg\\/101.0.1210.53,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-05-26T10:08:10.144162364Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ-H3z0ZH6QfH0ejMJ2Nj-WMPZikwGeEckIOkWuAIa8bEg4XVbPUDTyvrA\",\"request\":{\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ-H3z0ZH6QfH0ejMJ2Nj-WMPZikwGeEckIOkWuAIa8bEg4XVbPUDTyvrA\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"sql\":\"SELECT *\\nFROM Singers AS s JOIN@{FORCE_JOIN_ORDER=TRUE} Albums AS a\\nON s.SingerId = a.Singerid\\nWHERE s.LastName LIKE '%a' AND a.AlbumTitle LIKE 'G%';\",\"queryMode\":\"PROFILE\"}},\"insertId\":\"y4nt9od21zm\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-test\",\"location\":\"asia-south1\",\"project_id\":\"project-sccd\",\"instance_config\":\"\"}},\"timestamp\":\"2022-05-26T10:08:10.137901588Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"2738706054634786023\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-05-26T10:08:11.757949748Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("235796560", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -855,7 +855,7 @@ public void filterSqlWithSingleLineCommentTest() { public void filterSqlWithMultiLineCommentTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"user@test.com\"},\"requestMetadata\":{\"callerIp\":\"148.64.5.12\",\"callerSuppliedUserAgent\":\"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/102.0.5005.63 Safari\\/537.36 Edg\\/102.0.1245.33,gzip(gfe),gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-06-13T05:43:37.083408134Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteStreamingSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"permission\":\"spanner.databases.select\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ_2kgWCr9w5pG7plvvT1dqSSoNhl8qRmOANgvjlyVR2AhuAegCTVNdAOQ\",\"request\":{\"sql\":\"select FirstName, ----------it will display first name.\\nLastName from singers\\n\",\"queryMode\":\"PROFILE\",\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-test\\/databases\\/test\\/sessions\\/AP1odZ_2kgWCr9w5pG7plvvT1dqSSoNhl8qRmOANgvjlyVR2AhuAegCTVNdAOQ\"}},\"insertId\":\"1lzp1jmf15241v\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_id\":\"spanner-test\",\"location\":\"asia-south1\",\"project_id\":\"project-sccd\",\"instance_config\":\"\"}},\"timestamp\":\"2022-06-13T05:43:37.083245617Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"operation\":{\"id\":\"7720251317467415618\",\"producer\":\"spanner.googleapis.com\",\"first\":true},\"receiveTimestamp\":\"2022-06-13T05:43:37.152844729Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); Sentence sentence = record.getData().getConstruct().getSentences().get(0); assertEquals("-2082082286", record.getSessionId()); assertEquals("project-sccd:spanner-test:test", record.getDbName()); @@ -898,7 +898,7 @@ public void filterDeleteWithoutFromTest() { public void filterAutomationInsertTest() { final String gcpString2 = "{\"protoPayload\":{\"@type\":\"type.googleapis.com\\/google.cloud.audit.AuditLog\",\"authenticationInfo\":{\"principalEmail\":\"automation-spanner@project-sccd.iam.gserviceaccount.com\",\"serviceAccountKeyName\":\"\\/\\/iam.googleapis.com\\/projects\\/project-sccd\\/serviceAccounts\\/automation-spanner@project-sccd.iam.gserviceaccount.com\\/keys\\/14c38b258dc0bca0a5bb16ea5cfaba33c2186e94\",\"principalSubject\":\"serviceAccount:automation-spanner@project-sccd.iam.gserviceaccount.com\"},\"requestMetadata\":{\"callerIp\":\"111.222.333.444\",\"callerSuppliedUserAgent\":\"spanner-java\\/2.0.0 grpc-java-netty\\/1.44.1,gzip(gfe)\",\"requestAttributes\":{\"time\":\"2022-06-14T14:17:23.622208179Z\",\"auth\":{}},\"destinationAttributes\":{}},\"serviceName\":\"spanner.googleapis.com\",\"methodName\":\"google.spanner.v1.Spanner.ExecuteSql\",\"authorizationInfo\":[{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-divya\\/databases\\/spanner-auto5\",\"permission\":\"spanner.databases.beginOrRollbackReadWriteTransaction\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-divya\\/databases\\/spanner-auto5\",\"type\":\"spanner.databases\"}},{\"resource\":\"projects\\/project-sccd\\/instances\\/spanner-divya\\/databases\\/spanner-auto5\",\"permission\":\"spanner.databases.write\",\"granted\":true,\"resourceAttributes\":{\"service\":\"spanner\",\"name\":\"projects\\/project-sccd\\/instances\\/spanner-divya\\/databases\\/spanner-auto5\",\"type\":\"spanner.databases\"}}],\"resourceName\":\"projects\\/project-sccd\\/instances\\/spanner-divya\\/databases\\/spanner-auto5\\/sessions\\/AP1odZ_CFFGhflVVEDixe447b4y4AoTvh3exiNPS2DYpf7mNLFHh8tZEf4amIQ\",\"request\":{\"requestOptions\":{},\"sql\":\"insert into `ACCOUNT_MASTER` (`AccountName`, `groupID`, `account_id`) values (@p1, @p2, @p3)\",\"queryOptions\":{},\"@type\":\"type.googleapis.com\\/google.spanner.v1.ExecuteSqlRequest\",\"session\":\"projects\\/project-sccd\\/instances\\/spanner-divya\\/databases\\/spanner-auto5\\/sessions\\/AP1odZ_CFFGhflVVEDixe447b4y4AoTvh3exiNPS2DYpf7mNLFHh8tZEf4amIQ\"},\"response\":{\"@type\":\"type.googleapis.com\\/google.spanner.v1.ResultSet\"}},\"insertId\":\"1b6c67md3n1u\",\"resource\":{\"type\":\"spanner_instance\",\"labels\":{\"instance_config\":\"\",\"project_id\":\"project-sccd\",\"location\":\"asia-south1\",\"instance_id\":\"spanner-divya\"}},\"timestamp\":\"2022-06-14T14:17:23.617454797Z\",\"severity\":\"INFO\",\"logName\":\"projects\\/project-sccd\\/logs\\/cloudaudit.googleapis.com%2Fdata_access\",\"receiveTimestamp\":\"2022-06-14T14:17:24.534688004Z\"}"; final JsonObject spannerJson = JsonParser.parseString(gcpString2).getAsJsonObject(); - Record record = Parser.parseRecord(spannerJson); + UCRecord record = Parser.parseRecord(spannerJson); SessionLocator actual = record.getSessionLocator(); assertEquals("0.0.0.0", actual.getServerIp()); assertEquals(-1, actual.getServerPort()); diff --git a/filter-plugin/logstash-filter-redshift-aws-guardium/build.gradle b/filter-plugin/logstash-filter-redshift-aws-guardium/build.gradle index b38356506..8c478c805 100644 --- a/filter-plugin/logstash-filter-redshift-aws-guardium/build.gradle +++ b/filter-plugin/logstash-filter-redshift-aws-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "RedShiftGuardiumConnector" pluginInfo.pluginName = "redshift_guardium_connector" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-redshift-aws-guardium/gradlew b/filter-plugin/logstash-filter-redshift-aws-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/Parser.java b/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/Parser.java index 681363ced..3abb8f66d 100644 --- a/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/Parser.java +++ b/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/Parser.java @@ -4,7 +4,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Construct; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.Sentence; import com.ibm.guardium.universalconnector.commons.structures.SentenceObject; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; @@ -46,8 +46,8 @@ public class Parser { * @param event * @return record */ - public static Record parseRecord(final Event event) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final Event event) throws ParseException { + UCRecord record = new UCRecord(); String sessionId = RedShiftTags.NA_STRING; String dbName = RedShiftTags.UNKNOWN_STRING; record.setSessionId( @@ -128,7 +128,7 @@ public static SessionLocator parseSessionLocator(final Event event) { * @param event * @return Accessor */ - public static Accessor parseAccessor(final Event event, final Record record) { + public static Accessor parseAccessor(final Event event, final UCRecord record) { Accessor accessor = new Accessor(); if (event.getField(RedShiftTags.U_IDENTIFIER) != null) { accessor.setDbUser(event.getField(RedShiftTags.U_IDENTIFIER).toString()); diff --git a/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/RedShiftGuardiumConnector.java b/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/RedShiftGuardiumConnector.java index 7b776ca1d..598f9f4f2 100644 --- a/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/RedShiftGuardiumConnector.java +++ b/filter-plugin/logstash-filter-redshift-aws-guardium/src/main/java/com/ibm/guardium/redshift/RedShiftGuardiumConnector.java @@ -8,7 +8,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; import co.elastic.logstash.api.Event; @@ -61,7 +61,7 @@ public Collection filter(Collection events, FilterMatchListener ma && !e.getField(RedShiftTags.USER_NAME).toString().equalsIgnoreCase("RDSDB") && e.getField(RedShiftTags.STATUS).toString().equalsIgnoreCase("authentication failure"))) { try { - Record record = Parser.parseRecord(e); + UCRecord record = Parser.parseRecord(e); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/ParserTest.java b/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/ParserTest.java index 2d434f7bf..59e859322 100644 --- a/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/ParserTest.java +++ b/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/ParserTest.java @@ -10,7 +10,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -19,7 +19,7 @@ class ParserTest { @Test public void testparseAccessor() { - Record record = new Record(); + UCRecord record = new UCRecord(); record.setDbName("979326520502_guardiumredshift:dev"); Event e = new org.logstash.Event(); e.setField("username", "awsuser"); @@ -107,7 +107,7 @@ public void testparseRecord_ConnectionLog() throws ParseException { e.setField("year", "2022"); e.setField("time", "04:58:51:641"); e.setField("action", "authentication failure"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("796", record.getSessionId()); assertEquals("979326520502_guardiumredshift:dev", record.getDbName()); @@ -127,7 +127,7 @@ public void testparseRecord_UserActivityLog() throws ParseException { e.setField("user", "awsuser"); e.setField("timestamp", "2022-03-17T07:34:29.118Z"); e.setField("sql_query", "SELECT d.datname as Name"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("1073979586", record.getSessionId()); assertEquals("979326520502_guardiumredshift:dev", record.getDbName()); @@ -142,7 +142,7 @@ public void testparseRecord_NA() throws ParseException { e.setField("pid", "1073979586"); e.setField("timestamp", "2022-03-17T07:34:29.118Z"); e.setField("sql_query", "SELECT d.datname as Name"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("1073979586", record.getSessionId()); assertEquals(1647502469118L, record.getTime().getTimstamp()); diff --git a/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/RedShiftGuardiumConnectorTest.java b/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/RedShiftGuardiumConnectorTest.java index db1ede4ae..0a6ff9917 100644 --- a/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/RedShiftGuardiumConnectorTest.java +++ b/filter-plugin/logstash-filter-redshift-aws-guardium/src/test/java/com/ibm/guardium/redshift/RedShiftGuardiumConnectorTest.java @@ -338,7 +338,7 @@ public void testparseRecord1() { e.setField("dbprefix", "979326520502_guardiumredshift"); e.setField("serverHostnamePrefix", "979326520502_guardiumredshift"); e.setField("sql_query", - "LOG: CREATE TABLE T1 (   col1 Varchar(20) distkey sortkey );"); + "LOG: CREATE TABLE T1 ( col1 Varchar(20) distkey sortkey );"); Collection results = filter.filter(Collections.singletonList(e), matchListener); Assert.assertEquals(1, results.size()); Assert.assertNotNull(e.getField(GuardConstants.GUARDIUM_RECORD_FIELD_NAME)); diff --git a/filter-plugin/logstash-filter-s3-guardium/build.gradle b/filter-plugin/logstash-filter-s3-guardium/build.gradle index b743e1a9d..b583e733a 100644 --- a/filter-plugin/logstash-filter-s3-guardium/build.gradle +++ b/filter-plugin/logstash-filter-s3-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "LogstashFilterS3Guardium" pluginInfo.pluginName = "logstash_filter_s3_guardium" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-s3-guardium/logstash-filter-logstash_filter_s3_guardium.zip b/filter-plugin/logstash-filter-s3-guardium/logstash-filter-logstash_filter_s3_guardium.zip index 70703728d..0db40fc95 100644 Binary files a/filter-plugin/logstash-filter-s3-guardium/logstash-filter-logstash_filter_s3_guardium.zip and b/filter-plugin/logstash-filter-s3-guardium/logstash-filter-logstash_filter_s3_guardium.zip differ diff --git a/filter-plugin/logstash-filter-s3-guardium/src/main/java/com/ibm/guardium/s3/Parser.java b/filter-plugin/logstash-filter-s3-guardium/src/main/java/com/ibm/guardium/s3/Parser.java index e5d053924..6cc839c41 100644 --- a/filter-plugin/logstash-filter-s3-guardium/src/main/java/com/ibm/guardium/s3/Parser.java +++ b/filter-plugin/logstash-filter-s3-guardium/src/main/java/com/ibm/guardium/s3/Parser.java @@ -6,16 +6,16 @@ */ package com.ibm.guardium.s3; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; - import com.google.gson.*; import com.ibm.guardium.universalconnector.commons.structures.*; - +import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import sun.net.util.IPAddressUtil; + +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Set; public class Parser { @@ -32,13 +32,13 @@ public class Parser { private static final Gson gson = new Gson(); - public static Record buildRecord(JsonElement auditEl) throws Exception { + public static UCRecord buildRecord(JsonElement auditEl) throws Exception { if (auditEl==null || !auditEl.isJsonObject()){ throw new Exception("Invalid event data"); } - Record record = new Record(); + UCRecord record = new UCRecord(); // ------------------ Build record upper layer // userIdentity is a mandatory property @@ -279,7 +279,9 @@ public static String getHost(JsonObject requestParameters){ } public static String validateIP(String sourceIPAddress){ - if (IPAddressUtil.isIPv4LiteralAddress(sourceIPAddress) || IPAddressUtil.isIPv6LiteralAddress(sourceIPAddress)){ + var inetValidator = InetAddressValidator.getInstance(); + if (inetValidator.isValidInet4Address(sourceIPAddress) || + inetValidator.isValidInet6Address(sourceIPAddress)){ return sourceIPAddress; } else { return UNKNOWN_IP; @@ -360,7 +362,7 @@ public static void main(String[] args){ JsonObject inputJSON = (JsonObject) JsonParser.parseString(parseErrorEvent); // JsonObject inputJSON = (JsonObject) JsonParser.parseString(EventSamples.getSamplesByEventName(EventSamples.EventName.DeleteBucket).get(0).getJsonStr()); - Record record = Parser.buildRecord(inputJSON); + UCRecord record = Parser.buildRecord(inputJSON); System.out.println(record); String recordStr = gson.toJson(record); System.out.println(recordStr); diff --git a/filter-plugin/logstash-filter-s3-guardium/src/main/java/org/logstashplugins/LogstashFilterS3Guardium.java b/filter-plugin/logstash-filter-s3-guardium/src/main/java/org/logstashplugins/LogstashFilterS3Guardium.java index 5acef613e..bede6e3e6 100644 --- a/filter-plugin/logstash-filter-s3-guardium/src/main/java/org/logstashplugins/LogstashFilterS3Guardium.java +++ b/filter-plugin/logstash-filter-s3-guardium/src/main/java/org/logstashplugins/LogstashFilterS3Guardium.java @@ -16,7 +16,7 @@ import com.google.gson.*; import com.ibm.guardium.s3.Parser; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -89,7 +89,7 @@ public Collection filter(Collection events, FilterMatchListener ma throw new Exception("Invalid event, no relevant for s3 parser properties found"); } - Record record = Parser.buildRecord(inputJSON); + UCRecord record = Parser.buildRecord(inputJSON); if (record==null){ log.warn("Failed to parse event "+logEvent(e)); continue; diff --git a/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/ParserTest.java b/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/ParserTest.java index 5eaf128f4..5d22b78a3 100644 --- a/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/ParserTest.java +++ b/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/ParserTest.java @@ -12,7 +12,7 @@ import com.ibm.guardium.samples.EventSamples; import com.ibm.guardium.s3.Parser; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,7 +27,7 @@ public void testParseAsConstruct_Find() { // final String actualResult = Parser.Parse(mongoJson); JsonObject inputJSON = (JsonObject) JsonParser.parseString(EventSamples.getSamplesByEventName(EventSamples.EventName.GetObject).get(0).getJsonStr()); try { - // Record result = Parser.buildRecord(inputJSON); + // UCRecord result = Parser.buildRecord(inputJSON); System.out.println("result"); } catch (Exception e) { e.printStackTrace(); diff --git a/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/SampledEventsTest.java b/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/SampledEventsTest.java index 3ef911cb7..b6997ee68 100644 --- a/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/SampledEventsTest.java +++ b/filter-plugin/logstash-filter-s3-guardium/src/test/java/com/ibm/guardium/SampledEventsTest.java @@ -9,7 +9,7 @@ import com.google.gson.JsonParser; import com.ibm.guardium.samples.EventSamples; import com.ibm.guardium.s3.Parser; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,7 +42,7 @@ public static Collection data() { public void testParseAsConstruct_dbname() throws Exception{ JsonObject inputJSON = (JsonObject) JsonParser.parseString(event.getJsonStr()); - Record result = Parser.buildRecord(inputJSON); + UCRecord result = Parser.buildRecord(inputJSON); Assert.assertTrue("db name is null, event "+event, result.getDbName() != null); // for PutAccessPolicy event we do not have dbname available if (!EventSamples.EventName.PutAccessPolicy.equals(event.getEventName()) && @@ -54,7 +54,7 @@ public void testParseAsConstruct_dbname() throws Exception{ @Test public void testParseAsConstruct_appUserName() throws Exception{ JsonObject inputJSON = (JsonObject) JsonParser.parseString(event.getJsonStr()); - Record result = Parser.buildRecord(inputJSON); + UCRecord result = Parser.buildRecord(inputJSON); Assert.assertTrue("app user name is null, event "+event, result.getAppUserName()!= null); Assert.assertTrue("app user name is empty, event "+event, result.getAppUserName().length() != 0); } @@ -63,7 +63,7 @@ public void testParseAsConstruct_appUserName() throws Exception{ public void testParseAsConstruct_SessionLocator_clientIp() throws Exception{ JsonObject inputJSON = (JsonObject) JsonParser.parseString(event.getJsonStr()); - Record result = Parser.buildRecord(inputJSON); + UCRecord result = Parser.buildRecord(inputJSON); String clientIp = result.getSessionLocator().getClientIp(); System.out.println(clientIp); Assert.assertTrue("app user name is null, event "+event, clientIp!= null); @@ -75,7 +75,7 @@ public void testParseAsConstruct_SessionLocator_clientIp() throws Exception{ public void testParseAsConstruct_SessionLocator_serverIp() throws Exception{ JsonObject inputJSON = (JsonObject) JsonParser.parseString(event.getJsonStr()); - Record result = Parser.buildRecord(inputJSON); + UCRecord result = Parser.buildRecord(inputJSON); String serverIp = result.getSessionLocator().getServerIp(); System.out.println(serverIp); Assert.assertTrue("app user name is null, event "+event, serverIp!= null); diff --git a/filter-plugin/logstash-filter-s3-guardium/src/test/java/org/logstashplugins/JavaFilterExampleTest.java b/filter-plugin/logstash-filter-s3-guardium/src/test/java/org/logstashplugins/JavaFilterExampleTest.java index 67c522117..314b064ca 100644 --- a/filter-plugin/logstash-filter-s3-guardium/src/test/java/org/logstashplugins/JavaFilterExampleTest.java +++ b/filter-plugin/logstash-filter-s3-guardium/src/test/java/org/logstashplugins/JavaFilterExampleTest.java @@ -75,8 +75,8 @@ public void testJavaExampleFilter() { Assert.assertTrue(recordStr!=null && recordStr.length()>0); // ip resolution s3-1.amazonaws.com may give different ips, no need to test only relevant properties and think about worthiness of ip resolution here ... -// Record record = new Gson().fromJson(recordStr, Record.class); -// Record recordExpected = new Gson().fromJson("{\"sessionId\":\"{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"}\",\"dbName\":\"guardium01\",\"appUserName\":\"AWSServiceRoleForTrustedAdvisor\",\"time\":1594688637000,\"gmtOffsetInMin\":0,\"dstOffsetInMin\":0,\"sessionLocator\":{\"clientIp\":\"10.246.238.2\",\"clientPort\":0,\"serverIp\":\"52.216.133.245\",\"serverPort\":0,\"isIpv6\":false,\"clientIpv6\":null,\"serverIpv6\":null},\"accessor\":{\"dbUser\":\"AWSServiceRoleForTrustedAdvisor\",\"serverType\":\"S3\",\"serverOs\":\"\",\"clientOs\":\"\",\"clientHostName\":\"10.246.238.2\",\"serverHostName\":\"s3.amazonaws.com\",\"commProtocol\":\"AwsApiCall\",\"dbProtocol\":\"S3\",\"dbProtocolVersion\":\"1.05\",\"osUser\":\"\",\"sourceProgram\":\"AWS-Support-TrustedAdvisor, aws-internal\",\"client_mac\":\"\",\"serverDescription\":\"us-east-1\",\"serviceName\":\"s3.amazonaws.com\",\"language\":\"\",\"type\":\"AwsApiCall\"},\"data\":{\"construct\":{\"sentences\":[{\"verb\":\"GetBucketLocation\",\"objects\":[{\"name\":\"\",\"type\":null,\"fields\":[],\"schema\":\"\"}],\"descendants\":[],\"fields\":[]}],\"fullSql\":\"{\\\"eventVersion\\\":\\\"1.05\\\",\\\"userIdentity\\\":{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"},\\\"eventTime\\\":\\\"2020-07-14T04:03:57Z\\\",\\\"eventSource\\\":\\\"s3.amazonaws.com\\\",\\\"eventName\\\":\\\"GetBucketLocation\\\",\\\"awsRegion\\\":\\\"us-east-1\\\",\\\"sourceIPAddress\\\":\\\"10.246.238.2\\\",\\\"userAgent\\\":\\\"[AWS-Support-TrustedAdvisor, aws-internal/3 aws-sdk-java/1.11.728 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.242-b08 java/1.8.0_242 vendor/Oracle_Corporation]\\\",\\\"requestParameters\\\":{\\\"host\\\":[\\\"s3.us-east-1.amazonaws.com\\\"],\\\"bucketName\\\":\\\"guardium01\\\",\\\"location\\\":[\\\"\\\"],\\\"aws-account\\\":[\\\"987076625343\\\"]},\\\"additionalEventData\\\":{\\\"SignatureVersion\\\":\\\"SigV4\\\",\\\"CipherSuite\\\":\\\"ECDHE-RSA-AES128-SHA\\\",\\\"AuthenticationMethod\\\":\\\"AuthHeader\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"},\\\"requestID\\\":\\\"271E9E0DC890C561\\\",\\\"eventID\\\":\\\"f7a85761-d85a-430f-ac55-a71e1b82a660\\\",\\\"eventType\\\":\\\"AwsApiCall\\\",\\\"recipientAccountId\\\":\\\"987076625343\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"}\",\"redactedSensitiveDataSql\":\"{\\\"eventVersion\\\":\\\"1.05\\\",\\\"userIdentity\\\":{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"},\\\"eventTime\\\":\\\"2020-07-14T04:03:57Z\\\",\\\"eventSource\\\":\\\"s3.amazonaws.com\\\",\\\"eventName\\\":\\\"GetBucketLocation\\\",\\\"awsRegion\\\":\\\"us-east-1\\\",\\\"sourceIPAddress\\\":\\\"10.246.238.2\\\",\\\"userAgent\\\":\\\"[AWS-Support-TrustedAdvisor, aws-internal/3 aws-sdk-java/1.11.728 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.242-b08 java/1.8.0_242 vendor/Oracle_Corporation]\\\",\\\"requestParameters\\\":{\\\"host\\\":[\\\"s3.us-east-1.amazonaws.com\\\"],\\\"bucketName\\\":\\\"guardium01\\\",\\\"location\\\":[\\\"\\\"],\\\"aws-account\\\":[\\\"987076625343\\\"]},\\\"additionalEventData\\\":{\\\"SignatureVersion\\\":\\\"SigV4\\\",\\\"CipherSuite\\\":\\\"ECDHE-RSA-AES128-SHA\\\",\\\"AuthenticationMethod\\\":\\\"AuthHeader\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"},\\\"requestID\\\":\\\"271E9E0DC890C561\\\",\\\"eventID\\\":\\\"f7a85761-d85a-430f-ac55-a71e1b82a660\\\",\\\"eventType\\\":\\\"AwsApiCall\\\",\\\"recipientAccountId\\\":\\\"987076625343\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"}\"},\"originalSqlCommand\":\"{\\\"eventVersion\\\":\\\"1.05\\\",\\\"userIdentity\\\":{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"},\\\"eventTime\\\":\\\"2020-07-14T04:03:57Z\\\",\\\"eventSource\\\":\\\"s3.amazonaws.com\\\",\\\"eventName\\\":\\\"GetBucketLocation\\\",\\\"awsRegion\\\":\\\"us-east-1\\\",\\\"sourceIPAddress\\\":\\\"10.246.238.2\\\",\\\"userAgent\\\":\\\"[AWS-Support-TrustedAdvisor, aws-internal/3 aws-sdk-java/1.11.728 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.242-b08 java/1.8.0_242 vendor/Oracle_Corporation]\\\",\\\"requestParameters\\\":{\\\"host\\\":[\\\"s3.us-east-1.amazonaws.com\\\"],\\\"bucketName\\\":\\\"guardium01\\\",\\\"location\\\":[\\\"\\\"],\\\"aws-account\\\":[\\\"987076625343\\\"]},\\\"additionalEventData\\\":{\\\"SignatureVersion\\\":\\\"SigV4\\\",\\\"CipherSuite\\\":\\\"ECDHE-RSA-AES128-SHA\\\",\\\"AuthenticationMethod\\\":\\\"AuthHeader\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"},\\\"requestID\\\":\\\"271E9E0DC890C561\\\",\\\"eventID\\\":\\\"f7a85761-d85a-430f-ac55-a71e1b82a660\\\",\\\"eventType\\\":\\\"AwsApiCall\\\",\\\"recipientAccountId\\\":\\\"987076625343\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"}\",\"useConstruct\":true},\"exception\":null}", Record.class); +// UCRecord record = new Gson().fromJson(recordStr, UCRecord.class); +// UCRecord recordExpected = new Gson().fromJson("{\"sessionId\":\"{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"}\",\"dbName\":\"guardium01\",\"appUserName\":\"AWSServiceRoleForTrustedAdvisor\",\"time\":1594688637000,\"gmtOffsetInMin\":0,\"dstOffsetInMin\":0,\"sessionLocator\":{\"clientIp\":\"10.246.238.2\",\"clientPort\":0,\"serverIp\":\"52.216.133.245\",\"serverPort\":0,\"isIpv6\":false,\"clientIpv6\":null,\"serverIpv6\":null},\"accessor\":{\"dbUser\":\"AWSServiceRoleForTrustedAdvisor\",\"serverType\":\"S3\",\"serverOs\":\"\",\"clientOs\":\"\",\"clientHostName\":\"10.246.238.2\",\"serverHostName\":\"s3.amazonaws.com\",\"commProtocol\":\"AwsApiCall\",\"dbProtocol\":\"S3\",\"dbProtocolVersion\":\"1.05\",\"osUser\":\"\",\"sourceProgram\":\"AWS-Support-TrustedAdvisor, aws-internal\",\"client_mac\":\"\",\"serverDescription\":\"us-east-1\",\"serviceName\":\"s3.amazonaws.com\",\"language\":\"\",\"type\":\"AwsApiCall\"},\"data\":{\"construct\":{\"sentences\":[{\"verb\":\"GetBucketLocation\",\"objects\":[{\"name\":\"\",\"type\":null,\"fields\":[],\"schema\":\"\"}],\"descendants\":[],\"fields\":[]}],\"fullSql\":\"{\\\"eventVersion\\\":\\\"1.05\\\",\\\"userIdentity\\\":{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"},\\\"eventTime\\\":\\\"2020-07-14T04:03:57Z\\\",\\\"eventSource\\\":\\\"s3.amazonaws.com\\\",\\\"eventName\\\":\\\"GetBucketLocation\\\",\\\"awsRegion\\\":\\\"us-east-1\\\",\\\"sourceIPAddress\\\":\\\"10.246.238.2\\\",\\\"userAgent\\\":\\\"[AWS-Support-TrustedAdvisor, aws-internal/3 aws-sdk-java/1.11.728 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.242-b08 java/1.8.0_242 vendor/Oracle_Corporation]\\\",\\\"requestParameters\\\":{\\\"host\\\":[\\\"s3.us-east-1.amazonaws.com\\\"],\\\"bucketName\\\":\\\"guardium01\\\",\\\"location\\\":[\\\"\\\"],\\\"aws-account\\\":[\\\"987076625343\\\"]},\\\"additionalEventData\\\":{\\\"SignatureVersion\\\":\\\"SigV4\\\",\\\"CipherSuite\\\":\\\"ECDHE-RSA-AES128-SHA\\\",\\\"AuthenticationMethod\\\":\\\"AuthHeader\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"},\\\"requestID\\\":\\\"271E9E0DC890C561\\\",\\\"eventID\\\":\\\"f7a85761-d85a-430f-ac55-a71e1b82a660\\\",\\\"eventType\\\":\\\"AwsApiCall\\\",\\\"recipientAccountId\\\":\\\"987076625343\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"}\",\"redactedSensitiveDataSql\":\"{\\\"eventVersion\\\":\\\"1.05\\\",\\\"userIdentity\\\":{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"},\\\"eventTime\\\":\\\"2020-07-14T04:03:57Z\\\",\\\"eventSource\\\":\\\"s3.amazonaws.com\\\",\\\"eventName\\\":\\\"GetBucketLocation\\\",\\\"awsRegion\\\":\\\"us-east-1\\\",\\\"sourceIPAddress\\\":\\\"10.246.238.2\\\",\\\"userAgent\\\":\\\"[AWS-Support-TrustedAdvisor, aws-internal/3 aws-sdk-java/1.11.728 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.242-b08 java/1.8.0_242 vendor/Oracle_Corporation]\\\",\\\"requestParameters\\\":{\\\"host\\\":[\\\"s3.us-east-1.amazonaws.com\\\"],\\\"bucketName\\\":\\\"guardium01\\\",\\\"location\\\":[\\\"\\\"],\\\"aws-account\\\":[\\\"987076625343\\\"]},\\\"additionalEventData\\\":{\\\"SignatureVersion\\\":\\\"SigV4\\\",\\\"CipherSuite\\\":\\\"ECDHE-RSA-AES128-SHA\\\",\\\"AuthenticationMethod\\\":\\\"AuthHeader\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"},\\\"requestID\\\":\\\"271E9E0DC890C561\\\",\\\"eventID\\\":\\\"f7a85761-d85a-430f-ac55-a71e1b82a660\\\",\\\"eventType\\\":\\\"AwsApiCall\\\",\\\"recipientAccountId\\\":\\\"987076625343\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"}\"},\"originalSqlCommand\":\"{\\\"eventVersion\\\":\\\"1.05\\\",\\\"userIdentity\\\":{\\\"type\\\":\\\"AssumedRole\\\",\\\"principalId\\\":\\\":TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"arn\\\":\\\"arn:aws:sts::987076625343:assumed-role/AWSServiceRoleForTrustedAdvisor/TrustedAdvisor_987076625343_152bf7d3-3289-497e-a68b-60210b555cc4\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"accessKeyId\\\":\\\"\\\",\\\"sessionContext\\\":{\\\"attributes\\\":{\\\"mfaAuthenticated\\\":\\\"false\\\",\\\"creationDate\\\":\\\"2020-07-14T04:03:56Z\\\"},\\\"sessionIssuer\\\":{\\\"type\\\":\\\"Role\\\",\\\"principalId\\\":\\\"\\\",\\\"arn\\\":\\\"arn:aws:iam::987076625343:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor\\\",\\\"accountId\\\":\\\"987076625343\\\",\\\"userName\\\":\\\"AWSServiceRoleForTrustedAdvisor\\\"}},\\\"invokedBy\\\":\\\"AWS Internal\\\"},\\\"eventTime\\\":\\\"2020-07-14T04:03:57Z\\\",\\\"eventSource\\\":\\\"s3.amazonaws.com\\\",\\\"eventName\\\":\\\"GetBucketLocation\\\",\\\"awsRegion\\\":\\\"us-east-1\\\",\\\"sourceIPAddress\\\":\\\"10.246.238.2\\\",\\\"userAgent\\\":\\\"[AWS-Support-TrustedAdvisor, aws-internal/3 aws-sdk-java/1.11.728 Linux/4.9.184-0.1.ac.235.83.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.242-b08 java/1.8.0_242 vendor/Oracle_Corporation]\\\",\\\"requestParameters\\\":{\\\"host\\\":[\\\"s3.us-east-1.amazonaws.com\\\"],\\\"bucketName\\\":\\\"guardium01\\\",\\\"location\\\":[\\\"\\\"],\\\"aws-account\\\":[\\\"987076625343\\\"]},\\\"additionalEventData\\\":{\\\"SignatureVersion\\\":\\\"SigV4\\\",\\\"CipherSuite\\\":\\\"ECDHE-RSA-AES128-SHA\\\",\\\"AuthenticationMethod\\\":\\\"AuthHeader\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"},\\\"requestID\\\":\\\"271E9E0DC890C561\\\",\\\"eventID\\\":\\\"f7a85761-d85a-430f-ac55-a71e1b82a660\\\",\\\"eventType\\\":\\\"AwsApiCall\\\",\\\"recipientAccountId\\\":\\\"987076625343\\\",\\\"vpcEndpointId\\\":\\\"vpce-00dc1369\\\"}\",\"useConstruct\":true},\"exception\":null}", UCRecord.class); // Assert.assertEquals(recordExpected,record); } @@ -94,7 +94,7 @@ public void testJavaExampleFilter() { // Collection results = filter.filter(Collections.singletonList(e), matchListener); // // Assert.assertEquals(1, results.size()); -// Assert.assertNotNull(e.getField("Record")); +// Assert.assertNotNull(e.getField("UCRecord")); // Assert.assertEquals(1, matchListener.getMatchCount()); // } // @@ -231,8 +231,8 @@ public void testJavaExampleFilter() { // Collection results = filter.filter(Collections.singletonList(e), matchListener); // // Assert.assertEquals(1, results.size()); -// String recordString = e.getField("Record").toString(); -// Record record = (new Gson()).fromJson(recordString, Record.class); +// String recordString = e.getField("UCRecord").toString(); +// UCRecord record = (new Gson()).fromJson(recordString, UCRecord.class); // Assert.assertNotNull(record); // // Assert.assertEquals( diff --git a/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverFilebeatPackage/SAPHANA/SAPHANA-offline-plugin.zip b/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverFilebeatPackage/SAPHANA/SAPHANA-offline-plugin.zip index 672150ada..78c34932c 100644 Binary files a/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverFilebeatPackage/SAPHANA/SAPHANA-offline-plugin.zip and b/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverFilebeatPackage/SAPHANA/SAPHANA-offline-plugin.zip differ diff --git a/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverJdbcPackage/SAPHANA/SAPHANA-offline-plugin.zip b/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverJdbcPackage/SAPHANA/SAPHANA-offline-plugin.zip index 672150ada..78c34932c 100644 Binary files a/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverJdbcPackage/SAPHANA/SAPHANA-offline-plugin.zip and b/filter-plugin/logstash-filter-saphana-guardium/SaphanaOverJdbcPackage/SAPHANA/SAPHANA-offline-plugin.zip differ diff --git a/filter-plugin/logstash-filter-saphana-guardium/build.gradle b/filter-plugin/logstash-filter-saphana-guardium/build.gradle index 1efa269cf..4edeb33b1 100644 --- a/filter-plugin/logstash-filter-saphana-guardium/build.gradle +++ b/filter-plugin/logstash-filter-saphana-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "SapHanaGuardiumPluginFilter" pluginInfo.pluginName = "saphana_guardium_plugin_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" @@ -43,8 +43,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-saphana-guardium/gradlew b/filter-plugin/logstash-filter-saphana-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-saphana-guardium/lib/logstash-filter-saphana_guardium_plugin_filter_jars.rb b/filter-plugin/logstash-filter-saphana-guardium/lib/logstash-filter-saphana_guardium_plugin_filter_jars.rb deleted file mode 100644 index 735df6481..000000000 --- a/filter-plugin/logstash-filter-saphana-guardium/lib/logstash-filter-saphana_guardium_plugin_filter_jars.rb +++ /dev/null @@ -1,5 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 - -require 'jar_dependencies' -require_jar('com.ibm.guardium.saphana', 'logstash-filter-saphana_guardium_plugin_filter', '1.0.1') diff --git a/filter-plugin/logstash-filter-saphana-guardium/lib/logstash/filters/saphana_guardium_plugin_filter.rb b/filter-plugin/logstash-filter-saphana-guardium/lib/logstash/filters/saphana_guardium_plugin_filter.rb deleted file mode 100644 index fe796f2da..000000000 --- a/filter-plugin/logstash-filter-saphana-guardium/lib/logstash/filters/saphana_guardium_plugin_filter.rb +++ /dev/null @@ -1,12 +0,0 @@ -# AUTOGENERATED BY THE GRADLE SCRIPT. EDITS WILL BE OVERWRITTEN. -# encoding: utf-8 -require "logstash/filters/base" -require "logstash/namespace" -require "logstash-filter-saphana_guardium_plugin_filter_jars" -require "java" - -class LogStash::Filters::SapHanaGuardiumPluginFilter < LogStash::Filters::Base - config_name "saphana_guardium_plugin_filter" - - def self.javaClass() Java::com.ibm.guardium.saphana.SapHanaGuardiumPluginFilter.java_class; end -end diff --git a/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/Parser.java b/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/Parser.java index a59c5ea54..b1bfe3943 100644 --- a/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/Parser.java +++ b/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/Parser.java @@ -15,9 +15,9 @@ public class Parser { private static Logger log = LogManager.getLogger(Parser.class); - public static Record parseRecord(final JsonObject data) throws ParseException { + public static UCRecord parseRecord(final JsonObject data) throws ParseException { - Record record = new Record(); + UCRecord record = new UCRecord(); if (data != null) { if (data.has(Constants.SESSION_ID) && !data.get(Constants.SESSION_ID).isJsonNull()) { diff --git a/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilter.java b/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilter.java index 9f42023f1..1c0f967b3 100644 --- a/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-saphana-guardium/src/main/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilter.java @@ -58,7 +58,7 @@ public Collection filter(Collection events, FilterMatchListener ma JsonObject data = new JsonObject(); data = inputData(e); try { - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/ParserTest.java b/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/ParserTest.java index cfcd17d0e..897f6ec1a 100644 --- a/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/ParserTest.java +++ b/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/ParserTest.java @@ -12,7 +12,7 @@ import com.ibm.guardium.saphana.Constants; import com.ibm.guardium.saphana.Parser; import com.ibm.guardium.universalconnector.commons.structures.*; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; @@ -44,7 +44,7 @@ public void testParseRecord_CreateTable() throws ParseException { data.addProperty(Constants.SCHEMA_NAME, "SYSTEM"); data.addProperty(Constants.MIN_OFF,"+04:00"); - final Record record = Parser.parseRecord(data); + final UCRecord record = Parser.parseRecord(data); Assert.assertEquals(record.getDbName(), record.getAccessor().getServiceName()); @@ -74,7 +74,7 @@ public void testParseRecord_Error() throws ParseException { data.addProperty(Constants.SCHEMA_NAME, "SYSTEM"); data.addProperty(Constants.MIN_OFF,"+06:00"); - final Record record = Parser.parseRecord(data); + final UCRecord record = Parser.parseRecord(data); Assert.assertEquals("LOGIN_FAILED", record.getException().getExceptionTypeId()); Assert.assertEquals("authentication failed", record.getException().getDescription()); @@ -114,7 +114,7 @@ public void testParseAccessor() throws ParseException { data.addProperty(Constants.SCHEMA_NAME, "SYSTEM"); data.addProperty(Constants.MIN_OFF,"+09:00"); - Record record = Parser.parseRecord(data); + UCRecord record = Parser.parseRecord(data); Accessor actual = record.getAccessor(); Assert.assertEquals(Constants.DB_PROTOCOL, actual.getDbProtocol()); diff --git a/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilterTest.java b/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilterTest.java index da40a1d33..3dca41c68 100644 --- a/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilterTest.java +++ b/filter-plugin/logstash-filter-saphana-guardium/src/test/java/com/ibm/guardium/saphana/SapHanaGuardiumPluginFilterTest.java @@ -9,7 +9,7 @@ import co.elastic.logstash.api.Event; import co.elastic.logstash.api.FilterMatchListener; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; //import org.logstash.plugins.ConfigurationImpl; diff --git a/filter-plugin/logstash-filter-scylldb-guardium/ScyllaDBOverSyslogPackage/guardium_logstash-offline-plugin-scylladb.zip b/filter-plugin/logstash-filter-scylldb-guardium/ScyllaDBOverSyslogPackage/guardium_logstash-offline-plugin-scylladb.zip index def4ae4cb..1c12d0a2f 100644 Binary files a/filter-plugin/logstash-filter-scylldb-guardium/ScyllaDBOverSyslogPackage/guardium_logstash-offline-plugin-scylladb.zip and b/filter-plugin/logstash-filter-scylldb-guardium/ScyllaDBOverSyslogPackage/guardium_logstash-offline-plugin-scylladb.zip differ diff --git a/filter-plugin/logstash-filter-scylldb-guardium/build.gradle b/filter-plugin/logstash-filter-scylldb-guardium/build.gradle index 30a29ecf4..28a792009 100644 --- a/filter-plugin/logstash-filter-scylldb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-scylldb-guardium/build.gradle @@ -22,8 +22,8 @@ pluginInfo.pluginClass = "ScyllaDbGuardiumFilter" pluginInfo.pluginName = "scylladb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 buildscript { repositories { mavenCentral() @@ -34,7 +34,7 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0' + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' //classpath 'org.owasp:dependency-check-gradle:8.3.1' //classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.8" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' @@ -163,4 +163,4 @@ jacocoTestReport { }) } } -test.finalizedBy jacocoTestReport \ No newline at end of file +test.finalizedBy jacocoTestReport diff --git a/filter-plugin/logstash-filter-scylldb-guardium/gradlew b/filter-plugin/logstash-filter-scylldb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/Parser.java b/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/Parser.java index 2ae5b53f4..d7dcaf07b 100644 --- a/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/Parser.java +++ b/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/Parser.java @@ -22,7 +22,7 @@ import co.elastic.logstash.api.Event; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -37,8 +37,8 @@ public class Parser { * @return * @throws Exception */ - public static Record parseRecord(Event event) throws Exception { - Record record = new Record(); + public static UCRecord parseRecord(Event event) throws Exception { + UCRecord record = new UCRecord(); try { Integer hashcode = null; if (event.getField(Constants.DB_NAME) != null && event.getField(Constants.USER_NAME) != null diff --git a/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/ScyllaDbGuardiumFilter.java b/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/ScyllaDbGuardiumFilter.java index 44ed6bd71..f1d010494 100644 --- a/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/ScyllaDbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-scylldb-guardium/src/main/java/com/ibm/guardium/scylladb/ScyllaDbGuardiumFilter.java @@ -13,7 +13,7 @@ import co.elastic.logstash.api.PluginConfigSpec; import com.google.gson.*; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.*; @@ -47,7 +47,7 @@ public Collection filter(Collection events, FilterMatchListener ma log.debug("Event now {}:",event.getData()); } try { - Record rec = Parser.parseRecord(event); + UCRecord rec = Parser.parseRecord(event); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.disableHtmlEscaping().create(); diff --git a/filter-plugin/logstash-filter-scylldb-guardium/src/test/java/com/ibm/guardium/scylladb/ParserTest.java b/filter-plugin/logstash-filter-scylldb-guardium/src/test/java/com/ibm/guardium/scylladb/ParserTest.java index 7baf78c87..21e7297a7 100644 --- a/filter-plugin/logstash-filter-scylldb-guardium/src/test/java/com/ibm/guardium/scylladb/ParserTest.java +++ b/filter-plugin/logstash-filter-scylldb-guardium/src/test/java/com/ibm/guardium/scylladb/ParserTest.java @@ -7,7 +7,7 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Event; public class ParserTest { @@ -25,7 +25,7 @@ public void testParseRecord() throws Exception { e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("mykeyspace", record.getDbName()); assertEquals("172.31.57.239", record.getSessionLocator().getServerIp()); @@ -46,7 +46,7 @@ public void testParsesql() throws Exception { e.setField("error", "\"false\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("USE mykeyspace;", record.getData().getOriginalSqlCommand()); } @@ -62,7 +62,7 @@ public void testParseuser() throws Exception { e.setField("error", "\"false\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("alice1", record.getAccessor().getDbUser()); } @@ -78,7 +78,7 @@ public void testParseLogin_success() throws Exception { e.setField("error", "\"false\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("LOGIN", record.getData().getOriginalSqlCommand()); } @@ -94,7 +94,7 @@ public void testParseLogin_fail() throws Exception { e.setField("error", "\"true\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("", record.getException().getSqlString()); } @@ -110,7 +110,7 @@ public void testParseErrorsql() throws Exception { e.setField("error", "\"true\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("DWP-5CD212FV5L", record.getAccessor().getServerHostName()); assertEquals("Error Occurred", record.getException().getDescription()); @@ -130,7 +130,7 @@ public void testParseMultilineSqltype1() throws Exception { e.setField("error", "\"false\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("CREATE MATERIALIZED VIEW IF NOT EXISTS user_emails_by_id AS\n" + "SELECT user_id, email FROM users --this is singleline\n" @@ -150,7 +150,7 @@ public void testParseMultilineSqltype2() throws Exception { e.setField("error", "\"false\""); e.setField("timestamp", "2024-01-10T02:35:58.000Z"); e.setField("logsource", "DWP-5CD212FV5L"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); assertNotNull(record); assertEquals("drop\n" + "type\n" diff --git a/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-7.12.1.zip b/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-7.12.1.zip index 439302f86..fb808b2b4 100644 Binary files a/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-7.12.1.zip and b/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-7.12.1.zip differ diff --git a/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-8.3.3.zip b/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-8.3.3.zip index 13004e2e7..71533c97f 100644 Binary files a/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-8.3.3.zip and b/filter-plugin/logstash-filter-snowflake-guardium/SnowflakeOverJbdcPackage/Snowflake/logstash-offline-plugins-8.3.3.zip differ diff --git a/filter-plugin/logstash-filter-snowflake-guardium/build.gradle b/filter-plugin/logstash-filter-snowflake-guardium/build.gradle index b59919c0c..87a41406b 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/build.gradle +++ b/filter-plugin/logstash-filter-snowflake-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginName = "guardium_snowflake_filter" // must match the @Logs pluginInfo.email = "" // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/GuardiumSnowflakeFilter.java b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/GuardiumSnowflakeFilter.java index e1c3c99ef..c467b285d 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/GuardiumSnowflakeFilter.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/GuardiumSnowflakeFilter.java @@ -25,7 +25,7 @@ import com.ibm.guardium.snowflakedb.parser.SuccessEventParser; import com.ibm.guardium.snowflakedb.utils.Constants; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.google.gson.*; @@ -79,7 +79,7 @@ public Collection filter(Collection events, FilterMatchListener ma } if(parser != null){ - Record rec = parser.parseRecord(event.toMap()); + UCRecord rec = parser.parseRecord(event.toMap()); if(rec.getAccessor().getDbUser() == null || rec.getAccessor().getDbUser().equals("")){ event.tag(Constants.LOGSTASH_TAG_SKIP_NOT_SNOWFLAKE); skippedEvents.add(event); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/AuthFailedEventParser.java b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/AuthFailedEventParser.java index 9e51b71fe..48a582b53 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/AuthFailedEventParser.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/AuthFailedEventParser.java @@ -9,7 +9,7 @@ import com.ibm.guardium.snowflakedb.utils.DefaultGuardRecordBuilder; import com.ibm.guardium.snowflakedb.exceptions.ParseException; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; import org.apache.logging.log4j.LogManager; @@ -24,7 +24,7 @@ public class AuthFailedEventParser implements Parser{ private static Logger log = LogManager.getLogger(SuccessEventParser.class); private Map eventMap; - private Record guardRecord; + private UCRecord guardRecord; public AuthFailedEventParser() { DefaultGuardRecordBuilder builder = new DefaultGuardRecordBuilder(); @@ -32,7 +32,7 @@ public AuthFailedEventParser() { eventMap = new HashMap<>(); } @Override - public Record parseRecord(Map event) throws ParseException { + public UCRecord parseRecord(Map event) throws ParseException { if(event == null){ ParseException e = new ParseException("Snowflake filter: Event object is null."); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/Parser.java b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/Parser.java index f9cc98998..c2ac27e50 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/Parser.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/Parser.java @@ -7,7 +7,7 @@ import com.ibm.guardium.snowflakedb.utils.Constants; import com.ibm.guardium.snowflakedb.exceptions.ParseException; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.commons.lang3.StringUtils; import java.time.LocalDateTime; @@ -19,7 +19,7 @@ public interface Parser { - Record parseRecord(Map event) throws ParseException; + UCRecord parseRecord(Map event) throws ParseException; default String getClientOS(Map clientEnvironment) { String osMake = Constants.UNKNOWN_STRING; diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SQLErrorEventParser.java b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SQLErrorEventParser.java index 733038cf9..50a392722 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SQLErrorEventParser.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SQLErrorEventParser.java @@ -23,7 +23,7 @@ public class SQLErrorEventParser implements Parser{ private static Logger log = LogManager.getLogger(SuccessEventParser.class); private Map eventMap; - private Record guardRecord; + private UCRecord guardRecord; public SQLErrorEventParser(){ DefaultGuardRecordBuilder builder = new DefaultGuardRecordBuilder(); @@ -31,7 +31,7 @@ public SQLErrorEventParser(){ eventMap = new HashMap<>(); } @Override - public Record parseRecord(Map event) throws ParseException { + public UCRecord parseRecord(Map event) throws ParseException { if(event == null){ ParseException e = new ParseException("Snowflake filter: Event object is null."); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SuccessEventParser.java b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SuccessEventParser.java index 2ddaa316c..8a4acfac5 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SuccessEventParser.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/parser/SuccessEventParser.java @@ -23,7 +23,7 @@ public class SuccessEventParser implements Parser{ private static Logger log = LogManager.getLogger(SuccessEventParser.class); private Map eventMap; - private Record guardRecord; + private UCRecord guardRecord; public SuccessEventParser() { DefaultGuardRecordBuilder builder = new DefaultGuardRecordBuilder(); @@ -39,7 +39,7 @@ public SuccessEventParser() { * @return */ @Override - public Record parseRecord(final Map event) throws ParseException { + public UCRecord parseRecord(final Map event) throws ParseException { if(event == null){ ParseException e = new ParseException("Snowflake filter: Event object is null."); log.error(e); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/utils/DefaultGuardRecordBuilder.java b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/utils/DefaultGuardRecordBuilder.java index bff467e17..26b3ff569 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/utils/DefaultGuardRecordBuilder.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/main/java/com/ibm/guardium/snowflakedb/utils/DefaultGuardRecordBuilder.java @@ -8,8 +8,8 @@ import com.ibm.guardium.universalconnector.commons.structures.*; public class DefaultGuardRecordBuilder { - public Record buildGuardRecordWithDefaultValues(){ - Record record = new Record(); + public UCRecord buildGuardRecordWithDefaultValues(){ + UCRecord record = new UCRecord(); record.setAppUserName(Constants.NOT_AVAILABLE); record.setDbName(Constants.UNKNOWN_STRING); record.setSessionId(Constants.UNKNOWN_STRING); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/AuthFailedEventParserTest.java b/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/AuthFailedEventParserTest.java index 856d16941..193cc0a74 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/AuthFailedEventParserTest.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/AuthFailedEventParserTest.java @@ -9,7 +9,7 @@ import com.ibm.guardium.snowflakedb.parser.AuthFailedEventParser; import com.ibm.guardium.snowflakedb.parser.Parser; import com.ibm.guardium.snowflakedb.utils.Constants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import org.junit.Assert; import org.junit.Test; @@ -27,7 +27,7 @@ public void testAuthError(){ Map event = e.toMap(); try{ - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); Integer hashCode = (e.getField(Constants.CLIENT_IP).toString() + SessionLocator.PORT_DEFAULT + e.getField(Constants.SERVER_IP) + Constants.SERVER_PORT).hashCode(); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SQLErrorEventParserTest.java b/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SQLErrorEventParserTest.java index 1b8bec6e9..39ce20e5f 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SQLErrorEventParserTest.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SQLErrorEventParserTest.java @@ -10,7 +10,7 @@ import com.ibm.guardium.snowflakedb.parser.Parser; import com.ibm.guardium.snowflakedb.parser.SQLErrorEventParser; import com.ibm.guardium.snowflakedb.utils.Constants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.Event; @@ -27,7 +27,7 @@ public void testSQLError(){ Map event = e.toMap(); try{ - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); Assert.assertEquals(record.getSessionId(), event.get(Constants.SESSION_ID).toString()); Assert.assertEquals(record.getDbName(), event.get(Constants.DATABASE_NAME).toString()); diff --git a/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SuccessEventParserTest.java b/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SuccessEventParserTest.java index 3c4c2e4e1..2a655a43a 100644 --- a/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SuccessEventParserTest.java +++ b/filter-plugin/logstash-filter-snowflake-guardium/src/test/java/com/ibm/guardium/snowflakedb/SuccessEventParserTest.java @@ -10,7 +10,7 @@ import com.ibm.guardium.snowflakedb.parser.Parser; import com.ibm.guardium.snowflakedb.parser.SuccessEventParser; import com.ibm.guardium.snowflakedb.utils.Constants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.junit.Assert; import org.junit.Test; import org.logstash.Event; @@ -28,7 +28,7 @@ public void testSuccessEvent(){ Map event = e.toMap(); try{ - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); Assert.assertEquals(record.getSessionId(), event.get(Constants.SESSION_ID).toString()); Assert.assertEquals(record.getDbName(), event.get(Constants.DATABASE_NAME).toString()); @@ -90,7 +90,7 @@ public void testGetTime(){ Map event = e.toMap(); try{ - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); System.out.println(record.getTime().getTimstamp()); }catch (ParseException ex){ Assert.fail(ex.getMessage()); @@ -107,7 +107,7 @@ public void testGetTimeWithZone(){ Map event = e.toMap(); try{ - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); System.out.println(record.getTime().getTimstamp()); }catch (ParseException ex){ Assert.fail(ex.getMessage()); @@ -124,7 +124,7 @@ public void testAccessorWithoutClientOSUser(){ Map event = e.toMap(); try{ - Record record = parser.parseRecord(event); + UCRecord record = parser.parseRecord(event); Assert.assertEquals(Constants.NOT_AVAILABLE,record.getAccessor().getOsUser()); }catch (ParseException ex){ Assert.fail(ex.getMessage()); diff --git a/filter-plugin/logstash-filter-teradatadb-guardium/TeradataOverJdbcPackage/logstash-filter-teradatadb_guardium_plugin_filter.zip b/filter-plugin/logstash-filter-teradatadb-guardium/TeradataOverJdbcPackage/logstash-filter-teradatadb_guardium_plugin_filter.zip index 89a44d758..0837c8c18 100644 Binary files a/filter-plugin/logstash-filter-teradatadb-guardium/TeradataOverJdbcPackage/logstash-filter-teradatadb_guardium_plugin_filter.zip and b/filter-plugin/logstash-filter-teradatadb-guardium/TeradataOverJdbcPackage/logstash-filter-teradatadb_guardium_plugin_filter.zip differ diff --git a/filter-plugin/logstash-filter-teradatadb-guardium/build.gradle b/filter-plugin/logstash-filter-teradatadb-guardium/build.gradle index 4a62c047d..1a1c6f99a 100644 --- a/filter-plugin/logstash-filter-teradatadb-guardium/build.gradle +++ b/filter-plugin/logstash-filter-teradatadb-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "TeradatadbGuardiumPluginFilter" pluginInfo.pluginName = "teradatadb_guardium_plugin_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" @@ -43,8 +43,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } diff --git a/filter-plugin/logstash-filter-teradatadb-guardium/gradlew b/filter-plugin/logstash-filter-teradatadb-guardium/gradlew old mode 100644 new mode 100755 diff --git a/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/Parser.java b/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/Parser.java index a02be5f07..177b93d67 100644 --- a/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/Parser.java +++ b/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/Parser.java @@ -7,7 +7,7 @@ import com.ibm.guardium.universalconnector.commons.structures.Accessor; import com.ibm.guardium.universalconnector.commons.structures.Data; import com.ibm.guardium.universalconnector.commons.structures.ExceptionRecord; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -15,9 +15,9 @@ public class Parser { - public static Record parseRecord(final Event e) throws ParseException { + public static UCRecord parseRecord(final Event e) throws ParseException { - Record record = new Record(); + UCRecord record = new UCRecord(); record.setSessionId(e.getField(Constants.SESSION_ID).toString()); diff --git a/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/TeradatadbGuardiumPluginFilter.java b/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/TeradatadbGuardiumPluginFilter.java index edbada40d..3329e7d91 100644 --- a/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/TeradatadbGuardiumPluginFilter.java +++ b/filter-plugin/logstash-filter-teradatadb-guardium/src/main/java/com/ibm/guardium/teradatadb/TeradatadbGuardiumPluginFilter.java @@ -11,7 +11,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import co.elastic.logstash.api.Configuration; import co.elastic.logstash.api.Context; @@ -52,7 +52,7 @@ public Collection filter(Collection events, FilterMatchListener ma for (Event e : events) { try { - Record record = Parser.parseRecord(e); + UCRecord record = Parser.parseRecord(e); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/filter-plugin/logstash-filter-teradatadb-guardium/src/test/java/com/ibm/guardium/teradatadb/ParserTest.java b/filter-plugin/logstash-filter-teradatadb-guardium/src/test/java/com/ibm/guardium/teradatadb/ParserTest.java index e2a101d40..a4c6e5881 100644 --- a/filter-plugin/logstash-filter-teradatadb-guardium/src/test/java/com/ibm/guardium/teradatadb/ParserTest.java +++ b/filter-plugin/logstash-filter-teradatadb-guardium/src/test/java/com/ibm/guardium/teradatadb/ParserTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import com.ibm.guardium.universalconnector.commons.structures.Accessor; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import com.ibm.guardium.universalconnector.commons.structures.SessionLocator; import com.ibm.guardium.universalconnector.commons.structures.Time; @@ -44,7 +44,7 @@ public void createQuery() throws ParseException { + "LastName VARCHAR(30), DOB DATE FORMAT 'YYYY-MM-DD', JoinedDate DATE FORMAT 'YYYY-MM-DD', " + "DepartmentNo BYTEINT ) UNIQUE PRIMARY INDEX ( EmployeeNo );"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -55,7 +55,7 @@ public void insertQuery() throws ParseException { e.setField(Constants.SQL_TEXT_INFO, "INSERT INTO Employee (EmployeeNo, FirstName, LastName, DOB, JoinedDate, DepartmentNo )" + "VALUES ( 101, 'Mike', 'James', '1980-01-05', '2005-03-27', 01);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -66,7 +66,7 @@ public void selectQuery() throws ParseException { e.setField(Constants.SQL_TEXT_INFO, "SELECT A.EmployeeNo, A.DepartmentNo, B.NetPay FROM Employee A " + "INNER JOIN Salary B ON (A.EmployeeNo = B. EmployeeNo);"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); Assert.assertEquals(record.getDbName(), record.getAccessor().getServiceName()); } @@ -78,7 +78,7 @@ public void updateQuery() throws ParseException { Event e=intitalizeEventObject(); e.setField(Constants.SQL_TEXT_INFO, "UPDATE Employee SET DepartmentNo = 03 WHERE EmployeeNo = 101;"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -89,7 +89,7 @@ public void deleteQuery() throws ParseException { Event e=intitalizeEventObject(); e.setField(Constants.SQL_TEXT_INFO, "DELETE FROM Employee WHERE EmployeeNo = 101;"); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(record.getData().getConstruct(), null); } @@ -129,7 +129,7 @@ public void testErrors() throws ParseException { e.setField(Constants.SQL_TEXT_INFO, "select * from DBC.QryLog;"); e.setField(Constants.ERROR_TEXT, "The user does not have SELECT access to DBC.QryLog."); - final Record record = Parser.parseRecord(e); + final UCRecord record = Parser.parseRecord(e); Assert.assertEquals(Constants.SQL_ERROR,record.getException().getExceptionTypeId()); Assert.assertEquals("The user does not have SELECT access to DBC.QryLog." diff --git a/filter-plugin/logstash-filter-yugabyte-guardium/YugabytedbOverFilebeatPackage/YugabyteDB/yugabytedb-logstash-offline-plugins-1.0.0.zip b/filter-plugin/logstash-filter-yugabyte-guardium/YugabytedbOverFilebeatPackage/YugabyteDB/yugabytedb-logstash-offline-plugins-1.0.0.zip index e69de29bb..535c77030 100644 Binary files a/filter-plugin/logstash-filter-yugabyte-guardium/YugabytedbOverFilebeatPackage/YugabyteDB/yugabytedb-logstash-offline-plugins-1.0.0.zip and b/filter-plugin/logstash-filter-yugabyte-guardium/YugabytedbOverFilebeatPackage/YugabyteDB/yugabytedb-logstash-offline-plugins-1.0.0.zip differ diff --git a/filter-plugin/logstash-filter-yugabyte-guardium/build.gradle b/filter-plugin/logstash-filter-yugabyte-guardium/build.gradle index 1b9bafda1..aa0bc9303 100644 --- a/filter-plugin/logstash-filter-yugabyte-guardium/build.gradle +++ b/filter-plugin/logstash-filter-yugabyte-guardium/build.gradle @@ -20,10 +20,10 @@ pluginInfo.pluginClass = "YugabytedbGuardiumFilter" pluginInfo.pluginName = "yugabytedb_guardium_filter" // must match the @LogstashPlugin annotation in the main plugin class // =========================================================================== -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 17 +targetCompatibility = 17 -def jacocoVersion = '0.8.4' +def jacocoVersion = '0.8.8' // minimumCoverage can be set by Travis ENV def minimumCoverageStr = System.getenv("MINIMUM_COVERAGE") ?: "50.0%" if (minimumCoverageStr.endsWith("%")) { @@ -41,8 +41,8 @@ buildscript { } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' - classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.0.0-RC2" + classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.0' + classpath "org.barfuin.gradle.jacocolog:gradle-jacoco-log:3.1.0" classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2' } } @@ -186,4 +186,4 @@ jacocoTestCoverageVerification { })) } } -project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) \ No newline at end of file +project.tasks.check.dependsOn(jacocoTestCoverageVerification, jacocoTestReport) diff --git a/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/Parser.java b/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/Parser.java index 69b0de9c8..16f7caf75 100644 --- a/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/Parser.java +++ b/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/Parser.java @@ -21,8 +21,8 @@ public class Parser { private static Logger log = LogManager.getLogger(Parser.class); - public static Record parseRecord(final Map data) throws ParseException { - Record record = new Record(); + public static UCRecord parseRecord(final Map data) throws ParseException { + UCRecord record = new UCRecord(); if (data != null) { if(log.isDebugEnabled()){ diff --git a/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/YugabytedbGuardiumFilter.java b/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/YugabytedbGuardiumFilter.java index d4e0e5e30..ceb8eb073 100644 --- a/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/YugabytedbGuardiumFilter.java +++ b/filter-plugin/logstash-filter-yugabyte-guardium/src/main/java/com/ibm/guardium/yugabytedb/YugabytedbGuardiumFilter.java @@ -9,7 +9,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.ibm.guardium.universalconnector.commons.GuardConstants; -import com.ibm.guardium.universalconnector.commons.structures.Record; +import com.ibm.guardium.universalconnector.commons.structures.UCRecord; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; @@ -59,7 +59,7 @@ public Collection filter(Collection events, FilterMatchListener ma for (Event e : events) { try { - Record record = Parser.parseRecord(e.toMap()); + UCRecord record = Parser.parseRecord(e.toMap()); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); final Gson gson = builder.create(); diff --git a/versions.yml b/versions.yml index 4c3d519c9..0e5bbbb97 100644 --- a/versions.yml +++ b/versions.yml @@ -10,9 +10,9 @@ dependencies: junitJupiter: 5.7.1 mockitoAll: 2.0.2-beta json: 20231013 - parboiledJava: 1.1.8 + parboiledJava: 1.4.1 javaxJson: 1.1.4 guava: 32.1.3-jre commonsText: 1.10.0 tinkergraphGremlin: 3.6.4 - rdf4jQueryparserSparql: 5.0.2 \ No newline at end of file + rdf4jQueryparserSparql: 5.0.2