mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-18 07:14:09 +01:00
reduced complexity around determining if the jar contains classes
Former-commit-id: 3d31a3cbebcf0bebec17ee5f8c9a060f60458db8
This commit is contained in:
@@ -360,10 +360,6 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
}
|
}
|
||||||
return foundSomething;
|
return foundSomething;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Tracks whether the jar being analyzed contains classes.
|
|
||||||
*/
|
|
||||||
private boolean hasClasses = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyzes the path information of the classes contained within the
|
* Analyzes the path information of the classes contained within the
|
||||||
@@ -379,7 +375,6 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
*/
|
*/
|
||||||
protected boolean analyzePackageNames(Dependency dependency, boolean addPackagesAsEvidence)
|
protected boolean analyzePackageNames(Dependency dependency, boolean addPackagesAsEvidence)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
hasClasses = false;
|
|
||||||
JarFile jar = null;
|
JarFile jar = null;
|
||||||
try {
|
try {
|
||||||
jar = new JarFile(dependency.getActualFilePath());
|
jar = new JarFile(dependency.getActualFilePath());
|
||||||
@@ -391,7 +386,7 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
final int count = collectPackageNameInformation(en, level0, level1, level2, level3);
|
final int count = collectPackageNameInformation(en, level0, level1, level2, level3);
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return hasClasses;
|
return false;
|
||||||
}
|
}
|
||||||
final EvidenceCollection vendor = dependency.getVendorEvidence();
|
final EvidenceCollection vendor = dependency.getVendorEvidence();
|
||||||
final EvidenceCollection product = dependency.getProductEvidence();
|
final EvidenceCollection product = dependency.getProductEvidence();
|
||||||
@@ -490,7 +485,7 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
jar.close();
|
jar.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasClasses;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -725,7 +720,6 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
while (en.hasMoreElements()) {
|
while (en.hasMoreElements()) {
|
||||||
final java.util.jar.JarEntry entry = (java.util.jar.JarEntry) en.nextElement();
|
final java.util.jar.JarEntry entry = (java.util.jar.JarEntry) en.nextElement();
|
||||||
if (entry.getName().endsWith(".class")) {
|
if (entry.getName().endsWith(".class")) {
|
||||||
hasClasses = true;
|
|
||||||
String[] path;
|
String[] path;
|
||||||
if (entry.getName().contains("/")) {
|
if (entry.getName().contains("/")) {
|
||||||
path = entry.getName().toLowerCase().split("/");
|
path = entry.getName().toLowerCase().split("/");
|
||||||
|
|||||||
Reference in New Issue
Block a user