Post Black Linting
This commit is contained in:
+38
-35
@@ -14,12 +14,11 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#TODO Add CSV injection prevention
|
||||
#TODO Continue OTP and Local approval rewrites
|
||||
#TODO Explore pywin32
|
||||
#TODO Fix Requirements.txt
|
||||
#TODO Create Generic system_config.json for gitea
|
||||
# TODO Add CSV injection prevention
|
||||
# TODO Continue OTP and Local approval rewrites
|
||||
# TODO Explore pywin32
|
||||
# TODO Fix Requirements.txt
|
||||
# TODO Create Generic system_config.json for gitea
|
||||
|
||||
|
||||
import logging
|
||||
@@ -29,62 +28,66 @@ import dotenv
|
||||
import urllib3
|
||||
|
||||
import flows.localApproval as la
|
||||
from Server.scheduler_async import recurring_job, register_function, reload_jobs, start_scheduler
|
||||
from Server.scheduler_async import (
|
||||
recurring_job,
|
||||
register_function,
|
||||
reload_jobs,
|
||||
start_scheduler,
|
||||
)
|
||||
from services.API import AirlockAPIWrapper
|
||||
from services.policyhandler import updateAuditPoliciesFromEnforcementPolices
|
||||
from services.security import getAPI
|
||||
from utils.setup import setup
|
||||
|
||||
urllib3.disable_warnings(
|
||||
urllib3.exceptions.InsecureRequestWarning
|
||||
)
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
#Determine working directory, setup directory, configure logging, sent env, get API and URL if not already stored
|
||||
|
||||
# Determine working directory, setup directory, configure logging, sent env, get API and URL if not already stored
|
||||
|
||||
working_dir = setup()
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
dotenv.load_dotenv(dotenv_path=working_dir / ".env")
|
||||
|
||||
try:
|
||||
url = os.getenv("URL")
|
||||
username = os.getenv("USERNAME")
|
||||
url = os.getenv("URL")
|
||||
username = os.getenv("USERNAME")
|
||||
|
||||
if not url:
|
||||
raise ValueError("Missing URL in environment variables.")
|
||||
if not username:
|
||||
raise ValueError("Missing USERNAME in environment variables.")
|
||||
if not url:
|
||||
raise ValueError("Missing URL in environment variables.")
|
||||
if not username:
|
||||
raise ValueError("Missing USERNAME in environment variables.")
|
||||
|
||||
logger.debug(f"Retrieved URL: {url}")
|
||||
logger.debug(f"Retrieved Username: {username}")
|
||||
|
||||
logger.debug(f"Retrieved URL: {url}")
|
||||
logger.debug(f"Retrieved Username: {username}")
|
||||
|
||||
except ValueError as e:
|
||||
logger.error(f"Configuration error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
logger.error(f"Configuration error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
api = AirlockAPIWrapper(
|
||||
base_url=str(os.getenv("URL")),
|
||||
api_key = getAPI(username, "AirlockTools"),
|
||||
)
|
||||
|
||||
base_url=str(os.getenv("URL")),
|
||||
api_key=getAPI(username, "AirlockTools"),
|
||||
)
|
||||
|
||||
logger.info("Running non-interactively to start monitoring Airlock Changes")
|
||||
|
||||
|
||||
register_function("monitorLA", la.scheduleAddingLAHashes)
|
||||
register_function("updateAuditPolicies", updateAuditPoliciesFromEnforcementPolices)
|
||||
|
||||
|
||||
if not os.path.exists("scheduling\\jobs.json"):
|
||||
if not os.path.exists("scheduling\\jobs.json"):
|
||||
recurring_job("monitorLA", "monitorLA", interval=50, unit="seconds", args=[api])
|
||||
recurring_job("updateAuditPolicies", "updateAudit", interval=5, unit="minutes", args=[api])
|
||||
recurring_job(
|
||||
"updateAuditPolicies", "updateAudit", interval=5, unit="minutes", args=[api]
|
||||
)
|
||||
else:
|
||||
reload_jobs()
|
||||
|
||||
|
||||
start_scheduler()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user