diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 8a8042c..d5f7f1d 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -3,7 +3,7 @@ run-name: Deploy to ${{ inputs.deploy_target }} by @${{ gitea.actor }} on: [push] jobs: - Build: + linux: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 diff --git a/config.toml.example b/config.toml.example index e0a651b..59bb7a0 100644 --- a/config.toml.example +++ b/config.toml.example @@ -4,7 +4,41 @@ server = "192.168.x.x" database = "EFTDB" user = "a" password = "a" -query = "SELECT [Id],[Version] FROM [EFTDB].[dbo].[tbl_Schema_Version]" +query = """DECLARE @stopTime DATETIME2 +SET @stopTime = DATEADD(DAY, -30, GETDATE()) +SELECT [ProtocolCommandID] + ,p.[Time_stamp] + ,[RemoteIP] + ,[RemotePort] + ,[LocalIP] + ,[LocalPort] + ,[Protocol] + ,[SiteName] + ,[Command] + ,[CommandParameters] + ,[FileName] + ,[VirtualFolderName] + ,[PhysicalFolderName] + ,[IsInternal] + ,[FileSize] + ,[TransferTime] + ,[BytesTransferred] + ,[ResultID] + ,p.[TransactionID] + ,[Description] + ,[Actor] + ,t.ParentTransactionID + ,t.TransactionObject + ,t.NodeName + ,t.TransactionGUID + FROM [EFTDB].[dbo].[tbl_ProtocolCommands] p Full JOIN tbl_Transactions t ON (p.TransactionID = t.TransactionID) + WHERE p.Time_stamp > @stopTime""" + +[immutables] +prd_instance_id = 1 +product_guid = "asdf" +product_name = "EFT" +product_version ="8.1.0.9" [output] filename ="./data.json" diff --git a/executable/config.toml.example b/executable/config.toml.example index e0a651b..1eb2bfa 100644 --- a/executable/config.toml.example +++ b/executable/config.toml.example @@ -4,8 +4,28 @@ server = "192.168.x.x" database = "EFTDB" user = "a" password = "a" -query = "SELECT [Id],[Version] FROM [EFTDB].[dbo].[tbl_Schema_Version]" - +query = """SELECT TOP (1) [ProtocolCommandID] + ,[Time_stamp] + ,[RemoteIP] + ,[RemotePort] + ,[LocalIP] + ,[LocalPort] + ,[Protocol] + ,[SiteName] + ,[Command] + ,[CommandParameters] + ,[FileName] + ,[VirtualFolderName] + ,[PhysicalFolderName] + ,[IsInternal] + ,[FileSize] + ,[TransferTime] + ,[BytesTransferred] + ,[ResultID] + ,[TransactionID] + ,[Description] + ,[Actor] + FROM [EFTDB].[dbo].[tbl_ProtocolCommands]""" [output] filename ="./data.json" diff --git a/inex.py b/inex.py index 6e23339..7e2e149 100644 --- a/inex.py +++ b/inex.py @@ -35,6 +35,10 @@ class Inex: self.useLog = self.config["logging"]["useLog"] self.logPath = self.config["logging"]["logPath"] self.logLevel = self.config["logging"]["logLevel"] + self.prdInstanceID = self.config["immutables"]["prd_instance_id"] + self.productGUID = self.config["immutables"]["product_guid"] + self.productName = self.config["immutables"]["product_name"] + self.productVersion = self.config["immutables"]["product_version"] #Setup logging inexLog(self) @@ -43,10 +47,10 @@ class Inex: self.cursor = self.ic.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword) self.data = self.ic.databaseQuery(self, self.cursor, self.dbQuery) - # print(f"returned data: {self.data}") - self.modifiedData = processData(self.data, dataTemplate) - print(self.modifiedData) + self.modifiedData = processData(self.data, dataTemplate, prd_instance_id=self.prdInstanceID,\ + product_guid=self.productGUID,product_name=self.productName,product_version=self.productVersion) + # TODO: move this to its own function if self.useLog: diff --git a/inexDataProcessing.py b/inexDataProcessing.py index 5b408e0..2b7c2ee 100644 --- a/inexDataProcessing.py +++ b/inexDataProcessing.py @@ -1,4 +1,4 @@ -def processData(data, template): +def processData(data, template, **kwargs): processedData = [] for row in data: # print(f'Row: {row}') @@ -11,10 +11,10 @@ def processData(data, template): file_name=row.get('FileName'),\ guid=row.get('TransactionGUID'),\ ref_id=row.get('ProtocolCommandID'),\ - prd_instance_id=row.get(''),\ - product_guid=row.get(''),\ - product_name=row.get(''),\ - product_version=row.get(''),\ + prd_instance_id=kwargs.get('prd_instance_id'),\ + product_guid=kwargs.get('product_guid'),\ + product_name=kwargs.get('product_name'),\ + product_version=kwargs.get('product_version'),\ node_name=row.get('NodeName'),\ src_endpoint_port=row.get('RemotePort'),\ src_endpoint_ip=row.get('RemoteIP'),\ @@ -25,8 +25,17 @@ def processData(data, template): bytes_out=row.get('BytesTransferred'),\ transfer_time=row.get('TransferTime'),\ time=row.get('Time_stamp'),\ - user_type=row.get(''),\ + user_type=identifyUserType(row.get('user_type')),\ user_domain=row.get('SiteName'),\ user_name=row.get('Actor'),\ - utype=row.get('Command'))) - return processedData \ No newline at end of file + utype=row.get('TransactionObject'))) + return processedData + +def identifyUserType(obj): + if obj: + if "Admin" in obj: + return "Administrator" + else: + return "User" + else: + return None \ No newline at end of file