Compare commits
22 Commits
6f6e38fe13
...
v.0.0.4
Author | SHA1 | Date | |
---|---|---|---|
5c37b2fca2 | |||
cd9c6d535e | |||
643aaa946e | |||
cc8adbebad | |||
c7b4e8ef85 | |||
09d9b78e15 | |||
de17d1d45b | |||
f99801fa2b | |||
b076be8333 | |||
5cae8105d0 | |||
17155120ab | |||
7c65c0e357 | |||
8fbd10d9df | |||
cfa23470a8 | |||
73acbb6646 | |||
82ad280aa8 | |||
0174336f39 | |||
165ba4533c | |||
822fb79fd4 | |||
9ca8631abb | |||
6615637d07 | |||
c4bd226b7e |
@ -1,35 +1,41 @@
|
|||||||
name: Build
|
name: Build
|
||||||
on: push
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# build-linux-binary:
|
build-linux-binary:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
permissions:
|
||||||
# - uses: actions/checkout@v4
|
contents: write # release changes require contents write
|
||||||
# - uses: actions/setup-python@v5
|
steps:
|
||||||
# with:
|
- uses: actions/checkout@v4
|
||||||
# python-version: '3.12.4'
|
- uses: actions/setup-python@v5
|
||||||
# cache: 'pip' # caching pip dependencies
|
with:
|
||||||
# - run: apt-get update
|
python-version: '3.12.4'
|
||||||
# - run: apt-get install unixodbc -y
|
cache: 'pip' # caching pip dependencies
|
||||||
# - run: pip install -r requirements.txt
|
- run: lsb_release -a
|
||||||
# - run: pyinstaller --noconfirm --onefile --console ${{ gitea.workspace }}/inex.py
|
- run: apt-get update
|
||||||
# - uses: softprops/action-gh-release@v2
|
- run: apt-get install unixodbc -y
|
||||||
# - name: Release
|
- run: pip install -r requirements.txt
|
||||||
# uses: softprops/action-gh-release@v2
|
- run: pyinstaller --noconfirm --onefile --console ${{ gitea.workspace }}/inex.py
|
||||||
# if: startsWith(gitea.ref, 'refs/tags/')
|
- uses: softprops/action-gh-release@v2
|
||||||
# with:
|
with:
|
||||||
# files: ${{ gitea.workspace }}/dist/inex
|
files: ${{ gitea.workspace }}/dist/inex
|
||||||
|
|
||||||
build-windows-binary:
|
build-windows-binary:
|
||||||
runs-on: windows
|
runs-on: windows
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # release changes require contents write
|
contents: write # release changes require contents write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Upload Release Asset
|
- uses: actions/setup-python@v4
|
||||||
env:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
python-version: '3.12.4'
|
||||||
run: pip install -r requirements.txt
|
cache: 'pip' # caching pip dependencies
|
||||||
run: pyinstaller --noconfirm --onefile --console ${{ gitea.workspace }}/inex.py
|
- run: python -m pip install -r requirements.txt
|
||||||
# run: gh release upload <release_tag> <a_file>
|
- run: pyinstaller --noconfirm --onefile --console ${{ gitea.workspace }}/inex.py
|
||||||
|
- uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: ${{ gitea.workspace }}/dist/inex.exe
|
4
LICENSE
4
LICENSE
@ -209,7 +209,7 @@ If you develop a new program, and you want it to be of the greatest possible use
|
|||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
Inex
|
Inex
|
||||||
Copyright (C) 2024 jblu
|
Copyright (C) 2024 Jonathan Branan
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
Inex Copyright (C) 2024 jblu
|
Inex Copyright (C) 2024 Jonathan Branan
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
[database]
|
|
||||||
driver = "ODBC Driver 18 for SQL Server"
|
|
||||||
server = "192.168.x.x"
|
|
||||||
database = "EFTDB"
|
|
||||||
user = "a"
|
|
||||||
password = "a"
|
|
||||||
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"
|
|
||||||
|
|
||||||
[logging]
|
|
||||||
use_log = true
|
|
||||||
logLevel = "debug"
|
|
||||||
logPath = "./inex.log"
|
|
Binary file not shown.
12
inex.py
12
inex.py
@ -1,23 +1,20 @@
|
|||||||
import pyodbc
|
import pyodbc
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
|
||||||
import tomllib
|
import tomllib
|
||||||
from inexLogging import inexLog
|
from inexLogging import inexLog
|
||||||
import inexConnect
|
import inexConnect
|
||||||
from inexDataModel import dataTemplate
|
from inexDataModel import dataTemplate
|
||||||
from inexDataProcessing import processData
|
from inexDataProcessing import processData
|
||||||
import json
|
import json
|
||||||
import decimal
|
|
||||||
import requests
|
import requests
|
||||||
import inexEncoder
|
import inexEncoder
|
||||||
|
import inexSqlquery
|
||||||
class Inex:
|
class Inex:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initilize config, calls functions from inex-connect.py and inex-logging.py"""
|
"""Initilize config, calls functions from inex-connect.py and inex-logging.py"""
|
||||||
# assign libraries
|
# assign libraries
|
||||||
self.db = pyodbc
|
self.db = pyodbc
|
||||||
self.tm = datetime
|
|
||||||
self.il = logging
|
self.il = logging
|
||||||
self.ic = inexConnect
|
self.ic = inexConnect
|
||||||
self.r = requests
|
self.r = requests
|
||||||
@ -25,6 +22,7 @@ class Inex:
|
|||||||
self.os = os
|
self.os = os
|
||||||
self.j = json
|
self.j = json
|
||||||
self.e = inexEncoder.Encoder
|
self.e = inexEncoder.Encoder
|
||||||
|
self.sq = inexSqlquery
|
||||||
|
|
||||||
if self.os.path.exists('./config.toml'):
|
if self.os.path.exists('./config.toml'):
|
||||||
config_file_path = './config.toml'
|
config_file_path = './config.toml'
|
||||||
@ -63,9 +61,11 @@ class Inex:
|
|||||||
inexLog(self)
|
inexLog(self)
|
||||||
|
|
||||||
# create the connection to the database
|
# create the connection to the database
|
||||||
self.cursor = self.ic.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword)
|
self.cursor = self.ic.inexSql.connectDatabase(self, self.db, self.dbDriver, self.dbServer, self.dbDatabase, self.dbUser, self.dbPassword)
|
||||||
|
|
||||||
self.data = self.ic.databaseQuery(self, self.cursor, self.dbQuery)
|
# self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.dbQuery)
|
||||||
|
|
||||||
|
self.data = self.ic.inexSql.databaseQuery(self, self.cursor, self.sq.sqlQuerymodel.queryData())
|
||||||
|
|
||||||
self.modifiedData = processData(self.data, dataTemplate, prd_instance_id=self.prdInstanceID,\
|
self.modifiedData = processData(self.data, dataTemplate, prd_instance_id=self.prdInstanceID,\
|
||||||
product_guid=self.productGUID,product_name=self.productName,product_version=self.productVersion)
|
product_guid=self.productGUID,product_name=self.productName,product_version=self.productVersion)
|
||||||
|
@ -1,45 +1,46 @@
|
|||||||
def connectDatabase(self, lib, driver, server, database, user, password):
|
class inexSql:
|
||||||
"""Connects to the database. Requires a windows driver to do so.
|
def connectDatabase(self, lib, driver, server, database, user, password):
|
||||||
Typically there is one installed by default"""
|
"""Connects to the database. Requires a windows driver to do so.
|
||||||
|
Typically there is one installed by default"""
|
||||||
|
|
||||||
connectionString = f'DRIVER={{{driver}}};SERVER={server};DATABASE={database};UID={user};PWD={password};TrustServerCertificate=yes'
|
connectionString = f'DRIVER={{{driver}}};SERVER={server};DATABASE={database};UID={user};PWD={password};TrustServerCertificate=yes'
|
||||||
if self.useLog:
|
|
||||||
self.il.debug(f"Connection String: connectionString")
|
|
||||||
self.il.info(f"Connecting to {database}@{server} with driver[{driver}].")
|
|
||||||
try:
|
|
||||||
connection = lib.connect(connectionString)
|
|
||||||
except lib.Error as ex:
|
|
||||||
sqlstate = ex.args[1]
|
|
||||||
if self.useLog:
|
if self.useLog:
|
||||||
self.il.error(sqlstate)
|
self.il.debug(f"Connection String: connectionString")
|
||||||
if self.useLog:
|
self.il.info(f"Connecting to {database}@{server} with driver[{driver}].")
|
||||||
self.il.debug(f"Connected.")
|
try:
|
||||||
cursor = connection.cursor()
|
connection = lib.connect(connectionString)
|
||||||
|
except lib.Error as ex:
|
||||||
return cursor
|
sqlstate = ex.args[1]
|
||||||
|
if self.useLog:
|
||||||
def databaseQuery(self, cursor, query, args=()):
|
self.il.error(sqlstate)
|
||||||
if self.useLog:
|
|
||||||
self.il.debug(f"Query:")
|
|
||||||
self.il.debug(query)
|
|
||||||
self.il.info(f"Sending query:{query[0:20]}...")
|
|
||||||
|
|
||||||
try:
|
|
||||||
cur = cursor.execute(query, args)
|
|
||||||
except cur.Error as ex:
|
|
||||||
sqlstate = ex.args[1]
|
|
||||||
if self.useLog:
|
if self.useLog:
|
||||||
self.il.error(sqlstate)
|
self.il.debug(f"Connected.")
|
||||||
|
cursor = connection.cursor()
|
||||||
if self.useLog:
|
|
||||||
self.il.debug(f"Processing database response...")
|
return cursor
|
||||||
r = [dict((cur.description[i][0], value) \
|
|
||||||
for i, value in enumerate(row)) for row in cur.fetchall()]
|
def databaseQuery(self, cursor, query, args=()):
|
||||||
|
if self.useLog:
|
||||||
cur.connection.close()
|
self.il.debug(f"Query:")
|
||||||
if self.useLog:
|
self.il.debug(query)
|
||||||
self.il.debug(f"Database connection closed")
|
self.il.info(f"Sending query:{query[0:20]}...")
|
||||||
return r
|
|
||||||
|
try:
|
||||||
|
cur = cursor.execute(query, args)
|
||||||
|
except cur.Error as ex:
|
||||||
|
sqlstate = ex.args[1]
|
||||||
|
if self.useLog:
|
||||||
|
self.il.error(sqlstate)
|
||||||
|
|
||||||
|
if self.useLog:
|
||||||
|
self.il.debug(f"Processing database response...")
|
||||||
|
r = [dict((cur.description[i][0], value) \
|
||||||
|
for i, value in enumerate(row)) for row in cur.fetchall()]
|
||||||
|
|
||||||
|
cur.connection.close()
|
||||||
|
if self.useLog:
|
||||||
|
self.il.debug(f"Database connection closed")
|
||||||
|
return r
|
||||||
|
|
||||||
class fortraEFC:
|
class fortraEFC:
|
||||||
def getToken(self):
|
def getToken(self):
|
||||||
|
165
inexDataModel.py
165
inexDataModel.py
@ -45,4 +45,167 @@ def dataTemplate(**kwargs):
|
|||||||
"utype": kwargs.get('utype')
|
"utype": kwargs.get('utype')
|
||||||
}
|
}
|
||||||
|
|
||||||
return template
|
return template
|
||||||
|
|
||||||
|
FileUploaded = {
|
||||||
|
"bytes" : 2490,
|
||||||
|
"dst_endpoint": {
|
||||||
|
"port": 22,
|
||||||
|
"ip": "10.91.160.77",
|
||||||
|
"type": "SFTP"
|
||||||
|
},
|
||||||
|
"duration": 200,
|
||||||
|
"file": {
|
||||||
|
"created_time": 1722485724000,
|
||||||
|
"size": 2490,
|
||||||
|
"name": "Case9.vbs",
|
||||||
|
"path": "\\\\10.255.255.9\\shared\\HASite\\InetPub\\EFTRoot\\MySite\\Usr\\Ivan //<PhysicalFolderName>"
|
||||||
|
},
|
||||||
|
"guid": "48D9C7A3-2DC6-11EF-AA59-00155D641204",
|
||||||
|
"node_name":"PERF01-S2019-77",
|
||||||
|
"prd_ext_tenant_id": "e71851c2-593f-4f49-9c07-91727b1be94b",
|
||||||
|
"product_name": "GlobalScape EFT",
|
||||||
|
"prd_ext_tenant_name": "GlobalScape EFT",
|
||||||
|
"classifications": [{
|
||||||
|
"ref_id": "globalscape:48D9C7A3-2DC6-11EF-AA59-00155D641204",
|
||||||
|
"time":1722485724000,
|
||||||
|
}],
|
||||||
|
"session": {
|
||||||
|
"created_time":1722485724000,
|
||||||
|
"uid": "3615136"
|
||||||
|
},
|
||||||
|
"src_endpoint": {
|
||||||
|
"port": 58868,
|
||||||
|
"ip": "10.91.160.45",
|
||||||
|
"type":"SFTP"
|
||||||
|
},
|
||||||
|
"tenant": "e71851c2-593f-4f49-9c07-91727b1be94b",
|
||||||
|
"tenant_name":"GlobalScape",
|
||||||
|
"time":1722485724000,
|
||||||
|
"status_code":226,
|
||||||
|
"status_detail":"Upload Successful",
|
||||||
|
"user": {
|
||||||
|
"home_directory": "/Usr/Ivan/",
|
||||||
|
"uuid":"48D9C7A3-2DC6-11EF-AA59-00155D641204",
|
||||||
|
"uid": "3978403",
|
||||||
|
"type": "User",
|
||||||
|
"name": "Ivan"
|
||||||
|
},
|
||||||
|
"utype": "file_uploaded"
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDownloaded = {
|
||||||
|
"bytes" : 4891,
|
||||||
|
"dst_endpoint": {
|
||||||
|
"port": 443,
|
||||||
|
"ip": "10.91.160.77",
|
||||||
|
"type": "HTTPS"
|
||||||
|
},
|
||||||
|
"duration": 200,
|
||||||
|
"file": {
|
||||||
|
"created_time": 1722518124000,
|
||||||
|
"size": 4891,
|
||||||
|
"name": "FileDownload1.exe",
|
||||||
|
"path": "\\\\10.255.255.9\\shared\\HASite\\InetPub\\EFTRoot\\MySite\\Usr\\Ivan //<PhysicalFolderName>"
|
||||||
|
},
|
||||||
|
"guid": "48D9C7A3-2DC6-11EF-AA59-00155D641205",
|
||||||
|
"node_name":"PERF01-S2019-77",
|
||||||
|
"prd_ext_tenant_id": "e71851c2-593f-4f49-9c07-91727b1be94b",
|
||||||
|
"product_name": "GlobalScape EFT",
|
||||||
|
"prd_ext_tenant_name": "GlobalScape EFT",
|
||||||
|
"classifications": [{
|
||||||
|
"ref_id": "globalscape:48D9C7A3-2DC6-11EF-AA59-00155D641205",
|
||||||
|
"time":1722518124000,
|
||||||
|
}],
|
||||||
|
"session": {
|
||||||
|
"created_time":1722518124000,
|
||||||
|
"uid": "3615137"
|
||||||
|
},
|
||||||
|
"src_endpoint": {
|
||||||
|
"port": 443,
|
||||||
|
"ip": "10.91.160.45",
|
||||||
|
"type":"HTTPS"
|
||||||
|
},
|
||||||
|
"tenant": "e71851c2-593f-4f49-9c07-91727b1be94b",
|
||||||
|
"tenant_name":"GlobalScape",
|
||||||
|
"time":1722518124000,
|
||||||
|
"status_code":226,
|
||||||
|
"status_detail":"Download Successful",
|
||||||
|
"user": {
|
||||||
|
"home_directory": "/Usr/Ivan/",
|
||||||
|
"uuid":"48D9C7A3-2DC6-11EF-AA59-00155D641205",
|
||||||
|
"uid": "3978404",
|
||||||
|
"type": "User",
|
||||||
|
"name": "Ivan"
|
||||||
|
},
|
||||||
|
"utype": "file_downloaded"}
|
||||||
|
|
||||||
|
FileDeleted = {
|
||||||
|
"file": {
|
||||||
|
"size": 304673,
|
||||||
|
"path": "\\\\10.255.255.9\\shared\\HASite\\InetPub\\EFTRoot\\MySite\\Usr\\Ivan",
|
||||||
|
"name": "DeleteME.txt"
|
||||||
|
},
|
||||||
|
"guid": "48D9C7A3-2DC6-11EF-AA59-00155D641207",
|
||||||
|
"classifications": [{
|
||||||
|
"ref_id": "globalscape:48D9C7A3-2DC6-11EF-AA59-00155D641207",
|
||||||
|
"time":1722515664000,
|
||||||
|
}],
|
||||||
|
"prd_ext_tenant_name": "Globalscape EFT",
|
||||||
|
"prd_ext_tenant_id": "e71851c2-593f-4f49-9c07-91727b1be94b",
|
||||||
|
"product_name": "Globalscape EFT",
|
||||||
|
"session": {
|
||||||
|
"created_time":1722515664000,
|
||||||
|
"uid": "3615138"
|
||||||
|
},
|
||||||
|
"src_endpoint": {
|
||||||
|
"port": 443,
|
||||||
|
"ip": "10.91.160.45",
|
||||||
|
"type":"HTTPS"
|
||||||
|
},
|
||||||
|
"dst_endpoint": {
|
||||||
|
"port": 443,
|
||||||
|
"ip": "10.91.160.77",
|
||||||
|
"type": "HTTPS"
|
||||||
|
},
|
||||||
|
"time": 1722515664000,
|
||||||
|
"user": {
|
||||||
|
"home_directory": "/Usr/Ivan/",
|
||||||
|
"uuid":"48D9C7A3-2DC6-11EF-AA59-00155D641207",
|
||||||
|
"uid": "3978406",
|
||||||
|
"type": "User",
|
||||||
|
"name": "Ivan"
|
||||||
|
},
|
||||||
|
"utype": "file_deleted"
|
||||||
|
}
|
||||||
|
|
||||||
|
Logon ={
|
||||||
|
"classifications": [{
|
||||||
|
"ref_id": "globalscape:48D9C7A3-2DC6-11EF-AA59-00155D641206",
|
||||||
|
"time": 1722510924000,
|
||||||
|
|
||||||
|
}],
|
||||||
|
"dst_endpoint": {
|
||||||
|
"port": 443,
|
||||||
|
"ip": "10.91.160.77",
|
||||||
|
"type": "HTTPS"
|
||||||
|
},
|
||||||
|
"guid": "48D9C7A3-2DC6-11EF-AA59-00155D641206",
|
||||||
|
"prd_ext_tenant_id": "e71851c2-593f-4f49-9c07-91727b1be94b",
|
||||||
|
"product_name": "GlobalScape EFT",
|
||||||
|
"prd_ext_tenant_name": "GlobalScape EFT",
|
||||||
|
"src_endpoint": {
|
||||||
|
"port": 443,
|
||||||
|
"ip": "10.91.160.45",
|
||||||
|
"type":"HTTPS"
|
||||||
|
},
|
||||||
|
"time": 1722510924000,
|
||||||
|
"user": {
|
||||||
|
"home_directory": "/Usr/Ivan/",
|
||||||
|
"uuid":"48D9C7A3-2DC6-11EF-AA59-00155D641206",
|
||||||
|
"uid": "3978405",
|
||||||
|
"type": "User",
|
||||||
|
"name": "Ivan"
|
||||||
|
},
|
||||||
|
"utype": "user_logged_on"
|
||||||
|
}
|
11
inexSqlquery.py
Normal file
11
inexSqlquery.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class sqlQuerymodel:
|
||||||
|
def queryData():
|
||||||
|
"""Embedded query data"""
|
||||||
|
q ="""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.CommandParameters, p.FileName, p.VirtualFolderName, p.PhysicalFolderName, p.IsInternal, p.FileSize, p.TransferTime, p.BytesTransferred, p.ResultID, t.TransactionID, p.Description, p.Actor, t.ParentTransactionID, 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"""
|
||||||
|
return q
|
Reference in New Issue
Block a user