Files
AirlockTools/AirlockTools.py
T
2025-08-20 22:46:55 -04:00

62 lines
1.8 KiB
Python

import dotenv
import os
import utils.getdeviceevents
import utils.allowlist
import utils.hashfunctions
import utils.pathfunctions
import urllib3
import pandas as pd
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
dotenv.load_dotenv()
url = "https://172.17.22.240:3129"
def apivalidation():
print("=== Welcome to the Airlock API Tool ===")
match os.getenv('APIKEY'):
case '':
print("Please add your API Key to the .env file")
case _:
menu()
def menu():
print("\n--- Main Menu ---")
print("1. Get All Events for Single Device")
print("2. Get Execution Histories for Allow List")
while True:
choice = input("Enter Menu Item: ")
if choice == '1':
utils.getdeviceevents.devicehistory(url,False)
if choice == '2':
utils.allowlist.allowlistexechistories(url,False)
if choice == '3':
executionhist = utils.allowlist.allowlistexechistories(url,True)
print(executionhist)
aggregated = utils.hashfunctions.aggregateHashes(executionhist)
print(aggregated)
augmented = utils.hashfunctions.augmentAggregatedHashes(url,aggregated)
print(augmented)
augmented.to_html("augmentedlist.html", index=False)
badpublisherlist = []
categorized = utils.hashfunctions.categorizeHashes(augmented, 5, badpublisherlist)
categorized[0].to_html("needsreview.html", index=False)
categorized[1].to_html("approved.html", index=False)
categorized[2].to_html("remaining.html", index=False)
if choice == '4':
html_file = "augmentedlist.html"
augmented_df = pd.read_html(html_file)
print(augmented_df)
combined_df = pd.concat(augmented_df, ignore_index=True)
test = utils.pathfunctions.filepathInitalGroup(combined_df)
test.to_html("testgroup2.html", index=False)
if __name__ == "__main__":
apivalidation()