Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def pretty_print_testcase(testcase, error=''):
""" Pretty print a testcase """
if error:
msg_template = Style.BRIGHT + '{id}' + Style.RESET_ALL + '\t' + \
Fore.MAGENTA + '{status}' + Fore.RESET + '\t' + \
'{name}\t=> ' + str(error)
elif testcase['status'] == 'PASS':
msg_template = Style.BRIGHT + '{id}' + Style.RESET_ALL + '\t' + \
Fore.LIGHTGREEN_EX + '{status}' + Fore.RESET + '\t' + \
'{name}\t'
else:
msg_template = Style.BRIGHT + '{id}' + Style.RESET_ALL + '\t' + \
Fore.LIGHTRED_EX + '{status}' + Fore.RESET + '\t' + \
'{name}\t'
print(msg_template.format(**testcase), end=Style.RESET_ALL)
result, _ = capsys.readouterr()
# Ansible Environment
title = [
colorama.Back.WHITE,
colorama.Style.BRIGHT,
colorama.Fore.BLACK,
'DEBUG: ANSIBLE ENVIRONMENT',
colorama.Fore.RESET,
colorama.Back.RESET,
colorama.Style.RESET_ALL,
]
print(''.join(title))
data = [
colorama.Fore.BLACK,
colorama.Style.BRIGHT,
util.safe_dump({'ANSIBLE_FOO': 'foo', 'ANSIBLE_BAR': 'bar'}),
colorama.Style.RESET_ALL,
colorama.Fore.RESET,
]
print(''.join(data))
# Molecule Environment
title = [
colorama.Back.WHITE,
colorama.Style.BRIGHT,
colorama.Fore.BLACK,
'DEBUG: MOLECULE ENVIRONMENT',
colorama.Fore.RESET,
colorama.Back.RESET,
colorama.Style.RESET_ALL,
]
def generate_security_group_message(security_group):
return (
colorama.Style.RESET_ALL
+ colorama.Style.BRIGHT
+ colorama.Fore.MAGENTA + security_group['GroupId']
+ " "
+ colorama.Fore.WHITE + security_group['GroupName']
+ colorama.Style.RESET_ALL
)
import socket
import threading
import re
import pickle
import time
from BlockChain import MinerChain, TraderChain
from random import randint
from colorama import Fore, Style
import traceback
# Variaveis globais, apenas para a concatenação da string e colorir a mesma (Biblioteca Colorama)
styleCommunication = Fore.MAGENTA + Style.BRIGHT
styleClient = Fore.GREEN + Style.BRIGHT
styleChain = Fore.YELLOW + Style.BRIGHT
class Connection:
'''
Classe base para conexoes
'''
def __init__(self, my_address, clients):
self.my_address = my_address
self.clients = clients
self.mine = True
self.connMiners = list()
self.connTraders = list()
def show_clients(self):
global styleClient
# sqlite stuff
conn = sqlite3.connect('lib/typo3scan.db')
c = conn.cursor()
c.execute('SELECT advisory, vulnerability, subcomponent, affected_version_max, affected_version_min FROM core_vulns WHERE (?<=affected_version_max AND ?>=affected_version_min)', (version, version,))
data = c.fetchall()
if data:
json_list = {}
for vulnerability in data:
# maybe instead use this: https://oraerr.com/database/sql/how-to-compare-version-string-x-y-z-in-mysql-2/
if parse_version(version) <= parse_version(vulnerability[3]):
json_list[vulnerability[0]] = {'Type': vulnerability[1], 'Subcomponent': vulnerability[2], 'Affected': '{} - {}'.format(vulnerability[3], vulnerability[4]), 'Advisory': 'https://typo3.org/security/advisory/{}'.format(vulnerability[0].lower())}
if json_list:
self.set_typo3_vulns(json_list)
print(' \u2514 Known Vulnerabilities:\n')
for vulnerability in json_list.keys():
print(Style.BRIGHT + ' [!] {}'.format(Fore.RED + vulnerability + Style.RESET_ALL))
print(' \u251c Vulnerability Type:'.ljust(28) + json_list[vulnerability]['Type'])
print(' \u251c Subcomponent:'.ljust(28) + json_list[vulnerability]['Subcomponent'])
print(' \u251c Affected Versions:'.ljust(28) + json_list[vulnerability]['Affected'])
print(' \u2514 Advisory URL:'.ljust(28) + json_list[vulnerability]['Advisory'] + '\n')
else:
print(' \u2514 No Known Vulnerabilities')
else:
print(' \u2514', Fore.RED + 'No Version Information Found.' + Fore.RESET)
if color.upper() == 'B':
c = colorama.Fore.BLUE
elif color.upper() == 'R':
c = colorama.Fore.RED
elif color.upper() == 'G':
c = colorama.Fore.GREEN
elif color.upper() == 'Y':
c = colorama.Fore.YELLOW
elif color.upper() == 'W':
c = colorama.Fore.WHITE
elif color.upper() == 'C':
c = colorama.Fore.CYAN
else:
logger.error('print_c(): Unknown color code %s' % color)
raise ValueError
print(colorama.Style.BRIGHT + c + str(msg) + colorama.Style.RESET_ALL, end=end)
self.execute()
regex_skip = r'\[PyFunceble\sskip\]|\[ci\sskip\]'
if Helpers.Regex(
Helpers.Command('git log -2').execute(),
regex_skip,
return_data=False).match() or self.production:
Clean()
Directory(self.production)
if self.production and not Settings.quiet:
print(
Fore.CYAN +
Style.BRIGHT +
'\n\nThe production logic was successfully completed!')
print('You can now distribute this repository.\n')
else:
if not Settings.quiet:
print(
Fore.CYAN +
Style.BRIGHT +
'\n\nThe installation was successfully completed!')
print(
"You can now use the script with '%s' or learn how to use it with '%s'\n" % # pylint: disable=line-too-long
(Style.BRIGHT + './' + Settings.script + '.py [-OPTIONS]' + Style.RESET_ALL,
Style.BRIGHT + './' + Settings.script + '.py --help' + Style.RESET_ALL))
used_protocol = "OPENVPN-TCP"
else:
used_protocol = "OPENVPN-UDP"
# use api.nordvpn.com
json_res_list = api.get_data_from_api(
country_code=country_code, area=area, p2p=p2p, dedicated=dedicated,
double_vpn=double_vpn, tor_over_vpn=tor_over_vpn, anti_ddos=anti_ddos,
netflix=netflix, location=location)
server_list = filters.filter_by_protocol(json_res_list=json_res_list, tcp=tcp)
better_servers_list = filters.filter_by_load(server_list, max_load, top_servers)
if stats:
print(Style.BRIGHT + Fore.BLUE + "According to NordVPN, \
Least Busy " + Fore.GREEN + str(len(better_servers_list)) + Fore.BLUE + " Servers in \
" + Fore.GREEN + country_code.upper() + Fore.BLUE, end=" ")
if area:
print("in Location" + Fore.GREEN, json_res_list[0]["location_names"], end=" ")
print(Fore.BLUE + "With 'Load' Less Than", Fore.GREEN + str(max_load) + Fore.BLUE,
"Which Support", Fore.GREEN + used_protocol, end=" ")
if p2p:
print(", p2p =", p2p, end=" ")
if dedicated:
print(", dedicated =", dedicated, end=" ")
if double_vpn:
print(", double_vpn =", double_vpn, end=" ")
if tor_over_vpn:
print(", tor_over_vpn =", tor_over_vpn, end=" ")
if anti_ddos:
self.no_failed), extra=logs)
if (self.no_failed):
self.logger_testop.info(
colorama.Fore.RED +
colorama.Style.BRIGHT +
"Overall Tests failed!!! ", extra=logs)
self.result = "Failed"
elif (self.no_passed == 0 and self.no_failed == 0):
self.logger_testop.info(
colorama.Fore.RED +
colorama.Style.BRIGHT +
"None of the test cases executed !!! ", extra=logs)
else:
self.logger_testop.info(
colorama.Fore.GREEN +
colorama.Style.BRIGHT +
"Overall Tests passed!!! ", extra=logs)
self.result = "Passed"