mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-14 15:53:36 +01:00
Compare commits
354 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a042fab4b | ||
|
|
c3f000c5ef | ||
|
|
e848dd5bee | ||
|
|
566e11f755 | ||
|
|
13aa00e465 | ||
|
|
e9df060e0c | ||
|
|
c4724e8020 | ||
|
|
9c36087dae | ||
|
|
99dd04a1c1 | ||
|
|
29c47e3e96 | ||
|
|
659248ff22 | ||
|
|
71a7e8d2dc | ||
|
|
caabdc6584 | ||
|
|
0b92d2ec17 | ||
|
|
db8bcd8fd6 | ||
|
|
17cb96ef41 | ||
|
|
2248380c90 | ||
|
|
ffe64d2f8f | ||
|
|
a0c624fca6 | ||
|
|
31022ea8de | ||
|
|
0d0de4d5b3 | ||
|
|
1fdb4c4627 | ||
|
|
76665c54e2 | ||
|
|
04166766da | ||
|
|
aa7f903210 | ||
|
|
c4ca53cdf9 | ||
|
|
d5885acd6e | ||
|
|
550b3332a3 | ||
|
|
93b98576b8 | ||
|
|
e6f2c25167 | ||
|
|
0b207c6141 | ||
|
|
3ed5e85646 | ||
|
|
4068da33c8 | ||
|
|
d1d53ee65b | ||
|
|
38413c4f64 | ||
|
|
a6bb6cd170 | ||
|
|
145bf70420 | ||
|
|
e2c92c57e6 | ||
|
|
bcc2173768 | ||
|
|
aa1df53ab0 | ||
|
|
fb6a2a2c37 | ||
|
|
f403fc732c | ||
|
|
03aa7c56a2 | ||
|
|
547d6d4bcc | ||
|
|
2cba8f906d | ||
|
|
bb5ee6a347 | ||
|
|
34604efde4 | ||
|
|
c232a4fbad | ||
|
|
0c5dfdbe24 | ||
|
|
c0f9a382b3 | ||
|
|
8ca32fcace | ||
|
|
0461a9fc89 | ||
|
|
2b600290ae | ||
|
|
56fd3f2566 | ||
|
|
142e06e752 | ||
|
|
cbf2a047be | ||
|
|
1880e22d22 | ||
|
|
963b1eae1c | ||
|
|
d173573e6c | ||
|
|
b6c0426c1c | ||
|
|
4f18e9ee7f | ||
|
|
e227b90370 | ||
|
|
360b112bd2 | ||
|
|
ff7027439d | ||
|
|
a5ed91611a | ||
|
|
168b1c3684 | ||
|
|
7e1141ff16 | ||
|
|
168d55c54c | ||
|
|
d5ed2bc765 | ||
|
|
940a4613ee | ||
|
|
4f6d96e16b | ||
|
|
707d9925a8 | ||
|
|
657340c912 | ||
|
|
3e220704a1 | ||
|
|
4a2309a3f8 | ||
|
|
09122be7be | ||
|
|
e26ec47ad7 | ||
|
|
05ae73eea2 | ||
|
|
511d2b9457 | ||
|
|
bf96c24ec3 | ||
|
|
e328ec990c | ||
|
|
a5dee0cb27 | ||
|
|
7fb5d5bde5 | ||
|
|
5a329b4a6d | ||
|
|
500f6c5b6f | ||
|
|
29f76ba62a | ||
|
|
70e0c84a20 | ||
|
|
3dd95180e0 | ||
|
|
dcd8fc0320 | ||
|
|
bcd9fb0be9 | ||
|
|
a088d20612 | ||
|
|
29fb347bbb | ||
|
|
b2a436b3bc | ||
|
|
d288912df1 | ||
|
|
7bde6baaac | ||
|
|
26ca6d9b77 | ||
|
|
961626a136 | ||
|
|
641a311537 | ||
|
|
995ba02357 | ||
|
|
fb3e6e4208 | ||
|
|
e5363f7c8f | ||
|
|
d1a128b897 | ||
|
|
2b5fb4d75a | ||
|
|
6439ddde23 | ||
|
|
f2994ed4ff | ||
|
|
019bf67f93 | ||
|
|
78c1dcd0d0 | ||
|
|
e07b30df85 | ||
|
|
96cd517c36 | ||
|
|
2cb8e00c99 | ||
|
|
92f093009e | ||
|
|
27256a1854 | ||
|
|
ba782ca56f | ||
|
|
3f3e33a366 | ||
|
|
343fd75477 | ||
|
|
7bcfb6ff49 | ||
|
|
78ec08792f | ||
|
|
461b41f300 | ||
|
|
5b246424fb | ||
|
|
6af4b4cd5e | ||
|
|
6d348eb5a7 | ||
|
|
b26f6b697a | ||
|
|
554510bb78 | ||
|
|
3f2e5b7c69 | ||
|
|
3c4989f5ca | ||
|
|
d33c649be6 | ||
|
|
c55954e5e8 | ||
|
|
678311e65b | ||
|
|
ab1d3075e8 | ||
|
|
0a6f8b7ac1 | ||
|
|
422a1f78fc | ||
|
|
f21af8bd1e | ||
|
|
924278e387 | ||
|
|
c6ea4466fb | ||
|
|
318cc7a8fb | ||
|
|
9554a30286 | ||
|
|
5336da52d9 | ||
|
|
bd0c2e4ee4 | ||
|
|
64aad66adc | ||
|
|
587bf131db | ||
|
|
fc96c727ec | ||
|
|
d17bd5bd9e | ||
|
|
b22a935a6c | ||
|
|
a7c1d594dc | ||
|
|
dd20a9c7cc | ||
|
|
e0994e0e54 | ||
|
|
0f8ce09646 | ||
|
|
871e27d19f | ||
|
|
c429df3280 | ||
|
|
13f355c385 | ||
|
|
d33ddefb2d | ||
|
|
75b3f4b3c8 | ||
|
|
03ce1d2ea8 | ||
|
|
08eae2b09c | ||
|
|
c94f9e2d2b | ||
|
|
520370688c | ||
|
|
725949db2f | ||
|
|
5d647155b6 | ||
|
|
c152bd0517 | ||
|
|
f35146d93d | ||
|
|
e8e58555d0 | ||
|
|
7190dcc04e | ||
|
|
b623e3b3c8 | ||
|
|
d78e82bd56 | ||
|
|
ff478253e3 | ||
|
|
85c3368cda | ||
|
|
a4095cec8d | ||
|
|
c840ce249f | ||
|
|
b70812fc3d | ||
|
|
3ccf06321d | ||
|
|
1d5dd5ea11 | ||
|
|
0cadd88769 | ||
|
|
75499a3321 | ||
|
|
5096027523 | ||
|
|
5c8c07794d | ||
|
|
18a72bbb59 | ||
|
|
7b3c4475da | ||
|
|
419c446f01 | ||
|
|
735c16cc11 | ||
|
|
ed41abcf9d | ||
|
|
b750a8c802 | ||
|
|
1ee75dd8cb | ||
|
|
396efad518 | ||
|
|
8f33be262a | ||
|
|
9daa111f9c | ||
|
|
889bf22840 | ||
|
|
f46e96c7de | ||
|
|
9be6dc2935 | ||
|
|
6188f6d74a | ||
|
|
8837fab9fa | ||
|
|
316339011b | ||
|
|
fe7121e057 | ||
|
|
bc09bfd3ba | ||
|
|
26f19cead1 | ||
|
|
777b35f412 | ||
|
|
9e94ffb422 | ||
|
|
b6a38bf4d1 | ||
|
|
92d12ec68e | ||
|
|
93dd5e4b31 | ||
|
|
79e325e2ab | ||
|
|
0e095018a4 | ||
|
|
7040071ab9 | ||
|
|
e157350d03 | ||
|
|
28f6ef5eec | ||
|
|
15bcee3d10 | ||
|
|
67dbf70f5b | ||
|
|
c75b99837f | ||
|
|
cbc951be62 | ||
|
|
f5b38852a7 | ||
|
|
45b5fd3762 | ||
|
|
04c14f3a27 | ||
|
|
a55d89cc93 | ||
|
|
888801ab0c | ||
|
|
731528ef6e | ||
|
|
d7fbd0df47 | ||
|
|
6f95e6d499 | ||
|
|
79e6a13b29 | ||
|
|
b9a53775b6 | ||
|
|
1b15603227 | ||
|
|
a7ffeb7016 | ||
|
|
13b1c0fe0c | ||
|
|
1d259c510f | ||
|
|
56783bbf4d | ||
|
|
e63c296b16 | ||
|
|
57450a65cf | ||
|
|
716b52ef90 | ||
|
|
6ab8552f44 | ||
|
|
9880483690 | ||
|
|
7b9b459b74 | ||
|
|
0723606120 | ||
|
|
4261e9eb29 | ||
|
|
a322556c66 | ||
|
|
b6d3efa042 | ||
|
|
4019a0615c | ||
|
|
376e486c47 | ||
|
|
5b7c47682b | ||
|
|
741a803ea7 | ||
|
|
8a886f5434 | ||
|
|
01514af188 | ||
|
|
c5d5dccc57 | ||
|
|
5e58304448 | ||
|
|
dd9c4bfa42 | ||
|
|
e6a559f0d1 | ||
|
|
f1c860f68c | ||
|
|
cd175816e2 | ||
|
|
1d74d2e241 | ||
|
|
c4479a36a9 | ||
|
|
cc2c18243e | ||
|
|
211d34fcef | ||
|
|
dc60c24d89 | ||
|
|
922e6437cf | ||
|
|
1058157827 | ||
|
|
33b38e686a | ||
|
|
a6014f30dd | ||
|
|
3fc75df55d | ||
|
|
2bcd9d78e8 | ||
|
|
723b9e9cea | ||
|
|
efb7088cd8 | ||
|
|
f2131102f5 | ||
|
|
eae04bb156 | ||
|
|
11716128df | ||
|
|
5122808189 | ||
|
|
3c1905f941 | ||
|
|
3348086c00 | ||
|
|
919efc5037 | ||
|
|
04ab0e09d5 | ||
|
|
c8862cb927 | ||
|
|
ac135ec2b6 | ||
|
|
0257000d1a | ||
|
|
608b95e941 | ||
|
|
e6a2c5b5b4 | ||
|
|
a546aadba1 | ||
|
|
5934588b2c | ||
|
|
3ad5482a30 | ||
|
|
c3902447af | ||
|
|
764aa466f4 | ||
|
|
9ffda6cd17 | ||
|
|
8281fb09fc | ||
|
|
b6988f96fb | ||
|
|
4597c13d9a | ||
|
|
acf7297c8d | ||
|
|
bbdc8298d9 | ||
|
|
4d9f102033 | ||
|
|
0056e1052c | ||
|
|
7b729e078b | ||
|
|
6a0623f1e7 | ||
|
|
542c871152 | ||
|
|
77189eeeb1 | ||
|
|
340172ab56 | ||
|
|
afcfed1c67 | ||
|
|
59ce3bb64d | ||
|
|
81c5aa73d2 | ||
|
|
12ff05208c | ||
|
|
dc0ef70699 | ||
|
|
6ce735dcc7 | ||
|
|
faf3298f7a | ||
|
|
4f1b6b4bf1 | ||
|
|
99702fdb67 | ||
|
|
7bce7691e4 | ||
|
|
7f90160936 | ||
|
|
f367ad7185 | ||
|
|
29a31476b1 | ||
|
|
b844b66614 | ||
|
|
3e6fa1ed1f | ||
|
|
e141b4eb9f | ||
|
|
c794194bb5 | ||
|
|
3a31902e78 | ||
|
|
fedafe55c3 | ||
|
|
1c0b885267 | ||
|
|
8e4791048b | ||
|
|
e28be6f2b7 | ||
|
|
55271b8e83 | ||
|
|
8b5d8679f7 | ||
|
|
51d8ced8ce | ||
|
|
1cc94dd60b | ||
|
|
6d107e79b6 | ||
|
|
6f44b4dce1 | ||
|
|
1600492780 | ||
|
|
5f396cc647 | ||
|
|
49bd45d88c | ||
|
|
c41e673346 | ||
|
|
cf8d1a490c | ||
|
|
962f20296c | ||
|
|
e9c1ae1893 | ||
|
|
5db51a2abf | ||
|
|
63be1efed9 | ||
|
|
7fe3c659e0 | ||
|
|
4d76c7685c | ||
|
|
b50bcde028 | ||
|
|
9a8b61ae47 | ||
|
|
c31880d8de | ||
|
|
1496dc8e7d | ||
|
|
cdbd513e42 | ||
|
|
653bf1764e | ||
|
|
df08acfe9e | ||
|
|
e7a5287bb4 | ||
|
|
656f26cc9d | ||
|
|
52385ddac4 | ||
|
|
50c58667ba | ||
|
|
9cc6ca5ebe | ||
|
|
34b82a3f84 | ||
|
|
d0401f3f8d | ||
|
|
f247978d12 | ||
|
|
999116c75e | ||
|
|
04e9f5b15b | ||
|
|
78b0f7798f | ||
|
|
b0727ef3cf | ||
|
|
01fb31fc15 | ||
|
|
a1187acc31 | ||
|
|
fe4a24a651 | ||
|
|
3dcce572d3 | ||
|
|
ece69014ce | ||
|
|
fc6bb67e56 | ||
|
|
968de2947b |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
.settings
|
||||
maven-eclipse.xml
|
||||
.externalToolBuilders
|
||||
.pmd
|
||||
# Netbeans configuration
|
||||
nb-configuration.xml
|
||||
/target/
|
||||
@@ -22,4 +23,4 @@ _site/**
|
||||
#unknown as to why these are showing up... but need to be ignored.
|
||||
.LCKpom.xml~
|
||||
#coverity
|
||||
/cov-int/
|
||||
/cov-int/
|
||||
|
||||
@@ -20,7 +20,7 @@ Copyright (c) 2013 - Jeremy Long. All Rights Reserved.
|
||||
<parent>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-parent</artifactId>
|
||||
<version>1.2.9</version>
|
||||
<version>1.2.11</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dependency-check-ant</artifactId>
|
||||
@@ -280,7 +280,6 @@ Copyright (c) 2013 - Jeremy Long. All Rights Reserved.
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>index</report>
|
||||
<report>summary</report>
|
||||
<report>license</report>
|
||||
<report>help</report>
|
||||
@@ -293,6 +292,7 @@ Copyright (c) 2013 - Jeremy Long. All Rights Reserved.
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
<bottom>Copyright© 2012-15 Jeremy Long. All Rights Reserved.</bottom>
|
||||
</configuration>
|
||||
<reportSets>
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* An Ant task definition to execute dependency-check during an Ant build.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DependencyCheckTask extends Task {
|
||||
|
||||
@@ -261,6 +261,29 @@ public class DependencyCheckTask extends Task {
|
||||
public void setAutoUpdate(boolean autoUpdate) {
|
||||
this.autoUpdate = autoUpdate;
|
||||
}
|
||||
/**
|
||||
* Whether only the update phase should be executed.
|
||||
*/
|
||||
private boolean updateOnly = false;
|
||||
|
||||
/**
|
||||
* Get the value of updateOnly.
|
||||
*
|
||||
* @return the value of updateOnly
|
||||
*/
|
||||
public boolean isUpdateOnly() {
|
||||
return updateOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of updateOnly.
|
||||
*
|
||||
* @param updateOnly new value of updateOnly
|
||||
*/
|
||||
public void setUpdateOnly(boolean updateOnly) {
|
||||
this.updateOnly = updateOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this within the
|
||||
* Site plugin unless the externalReport is set to true. Default is HTML.
|
||||
@@ -605,7 +628,7 @@ public class DependencyCheckTask extends Task {
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL of the Nexus server.
|
||||
* The URL of a Nexus server's REST API end point (http://domain/nexus/service/local).
|
||||
*/
|
||||
private String nexusUrl;
|
||||
|
||||
@@ -912,46 +935,51 @@ public class DependencyCheckTask extends Task {
|
||||
Engine engine = null;
|
||||
try {
|
||||
engine = new Engine(DependencyCheckTask.class.getClassLoader());
|
||||
|
||||
for (Resource resource : path) {
|
||||
final FileProvider provider = resource.as(FileProvider.class);
|
||||
if (provider != null) {
|
||||
final File file = provider.getFile();
|
||||
if (file != null && file.exists()) {
|
||||
engine.scan(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
engine.analyzeDependencies();
|
||||
DatabaseProperties prop = null;
|
||||
CveDB cve = null;
|
||||
//todo - should this be its own task?
|
||||
if (updateOnly) {
|
||||
engine.doUpdates();
|
||||
} else {
|
||||
try {
|
||||
cve = new CveDB();
|
||||
cve.open();
|
||||
prop = cve.getDatabaseProperties();
|
||||
} catch (DatabaseException ex) {
|
||||
LOGGER.log(Level.FINE, "Unable to retrieve DB Properties", ex);
|
||||
} finally {
|
||||
if (cve != null) {
|
||||
cve.close();
|
||||
for (Resource resource : path) {
|
||||
final FileProvider provider = resource.as(FileProvider.class);
|
||||
if (provider != null) {
|
||||
final File file = provider.getFile();
|
||||
if (file != null && file.exists()) {
|
||||
engine.scan(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final ReportGenerator reporter = new ReportGenerator(applicationName, engine.getDependencies(), engine.getAnalyzers(), prop);
|
||||
reporter.generateReports(reportOutputDirectory, reportFormat);
|
||||
|
||||
if (this.failBuildOnCVSS <= 10) {
|
||||
checkForFailure(engine.getDependencies());
|
||||
engine.analyzeDependencies();
|
||||
DatabaseProperties prop = null;
|
||||
CveDB cve = null;
|
||||
try {
|
||||
cve = new CveDB();
|
||||
cve.open();
|
||||
prop = cve.getDatabaseProperties();
|
||||
} catch (DatabaseException ex) {
|
||||
LOGGER.log(Level.FINE, "Unable to retrieve DB Properties", ex);
|
||||
} finally {
|
||||
if (cve != null) {
|
||||
cve.close();
|
||||
}
|
||||
}
|
||||
final ReportGenerator reporter = new ReportGenerator(applicationName, engine.getDependencies(), engine.getAnalyzers(), prop);
|
||||
reporter.generateReports(reportOutputDirectory, reportFormat);
|
||||
|
||||
if (this.failBuildOnCVSS <= 10) {
|
||||
checkForFailure(engine.getDependencies());
|
||||
}
|
||||
if (this.showSummary) {
|
||||
showSummary(engine.getDependencies());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.FINE, "Unable to generate dependency-check report", ex);
|
||||
throw new BuildException("Unable to generate dependency-check report", ex);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.FINE, "An exception occurred; unable to continue task", ex);
|
||||
throw new BuildException("An exception occurred; unable to continue task", ex);
|
||||
}
|
||||
if (this.showSummary) {
|
||||
showSummary(engine.getDependencies());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.FINE, "Unable to generate dependency-check report", ex);
|
||||
throw new BuildException("Unable to generate dependency-check report", ex);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.log(Level.FINE, "An exception occurred; unable to continue task", ex);
|
||||
throw new BuildException("An exception occurred; unable to continue task", ex);
|
||||
}
|
||||
} catch (DatabaseException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Unable to connect to the dependency-check database; analysis has stopped");
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.taskdefs</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* This package includes the Ant task definitions.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
package org.owasp.dependencycheck.taskdefs;
|
||||
|
||||
@@ -26,6 +26,7 @@ The following properties can be set on the dependency-check-maven plugin.
|
||||
Property | Description | Default Value
|
||||
---------------------|------------------------------------|------------------
|
||||
autoUpdate | Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to false. | true
|
||||
updateOnly | If set to true only the update phase of dependency-check will be executed; no scan will be executed and no report will be generated. | false
|
||||
externalReport | When using as a Site plugin this parameter sets whether or not the external report format should be used. | false
|
||||
outputDirectory | The location to write the report(s). Note, this is not used if generating the report as part of a `mvn site` build | 'target'
|
||||
failBuildOnCVSS | Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11 which means since the CVSS scores are 0-10, by default the build will never fail. | 11
|
||||
@@ -53,7 +54,7 @@ zipExtensions | A comma-separated list of additional file extensions t
|
||||
jarAnalyzer | Sets whether the Jar Analyzer will be used. | true
|
||||
centralAnalyzerEnabled | Sets whether the Central Analyzer will be used. **Disabling this analyzer is not recommended as it could lead to false negatives (e.g. libraries that have vulnerabilities may not be reported correctly).** If this analyzer is being disabled there is a good chance you also want to disable the Nexus Analyzer (see below). | true
|
||||
nexusAnalyzerEnabled | Sets whether Nexus Analyzer will be used. This analyzer is superceded by the Central Analyzer; however, you can configure this to run against a Nexus Pro installation. | true
|
||||
nexusUrl | Defines the Nexus Pro URL. If not set the Nexus Analyzer will be disabled. |
|
||||
nexusUrl | Defines the Nexus web service endpoint (example http://domain.enterprise/nexus/service/local/). If not set the Nexus Analyzer will be disabled. |
|
||||
nexusUsesProxy | Whether or not the defined proxy should be used when connecting to Nexus. | true
|
||||
nuspecAnalyzerEnabled | Sets whether or not the .NET Nuget Nuspec Analyzer will be used. | true
|
||||
assemblyAnalyzerEnabled | Sets whether or not the .NET Assembly Analyzer should be used. | true
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
About
|
||||
====================
|
||||
OWASP dependency-check-ant is an Ant Task that uses dependency-check-core to detect publicly
|
||||
disclosed vulnerabilities associated with the project's dependencies. The task will
|
||||
generate a report listing the dependency, any identified Common Platform Enumeration (CPE)
|
||||
identifiers, and the associated Common Vulnerability and Exposure (CVE) entries.
|
||||
|
||||
Installation
|
||||
====================
|
||||
Download dependency-check-ant from [bintray here](http://dl.bintray.com/jeremy-long/owasp/dependency-check-ant-${project.version}.jar).
|
||||
@@ -19,7 +26,7 @@ must add the classpath to the taskdef:
|
||||
```
|
||||
|
||||
It is important to understand that the first time this task is executed it may
|
||||
take 20 minutes or more as it downloads and processes the data from the National
|
||||
take 10 minutes or more as it downloads and processes the data from the National
|
||||
Vulnerability Database (NVD) hosted by NIST: https://nvd.nist.gov
|
||||
|
||||
After the first batch download, as long as the task is executed at least once every
|
||||
@@ -1,6 +1,6 @@
|
||||
Usage
|
||||
====================
|
||||
First, add the dependency-check-ant taskdef to your build.xml (see the [installation guide](installation.html):
|
||||
First, add the dependency-check-ant taskdef to your build.xml (see the [installation guide](installation.html)):
|
||||
|
||||
```xml
|
||||
<taskdef name="dependency-check" classname="org.owasp.dependencycheck.taskdefs.DependencyCheckTask"/>
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 10 KiB |
@@ -18,7 +18,9 @@ Copyright (c) 2013 Jeremy Long. All Rights Reserved.
|
||||
-->
|
||||
<project name="dependency-check-ant">
|
||||
<bannerLeft>
|
||||
<name>dependency-check-ant</name>
|
||||
<name>OWASP dependency-check-ant</name>
|
||||
<alt>OWASP dependency-check-ant</alt>
|
||||
<src>./images/dc-ant.svg</src>
|
||||
</bannerLeft>
|
||||
<body>
|
||||
<breadcrumbs>
|
||||
@@ -29,7 +31,6 @@ Copyright (c) 2013 Jeremy Long. All Rights Reserved.
|
||||
<item name="Usage" href="usage.html"/>
|
||||
<item name="Configuration" href="configuration.html"/>
|
||||
</menu>
|
||||
<menu ref="Project Documentation" />
|
||||
<menu ref="reports" />
|
||||
</body>
|
||||
</project>
|
||||
@@ -27,7 +27,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DependencyCheckTaskTest extends BuildFileTest {
|
||||
//TODO: The use of deprecated class BuildFileTestcan possibly
|
||||
|
||||
@@ -20,7 +20,7 @@ Copyright (c) 2012 - Jeremy Long. All Rights Reserved.
|
||||
<parent>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-parent</artifactId>
|
||||
<version>1.2.9</version>
|
||||
<version>1.2.11</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dependency-check-cli</artifactId>
|
||||
@@ -184,7 +184,6 @@ Copyright (c) 2012 - Jeremy Long. All Rights Reserved.
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>index</report>
|
||||
<report>summary</report>
|
||||
<report>license</report>
|
||||
<report>help</report>
|
||||
@@ -197,6 +196,7 @@ Copyright (c) 2012 - Jeremy Long. All Rights Reserved.
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
<bottom>Copyright© 2012-15 Jeremy Long. All Rights Reserved.</bottom>
|
||||
</configuration>
|
||||
<reportSets>
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* The command line interface for the DependencyCheck application.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class App {
|
||||
|
||||
@@ -95,12 +95,15 @@ public class App {
|
||||
|
||||
if (cli.isGetVersion()) {
|
||||
cli.printVersionInfo();
|
||||
} else if (cli.isUpdateOnly()) {
|
||||
populateSettings(cli);
|
||||
runUpdateOnly();
|
||||
} else if (cli.isRunScan()) {
|
||||
populateSettings(cli);
|
||||
try {
|
||||
runScan(cli.getReportDirectory(), cli.getReportFormat(), cli.getApplicationName(), cli.getScanFiles(), cli.getExcludeList());
|
||||
} catch (InvalidScanPathException ex) {
|
||||
Logger.getLogger(App.class.getName()).log(Level.SEVERE, "An invalid scan path was detected; unable to scan '//*' paths");
|
||||
LOGGER.log(Level.SEVERE, "An invalid scan path was detected; unable to scan '//*' paths");
|
||||
}
|
||||
} else {
|
||||
cli.printHelp();
|
||||
@@ -212,11 +215,29 @@ public class App {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only executes the update phase of dependency-check.
|
||||
*/
|
||||
private void runUpdateOnly() {
|
||||
Engine engine = null;
|
||||
try {
|
||||
engine = new Engine();
|
||||
engine.doUpdates();
|
||||
} catch (DatabaseException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Unable to connect to the dependency-check database; analysis has stopped");
|
||||
LOGGER.log(Level.FINE, "", ex);
|
||||
} finally {
|
||||
if (engine != null) {
|
||||
engine.cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the global Settings.
|
||||
*
|
||||
* @param cli a reference to the CLI Parser that contains the command line arguments used to set the corresponding
|
||||
* settings in the core engine.
|
||||
* @param cli a reference to the CLI Parser that contains the command line arguments used to set the corresponding settings in
|
||||
* the core engine.
|
||||
*/
|
||||
private void populateSettings(CliParser cli) {
|
||||
|
||||
@@ -231,6 +252,8 @@ public class App {
|
||||
final String suppressionFile = cli.getSuppressionFile();
|
||||
final boolean jarDisabled = cli.isJarDisabled();
|
||||
final boolean archiveDisabled = cli.isArchiveDisabled();
|
||||
final boolean pyDistDisabled = cli.isPythonDistributionDisabled();
|
||||
final boolean pyPkgDisabled = cli.isPythonPackageDisabled();
|
||||
final boolean assemblyDisabled = cli.isAssemblyDisabled();
|
||||
final boolean nuspecDisabled = cli.isNuspecDisabled();
|
||||
final boolean centralDisabled = cli.isCentralDisabled();
|
||||
@@ -296,6 +319,8 @@ public class App {
|
||||
//File Type Analyzer Settings
|
||||
Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, !jarDisabled);
|
||||
Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, !archiveDisabled);
|
||||
Settings.setBoolean(Settings.KEYS.ANALYZER_PYTHON_DISTRIBUTION_ENABLED, !pyDistDisabled);
|
||||
Settings.setBoolean(Settings.KEYS.ANALYZER_PYTHON_PACKAGE_ENABLED, !pyPkgDisabled);
|
||||
Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, !nuspecDisabled);
|
||||
Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, !assemblyDisabled);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.owasp.dependencycheck;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
@@ -36,7 +37,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* A utility to parse command line arguments for the DependencyCheck.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class CliParser {
|
||||
|
||||
@@ -266,6 +267,9 @@ public final class CliParser {
|
||||
@SuppressWarnings("static-access")
|
||||
private void addAdvancedOptions(final Options options) throws IllegalArgumentException {
|
||||
|
||||
final Option updateOnly = OptionBuilder.withLongOpt(ARGUMENT.UPDATE_ONLY)
|
||||
.withDescription("Only update the local NVD data cache; no scan will be executed.").create();
|
||||
|
||||
final Option data = OptionBuilder.withArgName("path").hasArg().withLongOpt(ARGUMENT.DATA_DIRECTORY)
|
||||
.withDescription("The location of the H2 Database file. This option should generally not be set.")
|
||||
.create(ARGUMENT.DATA_DIRECTORY_SHORT);
|
||||
@@ -319,10 +323,17 @@ public final class CliParser {
|
||||
final Option disableNuspecAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_NUSPEC)
|
||||
.withDescription("Disable the Nuspec Analyzer.")
|
||||
.create();
|
||||
|
||||
final Option disableAssemblyAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_ASSEMBLY)
|
||||
.withDescription("Disable the .NET Assembly Analyzer.")
|
||||
.create();
|
||||
|
||||
final Option disablePythonDistributionAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_PY_DIST)
|
||||
.withDescription("Disable the Python Distribution Analyzer.").create();
|
||||
|
||||
final Option disablePythonPackageAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_PY_PKG)
|
||||
.withDescription("Disable the Python Package Analyzer.").create();
|
||||
|
||||
final Option disableCentralAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_CENTRAL)
|
||||
.withDescription("Disable the Central Analyzer. If this analyzer is disabled it is likely you also want to disable "
|
||||
+ "the Nexus Analyzer.")
|
||||
@@ -333,7 +344,8 @@ public final class CliParser {
|
||||
.create();
|
||||
|
||||
final Option nexusUrl = OptionBuilder.withArgName("url").hasArg().withLongOpt(ARGUMENT.NEXUS_URL)
|
||||
.withDescription("The url to the Nexus Pro Server. If not set the Nexus Analyzer will be disabled.")
|
||||
.withDescription("The url to the Nexus Server's REST API Endpoint (http://domain/nexus/service/local). "
|
||||
+ "If not set the Nexus Analyzer will be disabled.")
|
||||
.create();
|
||||
|
||||
final Option nexusUsesProxy = OptionBuilder.withArgName("true/false").hasArg().withLongOpt(ARGUMENT.NEXUS_USES_PROXY)
|
||||
@@ -350,7 +362,8 @@ public final class CliParser {
|
||||
.withDescription("The path to Mono for .NET Assembly analysis on non-windows systems.")
|
||||
.create();
|
||||
|
||||
options.addOption(proxyPort)
|
||||
options.addOption(updateOnly)
|
||||
.addOption(proxyPort)
|
||||
.addOption(proxyServer)
|
||||
.addOption(proxyUsername)
|
||||
.addOption(proxyPassword)
|
||||
@@ -364,6 +377,8 @@ public final class CliParser {
|
||||
.addOption(disableJarAnalyzer)
|
||||
.addOption(disableArchiveAnalyzer)
|
||||
.addOption(disableAssemblyAnalyzer)
|
||||
.addOption(disablePythonDistributionAnalyzer)
|
||||
.addOption(disablePythonPackageAnalyzer)
|
||||
.addOption(disableNuspecAnalyzer)
|
||||
.addOption(disableCentralAnalyzer)
|
||||
.addOption(disableNexusAnalyzer)
|
||||
@@ -453,6 +468,24 @@ public final class CliParser {
|
||||
return (line != null) && line.hasOption(ARGUMENT.DISABLE_ASSEMBLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the disablePyDist command line argument was specified.
|
||||
*
|
||||
* @return true if the disablePyDist command line argument was specified; otherwise false
|
||||
*/
|
||||
public boolean isPythonDistributionDisabled() {
|
||||
return (line != null) && line.hasOption(ARGUMENT.DISABLE_PY_DIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the disablePyPkg command line argument was specified.
|
||||
*
|
||||
* @return true if the disablePyPkg command line argument was specified; otherwise false
|
||||
*/
|
||||
public boolean isPythonPackageDisabled() {
|
||||
return (line != null) && line.hasOption(ARGUMENT.DISABLE_PY_PKG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the disableNexus command line argument was specified.
|
||||
*
|
||||
@@ -689,12 +722,21 @@ public final class CliParser {
|
||||
/**
|
||||
* Checks if the auto update feature has been disabled. If it has been disabled via the command line this will return false.
|
||||
*
|
||||
* @return if auto-update is allowed.
|
||||
* @return <code>true</code> if auto-update is allowed; otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isAutoUpdate() {
|
||||
return (line == null) || !line.hasOption(ARGUMENT.DISABLE_AUTO_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the update only flag has been set.
|
||||
*
|
||||
* @return <code>true</code> if the update only flag has been set; otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean isUpdateOnly() {
|
||||
return (line == null) || line.hasOption(ARGUMENT.UPDATE_ONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database driver name if specified; otherwise null is returned.
|
||||
*
|
||||
@@ -770,6 +812,10 @@ public final class CliParser {
|
||||
* The short CLI argument name specifying that the CPE/CVE/etc. data should not be automatically updated.
|
||||
*/
|
||||
public static final String DISABLE_AUTO_UPDATE_SHORT = "n";
|
||||
/**
|
||||
* The long CLI argument name specifying that only the update phase should be executed; no scan should be run.
|
||||
*/
|
||||
public static final String UPDATE_ONLY = "updateonly";
|
||||
/**
|
||||
* The long CLI argument name specifying the directory to write the reports to.
|
||||
*/
|
||||
@@ -881,6 +927,14 @@ public final class CliParser {
|
||||
* Disables the Archive Analyzer.
|
||||
*/
|
||||
public static final String DISABLE_ARCHIVE = "disableArchive";
|
||||
/**
|
||||
* Disables the Python Distribution Analyzer.
|
||||
*/
|
||||
public static final String DISABLE_PY_DIST = "disablePyDist";
|
||||
/**
|
||||
* Disables the Python Package Analyzer.
|
||||
*/
|
||||
public static final String DISABLE_PY_PKG = "disablePyPkg";
|
||||
/**
|
||||
* Disables the Assembly Analyzer.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck;
|
||||
/**
|
||||
* Thrown if an invalid path is encountered.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
class InvalidScanPathException extends Exception {
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* Includes the main entry point for the DependencyChecker.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
|
||||
*/
|
||||
package org.owasp.dependencycheck;
|
||||
|
||||
@@ -19,27 +19,30 @@ Short | Argument Name | Parameter | Description | Requir
|
||||
|
||||
Advanced Options
|
||||
================
|
||||
Short | Argument Name | Parameter | Description | Default Value
|
||||
-------|-----------------------|-----------------|-----------------------------------------------------------------------------|---------------
|
||||
Short | Argument Name | Parameter | Description | Default Value
|
||||
-------|-----------------------|-----------------|----------------------------------------------------------------------------------|-------------------
|
||||
\-P | \-\-propertyfile | \<file\> | Specifies a file that contains properties to use instead of applicaion defaults. |
|
||||
| \-\-disableArchive | | Sets whether the Archive Analyzer will be used. | false
|
||||
| \-\-updateonly | | If set only the update phase of dependency-check will be executed; no scan will be executed and no report will be generated. |
|
||||
| \-\-disablePyDist | | Sets whether the Python Distribution Analyzer will be used. | false
|
||||
| \-\-disablePyPkg | | Sets whether the Python Package Analyzer will be used. | false
|
||||
| \-\-disableArchive | | Sets whether the Archive Analyzer will be used. | false
|
||||
| \-\-zipExtensions | \<strings\> | A comma-separated list of additional file extensions to be treated like a ZIP file, the contents will be extracted and analyzed. |
|
||||
| \-\-disableJar | | Sets whether the Jar Analyzer will be used. | false
|
||||
| \-\-disableJar | | Sets whether the Jar Analyzer will be used. | false
|
||||
| \-\-disableCentral | | Sets whether the Central Analyzer will be used. **Disabling this analyzer is not recommended as it could lead to false negatives (e.g. libraries that have vulnerabilities may not be reported correctly).** If this analyzer is being disabled there is a good chance you also want to disable the Nexus Analyzer. | false
|
||||
| \-\-disableNexus | | Sets whether the Nexus Analyzer will be used. Note, this has been superceded by the Central Analyzer. However, you can configure the Nexus URL to utilize an internally hosted Nexus Pro server. | false
|
||||
| \-\-nexus | \<url\> | The url to the Nexus Pro Server. If not set the Nexus Analyzer will be disabled. |
|
||||
| \-\-nexusUsesProxy | \<true\|false\> | Whether or not the defined proxy should be used when connecting to Nexus. | true
|
||||
| \-\-disableNuspec | | Sets whether or not the .NET Nuget Nuspec Analyzer will be used. | false
|
||||
| \-\-disableAssembly | | Sets whether or not the .NET Assembly Analyzer should be used. | false
|
||||
| \-\-pathToMono | \<path\> | The path to Mono for .NET Assembly analysis on non-windows systems. |
|
||||
| \-\-proxyserver | \<server\> | The proxy server to use when downloading resources. |
|
||||
| \-\-proxyport | \<port\> | The proxy port to use when downloading resources. |
|
||||
| \-\-connectiontimeout | \<timeout\> | The connection timeout (in milliseconds) to use when downloading resources. |
|
||||
| \-\-proxypass | \<pass\> | The proxy password to use when downloading resources. |
|
||||
| \-\-proxyuser | \<user\> | The proxy username to use when downloading resources. |
|
||||
| \-\-connectionString | \<connStr\> | The connection string to the database. |
|
||||
| \-\-dbDriverName | \<driver\> | The database driver name. |
|
||||
| \-\-nexus | \<url\> | The url to the Nexus Server's web service end point (example: http://domain.enterprise/nexus/service/local/). If not set the Nexus Analyzer will be disabled. |
|
||||
| \-\-nexusUsesProxy | \<true\|false\> | Whether or not the defined proxy should be used when connecting to Nexus. | true
|
||||
| \-\-disableNuspec | | Sets whether or not the .NET Nuget Nuspec Analyzer will be used. | false
|
||||
| \-\-disableAssembly | | Sets whether or not the .NET Assembly Analyzer should be used. | false
|
||||
| \-\-pathToMono | \<path\> | The path to Mono for .NET Assembly analysis on non-windows systems. |
|
||||
| \-\-proxyserver | \<server\> | The proxy server to use when downloading resources. |
|
||||
| \-\-proxyport | \<port\> | The proxy port to use when downloading resources. |
|
||||
| \-\-connectiontimeout | \<timeout\> | The connection timeout (in milliseconds) to use when downloading resources. |
|
||||
| \-\-proxypass | \<pass\> | The proxy password to use when downloading resources. |
|
||||
| \-\-proxyuser | \<user\> | The proxy username to use when downloading resources. |
|
||||
| \-\-connectionString | \<connStr\> | The connection string to the database. |
|
||||
| \-\-dbDriverName | \<driver\> | The database driver name. |
|
||||
| \-\-dbDriverPath | \<path\> | The path to the database driver; note, this does not need to be set unless the JAR is outside of the class path. |
|
||||
| \-\-dbPassword | \<password\> | The password for connecting to the database. |
|
||||
| \-\-dbUser | \<user\> | The username used to connect to the database. |
|
||||
| \-\-dbPassword | \<password\> | The password for connecting to the database. |
|
||||
| \-\-dbUser | \<user\> | The username used to connect to the database. |
|
||||
\-d | \-\-data | \<path\> | The location of the data directory used to store persistent data. This option should generally not be set. |
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
About
|
||||
====================
|
||||
OWASP dependency-check-cli is an command line tool that uses dependency-check-core to detect
|
||||
publicly disclosed vulnerabilities associated with the scanned project dependencies. The tool
|
||||
will generate a report listing the dependency, any identified Common Platform Enumeration (CPE)
|
||||
identifiers, and the associated Common Vulnerability and Exposure (CVE) entries.
|
||||
|
||||
Installation & Usage
|
||||
====================
|
||||
Download the dependency-check command line tool [here](http://dl.bintray.com/jeremy-long/owasp/dependency-check-${project.version}-release.zip).
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 10 KiB |
@@ -18,17 +18,18 @@ Copyright (c) 2013 Jeremy Long. All Rights Reserved.
|
||||
-->
|
||||
<project name="dependency-check-cli">
|
||||
<bannerLeft>
|
||||
<name>dependency-check-cli</name>
|
||||
<name>OWASP dependency-check-cli</name>
|
||||
<alt>OWASP dependency-check-cli</alt>
|
||||
<src>./images/dc-cli.svg</src>
|
||||
</bannerLeft>
|
||||
<body>
|
||||
<breadcrumbs>
|
||||
<item name="dependency-check" href="../index.html"/>
|
||||
</breadcrumbs>
|
||||
<menu name="Getting Started">
|
||||
<item name="Installation" href="installation.html"/>
|
||||
<item name="Installation" href="index.html"/>
|
||||
<item name="Configuration" href="arguments.html"/>
|
||||
</menu>
|
||||
<menu ref="Project Documentation" />
|
||||
<menu ref="reports" />
|
||||
</body>
|
||||
</project>
|
||||
@@ -34,7 +34,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class CliParserTest {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
|
||||
<parent>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-parent</artifactId>
|
||||
<version>1.2.9</version>
|
||||
<version>1.2.11</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dependency-check-core</artifactId>
|
||||
@@ -219,11 +219,26 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>summary</report>
|
||||
<report>license</report>
|
||||
<report>help</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
<bottom>Copyright© 2012-15 Jeremy Long. All Rights Reserved.</bottom>
|
||||
</configuration>
|
||||
<reportSets>
|
||||
@@ -519,6 +534,18 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.ltd.getahead</groupId>
|
||||
<artifactId>dwr</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>mailapi</artifactId>
|
||||
<version>1.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
@@ -677,6 +704,65 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gerrit</groupId>
|
||||
<artifactId>gerrit-extension-api</artifactId>
|
||||
<version>2.11</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-sqladmin</artifactId>
|
||||
<version>v1beta4-rev5-1.20.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt.google-apis</groupId>
|
||||
<artifactId>gwt-gears</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mozilla</groupId>
|
||||
<artifactId>rhino</artifactId>
|
||||
<version>1.7.6</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.microsoft.windowsazure</groupId>
|
||||
<artifactId>microsoft-azure-api-media</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.windowsazure</groupId>
|
||||
<artifactId>microsoft-azure-api-management-sql</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.bingads</groupId>
|
||||
<artifactId>microsoft.bingads</artifactId>
|
||||
<version>9.3.4</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
@@ -44,11 +44,10 @@ import org.owasp.dependencycheck.utils.InvalidSettingException;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
|
||||
/**
|
||||
* Scans files, directories, etc. for Dependencies. Analyzers are loaded and used to process the files found by the
|
||||
* scan, if a file is encountered and an Analyzer is associated with the file type then the file is turned into a
|
||||
* dependency.
|
||||
* Scans files, directories, etc. for Dependencies. Analyzers are loaded and used to process the files found by the scan, if a
|
||||
* file is encountered and an Analyzer is associated with the file type then the file is turned into a dependency.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class Engine {
|
||||
|
||||
@@ -163,8 +162,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any
|
||||
* dependencies identified are added to the dependency collection.
|
||||
* Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any dependencies
|
||||
* identified are added to the dependency collection.
|
||||
*
|
||||
* @param paths an array of paths to files or directories to be analyzed
|
||||
* @return the list of dependencies scanned
|
||||
@@ -184,8 +183,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies
|
||||
* identified are added to the dependency collection.
|
||||
* Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies identified
|
||||
* are added to the dependency collection.
|
||||
*
|
||||
* @param path the path to a file or directory to be analyzed
|
||||
* @return the list of dependencies scanned
|
||||
@@ -196,8 +195,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any
|
||||
* dependencies identified are added to the dependency collection.
|
||||
* Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any dependencies
|
||||
* identified are added to the dependency collection.
|
||||
*
|
||||
* @param files an array of paths to files or directories to be analyzed.
|
||||
* @return the list of dependencies
|
||||
@@ -216,8 +215,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any
|
||||
* dependencies identified are added to the dependency collection.
|
||||
* Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any dependencies
|
||||
* identified are added to the dependency collection.
|
||||
*
|
||||
* @param files a set of paths to files or directories to be analyzed
|
||||
* @return the list of dependencies scanned
|
||||
@@ -236,8 +235,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any
|
||||
* dependencies identified are added to the dependency collection.
|
||||
* Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any dependencies
|
||||
* identified are added to the dependency collection.
|
||||
*
|
||||
* @param files a set of paths to files or directories to be analyzed
|
||||
* @return the list of dependencies scanned
|
||||
@@ -256,8 +255,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies
|
||||
* identified are added to the dependency collection.
|
||||
* Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies identified
|
||||
* are added to the dependency collection.
|
||||
*
|
||||
* @param file the path to a file or directory to be analyzed
|
||||
* @return the list of dependencies scanned
|
||||
@@ -319,16 +318,17 @@ public class Engine {
|
||||
return null;
|
||||
}
|
||||
final String fileName = file.getName();
|
||||
final String extension = FileUtils.getFileExtension(fileName);
|
||||
String extension = FileUtils.getFileExtension(fileName);
|
||||
if (null == extension) {
|
||||
extension = fileName;
|
||||
}
|
||||
Dependency dependency = null;
|
||||
if (extension != null) {
|
||||
if (supportsExtension(extension)) {
|
||||
dependency = new Dependency(file);
|
||||
dependencies.add(dependency);
|
||||
if (supportsExtension(extension)) {
|
||||
dependency = new Dependency(file);
|
||||
if (extension == null ? fileName == null : extension.equals(fileName)) {
|
||||
dependency.setFileExtension(extension);
|
||||
}
|
||||
} else {
|
||||
final String msg = String.format("No file extension found on file '%s'. The file was not analyzed.", file.toString());
|
||||
LOGGER.log(Level.FINE, msg);
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
return dependency;
|
||||
}
|
||||
@@ -468,7 +468,7 @@ public class Engine {
|
||||
/**
|
||||
* Cycles through the cached web data sources and calls update on all of them.
|
||||
*/
|
||||
private void doUpdates() {
|
||||
public void doUpdates() {
|
||||
LOGGER.info("Checking for updates");
|
||||
final UpdateService service = new UpdateService(serviceClassLoader);
|
||||
final Iterator<CachedWebDataSource> iterator = service.getDataSources();
|
||||
|
||||
@@ -34,10 +34,10 @@ import org.owasp.dependencycheck.reporting.ReportGenerator;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
|
||||
/**
|
||||
* This class provides a way to easily conduct a scan solely based on existing evidence metadata rather than collecting
|
||||
* evidence from the files themselves. This class is based on the Ant task and Maven plugin with the exception that it
|
||||
* takes a list of dependencies that can be programmatically added from data in a spreadsheet, database or some other
|
||||
* datasource and conduct a scan based on this pre-defined evidence.
|
||||
* This class provides a way to easily conduct a scan solely based on existing evidence metadata rather than collecting evidence
|
||||
* from the files themselves. This class is based on the Ant task and Maven plugin with the exception that it takes a list of
|
||||
* dependencies that can be programmatically added from data in a spreadsheet, database or some other datasource and conduct a
|
||||
* scan based on this pre-defined evidence.
|
||||
*
|
||||
* <h2>Example:</h2>
|
||||
* <pre>
|
||||
@@ -161,9 +161,9 @@ public class DependencyCheckScanAgent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11
|
||||
* which means since the CVSS scores are 0-10, by default the build will never fail and the CVSS score is set to 11.
|
||||
* The valid range for the fail build on CVSS is 0 to 11, where anything above 10 will not cause the build to fail.
|
||||
* Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11 which
|
||||
* means since the CVSS scores are 0-10, by default the build will never fail and the CVSS score is set to 11. The valid range
|
||||
* for the fail build on CVSS is 0 to 11, where anything above 10 will not cause the build to fail.
|
||||
*/
|
||||
private float failBuildOnCVSS = 11;
|
||||
|
||||
@@ -186,8 +186,8 @@ public class DependencyCheckScanAgent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to
|
||||
* false. Default is true.
|
||||
* Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to false. Default
|
||||
* is true.
|
||||
*/
|
||||
private boolean autoUpdate = true;
|
||||
|
||||
@@ -210,8 +210,31 @@ public class DependencyCheckScanAgent {
|
||||
}
|
||||
|
||||
/**
|
||||
* The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this
|
||||
* within the Site plugin unless the externalReport is set to true. Default is HTML.
|
||||
* flag indicating whether or not to generate a report of findings.
|
||||
*/
|
||||
private boolean generateReport = true;
|
||||
|
||||
/**
|
||||
* Get the value of generateReport.
|
||||
*
|
||||
* @return the value of generateReport
|
||||
*/
|
||||
public boolean isGenerateReport() {
|
||||
return generateReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of generateReport.
|
||||
*
|
||||
* @param generateReport new value of generateReport
|
||||
*/
|
||||
public void setGenerateReport(boolean generateReport) {
|
||||
this.generateReport = generateReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this within the
|
||||
* Site plugin unless the externalReport is set to true. Default is HTML.
|
||||
*/
|
||||
private ReportGenerator.Format reportFormat = ReportGenerator.Format.HTML;
|
||||
|
||||
@@ -671,8 +694,8 @@ public class DependencyCheckScanAgent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional ZIP File extensions to add analyze. This should be a comma-separated list of file extensions to treat
|
||||
* like ZIP files.
|
||||
* Additional ZIP File extensions to add analyze. This should be a comma-separated list of file extensions to treat like ZIP
|
||||
* files.
|
||||
*/
|
||||
private String zipExtensions;
|
||||
|
||||
@@ -813,8 +836,7 @@ public class DependencyCheckScanAgent {
|
||||
* Executes the Dependency-Check on the dependent libraries.
|
||||
*
|
||||
* @return the Engine used to scan the dependencies.
|
||||
* @throws org.owasp.dependencycheck.data.nvdcve.DatabaseException thrown if there is an exception connecting to the
|
||||
* database
|
||||
* @throws org.owasp.dependencycheck.data.nvdcve.DatabaseException thrown if there is an exception connecting to the database
|
||||
*/
|
||||
private Engine executeDependencyCheck() throws DatabaseException {
|
||||
populateSettings();
|
||||
@@ -860,8 +882,8 @@ public class DependencyCheckScanAgent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system
|
||||
* properties required to change the proxy server, port, and connection timeout.
|
||||
* Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system properties
|
||||
* required to change the proxy server, port, and connection timeout.
|
||||
*/
|
||||
private void populateSettings() {
|
||||
Settings.initialize();
|
||||
@@ -942,14 +964,16 @@ public class DependencyCheckScanAgent {
|
||||
/**
|
||||
* Executes the dependency-check and generates the report.
|
||||
*
|
||||
* @throws org.owasp.dependencycheck.exception.ScanAgentException thrown if there is an exception executing the
|
||||
* scan.
|
||||
* @return a reference to the engine used to perform the scan.
|
||||
* @throws org.owasp.dependencycheck.exception.ScanAgentException thrown if there is an exception executing the scan.
|
||||
*/
|
||||
public void execute() throws ScanAgentException {
|
||||
public Engine execute() throws ScanAgentException {
|
||||
Engine engine = null;
|
||||
try {
|
||||
engine = executeDependencyCheck();
|
||||
generateExternalReports(engine, new File(this.reportOutputDirectory));
|
||||
if (this.generateReport) {
|
||||
generateExternalReports(engine, new File(this.reportOutputDirectory));
|
||||
}
|
||||
if (this.showSummary) {
|
||||
showSummary(engine.getDependencies());
|
||||
}
|
||||
@@ -966,6 +990,7 @@ public class DependencyCheckScanAgent {
|
||||
engine.cleanup();
|
||||
}
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -973,8 +998,7 @@ public class DependencyCheckScanAgent {
|
||||
* configuration.
|
||||
*
|
||||
* @param dependencies the list of dependency objects
|
||||
* @throws org.owasp.dependencycheck.exception.ScanAgentException thrown if there is an exception executing the
|
||||
* scan.
|
||||
* @throws org.owasp.dependencycheck.exception.ScanAgentException thrown if there is an exception executing the scan.
|
||||
*/
|
||||
private void checkForFailure(List<Dependency> dependencies) throws ScanAgentException {
|
||||
final StringBuilder ids = new StringBuilder();
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.agent</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* The agent package holds an agent API that can be used by other applications that have information about dependencies;
|
||||
* but would rather implement something in their code directly rather then spawn a process to run the entire
|
||||
* dependency-check engine. This basically provides programmatic access to running a scan.
|
||||
* </body>
|
||||
* </html>
|
||||
* The agent package holds an agent API that can be used by other applications that have information about dependencies; but would
|
||||
* rather implement something in their code directly rather then spawn a process to run the entire dependency-check engine. This
|
||||
* basically provides programmatic access to running a scan.
|
||||
*/
|
||||
package org.owasp.dependencycheck.agent;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public abstract class AbstractAnalyzer implements Analyzer {
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* The base FileTypeAnalyzer that all analyzers that have specific file types they analyze should extend.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public abstract class AbstractFileTypeAnalyzer extends AbstractAnalyzer implements FileTypeAnalyzer {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* Abstract base suppression analyzer that contains methods for parsing the suppression xml file.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.analyzer;
|
||||
/**
|
||||
* An enumeration defining the phases of analysis.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public enum AnalysisPhase {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.owasp.dependencycheck.dependency.Dependency;
|
||||
* An interface that defines an Analyzer that is used to identify Dependencies. An analyzer will collect information
|
||||
* about the dependency in the form of Evidence.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public interface Analyzer {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.ServiceLoader;
|
||||
* The Analyzer Service Loader. This class loads all services that implement
|
||||
* org.owasp.dependencycheck.analyzer.Analyzer.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class AnalyzerService {
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
* An analyzer that extracts files from archives and ensures any supported files contained within the archive are added
|
||||
* to the dependency list.</p>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.owasp.dependencycheck.utils.DependencyVersionUtil;
|
||||
* CPEAnalyzer is a utility class that takes a project dependency and attempts to discern if there is an associated CPE. It uses
|
||||
* the evidence contained within the dependency to search the Lucene index.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class CPEAnalyzer implements Analyzer {
|
||||
|
||||
@@ -160,6 +160,10 @@ public class CPEAnalyzer implements Analyzer {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return cpe != null && cpe.isOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the data store of CPE entries, trying to identify the CPE for the given dependency based on the evidence contained
|
||||
* within. The dependency passed in is updated with any identified CPE values.
|
||||
@@ -418,17 +422,6 @@ public class CPEAnalyzer implements Analyzer {
|
||||
* @return whether or not the EvidenceCollection contains the string
|
||||
*/
|
||||
private boolean collectionContainsString(EvidenceCollection ec, String text) {
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="This code fold contains an old version of the code, delete once more testing is done">
|
||||
// String[] splitText = text.split("[\\s_-]");
|
||||
//
|
||||
// for (String search : splitText) {
|
||||
// //final String search = text.replaceAll("[\\s_-]", "").toLowerCase();
|
||||
// if (ec.containsUsedString(search)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//</editor-fold>
|
||||
//TODO - likely need to change the split... not sure if this will work for CPE with special chars
|
||||
if (text == null) {
|
||||
return false;
|
||||
@@ -450,9 +443,16 @@ public class CPEAnalyzer implements Analyzer {
|
||||
list.add(word);
|
||||
}
|
||||
}
|
||||
if (tempWord != null && !list.isEmpty()) {
|
||||
final String tmp = list.get(list.size() - 1) + tempWord;
|
||||
list.add(tmp);
|
||||
if (tempWord != null) {
|
||||
if (!list.isEmpty()) {
|
||||
final String tmp = list.get(list.size() - 1) + tempWord;
|
||||
list.add(tmp);
|
||||
} else {
|
||||
list.add(tempWord);
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean contains = true;
|
||||
for (String word : list) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.owasp.dependencycheck.data.nexus.MavenArtifact;
|
||||
import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.Evidence;
|
||||
import org.owasp.dependencycheck.jaxb.pom.PomUtils;
|
||||
import org.owasp.dependencycheck.xml.pom.PomUtils;
|
||||
import org.owasp.dependencycheck.utils.DownloadFailedException;
|
||||
import org.owasp.dependencycheck.utils.Downloader;
|
||||
import org.owasp.dependencycheck.utils.InvalidSettingException;
|
||||
@@ -76,10 +76,6 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
* The searcher itself.
|
||||
*/
|
||||
private CentralSearch searcher;
|
||||
/**
|
||||
* Utility to read POM files.
|
||||
*/
|
||||
private PomUtils pomUtil = new PomUtils();
|
||||
/**
|
||||
* Field indicating if the analyzer is enabled.
|
||||
*/
|
||||
@@ -216,7 +212,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
LOGGER.fine(String.format("Downloading %s", ma.getPomUrl()));
|
||||
Downloader.fetchFile(new URL(ma.getPomUrl()), pomFile);
|
||||
pomUtil.analyzePOM(dependency, pomFile);
|
||||
PomUtils.analyzePOM(dependency, pomFile);
|
||||
|
||||
} catch (DownloadFailedException ex) {
|
||||
final String msg = String.format("Unable to download pom.xml for %s from Central; "
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.owasp.dependencycheck.suppression.SuppressionRule;
|
||||
* The suppression analyzer processes an externally defined XML document that complies with the suppressions.xsd schema.
|
||||
* Any identified CPE entries within the dependencies that match will be removed.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class CpeSuppressionAnalyzer extends AbstractSuppressionAnalyzer {
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.owasp.dependencycheck.utils.LogUtils;
|
||||
* <p>
|
||||
* Note, this grouping only works on dependencies with identified CVE entries</p>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Analyzer {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.owasp.dependencycheck.dependency.VulnerableSoftware;
|
||||
/**
|
||||
* This analyzer attempts to remove some well known false positives - specifically regarding the java runtime.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class FalsePositiveAnalyzer extends AbstractAnalyzer {
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.owasp.dependencycheck.utils.DependencyVersionUtil;
|
||||
*
|
||||
* Takes a dependency and analyzes the filename and determines the hashes.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class FileNameAnalyzer extends AbstractAnalyzer implements Analyzer {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.analyzer;
|
||||
/**
|
||||
* An Analyzer that scans specific file types.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public interface FileTypeAnalyzer extends Analyzer {
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.owasp.dependencycheck.dependency.Evidence;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class HintAnalyzer extends AbstractAnalyzer implements Analyzer {
|
||||
|
||||
|
||||
@@ -19,15 +19,12 @@ package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
@@ -46,26 +43,22 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.owasp.dependencycheck.Engine;
|
||||
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
|
||||
import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.EvidenceCollection;
|
||||
import org.owasp.dependencycheck.jaxb.pom.PomUtils;
|
||||
import org.owasp.dependencycheck.jaxb.pom.generated.License;
|
||||
import org.owasp.dependencycheck.jaxb.pom.generated.Model;
|
||||
import org.owasp.dependencycheck.jaxb.pom.generated.Organization;
|
||||
import org.owasp.dependencycheck.xml.pom.License;
|
||||
import org.owasp.dependencycheck.xml.pom.PomUtils;
|
||||
import org.owasp.dependencycheck.xml.pom.Model;
|
||||
import org.owasp.dependencycheck.utils.FileUtils;
|
||||
import org.owasp.dependencycheck.utils.NonClosingStream;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* Used to load a JAR file and collect information that can be used to determine the associated CPE.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
|
||||
@@ -149,17 +142,11 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
*/
|
||||
private static final Pattern HTML_DETECTION_PATTERN = Pattern.compile("\\<[a-z]+.*/?\\>", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* The POM Utility for parsing POM files.
|
||||
*/
|
||||
private PomUtils pomUtils = null;
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Constructs a new JarAnalyzer.
|
||||
*/
|
||||
public JarAnalyzer() {
|
||||
pomUtils = new PomUtils();
|
||||
}
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="All standard implmentation details of Analyzer">
|
||||
@@ -289,6 +276,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
}
|
||||
for (String path : pomEntries) {
|
||||
LOGGER.fine(String.format("Reading pom entry: %s", path));
|
||||
Properties pomProperties = null;
|
||||
try {
|
||||
if (externalPom == null) {
|
||||
@@ -315,16 +303,18 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
|
||||
newDependency.setFileName(displayName);
|
||||
newDependency.setFilePath(displayPath);
|
||||
setPomEvidence(newDependency, pom, pomProperties, null);
|
||||
pom.processProperties(pomProperties);
|
||||
setPomEvidence(newDependency, pom, null);
|
||||
engine.getDependencies().add(newDependency);
|
||||
Collections.sort(engine.getDependencies());
|
||||
} else {
|
||||
if (externalPom == null) {
|
||||
pom = retrievePom(path, jar);
|
||||
pom = PomUtils.readPom(path, jar);
|
||||
} else {
|
||||
pom = pomUtils.readPom(externalPom);
|
||||
pom = PomUtils.readPom(externalPom);
|
||||
}
|
||||
foundSomething |= setPomEvidence(dependency, pom, pomProperties, classes);
|
||||
pom.processProperties(pomProperties);
|
||||
foundSomething |= setPomEvidence(dependency, pom, classes);
|
||||
}
|
||||
} catch (AnalysisException ex) {
|
||||
final String msg = String.format("An error occured while analyzing '%s'.", dependency.getActualFilePath());
|
||||
@@ -353,6 +343,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
reader = new InputStreamReader(jar.getInputStream(propEntry), "UTF-8");
|
||||
pomProperties = new Properties();
|
||||
pomProperties.load(reader);
|
||||
LOGGER.fine(String.format("Read pom.properties: %s", propPath));
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
@@ -380,6 +371,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
final JarEntry entry = entries.nextElement();
|
||||
final String entryName = (new File(entry.getName())).getName().toLowerCase();
|
||||
if (!entry.isDirectory() && "pom.xml".equals(entryName)) {
|
||||
LOGGER.fine(String.format("POM Entry found: %s", entry.getName()));
|
||||
pomEntries.add(entry.getName());
|
||||
}
|
||||
}
|
||||
@@ -423,33 +415,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
closeStream(fos);
|
||||
closeStream(input);
|
||||
}
|
||||
Model model = null;
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
final InputStreamReader reader = new InputStreamReader(fis, "UTF-8");
|
||||
final InputSource xml = new InputSource(reader);
|
||||
final SAXSource source = new SAXSource(xml);
|
||||
model = pomUtils.readPom(source);
|
||||
} catch (FileNotFoundException ex) {
|
||||
final String msg = String.format("Unable to parse pom '%s' in jar '%s' (File Not Found)", path, jar.getName());
|
||||
LOGGER.log(Level.WARNING, msg);
|
||||
LOGGER.log(Level.FINE, "", ex);
|
||||
throw new AnalysisException(ex);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
final String msg = String.format("Unable to parse pom '%s' in jar '%s' (IO Exception)", path, jar.getName());
|
||||
LOGGER.log(Level.WARNING, msg);
|
||||
LOGGER.log(Level.FINE, "", ex);
|
||||
throw new AnalysisException(ex);
|
||||
} catch (AnalysisException ex) {
|
||||
final String msg = String.format("Unable to parse pom '%s' in jar '%s'", path, jar.getName());
|
||||
LOGGER.log(Level.WARNING, msg);
|
||||
LOGGER.log(Level.FINE, "", ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
closeStream(fis);
|
||||
}
|
||||
return model;
|
||||
return PomUtils.readPom(file);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,71 +448,55 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the specified POM from a jar file and converts it to a Model.
|
||||
*
|
||||
* @param path the path to the pom.xml file within the jar file
|
||||
* @param jar the jar file to extract the pom from
|
||||
* @return returns a
|
||||
* @throws AnalysisException is thrown if there is an exception extracting or parsing the POM
|
||||
* {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object
|
||||
*/
|
||||
private Model retrievePom(String path, JarFile jar) throws AnalysisException {
|
||||
final ZipEntry entry = jar.getEntry(path);
|
||||
Model model = null;
|
||||
if (entry != null) { //should never be null
|
||||
try {
|
||||
final NonClosingStream stream = new NonClosingStream(jar.getInputStream(entry));
|
||||
final InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
|
||||
final InputSource xml = new InputSource(reader);
|
||||
final SAXSource source = new SAXSource(xml);
|
||||
model = pomUtils.readPom(source);
|
||||
} catch (SecurityException ex) {
|
||||
final String msg = String.format("Unable to parse pom '%s' in jar '%s'; invalid signature", path, jar.getName());
|
||||
LOGGER.log(Level.WARNING, msg);
|
||||
LOGGER.log(Level.FINE, null, ex);
|
||||
throw new AnalysisException(ex);
|
||||
} catch (IOException ex) {
|
||||
final String msg = String.format("Unable to parse pom '%s' in jar '%s' (IO Exception)", path, jar.getName());
|
||||
LOGGER.log(Level.WARNING, msg);
|
||||
LOGGER.log(Level.FINE, "", ex);
|
||||
throw new AnalysisException(ex);
|
||||
} catch (Throwable ex) {
|
||||
final String msg = String.format("Unexpected error during parsing of the pom '%s' in jar '%s'", path, jar.getName());
|
||||
LOGGER.log(Level.WARNING, msg);
|
||||
LOGGER.log(Level.FINE, "", ex);
|
||||
throw new AnalysisException(ex);
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets evidence from the pom on the supplied dependency.
|
||||
*
|
||||
* @param dependency the dependency to set data on
|
||||
* @param pom the information from the pom
|
||||
* @param pomProperties the pom properties file (null if none exists)
|
||||
* @param classes a collection of ClassNameInformation - containing data about the fully qualified class names within the JAR
|
||||
* file being analyzed
|
||||
* @return true if there was evidence within the pom that we could use; otherwise false
|
||||
*/
|
||||
private boolean setPomEvidence(Dependency dependency, Model pom, Properties pomProperties, List<ClassNameInformation> classes) {
|
||||
public static boolean setPomEvidence(Dependency dependency, Model pom, List<ClassNameInformation> classes) {
|
||||
boolean foundSomething = false;
|
||||
boolean addAsIdentifier = true;
|
||||
if (pom == null) {
|
||||
return foundSomething;
|
||||
}
|
||||
String groupid = interpolateString(pom.getGroupId(), pomProperties);
|
||||
String parentGroupId = null;
|
||||
String groupid = pom.getGroupId();
|
||||
String parentGroupId = pom.getParentGroupId();
|
||||
String artifactid = pom.getArtifactId();
|
||||
String parentArtifactId = pom.getParentArtifactId();
|
||||
String version = pom.getVersion();
|
||||
String parentVersion = pom.getParentVersion();
|
||||
|
||||
if (pom.getParent() != null) {
|
||||
parentGroupId = interpolateString(pom.getParent().getGroupId(), pomProperties);
|
||||
if ((groupid == null || groupid.isEmpty()) && parentGroupId != null && !parentGroupId.isEmpty()) {
|
||||
groupid = parentGroupId;
|
||||
}
|
||||
if ("org.sonatype.oss".equals(parentGroupId) && "oss-parent".equals(parentArtifactId)) {
|
||||
parentGroupId = null;
|
||||
parentArtifactId = null;
|
||||
parentVersion = null;
|
||||
}
|
||||
|
||||
if ((groupid == null || groupid.isEmpty()) && parentGroupId != null && !parentGroupId.isEmpty()) {
|
||||
groupid = parentGroupId;
|
||||
}
|
||||
|
||||
final String originalGroupID = groupid;
|
||||
if (groupid.startsWith("org.") || groupid.startsWith("com.")) {
|
||||
groupid = groupid.substring(4);
|
||||
}
|
||||
|
||||
if ((artifactid == null || artifactid.isEmpty()) && parentArtifactId != null && !parentArtifactId.isEmpty()) {
|
||||
artifactid = parentArtifactId;
|
||||
}
|
||||
|
||||
final String originalArtifactID = artifactid;
|
||||
if (artifactid.startsWith("org.") || artifactid.startsWith("com.")) {
|
||||
artifactid = artifactid.substring(4);
|
||||
}
|
||||
|
||||
if ((version == null || version.isEmpty()) && parentVersion != null && !parentVersion.isEmpty()) {
|
||||
version = parentVersion;
|
||||
}
|
||||
|
||||
if (groupid != null && !groupid.isEmpty()) {
|
||||
foundSomething = true;
|
||||
@@ -564,20 +514,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
addAsIdentifier = false;
|
||||
}
|
||||
|
||||
String artifactid = interpolateString(pom.getArtifactId(), pomProperties);
|
||||
String parentArtifactId = null;
|
||||
|
||||
if (pom.getParent() != null) {
|
||||
parentArtifactId = interpolateString(pom.getParent().getArtifactId(), pomProperties);
|
||||
if ((artifactid == null || artifactid.isEmpty()) && parentArtifactId != null && !parentArtifactId.isEmpty()) {
|
||||
artifactid = parentArtifactId;
|
||||
}
|
||||
}
|
||||
final String originalArtifactID = artifactid;
|
||||
if (artifactid != null && !artifactid.isEmpty()) {
|
||||
if (artifactid.startsWith("org.") || artifactid.startsWith("com.")) {
|
||||
artifactid = artifactid.substring(4);
|
||||
}
|
||||
foundSomething = true;
|
||||
dependency.getProductEvidence().addEvidence("pom", "artifactid", artifactid, Confidence.HIGHEST);
|
||||
dependency.getVendorEvidence().addEvidence("pom", "artifactid", artifactid, Confidence.LOW);
|
||||
@@ -592,16 +529,6 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
} else {
|
||||
addAsIdentifier = false;
|
||||
}
|
||||
//version
|
||||
String version = interpolateString(pom.getVersion(), pomProperties);
|
||||
String parentVersion = null;
|
||||
|
||||
if (pom.getParent() != null) {
|
||||
parentVersion = interpolateString(pom.getParent().getVersion(), pomProperties);
|
||||
if ((version == null || version.isEmpty()) && parentVersion != null && !parentVersion.isEmpty()) {
|
||||
version = parentVersion;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != null && !version.isEmpty()) {
|
||||
foundSomething = true;
|
||||
@@ -614,22 +541,21 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
|
||||
if (addAsIdentifier) {
|
||||
dependency.addIdentifier("maven", String.format("%s:%s:%s", originalGroupID, originalArtifactID, version), null, Confidence.LOW);
|
||||
dependency.addIdentifier("maven", String.format("%s:%s:%s", originalGroupID, originalArtifactID, version), null, Confidence.HIGH);
|
||||
}
|
||||
|
||||
// org name
|
||||
final Organization org = pom.getOrganization();
|
||||
if (org != null && org.getName() != null) {
|
||||
foundSomething = true;
|
||||
final String orgName = interpolateString(org.getName(), pomProperties);
|
||||
if (orgName != null && !orgName.isEmpty()) {
|
||||
dependency.getVendorEvidence().addEvidence("pom", "organization name", orgName, Confidence.HIGH);
|
||||
addMatchingValues(classes, orgName, dependency.getVendorEvidence());
|
||||
}
|
||||
final String org = pom.getOrganization();
|
||||
if (org != null && !org.isEmpty()) {
|
||||
dependency.getVendorEvidence().addEvidence("pom", "organization name", org, Confidence.HIGH);
|
||||
dependency.getProductEvidence().addEvidence("pom", "organization name", org, Confidence.LOW);
|
||||
addMatchingValues(classes, org, dependency.getVendorEvidence());
|
||||
addMatchingValues(classes, org, dependency.getProductEvidence());
|
||||
}
|
||||
//pom name
|
||||
final String pomName = interpolateString(pom.getName(), pomProperties);
|
||||
if (pomName != null && !pomName.isEmpty()) {
|
||||
final String pomName = pom.getName();
|
||||
if (pomName
|
||||
!= null && !pomName.isEmpty()) {
|
||||
foundSomething = true;
|
||||
dependency.getProductEvidence().addEvidence("pom", "name", pomName, Confidence.HIGH);
|
||||
dependency.getVendorEvidence().addEvidence("pom", "name", pomName, Confidence.HIGH);
|
||||
@@ -638,16 +564,15 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
|
||||
//Description
|
||||
if (pom.getDescription() != null) {
|
||||
final String description = pom.getDescription();
|
||||
if (description != null && !description.isEmpty()) {
|
||||
foundSomething = true;
|
||||
final String description = interpolateString(pom.getDescription(), pomProperties);
|
||||
if (description != null && !description.isEmpty()) {
|
||||
final String trimmedDescription = addDescription(dependency, description, "pom", "description");
|
||||
addMatchingValues(classes, trimmedDescription, dependency.getVendorEvidence());
|
||||
addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence());
|
||||
}
|
||||
final String trimmedDescription = addDescription(dependency, description, "pom", "description");
|
||||
addMatchingValues(classes, trimmedDescription, dependency.getVendorEvidence());
|
||||
addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence());
|
||||
}
|
||||
extractLicense(pom, pomProperties, dependency);
|
||||
|
||||
extractLicense(pom, dependency);
|
||||
return foundSomething;
|
||||
}
|
||||
|
||||
@@ -974,62 +899,6 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A utility function that will interpolate strings based on values given in the properties file. It will also interpolate the
|
||||
* strings contained within the properties file so that properties can reference other properties.</p>
|
||||
* <p>
|
||||
* <b>Note:</b> if there is no property found the reference will be removed. In other words, if the interpolated string will
|
||||
* be replaced with an empty string.
|
||||
* </p>
|
||||
* <p>
|
||||
* Example:</p>
|
||||
* <code>
|
||||
* Properties p = new Properties();
|
||||
* p.setProperty("key", "value");
|
||||
* String s = interpolateString("'${key}' and '${nothing}'", p);
|
||||
* System.out.println(s);
|
||||
* </code>
|
||||
* <p>
|
||||
* Will result in:</p>
|
||||
* <code>
|
||||
* 'value' and ''
|
||||
* </code>
|
||||
*
|
||||
* @param text the string that contains references to properties.
|
||||
* @param properties a collection of properties that may be referenced within the text.
|
||||
* @return the interpolated text.
|
||||
*/
|
||||
public static String interpolateString(String text, Properties properties) {
|
||||
final Properties props = properties;
|
||||
if (text == null) {
|
||||
return text;
|
||||
}
|
||||
if (props == null) {
|
||||
return text;
|
||||
}
|
||||
|
||||
final int pos = text.indexOf("${");
|
||||
if (pos < 0) {
|
||||
return text;
|
||||
}
|
||||
final int end = text.indexOf("}");
|
||||
if (end < pos) {
|
||||
return text;
|
||||
}
|
||||
|
||||
final String propName = text.substring(pos + 2, end);
|
||||
String propValue = interpolateString(props.getProperty(propName), props);
|
||||
if (propValue == null) {
|
||||
propValue = "";
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder(propValue.length() + text.length());
|
||||
sb.append(text.subSequence(0, pos));
|
||||
sb.append(propValue);
|
||||
sb.append(text.substring(end + 1));
|
||||
return interpolateString(sb.toString(), props); //yes yes, this should be a loop...
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the key value pair from the manifest is for an "import" type entry for package names.
|
||||
*
|
||||
@@ -1137,7 +1006,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
* @param value the value to check to see if it contains a package name
|
||||
* @param evidence the evidence collection to add new entries too
|
||||
*/
|
||||
private void addMatchingValues(List<ClassNameInformation> classes, String value, EvidenceCollection evidence) {
|
||||
private static void addMatchingValues(List<ClassNameInformation> classes, String value, EvidenceCollection evidence) {
|
||||
if (value == null || value.isEmpty() || classes == null || classes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -1169,23 +1038,22 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
* Extracts the license information from the pom and adds it to the dependency.
|
||||
*
|
||||
* @param pom the pom object
|
||||
* @param pomProperties the properties, used for string interpolation
|
||||
* @param dependency the dependency to add license information too
|
||||
*/
|
||||
public static void extractLicense(Model pom, Properties pomProperties, Dependency dependency) {
|
||||
public static void extractLicense(Model pom, Dependency dependency) {
|
||||
//license
|
||||
if (pom.getLicenses() != null) {
|
||||
String license = null;
|
||||
for (License lic : pom.getLicenses().getLicense()) {
|
||||
for (License lic : pom.getLicenses()) {
|
||||
String tmp = null;
|
||||
if (lic.getName() != null) {
|
||||
tmp = interpolateString(lic.getName(), pomProperties);
|
||||
tmp = lic.getName();
|
||||
}
|
||||
if (lic.getUrl() != null) {
|
||||
if (tmp == null) {
|
||||
tmp = interpolateString(lic.getUrl(), pomProperties);
|
||||
tmp = lic.getUrl();
|
||||
} else {
|
||||
tmp += ": " + interpolateString(lic.getUrl(), pomProperties);
|
||||
tmp += ": " + lic.getUrl();
|
||||
}
|
||||
}
|
||||
if (tmp == null) {
|
||||
@@ -1202,6 +1070,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
if (license != null) {
|
||||
dependency.setLicense(license);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
*
|
||||
* Used to analyze a JavaScript file to gather information to aid in identification of a CPE identifier.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class JavaScriptAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.owasp.dependencycheck.data.nexus.NexusSearch;
|
||||
import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.Evidence;
|
||||
import org.owasp.dependencycheck.jaxb.pom.PomUtils;
|
||||
import org.owasp.dependencycheck.xml.pom.PomUtils;
|
||||
import org.owasp.dependencycheck.utils.InvalidSettingException;
|
||||
import org.owasp.dependencycheck.utils.DownloadFailedException;
|
||||
import org.owasp.dependencycheck.utils.Downloader;
|
||||
@@ -45,10 +45,10 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
* There are two settings which govern this behavior:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link org.owasp.dependencycheck.utils.Settings.KEYS#ANALYZER_NEXUS_ENABLED} determines whether this analyzer is
|
||||
* even enabled. This can be overridden by setting the system property.</li>
|
||||
* <li>{@link org.owasp.dependencycheck.utils.Settings.KEYS#ANALYZER_NEXUS_URL} the URL to a Nexus service to search by
|
||||
* SHA-1. There is an expected <code>%s</code> in this where the SHA-1 will get entered.</li>
|
||||
* <li>{@link org.owasp.dependencycheck.utils.Settings.KEYS#ANALYZER_NEXUS_ENABLED} determines whether this analyzer is even
|
||||
* enabled. This can be overridden by setting the system property.</li>
|
||||
* <li>{@link org.owasp.dependencycheck.utils.Settings.KEYS#ANALYZER_NEXUS_URL} the URL to a Nexus service to search by SHA-1.
|
||||
* There is an expected <code>%s</code> in this where the SHA-1 will get entered.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author colezlaw
|
||||
@@ -89,10 +89,6 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
* Field indicating if the analyzer is enabled.
|
||||
*/
|
||||
private final boolean enabled = checkEnabled();
|
||||
/**
|
||||
* Field for doing POM work
|
||||
*/
|
||||
private final PomUtils pomUtil = new PomUtils();
|
||||
|
||||
/**
|
||||
* Determines if this analyzer is enabled
|
||||
@@ -233,7 +229,7 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
}
|
||||
LOGGER.fine(String.format("Downloading %s", ma.getPomUrl()));
|
||||
Downloader.fetchFile(new URL(ma.getPomUrl()), pomFile);
|
||||
pomUtil.analyzePOM(dependency, pomFile);
|
||||
PomUtils.analyzePOM(dependency, pomFile);
|
||||
} catch (DownloadFailedException ex) {
|
||||
final String msg = String.format("Unable to download pom.xml for %s from Nexus repository; "
|
||||
+ "this could result in undetected CPE/CVEs.", dependency.getFileName());
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.owasp.dependencycheck.dependency.Vulnerability;
|
||||
* NvdCveAnalyzer is a utility class that takes a project dependency and attempts to discern if there is an associated
|
||||
* CVEs. It uses the the identifiers found by other analyzers to lookup the CVE data.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class NvdCveAnalyzer implements Analyzer {
|
||||
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
/*
|
||||
* This file is part of dependency-check-core.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Copyright (c) 2015 Institute for Defense Analyses. All Rights Reserved.
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.InternetHeaders;
|
||||
|
||||
import org.apache.commons.io.filefilter.NameFileFilter;
|
||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||
import org.apache.commons.io.input.AutoCloseInputStream;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.owasp.dependencycheck.Engine;
|
||||
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
|
||||
import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.EvidenceCollection;
|
||||
import org.owasp.dependencycheck.utils.ExtractionException;
|
||||
import org.owasp.dependencycheck.utils.ExtractionUtil;
|
||||
import org.owasp.dependencycheck.utils.FileUtils;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.owasp.dependencycheck.utils.UrlStringUtils;
|
||||
|
||||
/**
|
||||
* Used to analyze a Wheel or egg distribution files, or their contents in unzipped form, and collect information that can be used
|
||||
* to determine the associated CPE.
|
||||
*
|
||||
* @author Dale Visser <dvisser@ida.org>
|
||||
*/
|
||||
public class PythonDistributionAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
|
||||
/**
|
||||
* Name of egg metatdata files to analyze.
|
||||
*/
|
||||
private static final String PKG_INFO = "PKG-INFO";
|
||||
|
||||
/**
|
||||
* Name of wheel metadata files to analyze.
|
||||
*/
|
||||
private static final String METADATA = "METADATA";
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*/
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(PythonDistributionAnalyzer.class.getName());
|
||||
|
||||
/**
|
||||
* The count of directories created during analysis. This is used for creating temporary directories.
|
||||
*/
|
||||
private static int dirCount = 0;
|
||||
|
||||
/**
|
||||
* The name of the analyzer.
|
||||
*/
|
||||
private static final String ANALYZER_NAME = "Python Distribution Analyzer";
|
||||
/**
|
||||
* The phase that this analyzer is intended to run in.
|
||||
*/
|
||||
private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.INFORMATION_COLLECTION;
|
||||
|
||||
/**
|
||||
* The set of file extensions supported by this analyzer.
|
||||
*/
|
||||
private static final Set<String> EXTENSIONS = newHashSet("whl", "egg",
|
||||
"zip", METADATA, PKG_INFO);
|
||||
|
||||
/**
|
||||
* Used to match on egg archive candidate extenssions.
|
||||
*/
|
||||
private static final Pattern EGG_OR_ZIP = Pattern.compile("egg|zip");
|
||||
|
||||
/**
|
||||
* The parent directory for the individual directories per archive.
|
||||
*/
|
||||
private File tempFileLocation;
|
||||
|
||||
/**
|
||||
* Filter that detects *.dist-info files (but doesn't verify they are directories.
|
||||
*/
|
||||
private static final FilenameFilter DIST_INFO_FILTER = new SuffixFileFilter(
|
||||
".dist-info");
|
||||
|
||||
/**
|
||||
* Filter that detects files named "METADATA".
|
||||
*/
|
||||
private static final FilenameFilter EGG_INFO_FILTER = new NameFileFilter(
|
||||
"EGG-INFO");
|
||||
|
||||
/**
|
||||
* Filter that detects files named "METADATA".
|
||||
*/
|
||||
private static final FilenameFilter METADATA_FILTER = new NameFileFilter(
|
||||
METADATA);
|
||||
|
||||
/**
|
||||
* Filter that detects files named "PKG-INFO".
|
||||
*/
|
||||
private static final FilenameFilter PKG_INFO_FILTER = new NameFileFilter(
|
||||
PKG_INFO);
|
||||
|
||||
/**
|
||||
* Returns a list of file EXTENSIONS supported by this analyzer.
|
||||
*
|
||||
* @return a list of file EXTENSIONS supported by this analyzer.
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSupportedExtensions() {
|
||||
return EXTENSIONS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the analyzer.
|
||||
*
|
||||
* @return the name of the analyzer.
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return ANALYZER_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the phase that the analyzer is intended to run in.
|
||||
*
|
||||
* @return the phase that the analyzer is intended to run in.
|
||||
*/
|
||||
public AnalysisPhase getAnalysisPhase() {
|
||||
return ANALYSIS_PHASE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used in the properties file to reference the analyzer's enabled property.
|
||||
*
|
||||
* @return the analyzer's enabled property setting key
|
||||
*/
|
||||
@Override
|
||||
protected String getAnalyzerEnabledSettingKey() {
|
||||
return Settings.KEYS.ANALYZER_PYTHON_DISTRIBUTION_ENABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void analyzeFileType(Dependency dependency, Engine engine)
|
||||
throws AnalysisException {
|
||||
if ("whl".equals(dependency.getFileExtension())) {
|
||||
collectMetadataFromArchiveFormat(dependency, DIST_INFO_FILTER,
|
||||
METADATA_FILTER);
|
||||
} else if (EGG_OR_ZIP.matcher(
|
||||
StringUtils.stripToEmpty(dependency.getFileExtension()))
|
||||
.matches()) {
|
||||
collectMetadataFromArchiveFormat(dependency, EGG_INFO_FILTER,
|
||||
PKG_INFO_FILTER);
|
||||
} else {
|
||||
final File actualFile = dependency.getActualFile();
|
||||
final String name = actualFile.getName();
|
||||
final boolean metadata = METADATA.equals(name);
|
||||
if (metadata || PKG_INFO.equals(name)) {
|
||||
final File parent = actualFile.getParentFile();
|
||||
final String parentName = parent.getName();
|
||||
dependency.setDisplayFileName(parentName + "/" + name);
|
||||
if (parent.isDirectory()
|
||||
&& (metadata && parentName.endsWith(".dist-info")
|
||||
|| parentName.endsWith(".egg-info") || "EGG-INFO"
|
||||
.equals(parentName))) {
|
||||
collectWheelMetadata(dependency, actualFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the meta data from an archive.
|
||||
*
|
||||
* @param dependency the archive being scanned
|
||||
* @param folderFilter the filter to apply to the folder
|
||||
* @param metadataFilter the filter to apply to the meta data
|
||||
* @throws AnalysisException thrown when there is a problem analyzing the dependency
|
||||
*/
|
||||
private void collectMetadataFromArchiveFormat(Dependency dependency,
|
||||
FilenameFilter folderFilter, FilenameFilter metadataFilter)
|
||||
throws AnalysisException {
|
||||
final File temp = getNextTempDirectory();
|
||||
LOGGER.fine(String.format("%s exists? %b", temp, temp.exists()));
|
||||
try {
|
||||
ExtractionUtil.extractFilesUsingFilter(
|
||||
new File(dependency.getActualFilePath()), temp,
|
||||
metadataFilter);
|
||||
} catch (ExtractionException ex) {
|
||||
throw new AnalysisException(ex);
|
||||
}
|
||||
|
||||
collectWheelMetadata(
|
||||
dependency,
|
||||
getMatchingFile(getMatchingFile(temp, folderFilter),
|
||||
metadataFilter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure a usable temporary directory is available.
|
||||
*
|
||||
* @throws Exception an AnalyzeException is thrown when the temp directory cannot be created
|
||||
*/
|
||||
@Override
|
||||
protected void initializeFileTypeAnalyzer() throws Exception {
|
||||
final File baseDir = Settings.getTempDirectory();
|
||||
tempFileLocation = File.createTempFile("check", "tmp", baseDir);
|
||||
if (!tempFileLocation.delete()) {
|
||||
final String msg = String.format(
|
||||
"Unable to delete temporary file '%s'.",
|
||||
tempFileLocation.getAbsolutePath());
|
||||
throw new AnalysisException(msg);
|
||||
}
|
||||
if (!tempFileLocation.mkdirs()) {
|
||||
final String msg = String.format(
|
||||
"Unable to create directory '%s'.",
|
||||
tempFileLocation.getAbsolutePath());
|
||||
throw new AnalysisException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes any files extracted from the Wheel during analysis.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
if (tempFileLocation != null && tempFileLocation.exists()) {
|
||||
LOGGER.log(Level.FINE, "Attempting to delete temporary files");
|
||||
final boolean success = FileUtils.delete(tempFileLocation);
|
||||
if (!success) {
|
||||
LOGGER.log(Level.WARNING,
|
||||
"Failed to delete some temporary files, see the log for more details");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gathers evidence from the METADATA file.
|
||||
*
|
||||
* @param dependency the dependency being analyzed
|
||||
* @param file a reference to the manifest/properties file
|
||||
* @throws AnalysisException thrown when there is an error
|
||||
*/
|
||||
private static void collectWheelMetadata(Dependency dependency, File file)
|
||||
throws AnalysisException {
|
||||
final InternetHeaders headers = getManifestProperties(file);
|
||||
addPropertyToEvidence(headers, dependency.getVersionEvidence(),
|
||||
"Version", Confidence.HIGHEST);
|
||||
addPropertyToEvidence(headers, dependency.getProductEvidence(), "Name",
|
||||
Confidence.HIGHEST);
|
||||
final String url = headers.getHeader("Home-page", null);
|
||||
final EvidenceCollection vendorEvidence = dependency
|
||||
.getVendorEvidence();
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
if (UrlStringUtils.isUrl(url)) {
|
||||
vendorEvidence.addEvidence(METADATA, "vendor", url,
|
||||
Confidence.MEDIUM);
|
||||
}
|
||||
}
|
||||
addPropertyToEvidence(headers, vendorEvidence, "Author", Confidence.LOW);
|
||||
final String summary = headers.getHeader("Summary", null);
|
||||
if (StringUtils.isNotBlank(summary)) {
|
||||
JarAnalyzer
|
||||
.addDescription(dependency, summary, METADATA, "summary");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a value to the evidence collection.
|
||||
*
|
||||
* @param headers the properties collection
|
||||
* @param evidence the evidence collection to add the value
|
||||
* @param property the property name
|
||||
* @param confidence the confidence of the evidence
|
||||
*/
|
||||
private static void addPropertyToEvidence(InternetHeaders headers,
|
||||
EvidenceCollection evidence, String property, Confidence confidence) {
|
||||
final String value = headers.getHeader(property, null);
|
||||
LOGGER.fine(String.format("Property: %s, Value: %s", property, value));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
evidence.addEvidence(METADATA, property, value, confidence);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of files that match the given filter, this does not recursively scan the directory.
|
||||
*
|
||||
* @param folder the folder to filter
|
||||
* @param filter the filter to apply to the files in the directory
|
||||
* @return the list of Files in the directory that match the provided filter
|
||||
*/
|
||||
private static File getMatchingFile(File folder, FilenameFilter filter) {
|
||||
File result = null;
|
||||
final File[] matches = folder.listFiles(filter);
|
||||
if (null != matches && 1 == matches.length) {
|
||||
result = matches[0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the manifest entries from the provided file.
|
||||
*
|
||||
* @param manifest the manifest
|
||||
* @return the manifest entries
|
||||
*/
|
||||
private static InternetHeaders getManifestProperties(File manifest) {
|
||||
final InternetHeaders result = new InternetHeaders();
|
||||
if (null == manifest) {
|
||||
LOGGER.fine("Manifest file not found.");
|
||||
} else {
|
||||
try {
|
||||
result.load(new AutoCloseInputStream(new BufferedInputStream(
|
||||
new FileInputStream(manifest))));
|
||||
} catch (MessagingException e) {
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the next temporary destingation directory for extracting an archive.
|
||||
*
|
||||
* @return a directory
|
||||
* @throws AnalysisException thrown if unable to create temporary directory
|
||||
*/
|
||||
private File getNextTempDirectory() throws AnalysisException {
|
||||
File directory;
|
||||
|
||||
// getting an exception for some directories not being able to be
|
||||
// created; might be because the directory already exists?
|
||||
do {
|
||||
dirCount += 1;
|
||||
directory = new File(tempFileLocation, String.valueOf(dirCount));
|
||||
} while (directory.exists());
|
||||
if (!directory.mkdirs()) {
|
||||
throw new AnalysisException(String.format(
|
||||
"Unable to create temp directory '%s'.",
|
||||
directory.getAbsolutePath()));
|
||||
}
|
||||
return directory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* This file is part of dependency-check-core.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Copyright (c) 2015 Institute for Defense Analyses. All Rights Reserved.
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.NameFileFilter;
|
||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||
import org.owasp.dependencycheck.Engine;
|
||||
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
|
||||
import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.EvidenceCollection;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.owasp.dependencycheck.utils.UrlStringUtils;
|
||||
|
||||
/**
|
||||
* Used to analyze a Python package, and collect information that can be used to determine the associated CPE.
|
||||
*
|
||||
* @author Dale Visser <dvisser@ida.org>
|
||||
*/
|
||||
public class PythonPackageAnalyzer extends AbstractFileTypeAnalyzer {
|
||||
|
||||
/**
|
||||
* Used when compiling file scanning regex patterns.
|
||||
*/
|
||||
private static final int REGEX_OPTIONS = Pattern.DOTALL
|
||||
| Pattern.CASE_INSENSITIVE;
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
*/
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(PythonDistributionAnalyzer.class.getName());
|
||||
|
||||
/**
|
||||
* Filename extensions for files to be analyzed.
|
||||
*/
|
||||
private static final Set<String> EXTENSIONS = Collections
|
||||
.unmodifiableSet(Collections.singleton("py"));
|
||||
|
||||
/**
|
||||
* Pattern for matching the module docstring in a source file.
|
||||
*/
|
||||
private static final Pattern MODULE_DOCSTRING = Pattern.compile(
|
||||
"^(['\\\"]{3})(.*?)\\1", REGEX_OPTIONS);
|
||||
|
||||
/**
|
||||
* Matches assignments to version variables in Python source code.
|
||||
*/
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile(
|
||||
"\\b(__)?version(__)? *= *(['\"]+)(\\d+\\.\\d+.*?)\\3",
|
||||
REGEX_OPTIONS);
|
||||
|
||||
/**
|
||||
* Matches assignments to title variables in Python source code.
|
||||
*/
|
||||
private static final Pattern TITLE_PATTERN = compileAssignPattern("title");
|
||||
|
||||
/**
|
||||
* Matches assignments to summary variables in Python source code.
|
||||
*/
|
||||
private static final Pattern SUMMARY_PATTERN = compileAssignPattern("summary");
|
||||
|
||||
/**
|
||||
* Matches assignments to URL/URL variables in Python source code.
|
||||
*/
|
||||
private static final Pattern URI_PATTERN = compileAssignPattern("ur[il]");
|
||||
|
||||
/**
|
||||
* Matches assignments to home page variables in Python source code.
|
||||
*/
|
||||
private static final Pattern HOMEPAGE_PATTERN = compileAssignPattern("home_?page");
|
||||
|
||||
/**
|
||||
* Matches assignments to author variables in Python source code.
|
||||
*/
|
||||
private static final Pattern AUTHOR_PATTERN = compileAssignPattern("author");
|
||||
|
||||
/**
|
||||
* Filter that detects files named "__init__.py".
|
||||
*/
|
||||
private static final FileFilter INIT_PY_FILTER = new NameFileFilter("__init__.py");
|
||||
|
||||
/**
|
||||
* The file filter for python files.
|
||||
*/
|
||||
private static final FileFilter PY_FILTER = new SuffixFileFilter(".py");
|
||||
|
||||
/**
|
||||
* Returns the name of the Python Package Analyzer.
|
||||
*
|
||||
* @return the name of the analyzer
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Python Package Analyzer";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell that we are used for information collection.
|
||||
*
|
||||
* @return INFORMATION_COLLECTION
|
||||
*/
|
||||
@Override
|
||||
public AnalysisPhase getAnalysisPhase() {
|
||||
return AnalysisPhase.INFORMATION_COLLECTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of supported file extensions.
|
||||
*
|
||||
* @return the set of supported file extensions
|
||||
*/
|
||||
@Override
|
||||
protected Set<String> getSupportedExtensions() {
|
||||
return EXTENSIONS;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op initializer implementation.
|
||||
*
|
||||
* @throws Exception never thrown
|
||||
*/
|
||||
@Override
|
||||
protected void initializeFileTypeAnalyzer() throws Exception {
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to create a regex pattern matcher.
|
||||
*
|
||||
* @param name the value to use when constructing the assignment pattern
|
||||
* @return the compiled Pattern
|
||||
*/
|
||||
private static Pattern compileAssignPattern(String name) {
|
||||
return Pattern.compile(
|
||||
String.format("\\b(__)?%s(__)?\\b *= *(['\"]+)(.*?)\\3", name),
|
||||
REGEX_OPTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyzes python packages and adds evidence to the dependency.
|
||||
*
|
||||
* @param dependency the dependency being analyzed
|
||||
* @param engine the engine being used to perform the scan
|
||||
* @throws AnalysisException thrown if there is an unrecoverable error analyzing the dependency
|
||||
*/
|
||||
@Override
|
||||
protected void analyzeFileType(Dependency dependency, Engine engine)
|
||||
throws AnalysisException {
|
||||
final File file = dependency.getActualFile();
|
||||
final File parent = file.getParentFile();
|
||||
final String parentName = parent.getName();
|
||||
boolean found = false;
|
||||
if (INIT_PY_FILTER.accept(file)) {
|
||||
for (final File sourcefile : parent.listFiles(PY_FILTER)) {
|
||||
found |= analyzeFileContents(dependency, sourcefile);
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
dependency.setDisplayFileName(parentName + "/__init__.py");
|
||||
dependency.getProductEvidence().addEvidence(file.getName(),
|
||||
"PackageName", parentName, Confidence.MEDIUM);
|
||||
} else {
|
||||
// copy, alter and set in case some other thread is iterating over
|
||||
final List<Dependency> deps = new ArrayList<Dependency>(
|
||||
engine.getDependencies());
|
||||
deps.remove(dependency);
|
||||
engine.setDependencies(deps);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should gather information from leading docstrings, file comments, and assignments to __version__, __title__,
|
||||
* __summary__, __uri__, __url__, __home*page__, __author__, and their all caps equivalents.
|
||||
*
|
||||
* @param dependency the dependency being analyzed
|
||||
* @param file the file name to analyze
|
||||
* @return whether evidence was found
|
||||
* @throws AnalysisException thrown if there is an unrecoverable error
|
||||
*/
|
||||
private boolean analyzeFileContents(Dependency dependency, File file)
|
||||
throws AnalysisException {
|
||||
String contents = "";
|
||||
try {
|
||||
contents = FileUtils.readFileToString(file).trim();
|
||||
} catch (IOException e) {
|
||||
throw new AnalysisException(
|
||||
"Problem occured while reading dependency file.", e);
|
||||
}
|
||||
boolean found = false;
|
||||
if (!contents.isEmpty()) {
|
||||
final String source = file.getName();
|
||||
found = gatherEvidence(VERSION_PATTERN, contents, source,
|
||||
dependency.getVersionEvidence(), "SourceVersion",
|
||||
Confidence.MEDIUM);
|
||||
found |= addSummaryInfo(dependency, SUMMARY_PATTERN, 4, contents,
|
||||
source, "summary");
|
||||
if (INIT_PY_FILTER.accept(file)) {
|
||||
found |= addSummaryInfo(dependency, MODULE_DOCSTRING, 2,
|
||||
contents, source, "docstring");
|
||||
}
|
||||
found |= gatherEvidence(TITLE_PATTERN, contents, source,
|
||||
dependency.getProductEvidence(), "SourceTitle",
|
||||
Confidence.LOW);
|
||||
final EvidenceCollection vendorEvidence = dependency
|
||||
.getVendorEvidence();
|
||||
found |= gatherEvidence(AUTHOR_PATTERN, contents, source,
|
||||
vendorEvidence, "SourceAuthor", Confidence.MEDIUM);
|
||||
try {
|
||||
found |= gatherHomePageEvidence(URI_PATTERN, vendorEvidence,
|
||||
source, "URL", contents);
|
||||
found |= gatherHomePageEvidence(HOMEPAGE_PATTERN,
|
||||
vendorEvidence, source, "HomePage", contents);
|
||||
} catch (MalformedURLException e) {
|
||||
LOGGER.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds summary information to the dependency
|
||||
*
|
||||
* @param dependency the dependency being analyzed
|
||||
* @param pattern the pattern used to perform analysis
|
||||
* @param group the group from the pattern that indicates the data to use
|
||||
* @param contents the data being analyzed
|
||||
* @param source the source name to use when recording the evidence
|
||||
* @param key the key name to use when recording the evidence
|
||||
* @return true if evidence was collected; otherwise false
|
||||
*/
|
||||
private boolean addSummaryInfo(Dependency dependency, Pattern pattern,
|
||||
int group, String contents, String source, String key) {
|
||||
final Matcher matcher = pattern.matcher(contents);
|
||||
final boolean found = matcher.find();
|
||||
if (found) {
|
||||
JarAnalyzer.addDescription(dependency, matcher.group(group),
|
||||
source, key);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects evidence from the home page URL.
|
||||
*
|
||||
* @param pattern the pattern to match
|
||||
* @param evidence the evidence collection to add the evidence to
|
||||
* @param source the source of the evidence
|
||||
* @param name the name of the evidence
|
||||
* @param contents the home page URL
|
||||
* @return true if evidence was collected; otherwise false
|
||||
* @throws MalformedURLException thrown if the URL is malformed
|
||||
*/
|
||||
private boolean gatherHomePageEvidence(Pattern pattern,
|
||||
EvidenceCollection evidence, String source, String name,
|
||||
String contents) throws MalformedURLException {
|
||||
final Matcher matcher = pattern.matcher(contents);
|
||||
boolean found = false;
|
||||
if (matcher.find()) {
|
||||
final String url = matcher.group(4);
|
||||
if (UrlStringUtils.isUrl(url)) {
|
||||
found = true;
|
||||
evidence.addEvidence(source, name, url, Confidence.MEDIUM);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gather evidence from a Python source file usin the given string assignment regex pattern.
|
||||
*
|
||||
* @param pattern to scan contents with
|
||||
* @param contents of Python source file
|
||||
* @param source for storing evidence
|
||||
* @param evidence to store evidence in
|
||||
* @param name of evidence
|
||||
* @param confidence in evidence
|
||||
* @return whether evidence was found
|
||||
*/
|
||||
private boolean gatherEvidence(Pattern pattern, String contents,
|
||||
String source, EvidenceCollection evidence, String name,
|
||||
Confidence confidence) {
|
||||
final Matcher matcher = pattern.matcher(contents);
|
||||
final boolean found = matcher.find();
|
||||
if (found) {
|
||||
evidence.addEvidence(source, name, matcher.group(4), confidence);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAnalyzerEnabledSettingKey() {
|
||||
return Settings.KEYS.ANALYZER_PYTHON_PACKAGE_ENABLED;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import org.owasp.dependencycheck.suppression.SuppressionRule;
|
||||
* The suppression analyzer processes an externally defined XML document that complies with the suppressions.xsd schema.
|
||||
* Any identified Vulnerability entries within the dependencies that match will be removed.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class VulnerabilitySuppressionAnalyzer extends AbstractSuppressionAnalyzer {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.analyzer.exception;
|
||||
/**
|
||||
* An exception thrown when the analysis of a dependency fails.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class AnalysisException extends Exception {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.analyzer.exception;
|
||||
/**
|
||||
* An exception thrown when files in an archive cannot be extracted.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class ArchiveExtractionException extends Exception {
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.analyzer.exception</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>
|
||||
* A collection of exception classes used within the analyzers.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
* A collection of exception classes used within the analyzers.
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer.exception;
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.analyzer</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* Analyzers are used to inspect the identified dependencies, collect Evidence,
|
||||
* and process the dependencies.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
|
||||
* Analyzers are used to inspect the identified dependencies, collect Evidence, and process the dependencies.
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
@@ -123,7 +123,7 @@ public class CentralSearch {
|
||||
final String a = xpath.evaluate("./str[@name='a']", docs.item(i));
|
||||
LOGGER.finest(String.format("ArtifactId: %s", a));
|
||||
final String v = xpath.evaluate("./str[@name='v']", docs.item(i));
|
||||
final NodeList atts = (NodeList) xpath.evaluate("./arr[@name='ec']/str", docs.item(i), XPathConstants.NODESET);
|
||||
NodeList atts = (NodeList) xpath.evaluate("./arr[@name='ec']/str", docs.item(i), XPathConstants.NODESET);
|
||||
boolean pomAvailable = false;
|
||||
boolean jarAvailable = false;
|
||||
for (int x = 0; x < atts.getLength(); x++) {
|
||||
@@ -134,8 +134,18 @@ public class CentralSearch {
|
||||
jarAvailable = true;
|
||||
}
|
||||
}
|
||||
|
||||
atts = (NodeList) xpath.evaluate("./arr[@name='tags']/str", docs.item(i), XPathConstants.NODESET);
|
||||
boolean useHTTPS = false;
|
||||
for (int x = 0; x < atts.getLength(); x++) {
|
||||
final String tmp = xpath.evaluate(".", atts.item(x));
|
||||
if ("https".equals(tmp)) {
|
||||
useHTTPS = true;
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.finest(String.format("Version: %s", v));
|
||||
result.add(new MavenArtifact(g, a, v, jarAvailable, pomAvailable));
|
||||
result.add(new MavenArtifact(g, a, v, jarAvailable, pomAvailable, useHTTPS));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.central</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>
|
||||
* Contains classes related to searching Maven Central.</p>
|
||||
* <p>
|
||||
* These are used to abstract Maven Central searching away from OWASP Dependency Check so they can be reused elsewhere.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
*
|
||||
* Contains classes related to searching Maven Central.<br/><br/>
|
||||
*
|
||||
* These are used to abstract Maven Central searching away from OWASP Dependency Check so they can be reused elsewhere.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.central;
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.owasp.dependencycheck.utils.Pair;
|
||||
* An in memory lucene index that contains the vendor/product combinations from the CPE (application) identifiers within the NVD
|
||||
* CVE data.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class CpeMemoryIndex {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.data.cpe;
|
||||
/**
|
||||
* Fields is a collection of field names used within the Lucene index for CPE entries.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class Fields {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.net.URLDecoder;
|
||||
/**
|
||||
* A CPE entry containing the name, vendor, product, and version.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class IndexEntry implements Serializable {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.data.cpe;
|
||||
/**
|
||||
* An exception thrown when the there is an issue using the in-memory CPE Index.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class IndexException extends Exception {
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.cpe</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* Contains classes for working with the CPE Lucene Index.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.cpe;
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class CweDB {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
/**
|
||||
* A SAX Handler that will parse the CWE XML.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class CweHandler extends DefaultHandler {
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.cwe</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* Contains classes for working with the CWE Database.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.cwe;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
/**
|
||||
* An abstract tokenizing filter that can be used as the base for a tokenizing filter.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public abstract class AbstractTokenizingFilter extends TokenFilter {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.apache.lucene.util.Version;
|
||||
/**
|
||||
* Tokenizes the input breaking it into tokens when non-alpha/numeric characters are found.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class AlphaNumericTokenizer extends CharTokenizer {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DependencySimilarity extends DefaultSimilarity {
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.apache.lucene.util.Version;
|
||||
* A Lucene Analyzer that utilizes the WhitespaceTokenizer, WordDelimiterFilter, LowerCaseFilter, and StopFilter. The intended
|
||||
* purpose of this Analyzer is to index the CPE fields vendor and product.</p>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class FieldAnalyzer extends Analyzer {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.apache.lucene.util.Version;
|
||||
* <p>
|
||||
* Lucene utils is a set of utilize written to make constructing Lucene queries simpler.</p>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class LuceneUtils {
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.apache.lucene.util.Version;
|
||||
/**
|
||||
* A Lucene field analyzer used to analyzer queries against the CPE data.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class SearchFieldAnalyzer extends Analyzer {
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
* <p>
|
||||
* <b>Example:</b> "Spring Framework Core" -> "Spring SpringFramework Framework FrameworkCore Core".</p>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class TokenPairConcatenatingFilter extends TokenFilter {
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.owasp.dependencycheck.utils.UrlStringUtils;
|
||||
* <p>
|
||||
* <b>Example:</b> "3.0.0.RELEASE" -> "3 3.0 3.0.0 RELEASE 3.0.0.RELEASE".</p>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class UrlTokenizingFilter extends AbstractTokenizingFilter {
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.lucene</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* Contains classes used to work with the Lucene Indexes.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.lucene;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class MavenArtifact {
|
||||
/**
|
||||
* The base URL for download artifacts from Central.
|
||||
*/
|
||||
private static final String CENTRAL_CONTENT_URL = "http://search.maven.org/remotecontent?filepath=";
|
||||
private static final String CENTRAL_CONTENT_URL = "//search.maven.org/remotecontent?filepath=";
|
||||
|
||||
/**
|
||||
* The groupId
|
||||
@@ -80,19 +80,26 @@ public class MavenArtifact {
|
||||
* @param version the version
|
||||
* @param jarAvailable if the jar file is available from central
|
||||
* @param pomAvailable if the pom file is available from central
|
||||
* @param secureDownload if the jar and pom files should be downloaded using HTTPS.
|
||||
*/
|
||||
public MavenArtifact(String groupId, String artifactId, String version, boolean jarAvailable, boolean pomAvailable) {
|
||||
public MavenArtifact(String groupId, String artifactId, String version, boolean jarAvailable, boolean pomAvailable, boolean secureDownload) {
|
||||
this.groupId = groupId;
|
||||
this.artifactId = artifactId;
|
||||
this.version = version;
|
||||
String base;
|
||||
if (secureDownload) {
|
||||
base = "https:" + CENTRAL_CONTENT_URL;
|
||||
} else {
|
||||
base = "http:" + CENTRAL_CONTENT_URL;
|
||||
}
|
||||
if (jarAvailable) {
|
||||
//org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom
|
||||
this.artifactUrl = this.CENTRAL_CONTENT_URL + groupId.replace('.', '/') + "/" + artifactId.replace('.', '/') + "/"
|
||||
this.artifactUrl = base + groupId.replace('.', '/') + "/" + artifactId + "/"
|
||||
+ version + "/" + artifactId + "-" + version + ".jar";
|
||||
}
|
||||
if (pomAvailable) {
|
||||
//org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom
|
||||
this.pomUrl = this.CENTRAL_CONTENT_URL + groupId.replace('.', '/') + "/" + artifactId.replace('.', '/') + "/"
|
||||
this.pomUrl = base + groupId.replace('.', '/') + "/" + artifactId + "/"
|
||||
+ version + "/" + artifactId + "-" + version + ".pom";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,20 +40,26 @@ import org.w3c.dom.Document;
|
||||
public class NexusSearch {
|
||||
|
||||
/**
|
||||
* The root URL for the Nexus repository service
|
||||
* The root URL for the Nexus repository service.
|
||||
*/
|
||||
private final URL rootURL;
|
||||
|
||||
/**
|
||||
* Whether to use the Proxy when making requests
|
||||
* Whether to use the Proxy when making requests.
|
||||
*/
|
||||
private boolean useProxy;
|
||||
|
||||
/**
|
||||
* The username to use if the Nexus requires authentication.
|
||||
*/
|
||||
private String userName = null;
|
||||
/**
|
||||
* The password to use if the Nexus requires authentication.
|
||||
*/
|
||||
private char[] password;
|
||||
/**
|
||||
* Used for logging.
|
||||
*/
|
||||
private static final Logger LOGGER = Logger.getLogger(NexusSearch.class
|
||||
.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(NexusSearch.class.getName());
|
||||
|
||||
/**
|
||||
* Creates a NexusSearch for the given repository URL.
|
||||
@@ -98,10 +104,9 @@ public class NexusSearch {
|
||||
// Determine if we need to use a proxy. The rules:
|
||||
// 1) If the proxy is set, AND the setting is set to true, use the proxy
|
||||
// 2) Otherwise, don't use the proxy (either the proxy isn't configured,
|
||||
// or proxy is specifically
|
||||
// set to false
|
||||
final HttpURLConnection conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
|
||||
// or proxy is specifically set to false
|
||||
HttpURLConnection conn;
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
conn.setDoOutput(true);
|
||||
|
||||
// JSON would be more elegant, but there's not currently a dependency
|
||||
@@ -163,8 +168,10 @@ public class NexusSearch {
|
||||
* @return whether the repository is listening and returns the /status URL correctly
|
||||
*/
|
||||
public boolean preflightRequest() {
|
||||
HttpURLConnection conn;
|
||||
try {
|
||||
final HttpURLConnection conn = URLConnectionFactory.createHttpURLConnection(new URL(rootURL, "status"), useProxy);
|
||||
final URL url = new URL(rootURL, "status");
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
conn.addRequestProperty("Accept", "application/xml");
|
||||
conn.connect();
|
||||
if (conn.getResponseCode() != 200) {
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.nexus</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>
|
||||
* Contains classes related to searching a Nexus repository.</p>
|
||||
* <p>
|
||||
* These are used to abstract Nexus searching away from OWASP Dependency Check so they can be reused elsewhere.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
* Contains classes related to searching a Nexus repository.<br/><br/>
|
||||
*
|
||||
* These are used to abstract Nexus searching away from OWASP Dependency Check so they can be reused elsewhere.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.nexus;
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.nuget</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>
|
||||
* Contains classes related to parsing Nuget related files</p>
|
||||
* <p>
|
||||
* These are used to abstract away Nuget-related handling from Dependency Check
|
||||
* so they can be used elsewhere.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
* Contains classes related to parsing Nuget related files<br/><br/>
|
||||
* These are used to abstract away Nuget-related handling from Dependency Check so they can be used elsewhere.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.nuget;
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
* obtaining a connection will ensure the database file exists and that the appropriate table structure has been
|
||||
* created.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class ConnectionFactory {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ package org.owasp.dependencycheck.data.nvdcve;
|
||||
* An exception used to indicate the db4o database is corrupt. This could be due to invalid data or a complete failure
|
||||
* of the db.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
class CorruptDatabaseException extends DatabaseException {
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -47,7 +48,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* The database holding information about the NVD CVE data.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class CveDB {
|
||||
|
||||
@@ -59,6 +60,10 @@ public class CveDB {
|
||||
* Database connection
|
||||
*/
|
||||
private Connection conn;
|
||||
/**
|
||||
* The bundle of statements used when accessing the database.
|
||||
*/
|
||||
private ResourceBundle statementBundle = null;
|
||||
|
||||
/**
|
||||
* Creates a new CveDB object and opens the database connection. Note, the connection must be closed by the caller by calling
|
||||
@@ -68,6 +73,7 @@ public class CveDB {
|
||||
*/
|
||||
public CveDB() throws DatabaseException {
|
||||
super();
|
||||
statementBundle = java.util.ResourceBundle.getBundle("data/dbStatements");
|
||||
try {
|
||||
open();
|
||||
databaseProperties = new DatabaseProperties(this);
|
||||
@@ -162,116 +168,7 @@ public class CveDB {
|
||||
public DatabaseProperties getDatabaseProperties() {
|
||||
return databaseProperties;
|
||||
}
|
||||
//<editor-fold defaultstate="collapsed" desc="Constants to create, maintain, and retrieve data from the CVE Database">
|
||||
/**
|
||||
* SQL Statement to delete references by vulnerability ID.
|
||||
*/
|
||||
private static final String DELETE_REFERENCE = "DELETE FROM reference WHERE cveid = ?";
|
||||
/**
|
||||
* SQL Statement to delete software by vulnerability ID.
|
||||
*/
|
||||
private static final String DELETE_SOFTWARE = "DELETE FROM software WHERE cveid = ?";
|
||||
/**
|
||||
* SQL Statement to delete a vulnerability by CVE.
|
||||
*/
|
||||
private static final String DELETE_VULNERABILITY = "DELETE FROM vulnerability WHERE id = ?";
|
||||
/**
|
||||
* SQL Statement to cleanup orphan entries. Yes, the db schema could be a little tighter, but what we have works well to keep
|
||||
* the data file size down a bit.
|
||||
*/
|
||||
private static final String CLEANUP_ORPHANS = "DELETE FROM CpeEntry WHERE id not in (SELECT CPEEntryId FROM Software); ";
|
||||
/**
|
||||
* SQL Statement to insert a new reference.
|
||||
*/
|
||||
private static final String INSERT_REFERENCE = "INSERT INTO reference (cveid, name, url, source) VALUES (?, ?, ?, ?)";
|
||||
/**
|
||||
* SQL Statement to insert a new software.
|
||||
*/
|
||||
private static final String INSERT_SOFTWARE = "INSERT INTO software (cveid, cpeEntryId, previousVersion) VALUES (?, ?, ?)";
|
||||
/**
|
||||
* SQL Statement to insert a new cpe.
|
||||
*/
|
||||
private static final String INSERT_CPE = "INSERT INTO cpeEntry (cpe, vendor, product) VALUES (?, ?, ?)";
|
||||
/**
|
||||
* SQL Statement to get a CPEProductID.
|
||||
*/
|
||||
private static final String SELECT_CPE_ID = "SELECT id FROM cpeEntry WHERE cpe = ?";
|
||||
/**
|
||||
* SQL Statement to insert a new vulnerability.
|
||||
*/
|
||||
private static final String INSERT_VULNERABILITY = "INSERT INTO vulnerability (cve, description, cwe, cvssScore, cvssAccessVector, "
|
||||
+ "cvssAccessComplexity, cvssAuthentication, cvssConfidentialityImpact, cvssIntegrityImpact, cvssAvailabilityImpact) "
|
||||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
/**
|
||||
* SQL Statement to update a vulnerability.
|
||||
*/
|
||||
private static final String UPDATE_VULNERABILITY = "UPDATE vulnerability SET description=?, cwe=?, cvssScore=?, cvssAccessVector=?, "
|
||||
+ "cvssAccessComplexity=?, cvssAuthentication=?, cvssConfidentialityImpact=?, cvssIntegrityImpact=?, cvssAvailabilityImpact=? "
|
||||
+ "WHERE id=?";
|
||||
/**
|
||||
* SQL Statement to find CVE entries based on CPE data.
|
||||
*/
|
||||
private static final String SELECT_CVE_FROM_SOFTWARE = "SELECT cve, cpe, previousVersion "
|
||||
+ "FROM software INNER JOIN vulnerability ON vulnerability.id = software.cveId "
|
||||
+ "INNER JOIN cpeEntry ON cpeEntry.id = software.cpeEntryId "
|
||||
+ "WHERE vendor = ? AND product = ? "
|
||||
+ "ORDER BY cve, cpe"; //, previousVersion
|
||||
//unfortunately, the version info is too complicated to do in a select. Need to filter this afterwards
|
||||
// + " AND (version = '-' OR previousVersion IS NOT NULL OR version=?)";
|
||||
//
|
||||
/**
|
||||
* SQL Statement to find the CPE entry based on the vendor and product.
|
||||
*/
|
||||
private static final String SELECT_CPE_ENTRIES = "SELECT cpe FROM cpeEntry WHERE vendor = ? AND product = ?";
|
||||
/**
|
||||
* SQL Statement to select references by CVEID.
|
||||
*/
|
||||
private static final String SELECT_REFERENCE = "SELECT source, name, url FROM reference WHERE cveid = ?";
|
||||
/**
|
||||
* SQL Statement to select vendor and product for lucene index.
|
||||
*/
|
||||
private static final String SELECT_VENDOR_PRODUCT_LIST = "SELECT vendor, product FROM cpeEntry GROUP BY vendor, product";
|
||||
/**
|
||||
* SQL Statement to select software by CVEID.
|
||||
*/
|
||||
private static final String SELECT_SOFTWARE = "SELECT cpe, previousVersion "
|
||||
+ "FROM software INNER JOIN cpeEntry ON software.cpeEntryId = cpeEntry.id WHERE cveid = ?";
|
||||
// public static final String SELECT_SOFTWARE = "SELECT part, vendor, product, version, revision, previousVersion "
|
||||
// + "FROM software INNER JOIN cpeProduct ON cpeProduct.id = software.cpeProductId LEFT JOIN cpeVersion ON "
|
||||
// + "software.cpeVersionId = cpeVersion.id LEFT JOIN Version ON cpeVersion.versionId = version.id WHERE cveid = ?";
|
||||
/**
|
||||
* SQL Statement to select a vulnerability by CVEID.
|
||||
*/
|
||||
private static final String SELECT_VULNERABILITY = "SELECT id, description, cwe, cvssScore, cvssAccessVector, cvssAccessComplexity, "
|
||||
+ "cvssAuthentication, cvssConfidentialityImpact, cvssIntegrityImpact, cvssAvailabilityImpact FROM vulnerability WHERE cve = ?";
|
||||
/**
|
||||
* SQL Statement to select a vulnerability's primary key.
|
||||
*/
|
||||
private static final String SELECT_VULNERABILITY_ID = "SELECT id FROM vulnerability WHERE cve = ?";
|
||||
/**
|
||||
* SQL Statement to retrieve the properties from the database.
|
||||
*/
|
||||
private static final String SELECT_PROPERTIES = "SELECT id, value FROM properties";
|
||||
/**
|
||||
* SQL Statement to retrieve a property from the database.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static final String SELECT_PROPERTY = "SELECT id, value FROM properties WHERE id = ?";
|
||||
/**
|
||||
* SQL Statement to insert a new property.
|
||||
*/
|
||||
private static final String INSERT_PROPERTY = "INSERT INTO properties (id, value) VALUES (?, ?)";
|
||||
/**
|
||||
* SQL Statement to update a property.
|
||||
*/
|
||||
private static final String UPDATE_PROPERTY = "UPDATE properties SET value = ? WHERE id = ?";
|
||||
/**
|
||||
* SQL Statement to delete a property.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static final String DELETE_PROPERTY = "DELETE FROM properties WHERE id = ?";
|
||||
|
||||
//</editor-fold>
|
||||
/**
|
||||
* Searches the CPE entries in the database and retrieves all entries for a given vendor and product combination. The returned
|
||||
* list will include all versions of the product that are registered in the NVD CVE data.
|
||||
@@ -285,7 +182,7 @@ public class CveDB {
|
||||
ResultSet rs = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
ps = getConnection().prepareStatement(SELECT_CPE_ENTRIES);
|
||||
ps = getConnection().prepareStatement(statementBundle.getString("SELECT_CPE_ENTRIES"));
|
||||
ps.setString(1, vendor);
|
||||
ps.setString(2, product);
|
||||
rs = ps.executeQuery();
|
||||
@@ -317,7 +214,7 @@ public class CveDB {
|
||||
ResultSet rs = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
ps = getConnection().prepareStatement(SELECT_VENDOR_PRODUCT_LIST);
|
||||
ps = getConnection().prepareStatement(statementBundle.getString("SELECT_VENDOR_PRODUCT_LIST"));
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
data.add(new Pair<String, String>(rs.getString(1), rs.getString(2)));
|
||||
@@ -342,7 +239,7 @@ public class CveDB {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
ps = getConnection().prepareStatement(SELECT_PROPERTIES);
|
||||
ps = getConnection().prepareStatement(statementBundle.getString("SELECT_PROPERTIES"));
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
prop.setProperty(rs.getString(1), rs.getString(2));
|
||||
@@ -368,8 +265,8 @@ public class CveDB {
|
||||
PreparedStatement insertProperty = null;
|
||||
try {
|
||||
try {
|
||||
updateProperty = getConnection().prepareStatement(UPDATE_PROPERTY);
|
||||
insertProperty = getConnection().prepareStatement(INSERT_PROPERTY);
|
||||
updateProperty = getConnection().prepareStatement(statementBundle.getString("UPDATE_PROPERTY"));
|
||||
insertProperty = getConnection().prepareStatement(statementBundle.getString("INSERT_PROPERTY"));
|
||||
} catch (SQLException ex) {
|
||||
LOGGER.log(Level.WARNING, "Unable to save properties to the database");
|
||||
LOGGER.log(Level.FINE, "Unable to save properties to the database", ex);
|
||||
@@ -408,7 +305,7 @@ public class CveDB {
|
||||
PreparedStatement insertProperty = null;
|
||||
try {
|
||||
try {
|
||||
updateProperty = getConnection().prepareStatement(UPDATE_PROPERTY);
|
||||
updateProperty = getConnection().prepareStatement(statementBundle.getString("UPDATE_PROPERTY"));
|
||||
} catch (SQLException ex) {
|
||||
LOGGER.log(Level.WARNING, "Unable to save properties to the database");
|
||||
LOGGER.log(Level.FINE, "Unable to save properties to the database", ex);
|
||||
@@ -419,7 +316,7 @@ public class CveDB {
|
||||
updateProperty.setString(2, key);
|
||||
if (updateProperty.executeUpdate() == 0) {
|
||||
try {
|
||||
insertProperty = getConnection().prepareStatement(INSERT_PROPERTY);
|
||||
insertProperty = getConnection().prepareStatement(statementBundle.getString("INSERT_PROPERTY"));
|
||||
} catch (SQLException ex) {
|
||||
LOGGER.log(Level.WARNING, "Unable to save properties to the database");
|
||||
LOGGER.log(Level.FINE, "Unable to save properties to the database", ex);
|
||||
@@ -460,7 +357,7 @@ public class CveDB {
|
||||
|
||||
PreparedStatement ps;
|
||||
try {
|
||||
ps = getConnection().prepareStatement(SELECT_CVE_FROM_SOFTWARE);
|
||||
ps = getConnection().prepareStatement(statementBundle.getString("SELECT_CVE_FROM_SOFTWARE"));
|
||||
ps.setString(1, cpe.getVendor());
|
||||
ps.setString(2, cpe.getProduct());
|
||||
rs = ps.executeQuery();
|
||||
@@ -518,7 +415,7 @@ public class CveDB {
|
||||
ResultSet rsS = null;
|
||||
Vulnerability vuln = null;
|
||||
try {
|
||||
psV = getConnection().prepareStatement(SELECT_VULNERABILITY);
|
||||
psV = getConnection().prepareStatement(statementBundle.getString("SELECT_VULNERABILITY"));
|
||||
psV.setString(1, cve);
|
||||
rsV = psV.executeQuery();
|
||||
if (rsV.next()) {
|
||||
@@ -542,13 +439,13 @@ public class CveDB {
|
||||
vuln.setCvssIntegrityImpact(rsV.getString(9));
|
||||
vuln.setCvssAvailabilityImpact(rsV.getString(10));
|
||||
|
||||
psR = getConnection().prepareStatement(SELECT_REFERENCE);
|
||||
psR = getConnection().prepareStatement(statementBundle.getString("SELECT_REFERENCES"));
|
||||
psR.setInt(1, cveId);
|
||||
rsR = psR.executeQuery();
|
||||
while (rsR.next()) {
|
||||
vuln.addReference(rsR.getString(1), rsR.getString(2), rsR.getString(3));
|
||||
}
|
||||
psS = getConnection().prepareStatement(SELECT_SOFTWARE);
|
||||
psS = getConnection().prepareStatement(statementBundle.getString("SELECT_SOFTWARE"));
|
||||
psS.setInt(1, cveId);
|
||||
rsS = psS.executeQuery();
|
||||
while (rsS.next()) {
|
||||
@@ -593,16 +490,18 @@ public class CveDB {
|
||||
PreparedStatement insertSoftware = null;
|
||||
|
||||
try {
|
||||
selectVulnerabilityId = getConnection().prepareStatement(SELECT_VULNERABILITY_ID);
|
||||
deleteVulnerability = getConnection().prepareStatement(DELETE_VULNERABILITY);
|
||||
deleteReferences = getConnection().prepareStatement(DELETE_REFERENCE);
|
||||
deleteSoftware = getConnection().prepareStatement(DELETE_SOFTWARE);
|
||||
updateVulnerability = getConnection().prepareStatement(UPDATE_VULNERABILITY);
|
||||
insertVulnerability = getConnection().prepareStatement(INSERT_VULNERABILITY, Statement.RETURN_GENERATED_KEYS);
|
||||
insertReference = getConnection().prepareStatement(INSERT_REFERENCE);
|
||||
selectCpeId = getConnection().prepareStatement(SELECT_CPE_ID);
|
||||
insertCpe = getConnection().prepareStatement(INSERT_CPE, Statement.RETURN_GENERATED_KEYS);
|
||||
insertSoftware = getConnection().prepareStatement(INSERT_SOFTWARE);
|
||||
selectVulnerabilityId = getConnection().prepareStatement(statementBundle.getString("SELECT_VULNERABILITY_ID"));
|
||||
deleteVulnerability = getConnection().prepareStatement(statementBundle.getString("DELETE_VULNERABILITY"));
|
||||
deleteReferences = getConnection().prepareStatement(statementBundle.getString("DELETE_REFERENCE"));
|
||||
deleteSoftware = getConnection().prepareStatement(statementBundle.getString("DELETE_SOFTWARE"));
|
||||
updateVulnerability = getConnection().prepareStatement(statementBundle.getString("UPDATE_VULNERABILITY"));
|
||||
insertVulnerability = getConnection().prepareStatement(statementBundle.getString("INSERT_VULNERABILITY"),
|
||||
Statement.RETURN_GENERATED_KEYS);
|
||||
insertReference = getConnection().prepareStatement(statementBundle.getString("INSERT_REFERENCE"));
|
||||
selectCpeId = getConnection().prepareStatement(statementBundle.getString("SELECT_CPE_ID"));
|
||||
insertCpe = getConnection().prepareStatement(statementBundle.getString("INSERT_CPE"),
|
||||
Statement.RETURN_GENERATED_KEYS);
|
||||
insertSoftware = getConnection().prepareStatement(statementBundle.getString("INSERT_SOFTWARE"));
|
||||
int vulnerabilityId = 0;
|
||||
selectVulnerabilityId.setString(1, vuln.getName());
|
||||
ResultSet rs = selectVulnerabilityId.executeQuery();
|
||||
@@ -762,7 +661,7 @@ public class CveDB {
|
||||
public void cleanupDatabase() {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
ps = getConnection().prepareStatement(CLEANUP_ORPHANS);
|
||||
ps = getConnection().prepareStatement(statementBundle.getString("CLEANUP_ORPHANS"));
|
||||
if (ps != null) {
|
||||
ps.executeUpdate();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.data.nvdcve;
|
||||
/**
|
||||
* An exception thrown if an operation against the database fails.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DatabaseException extends Exception {
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.owasp.dependencycheck.data.update.exception.UpdateException;
|
||||
/**
|
||||
* This is a wrapper around a set of properties that are stored in the database.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DatabaseProperties {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.data.nvdcve;
|
||||
/**
|
||||
* An exception thrown the database driver is unable to be loaded.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DriverLoadException extends Exception {
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.logging.Logger;
|
||||
/**
|
||||
* DriverLoader is a utility class that is used to load database drivers.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public final class DriverLoader {
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.logging.Logger;
|
||||
* copy (with more comments and a few more methods implemented) of the DriverShim from:</p>
|
||||
* <blockquote>http://www.kfu.com/~nsayer/Java/dyn-jdbc.html</blockquote>
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
* @see java.sql.Driver
|
||||
*/
|
||||
class DriverShim implements Driver {
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.nvdcve</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* Contains classes used to work with the NVD CVE data.
|
||||
* </body>
|
||||
* </html>
|
||||
*/
|
||||
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.nvdcve;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.owasp.dependencycheck.data.update.exception.UpdateException;
|
||||
* Defines a data source who's data is retrieved from the Internet. This data can be downloaded and the local cache
|
||||
* updated.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public interface CachedWebDataSource {
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.owasp.dependencycheck.utils.URLConnectionFailureException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class EngineVersionCheck implements CachedWebDataSource {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.data.update;
|
||||
/**
|
||||
* A pojo that contains the Url and timestamp of the current NvdCve XML files.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class NvdCveInfo {
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* Class responsible for updating the NVD CVE and CPE data stores.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class NvdCveUpdater implements CachedWebDataSource {
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* Class responsible for updating the NVDCVE data store.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class StandardUpdate {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.ServiceLoader;
|
||||
* The CachedWebDataSource Service Loader. This class loads all services that implement
|
||||
* org.owasp.dependencycheck.data.update.CachedWebDataSource.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class UpdateService {
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.owasp.dependencycheck.utils.Downloader;
|
||||
* Contains a collection of updateable NvdCveInfo objects. This is used to determine which files need to be downloaded
|
||||
* and processed.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class UpdateableNvdCve implements java.lang.Iterable<NvdCveInfo>, Iterator<NvdCveInfo> {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.data.update.exception;
|
||||
/**
|
||||
* An InvalidDataDataException is a generic exception used when trying to load the NVD CVE meta data.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class InvalidDataException extends Exception {
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* An exception used when an error occurs reading a setting.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class UpdateException extends IOException {
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.update.exception</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>A collection of exception classes used within the application.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
*
|
||||
* A collection of exception classes used within the application.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.update.exception;
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.update</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>Contains classes used to update the data stores.</p>
|
||||
* <p>The UpdateService will load, any correctly defined CachedWebDataSource(s)
|
||||
* and call update() on them. The Cached Data Source must determine if it needs
|
||||
* to be updated and if so perform the update. The sub packages contain classes
|
||||
* used to perform the actual updates.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
*
|
||||
* Contains classes used to update the data stores.<br/><br/>
|
||||
*
|
||||
* The UpdateService will load, any correctly defined CachedWebDataSource(s) and call update() on them. The Cached Data Source
|
||||
* must determine if it needs to be updated and if so perform the update. The sub packages contain classes used to perform the
|
||||
* actual updates.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.update;
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
/**
|
||||
* A callable object to download two files.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class DownloadTask implements Callable<Future<ProcessTask>> {
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.xml.sax.SAXException;
|
||||
/**
|
||||
* A callable task that will process a given set of NVD CVE xml files and update the Cve Database accordingly.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class ProcessTask implements Callable<ProcessTask> {
|
||||
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.update.task</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>A collection of callable/runnable tasks used to speed up the update
|
||||
* process.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
* A collection of callable/runnable tasks used to speed up the update process.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.update.task;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
* CPEs that have previous versions specified. The previous version information is not in the 2.0 version of the schema
|
||||
* and is useful to ensure accurate identification (or at least complete).
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class NvdCve12Handler extends DefaultHandler {
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.xml.sax.helpers.DefaultHandler;
|
||||
/**
|
||||
* A SAX Handler that will parse the NVD CVE XML (schema version 2.0).
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public class NvdCve20Handler extends DefaultHandler {
|
||||
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
/**
|
||||
* <html>
|
||||
* <head>
|
||||
* <title>org.owasp.dependencycheck.data.nvdcve.xml</title>
|
||||
* </head>
|
||||
* <body>
|
||||
* <p>Contains classes used to parse the NVD CVE XML file.</p>
|
||||
* <p>The basic use is that the Importer is called to import an NVD CVE file.
|
||||
* The Importer instantiates an Indexer object (which extends Index). The
|
||||
* Indexer creates a partial-unmarshalling SAX parser (implemented in the
|
||||
* NvdCveXmlFilter) that extracts VulnerabilityTypes (aka Entry) from the NVD
|
||||
* CVE data file and stores these into a Lucene Index.</p>
|
||||
* </body>
|
||||
* </html>
|
||||
* Contains classes used to parse the NVD CVE XML file.<br/><br/>
|
||||
*
|
||||
* The basic use is that the Importer is called to import an NVD CVE file. The Importer instantiates an Indexer object (which
|
||||
* extends Index). The Indexer creates a partial-unmarshalling SAX parser (implemented in the NvdCveXmlFilter) that extracts
|
||||
* VulnerabilityTypes (aka Entry) from the NVD CVE data file and stores these into a Lucene Index.
|
||||
*/
|
||||
package org.owasp.dependencycheck.data.update.xml;
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.owasp.dependencycheck.dependency;
|
||||
/**
|
||||
* A confidence enumeration.
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
public enum Confidence {
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user