Skip to content

Understanding SeBAz.py

Deepak Balaji edited this page Apr 4, 2020 · 2 revisions

This page explains what SeBAz.py does

To start off, SeBAz.py is the entry point into all the scripts that make the tool function. Hence, this script takes care of

  • Arguments given during program call

  • Calling the functions as per the user's needs

  • Display progress bar and result on the terminal

  • Write findings into CSV

  • Generate report

Imports

  • parser from argumentsParser to deal with the options given by the user during program call

  • time gmtime localtime from time to calculate how long the program ran

  • get_recommendations from optionsParser.py to get the list of control ID's as specified in the user's script call

  • disp_exp from optionsParser.py to display the explanations of the controls

  • generatePDF from reportGenerator.py to generate report(s) from existing CSV(s)

  • geteuid from os to ensure that the program exits if not called on as root

  • get_manager from enlighten to enable enlighten to control the terminal space to display progress bar and text properly

  • system from os to call the clear command and to make the logs directory

  • bold red green yellow from huepy to print colored text on the terminal

  • path from os to manage the path of the CSV, Report and log files

  • writer from csv to write findings into the spreadsheet

  • ThreadPoolExecutor from concurrent.futures to enable concurrent testing of controls using MultiThreading

  • test from benchmarks.py to actually perform the tests

  • repeat from itertools as the map function requires a list/tuple to be passed as argument, and test requires some variable arguments to be sent as well

  • createPDF from reportGenerator.py to create the report in the current run

  • Image from fabulous.image to print the logo on the terminal

Variables

  • options stores the options that was given as argument during program call. For more information, read this wiki

  • start stores the program start timestamp

  • gmt_time stores the program start time in GMT

  • local stores the program start time in the local time zone

  • recommendations stores the list of the recommendations that the user wants to test in this run

  • manager stores the enlighten terminal manager

  • file_path stores absolute path to the CSV that is created for this run

  • length stores the total number of controls that the user wants to check in this run

  • score stores the score of the system (Only those recommendations that are SCORED and have PASSED)

  • passed stores the count of all the recommendations that have PASSED irrespective of whether they are scored or not

  • passd is the enlighten progress bar manager that counts the number of controls that have passed

  • faild is the enlighten progress bar manager that counts the number of controls that have failed

  • check is the enlighten progress bar manager that counts the number of controls that needs to be checked by the user

  • log_file is the path of the log directory

  • results stores all the results of the tests that were performed. results is a 2-D list that consists of the following

    • first element is the score. 2 if the control passed and is scored, 1 if the control passed and is not scored, and 0 if the control failed [or] needs to be checked
    • second element is the result that needs to be written into the CSV. For more information, read this wiki
  • duration stores the time taken to execute the program as a string

  • result stores the result of the benchmark as a string

  • end stores the total time taken to execute the program as a float

Clone this wiki locally