From de3a3fd03d6c1bba3eb1eb75e9df17a1c1a1a92d Mon Sep 17 00:00:00 2001 From: Jonathan Branan Date: Wed, 14 Aug 2024 15:00:53 -0500 Subject: [PATCH 1/3] This addresses #17 --- README.md | 2 ++ config.toml.example | 1 + inex.py | 3 ++- inexSqlquery.py | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0acd03a..18f6f96 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,14 @@ You will need a *config.toml* file in the same directory where *inex.py* or inex | logging | Set if, where and level of logging | The following settings are not obvious as to how they affect the application. +> Note the #comments ``` [fortraPlatform] selectedPlatform = "dev" # This will modify which environment the data is pushed to. The tenant_id and secret must be manually modified. [database] overrideEmbeddedquery = true # Choose if embedded query should be overridden. +daysTopull = 30 # This setting is only related to the embedded query. Please note this will not affect query provided in config.toml driver = "ODBC Driver 18 for SQL Server" # Select which windows driver should be used. This one is recommended. [output] diff --git a/config.toml.example b/config.toml.example index 37c4113..d35370a 100644 --- a/config.toml.example +++ b/config.toml.example @@ -24,6 +24,7 @@ secret = "" [database] overrideEmbeddedquery = false +daysTopull = 30 driver = "ODBC Driver 18 for SQL Server" server = "192.168.x.x" database = "EFTDB" diff --git a/inex.py b/inex.py index 1d1af51..fa90f49 100644 --- a/inex.py +++ b/inex.py @@ -52,6 +52,7 @@ class Inex: self.writeJsonfile = self.config["output"]["dumpTojson"] self.pushToplatform = self.config["output"]["pushToplatform"] self.queryOverride = self.config["database"]["overrideEmbeddedquery"] + self.queryDaystopull = self.config["database"]["daysTopull"] except: print("No config.toml. Please use example file and configure appropriately") exit(1) @@ -70,7 +71,7 @@ class Inex: self.cursor = self.ic.inexSql.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword) - self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.sq.sqlQuerymodel.queryData(self.queryOverride,self.dbQuery)) + self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.sq.sqlQuerymodel.queryData(self.queryOverride,self.dbQuery, self.queryDaystopull)) self.modifiedData = processData(self.data, dataTemplate, prd_instance_id=self.prdInstanceID,\ product_guid=self.productGUID,product_name=self.productName,product_version=self.productVersion) diff --git a/inexSqlquery.py b/inexSqlquery.py index 8db92ab..39b7049 100644 --- a/inexSqlquery.py +++ b/inexSqlquery.py @@ -1,5 +1,5 @@ class sqlQuerymodel: - def queryData(overRideflag, configQuery): + def queryData(overRideflag, configQuery, daysTopull): """Embedded query data""" q ="""DECLARE @stopTime DATETIME2 SET @stopTime=DATEADD(DAY, -30, GETDATE()) @@ -7,5 +7,5 @@ class sqlQuerymodel: FROM tbl_Transactions t Full JOIN tbl_ProtocolCommands p ON(t.TransactionID=p.TransactionID) Full join tbl_Authentications a ON(t.TransactionID=a.TransactionID) - WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL""" + WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL""".replace("30", daysTopull) return configQuery if overRideflag else q \ No newline at end of file -- 2.45.2 From 267616f0e47ff7c87d1d25cbb9fbde106b344eed Mon Sep 17 00:00:00 2001 From: Jonathan Branan Date: Wed, 14 Aug 2024 15:05:27 -0500 Subject: [PATCH 2/3] Updated daysTopull value --- inexSqlquery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inexSqlquery.py b/inexSqlquery.py index 39b7049..9c10e87 100644 --- a/inexSqlquery.py +++ b/inexSqlquery.py @@ -7,5 +7,5 @@ class sqlQuerymodel: FROM tbl_Transactions t Full JOIN tbl_ProtocolCommands p ON(t.TransactionID=p.TransactionID) Full join tbl_Authentications a ON(t.TransactionID=a.TransactionID) - WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL""".replace("30", daysTopull) + WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL""".replace("30", str(daysTopull)) return configQuery if overRideflag else q \ No newline at end of file -- 2.45.2 From 8e8312e8533e7468c1db472fa69aedb8518b987f Mon Sep 17 00:00:00 2001 From: Jonathan Branan Date: Wed, 14 Aug 2024 15:19:37 -0500 Subject: [PATCH 3/3] Updated example --- config.toml.example | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/config.toml.example b/config.toml.example index d35370a..eb131bc 100644 --- a/config.toml.example +++ b/config.toml.example @@ -1,6 +1,33 @@ [fortraPlatform] selectedPlatform = "dev" +[output] +pushToplatform = true +dumpTojson = true +filename ="./data.json" +token = "./.token" + +[logging] +use_log = true +logLevel = "debug" +logPath = "./inex.log" + +[database] +overrideEmbeddedquery = false +daysTopull = 10 +driver = "ODBC Driver 18 for SQL Server" +server = "192.168.x.x" +database = "EFTDB" +user = "a" +password = "a" +query = """DECLARE @stopTime DATETIME2 +SET @stopTime=DATEADD(DAY, -30, GETDATE()) +SELECT p.ProtocolCommandID, t.Time_stamp, p.RemoteIP, p.RemotePort, p.LocalIP, p.LocalPort, p.Protocol, p.SiteName, p.Command, p.FileName, p.VirtualFolderName, p.FileSize, p.TransferTime, p.BytesTransferred, p.Description, p.ResultID, t.TransactionID, p.Actor, t.TransactionObject, t.NodeName, t.TransactionGUID, a.Protocol user_type +FROM tbl_Transactions t + Full JOIN tbl_ProtocolCommands p ON(t.TransactionID=p.TransactionID) + Full JOIN tbl_Authentications a ON(t.TransactionID=a.TransactionID) +WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL""" + [fortraPlatform.dev] idp = "https://foundation.foundation-dev.cloudops.fortradev.com/idp/realms/products/protocol/openid-connect/token" efc_url = "https://efc.efc-dev.cloudops.fortradev.com" @@ -22,35 +49,8 @@ tenant_id = "" client_id = "eft-event-generator-confidential" secret = "" -[database] -overrideEmbeddedquery = false -daysTopull = 30 -driver = "ODBC Driver 18 for SQL Server" -server = "192.168.x.x" -database = "EFTDB" -user = "a" -password = "a" -query = """DECLARE @stopTime DATETIME2 -SET @stopTime=DATEADD(DAY, -30, GETDATE()) -SELECT p.ProtocolCommandID, t.Time_stamp, p.RemoteIP, p.RemotePort, p.LocalIP, p.LocalPort, p.Protocol, p.SiteName, p.Command, p.FileName, p.VirtualFolderName, p.FileSize, p.TransferTime, p.BytesTransferred, p.Description, p.ResultID, t.TransactionID, p.Actor, t.TransactionObject, t.NodeName, t.TransactionGUID, a.Protocol user_type -FROM tbl_Transactions t - Full JOIN tbl_ProtocolCommands p ON(t.TransactionID=p.TransactionID) - Full JOIN tbl_Authentications a ON(t.TransactionID=a.TransactionID) -WHERE p.Time_stamp>@stopTime AND p.Command IS NOT NULL""" - [immutables] prd_instance_id = 1 product_guid = "asdf" product_name = "EFT" -product_version ="8.1.0.9" - -[output] -pushToplatform = true -dumpTojson = true -filename ="./data.json" -token = "./.token" - -[logging] -use_log = true -logLevel = "debug" -logPath = "./inex.log" \ No newline at end of file +product_version ="8.1.0.9" \ No newline at end of file -- 2.45.2