Debug installing app, that didn't tested on VT

This commit is contained in:
BarsTiger
2022-03-01 21:42:26 +02:00
parent be4762a983
commit b2bd838924
2 changed files with 53 additions and 43 deletions

View File

@@ -91,39 +91,46 @@ def install(package):
"You can add it by entering horsy --vt [key] in terminal") "You can add it by entering horsy --vt [key] in terminal")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
else: else:
download_ui.logs_box.append("If you want to disable scan, type horsy --vt disable in terminal") try:
download_ui.logs_box.append("Starting virustotal scan for program") download_ui.logs_box.append("If you want to disable scan, type horsy --vt disable in terminal")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) download_ui.logs_box.append("Starting virustotal scan for program")
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath)) download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], scan_file('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath))
horsy_vars.horsypath)) analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1],
download_ui.logs_box.append(f"Scan finished for program \nYou can see report for program by opening: " horsy_vars.horsypath))
f"{analysis['link']} \n" download_ui.logs_box.append(f"Scan finished for program \nYou can see report for program by opening: "
f"{analysis['detect']['malicious']} antivirus flagged this file as malicious") f"{analysis['link']} \n"
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) f"{analysis['detect']['malicious']} antivirus flagged this file as malicious")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
except:
pass
if r['download']: if r['download']:
download_ui.logs_box.append("") try:
download_ui.logs_box.append("Starting virustotal scan for dependency")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1], horsy_vars.horsypath))
download_ui.logs_box.append(f"Scan finished for dependency")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1],
horsy_vars.horsypath))
download_ui.logs_box.append(f"You can see report for dependency by opening: {analysis['link']}")
download_ui.logs_box.append(f"{analysis['detect']['malicious']} "
f"antivirus flagged this file as malicious")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
if analysis['detect']['malicious'] > 0:
download_ui.logs_box.append("")
download_ui.logs_box.append(f"SECURITY WARNING, APP INSTALLATION STOPPED")
download_ui.logs_box.append(f"Dependency can be malicious. "
f"It may run now, if this added to installation config")
download_ui.logs_box.append(f"You can disable VT check with horsy --vt disable \n"
f"or use horsy CLI to force install")
download_ui.logs_box.append("") download_ui.logs_box.append("")
download_ui.logs_box.append("Starting virustotal scan for dependency")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End) download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
scan_file('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1],
horsy_vars.horsypath))
download_ui.logs_box.append(f"Scan finished for dependency")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
analysis = get_report('{2}apps/{0}/{1}'.format(r['name'], r['download'].split('/')[-1],
horsy_vars.horsypath))
download_ui.logs_box.append(f"You can see report for dependency by opening: {analysis['link']}")
download_ui.logs_box.append(f"{analysis['detect']['malicious']} "
f"antivirus flagged this file as malicious")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
if analysis['detect']['malicious'] > 0:
download_ui.logs_box.append("")
download_ui.logs_box.append(f"SECURITY WARNING, APP INSTALLATION STOPPED")
download_ui.logs_box.append(f"Dependency can be malicious. "
f"It may run now, if this added to installation config")
download_ui.logs_box.append(f"You can disable VT check with horsy --vt disable \n"
f"or use horsy CLI to force install")
download_ui.logs_box.append("")
download_ui.logs_box.moveCursor(QtGui.QTextCursor.End)
except:
pass
if r['url'].split('.')[-1] == 'zip': if r['url'].split('.')[-1] == 'zip':
os.remove('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath)) os.remove('{2}apps/{0}/{1}'.format(r['name'], r['url'].split('/')[-1], horsy_vars.horsypath))

View File

@@ -63,18 +63,21 @@ def get_report(filename):
def scan_to_cli(filename): def scan_to_cli(filename):
print(f"Starting virustotal scan") try:
if not get_key(): print(f"Starting virustotal scan")
print(f"[red]Virustotal api key not found[/]") if not get_key():
print(f"You can add it by entering [bold]horsy --vt \[your key][/] in terminal") print(f"[red]Virustotal api key not found[/]")
else: print(f"You can add it by entering [bold]horsy --vt \[your key][/] in terminal")
print(f"[green]Virustotal api key found[/]") else:
print(f"[italic white]If you want to disable scan, type [/][bold]horsy --vt disable[/]" print(f"[green]Virustotal api key found[/]")
f"[italic white] in terminal[/]") print(f"[italic white]If you want to disable scan, type [/][bold]horsy --vt disable[/]"
scan_file(filename) f"[italic white] in terminal[/]")
print(f"[green]Virustotal scan finished[/]") scan_file(filename)
analysis = get_report(filename) print(f"[green]Virustotal scan finished[/]")
print(f"[green]You can see report by opening: [white]{analysis['link']}[/]") analysis = get_report(filename)
print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious") print(f"[green]You can see report by opening: [white]{analysis['link']}[/]")
print(f"{analysis['detect']['malicious']} antivirus flagged this file as malicious")
return analysis return analysis
except:
return None