mirror of
https://github.com/OpticFusion1/MCAntiMalware.git
synced 2026-05-14 09:40:35 +00:00
v15.11
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>MCAntiMalware</artifactId>
|
||||
<version>15.10</version>
|
||||
<version>15.11</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
|
||||
+19
-6
@@ -21,9 +21,12 @@ import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Stream;
|
||||
@@ -59,6 +62,7 @@ public class FileScanner {
|
||||
private final CommandLineParser commandLineParser;
|
||||
private final CheckManager checkManager;
|
||||
private final BiConsumer<Path, CheckResult> notifications;
|
||||
private List<Path> alreadyScanned = new ArrayList<>();
|
||||
|
||||
public FileScanner(CacheContainer cache, Database database, CommandLineParser commandLineParser, CheckManager checkManager, BiConsumer<Path, CheckResult> notifications) {
|
||||
this.cache = cache;
|
||||
@@ -69,12 +73,15 @@ public class FileScanner {
|
||||
}
|
||||
|
||||
public void scanFile(Path file) {
|
||||
if (alreadyScanned.contains(file)) {
|
||||
return;
|
||||
}
|
||||
alreadyScanned.add(file);
|
||||
// Not needed because this method shouldn't be called with a directory like tf it's FileScanner.scanFile like bruh
|
||||
// if (Files.isDirectory(file)) {
|
||||
// scanDirectory(file);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (ScanHelper.isFileEmpty(file)) {
|
||||
return;
|
||||
}
|
||||
@@ -181,32 +188,38 @@ public class FileScanner {
|
||||
|
||||
AtomicBoolean possiblyMalicious = new AtomicBoolean(false);
|
||||
|
||||
walkThroughFiles(rootFolder, classPath -> {
|
||||
if (!validClassPath(classPath)) {
|
||||
// Walks through every file within the .jar, .zip, or .rar file
|
||||
walkThroughFiles(rootFolder, zipEntryPath -> {
|
||||
// Checks if the zipEntryPath is a valid .class file
|
||||
if (!validClassPath(zipEntryPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClassNode classNode = cache.fetchClass(file, classPath);
|
||||
// Gets an instance of the .class. Returns null if not possible
|
||||
ClassNode classNode = cache.fetchClass(file, zipEntryPath);
|
||||
if (classNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Loops through every Anti-Malware check
|
||||
for (BaseCheck check : checkManager.getChecks()) {
|
||||
// Processes the classNode, rootFolder, and the file itself
|
||||
List<CheckResult> results = check.process(classNode, rootFolder, file, cache);
|
||||
if (results == null || results.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Used to determine if the "probably_safe" notification should be used
|
||||
possiblyMalicious.set(true);
|
||||
|
||||
// Loops through the Check results and sends a notification
|
||||
for (CheckResult checkResult : results) {
|
||||
if (commandLineParser.dontLogINFOCR() && checkResult.getType().equals("INFO")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
submitNotification(file, checkResult);
|
||||
}
|
||||
|
||||
// Resets the check to its default state
|
||||
check.reset();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user