@@ -75,8 +75,6 @@ public static void colorPrint(boolean erase, Ansi.Color highlight,
75
75
76
76
// Clear terminal + print or don't clear terminal + print
77
77
if (erase )
78
-
79
- // http://fusesource.github.io/jansi/
80
78
StdOut .print (ansi ().eraseScreen ().bg (highlight ).fg (text ).a (str )
81
79
.reset ());
82
80
else
@@ -88,11 +86,6 @@ public static void colorPrint(boolean erase, Ansi.Color highlight,
88
86
public static void printLogo (Ansi .Color text ) {
89
87
90
88
// VirusTotal ascii art logo
91
- // https://www.virustotal.com/gui/home/upload
92
- // https://cloudconvert.com/svg-to-jpg
93
- // https://pypi.org/project/ascii-art-cli/
94
- // Python library for image -> ascii art
95
- // cmd: ascii-art "logo - Copy.jpg" --width 90 --height 9 --chars @.
96
89
String logo =
97
90
"\n .@@@@@@@@@@@@@@@@......................................"
98
91
+ "...................................\n "
@@ -152,8 +145,6 @@ private static void help(String[] args, Ansi.Color text) {
152
145
StdOut .println ();
153
146
154
147
// End program
155
- // https://stackoverflow.com/questions/2434592/difference-in-syst
156
- // em-exit0-system-exit-1-system-exit1-in-java
157
148
System .exit (0 );
158
149
}
159
150
}
@@ -205,13 +196,9 @@ private static String cmdLineArg(String[] args, String flag,
205
196
private static String fileExists (String filePath ) {
206
197
207
198
// Absolute path of 'filePath'
208
- // https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html
209
- // https://docs.oracle.com/javase/tutorial/essential/io/pathOps.html
210
- // https://docs.oracle.com/javase/7/docs/api/java/nio/file/Paths.html
211
199
Path absFilePath = Paths .get (filePath ).toAbsolutePath ();
212
200
213
201
// Is the file valid, existing, accessible file
214
- // https://docs.oracle.com/javase/tutorial/essential/io/check.html
215
202
boolean realFile = Files .isRegularFile (absFilePath )
216
203
&& Files .isReadable (absFilePath )
217
204
&& Files .isExecutable (absFilePath ) && Files .exists (absFilePath );
@@ -243,11 +230,6 @@ public static WebElement findElement(WebDriver driver, String script,
243
230
WebElement element = null ;
244
231
245
232
// JavaScript 'script' returns something
246
- // https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/J
247
- // avascriptExecutor.html
248
- // https://www.browserstack.com/guide/javascriptexecutor-in-selenium
249
- // https://www.lambdatest.com/blog/how-to-use-javascriptexecutor-in-sele
250
- // nium-webdriver/
251
233
try {
252
234
JavascriptExecutor js = (JavascriptExecutor ) driver ;
253
235
element = (WebElement ) js .executeScript (script );
@@ -256,8 +238,6 @@ public static WebElement findElement(WebDriver driver, String script,
256
238
257
239
// If you want to return the HTML element, but JavaScript 'script'
258
240
// doesn't return anything
259
- // https://www.oracle.com/technical-resources/articles/java/java8-op
260
- // tional.html
261
241
if (element == null && !noReturn ) {
262
242
263
243
// Color print error message
@@ -294,8 +274,6 @@ public static boolean foundString(WebDriver driver, String script) {
294
274
}
295
275
296
276
// Execute 'script' again
297
- // https://stackoverflow.com/questions/40392594/java-try-and-catch-u
298
- // ntil-no-exception-is-thrown
299
277
catch (JavascriptException e ) {
300
278
continue ;
301
279
}
@@ -355,46 +333,6 @@ public static void removeEngines(String selectEngine,
355
333
// Runs everything
356
334
public static void main (String [] args ) {
357
335
358
- //--------------------------------------------------------------
359
- // TESTING: runs if '--test' or '-t' flag is present
360
- // 2 methods to test: cmdLineArg and fileExists
361
- // Iterate through command line arguments
362
- for (int i = 0 ; i < args .length ; i ++) {
363
- if (args [i ].equals ("--test" )) {
364
- // cmdLineArg test 1:
365
- String [] args0 = new String [] { "a" , "-b" , "follows b" };
366
- String afterB = cmdLineArg (args0 , "--b" , "-b" );
367
- assert afterB .equals ("follows b" );
368
-
369
- // cmdLineArg test 2:
370
- String [] args1 = new String [] { "vt" , "--file" , "file" , "-e" , "engine" };
371
- String file0 = cmdLineArg (args1 , "--file" , "-f" );
372
- assert file0 .equals ("file" );
373
- String engineName = cmdLineArg (args1 , "--engine" , "-e" );
374
- assert engineName .equals ("engine" );
375
-
376
- // cmdLineArg test 3:
377
- StdOut .println ("\n The following output is from a test case:" );
378
- String [] args2 = new String [] { "vt" , "--file" };
379
- String file1 = cmdLineArg (args2 , "--file" , "-f" );
380
- assert file1 == null ;
381
-
382
- }
383
-
384
- if (args [i ].equals ("-t" )) {
385
-
386
- // fileExists test 1:
387
- // https://www.delftstack.com/howto/java/java-get-type-of-object/
388
- StdOut .println (fileExists ("ScanResult.java" ).getClass () ==
389
- String .class );
390
-
391
- // filesExists test 2:
392
- StdOut .println ("\n The following output is from a test case:" );
393
- StdOut .println (fileExists ("asdfasdf" ).equals ("sdf" ));
394
- }
395
- }
396
- //--------------------------------------------------------------
397
-
398
336
// Color print logo
399
337
printLogo (BLUE );
400
338
@@ -419,10 +357,6 @@ public static void main(String[] args) {
419
357
".\\ chromedriver_win32\\ chromedriver.exe" );
420
358
421
359
// Browsing options
422
- // https://stackoverflow.com/questions/52975287/selenium-chromedrive
423
- // r-disable-logging-or-redirect-it-java
424
- // https://www.selenium.dev/selenium/docs/api/java/org/openqa/seleni
425
- // um/chrome/ChromeOptions.html
426
360
ChromeOptions options = new ChromeOptions ();
427
361
options .setHeadless (true );
428
362
// Logging suppression
@@ -440,13 +374,6 @@ public static void main(String[] args) {
440
374
441
375
// Find 'Choose file' button
442
376
// Long messy JavaScript code to find the button
443
- // https://stackoverflow.com/questions/62799036/unable-to-locate-the
444
- // -sign-in-element-within-shadow-root-open-using-selenium-a/6280367
445
- // 1#62803671
446
- // https://stackoverflow.com/questions/59345959/how-to-pass-the-valu
447
- // e-in-search-on-url-https-www-virustotal-com-gui-home-searc
448
- // https://developer.mozilla.org/en-US/docs/Web/API/Document/querySe
449
- // lector
450
377
String script = "return document.querySelector('vt-ui-shell"
451
378
+ " div#view-container home-view')"
452
379
+ ".shadowRoot.querySelector('div.wrapper"
@@ -457,7 +384,6 @@ public static void main(String[] args) {
457
384
WebElement fileUpload = findElement (driver , script , false );
458
385
459
386
// Upload file
460
- // https://www.guru99.com/upload-download-file-selenium-webdriver.html
461
387
fileUpload .sendKeys (absFilePath );
462
388
463
389
// Check if the file has been uploaded to VirusTotal before
@@ -486,10 +412,6 @@ public static void main(String[] args) {
486
412
if (foundString (driver , scanCompleteScript )) {
487
413
// Long messy JavaScript code to find + form Array of
488
414
// each individual engine scan HTML element
489
- // https://www.geeksforgeeks.org/jquery-queryselector-vs-queryse
490
- // lectorall-methods/
491
- // https://www.techiediaries.com/javascript-queryselectorall-nod
492
- // elist-foreach/
493
415
String resultScript
494
416
= "return Array.from(document.querySelector("
495
417
+ "'vt-ui-shell div#view-container file-view')"
@@ -517,12 +439,7 @@ public static void main(String[] args) {
517
439
// Following try-catch needed because of
518
440
// org.openqa.selenium.StaleElementReferenceException
519
441
// Get engine name from engine scan element
520
- // https://stackoverflow.com/questions/19149327/selenium-exc
521
- // eption-in-thread-main-org-openqa-selenium-staleelementref
522
- // erenceex
523
442
try {
524
- // https://docs.oracle.com/javase/7/docs/api/java/util/regex
525
- // /Pattern.html#sum
526
443
engine = detectionElements .get (i ).getText ().split ("\n " )[0 ];
527
444
}
528
445
0 commit comments