Updated query and mapped the proper data to the template
All checks were successful
Build Inex Executable / linux (push) Successful in 1m20s

This commit is contained in:
Jonathan Branan 2024-07-24 13:00:24 -05:00
parent e421b1b376
commit 702d93b9da
5 changed files with 82 additions and 15 deletions

View File

@ -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

View File

@ -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"

View File

@ -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"

10
inex.py
View File

@ -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:

View File

@ -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')))
utype=row.get('TransactionObject')))
return processedData
def identifyUserType(obj):
if obj:
if "Admin" in obj:
return "Administrator"
else:
return "User"
else:
return None