Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def print_banner(color=True):
"""Prints an Alarmageddon banner in color if the caller requests it
and stdout is a terminal. PEP8 is temporarily suspended...
"""
if color and sys.stdout.isatty():
# Print a color version of the banner
init()
print("")
print((Fore.WHITE + " " + Style.DIM + "( " + Style.NORMAL + "." + Style.DIM + " ( ) :" + Style.NORMAL + "." + Style.DIM + " ) " +
Style.NORMAL + Fore.YELLOW + ". , // . , " + Fore.GREEN + "/\\"))
print((Fore.WHITE + " " + Style.DIM + "( ( ) ) " + Style.NORMAL + Fore.YELLOW + ". // . " + Fore.GREEN + "/\\/ \\/\\"))
print((Fore.WHITE + " " + Style.DIM + "( : " + Style.NORMAL + "*" + Style.DIM + " ( ) " + Style.NORMAL + " * " + Fore.YELLOW +
". // . " + Fore.GREEN + "( " + Fore.RED + ">" + Fore.GREEN + "\\ /" + Fore.RED + "<" + Fore.GREEN + " )"))
print((Fore.WHITE + " * " + Style.DIM + " ( : ) " + Style.NORMAL + Fore.YELLOW + ". // . . " + Fore.GREEN + "/ `__` \\"))
print((Fore.WHITE + " " + Style.DIM + "( : : ) " + Style.NORMAL + " * " + Fore.RED + Style.BRIGHT + " O" + Fore.YELLOW + Style.NORMAL +
" . " + Fore.GREEN + "\\ /" + Fore.WHITE + "VVVV" + Fore.GREEN + "\ /"))
print((Fore.WHITE + " * " + Style.DIM + " ( : ) " + Style.NORMAL + Fore.RED + "/" + Fore.WHITE + "IIIIIII" + Fore.RED +
"/[]\\ "))
print((Fore.WHITE + " . " + Fore.RED + "||||" + Fore.WHITE + " . " + Fore.WHITE + Style.DIM + "d" + Style.NORMAL + Fore.RED + "_" + Fore.WHITE + "O" + Fore.RED +
"______" + Fore.WHITE + "O" + Fore.RED + "___" + Style.DIM + Fore.WHITE + "b" + Style.NORMAL))
print((Fore.WHITE + " . " + Fore.RED + "||||" + Fore.WHITE + " . \\o/ \\o/ " + Fore.GREEN + " __ \\" + Fore.WHITE + "^^^^" +
Fore.GREEN + "/ \ "))
print((Fore.WHITE + " " + Fore.MAGENTA + "_/ " + Fore.YELLOW + "@ @@" + Fore.MAGENTA + "_" + Fore.WHITE + " | | " +
Fore.GREEN + "/ /\\ \__/ \ "))
print((Fore.WHITE + " " + Fore.MAGENTA + "/ " + Fore.YELLOW + "@ @" + Fore.MAGENTA + " \ " + Fore.WHITE + " // \\\\ " +
def main():
colorama.init()
# gratuitous use of lambda.
pos = lambda y, x: '\x1b[%d;%dH' % (y, x)
# draw a white border.
print(Back.WHITE, end='')
print('%s%s' % (pos(MINY, MINX), ' '*MAXX), end='')
for y in range(MINY, 1+MAXY):
print('%s %s ' % (pos(y, MINX), pos(y, MAXX)), end='')
print('%s%s' % (pos(MAXY, MINX), ' '*MAXX), end='')
# draw some blinky lights for a while.
for i in range(PASSES):
print('%s%s%s%s%s' % (pos(randint(1+MINY,MAXY-1), randint(1+MINX,MAXX-1)), choice(FORES), choice(BACKS), choice(STYLES), choice(CHARS)), end='')
# put cursor to top, left, and set color to white-on-black with normal brightness.
print('%s%s%s%s' % (pos(MINY, MINX), Fore.WHITE, Back.BLACK, Style.NORMAL), end='')
from Interpreters.ISAFInterpreter import ISAFInterpreter
# COLORAMA INIT #
init()
# LOGGER CONFIGURATION #
log_handler = logging.handlers.RotatingFileHandler(Configuration.LOG_FILE_NAME,
maxBytes=int(Configuration.LOG_MAX_FILE_SIZE))
log_format = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s')
log_handler.setFormatter(log_format)
LOGGER = logging.getLogger()
LOGGER.setLevel(int(Configuration.LOG_LEVEL))
LOGGER.addHandler(log_handler)
# ARGUMENT PARSE #
parser = argparse.ArgumentParser(description=Style.BRIGHT + Fore.BLUE + 'ISAF - Industrial Security Auditing Framework' + Style.NORMAL + Fore.RESET)
parser.add_argument('-e',
'--extra-package-path',
help='Add extra modules to ISAF. (Overwrites Configured One)')
# GET VERSION LABEL #
version_label = str(subprocess.check_output(["git", "describe"]).strip(), "utf-8").split("-")[0]
def ISAF(extra_package_path=Configuration.EXTRA_PACKAGE_PATH):
if not os.path.isdir(extra_package_path):
extra_package_path = None
isaf = ISAFInterpreter(version_label, extra_package_path)
isaf.start()
if __name__ == "__main__":
def get_logger()->logging.Logger:
global _stream_logger_inited
if not _stream_logger_inited:
_init_stream_logger()
_stream_logger_inited = True
return logging.getLogger('lyrebird')
Color = namedtuple('Color', ['fore', 'style', 'back'])
COLORS = dict(
CRITICAL=Color(fore=Fore.WHITE, style=Style.BRIGHT, back=Back.RED),
ERROR=Color(fore=Fore.RED, style=Style.NORMAL, back=Back.RESET),
WARNING=Color(fore=Fore.YELLOW, style=Style.NORMAL, back=Back.RESET),
INFO=Color(fore=Fore.WHITE, style=Style.NORMAL, back=Back.RESET),
DEBUG=Color(fore=Fore.GREEN, style=Style.NORMAL, back=Back.RESET)
)
def colorit(message, levelname):
color = COLORS.get(levelname)
if color:
return f'{color.fore}{color.style}{color.back}{message}{Style.RESET_ALL}'
else:
return message
class ColorFormater(logging.Formatter):
def format(self, record:logging.LogRecord):
module = f'{colorit(record.module, record.levelname)}'
msg = f'{colorit(record.msg, record.levelname)}'
levelname = f'{colorit(record.levelname, record.levelname)}'
def all_for_support():
with tqdm(total=5) as pbar:
path = init_config()
get_status_check(path)
pbar.update(1)
get_logs(path)
pbar.update(1)
get_pip_freeze(path)
pbar.update(1)
make_zip(path)
pbar.update(1)
end_config(path)
pbar.update(1)
print('[{green}+{white}] Process Completed. A {bright}faraday_support.zip{normal} was generated'
.format(green=Fore.GREEN, white=Fore.WHITE, bright=Style.BRIGHT, normal=Style.NORMAL))
def set_metadata_tags(args, audio_file, idx, track, ripper):
# log completed file
print(Fore.GREEN + Style.BRIGHT + os.path.basename(audio_file) +
Style.NORMAL + "\t[ " + format_size(os.stat(audio_file)[ST_SIZE]) +
" ]" + Fore.RESET)
if args.output_type == "wav" or args.output_type == "pcm":
print(Fore.YELLOW + "Skipping metadata tagging for " +
args.output_type + " encoding...")
return
# ensure everything is loaded still
if not track.is_loaded:
track.load()
if not track.album.is_loaded:
track.album.load()
album_browser = track.album.browse()
album_browser.load()
# calculate num of tracks on disc and num of dics
def formatResult(result, plain=False, short=False, indent=''):
if not plain:
# colorama, BSD 3-Clause license, cross-platform terminal colours, pip install colorama
import colorama
DIM = colorama.Style.DIM #pylint: disable=no-member
BRIGHT = colorama.Style.BRIGHT #pylint: disable=no-member
NORMAL = colorama.Style.NORMAL #pylint: disable=no-member
GREEN = colorama.Fore.GREEN #pylint: disable=no-member
BLUE = colorama.Fore.BLUE #pylint: disable=no-member
RED = colorama.Fore.RED #pylint: disable=no-member
YELLOW = colorama.Fore.YELLOW #pylint: disable=no-member
RESET = colorama.Style.RESET_ALL #pylint: disable=no-member
else:
DIM = BRIGHT = NORMAL = GREEN = BLUE = RED = YELLOW = RESET = u''
def formatKeyword(keyword):
if keyword.endswith('official'):
return BRIGHT + GREEN + keyword + RESET
else:
return BRIGHT + keyword + NORMAL
def formatAuthor(author):
if isinstance(author, dict):
prev_vpc = node_vpc
if node.cluster != prev_cluster_name:
if node.cluster:
if True:
print( "%scluster [%s]" % (colorama.Style.RESET_ALL, node.cluster))
else:
print( "%s%s" % (colorama.Style.RESET_ALL, node.cluster))
prev_cluster_name = node.cluster or cluster_filter
else:
print (colorama.Style.RESET_ALL)
print( "unassigned:" )
prev_cluster_name = None
print(
colorama.Style.NORMAL,
colorama.Fore.CYAN,
" ",
" ".join(header_fmt) % tuple(node.disp_data()))
ext_data = []
if extended == 1:
ext_data = node.extended_data().items()
elif extended == 2:
ext_data = node.all_data().items()
if ext_data:
for (k,v) in sorted(ext_data, key=lambda x:x[0]):
print(colorama.Style.RESET_ALL, colorama.Style.DIM, header_fmt[1] % "", k, ":", v)
print(colorama.Style.RESET_ALL)
finally:
print(colorama.Style.RESET_ALL)
def arg_show(cli_args):
"""Show a card summary"""
board = backlog_board()
card = card_by_id(cli_args.card_id, board)
if not card:
return
print(f'{colorama.Fore.YELLOW}{colorama.Style.BRIGHT}{card.name}{colorama.Fore.RESET}')
print(f'Due: {format_due_date(card)}{colorama.Fore.RESET}{colorama.Style.NORMAL}')
for comment in sorted(card.get_comments(), key=lambda c: c['date'], reverse=True):
comment_datetime = str(dateutil.parser.parse(comment['date']))
print(f'{colorama.Fore.BLUE}{comment_datetime}', end=' ')
print(f'{colorama.Fore.GREEN}{comment["data"]["text"]}')
print(colorama.Fore.RESET, end='')