mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-16 16:46:55 +01:00
bug fixes
Former-commit-id: 4c1161542509a2e2e9b78be119a230e1d8cf4cfc
This commit is contained in:
@@ -178,7 +178,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
|
||||
* @param dependency the dependency to remove JRE CPEs from
|
||||
*/
|
||||
private void removeJreEntries(Dependency dependency) {
|
||||
final List<Identifier> identifiers = dependency.getIdentifiers();
|
||||
final Set<Identifier> identifiers = dependency.getIdentifiers();
|
||||
final Iterator<Identifier> itr = identifiers.iterator();
|
||||
while (itr.hasNext()) {
|
||||
final Identifier i = itr.next();
|
||||
|
||||
@@ -98,12 +98,24 @@ public class HintAnalyzer extends AbstractAnalyzer implements Analyzer {
|
||||
"org.springframework.core",
|
||||
Evidence.Confidence.HIGH);
|
||||
|
||||
final Set<Evidence> evidence = dependency.getProductEvidence().getEvidence();
|
||||
final Evidence springTest3 = new Evidence("Manifest",
|
||||
"Bundle-Vendor",
|
||||
"SpringSource",
|
||||
Evidence.Confidence.HIGH);
|
||||
|
||||
|
||||
Set<Evidence> evidence = dependency.getProductEvidence().getEvidence();
|
||||
if (evidence.contains(springTest1) || evidence.contains(springTest2)) {
|
||||
dependency.getProductEvidence().addEvidence("a priori", "product", "springsource_spring_framework", Evidence.Confidence.HIGH);
|
||||
dependency.getVendorEvidence().addEvidence("a priori", "vendor", "SpringSource", Evidence.Confidence.HIGH);
|
||||
dependency.getVendorEvidence().addEvidence("a priori", "vendor", "vmware", Evidence.Confidence.HIGH);
|
||||
}
|
||||
|
||||
evidence = dependency.getVendorEvidence().getEvidence();
|
||||
if (evidence.contains(springTest3)) {
|
||||
dependency.getProductEvidence().addEvidence("a priori", "product", "springsource_spring_framework", Evidence.Confidence.HIGH);
|
||||
dependency.getVendorEvidence().addEvidence("a priori", "vendor", "vmware", Evidence.Confidence.HIGH);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Dependency implements Comparable<Dependency> {
|
||||
/**
|
||||
* A list of Identifiers.
|
||||
*/
|
||||
private List<Identifier> identifiers;
|
||||
private Set<Identifier> identifiers;
|
||||
/**
|
||||
* A collection of vendor evidence.
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ public class Dependency implements Comparable<Dependency> {
|
||||
vendorEvidence = new EvidenceCollection();
|
||||
productEvidence = new EvidenceCollection();
|
||||
versionEvidence = new EvidenceCollection();
|
||||
identifiers = new ArrayList<Identifier>();
|
||||
identifiers = new TreeSet<Identifier>();
|
||||
vulnerabilities = new TreeSet<Vulnerability>(new VulnerabilityComparator());
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public class Dependency implements Comparable<Dependency> {
|
||||
*
|
||||
* @return an ArrayList of Identifiers.
|
||||
*/
|
||||
public List<Identifier> getIdentifiers() {
|
||||
public Set<Identifier> getIdentifiers() {
|
||||
return this.identifiers;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public class Dependency implements Comparable<Dependency> {
|
||||
*
|
||||
* @param identifiers A list of Identifiers.
|
||||
*/
|
||||
public void setIdentifiers(List<Identifier> identifiers) {
|
||||
public void setIdentifiers(Set<Identifier> identifiers) {
|
||||
this.identifiers = identifiers;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Identifier implements Comparable<Identifier> {
|
||||
* @param value the identifier value.
|
||||
* @param url the identifier url.
|
||||
*/
|
||||
Identifier(String type, String value, String url) {
|
||||
public Identifier(String type, String value, String url) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.url = url;
|
||||
@@ -45,7 +45,7 @@ public class Identifier implements Comparable<Identifier> {
|
||||
* @param url the identifier url.
|
||||
* @param description the description of the identifier.
|
||||
*/
|
||||
Identifier(String type, String value, String url, String description) {
|
||||
public Identifier(String type, String value, String url, String description) {
|
||||
this(type, value, url);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ import org.owasp.dependencycheck.dependency.Dependency;
|
||||
*/
|
||||
public class ReportGenerator {
|
||||
|
||||
public enum Format {
|
||||
ALL,
|
||||
XML,
|
||||
HTML
|
||||
}
|
||||
|
||||
/**
|
||||
* The Velocity Engine.
|
||||
*/
|
||||
@@ -105,18 +111,39 @@ public class ReportGenerator {
|
||||
/**
|
||||
* Generates the Dependency Reports for the identified dependencies.
|
||||
*
|
||||
* @param outputDir the path where the reports should be written.
|
||||
* @param outputFormat the format the report should be written in.
|
||||
* @throws IOException is thrown when the template file does not exist.
|
||||
* @param outputDir the path where the reports should be written
|
||||
* @param format the format the report should be written in
|
||||
* @throws IOException is thrown when the template file does not exist
|
||||
* @throws Exception is thrown if there is an error writing out the
|
||||
* reports.
|
||||
*/
|
||||
public void generateReports(String outputDir, Format format) throws IOException, Exception {
|
||||
if (format == Format.XML || format == Format.ALL) {
|
||||
generateReport("XmlReport", outputDir + File.separator + "DependencyCheck-Report.xml");
|
||||
}
|
||||
if (format == Format.HTML || format == Format.ALL) {
|
||||
generateReport("HtmlReport", outputDir + File.separator + "DependencyCheck-Report.html");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the Dependency Reports for the identified dependencies.
|
||||
*
|
||||
* @param outputDir the path where the reports should be written
|
||||
* @param outputFormat the format the report should be written in (XML, HTML, ALL)
|
||||
* @throws IOException is thrown when the template file does not exist
|
||||
* @throws Exception is thrown if there is an error writing out the
|
||||
* reports.
|
||||
*/
|
||||
public void generateReports(String outputDir, String outputFormat) throws IOException, Exception {
|
||||
if ("XML".equalsIgnoreCase(outputFormat) || "ALL".equalsIgnoreCase(outputFormat)) {
|
||||
generateReport("XmlReport", outputDir + File.separator + "DependencyCheck-Report.xml");
|
||||
if ("XML".equalsIgnoreCase(outputFormat)) {
|
||||
generateReports(outputDir, Format.XML);
|
||||
}
|
||||
if ("HTML".equalsIgnoreCase(outputFormat) || "ALL".equalsIgnoreCase(outputFormat)) {
|
||||
generateReport("HtmlReport", outputDir + File.separator + "DependencyCheck-Report.html");
|
||||
if ("HTML".equalsIgnoreCase(outputFormat)) {
|
||||
generateReports(outputDir, Format.XML);
|
||||
}
|
||||
if ("ALL".equalsIgnoreCase(outputFormat)) {
|
||||
generateReports(outputDir, Format.ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +157,7 @@ public class ReportGenerator {
|
||||
* @throws IOException is thrown when the template file does not exist.
|
||||
* @throws Exception is thrown when an exception occurs.
|
||||
*/
|
||||
public void generateReport(String templateName, String outFileName) throws IOException, Exception {
|
||||
protected void generateReport(String templateName, String outFileName) throws IOException, Exception {
|
||||
InputStream input = null;
|
||||
String templatePath = null;
|
||||
final File f = new File(templateName);
|
||||
|
||||
Reference in New Issue
Block a user