diff --git a/archive-analyzer.html b/archive-analyzer.html index 33e3dd1a9..ba93a0edd 100644 --- a/archive-analyzer.html +++ b/archive-analyzer.html @@ -1,13 +1,13 @@ - + dependency-check - Archive Analyzer @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/assembly-analyzer.html b/assembly-analyzer.html index e8ef84813..e8d457784 100644 --- a/assembly-analyzer.html +++ b/assembly-analyzer.html @@ -1,13 +1,13 @@ - + dependency-check - Assembly Analyzer @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/apidocs/allclasses-frame.html b/dependency-check-ant/apidocs/allclasses-frame.html index 50c63a6c9..cbe39fc7c 100644 --- a/dependency-check-ant/apidocs/allclasses-frame.html +++ b/dependency-check-ant/apidocs/allclasses-frame.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Ant Task 1.2.5 API) - +All Classes (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/allclasses-noframe.html b/dependency-check-ant/apidocs/allclasses-noframe.html index 43c5b59f2..9df6a8cdb 100644 --- a/dependency-check-ant/apidocs/allclasses-noframe.html +++ b/dependency-check-ant/apidocs/allclasses-noframe.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Ant Task 1.2.5 API) - +All Classes (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/constant-values.html b/dependency-check-ant/apidocs/constant-values.html index f667a297d..dcc375f31 100644 --- a/dependency-check-ant/apidocs/constant-values.html +++ b/dependency-check-ant/apidocs/constant-values.html @@ -2,16 +2,16 @@ - + -Constant Field Values (Dependency-Check Ant Task 1.2.5 API) - +Constant Field Values (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/deprecated-list.html b/dependency-check-ant/apidocs/deprecated-list.html index c10206c9e..3fd0dbe73 100644 --- a/dependency-check-ant/apidocs/deprecated-list.html +++ b/dependency-check-ant/apidocs/deprecated-list.html @@ -2,16 +2,16 @@ - + -Deprecated List (Dependency-Check Ant Task 1.2.5 API) - +Deprecated List (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/help-doc.html b/dependency-check-ant/apidocs/help-doc.html index cd287cb31..5f6d082b0 100644 --- a/dependency-check-ant/apidocs/help-doc.html +++ b/dependency-check-ant/apidocs/help-doc.html @@ -2,16 +2,16 @@ - + -API Help (Dependency-Check Ant Task 1.2.5 API) - +API Help (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/index-all.html b/dependency-check-ant/apidocs/index-all.html index c0d471465..91f6db4d2 100644 --- a/dependency-check-ant/apidocs/index-all.html +++ b/dependency-check-ant/apidocs/index-all.html @@ -2,16 +2,16 @@ - + -Index (Dependency-Check Ant Task 1.2.5 API) - +Index (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/index.html b/dependency-check-ant/apidocs/index.html index 2230f6272..52743f7ce 100644 --- a/dependency-check-ant/apidocs/index.html +++ b/dependency-check-ant/apidocs/index.html @@ -2,9 +2,9 @@ - + -Dependency-Check Ant Task 1.2.5 API +Dependency-Check Ant Task 1.2.6 API diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/DependencyCheckTask.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/DependencyCheckTask.html index d7a9872f5..8bfa2dc12 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/DependencyCheckTask.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/DependencyCheckTask.html @@ -2,16 +2,16 @@ - + -DependencyCheckTask (Dependency-Check Ant Task 1.2.5 API) - +DependencyCheckTask (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.ReportFormats.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.ReportFormats.html index e64ffa796..dc1f5f730 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.ReportFormats.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.ReportFormats.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.taskdefs.DependencyCheckTask.ReportFormats (Dependency-Check Ant Task 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.taskdefs.DependencyCheckTask.ReportFormats (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.html index 99132a56f..940f42ac9 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/class-use/DependencyCheckTask.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.taskdefs.DependencyCheckTask (Dependency-Check Ant Task 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.taskdefs.DependencyCheckTask (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-frame.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-frame.html index baaf286c7..44f6e3b9d 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-frame.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-frame.html @@ -2,10 +2,10 @@ - + -org.owasp.dependencycheck.taskdefs (Dependency-Check Ant Task 1.2.5 API) - +org.owasp.dependencycheck.taskdefs (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-summary.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-summary.html index 8caf22ce1..c565c1db8 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-summary.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-summary.html @@ -2,16 +2,16 @@ - + -org.owasp.dependencycheck.taskdefs (Dependency-Check Ant Task 1.2.5 API) - +org.owasp.dependencycheck.taskdefs (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-tree.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-tree.html index 66fc9c6de..6f545e93c 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-tree.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-tree.html @@ -2,16 +2,16 @@ - + -org.owasp.dependencycheck.taskdefs Class Hierarchy (Dependency-Check Ant Task 1.2.5 API) - +org.owasp.dependencycheck.taskdefs Class Hierarchy (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-use.html b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-use.html index 3f641de56..4e1febb90 100644 --- a/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-use.html +++ b/dependency-check-ant/apidocs/org/owasp/dependencycheck/taskdefs/package-use.html @@ -2,16 +2,16 @@ - + -Uses of Package org.owasp.dependencycheck.taskdefs (Dependency-Check Ant Task 1.2.5 API) - +Uses of Package org.owasp.dependencycheck.taskdefs (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/apidocs/overview-tree.html b/dependency-check-ant/apidocs/overview-tree.html index 0328b9001..47007c6d2 100644 --- a/dependency-check-ant/apidocs/overview-tree.html +++ b/dependency-check-ant/apidocs/overview-tree.html @@ -2,16 +2,16 @@ - + -Class Hierarchy (Dependency-Check Ant Task 1.2.5 API) - +Class Hierarchy (Dependency-Check Ant Task 1.2.6 API) + diff --git a/dependency-check-ant/checkstyle.html b/dependency-check-ant/checkstyle.html index a99ade9dd..241e3ba03 100644 --- a/dependency-check-ant/checkstyle.html +++ b/dependency-check-ant/checkstyle.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Checkstyle Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/cobertura/frame-summary-org.owasp.dependencycheck.taskdefs.html b/dependency-check-ant/cobertura/frame-summary-org.owasp.dependencycheck.taskdefs.html index b730975ba..5a8d726a4 100644 --- a/dependency-check-ant/cobertura/frame-summary-org.owasp.dependencycheck.taskdefs.html +++ b/dependency-check-ant/cobertura/frame-summary-org.owasp.dependencycheck.taskdefs.html @@ -38,6 +38,6 @@ var classTable = new SortableTable(document.getElementById("classResults"), ["String", "Percentage", "Percentage", "FormattedNumber"]); classTable.sort(0); - + diff --git a/dependency-check-ant/cobertura/frame-summary.html b/dependency-check-ant/cobertura/frame-summary.html index 4669a7aac..a6551af63 100644 --- a/dependency-check-ant/cobertura/frame-summary.html +++ b/dependency-check-ant/cobertura/frame-summary.html @@ -25,6 +25,6 @@ var packageTable = new SortableTable(document.getElementById("packageResults"), ["String", "Number", "Percentage", "Percentage", "FormattedNumber"]); packageTable.sort(0); - + diff --git a/dependency-check-ant/cobertura/org.owasp.dependencycheck.taskdefs.DependencyCheckTask.html b/dependency-check-ant/cobertura/org.owasp.dependencycheck.taskdefs.DependencyCheckTask.html index 934f1a323..e71792ba6 100644 --- a/dependency-check-ant/cobertura/org.owasp.dependencycheck.taskdefs.DependencyCheckTask.html +++ b/dependency-check-ant/cobertura/org.owasp.dependencycheck.taskdefs.DependencyCheckTask.html @@ -2062,15 +2062,15 @@  1111  4
                     summary.append(d.getFileName()).append(" (");
     1112  4
                     firstEntry = true;
     1113  4
                     for (Identifier id : d.getIdentifiers()) {
    -  1114  11
                         if (firstEntry) {
    +  1114  15
                         if (firstEntry) {
     1115  4
                             firstEntry = false;
     1116  
                         } else {
    -  1117  7
                             summary.append(", ");
    +  1117  11
                             summary.append(", ");
     1118  
                         }
    -  1119  11
                         summary.append(id.getValue());
    -  1120  11
                     }
    +  1119  15
                         summary.append(id.getValue());
    +  1120  15
                     }
     1121  4
                     summary.append(") : ").append(ids).append(NEW_LINE);
     1122  
                 }
    @@ -2154,6 +2154,6 @@
     }
    - + diff --git a/dependency-check-ant/configuration.html b/dependency-check-ant/configuration.html index 7c2e7bce0..78c0efa1c 100644 --- a/dependency-check-ant/configuration.html +++ b/dependency-check-ant/configuration.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Configuration @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -357,9 +357,9 @@ nexusUrl -Defines the Nexus URL. +Defines the Nexus Pro URL. If not set the Nexus Analyzer will be disabled. -https://repository.sonatype.org/service/local/ +  @@ -393,7 +393,7 @@ pathToMono -The path to Mono for .NET assembly analysis on non-windows systems +The path to Mono for .NET assembly analysis on non-windows systems.   diff --git a/dependency-check-ant/cpd.html b/dependency-check-ant/cpd.html index 2799443f4..abbd0f4aa 100644 --- a/dependency-check-ant/cpd.html +++ b/dependency-check-ant/cpd.html @@ -1,13 +1,13 @@ - + dependency-check-ant - CPD Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/dependency-updates-report.html b/dependency-check-ant/dependency-updates-report.html index 79acd24f5..23167cfe1 100644 --- a/dependency-check-ant/dependency-updates-report.html +++ b/dependency-check-ant/dependency-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Dependency Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -327,7 +327,7 @@ org.owasp dependency-check-core -1.2.5 +1.2.6 compile jar @@ -339,7 +339,7 @@ org.owasp dependency-check-utils -1.2.5 +1.2.6 compile jar @@ -388,7 +388,7 @@ jar Newer versions -4.12-beta-1 Next Incremental +4.12-beta-1 Next Incremental
    4.12-beta-2
    4.12-beta-3 Latest Incremental

    org.apache.ant:ant

    @@ -457,7 +457,7 @@ - + @@ -481,7 +481,7 @@ - + diff --git a/dependency-check-ant/findbugs.html b/dependency-check-ant/findbugs.html index 1aed036a4..e4aebd198 100644 --- a/dependency-check-ant/findbugs.html +++ b/dependency-check-ant/findbugs.html @@ -1,13 +1,13 @@ - + dependency-check-ant - FindBugs Bug Detector Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/index.html b/dependency-check-ant/index.html index e9f02ff6a..6ab207f99 100644 --- a/dependency-check-ant/index.html +++ b/dependency-check-ant/index.html @@ -1,13 +1,13 @@ - + dependency-check-ant - About @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/installation.html b/dependency-check-ant/installation.html index 78c1d4144..41d580952 100644 --- a/dependency-check-ant/installation.html +++ b/dependency-check-ant/installation.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Installation @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -160,7 +160,7 @@

    Installation

    -

    Download dependency-check-ant from bintray here. To install dependency-check-ant place the dependency-check-ant-1.2.5.jar into the lib directory of your Ant instalation directory. Once installed you can add the taskdef to you build.xml and add the task to a new or existing target:

    +

    Download dependency-check-ant from bintray here. To install dependency-check-ant place the dependency-check-ant-1.2.6.jar into the lib directory of your Ant instalation directory. Once installed you can add the taskdef to you build.xml and add the task to a new or existing target:

    <taskdef name="dependency-check" classname="org.owasp.dependencycheck.taskdefs.DependencyCheckTask"/>
    @@ -169,7 +169,7 @@
     
     
    <taskdef name="dependency-check" classname="org.owasp.dependencycheck.taskdefs.DependencyCheckTask">
    -    <classpath path="[path]/[to]/dependency-check-ant-1.2.5.jar"/>
    +    <classpath path="[path]/[to]/dependency-check-ant-1.2.6.jar"/>
     </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 Vulnerability Database (NVD) hosted by NIST: https://nvd.nist.gov

    diff --git a/dependency-check-ant/license.html b/dependency-check-ant/license.html index d8a26bbec..364a0e877 100644 --- a/dependency-check-ant/license.html +++ b/dependency-check-ant/license.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Project License @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/plugin-updates-report.html b/dependency-check-ant/plugin-updates-report.html index 286364ab9..3ee80aa8c 100644 --- a/dependency-check-ant/plugin-updates-report.html +++ b/dependency-check-ant/plugin-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Plugin Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -252,7 +252,7 @@
    - + @@ -264,7 +264,7 @@ - + @@ -350,13 +350,13 @@ - + - - + + @@ -370,13 +370,13 @@ - + - - + + @@ -400,23 +400,23 @@ - + - - + + - + - - + + @@ -440,13 +440,13 @@ - + - - + + @@ -477,7 +477,7 @@
    dependency-check-core
    Current Version1.2.5
    1.2.6
    Scope compile
    dependency-check-utils
    Current Version1.2.5
    1.2.6
    Scope compile
    # of plugins using the latest version available6
    1
    # of plugins where the next version available is smaller than an incremental version update
    # of plugins where the next version available is a minor version update8
    13
    # of plugins where the next version available is a major version updateNext Major Dependency status
    com.github.github site-maven-plugin0.90.9 0.10
    org.apache.maven.plugins maven-compiler-plugin3.13.1 3.2
    org.apache.maven.plugins maven-jar-plugin2.42.4 2.5
    org.apache.maven.plugins maven-resources-plugin2.62.6 2.7
    org.apache.maven.plugins maven-surefire-plugin2.162.16 2.17
    - + @@ -486,7 +486,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id com.github.github
    site-maven-plugin
    Current Version0.9
    +0.9 + +Newer versions +0.10 Next Minor

    Plugin org.apache.maven.plugins:maven-antrun-plugin

    @@ -522,7 +525,7 @@ -
    2.2-beta-5
    Newer versions2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4 Latest Minor
    +2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4
    2.4.1
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-clean-plugin

    @@ -540,13 +543,13 @@ -
    2.4.1
    Newer versions2.5 Next Minor
    +2.5 Next Minor
    2.6
    2.6.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-compiler-plugin

    - + @@ -555,7 +558,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-compiler-plugin
    Current Version3.1
    +3.1 + +Newer versions +3.2 Next Minor

    Plugin org.apache.maven.plugins:maven-dependency-plugin

    @@ -573,7 +579,7 @@ -
    2.1
    Newer versions2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8 Latest Minor
    +2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8
    2.9 Latest Minor

    Plugin org.apache.maven.plugins:maven-deploy-plugin

    @@ -591,7 +597,7 @@ -
    2.7
    Newer versions2.8 Next Minor
    2.8.1 Latest Minor
    +2.8 Next Minor
    2.8.1
    2.8.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-install-plugin

    @@ -609,13 +615,13 @@ -
    2.3.1
    Newer versions2.4 Next Minor
    2.5
    2.5.1 Latest Minor
    +2.4 Next Minor
    2.5
    2.5.1
    2.5.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-jar-plugin

    - + @@ -624,7 +630,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-jar-plugin
    Current Version2.4
    +2.4 + +Newer versions +2.5 Next Minor

    Plugin org.apache.maven.plugins:maven-release-plugin

    @@ -642,13 +651,13 @@ -
    2.0
    Newer versions2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2 Latest Minor
    +2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-resources-plugin

    - + @@ -657,7 +666,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-resources-plugin
    Current Version2.6
    +2.6 + +Newer versions +2.7 Next Minor

    Plugin org.apache.maven.plugins:maven-shade-plugin

    @@ -675,7 +687,7 @@ -
    2.1
    Newer versions2.2 Next Minor
    +2.2 Next Minor
    2.3 Latest Minor

    Plugin org.apache.maven.plugins:maven-site-plugin

    @@ -759,7 +771,7 @@
    - + @@ -768,7 +780,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-surefire-plugin
    Current Version2.16
    +2.16 + +Newer versions +2.17 Next Minor
    2.18 Latest Minor

    Plugin org.codehaus.mojo:cobertura-maven-plugin

    diff --git a/dependency-check-ant/pmd.html b/dependency-check-ant/pmd.html index 9e5fd77f1..f4f88419d 100644 --- a/dependency-check-ant/pmd.html +++ b/dependency-check-ant/pmd.html @@ -1,13 +1,13 @@ - + dependency-check-ant - PMD Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/project-info.html b/dependency-check-ant/project-info.html index f350529a0..922f72eef 100644 --- a/dependency-check-ant/project-info.html +++ b/dependency-check-ant/project-info.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Project Information @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/project-reports.html b/dependency-check-ant/project-reports.html index 493317185..e7977394e 100644 --- a/dependency-check-ant/project-reports.html +++ b/dependency-check-ant/project-reports.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Generated Reports @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/project-summary.html b/dependency-check-ant/project-summary.html index cb868e7e7..6ba4b9deb 100644 --- a/dependency-check-ant/project-summary.html +++ b/dependency-check-ant/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Project Summary @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -225,7 +225,7 @@ - + diff --git a/dependency-check-ant/surefire-report.html b/dependency-check-ant/surefire-report.html index ca29a71ab..efa828d10 100644 --- a/dependency-check-ant/surefire-report.html +++ b/dependency-check-ant/surefire-report.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Surefire Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -281,7 +281,7 @@ function toggleDisplay(elementId) { -
    dependency-check-ant
    Version1.2.5
    1.2.6
    Type jar
    0 0 100%64.47

    +32.839

    Note: failures are anticipated and checked for with assertions while errors are unanticipated.


    Package List

    @@ -302,7 +302,7 @@ function toggleDisplay(elementId) { 0 0 100% -64.47
    +32.839

    Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.

    org.owasp.dependencycheck.taskdefs

    @@ -324,7 +324,7 @@ function toggleDisplay(elementId) { 0 0 100% -64.47

    +32.839

    Test Cases

    [Summary] [Package List] [Test Cases]

    @@ -334,19 +334,19 @@ function toggleDisplay(elementId) { testGetFailBuildOnCVSS -0.833 +0.816 testAddDirSet -30.55 +12.783 testAddFileSet -17.502 +10.038 testAddFileList -15.585

    +9.202
    diff --git a/dependency-check-ant/taglist.html b/dependency-check-ant/taglist.html index bfb88281b..776d1dce7 100644 --- a/dependency-check-ant/taglist.html +++ b/dependency-check-ant/taglist.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Tag List report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-ant/usage.html b/dependency-check-ant/usage.html index 02db78353..a968c55b3 100644 --- a/dependency-check-ant/usage.html +++ b/dependency-check-ant/usage.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Usage @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -169,7 +169,7 @@
    <taskdef name="dependency-check" classname="org.owasp.dependencycheck.taskdefs.DependencyCheckTask">
    -    <classpath path="[path]/[to]/dependency-check-ant-1.2.5.jar"/>
    +    <classpath path="[path]/[to]/dependency-check-ant-1.2.6.jar"/>
     </taskdef>
     

    Next, add the task to a target of your choosing:

    diff --git a/dependency-check-ant/xref-test/index.html b/dependency-check-ant/xref-test/index.html index ac066043b..b4c39044c 100644 --- a/dependency-check-ant/xref-test/index.html +++ b/dependency-check-ant/xref-test/index.html @@ -4,7 +4,7 @@ - Dependency-Check Ant Task 1.2.5 Reference + Dependency-Check Ant Task 1.2.6 Reference diff --git a/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-frame.html b/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-frame.html index 6f49ff0f3..6df70f0f1 100644 --- a/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-frame.html +++ b/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference Package org.owasp.dependencycheck.taskdefs + Dependency-Check Ant Task 1.2.6 Reference Package org.owasp.dependencycheck.taskdefs diff --git a/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-summary.html b/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-summary.html index 5411e49e2..0b5ba422e 100644 --- a/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-summary.html +++ b/dependency-check-ant/xref-test/org/owasp/dependencycheck/taskdefs/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference Package org.owasp.dependencycheck.taskdefs + Dependency-Check Ant Task 1.2.6 Reference Package org.owasp.dependencycheck.taskdefs diff --git a/dependency-check-ant/xref-test/overview-frame.html b/dependency-check-ant/xref-test/overview-frame.html index f8824867d..02dd8533b 100644 --- a/dependency-check-ant/xref-test/overview-frame.html +++ b/dependency-check-ant/xref-test/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference + Dependency-Check Ant Task 1.2.6 Reference diff --git a/dependency-check-ant/xref-test/overview-summary.html b/dependency-check-ant/xref-test/overview-summary.html index 8bc76ebab..89d2c6915 100644 --- a/dependency-check-ant/xref-test/overview-summary.html +++ b/dependency-check-ant/xref-test/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference + Dependency-Check Ant Task 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Ant Task 1.2.5 Reference

    +

    Dependency-Check Ant Task 1.2.6 Reference

    diff --git a/dependency-check-ant/xref/index.html b/dependency-check-ant/xref/index.html index ac066043b..b4c39044c 100644 --- a/dependency-check-ant/xref/index.html +++ b/dependency-check-ant/xref/index.html @@ -4,7 +4,7 @@ - Dependency-Check Ant Task 1.2.5 Reference + Dependency-Check Ant Task 1.2.6 Reference diff --git a/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-frame.html b/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-frame.html index 78b962306..ca9bf8de5 100644 --- a/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-frame.html +++ b/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference Package org.owasp.dependencycheck.taskdefs + Dependency-Check Ant Task 1.2.6 Reference Package org.owasp.dependencycheck.taskdefs diff --git a/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-summary.html b/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-summary.html index 5d37f4f61..855301bf9 100644 --- a/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-summary.html +++ b/dependency-check-ant/xref/org/owasp/dependencycheck/taskdefs/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference Package org.owasp.dependencycheck.taskdefs + Dependency-Check Ant Task 1.2.6 Reference Package org.owasp.dependencycheck.taskdefs diff --git a/dependency-check-ant/xref/overview-frame.html b/dependency-check-ant/xref/overview-frame.html index f8824867d..02dd8533b 100644 --- a/dependency-check-ant/xref/overview-frame.html +++ b/dependency-check-ant/xref/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference + Dependency-Check Ant Task 1.2.6 Reference diff --git a/dependency-check-ant/xref/overview-summary.html b/dependency-check-ant/xref/overview-summary.html index 8bc76ebab..89d2c6915 100644 --- a/dependency-check-ant/xref/overview-summary.html +++ b/dependency-check-ant/xref/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Ant Task 1.2.5 Reference + Dependency-Check Ant Task 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Ant Task 1.2.5 Reference

    +

    Dependency-Check Ant Task 1.2.6 Reference

    diff --git a/dependency-check-cli/apidocs/allclasses-frame.html b/dependency-check-cli/apidocs/allclasses-frame.html index 12232ef5b..ec06db5c5 100644 --- a/dependency-check-cli/apidocs/allclasses-frame.html +++ b/dependency-check-cli/apidocs/allclasses-frame.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Command Line 1.2.5 API) - +All Classes (Dependency-Check Command Line 1.2.6 API) + @@ -13,8 +13,8 @@
    diff --git a/dependency-check-cli/apidocs/allclasses-noframe.html b/dependency-check-cli/apidocs/allclasses-noframe.html index ed6533361..c6099bbb9 100644 --- a/dependency-check-cli/apidocs/allclasses-noframe.html +++ b/dependency-check-cli/apidocs/allclasses-noframe.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Command Line 1.2.5 API) - +All Classes (Dependency-Check Command Line 1.2.6 API) + @@ -13,8 +13,8 @@
    diff --git a/dependency-check-cli/apidocs/constant-values.html b/dependency-check-cli/apidocs/constant-values.html index 60a5bf912..e93114584 100644 --- a/dependency-check-cli/apidocs/constant-values.html +++ b/dependency-check-cli/apidocs/constant-values.html @@ -2,16 +2,16 @@ - + -Constant Field Values (Dependency-Check Command Line 1.2.5 API) - +Constant Field Values (Dependency-Check Command Line 1.2.6 API) + @@ -25,11 +25,10 @@
    - + @@ -85,304 +84,311 @@ - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + + + + + + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + @@ -397,11 +403,10 @@ - @@ -98,11 +97,10 @@
    org.owasp.dependencycheck.cli.CliParser.ARGUMENT org.owasp.dependencycheck.CliParser.ARGUMENT 
    Modifier and Type Constant Field
    + public static final StringADDITIONAL_ZIP_EXTENSIONSADDITIONAL_ZIP_EXTENSIONS "zipExtensions"
    + public static final StringADVANCED_HELPADVANCED_HELP "advancedHelp"
    + public static final StringAPP_NAMEAPP_NAME "app"
    + public static final StringAPP_NAME_SHORTAPP_NAME_SHORT "a"
    + public static final StringCONNECTION_STRINGCONNECTION_STRING "connectionString"
    + public static final StringCONNECTION_TIMEOUTCONNECTION_TIMEOUT "connectiontimeout"
    + public static final StringCONNECTION_TIMEOUT_SHORTCONNECTION_TIMEOUT_SHORT "c"
    + public static final StringDATA_DIRECTORYDATA_DIRECTORY "data"
    + public static final StringDATA_DIRECTORY_SHORTDATA_DIRECTORY_SHORT "d"
    + public static final StringDB_DRIVERDB_DRIVER "dbDriverName"
    + public static final StringDB_DRIVER_PATHDB_DRIVER_PATH "dbDriverPath"
    + public static final StringDB_NAMEDB_NAME "dbUser"
    + public static final StringDB_PASSWORDDB_PASSWORD "dbPassword"
    + public static final StringDISABLE_ARCHIVEDISABLE_ARCHIVE "disableArchive"
    + public static final StringDISABLE_ASSEMBLYDISABLE_ASSEMBLY "disableAssembly"
    + public static final StringDISABLE_AUTO_UPDATEDISABLE_AUTO_UPDATE "noupdate"
    + public static final StringDISABLE_AUTO_UPDATE_SHORTDISABLE_AUTO_UPDATE_SHORT "n"
    + public static final StringDISABLE_JARDISABLE_JAR "disableJar"
    + public static final StringDISABLE_NEXUSDISABLE_NEXUS "disableNexus"
    + public static final StringDISABLE_NUSPECDISABLE_NUSPEC "disableNuspec"
    + public static final StringHELPEXCLUDE"exclude"
    + +public static final StringHELP "help"
    +
    public static final StringHELP_SHORTHELP_SHORT "h"
    +
    public static final StringNEXUS_URLNEXUS_URL "nexus"
    +
    public static final StringNEXUS_USES_PROXYNEXUS_USES_PROXY "nexusUsesProxy"
    +
    public static final StringOUTOUT "out"
    +
    public static final StringOUT_SHORTOUT_SHORT "o"
    +
    public static final StringOUTPUT_FORMATOUTPUT_FORMAT "format"
    +
    public static final StringOUTPUT_FORMAT_SHORTOUTPUT_FORMAT_SHORT "f"
    +
    public static final StringPATH_TO_MONOPATH_TO_MONO "mono"
    +
    public static final StringPROPPROP "propertyfile"
    +
    public static final StringPROP_SHORTPROP_SHORT "P"
    +
    public static final StringPROXY_PASSWORDPROXY_PASSWORD "proxypass"
    +
    public static final StringPROXY_PORTPROXY_PORT "proxyport"
    +
    public static final StringPROXY_SERVERPROXY_SERVER "proxyserver"
    +
    public static final StringPROXY_URLPROXY_URL "proxyurl"
    +
    public static final StringPROXY_USERNAMEPROXY_USERNAME "proxyuser"
    +
    public static final StringSCANSCAN "scan"
    +
    public static final StringSCAN_SHORTSCAN_SHORT "s"
    +
    public static final StringSUPPRESSION_FILESUPPRESSION_FILE "suppression"
    +
    public static final StringVERBOSE_LOGVERBOSE_LOG "log"
    +
    public static final StringVERBOSE_LOG_SHORTVERBOSE_LOG_SHORT "l"
    +
    public static final StringVERSIONVERSION "version"
    +
    public static final StringVERSION_SHORTVERSION_SHORT "v"
    org.owasp.dependencycheck.cli.CliParser.ARGUMENT.PROXY_URL +org.owasp.dependencycheck.CliParser.ARGUMENT.PROXY_URL
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Fields 
    Modifier and TypeField and Description
    static StringADDITIONAL_ZIP_EXTENSIONS +
    The CLI argument name for setting extra extensions.
    +
    static StringADVANCED_HELP +
    The long CLI argument name asking for advanced help.
    +
    static StringAPP_NAME +
    The long CLI argument name specifying the name of the application to be scanned.
    +
    static StringAPP_NAME_SHORT +
    The short CLI argument name specifying the name of the application to be scanned.
    +
    static StringCONNECTION_STRING +
    The CLI argument name for setting the connection string.
    +
    static StringCONNECTION_TIMEOUT +
    The CLI argument name indicating the connection timeout.
    +
    static StringCONNECTION_TIMEOUT_SHORT +
    The short CLI argument name indicating the connection timeout.
    +
    static StringDATA_DIRECTORY +
    The CLI argument name for setting the location of the data directory.
    +
    static StringDATA_DIRECTORY_SHORT +
    The short CLI argument name for setting the location of the data directory.
    +
    static StringDB_DRIVER +
    The CLI argument name for setting the database driver name.
    +
    static StringDB_DRIVER_PATH +
    The CLI argument name for setting the path to the database driver; in case it is not on the class path.
    +
    static StringDB_NAME +
    The CLI argument name for setting the database user name.
    +
    static StringDB_PASSWORD +
    The CLI argument name for setting the database password.
    +
    static StringDISABLE_ARCHIVE +
    Disables the Archive Analyzer.
    +
    static StringDISABLE_ASSEMBLY +
    Disables the Assembly Analyzer.
    +
    static StringDISABLE_AUTO_UPDATE +
    The long CLI argument name specifying that the CPE/CVE/etc.
    +
    static StringDISABLE_AUTO_UPDATE_SHORT +
    The short CLI argument name specifying that the CPE/CVE/etc.
    +
    static StringDISABLE_JAR +
    Disables the Jar Analyzer.
    +
    static StringDISABLE_NEXUS +
    Disables the Nexus Analyzer.
    +
    static StringDISABLE_NUSPEC +
    Disables the Nuspec Analyzer.
    +
    static StringEXCLUDE +
    Exclude path argument.
    +
    static StringHELP +
    The long CLI argument name asking for help.
    +
    static StringHELP_SHORT +
    The short CLI argument name asking for help.
    +
    static StringNEXUS_URL +
    The URL of the nexus server.
    +
    static StringNEXUS_USES_PROXY +
    Whether or not the defined proxy should be used when connecting to Nexus.
    +
    static StringOUT +
    The long CLI argument name specifying the directory to write the reports to.
    +
    static StringOUT_SHORT +
    The short CLI argument name specifying the directory to write the reports to.
    +
    static StringOUTPUT_FORMAT +
    The long CLI argument name specifying the output format to write the reports to.
    +
    static StringOUTPUT_FORMAT_SHORT +
    The short CLI argument name specifying the output format to write the reports to.
    +
    static StringPATH_TO_MONO +
    The CLI argument name for setting the path to mono for .NET Assembly analysis on non-windows systems.
    +
    static StringPROP +
    The CLI argument name for setting the location of an additional properties file.
    +
    static StringPROP_SHORT +
    The short CLI argument name for setting the location of an additional properties file.
    +
    static StringPROXY_PASSWORD +
    The CLI argument name indicating the proxy password.
    +
    static StringPROXY_PORT +
    The CLI argument name indicating the proxy port.
    +
    static StringPROXY_SERVER +
    The CLI argument name indicating the proxy server.
    +
    static StringPROXY_URL +
    Deprecated.  + +
    +
    static StringPROXY_USERNAME +
    The CLI argument name indicating the proxy username.
    +
    static StringSCAN +
    The long CLI argument name specifying the directory/file to scan.
    +
    static StringSCAN_SHORT +
    The short CLI argument name specifying the directory/file to scan.
    +
    static StringSUPPRESSION_FILE +
    The CLI argument name for setting the location of the suppression file.
    +
    static StringVERBOSE_LOG +
    The CLI argument name for setting the location of the data directory.
    +
    static StringVERBOSE_LOG_SHORT +
    The short CLI argument name for setting the location of the data directory.
    +
    static StringVERSION +
    The short CLI argument name asking for the version.
    +
    static StringVERSION_SHORT +
    The long CLI argument name asking for the version.
    +
    + + + + + + + + + +
    + +
    + + + +
    + + + + + +
    + + +

    Copyright© 2012-14 Jeremy Long. All Rights Reserved.

    + + diff --git a/dependency-check-cli/apidocs/org/owasp/dependencycheck/CliParser.html b/dependency-check-cli/apidocs/org/owasp/dependencycheck/CliParser.html new file mode 100644 index 000000000..9c96832e4 --- /dev/null +++ b/dependency-check-cli/apidocs/org/owasp/dependencycheck/CliParser.html @@ -0,0 +1,872 @@ + + + + + + +CliParser (Dependency-Check Command Line 1.2.6 API) + + + + + + + +
    + + + + + +
    + + + +
    +
    org.owasp.dependencycheck
    +

    Class CliParser

    +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + +
    + + + + + +
    + + +

    Copyright© 2012-14 Jeremy Long. All Rights Reserved.

    + + diff --git a/dependency-check-cli/apidocs/org/owasp/dependencycheck/class-use/App.html b/dependency-check-cli/apidocs/org/owasp/dependencycheck/class-use/App.html index b9e85de77..bc568c288 100644 --- a/dependency-check-cli/apidocs/org/owasp/dependencycheck/class-use/App.html +++ b/dependency-check-cli/apidocs/org/owasp/dependencycheck/class-use/App.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.App (Dependency-Check Command Line 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.App (Dependency-Check Command Line 1.2.6 API) + @@ -25,8 +25,7 @@ @@ -153,7 +153,7 @@

    Installation & Usage

    -

    Download the dependency-check command line tool here. Extract the zip file to a location on your computer and put the ‘bin’ directory into the path environment variable. On *nix systems you will likely need to make the shell script executable:

    +

    Download the dependency-check command line tool here. Extract the zip file to a location on your computer and put the ‘bin’ directory into the path environment variable. On *nix systems you will likely need to make the shell script executable:

    $ chmod +777 dependency-check.sh
    diff --git a/dependency-check-cli/license.html b/dependency-check-cli/license.html
    index f630f70db..d0bd6e8c7 100644
    --- a/dependency-check-cli/license.html
    +++ b/dependency-check-cli/license.html
    @@ -1,13 +1,13 @@
     
     
     
       
         
         
    -    
    +    
         
         dependency-check-cli - Project License
         
    @@ -54,7 +54,7 @@
                     
                         
                                   
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-cli/plugin-updates-report.html b/dependency-check-cli/plugin-updates-report.html index f2b76ddc9..b4a327198 100644 --- a/dependency-check-cli/plugin-updates-report.html +++ b/dependency-check-cli/plugin-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-cli - Plugin Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -238,7 +238,7 @@ # of plugins using the latest version available -6 +2 # of plugins where the next version available is smaller than an incremental version update @@ -250,7 +250,7 @@ # of plugins where the next version available is a minor version update -8 +12 # of plugins where the next version available is a major version update @@ -336,13 +336,13 @@ Next Major Dependency status - + com.github.github site-maven-plugin -0.9 - +0.9 +0.10 @@ -356,13 +356,13 @@ - + org.apache.maven.plugins maven-compiler-plugin -3.1 - +3.1 +3.2 @@ -386,13 +386,13 @@ - + org.apache.maven.plugins maven-jar-plugin -2.4 - +2.4 +2.5 @@ -416,20 +416,20 @@ - + org.apache.maven.plugins maven-surefire-plugin -2.16 - +2.16 +2.17 org.codehaus.mojo appassembler-maven-plugin -1.7 +1.8.1 @@ -463,7 +463,7 @@ - + @@ -472,7 +472,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id com.github.github
    site-maven-plugin
    Current Version0.9
    +0.9 + +Newer versions +0.10 Next Minor

    Plugin org.apache.maven.plugins:maven-antrun-plugin

    @@ -508,7 +511,7 @@ -
    2.2-beta-5
    Newer versions2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4 Latest Minor
    +2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4
    2.4.1
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-clean-plugin

    @@ -526,13 +529,13 @@ -
    2.4.1
    Newer versions2.5 Next Minor
    +2.5 Next Minor
    2.6
    2.6.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-compiler-plugin

    - + @@ -541,7 +544,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-compiler-plugin
    Current Version3.1
    +3.1 + +Newer versions +3.2 Next Minor

    Plugin org.apache.maven.plugins:maven-dependency-plugin

    @@ -559,7 +565,7 @@ -
    2.1
    Newer versions2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8 Latest Minor
    +2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8
    2.9 Latest Minor

    Plugin org.apache.maven.plugins:maven-deploy-plugin

    @@ -577,7 +583,7 @@ -
    2.7
    Newer versions2.8 Next Minor
    2.8.1 Latest Minor
    +2.8 Next Minor
    2.8.1
    2.8.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-install-plugin

    @@ -595,13 +601,13 @@ -
    2.3.1
    Newer versions2.4 Next Minor
    2.5
    2.5.1 Latest Minor
    +2.4 Next Minor
    2.5
    2.5.1
    2.5.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-jar-plugin

    - + @@ -610,7 +616,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-jar-plugin
    Current Version2.4
    +2.4 + +Newer versions +2.5 Next Minor

    Plugin org.apache.maven.plugins:maven-release-plugin

    @@ -628,7 +637,7 @@ -
    2.0
    Newer versions2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2 Latest Minor
    +2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-resources-plugin

    @@ -646,7 +655,7 @@ -
    2.5
    Newer versions2.6 Next Minor
    +2.6 Next Minor
    2.7 Latest Minor

    Plugin org.apache.maven.plugins:maven-site-plugin

    @@ -730,7 +739,7 @@
    - + @@ -739,7 +748,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-surefire-plugin
    Current Version2.16
    +2.16 + +Newer versions +2.17 Next Minor
    2.18 Latest Minor

    Plugin org.codehaus.mojo:appassembler-maven-plugin

    @@ -754,7 +766,7 @@ -
    appassembler-maven-plugin
    Current Version1.7
    +1.8.1

    Plugin org.codehaus.mojo:cobertura-maven-plugin

    diff --git a/dependency-check-cli/pmd.html b/dependency-check-cli/pmd.html index f4a786dd6..4cea21ec3 100644 --- a/dependency-check-cli/pmd.html +++ b/dependency-check-cli/pmd.html @@ -1,13 +1,13 @@ - + dependency-check-cli - PMD Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -237,38 +237,50 @@

    Files

    -

    org/owasp/dependencycheck/cli/CliParser.java

    +

    org/owasp/dependencycheck/App.java

    - - + +
    Violation Line
    Useless parentheses.362
    Logger should be a field, dont chain it103
    +
    +

    org/owasp/dependencycheck/CliParser.java

    + + + + + + + - + - + - + - + - + - + - + -
    ViolationLine
    These nested if statements could be combined146–150
    Useless parentheses.371
    390
    Useless parentheses.380
    399
    Useless parentheses.389
    408
    Useless parentheses.398
    417
    Useless parentheses.407
    426
    Useless parentheses.416
    435
    Useless parentheses.425
    444
    Useless parentheses.643
    +453 + +Useless parentheses. +679 diff --git a/dependency-check-cli/project-info.html b/dependency-check-cli/project-info.html index ba45121ee..aa7e4cfef 100644 --- a/dependency-check-cli/project-info.html +++ b/dependency-check-cli/project-info.html @@ -1,13 +1,13 @@ - + dependency-check-cli - Project Information @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-cli/project-reports.html b/dependency-check-cli/project-reports.html index b8ebbf00e..f3eaec494 100644 --- a/dependency-check-cli/project-reports.html +++ b/dependency-check-cli/project-reports.html @@ -1,13 +1,13 @@ - + dependency-check-cli - Generated Reports @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-cli/project-summary.html b/dependency-check-cli/project-summary.html index 4504685fa..66d3271c4 100644 --- a/dependency-check-cli/project-summary.html +++ b/dependency-check-cli/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check-cli - Project Summary @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -218,7 +218,7 @@ dependency-check-cli Version -1.2.5 +1.2.6 Type jar diff --git a/dependency-check-cli/surefire-report.html b/dependency-check-cli/surefire-report.html index 97d93e5bd..82c3c6293 100644 --- a/dependency-check-cli/surefire-report.html +++ b/dependency-check-cli/surefire-report.html @@ -1,13 +1,13 @@ - + dependency-check-cli - Surefire Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -267,7 +267,7 @@ function toggleDisplay(elementId) { 0 0 100% -0.039
    +0.022

    Note: failures are anticipated and checked for with assertions while errors are unanticipated.


    Package List

    @@ -282,16 +282,16 @@ function toggleDisplay(elementId) { Success Rate Time -org.owasp.dependencycheck.cli +org.owasp.dependencycheck 9 0 0 0 100% -0.039
    +0.022

    Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.

    -

    org.owasp.dependencycheck.cli

    +

    org.owasp.dependencycheck

    @@ -303,32 +303,32 @@ function toggleDisplay(elementId) { - - + + -
    Success Rate Time
    CliParserTestCliParserTest 9 0 0 0 100%0.039

    +0.022

    Test Cases

    [Summary] [Package List] [Test Cases]

    -

    CliParserTest

    +

    CliParserTest

    - + - + - + @@ -336,11 +336,11 @@ function toggleDisplay(elementId) { - + - + @@ -352,7 +352,7 @@ function toggleDisplay(elementId) { -
    testParse_printHelp0.035
    0.019
    testParse_printVersionInfo0.001
    0
    testParse_help0
    0.001
    testParse_scan
    testParse0
    0.002
    testParse_unknown0.001
    0
    testParse_version
    testParse_scan_withFileExists0.002

    +0
    diff --git a/dependency-check-cli/taglist.html b/dependency-check-cli/taglist.html index 4481408e0..7ae8b760a 100644 --- a/dependency-check-cli/taglist.html +++ b/dependency-check-cli/taglist.html @@ -1,13 +1,13 @@ - + dependency-check-cli - Tag List report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -240,20 +240,10 @@ Total number of occurrences Tag strings used by tag class -Todo Work -1 +Todo Work +0 todo, FIXME -

    Each tag is detailed below:

    -
    -

    Todo Work

    -

    Number of occurrences found in the code: 1

    - - - - - - -
    org.owasp.dependencycheck.cli.CliParserLine
    add a validation for *.zip extensions rather then relying on the engine to validate it.144
    +

    Each tag is detailed below:

    diff --git a/dependency-check-cli/xref-test/allclasses-frame.html b/dependency-check-cli/xref-test/allclasses-frame.html index d69c5b09d..0bba97722 100644 --- a/dependency-check-cli/xref-test/allclasses-frame.html +++ b/dependency-check-cli/xref-test/allclasses-frame.html @@ -12,7 +12,7 @@ diff --git a/dependency-check-cli/xref-test/index.html b/dependency-check-cli/xref-test/index.html index feef62db6..dcef10dc8 100644 --- a/dependency-check-cli/xref-test/index.html +++ b/dependency-check-cli/xref-test/index.html @@ -4,7 +4,7 @@ - Dependency-Check Command Line 1.2.5 Reference + Dependency-Check Command Line 1.2.6 Reference diff --git a/dependency-check-cli/xref-test/org/owasp/dependencycheck/CliParserTest.html b/dependency-check-cli/xref-test/org/owasp/dependencycheck/CliParserTest.html new file mode 100644 index 000000000..46a914283 --- /dev/null +++ b/dependency-check-cli/xref-test/org/owasp/dependencycheck/CliParserTest.html @@ -0,0 +1,286 @@ + + + +CliParserTest xref + + + +
    View Javadoc
    +1   /*
    +2    * This file is part of Dependency-Check.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *     http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   *
    +16   * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
    +17   */
    +18  package org.owasp.dependencycheck;
    +19  
    +20  import org.owasp.dependencycheck.CliParser;
    +21  import java.io.ByteArrayOutputStream;
    +22  import java.io.File;
    +23  import java.io.FileNotFoundException;
    +24  import java.io.IOException;
    +25  import java.io.PrintStream;
    +26  import org.apache.commons.cli.ParseException;
    +27  import org.junit.After;
    +28  import org.junit.AfterClass;
    +29  import org.junit.Assert;
    +30  import org.junit.Before;
    +31  import org.junit.BeforeClass;
    +32  import org.junit.Test;
    +33  import org.owasp.dependencycheck.utils.Settings;
    +34  
    +35  /**
    +36   *
    +37   * @author Jeremy Long <jeremy.long@owasp.org>
    +38   */
    +39  public class CliParserTest {
    +40  
    +41      @BeforeClass
    +42      public static void setUpClass() throws Exception {
    +43          Settings.initialize();
    +44      }
    +45  
    +46      @AfterClass
    +47      public static void tearDownClass() throws Exception {
    +48          Settings.cleanup(true);
    +49      }
    +50  
    +51      @Before
    +52      public void setUp() throws Exception {
    +53      }
    +54  
    +55      @After
    +56      public void tearDown() throws Exception {
    +57      }
    +58  
    +59      /**
    +60       * Test of parse method, of class CliParser.
    +61       *
    +62       * @throws Exception thrown when an exception occurs.
    +63       */
    +64      @Test
    +65      public void testParse() throws Exception {
    +66  
    +67          String[] args = {};
    +68          PrintStream out = System.out;
    +69  
    +70          ByteArrayOutputStream baos = new ByteArrayOutputStream();
    +71          System.setOut(new PrintStream(baos));
    +72  
    +73          CliParser instance = new CliParser();
    +74          instance.parse(args);
    +75  
    +76          Assert.assertFalse(instance.isGetVersion());
    +77          Assert.assertFalse(instance.isGetHelp());
    +78          Assert.assertFalse(instance.isRunScan());
    +79      }
    +80  
    +81      /**
    +82       * Test of parse method with help arg, of class CliParser.
    +83       *
    +84       * @throws Exception thrown when an exception occurs.
    +85       */
    +86      @Test
    +87      public void testParse_help() throws Exception {
    +88  
    +89          String[] args = {"-help"};
    +90          PrintStream out = System.out;
    +91  
    +92          CliParser instance = new CliParser();
    +93          instance.parse(args);
    +94  
    +95          Assert.assertFalse(instance.isGetVersion());
    +96          Assert.assertTrue(instance.isGetHelp());
    +97          Assert.assertFalse(instance.isRunScan());
    +98      }
    +99  
    +100     /**
    +101      * Test of parse method with version arg, of class CliParser.
    +102      *
    +103      * @throws Exception thrown when an exception occurs.
    +104      */
    +105     @Test
    +106     public void testParse_version() throws Exception {
    +107 
    +108         String[] args = {"-version"};
    +109 
    +110         CliParser instance = new CliParser();
    +111         instance.parse(args);
    +112         Assert.assertTrue(instance.isGetVersion());
    +113         Assert.assertFalse(instance.isGetHelp());
    +114         Assert.assertFalse(instance.isRunScan());
    +115 
    +116     }
    +117 
    +118     /**
    +119      * Test of parse method with jar and cpe args, of class CliParser.
    +120      *
    +121      * @throws Exception thrown when an exception occurs.
    +122      */
    +123     @Test
    +124     public void testParse_unknown() throws Exception {
    +125 
    +126         String[] args = {"-unknown"};
    +127 
    +128         PrintStream out = System.out;
    +129         PrintStream err = System.err;
    +130         ByteArrayOutputStream baos_out = new ByteArrayOutputStream();
    +131         ByteArrayOutputStream baos_err = new ByteArrayOutputStream();
    +132         System.setOut(new PrintStream(baos_out));
    +133         System.setErr(new PrintStream(baos_err));
    +134 
    +135         CliParser instance = new CliParser();
    +136 
    +137         try {
    +138             instance.parse(args);
    +139         } catch (ParseException ex) {
    +140             Assert.assertTrue(ex.getMessage().contains("Unrecognized option"));
    +141         }
    +142         Assert.assertFalse(instance.isGetVersion());
    +143         Assert.assertFalse(instance.isGetHelp());
    +144         Assert.assertFalse(instance.isRunScan());
    +145     }
    +146 
    +147     /**
    +148      * Test of parse method with scan arg, of class CliParser.
    +149      *
    +150      * @throws Exception thrown when an exception occurs.
    +151      */
    +152     @Test
    +153     public void testParse_scan() throws Exception {
    +154 
    +155         String[] args = {"-scan"};
    +156 
    +157         CliParser instance = new CliParser();
    +158 
    +159         try {
    +160             instance.parse(args);
    +161         } catch (ParseException ex) {
    +162             Assert.assertTrue(ex.getMessage().contains("Missing argument"));
    +163         }
    +164 
    +165         Assert.assertFalse(instance.isGetVersion());
    +166         Assert.assertFalse(instance.isGetHelp());
    +167         Assert.assertFalse(instance.isRunScan());
    +168     }
    +169 
    +170     /**
    +171      * Test of parse method with jar arg, of class CliParser.
    +172      *
    +173      * @throws Exception thrown when an exception occurs.
    +174      */
    +175     @Test
    +176     public void testParse_scan_unknownFile() throws Exception {
    +177 
    +178         String[] args = {"-scan", "jar.that.does.not.exist", "-app", "test"};
    +179 
    +180         CliParser instance = new CliParser();
    +181         try {
    +182             instance.parse(args);
    +183         } catch (FileNotFoundException ex) {
    +184             Assert.assertTrue(ex.getMessage().contains("Invalid 'scan' argument"));
    +185         }
    +186 
    +187         Assert.assertFalse(instance.isGetVersion());
    +188         Assert.assertFalse(instance.isGetHelp());
    +189         Assert.assertFalse(instance.isRunScan());
    +190     }
    +191 
    +192     /**
    +193      * Test of parse method with jar arg, of class CliParser.
    +194      *
    +195      * @throws Exception thrown when an exception occurs.
    +196      */
    +197     @Test
    +198     public void testParse_scan_withFileExists() throws Exception {
    +199         File path = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath());
    +200         String[] args = {"-scan", path.getCanonicalPath(), "-out", "./", "-app", "test"};
    +201 
    +202         CliParser instance = new CliParser();
    +203         instance.parse(args);
    +204 
    +205         Assert.assertEquals(path.getCanonicalPath(), instance.getScanFiles()[0]);
    +206 
    +207         Assert.assertFalse(instance.isGetVersion());
    +208         Assert.assertFalse(instance.isGetHelp());
    +209         Assert.assertTrue(instance.isRunScan());
    +210     }
    +211 
    +212     /**
    +213      * Test of printVersionInfo, of class CliParser.
    +214      *
    +215      * @throws Exception thrown when an exception occurs.
    +216      */
    +217     @Test
    +218     public void testParse_printVersionInfo() throws Exception {
    +219 
    +220         PrintStream out = System.out;
    +221         ByteArrayOutputStream baos = new ByteArrayOutputStream();
    +222         System.setOut(new PrintStream(baos));
    +223 
    +224         CliParser instance = new CliParser();
    +225         instance.printVersionInfo();
    +226         try {
    +227             baos.flush();
    +228             String text = (new String(baos.toByteArray())).toLowerCase();
    +229             String[] lines = text.split(System.getProperty("line.separator"));
    +230             Assert.assertEquals(1, lines.length);
    +231             Assert.assertTrue(text.contains("version"));
    +232             Assert.assertTrue(!text.contains("unknown"));
    +233         } catch (IOException ex) {
    +234             System.setOut(out);
    +235             Assert.fail("CliParser.printVersionInfo did not write anything to system.out.");
    +236         } finally {
    +237             System.setOut(out);
    +238         }
    +239     }
    +240 
    +241     /**
    +242      * Test of printHelp, of class CliParser.
    +243      *
    +244      * @throws Exception thrown when an exception occurs.
    +245      */
    +246     @Test
    +247     public void testParse_printHelp() throws Exception {
    +248 
    +249         PrintStream out = System.out;
    +250         ByteArrayOutputStream baos = new ByteArrayOutputStream();
    +251         System.setOut(new PrintStream(baos));
    +252 
    +253         CliParser instance = new CliParser();
    +254         String[] args = {"-h"};
    +255         instance.parse(args);
    +256         instance.printHelp();
    +257         args[0] = "-ah";
    +258         instance.parse(args);
    +259         instance.printHelp();
    +260         try {
    +261             baos.flush();
    +262             String text = (new String(baos.toByteArray()));
    +263             String[] lines = text.split(System.getProperty("line.separator"));
    +264             Assert.assertTrue(lines[0].startsWith("usage: "));
    +265             Assert.assertTrue((lines.length > 2));
    +266         } catch (IOException ex) {
    +267             System.setOut(out);
    +268             Assert.fail("CliParser.printVersionInfo did not write anything to system.out.");
    +269         } finally {
    +270             System.setOut(out);
    +271         }
    +272     }
    +273 }
    +
    +
    + + + diff --git a/dependency-check-cli/xref-test/org/owasp/dependencycheck/package-frame.html b/dependency-check-cli/xref-test/org/owasp/dependencycheck/package-frame.html new file mode 100644 index 000000000..b5761b9d2 --- /dev/null +++ b/dependency-check-cli/xref-test/org/owasp/dependencycheck/package-frame.html @@ -0,0 +1,24 @@ + + + + + + Dependency-Check Command Line 1.2.6 Reference Package org.owasp.dependencycheck + + + + +

    + org.owasp.dependencycheck +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-cli/xref-test/org/owasp/dependencycheck/package-summary.html b/dependency-check-cli/xref-test/org/owasp/dependencycheck/package-summary.html new file mode 100644 index 000000000..9280bc692 --- /dev/null +++ b/dependency-check-cli/xref-test/org/owasp/dependencycheck/package-summary.html @@ -0,0 +1,69 @@ + + + + + + Dependency-Check Command Line 1.2.6 Reference Package org.owasp.dependencycheck + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck

    + + + + + + + + + + + + +
    Class Summary
    + CliParserTest +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-cli/xref-test/overview-frame.html b/dependency-check-cli/xref-test/overview-frame.html index f8a689db2..b951e4676 100644 --- a/dependency-check-cli/xref-test/overview-frame.html +++ b/dependency-check-cli/xref-test/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Command Line 1.2.5 Reference + Dependency-Check Command Line 1.2.6 Reference @@ -16,7 +16,7 @@ diff --git a/dependency-check-cli/xref-test/overview-summary.html b/dependency-check-cli/xref-test/overview-summary.html index 2e8ffe6b8..f9b4e40f7 100644 --- a/dependency-check-cli/xref-test/overview-summary.html +++ b/dependency-check-cli/xref-test/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Command Line 1.2.5 Reference + Dependency-Check Command Line 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Command Line 1.2.5 Reference

    +

    Dependency-Check Command Line 1.2.6 Reference

    @@ -35,7 +35,7 @@ diff --git a/dependency-check-cli/xref/allclasses-frame.html b/dependency-check-cli/xref/allclasses-frame.html index 4e867c915..8b1e3fbd7 100644 --- a/dependency-check-cli/xref/allclasses-frame.html +++ b/dependency-check-cli/xref/allclasses-frame.html @@ -12,13 +12,16 @@ diff --git a/dependency-check-cli/xref/index.html b/dependency-check-cli/xref/index.html index feef62db6..dcef10dc8 100644 --- a/dependency-check-cli/xref/index.html +++ b/dependency-check-cli/xref/index.html @@ -4,7 +4,7 @@ - Dependency-Check Command Line 1.2.5 Reference + Dependency-Check Command Line 1.2.6 Reference diff --git a/dependency-check-cli/xref/org/owasp/dependencycheck/App.html b/dependency-check-cli/xref/org/owasp/dependencycheck/App.html index cac5b0c76..0ecb5d31d 100644 --- a/dependency-check-cli/xref/org/owasp/dependencycheck/App.html +++ b/dependency-check-cli/xref/org/owasp/dependencycheck/App.html @@ -29,250 +29,311 @@ 21import java.io.FileNotFoundException; 22import java.io.IOException; 23import java.io.InputStream; -24import java.util.List; -25import java.util.logging.Level; -26import java.util.logging.Logger; -27import org.apache.commons.cli.ParseException; -28import org.owasp.dependencycheck.cli.CliParser; -29import org.owasp.dependencycheck.data.nvdcve.CveDB; -30import org.owasp.dependencycheck.data.nvdcve.DatabaseException; -31import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties; -32import org.owasp.dependencycheck.dependency.Dependency; -33import org.owasp.dependencycheck.reporting.ReportGenerator; -34import org.owasp.dependencycheck.utils.LogUtils; -35import org.owasp.dependencycheck.utils.Settings; -36 -37/** -38 * The command line interface for the DependencyCheck application. -39 * -40 * @author Jeremy Long <jeremy.long@owasp.org> -41 */ -42publicclassApp { -43 -44/** -45 * The location of the log properties configuration file. -46 */ -47privatestaticfinal String LOG_PROPERTIES_FILE = "log.properties"; -48 -49/** -50 * The logger. -51 */ -52privatestaticfinal Logger LOGGER = Logger.getLogger(App.class.getName()); -53 -54/** -55 * The main method for the application. -56 * -57 * @param args the command line arguments -58 */ -59publicstaticvoid main(String[] args) { -60try { -61 Settings.initialize(); -62finalApp app = newApp(); -63 app.run(args); -64 } finally { -65 Settings.cleanup(true); -66 } -67 } -68 -69/** -70 * Main CLI entry-point into the application. -71 * -72 * @param args the command line arguments -73 */ -74publicvoid run(String[] args) { -75finalCliParser cli = newCliParser(); -76 -77try { -78 cli.parse(args); -79 } catch (FileNotFoundException ex) { -80 System.err.println(ex.getMessage()); -81 cli.printHelp(); -82return; -83 } catch (ParseException ex) { +24import java.util.ArrayList; +25import java.util.Arrays; +26import java.util.HashSet; +27import java.util.List; +28import java.util.Set; +29import java.util.logging.Level; +30import java.util.logging.Logger; +31import org.apache.commons.cli.ParseException; +32import org.owasp.dependencycheck.data.nvdcve.CveDB; +33import org.owasp.dependencycheck.data.nvdcve.DatabaseException; +34import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties; +35import org.owasp.dependencycheck.dependency.Dependency; +36import org.owasp.dependencycheck.org.apache.tools.ant.DirectoryScanner; +37import org.owasp.dependencycheck.reporting.ReportGenerator; +38import org.owasp.dependencycheck.utils.LogUtils; +39import org.owasp.dependencycheck.utils.Settings; +40 +41/** +42 * The command line interface for the DependencyCheck application. +43 * +44 * @author Jeremy Long <jeremy.long@owasp.org> +45 */ +46publicclassApp { +47 +48/** +49 * The location of the log properties configuration file. +50 */ +51privatestaticfinal String LOG_PROPERTIES_FILE = "log.properties"; +52 +53/** +54 * The logger. +55 */ +56privatestaticfinal Logger LOGGER = Logger.getLogger(App.class.getName()); +57 +58/** +59 * The main method for the application. +60 * +61 * @param args the command line arguments +62 */ +63publicstaticvoid main(String[] args) { +64try { +65 Settings.initialize(); +66finalApp app = newApp(); +67 app.run(args); +68 } finally { +69 Settings.cleanup(true); +70 } +71 } +72 +73/** +74 * Main CLI entry-point into the application. +75 * +76 * @param args the command line arguments +77 */ +78publicvoid run(String[] args) { +79finalCliParser cli = newCliParser(); +80 +81try { +82 cli.parse(args); +83 } catch (FileNotFoundException ex) { 84 System.err.println(ex.getMessage()); 85 cli.printHelp(); 86return; -87 } -88 -89final InputStream in = App.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE); -90 LogUtils.prepareLogger(in, cli.getVerboseLog()); -91 -92if (cli.isGetVersion()) { -93 cli.printVersionInfo(); -94 } elseif (cli.isRunScan()) { -95 populateSettings(cli); -96 runScan(cli.getReportDirectory(), cli.getReportFormat(), cli.getApplicationName(), cli.getScanFiles()); -97 } else { -98 cli.printHelp(); -99 } -100 } -101 -102/** -103 * Scans the specified directories and writes the dependency reports to the reportDirectory. -104 * -105 * @param reportDirectory the path to the directory where the reports will be written -106 * @param outputFormat the output format of the report -107 * @param applicationName the application name for the report -108 * @param files the files/directories to scan -109 */ -110privatevoid runScan(String reportDirectory, String outputFormat, String applicationName, String[] files) { -111 Engine scanner = null; -112try { -113 scanner = new Engine(); -114 -115for (String file : files) { -116 scanner.scan(file); -117 } -118 -119 scanner.analyzeDependencies(); -120final List<Dependency> dependencies = scanner.getDependencies(); -121 DatabaseProperties prop = null; -122 CveDB cve = null; -123try { -124 cve = new CveDB(); -125 cve.open(); -126 prop = cve.getDatabaseProperties(); -127 } catch (DatabaseException ex) { -128 LOGGER.log(Level.FINE, "Unable to retrieve DB Properties", ex); -129 } finally { -130if (cve != null) { -131 cve.close(); -132 } -133 } -134final ReportGenerator report = new ReportGenerator(applicationName, dependencies, scanner.getAnalyzers(), prop); -135try { -136 report.generateReports(reportDirectory, outputFormat); -137 } catch (IOException ex) { -138 LOGGER.log(Level.SEVERE, "There was an IO error while attempting to generate the report."); -139 LOGGER.log(Level.FINE, null, ex); -140 } catch (Throwable ex) { -141 LOGGER.log(Level.SEVERE, "There was an error while attempting to generate the report."); -142 LOGGER.log(Level.FINE, null, ex); -143 } -144 } catch (DatabaseException ex) { -145 LOGGER.log(Level.SEVERE, "Unable to connect to the dependency-check database; analysis has stopped"); -146 LOGGER.log(Level.FINE, "", ex); -147 } finally { -148if (scanner != null) { -149 scanner.cleanup(); -150 } -151 } -152 } -153 -154/** -155 * Updates the global Settings. -156 * -157 * @param cli a reference to the CLI Parser that contains the command line arguments used to set the corresponding -158 * settings in the core engine. -159 */ -160privatevoid populateSettings(CliParser cli) { -161 -162finalboolean autoUpdate = cli.isAutoUpdate(); -163final String connectionTimeout = cli.getConnectionTimeout(); -164final String proxyServer = cli.getProxyServer(); -165final String proxyPort = cli.getProxyPort(); -166final String proxyUser = cli.getProxyUsername(); -167final String proxyPass = cli.getProxyPassword(); -168final String dataDirectory = cli.getDataDirectory(); -169final File propertiesFile = cli.getPropertiesFile(); -170final String suppressionFile = cli.getSuppressionFile(); -171finalboolean jarDisabled = cli.isJarDisabled(); -172finalboolean archiveDisabled = cli.isArchiveDisabled(); -173finalboolean assemblyDisabled = cli.isAssemblyDisabled(); -174finalboolean nuspecDisabled = cli.isNuspecDisabled(); -175finalboolean nexusDisabled = cli.isNexusDisabled(); -176final String nexusUrl = cli.getNexusUrl(); -177final String databaseDriverName = cli.getDatabaseDriverName(); -178final String databaseDriverPath = cli.getDatabaseDriverPath(); -179final String connectionString = cli.getConnectionString(); -180final String databaseUser = cli.getDatabaseUser(); -181final String databasePassword = cli.getDatabasePassword(); -182final String additionalZipExtensions = cli.getAdditionalZipExtensions(); -183final String pathToMono = cli.getPathToMono(); -184 -185if (propertiesFile != null) { -186try { -187 Settings.mergeProperties(propertiesFile); -188 } catch (FileNotFoundException ex) { -189final String msg = String.format("Unable to load properties file '%s'", propertiesFile.getPath()); -190 LOGGER.log(Level.SEVERE, msg); -191 LOGGER.log(Level.FINE, null, ex); -192 } catch (IOException ex) { -193final String msg = String.format("Unable to find properties file '%s'", propertiesFile.getPath()); -194 LOGGER.log(Level.SEVERE, msg); -195 LOGGER.log(Level.FINE, null, ex); -196 } -197 } -198// We have to wait until we've merged the properties before attempting to set whether we use -199// the proxy for Nexus since it could be disabled in the properties, but not explicitly stated -200// on the command line -201finalboolean nexusUsesProxy = cli.isNexusUsesProxy(); -202if (dataDirectory != null) { -203 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory); -204 } elseif (System.getProperty("basedir") != null) { -205final File dataDir = new File(System.getProperty("basedir"), "data"); -206 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDir.getAbsolutePath()); -207 } else { -208final File jarPath = new File(App.class.getProtectionDomain().getCodeSource().getLocation().getPath()); -209final File base = jarPath.getParentFile(); -210final String sub = Settings.getString(Settings.KEYS.DATA_DIRECTORY); -211final File dataDir = new File(base, sub); -212 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDir.getAbsolutePath()); -213 } -214 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); -215if (proxyServer != null && !proxyServer.isEmpty()) { -216 Settings.setString(Settings.KEYS.PROXY_SERVER, proxyServer); -217 } -218if (proxyPort != null && !proxyPort.isEmpty()) { -219 Settings.setString(Settings.KEYS.PROXY_PORT, proxyPort); -220 } -221if (proxyUser != null && !proxyUser.isEmpty()) { -222 Settings.setString(Settings.KEYS.PROXY_USERNAME, proxyUser); -223 } -224if (proxyPass != null && !proxyPass.isEmpty()) { -225 Settings.setString(Settings.KEYS.PROXY_PASSWORD, proxyPass); -226 } -227if (connectionTimeout != null && !connectionTimeout.isEmpty()) { -228 Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout); -229 } -230if (suppressionFile != null && !suppressionFile.isEmpty()) { -231 Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile); -232 } -233 -234//File Type Analyzer Settings -235 Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, !jarDisabled); -236 Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, !archiveDisabled); -237 Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, !nuspecDisabled); -238 Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, !assemblyDisabled); -239 -240 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, !nexusDisabled); -241if (nexusUrl != null && !nexusUrl.isEmpty()) { -242 Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl); -243 } -244 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy); -245if (databaseDriverName != null && !databaseDriverName.isEmpty()) { -246 Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName); -247 } -248if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) { -249 Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath); -250 } -251if (connectionString != null && !connectionString.isEmpty()) { -252 Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString); -253 } -254if (databaseUser != null && !databaseUser.isEmpty()) { -255 Settings.setString(Settings.KEYS.DB_USER, databaseUser); -256 } -257if (databasePassword != null && !databasePassword.isEmpty()) { -258 Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword); -259 } -260if (additionalZipExtensions != null && !additionalZipExtensions.isEmpty()) { -261 Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, additionalZipExtensions); -262 } -263if (pathToMono != null && !pathToMono.isEmpty()) { -264 Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono); -265 } -266 } -267 } +87 } catch (ParseException ex) { +88 System.err.println(ex.getMessage()); +89 cli.printHelp(); +90return; +91 } +92 +93final InputStream in = App.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE); +94 LogUtils.prepareLogger(in, cli.getVerboseLog()); +95 +96if (cli.isGetVersion()) { +97 cli.printVersionInfo(); +98 } elseif (cli.isRunScan()) { +99 populateSettings(cli); +100try { +101 runScan(cli.getReportDirectory(), cli.getReportFormat(), cli.getApplicationName(), cli.getScanFiles(), cli.getExcludeList()); +102 } catch (InvalidScanPathException ex) { +103 Logger.getLogger(App.class.getName()).log(Level.SEVERE, "An invalid scan path was detected; unable to scan '//*' paths"); +104 } +105 } else { +106 cli.printHelp(); +107 } +108 } +109 +110/** +111 * Scans the specified directories and writes the dependency reports to the reportDirectory. +112 * +113 * @param reportDirectory the path to the directory where the reports will be written +114 * @param outputFormat the output format of the report +115 * @param applicationName the application name for the report +116 * @param files the files/directories to scan +117 * @param excludes the patterns for files/directories to exclude +118 * +119 * @throws InvalidScanPathException thrown if the path to scan starts with "//" +120 */ +121privatevoid runScan(String reportDirectory, String outputFormat, String applicationName, String[] files, +122 String[] excludes) throws InvalidScanPathException { +123 Engine engine = null; +124try { +125 engine = new Engine(); +126 List<String> antStylePaths = new ArrayList<String>(); +127if (excludes == null || excludes.length == 0) { +128for (String file : files) { +129if (file.contains("*") || file.contains("?")) { +130 antStylePaths.add(file); +131 } else { +132 engine.scan(file); +133 } +134 } +135 } else { +136 antStylePaths = Arrays.asList(files); +137 } +138 +139final Set<File> paths = new HashSet<File>(); +140for (String file : antStylePaths) { +141final DirectoryScanner scanner = new DirectoryScanner(); +142 String include = file.replace('\\', '/'); +143 File baseDir; +144 +145if (include.startsWith("//")) { +146thrownewInvalidScanPathException("Unable to scan paths specified by //"); +147 } elseif (include.startsWith("./")) { +148 baseDir = new File("."); +149 include = include.substring(2); +150 } elseif (include.startsWith("/")) { +151 baseDir = new File("/"); +152 include = include.substring(1); +153 } elseif (include.contains("/")) { +154finalint pos = include.indexOf('/'); +155final String tmp = include.substring(0, pos); +156if (tmp.contains("*") || tmp.contains("?")) { +157 baseDir = new File("."); +158 } else { +159 baseDir = new File(tmp); +160 include = include.substring(pos + 1); +161 } +162 } else { //no path info - must just be a file in the working directory +163 baseDir = new File("."); +164 } +165 scanner.setBasedir(baseDir); +166 scanner.setIncludes(include); +167if (excludes != null && excludes.length > 0) { +168 scanner.addExcludes(excludes); +169 } +170 scanner.scan(); +171if (scanner.getIncludedFilesCount() > 0) { +172for (String s : scanner.getIncludedFiles()) { +173final File f = new File(baseDir, s); +174 paths.add(f); +175 } +176 } +177 } +178 engine.scan(paths); +179 +180 engine.analyzeDependencies(); +181final List<Dependency> dependencies = engine.getDependencies(); +182 DatabaseProperties prop = null; +183 CveDB cve = null; +184try { +185 cve = new CveDB(); +186 cve.open(); +187 prop = cve.getDatabaseProperties(); +188 } catch (DatabaseException ex) { +189 LOGGER.log(Level.FINE, "Unable to retrieve DB Properties", ex); +190 } finally { +191if (cve != null) { +192 cve.close(); +193 } +194 } +195final ReportGenerator report = new ReportGenerator(applicationName, dependencies, engine.getAnalyzers(), prop); +196try { +197 report.generateReports(reportDirectory, outputFormat); +198 } catch (IOException ex) { +199 LOGGER.log(Level.SEVERE, "There was an IO error while attempting to generate the report."); +200 LOGGER.log(Level.FINE, null, ex); +201 } catch (Throwable ex) { +202 LOGGER.log(Level.SEVERE, "There was an error while attempting to generate the report."); +203 LOGGER.log(Level.FINE, null, ex); +204 } +205 } catch (DatabaseException ex) { +206 LOGGER.log(Level.SEVERE, "Unable to connect to the dependency-check database; analysis has stopped"); +207 LOGGER.log(Level.FINE, "", ex); +208 } finally { +209if (engine != null) { +210 engine.cleanup(); +211 } +212 } +213 } +214 +215/** +216 * Updates the global Settings. +217 * +218 * @param cli a reference to the CLI Parser that contains the command line arguments used to set the corresponding +219 * settings in the core engine. +220 */ +221privatevoid populateSettings(CliParser cli) { +222 +223finalboolean autoUpdate = cli.isAutoUpdate(); +224final String connectionTimeout = cli.getConnectionTimeout(); +225final String proxyServer = cli.getProxyServer(); +226final String proxyPort = cli.getProxyPort(); +227final String proxyUser = cli.getProxyUsername(); +228final String proxyPass = cli.getProxyPassword(); +229final String dataDirectory = cli.getDataDirectory(); +230final File propertiesFile = cli.getPropertiesFile(); +231final String suppressionFile = cli.getSuppressionFile(); +232finalboolean jarDisabled = cli.isJarDisabled(); +233finalboolean archiveDisabled = cli.isArchiveDisabled(); +234finalboolean assemblyDisabled = cli.isAssemblyDisabled(); +235finalboolean nuspecDisabled = cli.isNuspecDisabled(); +236finalboolean nexusDisabled = cli.isNexusDisabled(); +237final String nexusUrl = cli.getNexusUrl(); +238final String databaseDriverName = cli.getDatabaseDriverName(); +239final String databaseDriverPath = cli.getDatabaseDriverPath(); +240final String connectionString = cli.getConnectionString(); +241final String databaseUser = cli.getDatabaseUser(); +242final String databasePassword = cli.getDatabasePassword(); +243final String additionalZipExtensions = cli.getAdditionalZipExtensions(); +244final String pathToMono = cli.getPathToMono(); +245 +246if (propertiesFile != null) { +247try { +248 Settings.mergeProperties(propertiesFile); +249 } catch (FileNotFoundException ex) { +250final String msg = String.format("Unable to load properties file '%s'", propertiesFile.getPath()); +251 LOGGER.log(Level.SEVERE, msg); +252 LOGGER.log(Level.FINE, null, ex); +253 } catch (IOException ex) { +254final String msg = String.format("Unable to find properties file '%s'", propertiesFile.getPath()); +255 LOGGER.log(Level.SEVERE, msg); +256 LOGGER.log(Level.FINE, null, ex); +257 } +258 } +259// We have to wait until we've merged the properties before attempting to set whether we use +260// the proxy for Nexus since it could be disabled in the properties, but not explicitly stated +261// on the command line +262finalboolean nexusUsesProxy = cli.isNexusUsesProxy(); +263if (dataDirectory != null) { +264 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory); +265 } elseif (System.getProperty("basedir") != null) { +266final File dataDir = new File(System.getProperty("basedir"), "data"); +267 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDir.getAbsolutePath()); +268 } else { +269final File jarPath = new File(App.class.getProtectionDomain().getCodeSource().getLocation().getPath()); +270final File base = jarPath.getParentFile(); +271final String sub = Settings.getString(Settings.KEYS.DATA_DIRECTORY); +272final File dataDir = new File(base, sub); +273 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDir.getAbsolutePath()); +274 } +275 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); +276if (proxyServer != null && !proxyServer.isEmpty()) { +277 Settings.setString(Settings.KEYS.PROXY_SERVER, proxyServer); +278 } +279if (proxyPort != null && !proxyPort.isEmpty()) { +280 Settings.setString(Settings.KEYS.PROXY_PORT, proxyPort); +281 } +282if (proxyUser != null && !proxyUser.isEmpty()) { +283 Settings.setString(Settings.KEYS.PROXY_USERNAME, proxyUser); +284 } +285if (proxyPass != null && !proxyPass.isEmpty()) { +286 Settings.setString(Settings.KEYS.PROXY_PASSWORD, proxyPass); +287 } +288if (connectionTimeout != null && !connectionTimeout.isEmpty()) { +289 Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout); +290 } +291if (suppressionFile != null && !suppressionFile.isEmpty()) { +292 Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile); +293 } +294 +295//File Type Analyzer Settings +296 Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, !jarDisabled); +297 Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, !archiveDisabled); +298 Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, !nuspecDisabled); +299 Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, !assemblyDisabled); +300 +301 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, !nexusDisabled); +302if (nexusUrl != null && !nexusUrl.isEmpty()) { +303 Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl); +304 } +305 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy); +306if (databaseDriverName != null && !databaseDriverName.isEmpty()) { +307 Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName); +308 } +309if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) { +310 Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath); +311 } +312if (connectionString != null && !connectionString.isEmpty()) { +313 Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString); +314 } +315if (databaseUser != null && !databaseUser.isEmpty()) { +316 Settings.setString(Settings.KEYS.DB_USER, databaseUser); +317 } +318if (databasePassword != null && !databasePassword.isEmpty()) { +319 Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword); +320 } +321if (additionalZipExtensions != null && !additionalZipExtensions.isEmpty()) { +322 Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, additionalZipExtensions); +323 } +324if (pathToMono != null && !pathToMono.isEmpty()) { +325 Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono); +326 } +327 } +328 }
    diff --git a/dependency-check-cli/xref/org/owasp/dependencycheck/CliParser.html b/dependency-check-cli/xref/org/owasp/dependencycheck/CliParser.html new file mode 100644 index 000000000..279f8cc93 --- /dev/null +++ b/dependency-check-cli/xref/org/owasp/dependencycheck/CliParser.html @@ -0,0 +1,934 @@ + + + +CliParser xref + + + +
    View Javadoc
    +1   /*
    +2    * This file is part of dependency-check-cli.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *     http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   *
    +16   * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
    +17   */
    +18  package org.owasp.dependencycheck;
    +19  
    +20  import java.io.File;
    +21  import java.io.FileNotFoundException;
    +22  import java.util.logging.Logger;
    +23  import org.apache.commons.cli.CommandLine;
    +24  import org.apache.commons.cli.CommandLineParser;
    +25  import org.apache.commons.cli.HelpFormatter;
    +26  import org.apache.commons.cli.Option;
    +27  import org.apache.commons.cli.OptionBuilder;
    +28  import org.apache.commons.cli.OptionGroup;
    +29  import org.apache.commons.cli.Options;
    +30  import org.apache.commons.cli.ParseException;
    +31  import org.apache.commons.cli.PosixParser;
    +32  import org.owasp.dependencycheck.reporting.ReportGenerator.Format;
    +33  import org.owasp.dependencycheck.utils.InvalidSettingException;
    +34  import org.owasp.dependencycheck.utils.Settings;
    +35  
    +36  /**
    +37   * A utility to parse command line arguments for the DependencyCheck.
    +38   *
    +39   * @author Jeremy Long <jeremy.long@owasp.org>
    +40   */
    +41  public final class CliParser {
    +42  
    +43      /**
    +44       * The logger.
    +45       */
    +46      private static final Logger LOGGER = Logger.getLogger(CliParser.class.getName());
    +47      /**
    +48       * The command line.
    +49       */
    +50      private CommandLine line;
    +51      /**
    +52       * Indicates whether the arguments are valid.
    +53       */
    +54      private boolean isValid = true;
    +55  
    +56      /**
    +57       * Parses the arguments passed in and captures the results for later use.
    +58       *
    +59       * @param args the command line arguments
    +60       * @throws FileNotFoundException is thrown when a 'file' argument does not point to a file that exists.
    +61       * @throws ParseException is thrown when a Parse Exception occurs.
    +62       */
    +63      public void parse(String[] args) throws FileNotFoundException, ParseException {
    +64          line = parseArgs(args);
    +65  
    +66          if (line != null) {
    +67              validateArgs();
    +68          }
    +69      }
    +70  
    +71      /**
    +72       * Parses the command line arguments.
    +73       *
    +74       * @param args the command line arguments
    +75       * @return the results of parsing the command line arguments
    +76       * @throws ParseException if the arguments are invalid
    +77       */
    +78      private CommandLine parseArgs(String[] args) throws ParseException {
    +79          final CommandLineParser parser = new PosixParser();
    +80          final Options options = createCommandLineOptions();
    +81          return parser.parse(options, args);
    +82      }
    +83  
    +84      /**
    +85       * Validates that the command line arguments are valid.
    +86       *
    +87       * @throws FileNotFoundException if there is a file specified by either the SCAN or CPE command line arguments that
    +88       * does not exist.
    +89       * @throws ParseException is thrown if there is an exception parsing the command line.
    +90       */
    +91      private void validateArgs() throws FileNotFoundException, ParseException {
    +92          if (isRunScan()) {
    +93              validatePathExists(getScanFiles(), ARGUMENT.SCAN);
    +94              validatePathExists(getReportDirectory(), ARGUMENT.OUT);
    +95              if (getPathToMono() != null) {
    +96                  validatePathExists(getPathToMono(), ARGUMENT.PATH_TO_MONO);
    +97              }
    +98              if (!line.hasOption(ARGUMENT.APP_NAME)) {
    +99                  throw new ParseException("Missing 'app' argument; the scan cannot be run without the an application name.");
    +100             }
    +101             if (line.hasOption(ARGUMENT.OUTPUT_FORMAT)) {
    +102                 final String format = line.getOptionValue(ARGUMENT.OUTPUT_FORMAT);
    +103                 try {
    +104                     Format.valueOf(format);
    +105                 } catch (IllegalArgumentException ex) {
    +106                     final String msg = String.format("An invalid 'format' of '%s' was specified. "
    +107                             + "Supported output formats are XML, HTML, VULN, or ALL", format);
    +108                     throw new ParseException(msg);
    +109                 }
    +110             }
    +111         }
    +112     }
    +113 
    +114     /**
    +115      * Validates whether or not the path(s) points at a file that exists; if the path(s) does not point to an existing
    +116      * file a FileNotFoundException is thrown.
    +117      *
    +118      * @param paths the paths to validate if they exists
    +119      * @param optType the option being validated (e.g. scan, out, etc.)
    +120      * @throws FileNotFoundException is thrown if one of the paths being validated does not exist.
    +121      */
    +122     private void validatePathExists(String[] paths, String optType) throws FileNotFoundException {
    +123         for (String path : paths) {
    +124             validatePathExists(path, optType);
    +125         }
    +126     }
    +127 
    +128     /**
    +129      * Validates whether or not the path points at a file that exists; if the path does not point to an existing file a
    +130      * FileNotFoundException is thrown.
    +131      *
    +132      * @param path the paths to validate if they exists
    +133      * @param argumentName the argument being validated (e.g. scan, out, etc.)
    +134      * @throws FileNotFoundException is thrown if the path being validated does not exist.
    +135      */
    +136     private void validatePathExists(String path, String argumentName) throws FileNotFoundException {
    +137         if (path == null) {
    +138             isValid = false;
    +139             final String msg = String.format("Invalid '%s' argument: null", argumentName);
    +140             throw new FileNotFoundException(msg);
    +141         } else if (!path.contains("*") && !path.contains("?")) {
    +142             final File f = new File(path);
    +143             if ("o".equals(argumentName.substring(0, 1).toLowerCase()) && !"ALL".equals(this.getReportFormat().toUpperCase())) {
    +144                 final String checkPath = path.toLowerCase();
    +145                 if (checkPath.endsWith(".html") || checkPath.endsWith(".xml") || checkPath.endsWith(".htm")) {
    +146                     if (!f.getParentFile().isDirectory()) {
    +147                         isValid = false;
    +148                         final String msg = String.format("Invalid '%s' argument: '%s'", argumentName, path);
    +149                         throw new FileNotFoundException(msg);
    +150                     }
    +151                 }
    +152             } else {
    +153                 if (!f.exists()) {
    +154                     isValid = false;
    +155                     final String msg = String.format("Invalid '%s' argument: '%s'", argumentName, path);
    +156                     throw new FileNotFoundException(msg);
    +157                 }
    +158             }
    +159         } else if (path.startsWith("//") || path.startsWith("\\\\")) {
    +160             isValid = false;
    +161             final String msg = String.format("Invalid '%s' argument: '%s'%nUnable to scan paths that start with '//'.", argumentName, path);
    +162             throw new FileNotFoundException(msg);
    +163         }
    +164     }
    +165 
    +166     /**
    +167      * Generates an Options collection that is used to parse the command line and to display the help message.
    +168      *
    +169      * @return the command line options used for parsing the command line
    +170      */
    +171     @SuppressWarnings("static-access")
    +172     private Options createCommandLineOptions() {
    +173         final Options options = new Options();
    +174         addStandardOptions(options);
    +175         addAdvancedOptions(options);
    +176         addDeprecatedOptions(options);
    +177         return options;
    +178     }
    +179 
    +180     /**
    +181      * Adds the standard command line options to the given options collection.
    +182      *
    +183      * @param options a collection of command line arguments
    +184      * @throws IllegalArgumentException thrown if there is an exception
    +185      */
    +186     @SuppressWarnings("static-access")
    +187     private void addStandardOptions(final Options options) throws IllegalArgumentException {
    +188         final Option help = new Option(ARGUMENT.HELP_SHORT, ARGUMENT.HELP, false,
    +189                 "Print this message.");
    +190 
    +191         final Option advancedHelp = OptionBuilder.withLongOpt(ARGUMENT.ADVANCED_HELP)
    +192                 .withDescription("Print the advanced help message.").create();
    +193 
    +194         final Option version = new Option(ARGUMENT.VERSION_SHORT, ARGUMENT.VERSION,
    +195                 false, "Print the version information.");
    +196 
    +197         final Option noUpdate = new Option(ARGUMENT.DISABLE_AUTO_UPDATE_SHORT, ARGUMENT.DISABLE_AUTO_UPDATE,
    +198                 false, "Disables the automatic updating of the CPE data.");
    +199 
    +200         final Option appName = OptionBuilder.withArgName("name").hasArg().withLongOpt(ARGUMENT.APP_NAME)
    +201                 .withDescription("The name of the application being scanned. This is a required argument.")
    +202                 .create(ARGUMENT.APP_NAME_SHORT);
    +203 
    +204         final Option path = OptionBuilder.withArgName("path").hasArg().withLongOpt(ARGUMENT.SCAN)
    +205                 .withDescription("The path to scan - this option can be specified multiple times. Ant style"
    +206                         + " paths are supported (e.g. path/**/*.jar).")
    +207                 .create(ARGUMENT.SCAN_SHORT);
    +208 
    +209         final Option excludes = OptionBuilder.withArgName("pattern").hasArg().withLongOpt(ARGUMENT.EXCLUDE)
    +210                 .withDescription("Specify and exclusion pattern. This option can be specified multiple times"
    +211                         + " and it accepts Ant style excludsions.")
    +212                 .create();
    +213 
    +214         final Option props = OptionBuilder.withArgName("file").hasArg().withLongOpt(ARGUMENT.PROP)
    +215                 .withDescription("A property file to load.")
    +216                 .create(ARGUMENT.PROP_SHORT);
    +217 
    +218         final Option out = OptionBuilder.withArgName("path").hasArg().withLongOpt(ARGUMENT.OUT)
    +219                 .withDescription("The folder to write reports to. This defaults to the current directory. "
    +220                         + "It is possible to set this to a specific file name if the format argument is not set to ALL.")
    +221                 .create(ARGUMENT.OUT_SHORT);
    +222 
    +223         final Option outputFormat = OptionBuilder.withArgName("format").hasArg().withLongOpt(ARGUMENT.OUTPUT_FORMAT)
    +224                 .withDescription("The output format to write to (XML, HTML, VULN, ALL). The default is HTML.")
    +225                 .create(ARGUMENT.OUTPUT_FORMAT_SHORT);
    +226 
    +227         final Option verboseLog = OptionBuilder.withArgName("file").hasArg().withLongOpt(ARGUMENT.VERBOSE_LOG)
    +228                 .withDescription("The file path to write verbose logging information.")
    +229                 .create(ARGUMENT.VERBOSE_LOG_SHORT);
    +230 
    +231         final Option suppressionFile = OptionBuilder.withArgName("file").hasArg().withLongOpt(ARGUMENT.SUPPRESSION_FILE)
    +232                 .withDescription("The file path to the suppression XML file.")
    +233                 .create();
    +234 
    +235         //This is an option group because it can be specified more then once.
    +236         final OptionGroup og = new OptionGroup();
    +237         og.addOption(path);
    +238 
    +239         final OptionGroup exog = new OptionGroup();
    +240         exog.addOption(excludes);
    +241 
    +242         options.addOptionGroup(og)
    +243                 .addOptionGroup(exog)
    +244                 .addOption(out)
    +245                 .addOption(outputFormat)
    +246                 .addOption(appName)
    +247                 .addOption(version)
    +248                 .addOption(help)
    +249                 .addOption(advancedHelp)
    +250                 .addOption(noUpdate)
    +251                 .addOption(props)
    +252                 .addOption(verboseLog)
    +253                 .addOption(suppressionFile);
    +254     }
    +255 
    +256     /**
    +257      * Adds the advanced command line options to the given options collection. These are split out for purposes of being
    +258      * able to display two different help messages.
    +259      *
    +260      * @param options a collection of command line arguments
    +261      * @throws IllegalArgumentException thrown if there is an exception
    +262      */
    +263     @SuppressWarnings("static-access")
    +264     private void addAdvancedOptions(final Options options) throws IllegalArgumentException {
    +265 
    +266         final Option data = OptionBuilder.withArgName("path").hasArg().withLongOpt(ARGUMENT.DATA_DIRECTORY)
    +267                 .withDescription("The location of the H2 Database file. This option should generally not be set.")
    +268                 .create(ARGUMENT.DATA_DIRECTORY_SHORT);
    +269 
    +270         final Option connectionTimeout = OptionBuilder.withArgName("timeout").hasArg().withLongOpt(ARGUMENT.CONNECTION_TIMEOUT)
    +271                 .withDescription("The connection timeout (in milliseconds) to use when downloading resources.")
    +272                 .create(ARGUMENT.CONNECTION_TIMEOUT_SHORT);
    +273 
    +274         final Option proxyServer = OptionBuilder.withArgName("server").hasArg().withLongOpt(ARGUMENT.PROXY_SERVER)
    +275                 .withDescription("The proxy server to use when downloading resources.")
    +276                 .create();
    +277 
    +278         final Option proxyPort = OptionBuilder.withArgName("port").hasArg().withLongOpt(ARGUMENT.PROXY_PORT)
    +279                 .withDescription("The proxy port to use when downloading resources.")
    +280                 .create();
    +281 
    +282         final Option proxyUsername = OptionBuilder.withArgName("user").hasArg().withLongOpt(ARGUMENT.PROXY_USERNAME)
    +283                 .withDescription("The proxy username to use when downloading resources.")
    +284                 .create();
    +285 
    +286         final Option proxyPassword = OptionBuilder.withArgName("pass").hasArg().withLongOpt(ARGUMENT.PROXY_PASSWORD)
    +287                 .withDescription("The proxy password to use when downloading resources.")
    +288                 .create();
    +289 
    +290         final Option connectionString = OptionBuilder.withArgName("connStr").hasArg().withLongOpt(ARGUMENT.CONNECTION_STRING)
    +291                 .withDescription("The connection string to the database.")
    +292                 .create();
    +293 
    +294         final Option dbUser = OptionBuilder.withArgName("user").hasArg().withLongOpt(ARGUMENT.DB_NAME)
    +295                 .withDescription("The username used to connect to the database.")
    +296                 .create();
    +297 
    +298         final Option dbPassword = OptionBuilder.withArgName("password").hasArg().withLongOpt(ARGUMENT.DB_PASSWORD)
    +299                 .withDescription("The password for connecting to the database.")
    +300                 .create();
    +301 
    +302         final Option dbDriver = OptionBuilder.withArgName("driver").hasArg().withLongOpt(ARGUMENT.DB_DRIVER)
    +303                 .withDescription("The database driver name.")
    +304                 .create();
    +305 
    +306         final Option dbDriverPath = OptionBuilder.withArgName("path").hasArg().withLongOpt(ARGUMENT.DB_DRIVER_PATH)
    +307                 .withDescription("The path to the database driver; note, this does not need to be set unless the JAR is outside of the classpath.")
    +308                 .create();
    +309 
    +310         final Option disableJarAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_JAR)
    +311                 .withDescription("Disable the Jar Analyzer.")
    +312                 .create();
    +313         final Option disableArchiveAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_ARCHIVE)
    +314                 .withDescription("Disable the Archive Analyzer.")
    +315                 .create();
    +316         final Option disableNuspecAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_NUSPEC)
    +317                 .withDescription("Disable the Nuspec Analyzer.")
    +318                 .create();
    +319         final Option disableAssemblyAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_ASSEMBLY)
    +320                 .withDescription("Disable the .NET Assembly Analyzer.")
    +321                 .create();
    +322 
    +323         final Option disableNexusAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_NEXUS)
    +324                 .withDescription("Disable the Nexus Analyzer.")
    +325                 .create();
    +326 
    +327         final Option nexusUrl = OptionBuilder.withArgName("url").hasArg().withLongOpt(ARGUMENT.NEXUS_URL)
    +328                 .withDescription("The url to the Nexus Pro Server. If not set the Nexus Analyzer will be disabled.")
    +329                 .create();
    +330 
    +331         final Option nexusUsesProxy = OptionBuilder.withArgName("true/false").hasArg().withLongOpt(ARGUMENT.NEXUS_USES_PROXY)
    +332                 .withDescription("Whether or not the configured proxy should be used when connecting to Nexus.")
    +333                 .create();
    +334 
    +335         final Option additionalZipExtensions = OptionBuilder.withArgName("extensions").hasArg()
    +336                 .withLongOpt(ARGUMENT.ADDITIONAL_ZIP_EXTENSIONS)
    +337                 .withDescription("A comma separated list of additional extensions to be scanned as ZIP files "
    +338                         + "(ZIP, EAR, WAR are already treated as zip files)")
    +339                 .create();
    +340 
    +341         final Option pathToMono = OptionBuilder.withArgName("path").hasArg().withLongOpt(ARGUMENT.PATH_TO_MONO)
    +342                 .withDescription("The path to Mono for .NET Assembly analysis on non-windows systems.")
    +343                 .create();
    +344 
    +345         options.addOption(proxyPort)
    +346                 .addOption(proxyServer)
    +347                 .addOption(proxyUsername)
    +348                 .addOption(proxyPassword)
    +349                 .addOption(connectionTimeout)
    +350                 .addOption(connectionString)
    +351                 .addOption(dbUser)
    +352                 .addOption(data)
    +353                 .addOption(dbPassword)
    +354                 .addOption(dbDriver)
    +355                 .addOption(dbDriverPath)
    +356                 .addOption(disableJarAnalyzer)
    +357                 .addOption(disableArchiveAnalyzer)
    +358                 .addOption(disableAssemblyAnalyzer)
    +359                 .addOption(disableNuspecAnalyzer)
    +360                 .addOption(disableNexusAnalyzer)
    +361                 .addOption(nexusUrl)
    +362                 .addOption(nexusUsesProxy)
    +363                 .addOption(additionalZipExtensions)
    +364                 .addOption(pathToMono);
    +365     }
    +366 
    +367     /**
    +368      * Adds the deprecated command line options to the given options collection. These are split out for purposes of not
    +369      * including them in the help message. We need to add the deprecated options so as not to break existing scripts.
    +370      *
    +371      * @param options a collection of command line arguments
    +372      * @throws IllegalArgumentException thrown if there is an exception
    +373      */
    +374     @SuppressWarnings("static-access")
    +375     private void addDeprecatedOptions(final Options options) throws IllegalArgumentException {
    +376 
    +377         final Option proxyServer = OptionBuilder.withArgName("url").hasArg().withLongOpt(ARGUMENT.PROXY_URL)
    +378                 .withDescription("The proxy url argument is deprecated, use proxyserver instead.")
    +379                 .create();
    +380 
    +381         options.addOption(proxyServer);
    +382     }
    +383 
    +384     /**
    +385      * Determines if the 'version' command line argument was passed in.
    +386      *
    +387      * @return whether or not the 'version' command line argument was passed in
    +388      */
    +389     public boolean isGetVersion() {
    +390         return (line != null) && line.hasOption(ARGUMENT.VERSION);
    +391     }
    +392 
    +393     /**
    +394      * Determines if the 'help' command line argument was passed in.
    +395      *
    +396      * @return whether or not the 'help' command line argument was passed in
    +397      */
    +398     public boolean isGetHelp() {
    +399         return (line != null) && line.hasOption(ARGUMENT.HELP);
    +400     }
    +401 
    +402     /**
    +403      * Determines if the 'scan' command line argument was passed in.
    +404      *
    +405      * @return whether or not the 'scan' command line argument was passed in
    +406      */
    +407     public boolean isRunScan() {
    +408         return (line != null) && isValid && line.hasOption(ARGUMENT.SCAN);
    +409     }
    +410 
    +411     /**
    +412      * Returns true if the disableJar command line argument was specified.
    +413      *
    +414      * @return true if the disableJar command line argument was specified; otherwise false
    +415      */
    +416     public boolean isJarDisabled() {
    +417         return (line != null) && line.hasOption(ARGUMENT.DISABLE_JAR);
    +418     }
    +419 
    +420     /**
    +421      * Returns true if the disableArchive command line argument was specified.
    +422      *
    +423      * @return true if the disableArchive command line argument was specified; otherwise false
    +424      */
    +425     public boolean isArchiveDisabled() {
    +426         return (line != null) && line.hasOption(ARGUMENT.DISABLE_ARCHIVE);
    +427     }
    +428 
    +429     /**
    +430      * Returns true if the disableNuspec command line argument was specified.
    +431      *
    +432      * @return true if the disableNuspec command line argument was specified; otherwise false
    +433      */
    +434     public boolean isNuspecDisabled() {
    +435         return (line != null) && line.hasOption(ARGUMENT.DISABLE_NUSPEC);
    +436     }
    +437 
    +438     /**
    +439      * Returns true if the disableAssembly command line argument was specified.
    +440      *
    +441      * @return true if the disableAssembly command line argument was specified; otherwise false
    +442      */
    +443     public boolean isAssemblyDisabled() {
    +444         return (line != null) && line.hasOption(ARGUMENT.DISABLE_ASSEMBLY);
    +445     }
    +446 
    +447     /**
    +448      * Returns true if the disableNexus command line argument was specified.
    +449      *
    +450      * @return true if the disableNexus command line argument was specified; otherwise false
    +451      */
    +452     public boolean isNexusDisabled() {
    +453         return (line != null) && line.hasOption(ARGUMENT.DISABLE_NEXUS);
    +454     }
    +455 
    +456     /**
    +457      * Returns the url to the nexus server if one was specified.
    +458      *
    +459      * @return the url to the nexus server; if none was specified this will return null;
    +460      */
    +461     public String getNexusUrl() {
    +462         if (line == null || !line.hasOption(ARGUMENT.NEXUS_URL)) {
    +463             return null;
    +464         } else {
    +465             return line.getOptionValue(ARGUMENT.NEXUS_URL);
    +466         }
    +467     }
    +468 
    +469     /**
    +470      * Returns true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false is
    +471      * returned.
    +472      *
    +473      * @return true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false
    +474      */
    +475     public boolean isNexusUsesProxy() {
    +476         // If they didn't specify whether Nexus needs to use the proxy, we should
    +477         // still honor the property if it's set.
    +478         if (line == null || !line.hasOption(ARGUMENT.NEXUS_USES_PROXY)) {
    +479             try {
    +480                 return Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY);
    +481             } catch (InvalidSettingException ise) {
    +482                 return true;
    +483             }
    +484         } else {
    +485             return Boolean.parseBoolean(line.getOptionValue(ARGUMENT.NEXUS_USES_PROXY));
    +486         }
    +487     }
    +488 
    +489     /**
    +490      * Displays the command line help message to the standard output.
    +491      */
    +492     public void printHelp() {
    +493         final HelpFormatter formatter = new HelpFormatter();
    +494         final Options options = new Options();
    +495         addStandardOptions(options);
    +496         if (line != null && line.hasOption(ARGUMENT.ADVANCED_HELP)) {
    +497             addAdvancedOptions(options);
    +498         }
    +499         final String helpMsg = String.format("%n%s"
    +500                 + " can be used to identify if there are any known CVE vulnerabilities in libraries utilized by an application. "
    +501                 + "%s will automatically update required data from the Internet, such as the CVE and CPE data files from nvd.nist.gov.%n%n",
    +502                 Settings.getString("application.name", "DependencyCheck"),
    +503                 Settings.getString("application.name", "DependencyCheck"));
    +504 
    +505         formatter.printHelp(Settings.getString("application.name", "DependencyCheck"),
    +506                 helpMsg,
    +507                 options,
    +508                 "",
    +509                 true);
    +510     }
    +511 
    +512     /**
    +513      * Retrieves the file command line parameter(s) specified for the 'scan' argument.
    +514      *
    +515      * @return the file paths specified on the command line for scan
    +516      */
    +517     public String[] getScanFiles() {
    +518         return line.getOptionValues(ARGUMENT.SCAN);
    +519     }
    +520 
    +521     /**
    +522      * Retrieves the list of excluded file patterns specified by the 'exclude' argument.
    +523      *
    +524      * @return the excluded file patterns
    +525      */
    +526     public String[] getExcludeList() {
    +527         return line.getOptionValues(ARGUMENT.EXCLUDE);
    +528     }
    +529 
    +530     /**
    +531      * Returns the directory to write the reports to specified on the command line.
    +532      *
    +533      * @return the path to the reports directory.
    +534      */
    +535     public String getReportDirectory() {
    +536         return line.getOptionValue(ARGUMENT.OUT, ".");
    +537     }
    +538 
    +539     /**
    +540      * Returns the path to Mono for .NET Assembly analysis on non-windows systems.
    +541      *
    +542      * @return the path to Mono
    +543      */
    +544     public String getPathToMono() {
    +545         return line.getOptionValue(ARGUMENT.PATH_TO_MONO);
    +546     }
    +547 
    +548     /**
    +549      * Returns the output format specified on the command line. Defaults to HTML if no format was specified.
    +550      *
    +551      * @return the output format name.
    +552      */
    +553     public String getReportFormat() {
    +554         return line.getOptionValue(ARGUMENT.OUTPUT_FORMAT, "HTML");
    +555     }
    +556 
    +557     /**
    +558      * Returns the application name specified on the command line.
    +559      *
    +560      * @return the application name.
    +561      */
    +562     public String getApplicationName() {
    +563         return line.getOptionValue(ARGUMENT.APP_NAME);
    +564     }
    +565 
    +566     /**
    +567      * Returns the connection timeout.
    +568      *
    +569      * @return the connection timeout
    +570      */
    +571     public String getConnectionTimeout() {
    +572         return line.getOptionValue(ARGUMENT.CONNECTION_TIMEOUT);
    +573     }
    +574 
    +575     /**
    +576      * Returns the proxy server.
    +577      *
    +578      * @return the proxy server
    +579      */
    +580     public String getProxyServer() {
    +581 
    +582         String server = line.getOptionValue(ARGUMENT.PROXY_SERVER);
    +583         if (server == null) {
    +584             server = line.getOptionValue(ARGUMENT.PROXY_URL);
    +585             if (server != null) {
    +586                 LOGGER.warning("An old command line argument 'proxyurl' was detected; use proxyserver instead");
    +587             }
    +588         }
    +589         return server;
    +590     }
    +591 
    +592     /**
    +593      * Returns the proxy port.
    +594      *
    +595      * @return the proxy port
    +596      */
    +597     public String getProxyPort() {
    +598         return line.getOptionValue(ARGUMENT.PROXY_PORT);
    +599     }
    +600 
    +601     /**
    +602      * Returns the proxy username.
    +603      *
    +604      * @return the proxy username
    +605      */
    +606     public String getProxyUsername() {
    +607         return line.getOptionValue(ARGUMENT.PROXY_USERNAME);
    +608     }
    +609 
    +610     /**
    +611      * Returns the proxy password.
    +612      *
    +613      * @return the proxy password
    +614      */
    +615     public String getProxyPassword() {
    +616         return line.getOptionValue(ARGUMENT.PROXY_PASSWORD);
    +617     }
    +618 
    +619     /**
    +620      * Get the value of dataDirectory.
    +621      *
    +622      * @return the value of dataDirectory
    +623      */
    +624     public String getDataDirectory() {
    +625         return line.getOptionValue(ARGUMENT.DATA_DIRECTORY);
    +626     }
    +627 
    +628     /**
    +629      * Returns the properties file specified on the command line.
    +630      *
    +631      * @return the properties file specified on the command line
    +632      */
    +633     public File getPropertiesFile() {
    +634         final String path = line.getOptionValue(ARGUMENT.PROP);
    +635         if (path != null) {
    +636             return new File(path);
    +637         }
    +638         return null;
    +639     }
    +640 
    +641     /**
    +642      * Returns the path to the verbose log file.
    +643      *
    +644      * @return the path to the verbose log file
    +645      */
    +646     public String getVerboseLog() {
    +647         return line.getOptionValue(ARGUMENT.VERBOSE_LOG);
    +648     }
    +649 
    +650     /**
    +651      * Returns the path to the suppression file.
    +652      *
    +653      * @return the path to the suppression file
    +654      */
    +655     public String getSuppressionFile() {
    +656         return line.getOptionValue(ARGUMENT.SUPPRESSION_FILE);
    +657     }
    +658 
    +659     /**
    +660      * <p>
    +661      * Prints the manifest information to standard output.</p>
    +662      * <ul><li>Implementation-Title: ${pom.name}</li>
    +663      * <li>Implementation-Version: ${pom.version}</li></ul>
    +664      */
    +665     public void printVersionInfo() {
    +666         final String version = String.format("%s version %s",
    +667                 Settings.getString("application.name", "DependencyCheck"),
    +668                 Settings.getString("application.version", "Unknown"));
    +669         System.out.println(version);
    +670     }
    +671 
    +672     /**
    +673      * Checks if the auto update feature has been disabled. If it has been disabled via the command line this will
    +674      * return false.
    +675      *
    +676      * @return if auto-update is allowed.
    +677      */
    +678     public boolean isAutoUpdate() {
    +679         return (line == null) || !line.hasOption(ARGUMENT.DISABLE_AUTO_UPDATE);
    +680     }
    +681 
    +682     /**
    +683      * Returns the database driver name if specified; otherwise null is returned.
    +684      *
    +685      * @return the database driver name if specified; otherwise null is returned
    +686      */
    +687     public String getDatabaseDriverName() {
    +688         return line.getOptionValue(ARGUMENT.DB_DRIVER);
    +689     }
    +690 
    +691     /**
    +692      * Returns the database driver path if specified; otherwise null is returned.
    +693      *
    +694      * @return the database driver name if specified; otherwise null is returned
    +695      */
    +696     public String getDatabaseDriverPath() {
    +697         return line.getOptionValue(ARGUMENT.DB_DRIVER_PATH);
    +698     }
    +699 
    +700     /**
    +701      * Returns the database connection string if specified; otherwise null is returned.
    +702      *
    +703      * @return the database connection string if specified; otherwise null is returned
    +704      */
    +705     public String getConnectionString() {
    +706         return line.getOptionValue(ARGUMENT.CONNECTION_STRING);
    +707     }
    +708 
    +709     /**
    +710      * Returns the database database user name if specified; otherwise null is returned.
    +711      *
    +712      * @return the database database user name if specified; otherwise null is returned
    +713      */
    +714     public String getDatabaseUser() {
    +715         return line.getOptionValue(ARGUMENT.DB_NAME);
    +716     }
    +717 
    +718     /**
    +719      * Returns the database database password if specified; otherwise null is returned.
    +720      *
    +721      * @return the database database password if specified; otherwise null is returned
    +722      */
    +723     public String getDatabasePassword() {
    +724         return line.getOptionValue(ARGUMENT.DB_PASSWORD);
    +725     }
    +726 
    +727     /**
    +728      * Returns the additional Extensions if specified; otherwise null is returned.
    +729      *
    +730      * @return the additional Extensions; otherwise null is returned
    +731      */
    +732     public String getAdditionalZipExtensions() {
    +733         return line.getOptionValue(ARGUMENT.ADDITIONAL_ZIP_EXTENSIONS);
    +734     }
    +735 
    +736     /**
    +737      * A collection of static final strings that represent the possible command line arguments.
    +738      */
    +739     public static class ARGUMENT {
    +740 
    +741         /**
    +742          * The long CLI argument name specifying the directory/file to scan.
    +743          */
    +744         public static final String SCAN = "scan";
    +745         /**
    +746          * The short CLI argument name specifying the directory/file to scan.
    +747          */
    +748         public static final String SCAN_SHORT = "s";
    +749         /**
    +750          * The long CLI argument name specifying that the CPE/CVE/etc. data should not be automatically updated.
    +751          */
    +752         public static final String DISABLE_AUTO_UPDATE = "noupdate";
    +753         /**
    +754          * The short CLI argument name specifying that the CPE/CVE/etc. data should not be automatically updated.
    +755          */
    +756         public static final String DISABLE_AUTO_UPDATE_SHORT = "n";
    +757         /**
    +758          * The long CLI argument name specifying the directory to write the reports to.
    +759          */
    +760         public static final String OUT = "out";
    +761         /**
    +762          * The short CLI argument name specifying the directory to write the reports to.
    +763          */
    +764         public static final String OUT_SHORT = "o";
    +765         /**
    +766          * The long CLI argument name specifying the output format to write the reports to.
    +767          */
    +768         public static final String OUTPUT_FORMAT = "format";
    +769         /**
    +770          * The short CLI argument name specifying the output format to write the reports to.
    +771          */
    +772         public static final String OUTPUT_FORMAT_SHORT = "f";
    +773         /**
    +774          * The long CLI argument name specifying the name of the application to be scanned.
    +775          */
    +776         public static final String APP_NAME = "app";
    +777         /**
    +778          * The short CLI argument name specifying the name of the application to be scanned.
    +779          */
    +780         public static final String APP_NAME_SHORT = "a";
    +781         /**
    +782          * The long CLI argument name asking for help.
    +783          */
    +784         public static final String HELP = "help";
    +785         /**
    +786          * The long CLI argument name asking for advanced help.
    +787          */
    +788         public static final String ADVANCED_HELP = "advancedHelp";
    +789         /**
    +790          * The short CLI argument name asking for help.
    +791          */
    +792         public static final String HELP_SHORT = "h";
    +793         /**
    +794          * The long CLI argument name asking for the version.
    +795          */
    +796         public static final String VERSION_SHORT = "v";
    +797         /**
    +798          * The short CLI argument name asking for the version.
    +799          */
    +800         public static final String VERSION = "version";
    +801         /**
    +802          * The CLI argument name indicating the proxy port.
    +803          */
    +804         public static final String PROXY_PORT = "proxyport";
    +805         /**
    +806          * The CLI argument name indicating the proxy server.
    +807          */
    +808         public static final String PROXY_SERVER = "proxyserver";
    +809         /**
    +810          * The CLI argument name indicating the proxy url.
    +811          *
    +812          * @deprecated use {@link org.owasp.dependencycheck.cli.CliParser.ArgumentName#PROXY_SERVER} instead
    +813          */
    +814         @Deprecated
    +815         public static final String PROXY_URL = "proxyurl";
    +816         /**
    +817          * The CLI argument name indicating the proxy username.
    +818          */
    +819         public static final String PROXY_USERNAME = "proxyuser";
    +820         /**
    +821          * The CLI argument name indicating the proxy password.
    +822          */
    +823         public static final String PROXY_PASSWORD = "proxypass";
    +824         /**
    +825          * The short CLI argument name indicating the connection timeout.
    +826          */
    +827         public static final String CONNECTION_TIMEOUT_SHORT = "c";
    +828         /**
    +829          * The CLI argument name indicating the connection timeout.
    +830          */
    +831         public static final String CONNECTION_TIMEOUT = "connectiontimeout";
    +832         /**
    +833          * The short CLI argument name for setting the location of an additional properties file.
    +834          */
    +835         public static final String PROP_SHORT = "P";
    +836         /**
    +837          * The CLI argument name for setting the location of an additional properties file.
    +838          */
    +839         public static final String PROP = "propertyfile";
    +840         /**
    +841          * The CLI argument name for setting the location of the data directory.
    +842          */
    +843         public static final String DATA_DIRECTORY = "data";
    +844         /**
    +845          * The short CLI argument name for setting the location of the data directory.
    +846          */
    +847         public static final String DATA_DIRECTORY_SHORT = "d";
    +848         /**
    +849          * The CLI argument name for setting the location of the data directory.
    +850          */
    +851         public static final String VERBOSE_LOG = "log";
    +852         /**
    +853          * The short CLI argument name for setting the location of the data directory.
    +854          */
    +855         public static final String VERBOSE_LOG_SHORT = "l";
    +856         /**
    +857          * The CLI argument name for setting the location of the suppression file.
    +858          */
    +859         public static final String SUPPRESSION_FILE = "suppression";
    +860         /**
    +861          * Disables the Jar Analyzer.
    +862          */
    +863         public static final String DISABLE_JAR = "disableJar";
    +864         /**
    +865          * Disables the Archive Analyzer.
    +866          */
    +867         public static final String DISABLE_ARCHIVE = "disableArchive";
    +868         /**
    +869          * Disables the Assembly Analyzer.
    +870          */
    +871         public static final String DISABLE_ASSEMBLY = "disableAssembly";
    +872         /**
    +873          * Disables the Nuspec Analyzer.
    +874          */
    +875         public static final String DISABLE_NUSPEC = "disableNuspec";
    +876         /**
    +877          * Disables the Nexus Analyzer.
    +878          */
    +879         public static final String DISABLE_NEXUS = "disableNexus";
    +880         /**
    +881          * The URL of the nexus server.
    +882          */
    +883         public static final String NEXUS_URL = "nexus";
    +884         /**
    +885          * Whether or not the defined proxy should be used when connecting to Nexus.
    +886          */
    +887         public static final String NEXUS_USES_PROXY = "nexusUsesProxy";
    +888         /**
    +889          * The CLI argument name for setting the connection string.
    +890          */
    +891         public static final String CONNECTION_STRING = "connectionString";
    +892         /**
    +893          * The CLI argument name for setting the database user name.
    +894          */
    +895         public static final String DB_NAME = "dbUser";
    +896         /**
    +897          * The CLI argument name for setting the database password.
    +898          */
    +899         public static final String DB_PASSWORD = "dbPassword";
    +900         /**
    +901          * The CLI argument name for setting the database driver name.
    +902          */
    +903         public static final String DB_DRIVER = "dbDriverName";
    +904         /**
    +905          * The CLI argument name for setting the path to the database driver; in case it is not on the class path.
    +906          */
    +907         public static final String DB_DRIVER_PATH = "dbDriverPath";
    +908         /**
    +909          * The CLI argument name for setting the path to mono for .NET Assembly analysis on non-windows systems.
    +910          */
    +911         public static final String PATH_TO_MONO = "mono";
    +912         /**
    +913          * The CLI argument name for setting extra extensions.
    +914          */
    +915         public static final String ADDITIONAL_ZIP_EXTENSIONS = "zipExtensions";
    +916         /**
    +917          * Exclude path argument.
    +918          */
    +919         public static final String EXCLUDE = "exclude";
    +920     }
    +921 }
    +
    +
    + + + diff --git a/dependency-check-cli/xref/org/owasp/dependencycheck/InvalidScanPathException.html b/dependency-check-cli/xref/org/owasp/dependencycheck/InvalidScanPathException.html new file mode 100644 index 000000000..2569dd9d6 --- /dev/null +++ b/dependency-check-cli/xref/org/owasp/dependencycheck/InvalidScanPathException.html @@ -0,0 +1,72 @@ + + + +InvalidScanPathException xref + + + +
    View Javadoc
    +1   /*
    +2    * Copyright 2014 OWASP.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *      http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   */
    +16  package org.owasp.dependencycheck;
    +17  
    +18  /**
    +19   * Thrown if an invalid path is encountered.
    +20   *
    +21   * @author Jeremy Long <jeremy.long@owasp.org>
    +22   */
    +23  class InvalidScanPathException extends Exception {
    +24  
    +25      /**
    +26       * Creates a new InvalidScanPathException.
    +27       */
    +28      public InvalidScanPathException() {
    +29          super();
    +30      }
    +31  
    +32      /**
    +33       * Creates a new InvalidScanPathException.
    +34       *
    +35       * @param msg a message for the exception
    +36       */
    +37      public InvalidScanPathException(String msg) {
    +38          super(msg);
    +39      }
    +40  
    +41      /**
    +42       * Creates a new InvalidScanPathException.
    +43       *
    +44       * @param ex the cause of the exception
    +45       */
    +46      public InvalidScanPathException(Throwable ex) {
    +47          super(ex);
    +48      }
    +49  
    +50      /**
    +51       * Creates a new InvalidScanPathException.
    +52       *
    +53       * @param msg a message for the exception
    +54       * @param ex the cause of the exception
    +55       */
    +56      public InvalidScanPathException(String msg, Throwable ex) {
    +57          super(msg, ex);
    +58      }
    +59  }
    +
    +
    + + + diff --git a/dependency-check-cli/xref/org/owasp/dependencycheck/package-frame.html b/dependency-check-cli/xref/org/owasp/dependencycheck/package-frame.html index 76311c3c0..1dfb14fb7 100644 --- a/dependency-check-cli/xref/org/owasp/dependencycheck/package-frame.html +++ b/dependency-check-cli/xref/org/owasp/dependencycheck/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Command Line 1.2.5 Reference Package org.owasp.dependencycheck + Dependency-Check Command Line 1.2.6 Reference Package org.owasp.dependencycheck @@ -16,7 +16,16 @@ diff --git a/dependency-check-cli/xref/org/owasp/dependencycheck/package-summary.html b/dependency-check-cli/xref/org/owasp/dependencycheck/package-summary.html index 385084ac6..c3541e08b 100644 --- a/dependency-check-cli/xref/org/owasp/dependencycheck/package-summary.html +++ b/dependency-check-cli/xref/org/owasp/dependencycheck/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Command Line 1.2.5 Reference Package org.owasp.dependencycheck + Dependency-Check Command Line 1.2.6 Reference Package org.owasp.dependencycheck @@ -36,9 +36,24 @@ + + + + + + + + +
    - org.owasp.dependencycheck.cli + org.owasp.dependencycheck
    + ARGUMENT +
    App
    + CliParser +
    + InvalidScanPathException +
    diff --git a/dependency-check-cli/xref/overview-frame.html b/dependency-check-cli/xref/overview-frame.html index a544002d5..b951e4676 100644 --- a/dependency-check-cli/xref/overview-frame.html +++ b/dependency-check-cli/xref/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Command Line 1.2.5 Reference + Dependency-Check Command Line 1.2.6 Reference @@ -17,9 +17,6 @@ diff --git a/dependency-check-cli/xref/overview-summary.html b/dependency-check-cli/xref/overview-summary.html index 6d21377af..f9b4e40f7 100644 --- a/dependency-check-cli/xref/overview-summary.html +++ b/dependency-check-cli/xref/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Command Line 1.2.5 Reference + Dependency-Check Command Line 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Command Line 1.2.5 Reference

    +

    Dependency-Check Command Line 1.2.6 Reference

    @@ -37,11 +37,6 @@ - - -
    org.owasp.dependencycheck
    - org.owasp.dependencycheck.cli -
    diff --git a/dependency-check-core/apidocs/allclasses-frame.html b/dependency-check-core/apidocs/allclasses-frame.html index 276b8e0dc..de008697a 100644 --- a/dependency-check-core/apidocs/allclasses-frame.html +++ b/dependency-check-core/apidocs/allclasses-frame.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Core 1.2.5 API) - +All Classes (Dependency-Check Core 1.2.6 API) + @@ -40,6 +40,8 @@
  • BuildBase.Resources
  • BuildBase.TestResources
  • CachedWebDataSource
  • +
  • CentralAnalyzer
  • +
  • CentralSearch
  • CiManagement
  • CiManagement.Notifiers
  • Confidence
  • diff --git a/dependency-check-core/apidocs/allclasses-noframe.html b/dependency-check-core/apidocs/allclasses-noframe.html index e5659028f..0a92d88d8 100644 --- a/dependency-check-core/apidocs/allclasses-noframe.html +++ b/dependency-check-core/apidocs/allclasses-noframe.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Core 1.2.5 API) - +All Classes (Dependency-Check Core 1.2.6 API) + @@ -40,6 +40,8 @@
  • BuildBase.Resources
  • BuildBase.TestResources
  • CachedWebDataSource
  • +
  • CentralAnalyzer
  • +
  • CentralSearch
  • CiManagement
  • CiManagement.Notifiers
  • Confidence
  • diff --git a/dependency-check-core/apidocs/constant-values.html b/dependency-check-core/apidocs/constant-values.html index 8bededd12..13583cbba 100644 --- a/dependency-check-core/apidocs/constant-values.html +++ b/dependency-check-core/apidocs/constant-values.html @@ -2,16 +2,16 @@ - + -Constant Field Values (Dependency-Check Core 1.2.5 API) - +Constant Field Values (Dependency-Check Core 1.2.6 API) + @@ -94,6 +94,25 @@ +
  • + + + + + + + + + + + + + + +
    org.owasp.dependencycheck.analyzer.NexusAnalyzer 
    Modifier and TypeConstant FieldValue
    + +public static final StringDEFAULT_URL"https://repository.sonatype.org/service/local/"
    +
  • @@ -358,10 +359,11 @@ implements
  • scan

    -
    public void scan(String path)
    +
    public List<Dependency> scan(String path)
    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.
    -
    Parameters:
    path - the path to a file or directory to be analyzed.
    +
    Parameters:
    path - the path to a file or directory to be analyzed
    +
    Returns:
    the list of dependencies scanned
  • @@ -370,10 +372,11 @@ implements
  • scan

    -
    public void scan(File[] files)
    +
    public List<Dependency> scan(File[] files)
    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.
    -
    Parameters:
    files - an array of paths to files or directories to be analyzed.
    Since:
    +
    Parameters:
    files - an array of paths to files or directories to be analyzed.
    +
    Returns:
    the list of dependencies
    Since:
    v0.3.2.5
  • @@ -383,10 +386,11 @@ implements
  • scan

    -
    public void scan(Set<File> files)
    +
    public List<Dependency> scan(Set<File> files)
    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.
    -
    Parameters:
    files - a set of paths to files or directories to be analyzed.
    Since:
    +
    Parameters:
    files - a set of paths to files or directories to be analyzed
    +
    Returns:
    the list of dependencies scanned
    Since:
    v0.3.2.5
  • @@ -396,10 +400,11 @@ implements
  • scan

    -
    public void scan(List<File> files)
    +
    public List<Dependency> scan(List<File> files)
    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.
    -
    Parameters:
    files - a set of paths to files or directories to be analyzed.
    Since:
    +
    Parameters:
    files - a set of paths to files or directories to be analyzed
    +
    Returns:
    the list of dependencies scanned
    Since:
    v0.3.2.5
  • @@ -409,10 +414,11 @@ implements
  • scan

    -
    public void scan(File file)
    +
    public List<Dependency> scan(File file)
    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.
    -
    Parameters:
    file - the path to a file or directory to be analyzed.
    Since:
    +
    Parameters:
    file - the path to a file or directory to be analyzed
    +
    Returns:
    the list of dependencies scanned
    Since:
    v0.3.2.4
  • @@ -422,9 +428,10 @@ implements
  • scanDirectory

    -
    protected void scanDirectory(File dir)
    +
    protected List<Dependency> scanDirectory(File dir)
    Recursively scans files and directories. Any dependencies identified are added to the dependency collection.
    -
    Parameters:
    dir - the directory to scan.
    +
    Parameters:
    dir - the directory to scan
    +
    Returns:
    the list of Dependency objects scanned
  • @@ -433,9 +440,10 @@ implements
  • scanFile

    -
    protected void scanFile(File file)
    +
    protected Dependency scanFile(File file)
    Scans a specified file. If a dependency is identified it is added to the dependency collection.
    -
    Parameters:
    file - The file to scan.
    +
    Parameters:
    file - The file to scan
    +
    Returns:
    the scanned dependency
  • diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/DependencyCheckScanAgent.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/DependencyCheckScanAgent.html index 0ff0d1ce1..364af1353 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/DependencyCheckScanAgent.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/DependencyCheckScanAgent.html @@ -2,16 +2,16 @@ - + -DependencyCheckScanAgent (Dependency-Check Core 1.2.5 API) - +DependencyCheckScanAgent (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/class-use/DependencyCheckScanAgent.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/class-use/DependencyCheckScanAgent.html index d2661e662..b664abadd 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/class-use/DependencyCheckScanAgent.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/class-use/DependencyCheckScanAgent.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.agent.DependencyCheckScanAgent (Dependency-Check Core 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.agent.DependencyCheckScanAgent (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-frame.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-frame.html index cbcde3586..3d07c69cf 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-frame.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-frame.html @@ -2,10 +2,10 @@ - + -org.owasp.dependencycheck.agent (Dependency-Check Core 1.2.5 API) - +org.owasp.dependencycheck.agent (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-summary.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-summary.html index ad596d20a..030122fd6 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-summary.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-summary.html @@ -2,16 +2,16 @@ - + -org.owasp.dependencycheck.agent (Dependency-Check Core 1.2.5 API) - +org.owasp.dependencycheck.agent (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-tree.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-tree.html index 93ec2398b..d505a920e 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-tree.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-tree.html @@ -2,16 +2,16 @@ - + -org.owasp.dependencycheck.agent Class Hierarchy (Dependency-Check Core 1.2.5 API) - +org.owasp.dependencycheck.agent Class Hierarchy (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-use.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-use.html index 9ab16fb17..5c5ff6e19 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-use.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/agent/package-use.html @@ -2,16 +2,16 @@ - + -Uses of Package org.owasp.dependencycheck.agent (Dependency-Check Core 1.2.5 API) - +Uses of Package org.owasp.dependencycheck.agent (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractAnalyzer.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractAnalyzer.html index 500338bbd..7add519f8 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractAnalyzer.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractAnalyzer.html @@ -2,16 +2,16 @@ - + -AbstractAnalyzer (Dependency-Check Core 1.2.5 API) - +AbstractAnalyzer (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractFileTypeAnalyzer.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractFileTypeAnalyzer.html index 545983e73..59edc4d58 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractFileTypeAnalyzer.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractFileTypeAnalyzer.html @@ -2,16 +2,16 @@ - + -AbstractFileTypeAnalyzer (Dependency-Check Core 1.2.5 API) - +AbstractFileTypeAnalyzer (Dependency-Check Core 1.2.6 API) + @@ -106,7 +106,7 @@
    Direct Known Subclasses:
    -
    ArchiveAnalyzer, AssemblyAnalyzer, JarAnalyzer, JavaScriptAnalyzer, NexusAnalyzer, NuspecAnalyzer
    +
    ArchiveAnalyzer, AssemblyAnalyzer, CentralAnalyzer, JarAnalyzer, JavaScriptAnalyzer, NexusAnalyzer, NuspecAnalyzer


    diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.html index 343009a84..82c267d0d 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.html @@ -2,16 +2,16 @@ - + -AbstractSuppressionAnalyzer (Dependency-Check Core 1.2.5 API) - +AbstractSuppressionAnalyzer (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalysisPhase.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalysisPhase.html index 55048a9c4..4a362e61a 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalysisPhase.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalysisPhase.html @@ -2,16 +2,16 @@ - + -AnalysisPhase (Dependency-Check Core 1.2.5 API) - +AnalysisPhase (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/Analyzer.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/Analyzer.html index 69b0937cc..6e9fc6a94 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/Analyzer.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/Analyzer.html @@ -2,16 +2,16 @@ - + -Analyzer (Dependency-Check Core 1.2.5 API) - +Analyzer (Dependency-Check Core 1.2.6 API) + @@ -93,7 +93,7 @@
    All Known Implementing Classes:
    -
    AbstractAnalyzer, AbstractFileTypeAnalyzer, AbstractSuppressionAnalyzer, ArchiveAnalyzer, AssemblyAnalyzer, CPEAnalyzer, CpeSuppressionAnalyzer, DependencyBundlingAnalyzer, FalsePositiveAnalyzer, FileNameAnalyzer, HintAnalyzer, JarAnalyzer, JavaScriptAnalyzer, NexusAnalyzer, NuspecAnalyzer, NvdCveAnalyzer, VulnerabilitySuppressionAnalyzer
    +
    AbstractAnalyzer, AbstractFileTypeAnalyzer, AbstractSuppressionAnalyzer, ArchiveAnalyzer, AssemblyAnalyzer, CentralAnalyzer, CPEAnalyzer, CpeSuppressionAnalyzer, DependencyBundlingAnalyzer, FalsePositiveAnalyzer, FileNameAnalyzer, HintAnalyzer, JarAnalyzer, JavaScriptAnalyzer, NexusAnalyzer, NuspecAnalyzer, NvdCveAnalyzer, VulnerabilitySuppressionAnalyzer


    diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalyzerService.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalyzerService.html index 681be199b..95567abd5 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalyzerService.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AnalyzerService.html @@ -2,16 +2,16 @@ - + -AnalyzerService (Dependency-Check Core 1.2.5 API) - +AnalyzerService (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html index adf38fe04..311717cec 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html @@ -2,16 +2,16 @@ - + -ArchiveAnalyzer (Dependency-Check Core 1.2.5 API) - +ArchiveAnalyzer (Dependency-Check Core 1.2.6 API) + diff --git a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html index 6f97f21fc..c3d545913 100644 --- a/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html +++ b/dependency-check-core/apidocs/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html @@ -2,16 +2,16 @@ - + -AssemblyAnalyzer (Dependency-Check Core 1.2.5 API) - +AssemblyAnalyzer (Dependency-Check Core 1.2.6 API) + @@ -38,7 +38,7 @@ + +boolean +isEnabled() +
    Determine whether to enable this analyzer or not.
    + + @@ -244,7 +244,7 @@ # of dependencies using the latest version available -8 +5 # of dependencies where the next version available is smaller than an incremental version update @@ -256,7 +256,7 @@ # of dependencies where the next version available is a minor version update -11 +13 # of dependencies where the next version available is a major version update @@ -292,7 +292,7 @@ 3.0.0 - + com.google.inject guice 3.0 @@ -301,7 +301,7 @@ jar - +4.0-beta @@ -412,7 +412,7 @@ 1.5 - + org.apache.commons commons-compress 1.8.1 @@ -421,7 +421,7 @@ jar - +1.9 @@ -532,18 +532,6 @@ - -org.apache.velocity -velocity-tools -2.0 -compile - -jar - - - - - org.dojotoolkit dojo-war @@ -555,7 +543,7 @@ 1.3.1 1.4.2 - + org.glassfish.main.admingui war @@ -567,7 +555,7 @@ 4.1 - + org.jsoup jsoup @@ -577,9 +565,9 @@ jar 1.7.3 - +1.8.1 - + org.mortbay.jetty jetty @@ -591,11 +579,11 @@ 6.1.17 - + org.owasp dependency-check-utils -1.2.5 +1.2.6 compile jar @@ -603,7 +591,7 @@ - + org.springframework spring-webmvc @@ -615,7 +603,7 @@ 2.5.6 3.0.0.RELEASE - + org.springframework.retry spring-retry @@ -627,7 +615,7 @@ 1.1.1.RELEASE - + org.springframework.security spring-security-web @@ -639,7 +627,7 @@ 3.0.1.RELEASE - + Status Group Id Artifact Id @@ -657,28 +645,28 @@

    com.google.code.findbugs:annotations

    - + - + - + - + - + - + - + - +
    Status  There is at least one newer incremental version available. Incremental updates are typically passive.
    Group Id com.google.code.findbugs
    Artifact Id annotations
    Current Version 2.0.1
    Scope compile
    Classifier
    Type jar
    Newer versions 2.0.2 Next Incremental
    2.0.3 Latest Incremental
    3.0.0 Next Major
    @@ -686,7 +674,7 @@ - + @@ -704,7 +692,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id com.google.inject
    Typejar
    +jar + +Newer versions +4.0-beta Next Minor
    4.0-beta4
    4.0-beta5 Latest Minor

    com.h2database:h2

    @@ -731,7 +722,7 @@ -
    jar
    Newer versions1.3.173 Next Incremental
    1.3.174
    1.3.175
    1.3.176 Latest Incremental
    1.4.177 Next Minor
    1.4.178
    1.4.179
    1.4.180
    1.4.181 Latest Minor
    +1.3.173 Next Incremental
    1.3.174
    1.3.175
    1.3.176 Latest Incremental
    1.4.177 Next Minor
    1.4.178
    1.4.179
    1.4.180
    1.4.181
    1.4.182 Latest Minor

    com.hazelcast:hazelcast

    @@ -758,7 +749,7 @@ -
    jar
    Newer versions2.5.1 Next Incremental
    2.6 Next Minor
    2.6.1
    2.6.2
    2.6.3
    2.6.4
    2.6.5
    2.6.6
    2.6.7
    2.6.8
    2.6.9
    3.0-RC1
    3.0-RC2 Latest Minor
    3.0 Next Major
    3.0.1
    3.0.2
    3.0.3
    3.1
    3.1.1
    3.1.2
    3.1.3
    3.1.4
    3.1.5
    3.1.6
    3.1.7
    3.2-RC1
    3.2-RC2
    3.2
    3.2.1
    3.2.2
    3.2.3
    3.2.4
    3.2.5
    3.2.6
    3.3-RC1
    3.3-RC2
    3.3-RC3
    3.3
    3.3-EA
    3.3-EA2 Latest Major
    +2.5.1 Next Incremental
    2.6 Next Minor
    2.6.1
    2.6.2
    2.6.3
    2.6.4
    2.6.5
    2.6.6
    2.6.7
    2.6.8
    2.6.9
    3.0-RC1
    3.0-RC2 Latest Minor
    3.0 Next Major
    3.0.1
    3.0.2
    3.0.3
    3.1
    3.1.1
    3.1.2
    3.1.3
    3.1.4
    3.1.5
    3.1.6
    3.1.7
    3.2-RC1
    3.2-RC2
    3.2
    3.2.1
    3.2.2
    3.2.3
    3.2.4
    3.2.5
    3.2.6
    3.3-RC1
    3.3-RC2
    3.3-RC3
    3.3
    3.3-EA
    3.3-EA2
    3.3.1
    3.3.2
    3.3.3
    3.4-EA Latest Major

    commons-cli:commons-cli

    @@ -860,7 +851,7 @@ -
    jar
    Newer versions4.12-beta-1 Next Incremental
    +4.12-beta-1 Next Incremental
    4.12-beta-2
    4.12-beta-3 Latest Incremental

    net.sf.ehcache:ehcache-core

    @@ -947,7 +938,7 @@
    - + @@ -965,7 +956,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.commons
    Typejar
    +jar + +Newer versions +1.9 Next Minor

    org.apache.geronimo.daytrader:daytrader-ear

    @@ -1016,7 +1010,7 @@ -
    jar
    Newer versions4.6.0 Next Minor
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.10.0 Latest Minor
    +4.6.0 Next Minor
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.9.1
    4.10.0
    4.10.1
    4.10.2 Latest Minor

    org.apache.lucene:lucene-core

    @@ -1043,7 +1037,7 @@ -
    jar
    Newer versions4.6.0 Next Minor
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.10.0 Latest Minor
    +4.6.0 Next Minor
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.9.1
    4.10.0
    4.10.1
    4.10.2 Latest Minor

    org.apache.lucene:lucene-queryparser

    @@ -1070,7 +1064,7 @@ -
    jar
    Newer versions4.6.0 Next Minor
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.10.0 Latest Minor
    +4.6.0 Next Minor
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.9.1
    4.10.0
    4.10.1
    4.10.2 Latest Minor

    org.apache.lucene:lucene-test-framework

    @@ -1097,7 +1091,7 @@ -
    jar
    Newer versions4.4.0 Next Minor
    4.5.0
    4.5.1
    4.6.0
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.10.0 Latest Minor
    +4.4.0 Next Minor
    4.5.0
    4.5.1
    4.6.0
    4.6.1
    4.7.0
    4.7.1
    4.7.2
    4.8.0
    4.8.1
    4.9.0
    4.9.1
    4.10.0
    4.10.1
    4.10.2 Latest Minor

    org.apache.maven.scm:maven-scm-provider-cvsexe

    @@ -1124,7 +1118,7 @@ -
    jar
    Newer versions1.9 Next Minor
    1.9.1 Latest Minor
    +1.9 Next Minor
    1.9.1
    1.9.2 Latest Minor

    org.apache.openjpa:openjpa

    @@ -1204,30 +1198,6 @@
    Type jar
    -

    org.apache.velocity:velocity-tools

    - - - - - - - - - - - - - - - - - - - - - -
    Status No newer versions available.
    Group Idorg.apache.velocity
    Artifact Idvelocity-tools
    Current Version2.0
    Scopecompile
    Classifier
    Typejar
    -

    org.dojotoolkit:dojo-war

    @@ -1253,7 +1223,7 @@ -
    war
    Newer versions1.3.1 Next Incremental
    1.3.2 Latest Incremental
    1.4.2 Next Minor
    1.4.3
    1.5.0
    1.6.0
    1.6.1
    1.7.0
    1.7.1
    1.7.2
    1.8.0
    1.8.1
    1.8.2
    1.8.3
    1.9.0b2
    1.9.0
    1.9.1
    1.9.2
    1.9.3
    1.10.0 Latest Minor
    +1.3.1 Next Incremental
    1.3.2 Latest Incremental
    1.4.2 Next Minor
    1.4.3
    1.5.0
    1.6.0
    1.6.1
    1.7.0
    1.7.1
    1.7.2
    1.8.0
    1.8.1
    1.8.2
    1.8.3
    1.9.0b2
    1.9.0
    1.9.1
    1.9.2
    1.9.3
    1.10.0
    1.10.1
    1.10.2 Latest Minor

    org.glassfish.main.admingui:war

    @@ -1307,7 +1277,7 @@ -
    jar
    Newer versions1.7.3 Next Incremental
    +1.7.3 Next Incremental
    1.8.1 Next Minor

    org.mortbay.jetty:jetty

    @@ -1349,7 +1319,7 @@ - + @@ -1385,7 +1355,7 @@ -
    dependency-check-utils
    Current Version1.2.5
    1.2.6
    Scope compile
    jar
    Newer versions2.5.6 Next Incremental
    2.5.6.SEC01
    2.5.6.SEC02
    2.5.6.SEC03 Latest Incremental
    3.0.0.RELEASE Next Major
    3.0.1.RELEASE
    3.0.2.RELEASE
    3.0.3.RELEASE
    3.0.4.RELEASE
    3.0.5.RELEASE
    3.0.6.RELEASE
    3.0.7.RELEASE
    3.1.0.RELEASE
    3.1.1.RELEASE
    3.1.2.RELEASE
    3.2.0.RELEASE
    3.2.1.RELEASE
    3.2.2.RELEASE
    3.2.3.RELEASE
    3.2.4.RELEASE
    3.2.5.RELEASE
    3.2.6.RELEASE
    3.2.7.RELEASE
    3.2.8.RELEASE
    3.2.9.RELEASE
    3.2.10.RELEASE
    3.2.11.RELEASE
    4.0.0.RELEASE
    4.0.1.RELEASE
    4.0.2.RELEASE
    4.0.3.RELEASE
    4.0.4.RELEASE
    4.0.5.RELEASE
    4.0.6.RELEASE
    4.0.7.RELEASE
    4.1.0.RELEASE Latest Major
    +2.5.6 Next Incremental
    2.5.6.SEC01
    2.5.6.SEC02
    2.5.6.SEC03 Latest Incremental
    3.0.0.RELEASE Next Major
    3.0.1.RELEASE
    3.0.2.RELEASE
    3.0.3.RELEASE
    3.0.4.RELEASE
    3.0.5.RELEASE
    3.0.6.RELEASE
    3.0.7.RELEASE
    3.1.0.RELEASE
    3.1.1.RELEASE
    3.1.2.RELEASE
    3.2.0.RELEASE
    3.2.1.RELEASE
    3.2.2.RELEASE
    3.2.3.RELEASE
    3.2.4.RELEASE
    3.2.5.RELEASE
    3.2.6.RELEASE
    3.2.7.RELEASE
    3.2.8.RELEASE
    3.2.9.RELEASE
    3.2.10.RELEASE
    3.2.11.RELEASE
    3.2.12.RELEASE
    4.0.0.RELEASE
    4.0.1.RELEASE
    4.0.2.RELEASE
    4.0.3.RELEASE
    4.0.4.RELEASE
    4.0.5.RELEASE
    4.0.6.RELEASE
    4.0.7.RELEASE
    4.0.8.RELEASE
    4.1.0.RELEASE
    4.1.1.RELEASE
    4.1.2.RELEASE Latest Major

    org.springframework.retry:spring-retry

    @@ -1412,7 +1382,7 @@ -
    jar
    Newer versions1.1.1.RELEASE Next Major
    +1.1.1.RELEASE Next Major
    1.1.2.RELEASE Latest Major

    org.springframework.security:spring-security-web

    diff --git a/dependency-check-core/failsafe-report.html b/dependency-check-core/failsafe-report.html index 01500cf46..286f851f4 100644 --- a/dependency-check-core/failsafe-report.html +++ b/dependency-check-core/failsafe-report.html @@ -1,13 +1,13 @@ - + dependency-check-core - Surefire Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -268,12 +268,12 @@ function toggleDisplay(elementId) { - + -
    Success Rate Time
    3334 0 0 0 100%214.202

    +172.021

    Note: failures are anticipated and checked for with assertions while errors are unanticipated.


    Package List

    @@ -294,23 +294,23 @@ function toggleDisplay(elementId) { 0 0 100% -11.567 +10.04 org.owasp.dependencycheck -2 +1 0 0 0 100% -85.85 +35.85 org.owasp.dependencycheck.analyzer -17 +18 0 0 0 100% -44.255 +54.893 org.owasp.dependencycheck.data.update 4 @@ -318,15 +318,15 @@ function toggleDisplay(elementId) { 0 0 100% -56.755 +54.322 org.owasp.dependencycheck.data.nvdcve -8 +9 0 0 0 100% -15.775
    +16.916

    Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.

    org.owasp.dependencycheck.reporting

    @@ -348,7 +348,7 @@ function toggleDisplay(elementId) { 0 0 100% -11.567
    +10.04

    org.owasp.dependencycheck

    @@ -364,12 +364,12 @@ function toggleDisplay(elementId) { - + -
    EngineIntegrationTest21 0 0 0 100%85.85
    +35.85

    org.owasp.dependencycheck.analyzer

    @@ -390,16 +390,16 @@ function toggleDisplay(elementId) { - + - + - + @@ -408,7 +408,7 @@ function toggleDisplay(elementId) { -
    0 0 100%28.619
    34.97
    CPEAnalyzerIntegrationTest45 0 0 0 100%8.874
    11.822
    VulnerabilitySuppressionAnalyzerIntegrationTest0 0 100%6.762
    +8.101

    org.owasp.dependencycheck.data.update

    @@ -429,7 +429,7 @@ function toggleDisplay(elementId) { - + @@ -438,7 +438,7 @@ function toggleDisplay(elementId) { -
    0 0 100%26.184
    27.313
    StandardUpdateIntegrationTest0 0 100%30.571
    +27.009

    org.owasp.dependencycheck.data.nvdcve

    @@ -454,12 +454,12 @@ function toggleDisplay(elementId) { - + - + @@ -468,7 +468,7 @@ function toggleDisplay(elementId) { -
    CveDBIntegrationTest34 0 0 0 100%5.355
    6.676
    DatabasePropertiesIntegrationTest0 0 100%10.42

    +10.24

    Test Cases

    [Summary] [Package List] [Test Cases]

    @@ -478,15 +478,15 @@ function toggleDisplay(elementId) { testAnalyzeTar -6.076 +8.089 testAnalyzeTgz -13.247 +15.088 testAnalyze -1.312 +2.446 testGetAnalysisPhase @@ -494,19 +494,19 @@ function toggleDisplay(elementId) { testGetName -0.001 +0 testAnalyze_badZip -0.641 +0.896 testInitialize -0.001 +0 testAnalyzeTarGz -7.341 +8.45 testSupportsExtension @@ -514,33 +514,37 @@ function toggleDisplay(elementId) { testGetSupportedExtensions -0
    +0.001

    CPEAnalyzerIntegrationTest

    - + - + - - + + + + + + -
    testSearchCPE2.74
    3.169
    testDetermineCPE3.227
    3.482
    testDetermineCPE_full2.907
    testDetermineIdentifiers2.096
    testDetermineCPE_full3.074
    testBuildSearch0
    +0.001

    VulnerabilitySuppressionAnalyzerIntegrationTest

    - + @@ -555,78 +559,78 @@ function toggleDisplay(elementId) { - + - - + + + + + + -
    testAnalyze6.762
    8.101
    testGetAnalysisPhase
    testOpen2.048
    2.343
    testGetCPEs1.496
    testIsAffected0.534
    testGetCPEs2.016
    testGetVulnerabilities1.811
    +1.783

    DatabasePropertiesIntegrationTest

    - + - + - + - + -
    testSave3.94
    3.225
    testGetProperty_String_String1.547
    1.625
    testGetProperties1.625
    2.412
    testGetProperty_String1.671
    1.511
    testIsEmpty1.637
    +1.467

    NvdCveUpdaterIntegrationTest

    -
    testUpdate26.184
    +27.313

    StandardUpdateIntegrationTest

    - + - + -
    testOpenDataStores3.042
    2.458
    testUpdatesNeeded25.95
    1.619
    testWithinRange1.579
    +22.932

    EngineIntegrationTest

    - - - - -
    testScan7.952
    testEngine77.898
    +35.85

    ReportGeneratorIntegrationTest

    - + diff --git a/dependency-check-core/findbugs.html b/dependency-check-core/findbugs.html index 84a69745d..21a2318ae 100644 --- a/dependency-check-core/findbugs.html +++ b/dependency-check-core/findbugs.html @@ -1,13 +1,13 @@ - + dependency-check-core - FindBugs Bug Detector Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -252,8 +252,8 @@ - - + +
    testGenerateXMLReport11.567
    10.04
    testGenerateReport Errors Missing Classes
    198820011 0 0
    +1 + +org.owasp.dependencycheck.data.update.task.DownloadTask +2

    org.owasp.dependencycheck.Engine

    @@ -287,7 +293,7 @@ - + @@ -300,6 +306,21 @@ +
    org.owasp.dependencycheck.Engine is Serializable; consider declaring a serialVersionUID BAD_PRACTICE SE_NO_SERIALVERSIONID77-50577-533 Medium
    The field org.owasp.dependencycheck.Engine.analyzers is transient but isn't set by deserializationBAD_PRACTICE SE_TRANSIENT_FIELD_NOT_RESTORED Not availableMedium
    +
    +

    org.owasp.dependencycheck.analyzer.ArchiveAnalyzer

    + + + + + + + + + + + +
    BugCategoryDetailsLinePriority
    Redundant nullcheck of org.owasp.dependencycheck.analyzer.ArchiveAnalyzer.tempFileLocation, which is known to be non-null in org.owasp.dependencycheck.analyzer.ArchiveAnalyzer.close()STYLERCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE189 Medium

    org.owasp.dependencycheck.analyzer.AssemblyAnalyzer

    @@ -314,7 +335,7 @@ org.owasp.dependencycheck.analyzer.AssemblyAnalyzer.initializeFileTypeAnalyzer() discards result of readLine after checking if it is nonnull STYLE RV_DONT_JUST_NULL_CHECK_READLINE -236 +239 Medium

    org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer

    @@ -329,13 +350,13 @@ Possible null pointer dereference of currentVersion on branch that might be infeasible in org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer.removeSpuriousCPE(Dependency) STYLE NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE -175 +179 Medium Possible null pointer dereference of nextVersion on branch that might be infeasible in org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer.removeSpuriousCPE(Dependency) STYLE NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE -175 +179 Medium

    org.owasp.dependencycheck.analyzer.JavaScriptAnalyzer

    @@ -351,7 +372,28 @@ I18N DM_DEFAULT_ENCODING 115 -High
    +High +
    +

    org.owasp.dependencycheck.data.update.task.DownloadTask

    + + + + + + + + + + + + + + + + + + +
    BugCategoryDetailsLinePriority
    org.owasp.dependencycheck.data.update.task.DownloadTask.extractGzip(File) may fail to clean up java.io.OutputStream on checked exceptionEXPERIMENTALOBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE279Medium
    exceptional return value of java.io.File.delete() ignored in org.owasp.dependencycheck.data.update.task.DownloadTask.extractGzip(File)BAD_PRACTICERV_RETURN_VALUE_IGNORED_BAD_PRACTICE266Medium
    diff --git a/dependency-check-core/index.html b/dependency-check-core/index.html index e5bdb434c..56658985c 100644 --- a/dependency-check-core/index.html +++ b/dependency-check-core/index.html @@ -1,13 +1,13 @@ - + dependency-check-core - About @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-core/javancss.html b/dependency-check-core/javancss.html index 8457915eb..1b218c092 100644 --- a/dependency-check-core/javancss.html +++ b/dependency-check-core/javancss.html @@ -1,13 +1,13 @@ - + dependency-check-core - JavaNCSS Metric Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -257,13 +257,13 @@ Multi lines comment org.owasp.dependencycheck.analyzer -23 -172 -2250 -189 -1278 -158 -654 +24 +185 +2382 +204 +1368 +160 +697 org.owasp.dependencycheck.jaxb.pom.generated 86 @@ -276,10 +276,10 @@ org.owasp.dependencycheck.dependency 14 -176 -811 -173 -1097 +177 +831 +174 +1104 17 231 @@ -295,16 +295,16 @@ org.owasp.dependencycheck.suppression 6 55 -402 +401 61 -379 +383 5 -154 +151 org.owasp.dependencycheck.utils 10 43 -348 +349 40 238 6 @@ -349,9 +349,9 @@ org.owasp.dependencycheck 1 22 -224 +241 22 -124 +133 6 48 @@ -366,17 +366,17 @@ org.owasp.dependencycheck.data.update.task 2 -17 -173 18 -132 +207 +19 +140 0 60 org.owasp.dependencycheck.reporting 3 14 -159 +169 17 118 2 @@ -400,15 +400,24 @@ 0 85 +org.owasp.dependencycheck.data.central +1 +2 +69 +3 +23 +8 +36 + org.owasp.dependencycheck.data.cwe 2 5 -48 +49 6 29 1 53 - + org.owasp.dependencycheck.exception 2 8 @@ -417,7 +426,7 @@ 48 0 50 - + org.owasp.dependencycheck.analyzer.exception 2 8 @@ -426,7 +435,7 @@ 48 0 51 - + org.owasp.dependencycheck.data.update.exception 2 6 @@ -435,7 +444,7 @@ 40 0 50 - + org.owasp.dependencycheck.jaxb.pom 1 4 @@ -445,7 +454,7 @@ 0 30 - + @@ -453,49 +462,55 @@ - - - - - - - -
    Classes total Methods total NCSS totalJavadoc lines Single lines comment Multi lines comment
    195136186171505125854952680
    + +197 +1378 +8900 +1525 +12726 +505 +2756

    Objects

    [ package ] [ object ] [ method ] [ explanation ]

    TOP 30 classes containing the most NCSS.

    - + - - - - - - + + + + + + - + - + - + + + + + + + @@ -509,35 +524,35 @@ + + + + + + - - - - - - - - - - - - - - + + + + + + + + @@ -545,53 +560,53 @@ - - - - - - - + - + - + - + - + - + + + + + + + @@ -605,23 +620,23 @@ + + + + + + - + - - - - - - @@ -629,24 +644,18 @@ - - - - - - - + - + @@ -654,174 +663,180 @@
    Object NCSS Methods Classes Javadocs
    org.owasp.dependencycheck.analyzer.JarAnalyzer62930136
    org.owasp.dependencycheck.analyzer.JarAnalyzer66431137
    org.owasp.dependencycheck.data.nvdcve.CveDB 406 20 0 21
    org.owasp.dependencycheck.agent.DependencyCheckScanAgent 281 66 0 67
    org.owasp.dependencycheck.analyzer.CPEAnalyzer263274 16 2 29
    org.owasp.dependencycheck.dependency.Dependency21851052
    org.owasp.dependencycheck.jaxb.pom.generated.Model 2170 13
    org.owasp.dependencycheck.Engine21122022
    org.owasp.dependencycheck.data.update.xml.NvdCve20Handler 209 8 1 24
    org.owasp.dependencycheck.dependency.Dependency19950051
    org.owasp.dependencycheck.Engine19422022
    org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer 179 13 013
    14
    org.owasp.dependencycheck.jaxb.pom.generated.ObjectFactory 175 87 0 88
    org.owasp.dependencycheck.analyzer.DependencyBundlingAnalyzer17313014
    org.owasp.dependencycheck.suppression.SuppressionRule 1670 31
    org.owasp.dependencycheck.analyzer.DependencyBundlingAnalyzer15711012
    org.owasp.dependencycheck.data.update.StandardUpdate 143 8 0 9
    org.owasp.dependencycheck.data.nvdcve.ConnectionFactory 138 7 0 8
    org.owasp.dependencycheck.analyzer.AssemblyAnalyzer 134 8 0 8
    org.owasp.dependencycheck.dependency.EvidenceCollection 128 19 5 20
    org.owasp.dependencycheck.dependency.VulnerableSoftware 117 19 0 20
    org.owasp.dependencycheck.dependency.Vulnerability 108 36 0 35
    org.owasp.dependencycheck.data.cpe.CpeMemoryIndex 107 14 0 15
    org.owasp.dependencycheck.data.update.task.DownloadTask10612012
    org.owasp.dependencycheck.dependency.Evidence 1025 39
    org.owasp.dependencycheck.reporting.ReportGenerator98617
    org.owasp.dependencycheck.utils.DependencyVersion 98 11 0 11
    org.owasp.dependencycheck.jaxb.pom.generated.Profile 97 24 6 37
    org.owasp.dependencycheck.reporting.ReportGenerator88617
    org.owasp.dependencycheck.data.update.xml.NvdCve12Handler 801 10
    org.owasp.dependencycheck.data.update.task.DownloadTask7711011
    org.owasp.dependencycheck.jaxb.pom.generated.Plugin 70 18 4 27
    org.owasp.dependencycheck.suppression.SuppressionHandler 67 5 0 6
    org.owasp.dependencycheck.jaxb.pom.generated.BuildBase 65 1625

    TOP 30 classes containing the most methods.

    - + - + - + - + - - - - - - + + + + + + - - - - - - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + @@ -833,73 +848,72 @@ - - - - - - -
    Object NCSS Methods Classes Javadocs
    org.owasp.dependencycheck.jaxb.pom.generated.ObjectFactory 175 87 0 88
    org.owasp.dependencycheck.agent.DependencyCheckScanAgent 281 66 0 67
    org.owasp.dependencycheck.jaxb.pom.generated.Model 217 60 11 83
    org.owasp.dependencycheck.dependency.Dependency19950051
    org.owasp.dependencycheck.dependency.Dependency21851052
    org.owasp.dependencycheck.dependency.Vulnerability 108 36 0 35
    org.owasp.dependencycheck.analyzer.JarAnalyzer62930136
    org.owasp.dependencycheck.analyzer.JarAnalyzer66431137
    org.owasp.dependencycheck.suppression.SuppressionRule 167 30 0 31
    org.owasp.dependencycheck.jaxb.pom.generated.Build 101 28 5 39
    org.owasp.dependencycheck.jaxb.pom.generated.Profile 97 24 6 37
    org.owasp.dependencycheck.Engine194211 22 0 22
    org.owasp.dependencycheck.dependency.Evidence 102 21 0 22
    org.owasp.dependencycheck.data.nvdcve.CveDB 406 20 0 21
    org.owasp.dependencycheck.dependency.EvidenceCollection 128 19 5 20
    org.owasp.dependencycheck.dependency.VulnerableSoftware 117 19 0 20
    org.owasp.dependencycheck.jaxb.pom.generated.Dependency 52 18 1 21
    org.owasp.dependencycheck.jaxb.pom.generated.Developer 58 18 2 23
    org.owasp.dependencycheck.jaxb.pom.generated.Plugin 70 18 4 27
    org.owasp.dependencycheck.data.update.xml.NvdCve20Handler.Element 51 17 0 17
    org.owasp.dependencycheck.analyzer.CPEAnalyzer263274 16 2 29
    org.owasp.dependencycheck.dependency.Identifier 55 16 0 15
    org.owasp.dependencycheck.jaxb.pom.generated.BuildBase 65 16 4 25
    org.owasp.dependencycheck.jaxb.pom.generated.Contributor 53 16 2 21
    org.owasp.dependencycheck.data.nuget.NugetPackage 48 15 0 14
    org.owasp.dependencycheck.data.cpe.CpeMemoryIndex 107 14 0 15
    org.owasp.dependencycheck.jaxb.pom.generated.Notifier 42 14 1 17
    org.owasp.dependencycheck.analyzer.AbstractFileTypeAnalyzer 50 13 0 14
    org.owasp.dependencycheck.analyzer.DependencyBundlingAnalyzer17313014
    org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer 179 13 013
    14
    org.owasp.dependencycheck.analyzer.ArchiveAnalyzer 21148 12 011
    org.owasp.dependencycheck.data.nexus.MavenArtifact3312013
    +11

    Averages.

    - + - - - + + + - -
    NCSS average Program NCSS Classes average Methods average Javadocs average
    40.768,617.00
    41.588,900.00 0.326.988.17
    +6.99 +8.19

    Methods

    [ package ] [ object ] [ method ] [ explanation ]

    TOP 30 Methods containing the most NCSS.

    - + - + - + - - - - - + + + + + - + - + - + + + + + + @@ -961,30 +975,30 @@ - - - - - - + - + - + + + + + + @@ -1006,27 +1020,22 @@ - + - - - - - - -
    Methods NCSS CCN Javadocs
    org.owasp.dependencycheck.analyzer.JarAnalyzer.parseManifest(Dependency,ClassNameInformation) 118 45 1
    org.owasp.dependencycheck.data.nvdcve.CveDB.updateVulnerability(Vulnerability) 116 17 1
    org.owasp.dependencycheck.analyzer.JarAnalyzer.setPomEvidence(Dependency,Model,Properties,ClassNameInformation)87471
    org.owasp.dependencycheck.analyzer.JarAnalyzer.setPomEvidence(Dependency,Model,Properties,ClassNameInformation)85451
    org.owasp.dependencycheck.data.update.xml.NvdCve20Handler.endElement(String,String,String) 71 27 0
    org.owasp.dependencycheck.data.update.StandardUpdate.update() 62 25 1
    org.owasp.dependencycheck.analyzer.CPEAnalyzer.determineIdentifiers(Dependency,String,String,Confidence) 60 23 1
    org.owasp.dependencycheck.data.nvdcve.ConnectionFactory.initialize() 60 25 1
    org.owasp.dependencycheck.analyzer.JarAnalyzer.analyzePOM(Dependency,ClassNameInformation,Engine)56161
    org.owasp.dependencycheck.analyzer.AssemblyAnalyzer.initializeFileTypeAnalyzer() 5512 1
    org.owasp.dependencycheck.analyzer.JarAnalyzer.analyzePOM(Dependency,ClassNameInformation,Engine)42111
    org.owasp.dependencycheck.data.update.StandardUpdate.updatesNeeded() 42 17 1
    org.owasp.dependencycheck.reporting.ReportGenerator.generateReport(String,String) 41 16 1
    org.owasp.dependencycheck.analyzer.JarAnalyzer.addDescription(Dependency,String,String,String) 40 11 1
    org.owasp.dependencycheck.data.update.xml.NvdCve12Handler.startElement(String,String,String,Attributes) 40 14 0
    org.owasp.dependencycheck.data.central.CentralSearch.searchSha1(String)38131
    org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer.removeSpuriousCPE(Dependency) 3514 1
    org.owasp.dependencycheck.utils.DependencyVersion.compareTo(DependencyVersion)org.owasp.dependencycheck.data.update.task.DownloadTask.call() 32190
    org.owasp.dependencycheck.suppression.SuppressionRule.toString()31161
    +10 +0

    Averages.

    - + - - - - + + + +
    Program NCSS NCSS average CCN average Javadocs average
    8,617.004.872.36
    8,900.004.972.39 0.97

    Explanations

    @@ -1035,46 +1044,46 @@

    Statements for JavaNCSS are not statements as specified in the Java Language Specification but include all kinds of declarations too. Roughly spoken, NCSS is approximately equivalent to counting ';' and '{' characters in Java source files.

    Not counted are empty statements, empty blocks or semicolons after closing brackets. Of course, comments don't get counted too. Closing brackets also never get counted, the same applies to blocks in general.

    - + - + - + - + - + - + - + - + - + - + - +
    Examples
    Package declaration package java.lang;
    Import declaration import java.awt.*;
    Class declaration
    • public class Foo {
    • public class Foo extends Bla {
    Interface declaration public interface Able ; {
    Field declaration
    • int a;
    • int a, b, c = 5, d = 6;
    Method declaration
    • public void cry();
    • public void gib() throws DeadException {
    Constructor declaration public Foo() {
    Constructor invocation
    • this();
    • super();
    Statement declaration
      @@ -1084,7 +1093,7 @@
    • if (3 == 4);
    • if (4 == 4) { ;
    • } else {
    Label declaration fine :

    In some cases consecutive semicolons are illegal according to the JLS but JavaNCSS still tolerates them (thought JavaNCSS is still more strict as 'javac'). Nevertheless they are never counted as two statements.

    diff --git a/dependency-check-core/license.html b/dependency-check-core/license.html index 8df58a9e6..f84d09fa2 100644 --- a/dependency-check-core/license.html +++ b/dependency-check-core/license.html @@ -1,13 +1,13 @@ - + dependency-check-core - Project License @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-core/plugin-updates-report.html b/dependency-check-core/plugin-updates-report.html index 11ccb82b7..e88deb03f 100644 --- a/dependency-check-core/plugin-updates-report.html +++ b/dependency-check-core/plugin-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-core - Plugin Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -244,7 +244,7 @@ # of plugins using the latest version available -6 +1 # of plugins where the next version available is smaller than an incremental version update @@ -256,7 +256,7 @@ # of plugins where the next version available is a minor version update -8 +13 # of plugins where the next version available is a major version update @@ -342,13 +342,13 @@ Next Major Dependency status - + com.github.github site-maven-plugin -0.9 - +0.9 +0.10 @@ -362,13 +362,13 @@ - + org.apache.maven.plugins maven-compiler-plugin -3.1 - +3.1 +3.2 @@ -382,13 +382,13 @@ - + org.apache.maven.plugins maven-failsafe-plugin -2.16 - +2.16 +2.17 @@ -402,13 +402,13 @@ - + org.apache.maven.plugins maven-jar-plugin -2.4 - +2.4 +2.5 @@ -432,13 +432,13 @@ - + org.apache.maven.plugins maven-surefire-plugin -2.16 - +2.16 +2.17 @@ -469,7 +469,7 @@ - + @@ -478,7 +478,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id com.github.github
    site-maven-plugin
    Current Version0.9
    +0.9 + +Newer versions +0.10 Next Minor

    Plugin org.apache.maven.plugins:maven-antrun-plugin

    @@ -514,7 +517,7 @@ -
    2.2-beta-5
    Newer versions2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4 Latest Minor
    +2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4
    2.4.1
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-clean-plugin

    @@ -532,13 +535,13 @@ -
    2.4.1
    Newer versions2.5 Next Minor
    +2.5 Next Minor
    2.6
    2.6.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-compiler-plugin

    - + @@ -547,7 +550,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-compiler-plugin
    Current Version3.1
    +3.1 + +Newer versions +3.2 Next Minor

    Plugin org.apache.maven.plugins:maven-dependency-plugin

    @@ -565,7 +571,7 @@ -
    2.1
    Newer versions2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8 Latest Minor
    +2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8
    2.9 Latest Minor

    Plugin org.apache.maven.plugins:maven-deploy-plugin

    @@ -583,13 +589,13 @@ -
    2.7
    Newer versions2.8 Next Minor
    2.8.1 Latest Minor
    +2.8 Next Minor
    2.8.1
    2.8.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-failsafe-plugin

    - + @@ -598,7 +604,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-failsafe-plugin
    Current Version2.16
    +2.16 + +Newer versions +2.17 Next Minor
    2.18 Latest Minor

    Plugin org.apache.maven.plugins:maven-install-plugin

    @@ -616,13 +625,13 @@ -
    2.3.1
    Newer versions2.4 Next Minor
    2.5
    2.5.1 Latest Minor
    +2.4 Next Minor
    2.5
    2.5.1
    2.5.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-jar-plugin

    - + @@ -631,7 +640,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-jar-plugin
    Current Version2.4
    +2.4 + +Newer versions +2.5 Next Minor

    Plugin org.apache.maven.plugins:maven-release-plugin

    @@ -649,7 +661,7 @@ -
    2.0
    Newer versions2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2 Latest Minor
    +2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-resources-plugin

    @@ -667,7 +679,7 @@ -
    2.5
    Newer versions2.6 Next Minor
    +2.6 Next Minor
    2.7 Latest Minor

    Plugin org.apache.maven.plugins:maven-site-plugin

    @@ -751,7 +763,7 @@
    - + @@ -760,7 +772,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-surefire-plugin
    Current Version2.16
    +2.16 + +Newer versions +2.17 Next Minor
    2.18 Latest Minor

    Plugin org.codehaus.mojo:cobertura-maven-plugin

    diff --git a/dependency-check-core/pmd.html b/dependency-check-core/pmd.html index 734676cae..6abdd8c17 100644 --- a/dependency-check-core/pmd.html +++ b/dependency-check-core/pmd.html @@ -1,13 +1,13 @@ - + dependency-check-core - PMD Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -250,10 +250,10 @@ - + -
    Line
    These nested if statements could be combined362–365
    361–364
    These nested if statements could be combined376–379
    +375–378

    org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java

    @@ -262,7 +262,7 @@ -
    Line
    Avoid empty while statements236–238
    +239–241

    org/owasp/dependencycheck/analyzer/CPEAnalyzer.java

    @@ -271,215 +271,221 @@ - - - - - - - + - + -
    Line
    Useless parentheses.219
    Avoid unused method parameters such as 'currentConfidence'.495
    These nested if statements could be combined530–535
    221
    These nested if statements could be combined531–534
    541–546
    These nested if statements could be combined540–543
    +542–545 + +These nested if statements could be combined +551–554

    org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java

    - + - +
    Violation Line
    These nested if statements could be combined 228–230

    org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java

    - + - - - -
    Violation Line
    These nested if statements could be combined100–106
    These nested if statements could be combined164–184
    +105–111 + +These nested if statements could be combined +168–188

    org/owasp/dependencycheck/analyzer/JarAnalyzer.java

    - + - + -
    Violation Line
    Useless parentheses.383
    +401

    org/owasp/dependencycheck/analyzer/JavaScriptAnalyzer.java

    - + - +
    Violation Line
    Avoid unused local variables such as 'extractComments'. 113
    -

    org/owasp/dependencycheck/analyzer/NvdCveAnalyzer.java

    +

    org/owasp/dependencycheck/analyzer/NexusAnalyzer.java

    - + + + +
    Violation Line
    Useless parentheses.99
    +
    +

    org/owasp/dependencycheck/analyzer/NvdCveAnalyzer.java

    + + + +
    ViolationLine
    Useless parentheses. 76

    org/owasp/dependencycheck/data/cpe/IndexEntry.java

    - + - + - +
    Violation Line
    Useless parentheses. 172
    Useless parentheses. 175

    org/owasp/dependencycheck/data/nvdcve/CveDB.java

    - + - +
    Violation Line
    Useless parentheses. 745

    org/owasp/dependencycheck/data/nvdcve/DriverShim.java

    - + - +
    Violation Line
    Useless parentheses. 192

    org/owasp/dependencycheck/data/update/StandardUpdate.java

    - + - +
    Violation Line
    Useless parentheses. 118

    org/owasp/dependencycheck/dependency/Dependency.java

    - + - - - - + - + - + - + - + - + -
    Violation Line
    Useless parentheses.600
    Useless parentheses.603
    641
    Useless parentheses.606
    644
    Useless parentheses.609
    647
    Useless parentheses.612
    650
    Useless parentheses.615
    653
    Useless parentheses.630
    656
    Useless parentheses.633
    +671 + +Useless parentheses. +674

    org/owasp/dependencycheck/dependency/Evidence.java

    - + - +
    Violation Line
    Useless parentheses. 204

    org/owasp/dependencycheck/dependency/Identifier.java

    - + - + - +
    Violation Line
    Useless parentheses. 177
    Useless parentheses. 180

    org/owasp/dependencycheck/dependency/Reference.java

    - + - - - - + + + +
    Violation Line
    Useless parentheses.109
    Useless parentheses.112
    109
    Useless parentheses.112
    Useless parentheses. 115

    org/owasp/dependencycheck/dependency/Vulnerability.java

    - + - +
    Violation Line
    Useless parentheses. 373

    org/owasp/dependencycheck/dependency/VulnerableSoftware.java

    - + - - - - + + + +
    Violation Line
    Useless parentheses.143
    Useless parentheses.182
    143
    Useless parentheses.182
    Useless parentheses. 187

    org/owasp/dependencycheck/suppression/PropertyType.java

    - + - +
    Violation Line
    Useless parentheses. 161

    org/owasp/dependencycheck/utils/DependencyVersion.java

    - + - + - +
    Violation Line
    Useless parentheses. 135
    Useless parentheses. 196
    diff --git a/dependency-check-core/project-info.html b/dependency-check-core/project-info.html index ad8c05ad6..557f22f7c 100644 --- a/dependency-check-core/project-info.html +++ b/dependency-check-core/project-info.html @@ -1,13 +1,13 @@ - + dependency-check-core - Project Information @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-core/project-reports.html b/dependency-check-core/project-reports.html index d5df97f18..8096d4dfe 100644 --- a/dependency-check-core/project-reports.html +++ b/dependency-check-core/project-reports.html @@ -1,13 +1,13 @@ - + dependency-check-core - Generated Reports @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-core/project-summary.html b/dependency-check-core/project-summary.html index 4b34e7cfa..506e8a05c 100644 --- a/dependency-check-core/project-summary.html +++ b/dependency-check-core/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check-core - Project Summary @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -203,7 +203,7 @@ dependency-check-core Version -1.2.5 +1.2.6 Type jar diff --git a/dependency-check-core/surefire-report.html b/dependency-check-core/surefire-report.html index 784edd865..ab62e272d 100644 --- a/dependency-check-core/surefire-report.html +++ b/dependency-check-core/surefire-report.html @@ -1,13 +1,13 @@ - + dependency-check-core - Surefire Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -268,12 +268,12 @@ function toggleDisplay(elementId) { Success Rate Time -149 +158 0 0 1 -99.329% -19.855
    +99.367% +40.427

    Note: failures are anticipated and checked for with assertions while errors are unanticipated.


    Package List

    @@ -296,29 +296,77 @@ function toggleDisplay(elementId) { 100% 0 -org.owasp.dependencycheck.data.nuget -3 -0 -0 -0 -100% -0 - org.owasp.dependencycheck.data.nexus 4 0 0 0 100% -1.553 - +0.893 + org.owasp.dependencycheck.dependency -23 +25 0 0 0 100% -0.033 +0.006 + +org.owasp.dependencycheck.data.central +5 +0 +0 +0 +100% +0.166 + +org.owasp.dependencycheck.analyzer +43 +0 +0 +1 +97.674% +15.847 + +org.owasp.dependencycheck.data.update.xml +2 +0 +0 +0 +100% +0.155 + +org.owasp.dependencycheck.data.update +10 +0 +0 +0 +100% +0 + +org.owasp.dependencycheck.suppression +37 +0 +0 +0 +100% +0 + +org.owasp.dependencycheck.data.cpe +1 +0 +0 +0 +100% +0 + +org.owasp.dependencycheck.data.nuget +3 +0 +0 +0 +100% +0.02 org.owasp.dependencycheck.utils 10 @@ -328,29 +376,13 @@ function toggleDisplay(elementId) { 100% 0 -org.owasp.dependencycheck.data.update.xml -2 -0 -0 -0 -100% -0.349 - -org.owasp.dependencycheck.analyzer -42 -0 -0 +org.owasp.dependencycheck.data.update.task 1 -97.619% -16.787 - -org.owasp.dependencycheck.data.update -10 0 0 0 100% -0 +22.211 org.owasp.dependencycheck.data.nvdcve 6 @@ -358,31 +390,15 @@ function toggleDisplay(elementId) { 0 0 100% -0.039 +0.046 -org.owasp.dependencycheck.suppression -37 -0 -0 -0 -100% -0.005 - org.owasp.dependencycheck.data.lucene 10 0 0 0 100% -1.089 - -org.owasp.dependencycheck.data.cpe -1 -0 -0 -0 -100% -0
    +1.083

    Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.

    org.owasp.dependencycheck.data.cwe

    @@ -406,27 +422,6 @@ function toggleDisplay(elementId) { 100% 0
    -

    org.owasp.dependencycheck.data.nuget

    - - - - - - - - - - - - - - - - - - -
    ClassTestsErrors FailuresSkippedSuccess RateTime
    XPathNuspecParserTest3000100%0
    -

    org.owasp.dependencycheck.data.nexus

    @@ -446,7 +441,7 @@ function toggleDisplay(elementId) { -
    0 0 100%1.553
    +0.893

    org.owasp.dependencycheck.dependency

    @@ -462,12 +457,12 @@ function toggleDisplay(elementId) { - + - + @@ -478,7 +473,7 @@ function toggleDisplay(elementId) {
    DependencyTest2022 0 0 0 100%0.033
    0.006
    VulnerableSoftwareTest100% 0
    -

    org.owasp.dependencycheck.utils

    +

    org.owasp.dependencycheck.data.central

    @@ -490,27 +485,120 @@ function toggleDisplay(elementId) { - - - + + + + + + + +
    Success Rate Time
    DependencyVersionTest7CentralSearchTest5000100%0.166
    +
    +

    org.owasp.dependencycheck.analyzer

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -536,7 +624,7 @@ function toggleDisplay(elementId) { - + @@ -545,118 +633,7 @@ function toggleDisplay(elementId) { -
    ClassTestsErrors FailuresSkippedSuccess RateTime
    AbstractFileTypeAnalyzerTest1000100%0.023
    AbstractSuppressionAnalyzerTest4000100%0.566
    AnalyzerServiceTest1000100%0.583
    AssemblyAnalyzerTest500180%1
    DependencyBundlingAnalyzerTest5 0 0 0 100% 0
    DependencyVersionUtilTest1FalsePositiveAnalyzerTest3 0 0 0 100% 0
    FilterTest2FileNameAnalyzerTest5000100%0.034
    HintAnalyzerTest3000100%11.292
    JarAnalyzerTest5000100%2.349
    JavaScriptAnalyzerTest7000100%0
    NuspecAnalyzerTest4 0 0 00 0 100%0.121
    0.001
    NvdCve_2_0_HandlerTest0 0 100%0.228
    -
    -

    org.owasp.dependencycheck.analyzer

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ClassTestsErrors FailuresSkippedSuccess RateTime
    AbstractFileTypeAnalyzerTest1000100%0.089
    AbstractSuppressionAnalyzerTest4000100%0.681
    AnalyzerServiceTest1000100%0.684
    AssemblyAnalyzerTest500180%1.389
    DependencyBundlingAnalyzerTest4000100%0
    FalsePositiveAnalyzerTest3000100%0
    FileNameAnalyzerTest5000100%0.004
    HintAnalyzerTest3000100%12.317
    JarAnalyzerTest5000100%1.564
    JavaScriptAnalyzerTest7000100%0.059
    NuspecAnalyzerTest4000100%0
    +0.154

    org.owasp.dependencycheck.data.update

    @@ -688,27 +665,6 @@ function toggleDisplay(elementId) {
    100% 0
    -

    org.owasp.dependencycheck.data.nvdcve

    - - - - - - - - - - - - - - - - - - -
    ClassTestsErrors FailuresSkippedSuccess RateTime
    DriverLoaderTest6000100%0.039
    -

    org.owasp.dependencycheck.suppression

    @@ -755,7 +711,130 @@ function toggleDisplay(elementId) { -
    0 0 100%0.005
    +0 +
    +

    org.owasp.dependencycheck.data.cpe

    + + + + + + + + + + + + + + + + + + +
    ClassTestsErrors FailuresSkippedSuccess RateTime
    IndexEntryTest1000100%0
    +
    +

    org.owasp.dependencycheck.data.nuget

    + + + + + + + + + + + + + + + + + + +
    ClassTestsErrors FailuresSkippedSuccess RateTime
    XPathNuspecParserTest3000100%0.02
    +
    +

    org.owasp.dependencycheck.utils

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ClassTestsErrors FailuresSkippedSuccess RateTime
    DependencyVersionTest7000100%0
    DependencyVersionUtilTest1000100%0
    FilterTest2000100%0
    +
    +

    org.owasp.dependencycheck.data.update.task

    + + + + + + + + + + + + + + + + + + +
    ClassTestsErrors FailuresSkippedSuccess RateTime
    DownloadTaskTest1000100%22.211
    +
    +

    org.owasp.dependencycheck.data.nvdcve

    + + + + + + + + + + + + + + + + + + +
    ClassTestsErrors FailuresSkippedSuccess RateTime
    DriverLoaderTest6000100%0.046

    org.owasp.dependencycheck.data.lucene

    @@ -785,7 +864,7 @@ function toggleDisplay(elementId) { - + @@ -794,7 +873,7 @@ function toggleDisplay(elementId) { - + @@ -803,28 +882,7 @@ function toggleDisplay(elementId) { -
    0 0 100%0.001
    0
    TokenPairConcatenatingFilterTest0 0 100%0.141
    0.073
    UrlTokenizingFilterTest0 0 100%0.947
    -
    -

    org.owasp.dependencycheck.data.cpe

    - - - - - - - - - - - - - - - - - - -
    ClassTestsErrors FailuresSkippedSuccess RateTime
    IndexEntryTest1000100%0

    +1.01

    Test Cases

    [Summary] [Package List] [Test Cases]

    @@ -834,44 +892,44 @@ function toggleDisplay(elementId) { testNewHashSet -0.089
    +0.023

    AbstractSuppressionAnalyzerTest

    - + - + - + -
    testFailureToLocateSuppressionFileAnywhere0.524
    0.399
    testGetRulesFromSuppressionFileFromURL0.112
    0.148
    testGetRulesFromSuppressionFileInClasspath0.045
    0.018
    testGetSupportedExtensions0
    +0.001

    AnalyzerServiceTest

    -
    testGetAnalyzers0.684
    +0.583

    AssemblyAnalyzerTest

    - + - + - + -
    testGetName0.328
    0.281
    testAnalysis0.398
    0.167
    testWithSettingMono @@ -884,11 +942,11 @@ function toggleDisplay(elementId) {
    testNonexistent0.264
    0.18
    testLog4Net0.399
    +0.372

    DependencyBundlingAnalyzerTest

    @@ -906,6 +964,10 @@ function toggleDisplay(elementId) { + + + +
    0
    testFirstPathIsShortest0
    testIsCore 0
    @@ -929,68 +991,7 @@ function toggleDisplay(elementId) { testAnalyze -0.004 - - -testClose -0 - - -testGetAnalysisPhase -0 - - -testGetName -0 - - -testInitialize -0
    -
    -

    HintAnalyzerTest

    - - - - - - - - - - - - -
    testAnalyze12.3
    testGetAnalysisPhase0.017
    testGetName0
    -
    -

    JarAnalyzerTest

    - - - - - - - - - - - - - - - - - - - - -
    testAnalyze0.415
    testGetName0.28
    testInterpolateString0.262
    testSupportsExtension0.283
    testGetSupportedExtensions0.324
    -
    -

    JavaScriptAnalyzerTest

    - - - - - + @@ -1006,6 +1007,67 @@ function toggleDisplay(elementId) { +
    testAnalyze0.058
    0.033
    testClose
    testInitialize0
    +
    +

    HintAnalyzerTest

    + + + + + + + + + + + + +
    testAnalyze11.292
    testGetAnalysisPhase0
    testGetName0
    +
    +

    JarAnalyzerTest

    + + + + + + + + + + + + + + + + + + + + +
    testAnalyze0.648
    testGetName0.483
    testInterpolateString0.466
    testSupportsExtension0.353
    testGetSupportedExtensions0.399
    +
    +

    JavaScriptAnalyzerTest

    + + + + + + + + + + + + + + + + + + + + @@ -1035,6 +1097,29 @@ function toggleDisplay(elementId) {
    testAnalyze0
    testClose0
    testGetAnalysisPhase0
    testGetName0
    testInitialize 0
    testGetSupportedExtensions 0
    +

    CentralSearchTest

    + + + + + + + + + + + + + + + + + + + + +
    testMultipleReturns0.071
    testNullSha10
    testMalformedSha10
    testValidSha10.053
    testMissingSha10.042
    +

    IndexEntryTest

    @@ -1073,67 +1158,67 @@ function toggleDisplay(elementId) { -
    testAppendEscapedLuceneQuery_null0.001
    +0

    TokenPairConcatenatingFilterTest

    - - + + - -
    testClear0.131
    testExamples0.073
    testExamples0.01
    +testClear +0

    UrlTokenizingFilterTest

    - + - + -
    testRandomStrings0.92
    0.994
    testExamples0.01
    0.008
    testEmptyTerm0.017
    +0.008

    NexusSearchTest

    - + - + - + -
    testNullSha11.175
    0.675
    testMalformedSha10.071
    0.041
    testValidSha10.155
    0.099
    testMissingSha10.152
    +0.078

    XPathNuspecParserTest

    - + - + -
    testGoodDocument0
    0.007
    testMissingDocument0
    0.005
    testNotNuspec0
    +0.008

    DriverLoaderTest

    @@ -1156,11 +1241,11 @@ function toggleDisplay(elementId) { - + -
    testLoad_String_String0
    0.023
    testLoad_String_String_multiple_paths0.039
    +0.023

    NvdCveInfoTest

    @@ -1185,6 +1270,13 @@ function toggleDisplay(elementId) {
    testSetGetId 0
    +

    DownloadTaskTest

    + + + + +
    testCall22.211
    +

    UpdateableNvdCveTest

    @@ -1213,14 +1305,14 @@ function toggleDisplay(elementId) { -
    testParse0.121
    +0.001

    NvdCve_2_0_HandlerTest

    -
    testParse0.228
    +0.154

    DependencyTest

    @@ -1239,11 +1331,19 @@ function toggleDisplay(elementId) { + + + + + + + + - + @@ -1259,7 +1359,7 @@ function toggleDisplay(elementId) { - + @@ -1287,7 +1387,7 @@ function toggleDisplay(elementId) { - + @@ -1303,7 +1403,7 @@ function toggleDisplay(elementId) { -
    testGetActualFilePath0.001
    testAddAsEvidence0
    testAddAsEvidenceWithEmptyArtefact 0
    testSetFileExtension0.001
    0
    testGetIdentifiers
    testGetVendorEvidence0
    0.001
    testSetFileName
    testGetMd5sum0.008
    0
    testGetEvidence
    testSetActualFilePath0.024
    +0.004

    VulnerableSoftwareTest

    @@ -1378,11 +1478,11 @@ function toggleDisplay(elementId) { - + - + @@ -1390,7 +1490,7 @@ function toggleDisplay(elementId) { - + @@ -1398,11 +1498,11 @@ function toggleDisplay(elementId) { - + - + @@ -1515,7 +1615,7 @@ function toggleDisplay(elementId) {
    testSha10.001
    0
    testCpeMatches0.001
    0
    testHasCvssBelow
    testProcess0.001
    0
    testGetSha1
    testProcessGAV0.001
    0
    testAddCvssBelow0.001
    0
    testFilePath
    - +
    testParseVersionFromFileNametestParseVersion 0

    FilterTest

    diff --git a/dependency-check-core/taglist.html b/dependency-check-core/taglist.html index bc7039c63..4cd758645 100644 --- a/dependency-check-core/taglist.html +++ b/dependency-check-core/taglist.html @@ -1,13 +1,13 @@ - + dependency-check-core - Tag List report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -247,12 +247,12 @@ Tag strings used by tag class Todo Work -22 +20 todo, FIXME

    Each tag is detailed below:

    Todo Work

    -

    Number of occurrences found in the code: 22

    +

    Number of occurrences found in the code: 20

    @@ -262,7 +262,7 @@ - + @@ -271,95 +271,86 @@ - + - + - - - - - - - - - - + - + - + - - + + - - - - + - - + + + + + - - - - - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
    org.owasp.dependencycheck.analyzer.ArchiveAnalyzer108
    - can we get more evidence from the parent? EAR contains module name, etc. analyze the dependency (i.e. extract files) if it is a supported type.231
    230
    org.owasp.dependencycheck.analyzer.CPEAnalyzer Line
    173
    - likely need to change the split... not sure if this will work for CPE with special chars432
    441
    the following isn't quite right is it? need to think about this guessing game a bit more.527
    538
    org.owasp.dependencycheck.analyzer.CPEAnalyzerIntegrationTestLine
    - yeah, not a very good test as the results are the same with or without weighting...201
    fix this assert Assert.assertEquals(expResult, result.get(0).getName());209
    org.owasp.dependencycheck.analyzer.DependencyBundlingAnalyzerTest Line
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); 62
    org.owasp.dependencycheck.analyzer.FalsePositiveAnalyzer Line
    fix the version problem below162
    166
    - can we utilize the pom's groupid and artifactId to filter??? most of these are due to low quality data. Other idea would be to say any CPE found based on LOW confidence evidence should have a different CPE type? (this might be a better solution then just removing the URL for "best-guess" matches).263
    move this startsWith expression to a configuration file?272
    267
    move this to the hint analyzer360
    move this startsWith expression to a configuration file?276
    move this to the hint analyzer364
    org.owasp.dependencycheck.analyzer.JarAnalyzer Line
    remove weighting712
    change this to a regex?830
    remove weighting762
    change this to a regex?880
    org.owasp.dependencycheck.analyzer.JavaScriptAnalyzerTest Line
    improve the assertions assertTrue(depJQ6.getEvidence().size() > 0); assertTrue(depJQ10.getEvidence().size() > 0); assertTrue(depJQ10min.getEvidence().size() > 0); 103
    org.owasp.dependencycheck.data.lucene.SearchVersionAnalyzer Line
    consider implementing payloads/custom attributes... use custom attributes for major, minor, x, x, x, rcx these can then be used to weight the score for searches on the version. see http://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/analysis/package-summary.html#package_description look at this article to implement http://www.codewrecks.com/blog/index.php/2012/08/25/index-your-blog-using-tags-and-lucene-net/ 36
    org.owasp.dependencycheck.data.lucene.VersionAnalyzer Line
    consider implementing payloads/custom attributes... use custom attributes for major, minor, x, x, x, rcx these can then be used to weight the score for searches on the version. see http://lucene.apache.org/core/3_6_1/api/core/org/apache/lucene/analysis/package-summary.html#package_description look at this article to implement http://www.codewrecks.com/blog/index.php/2012/08/25/index-your-blog-using-tags-and-lucene-net/ 36
    org.owasp.dependencycheck.data.lucene.VersionTokenizingFilter Line
    should we also be splitting on dash or underscore? we would need to incorporate the dash or underscore back in... 81
    org.owasp.dependencycheck.data.nvdcve.CveDB Line
    consider utilizing the matchThreeVersion method to get additional results. However, this might also introduce false positives. 755
    org.owasp.dependencycheck.data.update.StandardUpdateIntegrationTest Line
    make this an actual test } 78
    org.owasp.dependencycheck.dependency.EvidenceCollection Line
    consider changing the regex to only compare alpha-numeric (i.e. strip everything else) 238
    org.owasp.dependencycheck.utils.DependencyVersion Line
    steal better version of code from compareTo 137
    diff --git a/dependency-check-core/xref-test/allclasses-frame.html b/dependency-check-core/xref-test/allclasses-frame.html index 49690cb03..09ac46d4a 100644 --- a/dependency-check-core/xref-test/allclasses-frame.html +++ b/dependency-check-core/xref-test/allclasses-frame.html @@ -40,6 +40,9 @@
  • CPEAnalyzerIntegrationTest +
  • +
  • + CentralSearchTest
  • CveDBIntegrationTest @@ -64,6 +67,9 @@
  • DependencyVersionUtilTest +
  • +
  • + DownloadTaskTest
  • DriverLoaderTest diff --git a/dependency-check-core/xref-test/index.html b/dependency-check-core/xref-test/index.html index 5151839d8..af28ffc0a 100644 --- a/dependency-check-core/xref-test/index.html +++ b/dependency-check-core/xref-test/index.html @@ -4,7 +4,7 @@ - Dependency-Check Core 1.2.5 Reference + Dependency-Check Core 1.2.6 Reference diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/EngineIntegrationTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/EngineIntegrationTest.html index 04d741229..a3382acbe 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/EngineIntegrationTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/EngineIntegrationTest.html @@ -31,70 +31,48 @@ 23 import org.junit.Test; 24 import org.owasp.dependencycheck.data.nvdcve.CveDB; 25 import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties; -26 import org.owasp.dependencycheck.dependency.Dependency; -27 import org.owasp.dependencycheck.reporting.ReportGenerator; -28 import org.owasp.dependencycheck.utils.Settings; -29 -30 /** -31 * -32 * @author Jeremy Long <jeremy.long@owasp.org> -33 */ -34 public class EngineIntegrationTest extends BaseTest { -35 -36 @Before -37 public void setUp() throws Exception { -38 org.owasp.dependencycheck.data.nvdcve.BaseDBTestCase.ensureDBExists(); -39 } -40 -41 @After -42 public void tearDown() { -43 } -44 -45 /** -46 * Test of scan method, of class Engine. -47 * -48 * @throws Exception is thrown when an exception occurs. -49 */ -50 @Test -51 public void testScan() throws Exception { -52 String testClasses = "target/test-classes/*.zip"; -53 boolean autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE); -54 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false); -55 Engine instance = new Engine(); -56 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); -57 instance.scan(testClasses); -58 assertTrue(instance.getDependencies().size() > 0); -59 for (Dependency d : instance.getDependencies()) { -60 assertTrue("non-zip file collected " + d.getFileName(), d.getFileName().toLowerCase().endsWith(".zip")); -61 } -62 instance.cleanup(); -63 } -64 -65 /** -66 * Test running the entire engine. -67 * -68 * @throws Exception is thrown when an exception occurs. -69 */ -70 @Test -71 public void testEngine() throws Exception { -72 String testClasses = "target/test-classes"; -73 boolean autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE); -74 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false); -75 Engine instance = new Engine(); -76 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); -77 instance.scan(testClasses); -78 assertTrue(instance.getDependencies().size() > 0); -79 instance.analyzeDependencies(); -80 CveDB cveDB = new CveDB(); -81 cveDB.open(); -82 DatabaseProperties dbProp = cveDB.getDatabaseProperties(); -83 cveDB.close(); -84 ReportGenerator rg = new ReportGenerator("DependencyCheck", -85 instance.getDependencies(), instance.getAnalyzers(), dbProp); -86 rg.generateReports("./target/", "ALL"); -87 instance.cleanup(); -88 } -89 } +26 import org.owasp.dependencycheck.reporting.ReportGenerator; +27 import org.owasp.dependencycheck.utils.Settings; +28 +29 /** +30 * +31 * @author Jeremy Long <jeremy.long@owasp.org> +32 */ +33 public class EngineIntegrationTest extends BaseTest { +34 +35 @Before +36 public void setUp() throws Exception { +37 org.owasp.dependencycheck.data.nvdcve.BaseDBTestCase.ensureDBExists(); +38 } +39 +40 @After +41 public void tearDown() { +42 } +43 +44 /** +45 * Test running the entire engine. +46 * +47 * @throws Exception is thrown when an exception occurs. +48 */ +49 @Test +50 public void testEngine() throws Exception { +51 String testClasses = "target/test-classes"; +52 boolean autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE); +53 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, false); +54 Engine instance = new Engine(); +55 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); +56 instance.scan(testClasses); +57 assertTrue(instance.getDependencies().size() > 0); +58 instance.analyzeDependencies(); +59 CveDB cveDB = new CveDB(); +60 cveDB.open(); +61 DatabaseProperties dbProp = cveDB.getDatabaseProperties(); +62 cveDB.close(); +63 ReportGenerator rg = new ReportGenerator("DependencyCheck", instance.getDependencies(), instance.getAnalyzers(), dbProp); +64 rg.generateReports("./target/", "ALL"); +65 instance.cleanup(); +66 } +67 }
    diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/ArchiveAnalyzerIntegrationTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/ArchiveAnalyzerIntegrationTest.html index 081edc1c9..dfca7c047 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/ArchiveAnalyzerIntegrationTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/ArchiveAnalyzerIntegrationTest.html @@ -48,7 +48,7 @@ 40 @Test 41 public void testGetSupportedExtensions() { 42 ArchiveAnalyzer instance = new ArchiveAnalyzer(); -43 Set expResult = new HashSet<String>(); +43 Set<String> expResult = new HashSet<String>(); 44 expResult.add("zip"); 45 expResult.add("war"); 46 expResult.add("ear"); diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/CPEAnalyzerIntegrationTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/CPEAnalyzerIntegrationTest.html index 2f39f1d7c..5fdad0d76 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/CPEAnalyzerIntegrationTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/CPEAnalyzerIntegrationTest.html @@ -33,193 +33,226 @@ 25 import org.apache.lucene.index.CorruptIndexException; 26 import org.apache.lucene.queryparser.classic.ParseException; 27 import org.junit.Assert; -28 import org.junit.Test; -29 import org.owasp.dependencycheck.data.cpe.AbstractDatabaseTestCase; -30 import org.owasp.dependencycheck.data.cpe.IndexEntry; -31 import org.owasp.dependencycheck.dependency.Dependency; -32 import org.owasp.dependencycheck.dependency.Identifier; -33 -34 /** -35 * -36 * @author Jeremy Long <jeremy.long@owasp.org> -37 */ -38 public class CPEAnalyzerIntegrationTest extends AbstractDatabaseTestCase { -39 -40 /** -41 * Tests of buildSearch of class CPEAnalyzer. -42 * -43 * @throws IOException is thrown when an IO Exception occurs. -44 * @throws CorruptIndexException is thrown when the index is corrupt. -45 * @throws ParseException is thrown when a parse exception occurs -46 */ -47 @Test -48 public void testBuildSearch() throws IOException, CorruptIndexException, ParseException { -49 Set<String> productWeightings = new HashSet<String>(1); -50 productWeightings.add("struts2"); -51 -52 Set<String> vendorWeightings = new HashSet<String>(1); -53 vendorWeightings.add("apache"); -54 -55 String vendor = "apache software foundation"; -56 String product = "struts 2 core"; -57 String version = "2.1.2"; -58 CPEAnalyzer instance = new CPEAnalyzer(); -59 -60 String queryText = instance.buildSearch(vendor, product, null, null); -61 String expResult = " product:( struts 2 core ) AND vendor:( apache software foundation ) "; -62 Assert.assertTrue(expResult.equals(queryText)); -63 -64 queryText = instance.buildSearch(vendor, product, null, productWeightings); -65 expResult = " product:( struts^5 struts2^5 2 core ) AND vendor:( apache software foundation ) "; -66 Assert.assertTrue(expResult.equals(queryText)); -67 -68 queryText = instance.buildSearch(vendor, product, vendorWeightings, null); -69 expResult = " product:( struts 2 core ) AND vendor:( apache^5 software foundation ) "; -70 Assert.assertTrue(expResult.equals(queryText)); -71 -72 queryText = instance.buildSearch(vendor, product, vendorWeightings, productWeightings); -73 expResult = " product:( struts^5 struts2^5 2 core ) AND vendor:( apache^5 software foundation ) "; -74 Assert.assertTrue(expResult.equals(queryText)); -75 } -76 -77 /** -78 * Test of determineCPE method, of class CPEAnalyzer. -79 * -80 * @throws Exception is thrown when an exception occurs -81 */ -82 @Test -83 public void testDetermineCPE_full() throws Exception { -84 CPEAnalyzer instance = new CPEAnalyzer(); -85 instance.open(); -86 FileNameAnalyzer fnAnalyzer = new FileNameAnalyzer(); -87 JarAnalyzer jarAnalyzer = new JarAnalyzer(); -88 HintAnalyzer hAnalyzer = new HintAnalyzer(); -89 FalsePositiveAnalyzer fp = new FalsePositiveAnalyzer(); -90 -91 try { -92 //callDetermineCPE_full("struts2-core-2.3.16.3.jar", "cpe:/a:apache:struts:2.3.16.3", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -93 callDetermineCPE_full("hazelcast-2.5.jar", null, instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -94 callDetermineCPE_full("spring-context-support-2.5.5.jar", "cpe:/a:vmware:springsource_spring_framework:2.5.5", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -95 callDetermineCPE_full("spring-core-3.0.0.RELEASE.jar", "cpe:/a:vmware:springsource_spring_framework:3.0.0", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -96 callDetermineCPE_full("org.mortbay.jetty.jar", "cpe:/a:mortbay_jetty:jetty:4.2", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -97 callDetermineCPE_full("jaxb-xercesImpl-1.5.jar", null, instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -98 callDetermineCPE_full("ehcache-core-2.2.0.jar", null, instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); -99 } finally { -100 instance.close(); -101 } -102 } -103 -104 /** -105 * Test of determineCPE method, of class CPEAnalyzer. -106 * -107 * @throws Exception is thrown when an exception occurs -108 */ -109 public void callDetermineCPE_full(String depName, String expResult, CPEAnalyzer instance, FileNameAnalyzer fnAnalyzer, JarAnalyzer jarAnalyzer, HintAnalyzer hAnalyzer, FalsePositiveAnalyzer fp) throws Exception { -110 -111 File file = new File(this.getClass().getClassLoader().getResource(depName).getPath()); +28 import static org.junit.Assert.assertTrue; +29 import org.junit.Test; +30 import org.owasp.dependencycheck.data.cpe.AbstractDatabaseTestCase; +31 import org.owasp.dependencycheck.data.cpe.IndexEntry; +32 import org.owasp.dependencycheck.dependency.Confidence; +33 import org.owasp.dependencycheck.dependency.Dependency; +34 import org.owasp.dependencycheck.dependency.Identifier; +35 +36 /** +37 * +38 * @author Jeremy Long <jeremy.long@owasp.org> +39 */ +40 public class CPEAnalyzerIntegrationTest extends AbstractDatabaseTestCase { +41 +42 /** +43 * Tests of buildSearch of class CPEAnalyzer. +44 * +45 * @throws IOException is thrown when an IO Exception occurs. +46 * @throws CorruptIndexException is thrown when the index is corrupt. +47 * @throws ParseException is thrown when a parse exception occurs +48 */ +49 @Test +50 public void testBuildSearch() throws IOException, CorruptIndexException, ParseException { +51 Set<String> productWeightings = new HashSet<String>(1); +52 productWeightings.add("struts2"); +53 +54 Set<String> vendorWeightings = new HashSet<String>(1); +55 vendorWeightings.add("apache"); +56 +57 String vendor = "apache software foundation"; +58 String product = "struts 2 core"; +59 String version = "2.1.2"; +60 CPEAnalyzer instance = new CPEAnalyzer(); +61 +62 String queryText = instance.buildSearch(vendor, product, null, null); +63 String expResult = " product:( struts 2 core ) AND vendor:( apache software foundation ) "; +64 Assert.assertTrue(expResult.equals(queryText)); +65 +66 queryText = instance.buildSearch(vendor, product, null, productWeightings); +67 expResult = " product:( struts^5 struts2^5 2 core ) AND vendor:( apache software foundation ) "; +68 Assert.assertTrue(expResult.equals(queryText)); +69 +70 queryText = instance.buildSearch(vendor, product, vendorWeightings, null); +71 expResult = " product:( struts 2 core ) AND vendor:( apache^5 software foundation ) "; +72 Assert.assertTrue(expResult.equals(queryText)); +73 +74 queryText = instance.buildSearch(vendor, product, vendorWeightings, productWeightings); +75 expResult = " product:( struts^5 struts2^5 2 core ) AND vendor:( apache^5 software foundation ) "; +76 Assert.assertTrue(expResult.equals(queryText)); +77 } +78 +79 /** +80 * Test of determineCPE method, of class CPEAnalyzer. +81 * +82 * @throws Exception is thrown when an exception occurs +83 */ +84 @Test +85 public void testDetermineCPE_full() throws Exception { +86 CPEAnalyzer instance = new CPEAnalyzer(); +87 instance.open(); +88 FileNameAnalyzer fnAnalyzer = new FileNameAnalyzer(); +89 JarAnalyzer jarAnalyzer = new JarAnalyzer(); +90 HintAnalyzer hAnalyzer = new HintAnalyzer(); +91 FalsePositiveAnalyzer fp = new FalsePositiveAnalyzer(); +92 +93 try { +94 //callDetermineCPE_full("struts2-core-2.3.16.3.jar", "cpe:/a:apache:struts:2.3.16.3", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +95 callDetermineCPE_full("hazelcast-2.5.jar", null, instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +96 callDetermineCPE_full("spring-context-support-2.5.5.jar", "cpe:/a:vmware:springsource_spring_framework:2.5.5", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +97 callDetermineCPE_full("spring-core-3.0.0.RELEASE.jar", "cpe:/a:vmware:springsource_spring_framework:3.0.0", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +98 callDetermineCPE_full("org.mortbay.jetty.jar", "cpe:/a:mortbay_jetty:jetty:4.2", instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +99 callDetermineCPE_full("jaxb-xercesImpl-1.5.jar", null, instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +100 callDetermineCPE_full("ehcache-core-2.2.0.jar", null, instance, fnAnalyzer, jarAnalyzer, hAnalyzer, fp); +101 } finally { +102 instance.close(); +103 } +104 } +105 +106 /** +107 * Test of determineCPE method, of class CPEAnalyzer. +108 * +109 * @throws Exception is thrown when an exception occurs +110 */ +111 public void callDetermineCPE_full(String depName, String expResult, CPEAnalyzer instance, FileNameAnalyzer fnAnalyzer, JarAnalyzer jarAnalyzer, HintAnalyzer hAnalyzer, FalsePositiveAnalyzer fp) throws Exception { 112 -113 Dependency dep = new Dependency(file); +113 File file = new File(this.getClass().getClassLoader().getResource(depName).getPath()); 114 -115 fnAnalyzer.analyze(dep, null); -116 jarAnalyzer.analyze(dep, null); -117 hAnalyzer.analyze(dep, null); -118 instance.analyze(dep, null); -119 fp.analyze(dep, null); -120 -121 if (expResult != null) { -122 Identifier expIdentifier = new Identifier("cpe", expResult, expResult); -123 Assert.assertTrue("Incorrect match: { dep:'" + dep.getFileName() + "' }", dep.getIdentifiers().contains(expIdentifier)); -124 } else { -125 for (Identifier i : dep.getIdentifiers()) { -126 Assert.assertFalse(String.format("%s - found a CPE identifier when should have been none (found '%s')", dep.getFileName(), i.getValue()), "cpe".equals(i.getType())); -127 } -128 } -129 } -130 -131 /** -132 * Test of determineCPE method, of class CPEAnalyzer. -133 * -134 * @throws Exception is thrown when an exception occurs -135 */ -136 @Test -137 public void testDetermineCPE() throws Exception { -138 File file = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath()); -139 //File file = new File(this.getClass().getClassLoader().getResource("axis2-adb-1.4.1.jar").getPath()); -140 Dependency struts = new Dependency(file); -141 -142 FileNameAnalyzer fnAnalyzer = new FileNameAnalyzer(); -143 fnAnalyzer.analyze(struts, null); -144 -145 JarAnalyzer jarAnalyzer = new JarAnalyzer(); -146 jarAnalyzer.analyze(struts, null); -147 -148 File fileCommonValidator = new File(this.getClass().getClassLoader().getResource("commons-validator-1.4.0.jar").getPath()); -149 Dependency commonValidator = new Dependency(fileCommonValidator); -150 jarAnalyzer.analyze(commonValidator, null); -151 -152 File fileSpring = new File(this.getClass().getClassLoader().getResource("spring-core-2.5.5.jar").getPath()); -153 Dependency spring = new Dependency(fileSpring); -154 jarAnalyzer.analyze(spring, null); -155 -156 File fileSpring3 = new File(this.getClass().getClassLoader().getResource("spring-core-3.0.0.RELEASE.jar").getPath()); -157 Dependency spring3 = new Dependency(fileSpring3); -158 jarAnalyzer.analyze(spring3, null); -159 -160 CPEAnalyzer instance = new CPEAnalyzer(); -161 instance.open(); -162 instance.determineCPE(commonValidator); -163 instance.determineCPE(struts); -164 instance.determineCPE(spring); -165 instance.determineCPE(spring3); -166 instance.close(); -167 -168 String expResult = "cpe:/a:apache:struts:2.1.2"; -169 Identifier expIdentifier = new Identifier("cpe", expResult, expResult); -170 String expResultSpring = "cpe:/a:springsource:spring_framework:2.5.5"; -171 String expResultSpring3 = "cpe:/a:vmware:springsource_spring_framework:3.0.0"; -172 -173 for (Identifier i : commonValidator.getIdentifiers()) { -174 Assert.assertFalse("Apache Common Validator - found a CPE identifier?", "cpe".equals(i.getType())); -175 } -176 -177 Assert.assertTrue("Incorrect match size - struts", struts.getIdentifiers().size() >= 1); -178 Assert.assertTrue("Incorrect match - struts", struts.getIdentifiers().contains(expIdentifier)); -179 Assert.assertTrue("Incorrect match size - spring3 - " + spring3.getIdentifiers().size(), spring3.getIdentifiers().size() >= 1); -180 -181 //the following two only work if the HintAnalyzer is used. -182 //Assert.assertTrue("Incorrect match size - spring", spring.getIdentifiers().size() == 1); -183 //Assert.assertTrue("Incorrect match - spring", spring.getIdentifiers().get(0).getValue().equals(expResultSpring)); -184 } -185 -186 /** -187 * Test of searchCPE method, of class CPEAnalyzer. -188 * -189 * @throws Exception is thrown when an exception occurs -190 */ -191 @Test -192 public void testSearchCPE() throws Exception { -193 String vendor = "apache software foundation"; -194 String product = "struts 2 core"; -195 String version = "2.1.2"; -196 String expResult = "cpe:/a:apache:struts:2.1.2"; -197 -198 CPEAnalyzer instance = new CPEAnalyzer(); -199 instance.open(); -200 -201 //TODO - yeah, not a very good test as the results are the same with or without weighting... -202 Set<String> productWeightings = new HashSet<String>(1); -203 productWeightings.add("struts2"); +115 Dependency dep = new Dependency(file); +116 +117 fnAnalyzer.analyze(dep, null); +118 jarAnalyzer.analyze(dep, null); +119 hAnalyzer.analyze(dep, null); +120 instance.analyze(dep, null); +121 fp.analyze(dep, null); +122 +123 if (expResult != null) { +124 Identifier expIdentifier = new Identifier("cpe", expResult, expResult); +125 Assert.assertTrue("Incorrect match: { dep:'" + dep.getFileName() + "' }", dep.getIdentifiers().contains(expIdentifier)); +126 } else { +127 for (Identifier i : dep.getIdentifiers()) { +128 Assert.assertFalse(String.format("%s - found a CPE identifier when should have been none (found '%s')", dep.getFileName(), i.getValue()), "cpe".equals(i.getType())); +129 } +130 } +131 } +132 +133 /** +134 * Test of determineCPE method, of class CPEAnalyzer. +135 * +136 * @throws Exception is thrown when an exception occurs +137 */ +138 @Test +139 public void testDetermineCPE() throws Exception { +140 File file = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath()); +141 //File file = new File(this.getClass().getClassLoader().getResource("axis2-adb-1.4.1.jar").getPath()); +142 Dependency struts = new Dependency(file); +143 +144 FileNameAnalyzer fnAnalyzer = new FileNameAnalyzer(); +145 fnAnalyzer.analyze(struts, null); +146 +147 JarAnalyzer jarAnalyzer = new JarAnalyzer(); +148 jarAnalyzer.analyze(struts, null); +149 +150 File fileCommonValidator = new File(this.getClass().getClassLoader().getResource("commons-validator-1.4.0.jar").getPath()); +151 Dependency commonValidator = new Dependency(fileCommonValidator); +152 jarAnalyzer.analyze(commonValidator, null); +153 +154 File fileSpring = new File(this.getClass().getClassLoader().getResource("spring-core-2.5.5.jar").getPath()); +155 Dependency spring = new Dependency(fileSpring); +156 jarAnalyzer.analyze(spring, null); +157 +158 File fileSpring3 = new File(this.getClass().getClassLoader().getResource("spring-core-3.0.0.RELEASE.jar").getPath()); +159 Dependency spring3 = new Dependency(fileSpring3); +160 jarAnalyzer.analyze(spring3, null); +161 +162 CPEAnalyzer instance = new CPEAnalyzer(); +163 instance.open(); +164 instance.determineCPE(commonValidator); +165 instance.determineCPE(struts); +166 instance.determineCPE(spring); +167 instance.determineCPE(spring3); +168 instance.close(); +169 +170 String expResult = "cpe:/a:apache:struts:2.1.2"; +171 Identifier expIdentifier = new Identifier("cpe", expResult, expResult); +172 String expResultSpring = "cpe:/a:springsource:spring_framework:2.5.5"; +173 String expResultSpring3 = "cpe:/a:vmware:springsource_spring_framework:3.0.0"; +174 +175 for (Identifier i : commonValidator.getIdentifiers()) { +176 Assert.assertFalse("Apache Common Validator - found a CPE identifier?", "cpe".equals(i.getType())); +177 } +178 +179 Assert.assertTrue("Incorrect match size - struts", struts.getIdentifiers().size() >= 1); +180 Assert.assertTrue("Incorrect match - struts", struts.getIdentifiers().contains(expIdentifier)); +181 Assert.assertTrue("Incorrect match size - spring3 - " + spring3.getIdentifiers().size(), spring3.getIdentifiers().size() >= 1); +182 +183 //the following two only work if the HintAnalyzer is used. +184 //Assert.assertTrue("Incorrect match size - spring", spring.getIdentifiers().size() == 1); +185 //Assert.assertTrue("Incorrect match - spring", spring.getIdentifiers().get(0).getValue().equals(expResultSpring)); +186 } +187 +188 /** +189 * Test of determineIdentifiers method, of class CPEAnalyzer. +190 * +191 * @throws Exception is thrown when an exception occurs +192 */ +193 @Test +194 public void testDetermineIdentifiers() throws Exception { +195 Dependency openssl = new Dependency(); +196 openssl.getVendorEvidence().addEvidence("test", "vendor", "openssl", Confidence.HIGHEST); +197 openssl.getProductEvidence().addEvidence("test", "product", "openssl", Confidence.HIGHEST); +198 openssl.getVersionEvidence().addEvidence("test", "version", "1.0.1c", Confidence.HIGHEST); +199 +200 CPEAnalyzer instance = new CPEAnalyzer(); +201 instance.open(); +202 instance.determineIdentifiers(openssl, "openssl", "openssl", Confidence.HIGHEST); +203 instance.close(); 204 -205 Set<String> vendorWeightings = new HashSet<String>(1); -206 vendorWeightings.add("apache"); +205 String expResult = "cpe:/a:openssl:openssl:1.0.1c"; +206 Identifier expIdentifier = new Identifier("cpe", expResult, expResult); 207 -208 List<IndexEntry> result = instance.searchCPE(vendor, product, productWeightings, vendorWeightings); -209 //TODO fix this assert -210 //Assert.assertEquals(expResult, result.get(0).getName()); +208 assertTrue(openssl.getIdentifiers().contains(expIdentifier)); +209 +210 } 211 -212 instance.close(); -213 } -214 } +212 /** +213 * Test of searchCPE method, of class CPEAnalyzer. +214 * +215 * @throws Exception is thrown when an exception occurs +216 */ +217 @Test +218 public void testSearchCPE() throws Exception { +219 String vendor = "apache software foundation"; +220 String product = "struts 2 core"; +221 String version = "2.1.2"; +222 String expVendor = "apache"; +223 String expProduct = "struts"; +224 +225 CPEAnalyzer instance = new CPEAnalyzer(); +226 instance.open(); +227 +228 Set<String> productWeightings = new HashSet<String>(1); +229 productWeightings.add("struts2"); +230 +231 Set<String> vendorWeightings = new HashSet<String>(1); +232 vendorWeightings.add("apache"); +233 +234 List<IndexEntry> result = instance.searchCPE(vendor, product, productWeightings, vendorWeightings); +235 instance.close(); +236 +237 boolean found = false; +238 for (IndexEntry entry : result) { +239 if (expVendor.equals(entry.getVendor()) && expProduct.equals(entry.getProduct())) { +240 found = true; +241 break; +242 } +243 } +244 assertTrue("apache:struts was not identified", found); +245 +246 } +247 }
    diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzerTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzerTest.html index 21c8f9093..9cf377956 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzerTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzerTest.html @@ -94,7 +94,43 @@ 86 assertEquals(expResult, result); 87 } 88 -89 } +89 @Test +90 public void testFirstPathIsShortest() { +91 DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer(); +92 +93 String left = "./a/c.jar"; +94 String right = "./d/e/f.jar"; +95 boolean expResult = true; +96 boolean result = instance.firstPathIsShortest(left, right); +97 assertEquals(expResult, result); +98 +99 left = "./a/b/c.jar"; +100 right = "./d/e/f.jar"; +101 expResult = true; +102 result = instance.firstPathIsShortest(left, right); +103 assertEquals(expResult, result); +104 +105 left = "./d/b/c.jar"; +106 right = "./a/e/f.jar"; +107 expResult = false; +108 result = instance.firstPathIsShortest(left, right); +109 assertEquals(expResult, result); +110 +111 left = "./a/b/c.jar"; +112 right = "./d/f.jar"; +113 expResult = false; +114 result = instance.firstPathIsShortest(left, right); +115 assertEquals(expResult, result); +116 +117 left = "./a/b/c.jar"; +118 right = "./a/b/c.jar"; +119 expResult = true; +120 result = instance.firstPathIsShortest(left, right); +121 assertEquals(expResult, result); +122 +123 } +124 +125 }
    diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JarAnalyzerTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JarAnalyzerTest.html index f3a8d55fc..d7d38a172 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JarAnalyzerTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JarAnalyzerTest.html @@ -101,7 +101,7 @@ 93 @Test 94 public void testGetSupportedExtensions() { 95 JarAnalyzer instance = new JarAnalyzer(); -96 Set expResult = new HashSet(); +96 Set<String> expResult = new HashSet<String>(); 97 expResult.add("jar"); 98 expResult.add("war"); 99 Set result = instance.getSupportedExtensions(); diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzerTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzerTest.html index 7ce034ce8..75bfe5635 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzerTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzerTest.html @@ -46,7 +46,7 @@ 38 @Test 39 public void testGetSupportedExtensions() { 40 JavaScriptAnalyzer instance = new JavaScriptAnalyzer(); -41 Set expResult = new HashSet<String>(); +41 Set<String> expResult = new HashSet<String>(); 42 expResult.add("js"); 43 Set result = instance.getSupportedExtensions(); 44 assertEquals(expResult, result); diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-frame.html index 514ebb8c7..02a974bb0 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.analyzer + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.analyzer diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-summary.html index e37f7f4ea..1aca86223 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/analyzer/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.analyzer + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.analyzer diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/CentralSearchTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/CentralSearchTest.html new file mode 100644 index 000000000..13d8de9f5 --- /dev/null +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/CentralSearchTest.html @@ -0,0 +1,76 @@ + + + +CentralSearchTest xref + + + +
    +1   package org.owasp.dependencycheck.data.central;
    +2   
    +3   import org.junit.Before;
    +4   import org.junit.Test;
    +5   import org.owasp.dependencycheck.BaseTest;
    +6   import org.owasp.dependencycheck.data.nexus.MavenArtifact;
    +7   import org.owasp.dependencycheck.utils.Settings;
    +8   
    +9   import java.io.FileNotFoundException;
    +10  import java.net.URL;
    +11  import java.util.List;
    +12  import java.util.logging.Logger;
    +13  
    +14  import static org.junit.Assert.*;
    +15  
    +16  /**
    +17   * Created by colezlaw on 10/13/14.
    +18   */
    +19  public class CentralSearchTest extends BaseTest {
    +20      private static final Logger LOGGER = Logger.getLogger(CentralSearchTest.class.getName());
    +21      private CentralSearch searcher;
    +22  
    +23      @Before
    +24      public void setUp() throws Exception {
    +25          String centralUrl = Settings.getString(Settings.KEYS.ANALYZER_CENTRAL_URL);
    +26          LOGGER.fine(centralUrl);
    +27          searcher = new CentralSearch(new URL(centralUrl));
    +28      }
    +29  
    +30      @Test(expected = IllegalArgumentException.class)
    +31      public void testNullSha1() throws Exception { searcher.searchSha1(null); }
    +32  
    +33      @Test(expected = IllegalArgumentException.class)
    +34      public void testMalformedSha1() throws Exception {
    +35          searcher.searchSha1("invalid");
    +36      }
    +37  
    +38      // This test does generate network traffic and communicates with a host
    +39      // you may not be able to reach. Remove the @Ignore annotation if you want to
    +40      // test it anyway
    +41      @Test
    +42      public void testValidSha1() throws Exception {
    +43          List<MavenArtifact> ma = searcher.searchSha1("9977a8d04e75609cf01badc4eb6a9c7198c4c5ea");
    +44          assertEquals("Incorrect group", "org.apache.maven.plugins", ma.get(0).getGroupId());
    +45          assertEquals("Incorrect artifact", "maven-compiler-plugin", ma.get(0).getArtifactId());
    +46          assertEquals("Incorrect version", "3.1", ma.get(0).getVersion());
    +47      }
    +48  
    +49      // This test does generate network traffic and communicates with a host
    +50      // you may not be able to reach. Remove the @Ignore annotation if you want to
    +51      // test it anyway
    +52      @Test(expected = FileNotFoundException.class)
    +53      public void testMissingSha1() throws Exception {
    +54          searcher.searchSha1("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
    +55      }
    +56  
    +57      // This test should give us multiple results back from Central
    +58      @Test
    +59      public void testMultipleReturns() throws Exception {
    +60          List<MavenArtifact> ma = searcher.searchSha1("94A9CE681A42D0352B3AD22659F67835E560D107");
    +61          assertTrue(ma.size() > 1);
    +62      }
    +63  }
    +
    +
    + + + diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/package-frame.html new file mode 100644 index 000000000..cecf08096 --- /dev/null +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/package-frame.html @@ -0,0 +1,24 @@ + + + + + + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.central + + + + +

    + org.owasp.dependencycheck.data.central +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/package-summary.html new file mode 100644 index 000000000..b92ac4577 --- /dev/null +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/central/package-summary.html @@ -0,0 +1,69 @@ + + + + + + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.central + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.data.central

    + + + + + + + + + + + + +
    Class Summary
    + CentralSearchTest +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-frame.html index 590053314..e1e9999f4 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cpe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cpe diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-summary.html index 88291a15a..cb573483e 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cpe/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cpe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cpe diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-frame.html index 3d23d6097..fac7ed0d4 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cwe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cwe diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-summary.html index 8d2746271..19c1dee6e 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/cwe/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cwe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cwe diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-frame.html index 53dae718b..8f69a8852 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.lucene + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.lucene diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-summary.html index 79c4c5b23..3eb440002 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/lucene/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.lucene + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.lucene diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-frame.html index 6fd716b3a..9a2a77d1a 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nexus + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nexus diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-summary.html index fe24f2848..303382582 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nexus/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nexus + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nexus diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-frame.html index 926fe7df8..62367f0b7 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nuget + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nuget diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-summary.html index 59e4ba290..78c632c63 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nuget/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nuget + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nuget diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/CveDBIntegrationTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/CveDBIntegrationTest.html index 362a9e408..de480ce66 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/CveDBIntegrationTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/CveDBIntegrationTest.html @@ -27,60 +27,79 @@ 19 20 import java.util.List; 21 import java.util.Set; -22 import static org.junit.Assert.assertTrue; -23 import org.junit.Test; -24 import org.owasp.dependencycheck.dependency.VulnerableSoftware; -25 -26 /** -27 * -28 * @author Jeremy Long <jeremy.long@owasp.org> -29 */ -30 public class CveDBIntegrationTest extends BaseDBTestCase { -31 -32 /** -33 * Pretty useless tests of open, commit, and close methods, of class CveDB. -34 */ -35 @Test -36 public void testOpen() throws Exception { -37 CveDB instance = new CveDB(); -38 instance.open(); -39 instance.commit(); -40 instance.close(); -41 } -42 -43 /** -44 * Test of getCPEs method, of class CveDB. -45 */ -46 @Test -47 public void testGetCPEs() throws Exception { -48 CveDB instance = new CveDB(); -49 try { -50 String vendor = "apache"; -51 String product = "struts"; -52 instance.open(); -53 Set<VulnerableSoftware> result = instance.getCPEs(vendor, product); -54 assertTrue(result.size() > 5); -55 } finally { -56 instance.close(); -57 } -58 } -59 -60 /** -61 * Test of getVulnerabilities method, of class CveDB. -62 */ -63 @Test -64 public void testGetVulnerabilities() throws Exception { -65 String cpeStr = "cpe:/a:apache:struts:2.1.2"; -66 CveDB instance = new CveDB(); -67 try { -68 instance.open(); -69 List result = instance.getVulnerabilities(cpeStr); -70 assertTrue(result.size() > 5); -71 } finally { -72 instance.close(); -73 } -74 } -75 } +22 import static org.junit.Assert.assertFalse; +23 import static org.junit.Assert.assertTrue; +24 import org.junit.Test; +25 import org.owasp.dependencycheck.dependency.VulnerableSoftware; +26 import org.owasp.dependencycheck.utils.DependencyVersion; +27 +28 /** +29 * +30 * @author Jeremy Long <jeremy.long@owasp.org> +31 */ +32 public class CveDBIntegrationTest extends BaseDBTestCase { +33 +34 /** +35 * Pretty useless tests of open, commit, and close methods, of class CveDB. +36 */ +37 @Test +38 public void testOpen() throws Exception { +39 CveDB instance = new CveDB(); +40 instance.open(); +41 instance.commit(); +42 instance.close(); +43 } +44 +45 /** +46 * Test of getCPEs method, of class CveDB. +47 */ +48 @Test +49 public void testGetCPEs() throws Exception { +50 CveDB instance = new CveDB(); +51 try { +52 String vendor = "apache"; +53 String product = "struts"; +54 instance.open(); +55 Set<VulnerableSoftware> result = instance.getCPEs(vendor, product); +56 assertTrue(result.size() > 5); +57 } finally { +58 instance.close(); +59 } +60 } +61 +62 /** +63 * Test of getVulnerabilities method, of class CveDB. +64 */ +65 @Test +66 public void testGetVulnerabilities() throws Exception { +67 String cpeStr = "cpe:/a:apache:struts:2.1.2"; +68 CveDB instance = new CveDB(); +69 try { +70 instance.open(); +71 List result = instance.getVulnerabilities(cpeStr); +72 assertTrue(result.size() > 5); +73 } finally { +74 instance.close(); +75 } +76 } +77 +78 /** +79 * Test of isAffected method, of class CveDB. +80 */ +81 @Test +82 public void testIsAffected() throws Exception { +83 String vendor = "openssl"; +84 String product = "openssl"; +85 DependencyVersion identifiedVersion = new DependencyVersion("1.0.1o"); +86 String cpeId = "cpe:/a:openssl:openssl:1.0.1e"; +87 String previous = "y"; +88 +89 CveDB instance = new CveDB(); +90 assertFalse(instance.isAffected(vendor, product, identifiedVersion, cpeId, previous)); +91 +92 } +93 +94 }
    diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-frame.html index e79892253..11c7c83eb 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nvdcve + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nvdcve diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-summary.html index 6457995d4..2d69772f7 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/nvdcve/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nvdcve + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nvdcve diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-frame.html index a135a7e4a..0ac9289d2 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-summary.html index 60a756137..88dd39c77 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/DownloadTaskTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/DownloadTaskTest.html new file mode 100644 index 000000000..0f1a8d459 --- /dev/null +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/DownloadTaskTest.html @@ -0,0 +1,88 @@ + + + +DownloadTaskTest xref + + + +
    +1   /*
    +2    * This file is part of dependency-check-core.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *     http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   *
    +16   * Copyright (c) 2014 Jeremy Long. All Rights Reserved.
    +17   */
    +18  package org.owasp.dependencycheck.data.update.task;
    +19  
    +20  import java.util.concurrent.ExecutorService;
    +21  import java.util.concurrent.Future;
    +22  import org.junit.After;
    +23  import org.junit.AfterClass;
    +24  import static org.junit.Assert.assertNull;
    +25  import org.junit.Before;
    +26  import org.junit.BeforeClass;
    +27  import org.junit.Test;
    +28  import org.owasp.dependencycheck.data.nvdcve.CveDB;
    +29  import org.owasp.dependencycheck.data.update.NvdCveInfo;
    +30  import org.owasp.dependencycheck.utils.Settings;
    +31  
    +32  /**
    +33   *
    +34   * @author Jeremy Long <jeremy.long@owasp.org>
    +35   */
    +36  public class DownloadTaskTest {
    +37  
    +38      public DownloadTaskTest() {
    +39      }
    +40  
    +41      @BeforeClass
    +42      public static void setUpClass() {
    +43      }
    +44  
    +45      @AfterClass
    +46      public static void tearDownClass() {
    +47      }
    +48  
    +49      @Before
    +50      public void setUp() {
    +51          Settings.initialize();
    +52      }
    +53  
    +54      @After
    +55      public void tearDown() {
    +56          Settings.cleanup();
    +57      }
    +58  
    +59      /**
    +60       * Test of call method, of class DownloadTask.
    +61       */
    +62      @Test
    +63      public void testCall() throws Exception {
    +64          NvdCveInfo cve = new NvdCveInfo();
    +65          cve.setId("modified");
    +66          cve.setNeedsUpdate(true);
    +67          cve.setUrl(Settings.getString(Settings.KEYS.CVE_MODIFIED_20_URL));
    +68          cve.setOldSchemaVersionUrl(Settings.getString(Settings.KEYS.CVE_MODIFIED_12_URL));
    +69          ExecutorService processExecutor = null;
    +70          CveDB cveDB = null;
    +71          DownloadTask instance = new DownloadTask(cve, processExecutor, cveDB, Settings.getInstance());;
    +72          Future<ProcessTask> result = instance.call();
    +73          assertNull(result);
    +74      }
    +75  }
    +
    +
    + + + diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/package-frame.html new file mode 100644 index 000000000..da087ead8 --- /dev/null +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/package-frame.html @@ -0,0 +1,24 @@ + + + + + + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.task + + + + +

    + org.owasp.dependencycheck.data.update.task +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/package-summary.html new file mode 100644 index 000000000..ac8afd5ce --- /dev/null +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/task/package-summary.html @@ -0,0 +1,69 @@ + + + + + + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.task + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.data.update.task

    + + + + + + + + + + + + +
    Class Summary
    + DownloadTaskTest +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-frame.html index 5b4319d59..0c8983b70 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.xml + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.xml diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-summary.html index 337dd64d1..7a3096981 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/data/update/xml/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.xml + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.xml diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/DependencyTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/DependencyTest.html index 3fb60c569..37346fde4 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/DependencyTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/DependencyTest.html @@ -31,278 +31,310 @@ 23 import org.junit.After; 24 import org.junit.AfterClass; 25 import static org.junit.Assert.assertEquals; -26 import static org.junit.Assert.assertTrue; -27 import org.junit.Before; -28 import org.junit.BeforeClass; -29 import org.junit.Test; -30 -31 /** -32 * -33 * @author Jeremy Long <jeremy.long@owasp.org> -34 */ -35 public class DependencyTest { -36 -37 public DependencyTest() { -38 } -39 -40 @BeforeClass -41 public static void setUpClass() throws Exception { -42 } -43 -44 @AfterClass -45 public static void tearDownClass() throws Exception { -46 } -47 -48 @Before -49 public void setUp() { -50 } -51 -52 @After -53 public void tearDown() { -54 } -55 -56 /** -57 * Test of getFileName method, of class Dependency. -58 */ -59 @Test -60 public void testGetFileName() { -61 Dependency instance = new Dependency(); -62 String expResult = "filename"; -63 instance.setFileName(expResult); -64 String result = instance.getFileName(); -65 assertEquals(expResult, result); -66 } -67 -68 /** -69 * Test of setFileName method, of class Dependency. -70 */ -71 @Test -72 public void testSetFileName() { -73 String fileName = "file.tar"; -74 Dependency instance = new Dependency(); -75 instance.setFileName(fileName); -76 assertEquals(fileName, instance.getFileName()); -77 } -78 -79 /** -80 * Test of setActualFilePath method, of class Dependency. -81 */ -82 @Test -83 public void testSetActualFilePath() { -84 String actualFilePath = "file.tar"; -85 Dependency instance = new Dependency(); -86 instance.setActualFilePath(actualFilePath); -87 assertEquals(actualFilePath, instance.getActualFilePath()); -88 } -89 -90 /** -91 * Test of getActualFilePath method, of class Dependency. -92 */ -93 @Test -94 public void testGetActualFilePath() { -95 Dependency instance = new Dependency(); -96 String expResult = "file.tar"; -97 instance.setActualFilePath(expResult); -98 String result = instance.getActualFilePath(); -99 assertEquals(expResult, result); -100 } -101 -102 /** -103 * Test of setFilePath method, of class Dependency. -104 */ -105 @Test -106 public void testSetFilePath() { -107 String filePath = "file.tar"; -108 Dependency instance = new Dependency(); -109 instance.setFilePath(filePath); -110 assertEquals(filePath, instance.getFilePath()); -111 } -112 -113 /** -114 * Test of getFilePath method, of class Dependency. -115 */ -116 @Test -117 public void testGetFilePath() { -118 Dependency instance = new Dependency(); -119 String expResult = "file.tar"; -120 instance.setFilePath(expResult); -121 String result = instance.getFilePath(); -122 assertEquals(expResult, result); -123 } -124 -125 /** -126 * Test of setFileExtension method, of class Dependency. -127 */ -128 @Test -129 public void testSetFileExtension() { -130 String fileExtension = "jar"; -131 Dependency instance = new Dependency(); -132 instance.setFileExtension(fileExtension); -133 assertEquals(fileExtension, instance.getFileExtension()); -134 } -135 -136 /** -137 * Test of getFileExtension method, of class Dependency. -138 */ -139 @Test -140 public void testGetFileExtension() { -141 Dependency instance = new Dependency(); -142 String expResult = "jar"; -143 instance.setFileExtension(expResult); -144 String result = instance.getFileExtension(); -145 assertEquals(expResult, result); -146 } -147 -148 /** -149 * Test of getMd5sum method, of class Dependency. -150 */ -151 @Test -152 public void testGetMd5sum() { -153 File file = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath()); -154 Dependency instance = new Dependency(file); -155 // assertEquals("89CE9E36AA9A9E03F1450936D2F4F8DD0F961F8B", result.getSha1sum()); -156 String expResult = "C30B57142E1CCBC1EFD5CD15F307358F"; -157 String result = instance.getMd5sum(); -158 assertEquals(expResult, result); -159 } -160 -161 /** -162 * Test of setMd5sum method, of class Dependency. -163 */ -164 @Test -165 public void testSetMd5sum() { -166 String md5sum = "test"; -167 Dependency instance = new Dependency(); -168 instance.setMd5sum(md5sum); -169 assertEquals(md5sum, instance.getMd5sum()); -170 } -171 -172 /** -173 * Test of getSha1sum method, of class Dependency. -174 */ -175 @Test -176 public void testGetSha1sum() { -177 File file = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath()); -178 Dependency instance = new Dependency(file); -179 String expResult = "89CE9E36AA9A9E03F1450936D2F4F8DD0F961F8B"; -180 String result = instance.getSha1sum(); -181 assertEquals(expResult, result); -182 } -183 -184 /** -185 * Test of setSha1sum method, of class Dependency. -186 */ -187 @Test -188 public void testSetSha1sum() { -189 String sha1sum = "test"; -190 Dependency instance = new Dependency(); -191 instance.setSha1sum(sha1sum); -192 assertEquals(sha1sum, instance.getSha1sum()); -193 } -194 -195 /** -196 * Test of getIdentifiers method, of class Dependency. -197 */ -198 @Test -199 public void testGetIdentifiers() { -200 Dependency instance = new Dependency(); -201 List expResult = null; -202 Set<Identifier> result = instance.getIdentifiers(); -203 -204 assertTrue(true); //this is just a getter setter pair. -205 } -206 -207 /** -208 * Test of setIdentifiers method, of class Dependency. -209 */ -210 @Test -211 public void testSetIdentifiers() { -212 Set<Identifier> identifiers = null; -213 Dependency instance = new Dependency(); -214 instance.setIdentifiers(identifiers); -215 assertTrue(true); //this is just a getter setter pair. -216 } -217 -218 /** -219 * Test of addIdentifier method, of class Dependency. -220 */ -221 @Test -222 public void testAddIdentifier() { -223 String type = "cpe"; -224 String value = "cpe:/a:apache:struts:2.1.2"; -225 String url = "http://somewhere"; -226 Identifier expResult = new Identifier(type, value, url); -227 -228 Dependency instance = new Dependency(); -229 instance.addIdentifier(type, value, url); -230 assertEquals(1, instance.getIdentifiers().size()); -231 assertTrue("Identifier doesn't contain expected result.", instance.getIdentifiers().contains(expResult)); -232 } -233 -234 /** -235 * Test of getEvidence method, of class Dependency. -236 */ -237 @Test -238 public void testGetEvidence() { -239 Dependency instance = new Dependency(); -240 EvidenceCollection expResult = null; -241 EvidenceCollection result = instance.getEvidence(); -242 assertTrue(true); //this is just a getter setter pair. -243 } -244 -245 /** -246 * Test of getEvidenceUsed method, of class Dependency. -247 */ -248 @Test -249 public void testGetEvidenceUsed() { -250 Dependency instance = new Dependency(); -251 String expResult = "used"; -252 -253 instance.getProductEvidence().addEvidence("used", "used", "used", Confidence.HIGH); -254 instance.getProductEvidence().addEvidence("not", "not", "not", Confidence.MEDIUM); -255 for (Evidence e : instance.getProductEvidence().iterator(Confidence.HIGH)) { -256 String use = e.getValue(); -257 } -258 -259 EvidenceCollection result = instance.getEvidenceUsed(); +26 import static org.junit.Assert.assertFalse; +27 import static org.junit.Assert.assertTrue; +28 import org.junit.Before; +29 import org.junit.BeforeClass; +30 import org.junit.Test; +31 import org.owasp.dependencycheck.data.nexus.MavenArtifact; +32 +33 /** +34 * +35 * @author Jeremy Long <jeremy.long@owasp.org> +36 */ +37 public class DependencyTest { +38 +39 public DependencyTest() { +40 } +41 +42 @BeforeClass +43 public static void setUpClass() throws Exception { +44 } +45 +46 @AfterClass +47 public static void tearDownClass() throws Exception { +48 } +49 +50 @Before +51 public void setUp() { +52 } +53 +54 @After +55 public void tearDown() { +56 } +57 +58 /** +59 * Test of getFileName method, of class Dependency. +60 */ +61 @Test +62 public void testGetFileName() { +63 Dependency instance = new Dependency(); +64 String expResult = "filename"; +65 instance.setFileName(expResult); +66 String result = instance.getFileName(); +67 assertEquals(expResult, result); +68 } +69 +70 /** +71 * Test of setFileName method, of class Dependency. +72 */ +73 @Test +74 public void testSetFileName() { +75 String fileName = "file.tar"; +76 Dependency instance = new Dependency(); +77 instance.setFileName(fileName); +78 assertEquals(fileName, instance.getFileName()); +79 } +80 +81 /** +82 * Test of setActualFilePath method, of class Dependency. +83 */ +84 @Test +85 public void testSetActualFilePath() { +86 String actualFilePath = "file.tar"; +87 Dependency instance = new Dependency(); +88 instance.setActualFilePath(actualFilePath); +89 assertEquals(actualFilePath, instance.getActualFilePath()); +90 } +91 +92 /** +93 * Test of getActualFilePath method, of class Dependency. +94 */ +95 @Test +96 public void testGetActualFilePath() { +97 Dependency instance = new Dependency(); +98 String expResult = "file.tar"; +99 instance.setActualFilePath(expResult); +100 String result = instance.getActualFilePath(); +101 assertEquals(expResult, result); +102 } +103 +104 /** +105 * Test of setFilePath method, of class Dependency. +106 */ +107 @Test +108 public void testSetFilePath() { +109 String filePath = "file.tar"; +110 Dependency instance = new Dependency(); +111 instance.setFilePath(filePath); +112 assertEquals(filePath, instance.getFilePath()); +113 } +114 +115 /** +116 * Test of getFilePath method, of class Dependency. +117 */ +118 @Test +119 public void testGetFilePath() { +120 Dependency instance = new Dependency(); +121 String expResult = "file.tar"; +122 instance.setFilePath(expResult); +123 String result = instance.getFilePath(); +124 assertEquals(expResult, result); +125 } +126 +127 /** +128 * Test of setFileExtension method, of class Dependency. +129 */ +130 @Test +131 public void testSetFileExtension() { +132 String fileExtension = "jar"; +133 Dependency instance = new Dependency(); +134 instance.setFileExtension(fileExtension); +135 assertEquals(fileExtension, instance.getFileExtension()); +136 } +137 +138 /** +139 * Test of getFileExtension method, of class Dependency. +140 */ +141 @Test +142 public void testGetFileExtension() { +143 Dependency instance = new Dependency(); +144 String expResult = "jar"; +145 instance.setFileExtension(expResult); +146 String result = instance.getFileExtension(); +147 assertEquals(expResult, result); +148 } +149 +150 /** +151 * Test of getMd5sum method, of class Dependency. +152 */ +153 @Test +154 public void testGetMd5sum() { +155 File file = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath()); +156 Dependency instance = new Dependency(file); +157 //assertEquals("89CE9E36AA9A9E03F1450936D2F4F8DD0F961F8B", result.getSha1sum()); +158 String expResult = "C30B57142E1CCBC1EFD5CD15F307358F"; +159 String result = instance.getMd5sum(); +160 assertEquals(expResult, result); +161 } +162 +163 /** +164 * Test of setMd5sum method, of class Dependency. +165 */ +166 @Test +167 public void testSetMd5sum() { +168 String md5sum = "test"; +169 Dependency instance = new Dependency(); +170 instance.setMd5sum(md5sum); +171 assertEquals(md5sum, instance.getMd5sum()); +172 } +173 +174 /** +175 * Test of getSha1sum method, of class Dependency. +176 */ +177 @Test +178 public void testGetSha1sum() { +179 File file = new File(this.getClass().getClassLoader().getResource("struts2-core-2.1.2.jar").getPath()); +180 Dependency instance = new Dependency(file); +181 String expResult = "89CE9E36AA9A9E03F1450936D2F4F8DD0F961F8B"; +182 String result = instance.getSha1sum(); +183 assertEquals(expResult, result); +184 } +185 +186 /** +187 * Test of setSha1sum method, of class Dependency. +188 */ +189 @Test +190 public void testSetSha1sum() { +191 String sha1sum = "test"; +192 Dependency instance = new Dependency(); +193 instance.setSha1sum(sha1sum); +194 assertEquals(sha1sum, instance.getSha1sum()); +195 } +196 +197 /** +198 * Test of getIdentifiers method, of class Dependency. +199 */ +200 @Test +201 public void testGetIdentifiers() { +202 Dependency instance = new Dependency(); +203 List expResult = null; +204 Set<Identifier> result = instance.getIdentifiers(); +205 +206 assertTrue(true); //this is just a getter setter pair. +207 } +208 +209 /** +210 * Test of setIdentifiers method, of class Dependency. +211 */ +212 @Test +213 public void testSetIdentifiers() { +214 Set<Identifier> identifiers = null; +215 Dependency instance = new Dependency(); +216 instance.setIdentifiers(identifiers); +217 assertTrue(true); //this is just a getter setter pair. +218 } +219 +220 /** +221 * Test of addIdentifier method, of class Dependency. +222 */ +223 @Test +224 public void testAddIdentifier() { +225 String type = "cpe"; +226 String value = "cpe:/a:apache:struts:2.1.2"; +227 String url = "http://somewhere"; +228 Identifier expResult = new Identifier(type, value, url); +229 +230 Dependency instance = new Dependency(); +231 instance.addIdentifier(type, value, url); +232 assertEquals(1, instance.getIdentifiers().size()); +233 assertTrue("Identifier doesn't contain expected result.", instance.getIdentifiers().contains(expResult)); +234 } +235 +236 /** +237 * Test of getEvidence method, of class Dependency. +238 */ +239 @Test +240 public void testGetEvidence() { +241 Dependency instance = new Dependency(); +242 EvidenceCollection expResult = null; +243 EvidenceCollection result = instance.getEvidence(); +244 assertTrue(true); //this is just a getter setter pair. +245 } +246 +247 /** +248 * Test of getEvidenceUsed method, of class Dependency. +249 */ +250 @Test +251 public void testGetEvidenceUsed() { +252 Dependency instance = new Dependency(); +253 String expResult = "used"; +254 +255 instance.getProductEvidence().addEvidence("used", "used", "used", Confidence.HIGH); +256 instance.getProductEvidence().addEvidence("not", "not", "not", Confidence.MEDIUM); +257 for (Evidence e : instance.getProductEvidence().iterator(Confidence.HIGH)) { +258 String use = e.getValue(); +259 } 260 -261 assertEquals(1, result.size()); -262 assertTrue(result.containsUsedString(expResult)); -263 } -264 -265 /** -266 * Test of getVendorEvidence method, of class Dependency. -267 */ -268 @Test -269 public void testGetVendorEvidence() { -270 Dependency instance = new Dependency(); -271 EvidenceCollection expResult = null; -272 EvidenceCollection result = instance.getVendorEvidence(); -273 assertTrue(true); //this is just a getter setter pair. -274 } -275 -276 /** -277 * Test of getProductEvidence method, of class Dependency. -278 */ -279 @Test -280 public void testGetProductEvidence() { -281 Dependency instance = new Dependency(); -282 EvidenceCollection expResult = null; -283 EvidenceCollection result = instance.getProductEvidence(); -284 assertTrue(true); //this is just a getter setter pair. -285 } -286 -287 /** -288 * Test of getVersionEvidence method, of class Dependency. -289 */ -290 @Test -291 public void testGetVersionEvidence() { -292 Dependency instance = new Dependency(); -293 EvidenceCollection expResult = null; -294 EvidenceCollection result = instance.getVersionEvidence(); -295 assertTrue(true); //this is just a getter setter pair. -296 } -297 } +261 EvidenceCollection result = instance.getEvidenceUsed(); +262 +263 assertEquals(1, result.size()); +264 assertTrue(result.containsUsedString(expResult)); +265 } +266 +267 /** +268 * Test of getVendorEvidence method, of class Dependency. +269 */ +270 @Test +271 public void testGetVendorEvidence() { +272 Dependency instance = new Dependency(); +273 EvidenceCollection expResult = null; +274 EvidenceCollection result = instance.getVendorEvidence(); +275 assertTrue(true); //this is just a getter setter pair. +276 } +277 +278 /** +279 * Test of getProductEvidence method, of class Dependency. +280 */ +281 @Test +282 public void testGetProductEvidence() { +283 Dependency instance = new Dependency(); +284 EvidenceCollection expResult = null; +285 EvidenceCollection result = instance.getProductEvidence(); +286 assertTrue(true); //this is just a getter setter pair. +287 } +288 +289 /** +290 * Test of getVersionEvidence method, of class Dependency. +291 */ +292 @Test +293 public void testGetVersionEvidence() { +294 Dependency instance = new Dependency(); +295 EvidenceCollection expResult = null; +296 EvidenceCollection result = instance.getVersionEvidence(); +297 assertTrue(true); //this is just a getter setter pair. +298 } +299 +300 /** +301 * Test of addAsEvidence method, of class Dependency. +302 */ +303 @Test +304 public void testAddAsEvidence() { +305 Dependency instance = new Dependency(); +306 MavenArtifact mavenArtifact = new MavenArtifact("group", "artifact", "version", "url"); +307 instance.addAsEvidence("pom", mavenArtifact, Confidence.HIGH); +308 assertTrue(instance.getEvidence().contains(Confidence.HIGH)); +309 assertFalse(instance.getEvidence().getEvidence("pom", "groupid").isEmpty()); +310 assertFalse(instance.getEvidence().getEvidence("pom", "artifactid").isEmpty()); +311 assertFalse(instance.getEvidence().getEvidence("pom", "version").isEmpty()); +312 assertFalse(instance.getIdentifiers().isEmpty()); +313 } +314 +315 /** +316 * Test of addAsEvidence method, of class Dependency. +317 */ +318 @Test +319 public void testAddAsEvidenceWithEmptyArtefact() { +320 Dependency instance = new Dependency(); +321 MavenArtifact mavenArtifact = new MavenArtifact(null, null, null, null); +322 instance.addAsEvidence("pom", mavenArtifact, Confidence.HIGH); +323 assertFalse(instance.getEvidence().contains(Confidence.HIGH)); +324 assertTrue(instance.getEvidence().getEvidence("pom", "groupid").isEmpty()); +325 assertTrue(instance.getEvidence().getEvidence("pom", "artifactid").isEmpty()); +326 assertTrue(instance.getEvidence().getEvidence("pom", "version").isEmpty()); +327 assertTrue(instance.getIdentifiers().isEmpty()); +328 } +329 }
    diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-frame.html index 3fc08ba78..570d6c96c 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.dependency + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.dependency diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-summary.html index 927ec0f2a..7f5eb6caa 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/dependency/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.dependency + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.dependency diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/package-frame.html index 22eb6dcce..aec93b7c2 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/package-summary.html index 8df6b8874..d087cc76a 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-frame.html index 480a9e72d..6f7abcd12 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.reporting + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.reporting diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-summary.html index 68b24947b..a78ddfa7e 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/reporting/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.reporting + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.reporting diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-frame.html index 094e59d01..72650ffbb 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.suppression + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.suppression diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-summary.html index 3f8ca7a60..66fd0feac 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/suppression/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.suppression + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.suppression diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionTest.html index 9842c1845..7b441bf17 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionTest.html @@ -173,28 +173,36 @@ 165 version = new DependencyVersion("1.2.3.1"); 166 assertEquals(-1, instance.compareTo(version)); 167 -168 DependencyVersion[] dv = new DependencyVersion[7]; -169 dv[0] = new DependencyVersion("2.1.3"); -170 dv[1] = new DependencyVersion("2.1.3.r2"); -171 dv[2] = new DependencyVersion("2.1.3.r1"); -172 dv[3] = new DependencyVersion("1.2.3.1"); -173 dv[4] = new DependencyVersion("1.2.3"); -174 dv[5] = new DependencyVersion("2"); -175 dv[6] = new DependencyVersion("-"); -176 -177 DependencyVersion[] expected = new DependencyVersion[7]; -178 expected[0] = new DependencyVersion("-"); -179 expected[1] = new DependencyVersion("1.2.3"); -180 expected[2] = new DependencyVersion("1.2.3.1"); -181 expected[3] = new DependencyVersion("2"); -182 expected[4] = new DependencyVersion("2.1.3"); -183 expected[5] = new DependencyVersion("2.1.3.r1"); -184 expected[6] = new DependencyVersion("2.1.3.r2"); -185 java.util.Arrays.sort(dv); -186 -187 assertArrayEquals(expected, dv); -188 } -189 } +168 instance = new DependencyVersion("1.0.1n"); +169 version = new DependencyVersion("1.0.1m"); +170 assertEquals(1, instance.compareTo(version)); +171 version = new DependencyVersion("1.0.1n"); +172 assertEquals(0, instance.compareTo(version)); +173 version = new DependencyVersion("1.0.1o"); +174 assertEquals(-1, instance.compareTo(version)); +175 +176 DependencyVersion[] dv = new DependencyVersion[7]; +177 dv[0] = new DependencyVersion("2.1.3"); +178 dv[1] = new DependencyVersion("2.1.3.r2"); +179 dv[2] = new DependencyVersion("2.1.3.r1"); +180 dv[3] = new DependencyVersion("1.2.3.1"); +181 dv[4] = new DependencyVersion("1.2.3"); +182 dv[5] = new DependencyVersion("2"); +183 dv[6] = new DependencyVersion("-"); +184 +185 DependencyVersion[] expected = new DependencyVersion[7]; +186 expected[0] = new DependencyVersion("-"); +187 expected[1] = new DependencyVersion("1.2.3"); +188 expected[2] = new DependencyVersion("1.2.3.1"); +189 expected[3] = new DependencyVersion("2"); +190 expected[4] = new DependencyVersion("2.1.3"); +191 expected[5] = new DependencyVersion("2.1.3.r1"); +192 expected[6] = new DependencyVersion("2.1.3.r2"); +193 java.util.Arrays.sort(dv); +194 +195 assertArrayEquals(expected, dv); +196 } +197 }
    diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionUtilTest.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionUtilTest.html index 2d2a06302..022eca57e 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionUtilTest.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/DependencyVersionUtilTest.html @@ -62,13 +62,13 @@ 54 * Test of parseVersion method, of class DependencyVersionUtil. 55 */ 56 @Test -57 public void testParseVersionFromFileName() { +57 public void testParseVersion() { 58 final String[] fileName = {"something-0.9.5.jar", "lib2-1.1.jar", "lib1.5r4-someflag-R26.jar", 59 "lib-1.2.5-dev-20050313.jar", "testlib_V4.4.0.jar", "lib-core-2.0.0-RC1-SNAPSHOT.jar", 60 "lib-jsp-2.0.1_R114940.jar", "dev-api-2.3.11_R121413.jar", "lib-api-3.7-SNAPSHOT.jar", -61 "-", "", "1.3-beta", "6"}; +61 "-", "", "1.3-beta", "6", "openssl1.0.1c", "jsf-impl-2.2.8-02.jar"}; 62 final String[] expResult = {"0.9.5", "1.1", "1.5.r4", "1.2.5", "4.4.0", "2.0.0.rc1", -63 "2.0.1.r114940", "2.3.11.r121413", "3.7", "-", null, "1.3.beta", "6"}; +63 "2.0.1.r114940", "2.3.11.r121413", "3.7", "-", null, "1.3.beta", "6", "1.0.1c", "2.2.8.02"}; 64 65 for (int i = 0; i < fileName.length; i++) { 66 final DependencyVersion version = DependencyVersionUtil.parseVersion(fileName[i]); diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-frame.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-frame.html index 2f4cfd696..f9317d4a0 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-frame.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-summary.html b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-summary.html index 3c02ba0a8..a4b45f99f 100644 --- a/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-summary.html +++ b/dependency-check-core/xref-test/org/owasp/dependencycheck/utils/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-core/xref-test/overview-frame.html b/dependency-check-core/xref-test/overview-frame.html index b3a9b883b..a5830d8e9 100644 --- a/dependency-check-core/xref-test/overview-frame.html +++ b/dependency-check-core/xref-test/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference + Dependency-Check Core 1.2.6 Reference @@ -20,6 +20,9 @@
  • org.owasp.dependencycheck.analyzer +
  • +
  • + org.owasp.dependencycheck.data.central
  • org.owasp.dependencycheck.data.cpe @@ -41,6 +44,9 @@
  • org.owasp.dependencycheck.data.update +
  • +
  • + org.owasp.dependencycheck.data.update.task
  • org.owasp.dependencycheck.data.update.xml diff --git a/dependency-check-core/xref-test/overview-summary.html b/dependency-check-core/xref-test/overview-summary.html index d1af66637..2edda9873 100644 --- a/dependency-check-core/xref-test/overview-summary.html +++ b/dependency-check-core/xref-test/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference + Dependency-Check Core 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Core 1.2.5 Reference

    +

    Dependency-Check Core 1.2.6 Reference

    @@ -42,6 +42,11 @@ + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + - + - + - - - - - - - - + + + + + + + - + - + - + + - + - + - + - + - - - + + + - + - + - + - + - - - + + + - + - - + + - + - - + - + - + - + - + - + - - - + + + - - - + + + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - - - + + + - + - + - + - + - - - + + + - + - + - + - + - - - + + + - + - - - + + + - - - + + + - + - + - - + - + - + - + + + - - + - + - + - + - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - + + + + + + + + + + + + + - - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - + - + + + + + + + + + - + - + - + - + - + - + - + - + - + - - + + + - + - + - + - + - - - + + - + - - - - - + + + + + + - + - + - - - + + - - - - - + + + + + + + + + - + - + - - - - - - - - + + + + - - + + + - - - - - - - + - - - + - + + + + + + + + - + - - + + + - - - - - + + + + + + + + + - - + + + - - - - - - + + + + - - - - - - - - - - - - - - - + + + + + + + + - - - - - - + + + + + + - + - - - - - + + + - - - + + - + - - - + + + + + - - - + + + + + - - - - - - + + + + + + - - + + - + - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + - - + + - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - + + + + + + + - - - - - - + + + + + + + + - - - + + + + + + + - - - - - - - - - - - + + + + - - - - - + + + + + - - - - - - - - - - - - - - + + + - - - + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - + + + + + + + + + + + + + + - + - - - + + + - - - - - + + + - - + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + - - - + + + + - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1264,291 +1262,316 @@ - + - + - - - - - - - - - - + + + + + + - - - - - + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    org.owasp.dependencycheck.analyzer
    + org.owasp.dependencycheck.data.central +
    @@ -77,6 +82,11 @@ org.owasp.dependencycheck.data.update
    + org.owasp.dependencycheck.data.update.task +
    diff --git a/dependency-check-core/xref/allclasses-frame.html b/dependency-check-core/xref/allclasses-frame.html index 2acc71243..4b234079a 100644 --- a/dependency-check-core/xref/allclasses-frame.html +++ b/dependency-check-core/xref/allclasses-frame.html @@ -70,6 +70,12 @@
  • CachedWebDataSource +
  • +
  • + CentralAnalyzer +
  • +
  • + CentralSearch
  • CiManagement diff --git a/dependency-check-core/xref/index.html b/dependency-check-core/xref/index.html index 5151839d8..af28ffc0a 100644 --- a/dependency-check-core/xref/index.html +++ b/dependency-check-core/xref/index.html @@ -4,7 +4,7 @@ - Dependency-Check Core 1.2.5 Reference + Dependency-Check Core 1.2.6 Reference diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/Engine.html b/dependency-check-core/xref/org/owasp/dependencycheck/Engine.html index 4d4039934..e95ef55e8 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/Engine.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/Engine.html @@ -70,11 +70,11 @@ 62 /** 63 * A Map of analyzers grouped by Analysis phase. 64 */ -65 private transient final EnumMap<AnalysisPhase, List<Analyzer>> analyzers; +65 private final transient EnumMap<AnalysisPhase, List<Analyzer>> analyzers; 66 /** 67 * A Map of analyzers grouped by Analysis phase. 68 */ -69 private transient final Set<FileTypeAnalyzer> fileTypeAnalyzers; +69 private final transient Set<FileTypeAnalyzer> fileTypeAnalyzers; 70 /** 71 * The ClassLoader to use when dynamically loading Analyzer and Update services. 72 */ @@ -82,7 +82,7 @@ 74 /** 75 * The Logger for use throughout the class. 76 */ -77 private transient static final Logger LOGGER = Logger.getLogger(Engine.class.getName()); +77 private static final transient Logger LOGGER = Logger.getLogger(Engine.class.getName()); 78 79 /** 80 * Creates a new Engine. @@ -176,342 +176,370 @@ 168 * Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any 169 * dependencies identified are added to the dependency collection. 170 * -171 * @since v0.3.2.5 -172 * -173 * @param paths an array of paths to files or directories to be analyzed. -174 */ -175 public void scan(String[] paths) { -176 for (String path : paths) { -177 final File file = new File(path); -178 scan(file); -179 } -180 } -181 -182 /** -183 * Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies -184 * identified are added to the dependency collection. -185 * -186 * @param path the path to a file or directory to be analyzed. -187 */ -188 public void scan(String path) { -189 if (path.matches("^.*[\\/]\\*\\.[^\\/:*|?<>\"]+$")) { -190 final String[] parts = path.split("\\*\\."); -191 final String[] ext = new String[]{parts[parts.length - 1]}; -192 final File dir = new File(path.substring(0, path.length() - ext[0].length() - 2)); -193 if (dir.isDirectory()) { -194 final List<File> files = (List<File>) org.apache.commons.io.FileUtils.listFiles(dir, ext, true); -195 scan(files); -196 } else { -197 final String msg = String.format("Invalid file path provided to scan '%s'", path); -198 LOGGER.log(Level.SEVERE, msg); -199 } -200 } else { -201 final File file = new File(path); -202 scan(file); -203 } -204 } -205 -206 /** -207 * Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any -208 * dependencies identified are added to the dependency collection. -209 * -210 * @since v0.3.2.5 -211 * -212 * @param files an array of paths to files or directories to be analyzed. -213 */ -214 public void scan(File[] files) { -215 for (File file : files) { -216 scan(file); -217 } +171 * @param paths an array of paths to files or directories to be analyzed +172 * @return the list of dependencies scanned +173 * +174 * @since v0.3.2.5 +175 */ +176 public List<Dependency> scan(String[] paths) { +177 final List<Dependency> deps = new ArrayList<Dependency>(); +178 for (String path : paths) { +179 final File file = new File(path); +180 final List<Dependency> d = scan(file); +181 if (d != null) { +182 deps.addAll(d); +183 } +184 } +185 return deps; +186 } +187 +188 /** +189 * Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies +190 * identified are added to the dependency collection. +191 * +192 * @param path the path to a file or directory to be analyzed +193 * @return the list of dependencies scanned +194 */ +195 public List<Dependency> scan(String path) { +196 final File file = new File(path); +197 return scan(file); +198 } +199 +200 /** +201 * Scans an array of files or directories. If a directory is specified, it will be scanned recursively. Any +202 * dependencies identified are added to the dependency collection. +203 * +204 * @param files an array of paths to files or directories to be analyzed. +205 * @return the list of dependencies +206 * +207 * @since v0.3.2.5 +208 */ +209 public List<Dependency> scan(File[] files) { +210 final List<Dependency> deps = new ArrayList<Dependency>(); +211 for (File file : files) { +212 final List<Dependency> d = scan(file); +213 if (d != null) { +214 deps.addAll(d); +215 } +216 } +217 return deps; 218 } 219 220 /** 221 * Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any 222 * dependencies identified are added to the dependency collection. 223 * -224 * @since v0.3.2.5 -225 * -226 * @param files a set of paths to files or directories to be analyzed. -227 */ -228 public void scan(Set<File> files) { -229 for (File file : files) { -230 scan(file); -231 } -232 } -233 -234 /** -235 * Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any -236 * dependencies identified are added to the dependency collection. -237 * -238 * @since v0.3.2.5 -239 * -240 * @param files a set of paths to files or directories to be analyzed. -241 */ -242 public void scan(List<File> files) { -243 for (File file : files) { -244 scan(file); -245 } -246 } -247 -248 /** -249 * Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies -250 * identified are added to the dependency collection. -251 * -252 * @since v0.3.2.4 -253 * -254 * @param file the path to a file or directory to be analyzed. -255 */ -256 public void scan(File file) { -257 if (file.exists()) { -258 if (file.isDirectory()) { -259 scanDirectory(file); -260 } else { -261 scanFile(file); -262 } -263 } -264 } -265 -266 /** -267 * Recursively scans files and directories. Any dependencies identified are added to the dependency collection. +224 * @param files a set of paths to files or directories to be analyzed +225 * @return the list of dependencies scanned +226 * +227 * @since v0.3.2.5 +228 */ +229 public List<Dependency> scan(Set<File> files) { +230 final List<Dependency> deps = new ArrayList<Dependency>(); +231 for (File file : files) { +232 final List<Dependency> d = scan(file); +233 if (d != null) { +234 deps.addAll(d); +235 } +236 } +237 return deps; +238 } +239 +240 /** +241 * Scans a list of files or directories. If a directory is specified, it will be scanned recursively. Any +242 * dependencies identified are added to the dependency collection. +243 * +244 * @param files a set of paths to files or directories to be analyzed +245 * @return the list of dependencies scanned +246 * +247 * @since v0.3.2.5 +248 */ +249 public List<Dependency> scan(List<File> files) { +250 final List<Dependency> deps = new ArrayList<Dependency>(); +251 for (File file : files) { +252 final List<Dependency> d = scan(file); +253 if (d != null) { +254 deps.addAll(d); +255 } +256 } +257 return deps; +258 } +259 +260 /** +261 * Scans a given file or directory. If a directory is specified, it will be scanned recursively. Any dependencies +262 * identified are added to the dependency collection. +263 * +264 * @param file the path to a file or directory to be analyzed +265 * @return the list of dependencies scanned +266 * +267 * @since v0.3.2.4 268 * -269 * @param dir the directory to scan. -270 */ -271 protected void scanDirectory(File dir) { -272 final File[] files = dir.listFiles(); -273 if (files != null) { -274 for (File f : files) { -275 if (f.isDirectory()) { -276 scanDirectory(f); -277 } else { -278 scanFile(f); -279 } -280 } -281 } -282 } -283 -284 /** -285 * Scans a specified file. If a dependency is identified it is added to the dependency collection. -286 * -287 * @param file The file to scan. -288 */ -289 protected void scanFile(File file) { -290 if (!file.isFile()) { -291 final String msg = String.format("Path passed to scanFile(File) is not a file: %s. Skipping the file.", file.toString()); -292 LOGGER.log(Level.FINE, msg); -293 return; -294 } -295 final String fileName = file.getName(); -296 final String extension = FileUtils.getFileExtension(fileName); -297 if (extension != null) { -298 if (supportsExtension(extension)) { -299 final Dependency dependency = new Dependency(file); -300 dependencies.add(dependency); -301 } -302 } else { -303 final String msg = String.format("No file extension found on file '%s'. The file was not analyzed.", -304 file.toString()); -305 LOGGER.log(Level.FINEST, msg); -306 } -307 } -308 -309 /** -310 * Runs the analyzers against all of the dependencies. -311 */ -312 public void analyzeDependencies() { -313 //need to ensure that data exists -314 try { -315 ensureDataExists(); -316 } catch (NoDataException ex) { -317 final String msg = String.format("%s%n%nUnable to continue dependency-check analysis.", ex.getMessage()); -318 LOGGER.log(Level.SEVERE, msg); -319 LOGGER.log(Level.FINE, null, ex); -320 return; -321 } catch (DatabaseException ex) { -322 final String msg = String.format("%s%n%nUnable to continue dependency-check analysis.", ex.getMessage()); -323 LOGGER.log(Level.SEVERE, msg); -324 LOGGER.log(Level.FINE, null, ex); -325 return; -326 -327 } -328 -329 final String logHeader = String.format("%n" -330 + "----------------------------------------------------%n" -331 + "BEGIN ANALYSIS%n" -332 + "----------------------------------------------------"); -333 LOGGER.log(Level.FINE, logHeader); -334 LOGGER.log(Level.INFO, "Analysis Starting"); -335 -336 // analysis phases -337 for (AnalysisPhase phase : AnalysisPhase.values()) { -338 final List<Analyzer> analyzerList = analyzers.get(phase); -339 -340 for (Analyzer a : analyzerList) { -341 initializeAnalyzer(a); -342 -343 /* need to create a copy of the collection because some of the -344 * analyzers may modify it. This prevents ConcurrentModificationExceptions. -345 * This is okay for adds/deletes because it happens per analyzer. -346 */ -347 final String msg = String.format("Begin Analyzer '%s'", a.getName()); -348 LOGGER.log(Level.FINE, msg); -349 final Set<Dependency> dependencySet = new HashSet<Dependency>(); -350 dependencySet.addAll(dependencies); -351 for (Dependency d : dependencySet) { -352 boolean shouldAnalyze = true; -353 if (a instanceof FileTypeAnalyzer) { -354 final FileTypeAnalyzer fAnalyzer = (FileTypeAnalyzer) a; -355 shouldAnalyze = fAnalyzer.supportsExtension(d.getFileExtension()); -356 } -357 if (shouldAnalyze) { -358 final String msgFile = String.format("Begin Analysis of '%s'", d.getActualFilePath()); -359 LOGGER.log(Level.FINE, msgFile); -360 try { -361 a.analyze(d, this); -362 } catch (AnalysisException ex) { -363 final String exMsg = String.format("An error occurred while analyzing '%s'.", d.getActualFilePath()); -364 LOGGER.log(Level.WARNING, exMsg); -365 LOGGER.log(Level.FINE, "", ex); -366 } catch (Throwable ex) { -367 final String axMsg = String.format("An unexpected error occurred during analysis of '%s'", d.getActualFilePath()); -368 //final AnalysisException ax = new AnalysisException(axMsg, ex); -369 LOGGER.log(Level.WARNING, axMsg); -370 LOGGER.log(Level.FINE, "", ex); -371 } -372 } -373 } -374 } -375 } -376 for (AnalysisPhase phase : AnalysisPhase.values()) { -377 final List<Analyzer> analyzerList = analyzers.get(phase); -378 -379 for (Analyzer a : analyzerList) { -380 closeAnalyzer(a); -381 } -382 } -383 -384 final String logFooter = String.format("%n" -385 + "----------------------------------------------------%n" -386 + "END ANALYSIS%n" -387 + "----------------------------------------------------"); -388 LOGGER.log(Level.FINE, logFooter); -389 LOGGER.log(Level.INFO, "Analysis Complete"); -390 } -391 -392 /** -393 * Initializes the given analyzer. -394 * -395 * @param analyzer the analyzer to initialize -396 */ -397 private void initializeAnalyzer(Analyzer analyzer) { -398 try { -399 final String msg = String.format("Initializing %s", analyzer.getName()); -400 LOGGER.log(Level.FINE, msg); -401 analyzer.initialize(); -402 } catch (Throwable ex) { -403 final String msg = String.format("Exception occurred initializing %s.", analyzer.getName()); -404 LOGGER.log(Level.SEVERE, msg); -405 LOGGER.log(Level.FINE, null, ex); -406 try { -407 analyzer.close(); -408 } catch (Throwable ex1) { -409 LOGGER.log(Level.FINEST, null, ex1); +269 */ +270 public List<Dependency> scan(File file) { +271 if (file.exists()) { +272 if (file.isDirectory()) { +273 return scanDirectory(file); +274 } else { +275 final Dependency d = scanFile(file); +276 if (d != null) { +277 final List<Dependency> deps = new ArrayList<Dependency>(); +278 deps.add(d); +279 return deps; +280 } +281 } +282 } +283 return null; +284 } +285 +286 /** +287 * Recursively scans files and directories. Any dependencies identified are added to the dependency collection. +288 * +289 * @param dir the directory to scan +290 * @return the list of Dependency objects scanned +291 */ +292 protected List<Dependency> scanDirectory(File dir) { +293 final File[] files = dir.listFiles(); +294 final List<Dependency> deps = new ArrayList<Dependency>(); +295 if (files != null) { +296 for (File f : files) { +297 if (f.isDirectory()) { +298 final List<Dependency> d = scanDirectory(f); +299 if (d != null) { +300 deps.addAll(d); +301 } +302 } else { +303 final Dependency d = scanFile(f); +304 deps.add(d); +305 } +306 } +307 } +308 return deps; +309 } +310 +311 /** +312 * Scans a specified file. If a dependency is identified it is added to the dependency collection. +313 * +314 * @param file The file to scan +315 * @return the scanned dependency +316 */ +317 protected Dependency scanFile(File file) { +318 if (!file.isFile()) { +319 final String msg = String.format("Path passed to scanFile(File) is not a file: %s. Skipping the file.", file.toString()); +320 LOGGER.log(Level.FINE, msg); +321 return null; +322 } +323 final String fileName = file.getName(); +324 final String extension = FileUtils.getFileExtension(fileName); +325 Dependency dependency = null; +326 if (extension != null) { +327 if (supportsExtension(extension)) { +328 dependency = new Dependency(file); +329 dependencies.add(dependency); +330 } +331 } else { +332 final String msg = String.format("No file extension found on file '%s'. The file was not analyzed.", file.toString()); +333 LOGGER.log(Level.FINEST, msg); +334 } +335 return dependency; +336 } +337 +338 /** +339 * Runs the analyzers against all of the dependencies. +340 */ +341 public void analyzeDependencies() { +342 //need to ensure that data exists +343 try { +344 ensureDataExists(); +345 } catch (NoDataException ex) { +346 final String msg = String.format("%s%n%nUnable to continue dependency-check analysis.", ex.getMessage()); +347 LOGGER.log(Level.SEVERE, msg); +348 LOGGER.log(Level.FINE, null, ex); +349 return; +350 } catch (DatabaseException ex) { +351 final String msg = String.format("%s%n%nUnable to continue dependency-check analysis.", ex.getMessage()); +352 LOGGER.log(Level.SEVERE, msg); +353 LOGGER.log(Level.FINE, null, ex); +354 return; +355 +356 } +357 +358 final String logHeader = String.format("%n" +359 + "----------------------------------------------------%n" +360 + "BEGIN ANALYSIS%n" +361 + "----------------------------------------------------"); +362 LOGGER.log(Level.FINE, logHeader); +363 LOGGER.log(Level.INFO, "Analysis Starting"); +364 +365 // analysis phases +366 for (AnalysisPhase phase : AnalysisPhase.values()) { +367 final List<Analyzer> analyzerList = analyzers.get(phase); +368 +369 for (Analyzer a : analyzerList) { +370 initializeAnalyzer(a); +371 +372 /* need to create a copy of the collection because some of the +373 * analyzers may modify it. This prevents ConcurrentModificationExceptions. +374 * This is okay for adds/deletes because it happens per analyzer. +375 */ +376 final String msg = String.format("Begin Analyzer '%s'", a.getName()); +377 LOGGER.log(Level.FINE, msg); +378 final Set<Dependency> dependencySet = new HashSet<Dependency>(); +379 dependencySet.addAll(dependencies); +380 for (Dependency d : dependencySet) { +381 boolean shouldAnalyze = true; +382 if (a instanceof FileTypeAnalyzer) { +383 final FileTypeAnalyzer fAnalyzer = (FileTypeAnalyzer) a; +384 shouldAnalyze = fAnalyzer.supportsExtension(d.getFileExtension()); +385 } +386 if (shouldAnalyze) { +387 final String msgFile = String.format("Begin Analysis of '%s'", d.getActualFilePath()); +388 LOGGER.log(Level.FINE, msgFile); +389 try { +390 a.analyze(d, this); +391 } catch (AnalysisException ex) { +392 final String exMsg = String.format("An error occurred while analyzing '%s'.", d.getActualFilePath()); +393 LOGGER.log(Level.WARNING, exMsg); +394 LOGGER.log(Level.FINE, "", ex); +395 } catch (Throwable ex) { +396 final String axMsg = String.format("An unexpected error occurred during analysis of '%s'", d.getActualFilePath()); +397 //final AnalysisException ax = new AnalysisException(axMsg, ex); +398 LOGGER.log(Level.WARNING, axMsg); +399 LOGGER.log(Level.FINE, "", ex); +400 } +401 } +402 } +403 } +404 } +405 for (AnalysisPhase phase : AnalysisPhase.values()) { +406 final List<Analyzer> analyzerList = analyzers.get(phase); +407 +408 for (Analyzer a : analyzerList) { +409 closeAnalyzer(a); 410 } 411 } -412 } -413 -414 /** -415 * Closes the given analyzer. -416 * -417 * @param analyzer the analyzer to close -418 */ -419 private void closeAnalyzer(Analyzer analyzer) { -420 final String msg = String.format("Closing Analyzer '%s'", analyzer.getName()); -421 LOGGER.log(Level.FINE, msg); -422 try { -423 analyzer.close(); -424 } catch (Throwable ex) { -425 LOGGER.log(Level.FINEST, null, ex); -426 } -427 } -428 -429 /** -430 * Cycles through the cached web data sources and calls update on all of them. -431 */ -432 private void doUpdates() { -433 final UpdateService service = new UpdateService(serviceClassLoader); -434 final Iterator<CachedWebDataSource> iterator = service.getDataSources(); -435 while (iterator.hasNext()) { -436 final CachedWebDataSource source = iterator.next(); -437 try { -438 source.update(); -439 } catch (UpdateException ex) { -440 LOGGER.log(Level.WARNING, -441 "Unable to update Cached Web DataSource, using local data instead. Results may not include recent vulnerabilities."); -442 LOGGER.log(Level.FINE, -443 String.format("Unable to update details for %s", source.getClass().getName()), ex); -444 } -445 } -446 } -447 -448 /** -449 * Returns a full list of all of the analyzers. This is useful for reporting which analyzers where used. -450 * -451 * @return a list of Analyzers -452 */ -453 public List<Analyzer> getAnalyzers() { -454 final List<Analyzer> ret = new ArrayList<Analyzer>(); -455 for (AnalysisPhase phase : AnalysisPhase.values()) { -456 final List<Analyzer> analyzerList = analyzers.get(phase); -457 ret.addAll(analyzerList); -458 } -459 return ret; -460 } -461 -462 /** -463 * Checks all analyzers to see if an extension is supported. -464 * -465 * @param ext a file extension -466 * @return true or false depending on whether or not the file extension is supported -467 */ -468 public boolean supportsExtension(String ext) { -469 if (ext == null) { -470 return false; -471 } -472 boolean scan = false; -473 for (FileTypeAnalyzer a : this.fileTypeAnalyzers) { -474 /* note, we can't break early on this loop as the analyzers need to know if -475 they have files to work on prior to initialization */ -476 scan |= a.supportsExtension(ext); -477 } -478 return scan; -479 } -480 -481 /** -482 * Checks the CPE Index to ensure documents exists. If none exist a NoDataException is thrown. -483 * -484 * @throws NoDataException thrown if no data exists in the CPE Index -485 * @throws DatabaseException thrown if there is an exception opening the database -486 */ -487 private void ensureDataExists() throws NoDataException, DatabaseException { -488 final CpeMemoryIndex cpe = CpeMemoryIndex.getInstance(); -489 final CveDB cve = new CveDB(); -490 -491 try { -492 cve.open(); -493 cpe.open(cve); -494 } catch (IndexException ex) { -495 throw new NoDataException(ex.getMessage(), ex); -496 } catch (DatabaseException ex) { -497 throw new NoDataException(ex.getMessage(), ex); -498 } finally { -499 cve.close(); -500 } -501 if (cpe.numDocs() <= 0) { -502 cpe.close(); -503 throw new NoDataException("No documents exist"); -504 } -505 } -506 } +412 +413 final String logFooter = String.format("%n" +414 + "----------------------------------------------------%n" +415 + "END ANALYSIS%n" +416 + "----------------------------------------------------"); +417 LOGGER.log(Level.FINE, logFooter); +418 LOGGER.log(Level.INFO, "Analysis Complete"); +419 } +420 +421 /** +422 * Initializes the given analyzer. +423 * +424 * @param analyzer the analyzer to initialize +425 */ +426 private void initializeAnalyzer(Analyzer analyzer) { +427 try { +428 final String msg = String.format("Initializing %s", analyzer.getName()); +429 LOGGER.log(Level.FINE, msg); +430 analyzer.initialize(); +431 } catch (Throwable ex) { +432 final String msg = String.format("Exception occurred initializing %s.", analyzer.getName()); +433 LOGGER.log(Level.SEVERE, msg); +434 LOGGER.log(Level.FINE, null, ex); +435 try { +436 analyzer.close(); +437 } catch (Throwable ex1) { +438 LOGGER.log(Level.FINEST, null, ex1); +439 } +440 } +441 } +442 +443 /** +444 * Closes the given analyzer. +445 * +446 * @param analyzer the analyzer to close +447 */ +448 private void closeAnalyzer(Analyzer analyzer) { +449 final String msg = String.format("Closing Analyzer '%s'", analyzer.getName()); +450 LOGGER.log(Level.FINE, msg); +451 try { +452 analyzer.close(); +453 } catch (Throwable ex) { +454 LOGGER.log(Level.FINEST, null, ex); +455 } +456 } +457 +458 /** +459 * Cycles through the cached web data sources and calls update on all of them. +460 */ +461 private void doUpdates() { +462 final UpdateService service = new UpdateService(serviceClassLoader); +463 final Iterator<CachedWebDataSource> iterator = service.getDataSources(); +464 while (iterator.hasNext()) { +465 final CachedWebDataSource source = iterator.next(); +466 try { +467 source.update(); +468 } catch (UpdateException ex) { +469 LOGGER.log(Level.WARNING, +470 "Unable to update Cached Web DataSource, using local data instead. Results may not include recent vulnerabilities."); +471 LOGGER.log(Level.FINE, String.format("Unable to update details for %s", source.getClass().getName()), ex); +472 } +473 } +474 } +475 +476 /** +477 * Returns a full list of all of the analyzers. This is useful for reporting which analyzers where used. +478 * +479 * @return a list of Analyzers +480 */ +481 public List<Analyzer> getAnalyzers() { +482 final List<Analyzer> ret = new ArrayList<Analyzer>(); +483 for (AnalysisPhase phase : AnalysisPhase.values()) { +484 final List<Analyzer> analyzerList = analyzers.get(phase); +485 ret.addAll(analyzerList); +486 } +487 return ret; +488 } +489 +490 /** +491 * Checks all analyzers to see if an extension is supported. +492 * +493 * @param ext a file extension +494 * @return true or false depending on whether or not the file extension is supported +495 */ +496 public boolean supportsExtension(String ext) { +497 if (ext == null) { +498 return false; +499 } +500 boolean scan = false; +501 for (FileTypeAnalyzer a : this.fileTypeAnalyzers) { +502 /* note, we can't break early on this loop as the analyzers need to know if +503 they have files to work on prior to initialization */ +504 scan |= a.supportsExtension(ext); +505 } +506 return scan; +507 } +508 +509 /** +510 * Checks the CPE Index to ensure documents exists. If none exist a NoDataException is thrown. +511 * +512 * @throws NoDataException thrown if no data exists in the CPE Index +513 * @throws DatabaseException thrown if there is an exception opening the database +514 */ +515 private void ensureDataExists() throws NoDataException, DatabaseException { +516 final CpeMemoryIndex cpe = CpeMemoryIndex.getInstance(); +517 final CveDB cve = new CveDB(); +518 +519 try { +520 cve.open(); +521 cpe.open(cve); +522 } catch (IndexException ex) { +523 throw new NoDataException(ex.getMessage(), ex); +524 } catch (DatabaseException ex) { +525 throw new NoDataException(ex.getMessage(), ex); +526 } finally { +527 cve.close(); +528 } +529 if (cpe.numDocs() <= 0) { +530 cpe.close(); +531 throw new NoDataException("No documents exist"); +532 } +533 } +534 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-frame.html index 44045661c..e05497be0 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.agent + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.agent diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-summary.html index 6f82bb9c6..2d8fe026f 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/agent/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.agent + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.agent diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html index 51bf73a16..2f94a7c27 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.html @@ -118,7 +118,7 @@ 110 static { 111 final String additionalZipExt = Settings.getString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS); 112 if (additionalZipExt != null) { -113 final HashSet ext = new HashSet<String>(Arrays.asList(additionalZipExt)); +113 final HashSet<String> ext = new HashSet<String>(Arrays.asList(additionalZipExt)); 114 ZIPPABLES.addAll(ext); 115 } 116 EXTENSIONS.addAll(ZIPPABLES); @@ -194,7 +194,7 @@ 186 if (tempFileLocation != null && tempFileLocation.exists()) { 187 LOGGER.log(Level.FINE, "Attempting to delete temporary files"); 188 final boolean success = FileUtils.delete(tempFileLocation); -189 if (!success && tempFileLocation != null & tempFileLocation.exists()) { +189 if (!success && tempFileLocation != null && tempFileLocation.exists() && tempFileLocation.list().length > 0) { 190 LOGGER.log(Level.WARNING, "Failed to delete some temporary files, see the log for more details"); 191 } 192 } @@ -229,273 +229,272 @@ 221 final String displayPath = String.format("%s%s", 222 dependency.getFilePath(), 223 d.getActualFilePath().substring(tmpDir.getAbsolutePath().length())); -224 final String displayName = String.format("%s%s%s", +224 final String displayName = String.format("%s: %s", 225 dependency.getFileName(), -226 File.separator, -227 d.getFileName()); -228 d.setFilePath(displayPath); -229 d.setFileName(displayName); -230 -231 //TODO - can we get more evidence from the parent? EAR contains module name, etc. -232 //analyze the dependency (i.e. extract files) if it is a supported type. -233 if (this.supportsExtension(d.getFileExtension()) && scanDepth < MAX_SCAN_DEPTH) { -234 scanDepth += 1; -235 analyze(d, engine); -236 scanDepth -= 1; -237 } -238 } -239 } -240 if (this.REMOVE_FROM_ANALYSIS.contains(dependency.getFileExtension())) { -241 if ("zip".equals(dependency.getFileExtension()) && isZipFileActuallyJarFile(dependency)) { -242 final File tdir = getNextTempDirectory(); -243 final String fileName = dependency.getFileName(); -244 -245 LOGGER.info(String.format("The zip file '%s' appears to be a JAR file, making a copy and analyzing it as a JAR.", fileName)); -246 -247 final File tmpLoc = new File(tdir, fileName.substring(0, fileName.length() - 3) + "jar"); -248 try { -249 org.apache.commons.io.FileUtils.copyFile(tdir, tmpLoc); -250 dependencies = new ArrayList<Dependency>(engine.getDependencies()); -251 engine.scan(tmpLoc); -252 newDependencies = engine.getDependencies(); -253 if (dependencies.size() != newDependencies.size()) { -254 //get the new dependencies -255 final Set<Dependency> dependencySet = new HashSet<Dependency>(); -256 dependencySet.addAll(newDependencies); -257 dependencySet.removeAll(dependencies); -258 if (dependencySet.size() != 1) { -259 LOGGER.info("Deep copy of ZIP to JAR file resulted in more then one dependency?"); -260 } -261 for (Dependency d : dependencySet) { -262 //fix the dependency's display name and path -263 d.setFilePath(dependency.getFilePath()); -264 d.setDisplayFileName(dependency.getFileName()); -265 } -266 } -267 } catch (IOException ex) { -268 final String msg = String.format("Unable to perform deep copy on '%s'", dependency.getActualFile().getPath()); -269 LOGGER.log(Level.FINE, msg, ex); -270 } -271 } -272 engine.getDependencies().remove(dependency); -273 } -274 Collections.sort(engine.getDependencies()); -275 } -276 -277 /** -278 * Retrieves the next temporary directory to extract an archive too. -279 * -280 * @return a directory -281 * @throws AnalysisException thrown if unable to create temporary directory -282 */ -283 private File getNextTempDirectory() throws AnalysisException { -284 dirCount += 1; -285 final File directory = new File(tempFileLocation, String.valueOf(dirCount)); -286 //getting an exception for some directories not being able to be created; might be because the directory already exists? -287 if (directory.exists()) { -288 return getNextTempDirectory(); -289 } -290 if (!directory.mkdirs()) { -291 final String msg = String.format("Unable to create temp directory '%s'.", directory.getAbsolutePath()); -292 throw new AnalysisException(msg); -293 } -294 return directory; -295 } -296 -297 /** -298 * Extracts the contents of an archive into the specified directory. -299 * -300 * @param archive an archive file such as a WAR or EAR -301 * @param destination a directory to extract the contents to -302 * @param engine the scanning engine -303 * @throws AnalysisException thrown if the archive is not found -304 */ -305 private void extractFiles(File archive, File destination, Engine engine) throws AnalysisException { -306 if (archive == null || destination == null) { -307 return; -308 } -309 -310 FileInputStream fis = null; -311 try { -312 fis = new FileInputStream(archive); -313 } catch (FileNotFoundException ex) { -314 LOGGER.log(Level.FINE, null, ex); -315 throw new AnalysisException("Archive file was not found.", ex); -316 } -317 final String archiveExt = FileUtils.getFileExtension(archive.getName()).toLowerCase(); -318 try { -319 if (ZIPPABLES.contains(archiveExt)) { -320 extractArchive(new ZipArchiveInputStream(new BufferedInputStream(fis)), destination, engine); -321 } else if ("tar".equals(archiveExt)) { -322 extractArchive(new TarArchiveInputStream(new BufferedInputStream(fis)), destination, engine); -323 } else if ("gz".equals(archiveExt) || "tgz".equals(archiveExt)) { -324 final String uncompressedName = GzipUtils.getUncompressedFilename(archive.getName()); -325 final String uncompressedExt = FileUtils.getFileExtension(uncompressedName).toLowerCase(); -326 if (engine.supportsExtension(uncompressedExt)) { -327 decompressFile(new GzipCompressorInputStream(new BufferedInputStream(fis)), new File(destination, uncompressedName)); -328 } -329 } -330 } catch (ArchiveExtractionException ex) { -331 final String msg = String.format("Exception extracting archive '%s'.", archive.getName()); -332 LOGGER.log(Level.WARNING, msg); -333 LOGGER.log(Level.FINE, null, ex); -334 } catch (IOException ex) { -335 final String msg = String.format("Exception reading archive '%s'.", archive.getName()); -336 LOGGER.log(Level.WARNING, msg); -337 LOGGER.log(Level.FINE, null, ex); -338 } finally { -339 try { -340 fis.close(); -341 } catch (IOException ex) { -342 LOGGER.log(Level.FINEST, null, ex); -343 } -344 } -345 } -346 -347 /** -348 * Extracts files from an archive. -349 * -350 * @param input the archive to extract files from -351 * @param destination the location to write the files too -352 * @param engine the dependency-check engine -353 * @throws ArchiveExtractionException thrown if there is an exception extracting files from the archive -354 */ -355 private void extractArchive(ArchiveInputStream input, File destination, Engine engine) throws ArchiveExtractionException { -356 ArchiveEntry entry; -357 try { -358 while ((entry = input.getNextEntry()) != null) { -359 if (entry.isDirectory()) { -360 final File d = new File(destination, entry.getName()); -361 if (!d.exists()) { -362 if (!d.mkdirs()) { -363 final String msg = String.format("Unable to create directory '%s'.", d.getAbsolutePath()); -364 throw new AnalysisException(msg); -365 } -366 } -367 } else { -368 final File file = new File(destination, entry.getName()); -369 final String ext = FileUtils.getFileExtension(file.getName()); -370 if (engine.supportsExtension(ext)) { -371 BufferedOutputStream bos = null; -372 FileOutputStream fos; -373 try { -374 final File parent = file.getParentFile(); -375 if (!parent.isDirectory()) { -376 if (!parent.mkdirs()) { -377 final String msg = String.format("Unable to build directory '%s'.", parent.getAbsolutePath()); -378 throw new AnalysisException(msg); -379 } -380 } -381 fos = new FileOutputStream(file); -382 bos = new BufferedOutputStream(fos, BUFFER_SIZE); -383 int count; -384 final byte data[] = new byte[BUFFER_SIZE]; -385 while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) { -386 bos.write(data, 0, count); -387 } -388 bos.flush(); -389 } catch (FileNotFoundException ex) { -390 LOGGER.log(Level.FINE, null, ex); -391 final String msg = String.format("Unable to find file '%s'.", file.getName()); -392 throw new AnalysisException(msg, ex); -393 } catch (IOException ex) { -394 LOGGER.log(Level.FINE, null, ex); -395 final String msg = String.format("IO Exception while parsing file '%s'.", file.getName()); -396 throw new AnalysisException(msg, ex); -397 } finally { -398 if (bos != null) { -399 try { -400 bos.close(); -401 } catch (IOException ex) { -402 LOGGER.log(Level.FINEST, null, ex); -403 } -404 } -405 } -406 } -407 } -408 } -409 } catch (IOException ex) { -410 throw new ArchiveExtractionException(ex); -411 } catch (Throwable ex) { -412 throw new ArchiveExtractionException(ex); -413 } finally { -414 if (input != null) { -415 try { -416 input.close(); -417 } catch (IOException ex) { -418 LOGGER.log(Level.FINEST, null, ex); -419 } -420 } -421 } -422 } -423 -424 /** -425 * Decompresses a file. -426 * -427 * @param inputStream the compressed file -428 * @param outputFile the location to write the decompressed file -429 * @throws ArchiveExtractionException thrown if there is an exception decompressing the file -430 */ -431 private void decompressFile(CompressorInputStream inputStream, File outputFile) throws ArchiveExtractionException { -432 FileOutputStream out = null; -433 try { -434 out = new FileOutputStream(outputFile); -435 final byte[] buffer = new byte[BUFFER_SIZE]; -436 int n = 0; -437 while (-1 != (n = inputStream.read(buffer))) { -438 out.write(buffer, 0, n); -439 } -440 } catch (FileNotFoundException ex) { -441 LOGGER.log(Level.FINE, null, ex); -442 throw new ArchiveExtractionException(ex); -443 } catch (IOException ex) { -444 LOGGER.log(Level.FINE, null, ex); -445 throw new ArchiveExtractionException(ex); -446 } finally { -447 if (out != null) { -448 try { -449 out.close(); -450 } catch (IOException ex) { -451 LOGGER.log(Level.FINEST, null, ex); -452 } -453 } -454 } -455 } -456 -457 /** -458 * Attempts to determine if a zip file is actually a JAR file. -459 * -460 * @param dependency the dependency to check -461 * @return true if the dependency appears to be a JAR file; otherwise false -462 */ -463 private boolean isZipFileActuallyJarFile(Dependency dependency) { -464 boolean isJar = false; -465 ZipFile zip = null; -466 try { -467 zip = new ZipFile(dependency.getActualFilePath()); -468 if (zip.getEntry("META-INF/MANIFEST.MF") != null -469 || zip.getEntry("META-INF/maven") != null) { -470 final Enumeration<ZipArchiveEntry> entries = zip.getEntries(); -471 while (entries.hasMoreElements()) { -472 final ZipArchiveEntry entry = entries.nextElement(); -473 if (!entry.isDirectory()) { -474 final String name = entry.getName().toLowerCase(); -475 if (name.endsWith(".class")) { -476 isJar = true; -477 break; -478 } -479 } -480 } -481 } -482 } catch (IOException ex) { -483 LOGGER.log(Level.FINE, String.format("Unable to unzip zip file '%s'", dependency.getFilePath()), ex); -484 } finally { -485 ZipFile.closeQuietly(zip); -486 } -487 -488 return isJar; -489 } -490 } +226 d.getFileName()); +227 d.setFilePath(displayPath); +228 d.setFileName(displayName); +229 +230 //TODO - can we get more evidence from the parent? EAR contains module name, etc. +231 //analyze the dependency (i.e. extract files) if it is a supported type. +232 if (this.supportsExtension(d.getFileExtension()) && scanDepth < MAX_SCAN_DEPTH) { +233 scanDepth += 1; +234 analyze(d, engine); +235 scanDepth -= 1; +236 } +237 } +238 } +239 if (this.REMOVE_FROM_ANALYSIS.contains(dependency.getFileExtension())) { +240 if ("zip".equals(dependency.getFileExtension()) && isZipFileActuallyJarFile(dependency)) { +241 final File tdir = getNextTempDirectory(); +242 final String fileName = dependency.getFileName(); +243 +244 LOGGER.info(String.format("The zip file '%s' appears to be a JAR file, making a copy and analyzing it as a JAR.", fileName)); +245 +246 final File tmpLoc = new File(tdir, fileName.substring(0, fileName.length() - 3) + "jar"); +247 try { +248 org.apache.commons.io.FileUtils.copyFile(tdir, tmpLoc); +249 dependencies = new ArrayList<Dependency>(engine.getDependencies()); +250 engine.scan(tmpLoc); +251 newDependencies = engine.getDependencies(); +252 if (dependencies.size() != newDependencies.size()) { +253 //get the new dependencies +254 final Set<Dependency> dependencySet = new HashSet<Dependency>(); +255 dependencySet.addAll(newDependencies); +256 dependencySet.removeAll(dependencies); +257 if (dependencySet.size() != 1) { +258 LOGGER.info("Deep copy of ZIP to JAR file resulted in more then one dependency?"); +259 } +260 for (Dependency d : dependencySet) { +261 //fix the dependency's display name and path +262 d.setFilePath(dependency.getFilePath()); +263 d.setDisplayFileName(dependency.getFileName()); +264 } +265 } +266 } catch (IOException ex) { +267 final String msg = String.format("Unable to perform deep copy on '%s'", dependency.getActualFile().getPath()); +268 LOGGER.log(Level.FINE, msg, ex); +269 } +270 } +271 engine.getDependencies().remove(dependency); +272 } +273 Collections.sort(engine.getDependencies()); +274 } +275 +276 /** +277 * Retrieves the next temporary directory to extract an archive too. +278 * +279 * @return a directory +280 * @throws AnalysisException thrown if unable to create temporary directory +281 */ +282 private File getNextTempDirectory() throws AnalysisException { +283 dirCount += 1; +284 final File directory = new File(tempFileLocation, String.valueOf(dirCount)); +285 //getting an exception for some directories not being able to be created; might be because the directory already exists? +286 if (directory.exists()) { +287 return getNextTempDirectory(); +288 } +289 if (!directory.mkdirs()) { +290 final String msg = String.format("Unable to create temp directory '%s'.", directory.getAbsolutePath()); +291 throw new AnalysisException(msg); +292 } +293 return directory; +294 } +295 +296 /** +297 * Extracts the contents of an archive into the specified directory. +298 * +299 * @param archive an archive file such as a WAR or EAR +300 * @param destination a directory to extract the contents to +301 * @param engine the scanning engine +302 * @throws AnalysisException thrown if the archive is not found +303 */ +304 private void extractFiles(File archive, File destination, Engine engine) throws AnalysisException { +305 if (archive == null || destination == null) { +306 return; +307 } +308 +309 FileInputStream fis = null; +310 try { +311 fis = new FileInputStream(archive); +312 } catch (FileNotFoundException ex) { +313 LOGGER.log(Level.FINE, null, ex); +314 throw new AnalysisException("Archive file was not found.", ex); +315 } +316 final String archiveExt = FileUtils.getFileExtension(archive.getName()).toLowerCase(); +317 try { +318 if (ZIPPABLES.contains(archiveExt)) { +319 extractArchive(new ZipArchiveInputStream(new BufferedInputStream(fis)), destination, engine); +320 } else if ("tar".equals(archiveExt)) { +321 extractArchive(new TarArchiveInputStream(new BufferedInputStream(fis)), destination, engine); +322 } else if ("gz".equals(archiveExt) || "tgz".equals(archiveExt)) { +323 final String uncompressedName = GzipUtils.getUncompressedFilename(archive.getName()); +324 final String uncompressedExt = FileUtils.getFileExtension(uncompressedName).toLowerCase(); +325 if (engine.supportsExtension(uncompressedExt)) { +326 decompressFile(new GzipCompressorInputStream(new BufferedInputStream(fis)), new File(destination, uncompressedName)); +327 } +328 } +329 } catch (ArchiveExtractionException ex) { +330 final String msg = String.format("Exception extracting archive '%s'.", archive.getName()); +331 LOGGER.log(Level.WARNING, msg); +332 LOGGER.log(Level.FINE, null, ex); +333 } catch (IOException ex) { +334 final String msg = String.format("Exception reading archive '%s'.", archive.getName()); +335 LOGGER.log(Level.WARNING, msg); +336 LOGGER.log(Level.FINE, null, ex); +337 } finally { +338 try { +339 fis.close(); +340 } catch (IOException ex) { +341 LOGGER.log(Level.FINEST, null, ex); +342 } +343 } +344 } +345 +346 /** +347 * Extracts files from an archive. +348 * +349 * @param input the archive to extract files from +350 * @param destination the location to write the files too +351 * @param engine the dependency-check engine +352 * @throws ArchiveExtractionException thrown if there is an exception extracting files from the archive +353 */ +354 private void extractArchive(ArchiveInputStream input, File destination, Engine engine) throws ArchiveExtractionException { +355 ArchiveEntry entry; +356 try { +357 while ((entry = input.getNextEntry()) != null) { +358 if (entry.isDirectory()) { +359 final File d = new File(destination, entry.getName()); +360 if (!d.exists()) { +361 if (!d.mkdirs()) { +362 final String msg = String.format("Unable to create directory '%s'.", d.getAbsolutePath()); +363 throw new AnalysisException(msg); +364 } +365 } +366 } else { +367 final File file = new File(destination, entry.getName()); +368 final String ext = FileUtils.getFileExtension(file.getName()); +369 if (engine.supportsExtension(ext)) { +370 BufferedOutputStream bos = null; +371 FileOutputStream fos; +372 try { +373 final File parent = file.getParentFile(); +374 if (!parent.isDirectory()) { +375 if (!parent.mkdirs()) { +376 final String msg = String.format("Unable to build directory '%s'.", parent.getAbsolutePath()); +377 throw new AnalysisException(msg); +378 } +379 } +380 fos = new FileOutputStream(file); +381 bos = new BufferedOutputStream(fos, BUFFER_SIZE); +382 int count; +383 final byte data[] = new byte[BUFFER_SIZE]; +384 while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) { +385 bos.write(data, 0, count); +386 } +387 bos.flush(); +388 } catch (FileNotFoundException ex) { +389 LOGGER.log(Level.FINE, null, ex); +390 final String msg = String.format("Unable to find file '%s'.", file.getName()); +391 throw new AnalysisException(msg, ex); +392 } catch (IOException ex) { +393 LOGGER.log(Level.FINE, null, ex); +394 final String msg = String.format("IO Exception while parsing file '%s'.", file.getName()); +395 throw new AnalysisException(msg, ex); +396 } finally { +397 if (bos != null) { +398 try { +399 bos.close(); +400 } catch (IOException ex) { +401 LOGGER.log(Level.FINEST, null, ex); +402 } +403 } +404 } +405 } +406 } +407 } +408 } catch (IOException ex) { +409 throw new ArchiveExtractionException(ex); +410 } catch (Throwable ex) { +411 throw new ArchiveExtractionException(ex); +412 } finally { +413 if (input != null) { +414 try { +415 input.close(); +416 } catch (IOException ex) { +417 LOGGER.log(Level.FINEST, null, ex); +418 } +419 } +420 } +421 } +422 +423 /** +424 * Decompresses a file. +425 * +426 * @param inputStream the compressed file +427 * @param outputFile the location to write the decompressed file +428 * @throws ArchiveExtractionException thrown if there is an exception decompressing the file +429 */ +430 private void decompressFile(CompressorInputStream inputStream, File outputFile) throws ArchiveExtractionException { +431 FileOutputStream out = null; +432 try { +433 out = new FileOutputStream(outputFile); +434 final byte[] buffer = new byte[BUFFER_SIZE]; +435 int n = 0; +436 while (-1 != (n = inputStream.read(buffer))) { +437 out.write(buffer, 0, n); +438 } +439 } catch (FileNotFoundException ex) { +440 LOGGER.log(Level.FINE, null, ex); +441 throw new ArchiveExtractionException(ex); +442 } catch (IOException ex) { +443 LOGGER.log(Level.FINE, null, ex); +444 throw new ArchiveExtractionException(ex); +445 } finally { +446 if (out != null) { +447 try { +448 out.close(); +449 } catch (IOException ex) { +450 LOGGER.log(Level.FINEST, null, ex); +451 } +452 } +453 } +454 } +455 +456 /** +457 * Attempts to determine if a zip file is actually a JAR file. +458 * +459 * @param dependency the dependency to check +460 * @return true if the dependency appears to be a JAR file; otherwise false +461 */ +462 private boolean isZipFileActuallyJarFile(Dependency dependency) { +463 boolean isJar = false; +464 ZipFile zip = null; +465 try { +466 zip = new ZipFile(dependency.getActualFilePath()); +467 if (zip.getEntry("META-INF/MANIFEST.MF") != null +468 || zip.getEntry("META-INF/maven") != null) { +469 final Enumeration<ZipArchiveEntry> entries = zip.getEntries(); +470 while (entries.hasMoreElements()) { +471 final ZipArchiveEntry entry = entries.nextElement(); +472 if (!entry.isDirectory()) { +473 final String name = entry.getName().toLowerCase(); +474 if (name.endsWith(".class")) { +475 isJar = true; +476 break; +477 } +478 } +479 } +480 } +481 } catch (IOException ex) { +482 LOGGER.log(Level.FINE, String.format("Unable to unzip zip file '%s'", dependency.getFilePath()), ex); +483 } finally { +484 ZipFile.closeQuietly(zip); +485 } +486 +487 return isJar; +488 } +489 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html index 560bb0433..289e21f35 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.html @@ -128,205 +128,209 @@ 120 // Try evacuating the error stream 121 rdr = new BufferedReader(new InputStreamReader(proc.getErrorStream(), "UTF-8")); 122 String line = null; -123 while (rdr.ready() && (line = rdr.readLine()) != null) { -124 LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.stderr", line); -125 } -126 int rc = 0; -127 doc = builder.parse(proc.getInputStream()); -128 -129 try { -130 rc = proc.waitFor(); -131 } catch (InterruptedException ie) { -132 return; -133 } -134 if (rc == 3) { -135 LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.notassembly", dependency.getActualFilePath()); -136 return; -137 } else if (rc != 0) { -138 LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.rc", rc); -139 } -140 -141 final XPath xpath = XPathFactory.newInstance().newXPath(); +123 // CheckStyle:VisibilityModifier OFF +124 while (rdr.ready() && (line = rdr.readLine()) != null) { +125 LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.stderr", line); +126 } +127 // CheckStyle:VisibilityModifier ON +128 int rc = 0; +129 doc = builder.parse(proc.getInputStream()); +130 +131 try { +132 rc = proc.waitFor(); +133 } catch (InterruptedException ie) { +134 return; +135 } +136 if (rc == 3) { +137 LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.notassembly", dependency.getActualFilePath()); +138 return; +139 } else if (rc != 0) { +140 LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.rc", rc); +141 } 142 -143 // First, see if there was an error -144 final String error = xpath.evaluate("/assembly/error", doc); -145 if (error != null && !"".equals(error)) { -146 throw new AnalysisException(error); -147 } -148 -149 final String version = xpath.evaluate("/assembly/version", doc); -150 if (version != null) { -151 dependency.getVersionEvidence().addEvidence(new Evidence("grokassembly", "version", -152 version, Confidence.HIGHEST)); -153 } -154 -155 final String vendor = xpath.evaluate("/assembly/company", doc); -156 if (vendor != null) { -157 dependency.getVendorEvidence().addEvidence(new Evidence("grokassembly", "vendor", -158 vendor, Confidence.HIGH)); -159 } -160 -161 final String product = xpath.evaluate("/assembly/product", doc); -162 if (product != null) { -163 dependency.getProductEvidence().addEvidence(new Evidence("grokassembly", "product", -164 product, Confidence.HIGH)); -165 } -166 -167 } catch (IOException ioe) { -168 throw new AnalysisException(ioe); -169 } catch (SAXException saxe) { -170 throw new AnalysisException("Couldn't parse GrokAssembly result", saxe); -171 } catch (XPathExpressionException xpe) { -172 // This shouldn't happen -173 throw new AnalysisException(xpe); -174 } finally { -175 if (rdr != null) { -176 try { -177 rdr.close(); -178 } catch (IOException ex) { -179 LOGGER.log(Level.FINEST, "ignore", ex); -180 } -181 } -182 } -183 } -184 -185 /** -186 * Initialize the analyzer. In this case, extract GrokAssembly.exe to a temporary location. -187 * -188 * @throws Exception if anything goes wrong -189 */ -190 @Override -191 public void initializeFileTypeAnalyzer() throws Exception { -192 final File tempFile = File.createTempFile("GKA", ".exe", Settings.getTempDirectory()); -193 FileOutputStream fos = null; -194 InputStream is = null; -195 try { -196 fos = new FileOutputStream(tempFile); -197 is = AssemblyAnalyzer.class.getClassLoader().getResourceAsStream("GrokAssembly.exe"); -198 final byte[] buff = new byte[4096]; -199 int bread = -1; -200 while ((bread = is.read(buff)) >= 0) { -201 fos.write(buff, 0, bread); -202 } -203 grokAssemblyExe = tempFile; -204 // Set the temp file to get deleted when we're done -205 grokAssemblyExe.deleteOnExit(); -206 LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.grokassembly.deployed", grokAssemblyExe.getPath()); -207 } catch (IOException ioe) { -208 this.setEnabled(false); -209 LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.notdeployed", ioe.getMessage()); -210 throw new AnalysisException("Could not extract GrokAssembly.exe", ioe); -211 } finally { -212 if (fos != null) { -213 try { -214 fos.close(); -215 } catch (Throwable e) { -216 LOGGER.fine("Error closing output stream"); -217 } -218 } -219 if (is != null) { -220 try { -221 is.close(); -222 } catch (Throwable e) { -223 LOGGER.fine("Error closing input stream"); -224 } -225 } -226 } -227 -228 // Now, need to see if GrokAssembly actually runs from this location. -229 final List<String> args = buildArgumentList(); -230 BufferedReader rdr = null; -231 try { -232 final ProcessBuilder pb = new ProcessBuilder(args); -233 final Process p = pb.start(); -234 // Try evacuating the error stream -235 rdr = new BufferedReader(new InputStreamReader(p.getErrorStream(), "UTF-8")); -236 while (rdr.ready() && rdr.readLine() != null) { -237 // We expect this to complain -238 } -239 final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(p.getInputStream()); -240 final XPath xpath = XPathFactory.newInstance().newXPath(); -241 final String error = xpath.evaluate("/assembly/error", doc); -242 if (p.waitFor() != 1 || error == null || "".equals(error)) { -243 LOGGER.warning("An error occurred with the .NET AssemblyAnalyzer, please see the log for more details."); -244 LOGGER.fine("GrokAssembly.exe is not working properly"); -245 grokAssemblyExe = null; -246 this.setEnabled(false); -247 throw new AnalysisException("Could not execute .NET AssemblyAnalyzer"); -248 } -249 } catch (Throwable e) { -250 if (e instanceof AnalysisException) { -251 throw (AnalysisException) e; -252 } else { -253 LOGGER.warning("analyzer.AssemblyAnalyzer.grokassembly.initialization.failed"); -254 LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.grokassembly.initialization.message", e.getMessage()); -255 this.setEnabled(false); -256 throw new AnalysisException("An error occured with the .NET AssemblyAnalyzer", e); -257 } -258 } finally { -259 if (rdr != null) { -260 try { -261 rdr.close(); -262 } catch (IOException ex) { -263 LOGGER.log(Level.FINEST, "ignore", ex); -264 } -265 } -266 } -267 builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); -268 } -269 -270 @Override -271 public void close() throws Exception { -272 super.close(); -273 try { -274 if (grokAssemblyExe != null && !grokAssemblyExe.delete()) { -275 grokAssemblyExe.deleteOnExit(); -276 } -277 } catch (SecurityException se) { -278 LOGGER.fine("analyzer.AssemblyAnalyzer.grokassembly.notdeleted"); -279 } -280 } -281 -282 /** -283 * Gets the set of extensions supported by this analyzer. -284 * -285 * @return the list of supported extensions -286 */ -287 @Override -288 public Set<String> getSupportedExtensions() { -289 return SUPPORTED_EXTENSIONS; -290 } -291 -292 /** -293 * Gets this analyzer's name. -294 * -295 * @return the analyzer name -296 */ -297 @Override -298 public String getName() { -299 return ANALYZER_NAME; -300 } -301 -302 /** -303 * Returns the phase this analyzer runs under. -304 * -305 * @return the phase this runs under -306 */ -307 @Override -308 public AnalysisPhase getAnalysisPhase() { -309 return ANALYSIS_PHASE; -310 } -311 -312 /** -313 * Returns the key used in the properties file to reference the analyzer's enabled property. -314 * -315 * @return the analyzer's enabled property setting key -316 */ -317 @Override -318 protected String getAnalyzerEnabledSettingKey() { -319 return Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED; -320 } -321 } +143 final XPath xpath = XPathFactory.newInstance().newXPath(); +144 +145 // First, see if there was an error +146 final String error = xpath.evaluate("/assembly/error", doc); +147 if (error != null && !"".equals(error)) { +148 throw new AnalysisException(error); +149 } +150 +151 final String version = xpath.evaluate("/assembly/version", doc); +152 if (version != null) { +153 dependency.getVersionEvidence().addEvidence(new Evidence("grokassembly", "version", +154 version, Confidence.HIGHEST)); +155 } +156 +157 final String vendor = xpath.evaluate("/assembly/company", doc); +158 if (vendor != null) { +159 dependency.getVendorEvidence().addEvidence(new Evidence("grokassembly", "vendor", +160 vendor, Confidence.HIGH)); +161 } +162 +163 final String product = xpath.evaluate("/assembly/product", doc); +164 if (product != null) { +165 dependency.getProductEvidence().addEvidence(new Evidence("grokassembly", "product", +166 product, Confidence.HIGH)); +167 } +168 +169 } catch (IOException ioe) { +170 throw new AnalysisException(ioe); +171 } catch (SAXException saxe) { +172 throw new AnalysisException("Couldn't parse GrokAssembly result", saxe); +173 } catch (XPathExpressionException xpe) { +174 // This shouldn't happen +175 throw new AnalysisException(xpe); +176 } finally { +177 if (rdr != null) { +178 try { +179 rdr.close(); +180 } catch (IOException ex) { +181 LOGGER.log(Level.FINEST, "ignore", ex); +182 } +183 } +184 } +185 } +186 +187 /** +188 * Initialize the analyzer. In this case, extract GrokAssembly.exe to a temporary location. +189 * +190 * @throws Exception if anything goes wrong +191 */ +192 @Override +193 public void initializeFileTypeAnalyzer() throws Exception { +194 final File tempFile = File.createTempFile("GKA", ".exe", Settings.getTempDirectory()); +195 FileOutputStream fos = null; +196 InputStream is = null; +197 try { +198 fos = new FileOutputStream(tempFile); +199 is = AssemblyAnalyzer.class.getClassLoader().getResourceAsStream("GrokAssembly.exe"); +200 final byte[] buff = new byte[4096]; +201 int bread = -1; +202 while ((bread = is.read(buff)) >= 0) { +203 fos.write(buff, 0, bread); +204 } +205 grokAssemblyExe = tempFile; +206 // Set the temp file to get deleted when we're done +207 grokAssemblyExe.deleteOnExit(); +208 LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.grokassembly.deployed", grokAssemblyExe.getPath()); +209 } catch (IOException ioe) { +210 this.setEnabled(false); +211 LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.notdeployed", ioe.getMessage()); +212 throw new AnalysisException("Could not extract GrokAssembly.exe", ioe); +213 } finally { +214 if (fos != null) { +215 try { +216 fos.close(); +217 } catch (Throwable e) { +218 LOGGER.fine("Error closing output stream"); +219 } +220 } +221 if (is != null) { +222 try { +223 is.close(); +224 } catch (Throwable e) { +225 LOGGER.fine("Error closing input stream"); +226 } +227 } +228 } +229 +230 // Now, need to see if GrokAssembly actually runs from this location. +231 final List<String> args = buildArgumentList(); +232 BufferedReader rdr = null; +233 try { +234 final ProcessBuilder pb = new ProcessBuilder(args); +235 final Process p = pb.start(); +236 // Try evacuating the error stream +237 rdr = new BufferedReader(new InputStreamReader(p.getErrorStream(), "UTF-8")); +238 // CheckStyle:VisibilityModifier OFF +239 while (rdr.ready() && rdr.readLine() != null) { +240 // We expect this to complain +241 } +242 // CheckStyle:VisibilityModifier ON +243 final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(p.getInputStream()); +244 final XPath xpath = XPathFactory.newInstance().newXPath(); +245 final String error = xpath.evaluate("/assembly/error", doc); +246 if (p.waitFor() != 1 || error == null || "".equals(error)) { +247 LOGGER.warning("An error occurred with the .NET AssemblyAnalyzer, please see the log for more details."); +248 LOGGER.fine("GrokAssembly.exe is not working properly"); +249 grokAssemblyExe = null; +250 this.setEnabled(false); +251 throw new AnalysisException("Could not execute .NET AssemblyAnalyzer"); +252 } +253 } catch (Throwable e) { +254 if (e instanceof AnalysisException) { +255 throw (AnalysisException) e; +256 } else { +257 LOGGER.warning("analyzer.AssemblyAnalyzer.grokassembly.initialization.failed"); +258 LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.grokassembly.initialization.message", e.getMessage()); +259 this.setEnabled(false); +260 throw new AnalysisException("An error occured with the .NET AssemblyAnalyzer", e); +261 } +262 } finally { +263 if (rdr != null) { +264 try { +265 rdr.close(); +266 } catch (IOException ex) { +267 LOGGER.log(Level.FINEST, "ignore", ex); +268 } +269 } +270 } +271 builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); +272 } +273 +274 @Override +275 public void close() throws Exception { +276 super.close(); +277 try { +278 if (grokAssemblyExe != null && !grokAssemblyExe.delete()) { +279 grokAssemblyExe.deleteOnExit(); +280 } +281 } catch (SecurityException se) { +282 LOGGER.fine("analyzer.AssemblyAnalyzer.grokassembly.notdeleted"); +283 } +284 } +285 +286 /** +287 * Gets the set of extensions supported by this analyzer. +288 * +289 * @return the list of supported extensions +290 */ +291 @Override +292 public Set<String> getSupportedExtensions() { +293 return SUPPORTED_EXTENSIONS; +294 } +295 +296 /** +297 * Gets this analyzer's name. +298 * +299 * @return the analyzer name +300 */ +301 @Override +302 public String getName() { +303 return ANALYZER_NAME; +304 } +305 +306 /** +307 * Returns the phase this analyzer runs under. +308 * +309 * @return the phase this runs under +310 */ +311 @Override +312 public AnalysisPhase getAnalysisPhase() { +313 return ANALYSIS_PHASE; +314 } +315 +316 /** +317 * Returns the key used in the properties file to reference the analyzer's enabled property. +318 * +319 * @return the analyzer's enabled property setting key +320 */ +321 @Override +322 protected String getAnalyzerEnabledSettingKey() { +323 return Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED; +324 } +325 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CPEAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CPEAnalyzer.html index fbb019367..f0dd53805 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CPEAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CPEAnalyzer.html @@ -196,576 +196,587 @@ 188 if (!vendors.isEmpty() && !products.isEmpty()) { 189 final List<IndexEntry> entries = searchCPE(vendors, products, dependency.getProductEvidence().getWeighting(), 190 dependency.getVendorEvidence().getWeighting()); -191 -192 boolean identifierAdded = false; -193 for (IndexEntry e : entries) { -194 if (verifyEntry(e, dependency)) { -195 final String vendor = e.getVendor(); -196 final String product = e.getProduct(); -197 identifierAdded |= determineIdentifiers(dependency, vendor, product, confidence); -198 } -199 } -200 if (identifierAdded) { -201 break; -202 } -203 } -204 } -205 } -206 -207 /** -208 * Returns the text created by concatenating the text and the values from the EvidenceCollection (filtered for a -209 * specific confidence). This attempts to prevent duplicate terms from being added.<br/<br/> Note, if the evidence -210 * is longer then 200 characters it will be truncated. -211 * -212 * @param text the base text. -213 * @param ec an EvidenceCollection -214 * @param confidenceFilter a Confidence level to filter the evidence by. -215 * @return the new evidence text -216 */ -217 private String addEvidenceWithoutDuplicateTerms(final String text, final EvidenceCollection ec, Confidence confidenceFilter) { -218 final String txt = (text == null) ? "" : text; -219 final StringBuilder sb = new StringBuilder(txt.length() + (20 * ec.size())); -220 sb.append(' ').append(txt).append(' '); -221 for (Evidence e : ec.iterator(confidenceFilter)) { -222 String value = e.getValue(); -223 -224 //hack to get around the fact that lucene does a really good job of recognizing domains and not -225 // splitting them. TODO - put together a better lucene analyzer specific to the domain. -226 if (value.startsWith("http://")) { -227 value = value.substring(7).replaceAll("\\.", " "); -228 } -229 if (value.startsWith("https://")) { -230 value = value.substring(8).replaceAll("\\.", " "); -231 } -232 if (sb.indexOf(" " + value + " ") < 0) { -233 sb.append(value).append(' '); -234 } -235 } -236 return sb.toString().trim(); -237 } -238 -239 /** -240 * <p> -241 * Searches the Lucene CPE index to identify possible CPE entries associated with the supplied vendor, product, and -242 * version.</p> -243 * -244 * <p> -245 * If either the vendorWeightings or productWeightings lists have been populated this data is used to add weighting -246 * factors to the search.</p> -247 * -248 * @param vendor the text used to search the vendor field -249 * @param product the text used to search the product field -250 * @param vendorWeightings a list of strings to use to add weighting factors to the vendor field -251 * @param productWeightings Adds a list of strings that will be used to add weighting factors to the product search -252 * @return a list of possible CPE values -253 * @throws CorruptIndexException when the Lucene index is corrupt -254 * @throws IOException when the Lucene index is not found -255 * @throws ParseException when the generated query is not valid -256 */ -257 protected List<IndexEntry> searchCPE(String vendor, String product, -258 Set<String> vendorWeightings, Set<String> productWeightings) -259 throws CorruptIndexException, IOException, ParseException { -260 final ArrayList<IndexEntry> ret = new ArrayList<IndexEntry>(MAX_QUERY_RESULTS); -261 -262 final String searchString = buildSearch(vendor, product, vendorWeightings, productWeightings); -263 if (searchString == null) { -264 return ret; -265 } -266 -267 final TopDocs docs = cpe.search(searchString, MAX_QUERY_RESULTS); -268 for (ScoreDoc d : docs.scoreDocs) { -269 if (d.score >= 0.08) { -270 final Document doc = cpe.getDocument(d.doc); -271 final IndexEntry entry = new IndexEntry(); -272 entry.setVendor(doc.get(Fields.VENDOR)); -273 entry.setProduct(doc.get(Fields.PRODUCT)); -274 // if (d.score < 0.08) { -275 // System.out.print(entry.getVendor()); -276 // System.out.print(":"); -277 // System.out.print(entry.getProduct()); -278 // System.out.print(":"); -279 // System.out.println(d.score); -280 // } -281 entry.setSearchScore(d.score); -282 if (!ret.contains(entry)) { -283 ret.add(entry); +191 if (entries == null) { +192 continue; +193 } +194 boolean identifierAdded = false; +195 for (IndexEntry e : entries) { +196 if (verifyEntry(e, dependency)) { +197 final String vendor = e.getVendor(); +198 final String product = e.getProduct(); +199 identifierAdded |= determineIdentifiers(dependency, vendor, product, confidence); +200 } +201 } +202 if (identifierAdded) { +203 break; +204 } +205 } +206 } +207 } +208 +209 /** +210 * Returns the text created by concatenating the text and the values from the EvidenceCollection (filtered for a +211 * specific confidence). This attempts to prevent duplicate terms from being added.<br/<br/> Note, if the evidence +212 * is longer then 200 characters it will be truncated. +213 * +214 * @param text the base text. +215 * @param ec an EvidenceCollection +216 * @param confidenceFilter a Confidence level to filter the evidence by. +217 * @return the new evidence text +218 */ +219 private String addEvidenceWithoutDuplicateTerms(final String text, final EvidenceCollection ec, Confidence confidenceFilter) { +220 final String txt = (text == null) ? "" : text; +221 final StringBuilder sb = new StringBuilder(txt.length() + (20 * ec.size())); +222 sb.append(' ').append(txt).append(' '); +223 for (Evidence e : ec.iterator(confidenceFilter)) { +224 String value = e.getValue(); +225 +226 //hack to get around the fact that lucene does a really good job of recognizing domains and not +227 // splitting them. TODO - put together a better lucene analyzer specific to the domain. +228 if (value.startsWith("http://")) { +229 value = value.substring(7).replaceAll("\\.", " "); +230 } +231 if (value.startsWith("https://")) { +232 value = value.substring(8).replaceAll("\\.", " "); +233 } +234 if (sb.indexOf(" " + value + " ") < 0) { +235 sb.append(value).append(' '); +236 } +237 } +238 return sb.toString().trim(); +239 } +240 +241 /** +242 * <p> +243 * Searches the Lucene CPE index to identify possible CPE entries associated with the supplied vendor, product, and +244 * version.</p> +245 * +246 * <p> +247 * If either the vendorWeightings or productWeightings lists have been populated this data is used to add weighting +248 * factors to the search.</p> +249 * +250 * @param vendor the text used to search the vendor field +251 * @param product the text used to search the product field +252 * @param vendorWeightings a list of strings to use to add weighting factors to the vendor field +253 * @param productWeightings Adds a list of strings that will be used to add weighting factors to the product search +254 * @return a list of possible CPE values +255 */ +256 protected List<IndexEntry> searchCPE(String vendor, String product, +257 Set<String> vendorWeightings, Set<String> productWeightings) { +258 +259 final ArrayList<IndexEntry> ret = new ArrayList<IndexEntry>(MAX_QUERY_RESULTS); +260 +261 final String searchString = buildSearch(vendor, product, vendorWeightings, productWeightings); +262 if (searchString == null) { +263 return ret; +264 } +265 try { +266 final TopDocs docs = cpe.search(searchString, MAX_QUERY_RESULTS); +267 for (ScoreDoc d : docs.scoreDocs) { +268 if (d.score >= 0.08) { +269 final Document doc = cpe.getDocument(d.doc); +270 final IndexEntry entry = new IndexEntry(); +271 entry.setVendor(doc.get(Fields.VENDOR)); +272 entry.setProduct(doc.get(Fields.PRODUCT)); +273 // if (d.score < 0.08) { +274 // System.out.print(entry.getVendor()); +275 // System.out.print(":"); +276 // System.out.print(entry.getProduct()); +277 // System.out.print(":"); +278 // System.out.println(d.score); +279 // } +280 entry.setSearchScore(d.score); +281 if (!ret.contains(entry)) { +282 ret.add(entry); +283 } 284 } 285 } -286 } -287 return ret; -288 } -289 -290 /** -291 * <p> -292 * Builds a Lucene search string by properly escaping data and constructing a valid search query.</p> -293 * -294 * <p> -295 * If either the possibleVendor or possibleProducts lists have been populated this data is used to add weighting -296 * factors to the search string generated.</p> -297 * -298 * @param vendor text to search the vendor field -299 * @param product text to search the product field -300 * @param vendorWeighting a list of strings to apply to the vendor to boost the terms weight -301 * @param productWeightings a list of strings to apply to the product to boost the terms weight -302 * @return the Lucene query -303 */ -304 protected String buildSearch(String vendor, String product, -305 Set<String> vendorWeighting, Set<String> productWeightings) { -306 final String v = vendor; //.replaceAll("[^\\w\\d]", " "); -307 final String p = product; //.replaceAll("[^\\w\\d]", " "); -308 final StringBuilder sb = new StringBuilder(v.length() + p.length() -309 + Fields.PRODUCT.length() + Fields.VENDOR.length() + STRING_BUILDER_BUFFER); -310 -311 if (!appendWeightedSearch(sb, Fields.PRODUCT, p, productWeightings)) { -312 return null; -313 } -314 sb.append(" AND "); -315 if (!appendWeightedSearch(sb, Fields.VENDOR, v, vendorWeighting)) { -316 return null; -317 } -318 return sb.toString(); -319 } -320 -321 /** -322 * This method constructs a Lucene query for a given field. The searchText is split into separate words and if the -323 * word is within the list of weighted words then an additional weighting is applied to the term as it is appended -324 * into the query. -325 * -326 * @param sb a StringBuilder that the query text will be appended to. -327 * @param field the field within the Lucene index that the query is searching. -328 * @param searchText text used to construct the query. -329 * @param weightedText a list of terms that will be considered higher importance when searching. -330 * @return if the append was successful. -331 */ -332 private boolean appendWeightedSearch(StringBuilder sb, String field, String searchText, Set<String> weightedText) { -333 sb.append(" ").append(field).append(":( "); -334 -335 final String cleanText = cleanseText(searchText); -336 -337 if ("".equals(cleanText)) { -338 return false; -339 } -340 -341 if (weightedText == null || weightedText.isEmpty()) { -342 LuceneUtils.appendEscapedLuceneQuery(sb, cleanText); -343 } else { -344 final StringTokenizer tokens = new StringTokenizer(cleanText); -345 while (tokens.hasMoreElements()) { -346 final String word = tokens.nextToken(); -347 String temp = null; -348 for (String weighted : weightedText) { -349 final String weightedStr = cleanseText(weighted); -350 if (equalsIgnoreCaseAndNonAlpha(word, weightedStr)) { -351 temp = LuceneUtils.escapeLuceneQuery(word) + WEIGHTING_BOOST; -352 if (!word.equalsIgnoreCase(weightedStr)) { -353 temp += " " + LuceneUtils.escapeLuceneQuery(weightedStr) + WEIGHTING_BOOST; -354 } -355 } -356 } -357 if (temp == null) { -358 temp = LuceneUtils.escapeLuceneQuery(word); -359 } -360 sb.append(" ").append(temp); -361 } -362 } -363 sb.append(" ) "); -364 return true; -365 } -366 -367 /** -368 * Removes characters from the input text that are not used within the CPE index. -369 * -370 * @param text is the text to remove the characters from. -371 * @return the text having removed some characters. -372 */ -373 private String cleanseText(String text) { -374 return text.replaceAll(CLEANSE_CHARACTER_RX, " "); -375 } -376 -377 /** -378 * Compares two strings after lower casing them and removing the non-alpha characters. -379 * -380 * @param l string one to compare. -381 * @param r string two to compare. -382 * @return whether or not the two strings are similar. -383 */ -384 private boolean equalsIgnoreCaseAndNonAlpha(String l, String r) { -385 if (l == null || r == null) { -386 return false; -387 } -388 -389 final String left = l.replaceAll(CLEANSE_NONALPHA_RX, ""); -390 final String right = r.replaceAll(CLEANSE_NONALPHA_RX, ""); -391 return left.equalsIgnoreCase(right); -392 } -393 -394 /** -395 * Ensures that the CPE Identified matches the dependency. This validates that the product, vendor, and version -396 * information for the CPE are contained within the dependencies evidence. -397 * -398 * @param entry a CPE entry. -399 * @param dependency the dependency that the CPE entries could be for. -400 * @return whether or not the entry is valid. -401 */ -402 private boolean verifyEntry(final IndexEntry entry, final Dependency dependency) { -403 boolean isValid = false; -404 -405 if (collectionContainsString(dependency.getProductEvidence(), entry.getProduct()) -406 && collectionContainsString(dependency.getVendorEvidence(), entry.getVendor())) { -407 //&& collectionContainsVersion(dependency.getVersionEvidence(), entry.getVersion()) -408 isValid = true; -409 } -410 return isValid; -411 } -412 -413 /** -414 * Used to determine if the EvidenceCollection contains a specific string. -415 * -416 * @param ec an EvidenceCollection -417 * @param text the text to search for -418 * @return whether or not the EvidenceCollection contains the string -419 */ -420 private boolean collectionContainsString(EvidenceCollection ec, String text) { +286 return ret; +287 } catch (ParseException ex) { +288 final String msg = String.format("Unable to parse: %s", searchString); +289 LOGGER.log(Level.WARNING, "An error occured querying the CPE data. See the log for more details."); +290 LOGGER.log(Level.INFO, msg, ex); +291 } catch (IOException ex) { +292 final String msg = String.format("IO Error with search string: %s", searchString); +293 LOGGER.log(Level.WARNING, "An error occured reading CPE data. See the log for more details."); +294 LOGGER.log(Level.INFO, msg, ex); +295 } +296 return null; +297 } +298 +299 /** +300 * <p> +301 * Builds a Lucene search string by properly escaping data and constructing a valid search query.</p> +302 * +303 * <p> +304 * If either the possibleVendor or possibleProducts lists have been populated this data is used to add weighting +305 * factors to the search string generated.</p> +306 * +307 * @param vendor text to search the vendor field +308 * @param product text to search the product field +309 * @param vendorWeighting a list of strings to apply to the vendor to boost the terms weight +310 * @param productWeightings a list of strings to apply to the product to boost the terms weight +311 * @return the Lucene query +312 */ +313 protected String buildSearch(String vendor, String product, +314 Set<String> vendorWeighting, Set<String> productWeightings) { +315 final String v = vendor; //.replaceAll("[^\\w\\d]", " "); +316 final String p = product; //.replaceAll("[^\\w\\d]", " "); +317 final StringBuilder sb = new StringBuilder(v.length() + p.length() +318 + Fields.PRODUCT.length() + Fields.VENDOR.length() + STRING_BUILDER_BUFFER); +319 +320 if (!appendWeightedSearch(sb, Fields.PRODUCT, p, productWeightings)) { +321 return null; +322 } +323 sb.append(" AND "); +324 if (!appendWeightedSearch(sb, Fields.VENDOR, v, vendorWeighting)) { +325 return null; +326 } +327 return sb.toString(); +328 } +329 +330 /** +331 * This method constructs a Lucene query for a given field. The searchText is split into separate words and if the +332 * word is within the list of weighted words then an additional weighting is applied to the term as it is appended +333 * into the query. +334 * +335 * @param sb a StringBuilder that the query text will be appended to. +336 * @param field the field within the Lucene index that the query is searching. +337 * @param searchText text used to construct the query. +338 * @param weightedText a list of terms that will be considered higher importance when searching. +339 * @return if the append was successful. +340 */ +341 private boolean appendWeightedSearch(StringBuilder sb, String field, String searchText, Set<String> weightedText) { +342 sb.append(" ").append(field).append(":( "); +343 +344 final String cleanText = cleanseText(searchText); +345 +346 if ("".equals(cleanText)) { +347 return false; +348 } +349 +350 if (weightedText == null || weightedText.isEmpty()) { +351 LuceneUtils.appendEscapedLuceneQuery(sb, cleanText); +352 } else { +353 final StringTokenizer tokens = new StringTokenizer(cleanText); +354 while (tokens.hasMoreElements()) { +355 final String word = tokens.nextToken(); +356 String temp = null; +357 for (String weighted : weightedText) { +358 final String weightedStr = cleanseText(weighted); +359 if (equalsIgnoreCaseAndNonAlpha(word, weightedStr)) { +360 temp = LuceneUtils.escapeLuceneQuery(word) + WEIGHTING_BOOST; +361 if (!word.equalsIgnoreCase(weightedStr)) { +362 temp += " " + LuceneUtils.escapeLuceneQuery(weightedStr) + WEIGHTING_BOOST; +363 } +364 } +365 } +366 if (temp == null) { +367 temp = LuceneUtils.escapeLuceneQuery(word); +368 } +369 sb.append(" ").append(temp); +370 } +371 } +372 sb.append(" ) "); +373 return true; +374 } +375 +376 /** +377 * Removes characters from the input text that are not used within the CPE index. +378 * +379 * @param text is the text to remove the characters from. +380 * @return the text having removed some characters. +381 */ +382 private String cleanseText(String text) { +383 return text.replaceAll(CLEANSE_CHARACTER_RX, " "); +384 } +385 +386 /** +387 * Compares two strings after lower casing them and removing the non-alpha characters. +388 * +389 * @param l string one to compare. +390 * @param r string two to compare. +391 * @return whether or not the two strings are similar. +392 */ +393 private boolean equalsIgnoreCaseAndNonAlpha(String l, String r) { +394 if (l == null || r == null) { +395 return false; +396 } +397 +398 final String left = l.replaceAll(CLEANSE_NONALPHA_RX, ""); +399 final String right = r.replaceAll(CLEANSE_NONALPHA_RX, ""); +400 return left.equalsIgnoreCase(right); +401 } +402 +403 /** +404 * Ensures that the CPE Identified matches the dependency. This validates that the product, vendor, and version +405 * information for the CPE are contained within the dependencies evidence. +406 * +407 * @param entry a CPE entry. +408 * @param dependency the dependency that the CPE entries could be for. +409 * @return whether or not the entry is valid. +410 */ +411 private boolean verifyEntry(final IndexEntry entry, final Dependency dependency) { +412 boolean isValid = false; +413 +414 if (collectionContainsString(dependency.getProductEvidence(), entry.getProduct()) +415 && collectionContainsString(dependency.getVendorEvidence(), entry.getVendor())) { +416 //&& collectionContainsVersion(dependency.getVersionEvidence(), entry.getVersion()) +417 isValid = true; +418 } +419 return isValid; +420 } 421 -422 //<editor-fold defaultstate="collapsed" desc="This code fold contains an old version of the code, delete once more testing is done"> -423 // String[] splitText = text.split("[\\s_-]"); -424 // -425 // for (String search : splitText) { -426 // //final String search = text.replaceAll("[\\s_-]", "").toLowerCase(); -427 // if (ec.containsUsedString(search)) { -428 // return true; -429 // } -430 // } -431 //</editor-fold> -432 //TODO - likely need to change the split... not sure if this will work for CPE with special chars -433 if (text == null) { -434 return false; -435 } -436 final String[] words = text.split("[\\s_-]"); -437 final List<String> list = new ArrayList<String>(); -438 String tempWord = null; -439 for (String word : words) { -440 /* -441 single letter words should be concatenated with the next word. -442 so { "m", "core", "sample" } -> { "mcore", "sample" } -443 */ -444 if (tempWord != null) { -445 list.add(tempWord + word); -446 tempWord = null; -447 } else if (word.length() <= 2) { -448 tempWord = word; -449 } else { -450 list.add(word); -451 } -452 } -453 if (tempWord != null && !list.isEmpty()) { -454 final String tmp = list.get(list.size() - 1) + tempWord; -455 list.add(tmp); -456 } -457 boolean contains = true; -458 for (String word : list) { -459 contains &= ec.containsUsedString(word); -460 } -461 return contains; -462 } -463 -464 /** -465 * Analyzes a dependency and attempts to determine if there are any CPE identifiers for this dependency. -466 * -467 * @param dependency The Dependency to analyze. -468 * @param engine The analysis engine -469 * @throws AnalysisException is thrown if there is an issue analyzing the dependency. -470 */ -471 @Override -472 public void analyze(Dependency dependency, Engine engine) throws AnalysisException { -473 try { -474 determineCPE(dependency); -475 } catch (CorruptIndexException ex) { -476 throw new AnalysisException("CPE Index is corrupt.", ex); -477 } catch (IOException ex) { -478 throw new AnalysisException("Failure opening the CPE Index.", ex); -479 } catch (ParseException ex) { -480 throw new AnalysisException("Unable to parse the generated Lucene query for this dependency.", ex); -481 } -482 } -483 -484 /** -485 * Retrieves a list of CPE values from the CveDB based on the vendor and product passed in. The list is then -486 * validated to find only CPEs that are valid for the given dependency. It is possible that the CPE identified is a -487 * best effort "guess" based on the vendor, product, and version information. -488 * -489 * @param dependency the Dependency being analyzed -490 * @param vendor the vendor for the CPE being analyzed -491 * @param product the product for the CPE being analyzed -492 * @return <code>true</code> if an identifier was added to the dependency; otherwise <code>false</code> -493 * @throws UnsupportedEncodingException is thrown if UTF-8 is not supported -494 */ -495 private boolean determineIdentifiers(Dependency dependency, String vendor, String product, Confidence currentConfidence) throws UnsupportedEncodingException { -496 final Set<VulnerableSoftware> cpes = cve.getCPEs(vendor, product); -497 DependencyVersion bestGuess = new DependencyVersion("-"); -498 Confidence bestGuessConf = null; -499 boolean hasBroadMatch = false; -500 final List<IdentifierMatch> collected = new ArrayList<IdentifierMatch>(); -501 for (Confidence conf : Confidence.values()) { -502 // if (conf.compareTo(currentConfidence) > 0) { -503 // break; -504 // } -505 for (Evidence evidence : dependency.getVersionEvidence().iterator(conf)) { -506 final DependencyVersion evVer = DependencyVersionUtil.parseVersion(evidence.getValue()); -507 if (evVer == null) { -508 continue; -509 } -510 for (VulnerableSoftware vs : cpes) { -511 DependencyVersion dbVer; -512 if (vs.getRevision() != null && !vs.getRevision().isEmpty()) { -513 dbVer = DependencyVersionUtil.parseVersion(vs.getVersion() + "." + vs.getRevision()); -514 } else { -515 dbVer = DependencyVersionUtil.parseVersion(vs.getVersion()); -516 } -517 if (dbVer == null) { //special case, no version specified - everything is vulnerable -518 hasBroadMatch = true; -519 final String url = String.format(NVD_SEARCH_URL, URLEncoder.encode(vs.getName(), "UTF-8")); -520 final IdentifierMatch match = new IdentifierMatch("cpe", vs.getName(), url, IdentifierConfidence.BROAD_MATCH, conf); -521 collected.add(match); -522 } else if (evVer.equals(dbVer)) { //yeah! exact match -523 final String url = String.format(NVD_SEARCH_URL, URLEncoder.encode(vs.getName(), "UTF-8")); -524 final IdentifierMatch match = new IdentifierMatch("cpe", vs.getName(), url, IdentifierConfidence.EXACT_MATCH, conf); -525 collected.add(match); -526 } else { -527 //TODO the following isn't quite right is it? need to think about this guessing game a bit more. -528 if (evVer.getVersionParts().size() <= dbVer.getVersionParts().size() -529 && evVer.matchesAtLeastThreeLevels(dbVer)) { -530 if (bestGuessConf == null || bestGuessConf.compareTo(conf) > 0) { -531 if (bestGuess.getVersionParts().size() < dbVer.getVersionParts().size()) { -532 bestGuess = dbVer; -533 bestGuessConf = conf; -534 } -535 } -536 } -537 } -538 } -539 if (bestGuessConf == null || bestGuessConf.compareTo(conf) > 0) { -540 if (bestGuess.getVersionParts().size() < evVer.getVersionParts().size()) { -541 bestGuess = evVer; -542 bestGuessConf = conf; -543 } -544 } -545 } -546 } -547 final String cpeName = String.format("cpe:/a:%s:%s:%s", vendor, product, bestGuess.toString()); -548 String url = null; -549 if (hasBroadMatch) { //if we have a broad match we can add the URL to the best guess. -550 final String cpeUrlName = String.format("cpe:/a:%s:%s", vendor, product); -551 url = String.format(NVD_SEARCH_URL, URLEncoder.encode(cpeUrlName, "UTF-8")); -552 } -553 if (bestGuessConf == null) { -554 bestGuessConf = Confidence.LOW; -555 } -556 final IdentifierMatch match = new IdentifierMatch("cpe", cpeName, url, IdentifierConfidence.BEST_GUESS, bestGuessConf); -557 collected.add(match); -558 -559 Collections.sort(collected); -560 final IdentifierConfidence bestIdentifierQuality = collected.get(0).getConfidence(); -561 final Confidence bestEvidenceQuality = collected.get(0).getEvidenceConfidence(); -562 boolean identifierAdded = false; -563 for (IdentifierMatch m : collected) { -564 if (bestIdentifierQuality.equals(m.getConfidence()) -565 && bestEvidenceQuality.equals(m.getEvidenceConfidence())) { -566 final Identifier i = m.getIdentifier(); -567 if (bestIdentifierQuality == IdentifierConfidence.BEST_GUESS) { -568 i.setConfidence(Confidence.LOW); -569 } else { -570 i.setConfidence(bestEvidenceQuality); -571 } -572 dependency.addIdentifier(i); -573 identifierAdded = true; -574 } -575 } -576 return identifierAdded; -577 } -578 -579 /** -580 * The confidence whether the identifier is an exact match, or a best guess. -581 */ -582 private enum IdentifierConfidence { -583 -584 /** -585 * An exact match for the CPE. -586 */ -587 EXACT_MATCH, -588 /** -589 * A best guess for the CPE. -590 */ -591 BEST_GUESS, -592 /** -593 * The entire vendor/product group must be added (without a guess at version) because there is a CVE with a VS -594 * that only specifies vendor/product. -595 */ -596 BROAD_MATCH -597 } -598 -599 /** -600 * A simple object to hold an identifier and carry information about the confidence in the identifier. -601 */ -602 private static class IdentifierMatch implements Comparable<IdentifierMatch> { -603 -604 /** -605 * Constructs an IdentifierMatch. -606 * -607 * @param type the type of identifier (such as CPE) -608 * @param value the value of the identifier -609 * @param url the URL of the identifier -610 * @param identifierConfidence the confidence in the identifier: best guess or exact match -611 * @param evidenceConfidence the confidence of the evidence used to find the identifier -612 */ -613 IdentifierMatch(String type, String value, String url, IdentifierConfidence identifierConfidence, Confidence evidenceConfidence) { -614 this.identifier = new Identifier(type, value, url); -615 this.confidence = identifierConfidence; -616 this.evidenceConfidence = evidenceConfidence; -617 } -618 //<editor-fold defaultstate="collapsed" desc="Property implementations: evidenceConfidence, confidence, identifier"> -619 /** -620 * The confidence in the evidence used to identify this match. -621 */ -622 private Confidence evidenceConfidence; -623 -624 /** -625 * Get the value of evidenceConfidence -626 * -627 * @return the value of evidenceConfidence -628 */ -629 public Confidence getEvidenceConfidence() { -630 return evidenceConfidence; -631 } -632 -633 /** -634 * Set the value of evidenceConfidence -635 * -636 * @param evidenceConfidence new value of evidenceConfidence -637 */ -638 public void setEvidenceConfidence(Confidence evidenceConfidence) { -639 this.evidenceConfidence = evidenceConfidence; -640 } -641 /** -642 * The confidence whether this is an exact match, or a best guess. -643 */ -644 private IdentifierConfidence confidence; -645 -646 /** -647 * Get the value of confidence. -648 * -649 * @return the value of confidence -650 */ -651 public IdentifierConfidence getConfidence() { -652 return confidence; -653 } -654 -655 /** -656 * Set the value of confidence. -657 * -658 * @param confidence new value of confidence -659 */ -660 public void setConfidence(IdentifierConfidence confidence) { -661 this.confidence = confidence; -662 } -663 /** -664 * The CPE identifier. -665 */ -666 private Identifier identifier; -667 -668 /** -669 * Get the value of identifier. -670 * -671 * @return the value of identifier -672 */ -673 public Identifier getIdentifier() { -674 return identifier; -675 } -676 -677 /** -678 * Set the value of identifier. -679 * -680 * @param identifier new value of identifier -681 */ -682 public void setIdentifier(Identifier identifier) { -683 this.identifier = identifier; -684 } -685 //</editor-fold> -686 //<editor-fold defaultstate="collapsed" desc="Standard implementations of toString, hashCode, and equals"> +422 /** +423 * Used to determine if the EvidenceCollection contains a specific string. +424 * +425 * @param ec an EvidenceCollection +426 * @param text the text to search for +427 * @return whether or not the EvidenceCollection contains the string +428 */ +429 private boolean collectionContainsString(EvidenceCollection ec, String text) { +430 +431 //<editor-fold defaultstate="collapsed" desc="This code fold contains an old version of the code, delete once more testing is done"> +432 // String[] splitText = text.split("[\\s_-]"); +433 // +434 // for (String search : splitText) { +435 // //final String search = text.replaceAll("[\\s_-]", "").toLowerCase(); +436 // if (ec.containsUsedString(search)) { +437 // return true; +438 // } +439 // } +440 //</editor-fold> +441 //TODO - likely need to change the split... not sure if this will work for CPE with special chars +442 if (text == null) { +443 return false; +444 } +445 final String[] words = text.split("[\\s_-]"); +446 final List<String> list = new ArrayList<String>(); +447 String tempWord = null; +448 for (String word : words) { +449 /* +450 single letter words should be concatenated with the next word. +451 so { "m", "core", "sample" } -> { "mcore", "sample" } +452 */ +453 if (tempWord != null) { +454 list.add(tempWord + word); +455 tempWord = null; +456 } else if (word.length() <= 2) { +457 tempWord = word; +458 } else { +459 list.add(word); +460 } +461 } +462 if (tempWord != null && !list.isEmpty()) { +463 final String tmp = list.get(list.size() - 1) + tempWord; +464 list.add(tmp); +465 } +466 boolean contains = true; +467 for (String word : list) { +468 contains &= ec.containsUsedString(word); +469 } +470 return contains; +471 } +472 +473 /** +474 * Analyzes a dependency and attempts to determine if there are any CPE identifiers for this dependency. +475 * +476 * @param dependency The Dependency to analyze. +477 * @param engine The analysis engine +478 * @throws AnalysisException is thrown if there is an issue analyzing the dependency. +479 */ +480 @Override +481 public void analyze(Dependency dependency, Engine engine) throws AnalysisException { +482 try { +483 determineCPE(dependency); +484 } catch (CorruptIndexException ex) { +485 throw new AnalysisException("CPE Index is corrupt.", ex); +486 } catch (IOException ex) { +487 throw new AnalysisException("Failure opening the CPE Index.", ex); +488 } catch (ParseException ex) { +489 throw new AnalysisException("Unable to parse the generated Lucene query for this dependency.", ex); +490 } +491 } +492 +493 /** +494 * Retrieves a list of CPE values from the CveDB based on the vendor and product passed in. The list is then +495 * validated to find only CPEs that are valid for the given dependency. It is possible that the CPE identified is a +496 * best effort "guess" based on the vendor, product, and version information. +497 * +498 * @param dependency the Dependency being analyzed +499 * @param vendor the vendor for the CPE being analyzed +500 * @param product the product for the CPE being analyzed +501 * @param currentConfidence the current confidence being used during analysis +502 * @return <code>true</code> if an identifier was added to the dependency; otherwise <code>false</code> +503 * @throws UnsupportedEncodingException is thrown if UTF-8 is not supported +504 */ +505 protected boolean determineIdentifiers(Dependency dependency, String vendor, String product, +506 Confidence currentConfidence) throws UnsupportedEncodingException { +507 final Set<VulnerableSoftware> cpes = cve.getCPEs(vendor, product); +508 DependencyVersion bestGuess = new DependencyVersion("-"); +509 Confidence bestGuessConf = null; +510 boolean hasBroadMatch = false; +511 final List<IdentifierMatch> collected = new ArrayList<IdentifierMatch>(); +512 for (Confidence conf : Confidence.values()) { +513 // if (conf.compareTo(currentConfidence) > 0) { +514 // break; +515 // } +516 for (Evidence evidence : dependency.getVersionEvidence().iterator(conf)) { +517 final DependencyVersion evVer = DependencyVersionUtil.parseVersion(evidence.getValue()); +518 if (evVer == null) { +519 continue; +520 } +521 for (VulnerableSoftware vs : cpes) { +522 DependencyVersion dbVer; +523 if (vs.getRevision() != null && !vs.getRevision().isEmpty()) { +524 dbVer = DependencyVersionUtil.parseVersion(vs.getVersion() + "." + vs.getRevision()); +525 } else { +526 dbVer = DependencyVersionUtil.parseVersion(vs.getVersion()); +527 } +528 if (dbVer == null) { //special case, no version specified - everything is vulnerable +529 hasBroadMatch = true; +530 final String url = String.format(NVD_SEARCH_URL, URLEncoder.encode(vs.getName(), "UTF-8")); +531 final IdentifierMatch match = new IdentifierMatch("cpe", vs.getName(), url, IdentifierConfidence.BROAD_MATCH, conf); +532 collected.add(match); +533 } else if (evVer.equals(dbVer)) { //yeah! exact match +534 final String url = String.format(NVD_SEARCH_URL, URLEncoder.encode(vs.getName(), "UTF-8")); +535 final IdentifierMatch match = new IdentifierMatch("cpe", vs.getName(), url, IdentifierConfidence.EXACT_MATCH, conf); +536 collected.add(match); +537 } else { +538 //TODO the following isn't quite right is it? need to think about this guessing game a bit more. +539 if (evVer.getVersionParts().size() <= dbVer.getVersionParts().size() +540 && evVer.matchesAtLeastThreeLevels(dbVer)) { +541 if (bestGuessConf == null || bestGuessConf.compareTo(conf) > 0) { +542 if (bestGuess.getVersionParts().size() < dbVer.getVersionParts().size()) { +543 bestGuess = dbVer; +544 bestGuessConf = conf; +545 } +546 } +547 } +548 } +549 } +550 if (bestGuessConf == null || bestGuessConf.compareTo(conf) > 0) { +551 if (bestGuess.getVersionParts().size() < evVer.getVersionParts().size()) { +552 bestGuess = evVer; +553 bestGuessConf = conf; +554 } +555 } +556 } +557 } +558 final String cpeName = String.format("cpe:/a:%s:%s:%s", vendor, product, bestGuess.toString()); +559 String url = null; +560 if (hasBroadMatch) { //if we have a broad match we can add the URL to the best guess. +561 final String cpeUrlName = String.format("cpe:/a:%s:%s", vendor, product); +562 url = String.format(NVD_SEARCH_URL, URLEncoder.encode(cpeUrlName, "UTF-8")); +563 } +564 if (bestGuessConf == null) { +565 bestGuessConf = Confidence.LOW; +566 } +567 final IdentifierMatch match = new IdentifierMatch("cpe", cpeName, url, IdentifierConfidence.BEST_GUESS, bestGuessConf); +568 collected.add(match); +569 +570 Collections.sort(collected); +571 final IdentifierConfidence bestIdentifierQuality = collected.get(0).getConfidence(); +572 final Confidence bestEvidenceQuality = collected.get(0).getEvidenceConfidence(); +573 boolean identifierAdded = false; +574 for (IdentifierMatch m : collected) { +575 if (bestIdentifierQuality.equals(m.getConfidence()) +576 && bestEvidenceQuality.equals(m.getEvidenceConfidence())) { +577 final Identifier i = m.getIdentifier(); +578 if (bestIdentifierQuality == IdentifierConfidence.BEST_GUESS) { +579 i.setConfidence(Confidence.LOW); +580 } else { +581 i.setConfidence(bestEvidenceQuality); +582 } +583 dependency.addIdentifier(i); +584 identifierAdded = true; +585 } +586 } +587 return identifierAdded; +588 } +589 +590 /** +591 * The confidence whether the identifier is an exact match, or a best guess. +592 */ +593 private enum IdentifierConfidence { +594 +595 /** +596 * An exact match for the CPE. +597 */ +598 EXACT_MATCH, +599 /** +600 * A best guess for the CPE. +601 */ +602 BEST_GUESS, +603 /** +604 * The entire vendor/product group must be added (without a guess at version) because there is a CVE with a VS +605 * that only specifies vendor/product. +606 */ +607 BROAD_MATCH +608 } +609 +610 /** +611 * A simple object to hold an identifier and carry information about the confidence in the identifier. +612 */ +613 private static class IdentifierMatch implements Comparable<IdentifierMatch> { +614 +615 /** +616 * Constructs an IdentifierMatch. +617 * +618 * @param type the type of identifier (such as CPE) +619 * @param value the value of the identifier +620 * @param url the URL of the identifier +621 * @param identifierConfidence the confidence in the identifier: best guess or exact match +622 * @param evidenceConfidence the confidence of the evidence used to find the identifier +623 */ +624 IdentifierMatch(String type, String value, String url, IdentifierConfidence identifierConfidence, Confidence evidenceConfidence) { +625 this.identifier = new Identifier(type, value, url); +626 this.confidence = identifierConfidence; +627 this.evidenceConfidence = evidenceConfidence; +628 } +629 //<editor-fold defaultstate="collapsed" desc="Property implementations: evidenceConfidence, confidence, identifier"> +630 /** +631 * The confidence in the evidence used to identify this match. +632 */ +633 private Confidence evidenceConfidence; +634 +635 /** +636 * Get the value of evidenceConfidence +637 * +638 * @return the value of evidenceConfidence +639 */ +640 public Confidence getEvidenceConfidence() { +641 return evidenceConfidence; +642 } +643 +644 /** +645 * Set the value of evidenceConfidence +646 * +647 * @param evidenceConfidence new value of evidenceConfidence +648 */ +649 public void setEvidenceConfidence(Confidence evidenceConfidence) { +650 this.evidenceConfidence = evidenceConfidence; +651 } +652 /** +653 * The confidence whether this is an exact match, or a best guess. +654 */ +655 private IdentifierConfidence confidence; +656 +657 /** +658 * Get the value of confidence. +659 * +660 * @return the value of confidence +661 */ +662 public IdentifierConfidence getConfidence() { +663 return confidence; +664 } +665 +666 /** +667 * Set the value of confidence. +668 * +669 * @param confidence new value of confidence +670 */ +671 public void setConfidence(IdentifierConfidence confidence) { +672 this.confidence = confidence; +673 } +674 /** +675 * The CPE identifier. +676 */ +677 private Identifier identifier; +678 +679 /** +680 * Get the value of identifier. +681 * +682 * @return the value of identifier +683 */ +684 public Identifier getIdentifier() { +685 return identifier; +686 } 687 688 /** -689 * Standard toString() implementation. +689 * Set the value of identifier. 690 * -691 * @return the string representation of the object +691 * @param identifier new value of identifier 692 */ -693 @Override -694 public String toString() { -695 return "IdentifierMatch{" + "evidenceConfidence=" + evidenceConfidence -696 + ", confidence=" + confidence + ", identifier=" + identifier + '}'; -697 } +693 public void setIdentifier(Identifier identifier) { +694 this.identifier = identifier; +695 } +696 //</editor-fold> +697 //<editor-fold defaultstate="collapsed" desc="Standard implementations of toString, hashCode, and equals"> 698 699 /** -700 * Standard hashCode() implementation. +700 * Standard toString() implementation. 701 * -702 * @return the hashCode +702 * @return the string representation of the object 703 */ 704 @Override -705 public int hashCode() { -706 int hash = 5; -707 hash = 97 * hash + (this.evidenceConfidence != null ? this.evidenceConfidence.hashCode() : 0); -708 hash = 97 * hash + (this.confidence != null ? this.confidence.hashCode() : 0); -709 hash = 97 * hash + (this.identifier != null ? this.identifier.hashCode() : 0); -710 return hash; -711 } -712 -713 /** -714 * Standard equals implementation. -715 * -716 * @param obj the object to compare -717 * @return true if the objects are equal, otherwise false -718 */ -719 @Override -720 public boolean equals(Object obj) { -721 if (obj == null) { -722 return false; -723 } -724 if (getClass() != obj.getClass()) { -725 return false; -726 } -727 final IdentifierMatch other = (IdentifierMatch) obj; -728 if (this.evidenceConfidence != other.evidenceConfidence) { -729 return false; -730 } -731 if (this.confidence != other.confidence) { -732 return false; -733 } -734 if (this.identifier != other.identifier && (this.identifier == null || !this.identifier.equals(other.identifier))) { -735 return false; -736 } -737 return true; -738 } -739 //</editor-fold> -740 -741 /** -742 * Standard implementation of compareTo that compares identifier confidence, evidence confidence, and then the -743 * identifier. -744 * -745 * @param o the IdentifierMatch to compare to -746 * @return the natural ordering of IdentifierMatch -747 */ -748 @Override -749 public int compareTo(IdentifierMatch o) { -750 int conf = this.confidence.compareTo(o.confidence); -751 if (conf == 0) { -752 conf = this.evidenceConfidence.compareTo(o.evidenceConfidence); -753 if (conf == 0) { -754 conf = identifier.compareTo(o.identifier); -755 } -756 } -757 return conf; -758 } -759 } -760 } +705 public String toString() { +706 return "IdentifierMatch{" + "evidenceConfidence=" + evidenceConfidence +707 + ", confidence=" + confidence + ", identifier=" + identifier + '}'; +708 } +709 +710 /** +711 * Standard hashCode() implementation. +712 * +713 * @return the hashCode +714 */ +715 @Override +716 public int hashCode() { +717 int hash = 5; +718 hash = 97 * hash + (this.evidenceConfidence != null ? this.evidenceConfidence.hashCode() : 0); +719 hash = 97 * hash + (this.confidence != null ? this.confidence.hashCode() : 0); +720 hash = 97 * hash + (this.identifier != null ? this.identifier.hashCode() : 0); +721 return hash; +722 } +723 +724 /** +725 * Standard equals implementation. +726 * +727 * @param obj the object to compare +728 * @return true if the objects are equal, otherwise false +729 */ +730 @Override +731 public boolean equals(Object obj) { +732 if (obj == null) { +733 return false; +734 } +735 if (getClass() != obj.getClass()) { +736 return false; +737 } +738 final IdentifierMatch other = (IdentifierMatch) obj; +739 if (this.evidenceConfidence != other.evidenceConfidence) { +740 return false; +741 } +742 if (this.confidence != other.confidence) { +743 return false; +744 } +745 if (this.identifier != other.identifier && (this.identifier == null || !this.identifier.equals(other.identifier))) { +746 return false; +747 } +748 return true; +749 } +750 //</editor-fold> +751 +752 /** +753 * Standard implementation of compareTo that compares identifier confidence, evidence confidence, and then the +754 * identifier. +755 * +756 * @param o the IdentifierMatch to compare to +757 * @return the natural ordering of IdentifierMatch +758 */ +759 @Override +760 public int compareTo(IdentifierMatch o) { +761 int conf = this.confidence.compareTo(o.confidence); +762 if (conf == 0) { +763 conf = this.evidenceConfidence.compareTo(o.evidenceConfidence); +764 if (conf == 0) { +765 conf = identifier.compareTo(o.identifier); +766 } +767 } +768 return conf; +769 } +770 } +771 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CentralAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CentralAnalyzer.html new file mode 100644 index 000000000..f312ad390 --- /dev/null +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/CentralAnalyzer.html @@ -0,0 +1,214 @@ + + + +CentralAnalyzer xref + + + +
    +1   /*
    +2    * This file is part of dependency-check-core.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *     http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   *
    +16   * Copyright (c) 2014 Jeremy Long. All Rights Reserved.
    +17   */
    +18  package org.owasp.dependencycheck.analyzer;
    +19  
    +20  import java.io.FileNotFoundException;
    +21  import java.io.IOException;
    +22  import java.net.URL;
    +23  import java.util.List;
    +24  import java.util.Set;
    +25  import java.util.logging.Level;
    +26  import java.util.logging.Logger;
    +27  import org.owasp.dependencycheck.Engine;
    +28  import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
    +29  import org.owasp.dependencycheck.data.central.CentralSearch;
    +30  import org.owasp.dependencycheck.data.nexus.MavenArtifact;
    +31  import org.owasp.dependencycheck.dependency.Confidence;
    +32  import org.owasp.dependencycheck.dependency.Dependency;
    +33  import org.owasp.dependencycheck.utils.InvalidSettingException;
    +34  import org.owasp.dependencycheck.utils.Settings;
    +35  
    +36  /**
    +37   * Analyzer which will attempt to locate a dependency, and the GAV information, by querying Central for the dependency's
    +38   * SHA-1 digest.
    +39   *
    +40   * @author colezlaw
    +41   */
    +42  public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
    +43  
    +44      /**
    +45       * The logger.
    +46       */
    +47      private static final Logger LOGGER = Logger.getLogger(CentralAnalyzer.class.getName());
    +48  
    +49      /**
    +50       * The name of the analyzer.
    +51       */
    +52      private static final String ANALYZER_NAME = "Central Analyzer";
    +53  
    +54      /**
    +55       * The phase in which this analyzer runs.
    +56       */
    +57      private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.INFORMATION_COLLECTION;
    +58  
    +59      /**
    +60       * The types of files on which this will work.
    +61       */
    +62      private static final Set<String> SUPPORTED_EXTENSIONS = newHashSet("jar");
    +63  
    +64      /**
    +65       * The analyzer should be disabled if there are errors, so this is a flag to determine if such an error has
    +66       * occurred.
    +67       */
    +68      private boolean errorFlag = false;
    +69  
    +70      /**
    +71       * The searcher itself.
    +72       */
    +73      private CentralSearch searcher;
    +74  
    +75      /**
    +76       * Field indicating if the analyzer is enabled.
    +77       */
    +78      private final boolean enabled = checkEnabled();
    +79  
    +80      /**
    +81       * Determine whether to enable this analyzer or not.
    +82       *
    +83       * @return whether the analyzer should be enabled
    +84       */
    +85      @Override
    +86      public boolean isEnabled() {
    +87          return enabled;
    +88      }
    +89  
    +90      /**
    +91       * Determines if this analyzer is enabled.
    +92       *
    +93       * @return <code>true</code> if the analyzer is enabled; otherwise <code>false</code>
    +94       */
    +95      private boolean checkEnabled() {
    +96          boolean retval = false;
    +97  
    +98          try {
    +99              if (Settings.getBoolean(Settings.KEYS.ANALYZER_CENTRAL_ENABLED)) {
    +100                 if (!Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)
    +101                         || NexusAnalyzer.DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL))) {
    +102                     LOGGER.info("Enabling the Central analyzer");
    +103                     retval = true;
    +104                 } else {
    +105                     LOGGER.info("Nexus analyzer is enabled, disabling the Central Analyzer");
    +106                 }
    +107             } else {
    +108                 LOGGER.info("Central analyzer disabled");
    +109             }
    +110         } catch (InvalidSettingException ise) {
    +111             LOGGER.warning("Invalid setting. Disabling the Central analyzer");
    +112         }
    +113         return retval;
    +114     }
    +115 
    +116     /**
    +117      * Initializes the analyzer once before any analysis is performed.
    +118      *
    +119      * @throws Exception if there's an error during initialization
    +120      */
    +121     @Override
    +122     public void initializeFileTypeAnalyzer() throws Exception {
    +123         LOGGER.fine("Initializing Central analyzer");
    +124         LOGGER.fine(String.format("Central analyzer enabled: %s", isEnabled()));
    +125         if (isEnabled()) {
    +126             final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_CENTRAL_URL);
    +127             LOGGER.fine(String.format("Central Analyzer URL: %s", searchUrl));
    +128             searcher = new CentralSearch(new URL(searchUrl));
    +129         }
    +130     }
    +131 
    +132     /**
    +133      * Returns the analyzer's name.
    +134      *
    +135      * @return the name of the analyzer
    +136      */
    +137     @Override
    +138     public String getName() {
    +139         return ANALYZER_NAME;
    +140     }
    +141 
    +142     /**
    +143      * Returns the key used in the properties file to to reference the analyzer's enabled property.
    +144      *
    +145      * @return the analyzer's enabled property setting key.
    +146      */
    +147     @Override
    +148     protected String getAnalyzerEnabledSettingKey() {
    +149         return Settings.KEYS.ANALYZER_CENTRAL_ENABLED;
    +150     }
    +151 
    +152     /**
    +153      * Returns the analysis phase under which the analyzer runs.
    +154      *
    +155      * @return the phase under which the analyzer runs
    +156      */
    +157     @Override
    +158     public AnalysisPhase getAnalysisPhase() {
    +159         return ANALYSIS_PHASE;
    +160     }
    +161 
    +162     /**
    +163      * Returns the extensions for which this Analyzer runs.
    +164      *
    +165      * @return the extensions for which this Analyzer runs
    +166      */
    +167     @Override
    +168     public Set<String> getSupportedExtensions() {
    +169         return SUPPORTED_EXTENSIONS;
    +170     }
    +171 
    +172     /**
    +173      * Performs the analysis.
    +174      *
    +175      * @param dependency the dependency to analyze
    +176      * @param engine the engine
    +177      * @throws AnalysisException when there's an exception during analysis
    +178      */
    +179     @Override
    +180     public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException {
    +181         if (errorFlag || !isEnabled()) {
    +182             return;
    +183         }
    +184 
    +185         try {
    +186             final List<MavenArtifact> mas = searcher.searchSha1(dependency.getSha1sum());
    +187             final Confidence confidence = mas.size() > 1 ? Confidence.HIGH : Confidence.HIGHEST;
    +188             for (MavenArtifact ma : mas) {
    +189                 LOGGER.fine(String.format("Central analyzer found artifact (%s) for dependency (%s)", ma.toString(), dependency.getFileName()));
    +190                 dependency.addAsEvidence("central", ma, confidence);
    +191             }
    +192         } catch (IllegalArgumentException iae) {
    +193             LOGGER.info(String.format("invalid sha1-hash on %s", dependency.getFileName()));
    +194         } catch (FileNotFoundException fnfe) {
    +195             LOGGER.fine(String.format("Artifact not found in repository: '%s", dependency.getFileName()));
    +196         } catch (IOException ioe) {
    +197             LOGGER.log(Level.FINE, "Could not connect to Central search", ioe);
    +198             errorFlag = true;
    +199         }
    +200     }
    +201 }
    +
    +
    + + + diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.html index 6d9281523..f81d7b7fa 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.html @@ -120,7 +120,7 @@ 112 while (subIterator.hasNext()) { 113 final Dependency nextDependency = subIterator.next(); 114 if (hashesMatch(dependency, nextDependency)) { -115 if (isCore(dependency, nextDependency)) { +115 if (firstPathIsShortest(dependency.getFilePath(), nextDependency.getFilePath())) { 116 mergeDependencies(dependency, nextDependency, dependenciesToRemove); 117 } else { 118 mergeDependencies(nextDependency, dependency, dependenciesToRemove); @@ -398,7 +398,46 @@ 390 } 391 return false; 392 } -393 } +393 +394 /** +395 * Determines which path is shortest; if path lengths are equal then we use compareTo of the string method to +396 * determine if the first path is smaller. +397 * +398 * @param left the first path to compare +399 * @param right the second path to compare +400 * @return <code>true</code> if the leftPath is the shortest; otherwise <code>false</code> +401 */ +402 protected boolean firstPathIsShortest(String left, String right) { +403 final String leftPath = left.replace('\\', '/'); +404 final String rightPath = right.replace('\\', '/'); +405 +406 final int leftCount = countChar(leftPath, '/'); +407 final int rightCount = countChar(rightPath, '/'); +408 if (leftCount == rightCount) { +409 return leftPath.compareTo(rightPath) <= 0; +410 } else { +411 return leftCount < rightCount; +412 } +413 } +414 +415 /** +416 * Counts the number of times the character is present in the string. +417 * +418 * @param string the string to count the characters in +419 * @param c the character to count +420 * @return the number of times the character is present in the string +421 */ +422 private int countChar(String string, char c) { +423 int count = 0; +424 final int max = string.length(); +425 for (int i = 0; i < max; i++) { +426 if (c == string.charAt(i)) { +427 count++; +428 } +429 } +430 return count; +431 } +432 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.html index f618044a8..264c891f9 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.html @@ -101,375 +101,379 @@ 93 addFalseNegativeCPEs(dependency); 94 } 95 -96 private void removeBadSpringMatches(Dependency dependency) { -97 String mustContain = null; -98 for (Identifier i : dependency.getIdentifiers()) { -99 if ("maven".contains(i.getType())) { -100 if (i.getValue() != null && i.getValue().startsWith("org.springframework.")) { -101 int endPoint = i.getValue().indexOf(":", 19); -102 if (endPoint >= 0) { -103 mustContain = i.getValue().substring(19, endPoint).toLowerCase(); -104 break; -105 } -106 } -107 } -108 } -109 if (mustContain != null) { -110 Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); -111 while (itr.hasNext()) { -112 Identifier i = itr.next(); -113 if ("cpe".contains(i.getType()) -114 && i.getValue() != null -115 && i.getValue().startsWith("cpe:/a:springsource:") -116 && !i.getValue().toLowerCase().contains(mustContain)) { -117 itr.remove(); -118 //dependency.getIdentifiers().remove(i); -119 } -120 -121 } -122 } -123 } -124 -125 /** -126 * <p> -127 * Intended to remove spurious CPE entries. By spurious we mean duplicate, less specific CPE entries.</p> -128 * <p> -129 * Example:</p> -130 * <code> -131 * cpe:/a:some-vendor:some-product -132 * cpe:/a:some-vendor:some-product:1.5 -133 * cpe:/a:some-vendor:some-product:1.5.2 -134 * </code> -135 * <p> -136 * Should be trimmed to:</p> -137 * <code> -138 * cpe:/a:some-vendor:some-product:1.5.2 -139 * </code> -140 * -141 * @param dependency the dependency being analyzed -142 */ -143 @SuppressWarnings("null") -144 private void removeSpuriousCPE(Dependency dependency) { -145 final List<Identifier> ids = new ArrayList<Identifier>(); -146 ids.addAll(dependency.getIdentifiers()); -147 Collections.sort(ids); -148 final ListIterator<Identifier> mainItr = ids.listIterator(); -149 while (mainItr.hasNext()) { -150 final Identifier currentId = mainItr.next(); -151 final VulnerableSoftware currentCpe = parseCpe(currentId.getType(), currentId.getValue()); -152 if (currentCpe == null) { -153 continue; -154 } -155 final ListIterator<Identifier> subItr = ids.listIterator(mainItr.nextIndex()); -156 while (subItr.hasNext()) { -157 final Identifier nextId = subItr.next(); -158 final VulnerableSoftware nextCpe = parseCpe(nextId.getType(), nextId.getValue()); -159 if (nextCpe == null) { -160 continue; -161 } -162 //TODO fix the version problem below -163 if (currentCpe.getVendor().equals(nextCpe.getVendor())) { -164 if (currentCpe.getProduct().equals(nextCpe.getProduct())) { -165 // see if one is contained in the other.. remove the contained one from dependency.getIdentifier -166 final String currentVersion = currentCpe.getVersion(); -167 final String nextVersion = nextCpe.getVersion(); -168 if (currentVersion == null && nextVersion == null) { -169 //how did we get here? -170 LOGGER.log(Level.FINE, "currentVersion and nextVersion are both null?"); -171 } else if (currentVersion == null && nextVersion != null) { -172 dependency.getIdentifiers().remove(currentId); -173 } else if (nextVersion == null && currentVersion != null) { -174 dependency.getIdentifiers().remove(nextId); -175 } else if (currentVersion.length() < nextVersion.length()) { -176 if (nextVersion.startsWith(currentVersion) || "-".equals(currentVersion)) { -177 dependency.getIdentifiers().remove(currentId); -178 } -179 } else { -180 if (currentVersion.startsWith(nextVersion) || "-".equals(nextVersion)) { -181 dependency.getIdentifiers().remove(nextId); +96 /** +97 * Removes inaccurate matches on springframework CPEs. +98 * +99 * @param dependency the dependency to test for and remove known inaccurate CPE matches +100 */ +101 private void removeBadSpringMatches(Dependency dependency) { +102 String mustContain = null; +103 for (Identifier i : dependency.getIdentifiers()) { +104 if ("maven".contains(i.getType())) { +105 if (i.getValue() != null && i.getValue().startsWith("org.springframework.")) { +106 final int endPoint = i.getValue().indexOf(":", 19); +107 if (endPoint >= 0) { +108 mustContain = i.getValue().substring(19, endPoint).toLowerCase(); +109 break; +110 } +111 } +112 } +113 } +114 if (mustContain != null) { +115 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); +116 while (itr.hasNext()) { +117 final Identifier i = itr.next(); +118 if ("cpe".contains(i.getType()) +119 && i.getValue() != null +120 && i.getValue().startsWith("cpe:/a:springsource:") +121 && !i.getValue().toLowerCase().contains(mustContain)) { +122 itr.remove(); +123 //dependency.getIdentifiers().remove(i); +124 } +125 } +126 } +127 } +128 +129 /** +130 * <p> +131 * Intended to remove spurious CPE entries. By spurious we mean duplicate, less specific CPE entries.</p> +132 * <p> +133 * Example:</p> +134 * <code> +135 * cpe:/a:some-vendor:some-product +136 * cpe:/a:some-vendor:some-product:1.5 +137 * cpe:/a:some-vendor:some-product:1.5.2 +138 * </code> +139 * <p> +140 * Should be trimmed to:</p> +141 * <code> +142 * cpe:/a:some-vendor:some-product:1.5.2 +143 * </code> +144 * +145 * @param dependency the dependency being analyzed +146 */ +147 @SuppressWarnings("null") +148 private void removeSpuriousCPE(Dependency dependency) { +149 final List<Identifier> ids = new ArrayList<Identifier>(); +150 ids.addAll(dependency.getIdentifiers()); +151 Collections.sort(ids); +152 final ListIterator<Identifier> mainItr = ids.listIterator(); +153 while (mainItr.hasNext()) { +154 final Identifier currentId = mainItr.next(); +155 final VulnerableSoftware currentCpe = parseCpe(currentId.getType(), currentId.getValue()); +156 if (currentCpe == null) { +157 continue; +158 } +159 final ListIterator<Identifier> subItr = ids.listIterator(mainItr.nextIndex()); +160 while (subItr.hasNext()) { +161 final Identifier nextId = subItr.next(); +162 final VulnerableSoftware nextCpe = parseCpe(nextId.getType(), nextId.getValue()); +163 if (nextCpe == null) { +164 continue; +165 } +166 //TODO fix the version problem below +167 if (currentCpe.getVendor().equals(nextCpe.getVendor())) { +168 if (currentCpe.getProduct().equals(nextCpe.getProduct())) { +169 // see if one is contained in the other.. remove the contained one from dependency.getIdentifier +170 final String currentVersion = currentCpe.getVersion(); +171 final String nextVersion = nextCpe.getVersion(); +172 if (currentVersion == null && nextVersion == null) { +173 //how did we get here? +174 LOGGER.log(Level.FINE, "currentVersion and nextVersion are both null?"); +175 } else if (currentVersion == null && nextVersion != null) { +176 dependency.getIdentifiers().remove(currentId); +177 } else if (nextVersion == null && currentVersion != null) { +178 dependency.getIdentifiers().remove(nextId); +179 } else if (currentVersion.length() < nextVersion.length()) { +180 if (nextVersion.startsWith(currentVersion) || "-".equals(currentVersion)) { +181 dependency.getIdentifiers().remove(currentId); 182 } -183 } -184 } -185 } -186 } -187 } -188 } -189 /** -190 * Regex to identify core java libraries and a few other commonly misidentified ones. -191 */ -192 public static final Pattern CORE_JAVA = Pattern.compile("^cpe:/a:(sun|oracle|ibm):(j2[ems]e|" -193 + "java(_platform_micro_edition|_runtime_environment|_se|virtual_machine|se_development_kit|fx)?|" -194 + "jdk|jre|jsse)($|:.*)"); -195 -196 /** -197 * Regex to identify core jsf libraries. -198 */ -199 public static final Pattern CORE_JAVA_JSF = Pattern.compile("^cpe:/a:(sun|oracle|ibm):jsf($|:.*)"); +183 } else { +184 if (currentVersion.startsWith(nextVersion) || "-".equals(nextVersion)) { +185 dependency.getIdentifiers().remove(nextId); +186 } +187 } +188 } +189 } +190 } +191 } +192 } +193 /** +194 * Regex to identify core java libraries and a few other commonly misidentified ones. +195 */ +196 public static final Pattern CORE_JAVA = Pattern.compile("^cpe:/a:(sun|oracle|ibm):(j2[ems]e|" +197 + "java(_platform_micro_edition|_runtime_environment|_se|virtual_machine|se_development_kit|fx)?|" +198 + "jdk|jre|jsse)($|:.*)"); +199 200 /** -201 * Regex to identify core java library files. This is currently incomplete. +201 * Regex to identify core jsf libraries. 202 */ -203 public static final Pattern CORE_FILES = Pattern.compile("(^|/)((alt[-])?rt|jsse|jfxrt|jfr|jce|javaws|deploy|charsets)\\.jar$"); +203 public static final Pattern CORE_JAVA_JSF = Pattern.compile("^cpe:/a:(sun|oracle|ibm):jsf($|:.*)"); 204 /** -205 * Regex to identify core jsf java library files. This is currently incomplete. +205 * Regex to identify core java library files. This is currently incomplete. 206 */ -207 public static final Pattern CORE_JSF_FILES = Pattern.compile("(^|/)jsf[-][^/]*\\.jar$"); -208 -209 /** -210 * Removes any CPE entries for the JDK/JRE unless the filename ends with rt.jar -211 * -212 * @param dependency the dependency to remove JRE CPEs from -213 */ -214 private void removeJreEntries(Dependency dependency) { -215 final Set<Identifier> identifiers = dependency.getIdentifiers(); -216 final Iterator<Identifier> itr = identifiers.iterator(); -217 while (itr.hasNext()) { -218 final Identifier i = itr.next(); -219 final Matcher coreCPE = CORE_JAVA.matcher(i.getValue()); -220 final Matcher coreFiles = CORE_FILES.matcher(dependency.getFileName()); -221 if (coreCPE.matches() && !coreFiles.matches()) { -222 itr.remove(); -223 } -224 final Matcher coreJsfCPE = CORE_JAVA_JSF.matcher(i.getValue()); -225 final Matcher coreJsfFiles = CORE_JSF_FILES.matcher(dependency.getFileName()); -226 if (coreJsfCPE.matches() && !coreJsfFiles.matches()) { -227 itr.remove(); -228 } -229 } -230 } -231 -232 /** -233 * Parses a CPE string into an IndexEntry. -234 * -235 * @param type the type of identifier -236 * @param value the cpe identifier to parse -237 * @return an VulnerableSoftware object constructed from the identifier -238 */ -239 private VulnerableSoftware parseCpe(String type, String value) { -240 if (!"cpe".equals(type)) { -241 return null; -242 } -243 final VulnerableSoftware cpe = new VulnerableSoftware(); -244 try { -245 cpe.parseName(value); -246 } catch (UnsupportedEncodingException ex) { -247 LOGGER.log(Level.FINEST, null, ex); -248 return null; -249 } -250 return cpe; -251 } -252 -253 /** -254 * Removes bad CPE matches for a dependency. Unfortunately, right now these are hard-coded patches for specific -255 * problems identified when testing this on a LARGE volume of jar files. -256 * -257 * @param dependency the dependency to analyze -258 */ -259 private void removeBadMatches(Dependency dependency) { -260 final Set<Identifier> identifiers = dependency.getIdentifiers(); -261 final Iterator<Identifier> itr = identifiers.iterator(); -262 -263 /* TODO - can we utilize the pom's groupid and artifactId to filter??? most of -264 * these are due to low quality data. Other idea would be to say any CPE -265 * found based on LOW confidence evidence should have a different CPE type? (this -266 * might be a better solution then just removing the URL for "best-guess" matches). -267 */ -268 //Set<Evidence> groupId = dependency.getVendorEvidence().getEvidence("pom", "groupid"); -269 //Set<Evidence> artifactId = dependency.getVendorEvidence().getEvidence("pom", "artifactid"); -270 while (itr.hasNext()) { -271 final Identifier i = itr.next(); -272 //TODO move this startsWith expression to a configuration file? -273 if ("cpe".equals(i.getType())) { -274 if ((i.getValue().matches(".*c\\+\\+.*") -275 || i.getValue().startsWith("cpe:/a:file:file") -276 || i.getValue().startsWith("cpe:/a:mozilla:mozilla") -277 || i.getValue().startsWith("cpe:/a:cvs:cvs") -278 || i.getValue().startsWith("cpe:/a:ftp:ftp") -279 || i.getValue().startsWith("cpe:/a:tcp:tcp") -280 || i.getValue().startsWith("cpe:/a:ssh:ssh") -281 || i.getValue().startsWith("cpe:/a:lookup:lookup")) -282 && (dependency.getFileName().toLowerCase().endsWith(".jar") -283 || dependency.getFileName().toLowerCase().endsWith("pom.xml") -284 || dependency.getFileName().toLowerCase().endsWith(".dll") -285 || dependency.getFileName().toLowerCase().endsWith(".exe") -286 || dependency.getFileName().toLowerCase().endsWith(".nuspec") -287 || dependency.getFileName().toLowerCase().endsWith(".nupkg"))) { -288 itr.remove(); -289 } else if ((i.getValue().startsWith("cpe:/a:jquery:jquery") -290 || i.getValue().startsWith("cpe:/a:prototypejs:prototype") -291 || i.getValue().startsWith("cpe:/a:yahoo:yui")) -292 && (dependency.getFileName().toLowerCase().endsWith(".jar") -293 || dependency.getFileName().toLowerCase().endsWith("pom.xml") -294 || dependency.getFileName().toLowerCase().endsWith(".dll") -295 || dependency.getFileName().toLowerCase().endsWith(".exe"))) { -296 itr.remove(); -297 } else if ((i.getValue().startsWith("cpe:/a:microsoft:excel") -298 || i.getValue().startsWith("cpe:/a:microsoft:word") -299 || i.getValue().startsWith("cpe:/a:microsoft:visio") -300 || i.getValue().startsWith("cpe:/a:microsoft:powerpoint") -301 || i.getValue().startsWith("cpe:/a:microsoft:office")) -302 && (dependency.getFileName().toLowerCase().endsWith(".jar") -303 || dependency.getFileName().toLowerCase().endsWith("pom.xml"))) { -304 itr.remove(); -305 } else if (i.getValue().startsWith("cpe:/a:apache:maven") -306 && !dependency.getFileName().toLowerCase().matches("maven-core-[\\d\\.]+\\.jar")) { -307 itr.remove(); -308 } else if (i.getValue().startsWith("cpe:/a:m-core:m-core") -309 && !dependency.getEvidenceUsed().containsUsedString("m-core")) { -310 itr.remove(); -311 } else if (i.getValue().startsWith("cpe:/a:jboss:jboss") -312 && !dependency.getFileName().toLowerCase().matches("jboss-?[\\d\\.-]+(GA)?\\.jar")) { -313 itr.remove(); -314 } -315 } -316 } -317 } -318 -319 /** -320 * Removes CPE matches for the wrong version of a dependency. Currently, this only covers Axis 1 & 2. -321 * -322 * @param dependency the dependency to analyze -323 */ -324 private void removeWrongVersionMatches(Dependency dependency) { -325 final Set<Identifier> identifiers = dependency.getIdentifiers(); -326 final Iterator<Identifier> itr = identifiers.iterator(); -327 -328 final String fileName = dependency.getFileName(); -329 if (fileName != null && fileName.contains("axis2")) { -330 while (itr.hasNext()) { -331 final Identifier i = itr.next(); -332 if ("cpe".equals(i.getType())) { -333 final String cpe = i.getValue(); -334 if (cpe != null && (cpe.startsWith("cpe:/a:apache:axis:") || "cpe:/a:apache:axis".equals(cpe))) { -335 itr.remove(); -336 } -337 } -338 } -339 } else if (fileName != null && fileName.contains("axis")) { -340 while (itr.hasNext()) { -341 final Identifier i = itr.next(); -342 if ("cpe".equals(i.getType())) { -343 final String cpe = i.getValue(); -344 if (cpe != null && (cpe.startsWith("cpe:/a:apache:axis2:") || "cpe:/a:apache:axis2".equals(cpe))) { -345 itr.remove(); -346 } -347 } -348 } -349 } -350 } -351 -352 /** -353 * There are some known CPE entries, specifically regarding sun and oracle products due to the acquisition and -354 * changes in product names, that based on given evidence we can add the related CPE entries to ensure a complete -355 * list of CVE entries. -356 * -357 * @param dependency the dependency being analyzed -358 */ -359 private void addFalseNegativeCPEs(Dependency dependency) { -360 //TODO move this to the hint analyzer -361 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); -362 while (itr.hasNext()) { -363 final Identifier i = itr.next(); -364 if ("cpe".equals(i.getType()) && i.getValue() != null -365 && (i.getValue().startsWith("cpe:/a:oracle:opensso:") -366 || i.getValue().startsWith("cpe:/a:oracle:opensso_enterprise:") -367 || i.getValue().startsWith("cpe:/a:sun:opensso_enterprise:") -368 || i.getValue().startsWith("cpe:/a:sun:opensso:"))) { -369 final String newCpe = String.format("cpe:/a:sun:opensso_enterprise:%s", i.getValue().substring(22)); -370 final String newCpe2 = String.format("cpe:/a:oracle:opensso_enterprise:%s", i.getValue().substring(22)); -371 final String newCpe3 = String.format("cpe:/a:sun:opensso:%s", i.getValue().substring(22)); -372 final String newCpe4 = String.format("cpe:/a:oracle:opensso:%s", i.getValue().substring(22)); -373 try { -374 dependency.addIdentifier("cpe", -375 newCpe, -376 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe, "UTF-8"))); -377 dependency.addIdentifier("cpe", -378 newCpe2, -379 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe2, "UTF-8"))); -380 dependency.addIdentifier("cpe", -381 newCpe3, -382 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe3, "UTF-8"))); -383 dependency.addIdentifier("cpe", -384 newCpe4, -385 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe4, "UTF-8"))); -386 } catch (UnsupportedEncodingException ex) { -387 LOGGER.log(Level.FINE, null, ex); -388 } -389 } -390 } -391 } -392 -393 /** -394 * Removes duplicate entries identified that are contained within JAR files. These occasionally crop up due to POM -395 * entries or other types of files (such as DLLs and EXEs) being contained within the JAR. -396 * -397 * @param dependency the dependency that might be a duplicate -398 * @param engine the engine used to scan all dependencies -399 */ -400 private void removeDuplicativeEntriesFromJar(Dependency dependency, Engine engine) { -401 if (dependency.getFileName().toLowerCase().endsWith("pom.xml") -402 || "dll".equals(dependency.getFileExtension()) -403 || "exe".equals(dependency.getFileExtension())) { -404 String parentPath = dependency.getFilePath().toLowerCase(); -405 if (parentPath.contains(".jar")) { -406 parentPath = parentPath.substring(0, parentPath.indexOf(".jar") + 4); -407 final Dependency parent = findDependency(parentPath, engine.getDependencies()); -408 if (parent != null) { -409 boolean remove = false; -410 for (Identifier i : dependency.getIdentifiers()) { -411 if ("cpe".equals(i.getType())) { -412 final String trimmedCPE = trimCpeToVendor(i.getValue()); -413 for (Identifier parentId : parent.getIdentifiers()) { -414 if ("cpe".equals(parentId.getType()) && parentId.getValue().startsWith(trimmedCPE)) { -415 remove |= true; -416 } -417 } -418 } -419 if (!remove) { //we can escape early -420 return; -421 } -422 } -423 if (remove) { -424 engine.getDependencies().remove(dependency); -425 } -426 } -427 } -428 -429 } -430 } -431 -432 /** -433 * Retrieves a given dependency, based on a given path, from a list of dependencies. -434 * -435 * @param dependencyPath the path of the dependency to return -436 * @param dependencies the collection of dependencies to search -437 * @return the dependency object for the given path, otherwise null -438 */ -439 private Dependency findDependency(String dependencyPath, List<Dependency> dependencies) { -440 for (Dependency d : dependencies) { -441 if (d.getFilePath().equalsIgnoreCase(dependencyPath)) { -442 return d; -443 } -444 } -445 return null; -446 } -447 -448 /** -449 * Takes a full CPE and returns the CPE trimmed to include only vendor and product. -450 * -451 * @param value the CPE value to trim -452 * @return a CPE value that only includes the vendor and product -453 */ -454 private String trimCpeToVendor(String value) { -455 //cpe:/a:jruby:jruby:1.0.8 -456 final int pos1 = value.indexOf(":", 7); //right of vendor -457 final int pos2 = value.indexOf(":", pos1 + 1); //right of product -458 if (pos2 < 0) { -459 return value; -460 } else { -461 return value.substring(0, pos2); -462 } -463 } -464 } +207 public static final Pattern CORE_FILES = Pattern.compile("(^|/)((alt[-])?rt|jsse|jfxrt|jfr|jce|javaws|deploy|charsets)\\.jar$"); +208 /** +209 * Regex to identify core jsf java library files. This is currently incomplete. +210 */ +211 public static final Pattern CORE_JSF_FILES = Pattern.compile("(^|/)jsf[-][^/]*\\.jar$"); +212 +213 /** +214 * Removes any CPE entries for the JDK/JRE unless the filename ends with rt.jar +215 * +216 * @param dependency the dependency to remove JRE CPEs from +217 */ +218 private void removeJreEntries(Dependency dependency) { +219 final Set<Identifier> identifiers = dependency.getIdentifiers(); +220 final Iterator<Identifier> itr = identifiers.iterator(); +221 while (itr.hasNext()) { +222 final Identifier i = itr.next(); +223 final Matcher coreCPE = CORE_JAVA.matcher(i.getValue()); +224 final Matcher coreFiles = CORE_FILES.matcher(dependency.getFileName()); +225 if (coreCPE.matches() && !coreFiles.matches()) { +226 itr.remove(); +227 } +228 final Matcher coreJsfCPE = CORE_JAVA_JSF.matcher(i.getValue()); +229 final Matcher coreJsfFiles = CORE_JSF_FILES.matcher(dependency.getFileName()); +230 if (coreJsfCPE.matches() && !coreJsfFiles.matches()) { +231 itr.remove(); +232 } +233 } +234 } +235 +236 /** +237 * Parses a CPE string into an IndexEntry. +238 * +239 * @param type the type of identifier +240 * @param value the cpe identifier to parse +241 * @return an VulnerableSoftware object constructed from the identifier +242 */ +243 private VulnerableSoftware parseCpe(String type, String value) { +244 if (!"cpe".equals(type)) { +245 return null; +246 } +247 final VulnerableSoftware cpe = new VulnerableSoftware(); +248 try { +249 cpe.parseName(value); +250 } catch (UnsupportedEncodingException ex) { +251 LOGGER.log(Level.FINEST, null, ex); +252 return null; +253 } +254 return cpe; +255 } +256 +257 /** +258 * Removes bad CPE matches for a dependency. Unfortunately, right now these are hard-coded patches for specific +259 * problems identified when testing this on a LARGE volume of jar files. +260 * +261 * @param dependency the dependency to analyze +262 */ +263 private void removeBadMatches(Dependency dependency) { +264 final Set<Identifier> identifiers = dependency.getIdentifiers(); +265 final Iterator<Identifier> itr = identifiers.iterator(); +266 +267 /* TODO - can we utilize the pom's groupid and artifactId to filter??? most of +268 * these are due to low quality data. Other idea would be to say any CPE +269 * found based on LOW confidence evidence should have a different CPE type? (this +270 * might be a better solution then just removing the URL for "best-guess" matches). +271 */ +272 //Set<Evidence> groupId = dependency.getVendorEvidence().getEvidence("pom", "groupid"); +273 //Set<Evidence> artifactId = dependency.getVendorEvidence().getEvidence("pom", "artifactid"); +274 while (itr.hasNext()) { +275 final Identifier i = itr.next(); +276 //TODO move this startsWith expression to a configuration file? +277 if ("cpe".equals(i.getType())) { +278 if ((i.getValue().matches(".*c\\+\\+.*") +279 || i.getValue().startsWith("cpe:/a:file:file") +280 || i.getValue().startsWith("cpe:/a:mozilla:mozilla") +281 || i.getValue().startsWith("cpe:/a:cvs:cvs") +282 || i.getValue().startsWith("cpe:/a:ftp:ftp") +283 || i.getValue().startsWith("cpe:/a:tcp:tcp") +284 || i.getValue().startsWith("cpe:/a:ssh:ssh") +285 || i.getValue().startsWith("cpe:/a:lookup:lookup")) +286 && (dependency.getFileName().toLowerCase().endsWith(".jar") +287 || dependency.getFileName().toLowerCase().endsWith("pom.xml") +288 || dependency.getFileName().toLowerCase().endsWith(".dll") +289 || dependency.getFileName().toLowerCase().endsWith(".exe") +290 || dependency.getFileName().toLowerCase().endsWith(".nuspec") +291 || dependency.getFileName().toLowerCase().endsWith(".nupkg"))) { +292 itr.remove(); +293 } else if ((i.getValue().startsWith("cpe:/a:jquery:jquery") +294 || i.getValue().startsWith("cpe:/a:prototypejs:prototype") +295 || i.getValue().startsWith("cpe:/a:yahoo:yui")) +296 && (dependency.getFileName().toLowerCase().endsWith(".jar") +297 || dependency.getFileName().toLowerCase().endsWith("pom.xml") +298 || dependency.getFileName().toLowerCase().endsWith(".dll") +299 || dependency.getFileName().toLowerCase().endsWith(".exe"))) { +300 itr.remove(); +301 } else if ((i.getValue().startsWith("cpe:/a:microsoft:excel") +302 || i.getValue().startsWith("cpe:/a:microsoft:word") +303 || i.getValue().startsWith("cpe:/a:microsoft:visio") +304 || i.getValue().startsWith("cpe:/a:microsoft:powerpoint") +305 || i.getValue().startsWith("cpe:/a:microsoft:office")) +306 && (dependency.getFileName().toLowerCase().endsWith(".jar") +307 || dependency.getFileName().toLowerCase().endsWith("pom.xml"))) { +308 itr.remove(); +309 } else if (i.getValue().startsWith("cpe:/a:apache:maven") +310 && !dependency.getFileName().toLowerCase().matches("maven-core-[\\d\\.]+\\.jar")) { +311 itr.remove(); +312 } else if (i.getValue().startsWith("cpe:/a:m-core:m-core") +313 && !dependency.getEvidenceUsed().containsUsedString("m-core")) { +314 itr.remove(); +315 } else if (i.getValue().startsWith("cpe:/a:jboss:jboss") +316 && !dependency.getFileName().toLowerCase().matches("jboss-?[\\d\\.-]+(GA)?\\.jar")) { +317 itr.remove(); +318 } +319 } +320 } +321 } +322 +323 /** +324 * Removes CPE matches for the wrong version of a dependency. Currently, this only covers Axis 1 & 2. +325 * +326 * @param dependency the dependency to analyze +327 */ +328 private void removeWrongVersionMatches(Dependency dependency) { +329 final Set<Identifier> identifiers = dependency.getIdentifiers(); +330 final Iterator<Identifier> itr = identifiers.iterator(); +331 +332 final String fileName = dependency.getFileName(); +333 if (fileName != null && fileName.contains("axis2")) { +334 while (itr.hasNext()) { +335 final Identifier i = itr.next(); +336 if ("cpe".equals(i.getType())) { +337 final String cpe = i.getValue(); +338 if (cpe != null && (cpe.startsWith("cpe:/a:apache:axis:") || "cpe:/a:apache:axis".equals(cpe))) { +339 itr.remove(); +340 } +341 } +342 } +343 } else if (fileName != null && fileName.contains("axis")) { +344 while (itr.hasNext()) { +345 final Identifier i = itr.next(); +346 if ("cpe".equals(i.getType())) { +347 final String cpe = i.getValue(); +348 if (cpe != null && (cpe.startsWith("cpe:/a:apache:axis2:") || "cpe:/a:apache:axis2".equals(cpe))) { +349 itr.remove(); +350 } +351 } +352 } +353 } +354 } +355 +356 /** +357 * There are some known CPE entries, specifically regarding sun and oracle products due to the acquisition and +358 * changes in product names, that based on given evidence we can add the related CPE entries to ensure a complete +359 * list of CVE entries. +360 * +361 * @param dependency the dependency being analyzed +362 */ +363 private void addFalseNegativeCPEs(Dependency dependency) { +364 //TODO move this to the hint analyzer +365 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); +366 while (itr.hasNext()) { +367 final Identifier i = itr.next(); +368 if ("cpe".equals(i.getType()) && i.getValue() != null +369 && (i.getValue().startsWith("cpe:/a:oracle:opensso:") +370 || i.getValue().startsWith("cpe:/a:oracle:opensso_enterprise:") +371 || i.getValue().startsWith("cpe:/a:sun:opensso_enterprise:") +372 || i.getValue().startsWith("cpe:/a:sun:opensso:"))) { +373 final String newCpe = String.format("cpe:/a:sun:opensso_enterprise:%s", i.getValue().substring(22)); +374 final String newCpe2 = String.format("cpe:/a:oracle:opensso_enterprise:%s", i.getValue().substring(22)); +375 final String newCpe3 = String.format("cpe:/a:sun:opensso:%s", i.getValue().substring(22)); +376 final String newCpe4 = String.format("cpe:/a:oracle:opensso:%s", i.getValue().substring(22)); +377 try { +378 dependency.addIdentifier("cpe", +379 newCpe, +380 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe, "UTF-8"))); +381 dependency.addIdentifier("cpe", +382 newCpe2, +383 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe2, "UTF-8"))); +384 dependency.addIdentifier("cpe", +385 newCpe3, +386 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe3, "UTF-8"))); +387 dependency.addIdentifier("cpe", +388 newCpe4, +389 String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe4, "UTF-8"))); +390 } catch (UnsupportedEncodingException ex) { +391 LOGGER.log(Level.FINE, null, ex); +392 } +393 } +394 } +395 } +396 +397 /** +398 * Removes duplicate entries identified that are contained within JAR files. These occasionally crop up due to POM +399 * entries or other types of files (such as DLLs and EXEs) being contained within the JAR. +400 * +401 * @param dependency the dependency that might be a duplicate +402 * @param engine the engine used to scan all dependencies +403 */ +404 private void removeDuplicativeEntriesFromJar(Dependency dependency, Engine engine) { +405 if (dependency.getFileName().toLowerCase().endsWith("pom.xml") +406 || "dll".equals(dependency.getFileExtension()) +407 || "exe".equals(dependency.getFileExtension())) { +408 String parentPath = dependency.getFilePath().toLowerCase(); +409 if (parentPath.contains(".jar")) { +410 parentPath = parentPath.substring(0, parentPath.indexOf(".jar") + 4); +411 final Dependency parent = findDependency(parentPath, engine.getDependencies()); +412 if (parent != null) { +413 boolean remove = false; +414 for (Identifier i : dependency.getIdentifiers()) { +415 if ("cpe".equals(i.getType())) { +416 final String trimmedCPE = trimCpeToVendor(i.getValue()); +417 for (Identifier parentId : parent.getIdentifiers()) { +418 if ("cpe".equals(parentId.getType()) && parentId.getValue().startsWith(trimmedCPE)) { +419 remove |= true; +420 } +421 } +422 } +423 if (!remove) { //we can escape early +424 return; +425 } +426 } +427 if (remove) { +428 engine.getDependencies().remove(dependency); +429 } +430 } +431 } +432 +433 } +434 } +435 +436 /** +437 * Retrieves a given dependency, based on a given path, from a list of dependencies. +438 * +439 * @param dependencyPath the path of the dependency to return +440 * @param dependencies the collection of dependencies to search +441 * @return the dependency object for the given path, otherwise null +442 */ +443 private Dependency findDependency(String dependencyPath, List<Dependency> dependencies) { +444 for (Dependency d : dependencies) { +445 if (d.getFilePath().equalsIgnoreCase(dependencyPath)) { +446 return d; +447 } +448 } +449 return null; +450 } +451 +452 /** +453 * Takes a full CPE and returns the CPE trimmed to include only vendor and product. +454 * +455 * @param value the CPE value to trim +456 * @return a CPE value that only includes the vendor and product +457 */ +458 private String trimCpeToVendor(String value) { +459 //cpe:/a:jruby:jruby:1.0.8 +460 final int pos1 = value.indexOf(":", 7); //right of vendor +461 final int pos2 = value.indexOf(":", pos1 + 1); //right of product +462 if (pos2 < 0) { +463 return value; +464 } else { +465 return value.substring(0, pos2); +466 } +467 } +468 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.html index 67b9ee555..04221a3f2 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.html @@ -81,7 +81,7 @@ 73 public void analyze(Dependency dependency, Engine engine) throws AnalysisException { 74 75 //strip any path information that may get added by ArchiveAnalyzer, etc. -76 final File f = new File(dependency.getFileName()); +76 final File f = dependency.getActualFile(); 77 String fileName = f.getName(); 78 79 //remove file extension diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/JarAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/JarAnalyzer.html index fe3658e13..fe2522a63 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/JarAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/JarAnalyzer.html @@ -301,1060 +301,1110 @@ 293 LOGGER.log(Level.FINE, msg, ex); 294 return false; 295 } -296 if (pomEntries.isEmpty()) { -297 return false; -298 } -299 for (String path : pomEntries) { -300 Properties pomProperties = null; -301 try { -302 pomProperties = retrievePomProperties(path, jar); -303 } catch (IOException ex) { -304 LOGGER.log(Level.FINEST, "ignore this, failed reading a non-existent pom.properties", ex); -305 } -306 Model pom = null; -307 try { -308 if (pomEntries.size() > 1) { -309 //extract POM to its own directory and add it as its own dependency -310 final Dependency newDependency = new Dependency(); -311 pom = extractPom(path, jar, newDependency); -312 -313 final String displayPath = String.format("%s%s%s", -314 dependency.getFilePath(), -315 File.separator, -316 path); //.replaceAll("[\\/]", File.separator)); -317 final String displayName = String.format("%s%s%s", -318 dependency.getFileName(), -319 File.separator, -320 path); //.replaceAll("[\\/]", File.separator)); -321 -322 newDependency.setFileName(displayName); -323 newDependency.setFilePath(displayPath); -324 setPomEvidence(newDependency, pom, pomProperties, null); -325 engine.getDependencies().add(newDependency); -326 Collections.sort(engine.getDependencies()); -327 } else { -328 pom = retrievePom(path, jar); -329 foundSomething |= setPomEvidence(dependency, pom, pomProperties, classes); -330 } -331 } catch (AnalysisException ex) { -332 final String msg = String.format("An error occured while analyzing '%s'.", dependency.getActualFilePath()); -333 LOGGER.log(Level.WARNING, msg); -334 LOGGER.log(Level.FINE, "", ex); -335 } -336 } -337 return foundSomething; -338 } -339 -340 /** -341 * Given a path to a pom.xml within a JarFile, this method attempts to load a sibling pom.properties if one exists. -342 * -343 * @param path the path to the pom.xml within the JarFile -344 * @param jar the JarFile to load the pom.properties from -345 * @return a Properties object or null if no pom.properties was found -346 * @throws IOException thrown if there is an exception reading the pom.properties -347 */ -348 private Properties retrievePomProperties(String path, final JarFile jar) throws IOException { -349 Properties pomProperties = null; -350 final String propPath = path.substring(0, path.length() - 7) + "pom.properies"; -351 final ZipEntry propEntry = jar.getEntry(propPath); -352 if (propEntry != null) { -353 Reader reader = null; -354 try { -355 reader = new InputStreamReader(jar.getInputStream(propEntry), "UTF-8"); -356 pomProperties = new Properties(); -357 pomProperties.load(reader); -358 } finally { -359 if (reader != null) { -360 try { -361 reader.close(); -362 } catch (IOException ex) { -363 LOGGER.log(Level.FINEST, "close error", ex); -364 } -365 } -366 } -367 } -368 return pomProperties; -369 } -370 -371 /** -372 * Searches a JarFile for pom.xml entries and returns a listing of these entries. -373 * -374 * @param jar the JarFile to search -375 * @return a list of pom.xml entries -376 * @throws IOException thrown if there is an exception reading a JarEntry -377 */ -378 private List<String> retrievePomListing(final JarFile jar) throws IOException { -379 final List<String> pomEntries = new ArrayList<String>(); -380 final Enumeration<JarEntry> entries = jar.entries(); -381 while (entries.hasMoreElements()) { -382 final JarEntry entry = entries.nextElement(); -383 final String entryName = (new File(entry.getName())).getName().toLowerCase(); -384 if (!entry.isDirectory() && "pom.xml".equals(entryName)) { -385 pomEntries.add(entry.getName()); -386 } -387 } -388 return pomEntries; -389 } -390 -391 /** -392 * Retrieves the specified POM from a jar file and converts it to a Model. -393 * -394 * @param path the path to the pom.xml file within the jar file -395 * @param jar the jar file to extract the pom from -396 * @param dependency the dependency being analyzed -397 * @return returns the POM object -398 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM -399 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object -400 */ -401 private Model extractPom(String path, JarFile jar, Dependency dependency) throws AnalysisException { -402 InputStream input = null; -403 FileOutputStream fos = null; -404 BufferedOutputStream bos = null; -405 final File tmpDir = getNextTempDirectory(); -406 final File file = new File(tmpDir, "pom.xml"); -407 try { -408 final ZipEntry entry = jar.getEntry(path); -409 input = jar.getInputStream(entry); -410 fos = new FileOutputStream(file); -411 bos = new BufferedOutputStream(fos, BUFFER_SIZE); -412 int count; -413 final byte data[] = new byte[BUFFER_SIZE]; -414 while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) { -415 bos.write(data, 0, count); -416 } -417 bos.flush(); -418 dependency.setActualFilePath(file.getAbsolutePath()); -419 } catch (IOException ex) { -420 final String msg = String.format("An error occurred reading '%s' from '%s'.", path, dependency.getFilePath()); -421 LOGGER.warning(msg); -422 LOGGER.log(Level.SEVERE, "", ex); -423 } finally { -424 closeStream(bos); -425 closeStream(fos); -426 closeStream(input); -427 } -428 Model model = null; -429 FileInputStream fis = null; -430 try { -431 fis = new FileInputStream(file); -432 final InputStreamReader reader = new InputStreamReader(fis, "UTF-8"); -433 final InputSource xml = new InputSource(reader); -434 final SAXSource source = new SAXSource(xml); -435 model = readPom(source); -436 } catch (FileNotFoundException ex) { -437 final String msg = String.format("Unable to parse pom '%s' in jar '%s' (File Not Found)", path, jar.getName()); -438 LOGGER.log(Level.WARNING, msg); -439 LOGGER.log(Level.FINE, "", ex); -440 throw new AnalysisException(ex); -441 } catch (UnsupportedEncodingException ex) { -442 final String msg = String.format("Unable to parse pom '%s' in jar '%s' (IO Exception)", path, jar.getName()); -443 LOGGER.log(Level.WARNING, msg); -444 LOGGER.log(Level.FINE, "", ex); -445 throw new AnalysisException(ex); -446 } catch (AnalysisException ex) { -447 final String msg = String.format("Unable to parse pom '%s' in jar '%s'", path, jar.getName()); -448 LOGGER.log(Level.WARNING, msg); -449 LOGGER.log(Level.FINE, "", ex); -450 throw ex; -451 } finally { -452 closeStream(fis); -453 } -454 return model; -455 } -456 -457 /** -458 * Silently closes an input stream ignoring errors. -459 * -460 * @param stream an input stream to close -461 */ -462 private void closeStream(InputStream stream) { -463 if (stream != null) { -464 try { -465 stream.close(); -466 } catch (IOException ex) { -467 LOGGER.log(Level.FINEST, null, ex); -468 } -469 } -470 } -471 -472 /** -473 * Silently closes an output stream ignoring errors. -474 * -475 * @param stream an output stream to close -476 */ -477 private void closeStream(OutputStream stream) { -478 if (stream != null) { -479 try { -480 stream.close(); -481 } catch (IOException ex) { -482 LOGGER.log(Level.FINEST, null, ex); -483 } -484 } -485 } -486 -487 /** -488 * Retrieves the specified POM from a jar file and converts it to a Model. -489 * -490 * @param path the path to the pom.xml file within the jar file -491 * @param jar the jar file to extract the pom from -492 * @return returns a -493 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM -494 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object -495 */ -496 private Model retrievePom(String path, JarFile jar) throws AnalysisException { -497 final ZipEntry entry = jar.getEntry(path); -498 Model model = null; -499 if (entry != null) { //should never be null -500 try { -501 final NonClosingStream stream = new NonClosingStream(jar.getInputStream(entry)); -502 final InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); -503 final InputSource xml = new InputSource(reader); -504 final SAXSource source = new SAXSource(xml); -505 model = readPom(source); -506 } catch (SecurityException ex) { -507 final String msg = String.format("Unable to parse pom '%s' in jar '%s'; invalid signature", path, jar.getName()); -508 LOGGER.log(Level.WARNING, msg); -509 LOGGER.log(Level.FINE, null, ex); -510 throw new AnalysisException(ex); -511 } catch (IOException ex) { -512 final String msg = String.format("Unable to parse pom '%s' in jar '%s' (IO Exception)", path, jar.getName()); -513 LOGGER.log(Level.WARNING, msg); -514 LOGGER.log(Level.FINE, "", ex); -515 throw new AnalysisException(ex); -516 } catch (Throwable ex) { -517 final String msg = String.format("Unexpected error during parsing of the pom '%s' in jar '%s'", path, jar.getName()); -518 LOGGER.log(Level.WARNING, msg); -519 LOGGER.log(Level.FINE, "", ex); -520 throw new AnalysisException(ex); -521 } -522 } -523 return model; -524 } -525 -526 /** -527 * Retrieves the specified POM from a jar file and converts it to a Model. -528 * -529 * @param source the SAXSource input stream to read the POM from -530 * @return returns the POM object -531 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM -532 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object -533 */ -534 private Model readPom(SAXSource source) throws AnalysisException { -535 Model model = null; -536 try { -537 final XMLFilter filter = new MavenNamespaceFilter(); -538 final SAXParserFactory spf = SAXParserFactory.newInstance(); -539 final SAXParser sp = spf.newSAXParser(); -540 final XMLReader xr = sp.getXMLReader(); -541 filter.setParent(xr); -542 final JAXBElement<Model> el = pomUnmarshaller.unmarshal(source, Model.class); -543 model = el.getValue(); -544 } catch (SecurityException ex) { -545 throw new AnalysisException(ex); -546 } catch (ParserConfigurationException ex) { -547 throw new AnalysisException(ex); -548 } catch (SAXException ex) { -549 throw new AnalysisException(ex); -550 } catch (JAXBException ex) { -551 throw new AnalysisException(ex); -552 } catch (Throwable ex) { -553 throw new AnalysisException(ex); -554 } -555 return model; -556 } -557 -558 /** -559 * Sets evidence from the pom on the supplied dependency. -560 * -561 * @param dependency the dependency to set data on -562 * @param pom the information from the pom -563 * @param pomProperties the pom properties file (null if none exists) -564 * @param classes a collection of ClassNameInformation - containing data about the fully qualified class names -565 * within the JAR file being analyzed -566 * @return true if there was evidence within the pom that we could use; otherwise false -567 */ -568 private boolean setPomEvidence(Dependency dependency, Model pom, Properties pomProperties, ArrayList<ClassNameInformation> classes) { -569 boolean foundSomething = false; -570 boolean addAsIdentifier = true; -571 if (pom == null) { -572 return foundSomething; -573 } -574 String groupid = interpolateString(pom.getGroupId(), pomProperties); -575 String parentGroupId = null; -576 -577 if (pom.getParent() != null) { -578 parentGroupId = interpolateString(pom.getParent().getGroupId(), pomProperties); -579 if ((groupid == null || groupid.isEmpty()) && parentGroupId != null && !parentGroupId.isEmpty()) { -580 groupid = parentGroupId; -581 } -582 } -583 final String originalGroupID = groupid; -584 -585 if (groupid != null && !groupid.isEmpty()) { -586 if (groupid.startsWith("org.") || groupid.startsWith("com.")) { -587 groupid = groupid.substring(4); -588 } -589 foundSomething = true; -590 dependency.getVendorEvidence().addEvidence("pom", "groupid", groupid, Confidence.HIGHEST); -591 dependency.getProductEvidence().addEvidence("pom", "groupid", groupid, Confidence.LOW); -592 addMatchingValues(classes, groupid, dependency.getVendorEvidence()); -593 addMatchingValues(classes, groupid, dependency.getProductEvidence()); -594 if (parentGroupId != null && !parentGroupId.isEmpty() && !parentGroupId.equals(groupid)) { -595 dependency.getVendorEvidence().addEvidence("pom", "parent-groupid", parentGroupId, Confidence.MEDIUM); -596 dependency.getProductEvidence().addEvidence("pom", "parent-groupid", parentGroupId, Confidence.LOW); -597 addMatchingValues(classes, parentGroupId, dependency.getVendorEvidence()); -598 addMatchingValues(classes, parentGroupId, dependency.getProductEvidence()); -599 } -600 } else { -601 addAsIdentifier = false; -602 } -603 -604 String artifactid = interpolateString(pom.getArtifactId(), pomProperties); -605 String parentArtifactId = null; -606 -607 if (pom.getParent() != null) { -608 parentArtifactId = interpolateString(pom.getParent().getArtifactId(), pomProperties); -609 if ((artifactid == null || artifactid.isEmpty()) && parentArtifactId != null && !parentArtifactId.isEmpty()) { -610 artifactid = parentArtifactId; -611 } -612 } -613 final String originalArtifactID = artifactid; -614 if (artifactid != null && !artifactid.isEmpty()) { -615 if (artifactid.startsWith("org.") || artifactid.startsWith("com.")) { -616 artifactid = artifactid.substring(4); -617 } -618 foundSomething = true; -619 dependency.getProductEvidence().addEvidence("pom", "artifactid", artifactid, Confidence.HIGHEST); -620 dependency.getVendorEvidence().addEvidence("pom", "artifactid", artifactid, Confidence.LOW); -621 addMatchingValues(classes, artifactid, dependency.getVendorEvidence()); -622 addMatchingValues(classes, artifactid, dependency.getProductEvidence()); -623 if (parentArtifactId != null && !parentArtifactId.isEmpty() && !parentArtifactId.equals(artifactid)) { -624 dependency.getProductEvidence().addEvidence("pom", "parent-artifactid", parentArtifactId, Confidence.MEDIUM); -625 dependency.getVendorEvidence().addEvidence("pom", "parent-artifactid", parentArtifactId, Confidence.LOW); -626 addMatchingValues(classes, parentArtifactId, dependency.getVendorEvidence()); -627 addMatchingValues(classes, parentArtifactId, dependency.getProductEvidence()); -628 } -629 } else { -630 addAsIdentifier = false; -631 } -632 //version -633 String version = interpolateString(pom.getVersion(), pomProperties); -634 String parentVersion = null; -635 -636 if (pom.getParent() != null) { -637 parentVersion = interpolateString(pom.getParent().getVersion(), pomProperties); -638 if ((version == null || version.isEmpty()) && parentVersion != null && !parentVersion.isEmpty()) { -639 version = parentVersion; -640 } -641 } -642 -643 if (version != null && !version.isEmpty()) { -644 foundSomething = true; -645 dependency.getVersionEvidence().addEvidence("pom", "version", version, Confidence.HIGHEST); -646 if (parentVersion != null && !parentVersion.isEmpty() && !parentVersion.equals(version)) { -647 dependency.getVersionEvidence().addEvidence("pom", "parent-version", version, Confidence.LOW); -648 } -649 } else { -650 addAsIdentifier = false; -651 } -652 -653 if (addAsIdentifier) { -654 dependency.addIdentifier("maven", String.format("%s:%s:%s", originalGroupID, originalArtifactID, version), null, Confidence.LOW); -655 } +296 File externalPom = null; +297 if (pomEntries.isEmpty()) { +298 if (dependency.getActualFilePath().matches(".*\\.m2.repository\\b.*")) { +299 String pomPath = dependency.getActualFilePath(); +300 pomPath = pomPath.substring(0, pomPath.lastIndexOf('.')) + ".pom"; +301 externalPom = new File(pomPath); +302 if (externalPom.isFile()) { +303 pomEntries.add(pomPath); +304 } else { +305 return false; +306 } +307 } else { +308 return false; +309 } +310 } +311 for (String path : pomEntries) { +312 Properties pomProperties = null; +313 try { +314 if (externalPom == null) { +315 pomProperties = retrievePomProperties(path, jar); +316 } +317 } catch (IOException ex) { +318 LOGGER.log(Level.FINEST, "ignore this, failed reading a non-existent pom.properties", ex); +319 } +320 Model pom = null; +321 try { +322 if (pomEntries.size() > 1) { +323 //extract POM to its own directory and add it as its own dependency +324 final Dependency newDependency = new Dependency(); +325 pom = extractPom(path, jar, newDependency); +326 +327 final String displayPath = String.format("%s%s%s", +328 dependency.getFilePath(), +329 File.separator, +330 path); +331 final String displayName = String.format("%s%s%s", +332 dependency.getFileName(), +333 File.separator, +334 path); +335 +336 newDependency.setFileName(displayName); +337 newDependency.setFilePath(displayPath); +338 setPomEvidence(newDependency, pom, pomProperties, null); +339 engine.getDependencies().add(newDependency); +340 Collections.sort(engine.getDependencies()); +341 } else { +342 if (externalPom == null) { +343 pom = retrievePom(path, jar); +344 } else { +345 pom = retrievePom(externalPom); +346 } +347 foundSomething |= setPomEvidence(dependency, pom, pomProperties, classes); +348 } +349 } catch (AnalysisException ex) { +350 final String msg = String.format("An error occured while analyzing '%s'.", dependency.getActualFilePath()); +351 LOGGER.log(Level.WARNING, msg); +352 LOGGER.log(Level.FINE, "", ex); +353 } +354 } +355 return foundSomething; +356 } +357 +358 /** +359 * Given a path to a pom.xml within a JarFile, this method attempts to load a sibling pom.properties if one exists. +360 * +361 * @param path the path to the pom.xml within the JarFile +362 * @param jar the JarFile to load the pom.properties from +363 * @return a Properties object or null if no pom.properties was found +364 * @throws IOException thrown if there is an exception reading the pom.properties +365 */ +366 private Properties retrievePomProperties(String path, final JarFile jar) throws IOException { +367 Properties pomProperties = null; +368 final String propPath = path.substring(0, path.length() - 7) + "pom.properies"; +369 final ZipEntry propEntry = jar.getEntry(propPath); +370 if (propEntry != null) { +371 Reader reader = null; +372 try { +373 reader = new InputStreamReader(jar.getInputStream(propEntry), "UTF-8"); +374 pomProperties = new Properties(); +375 pomProperties.load(reader); +376 } finally { +377 if (reader != null) { +378 try { +379 reader.close(); +380 } catch (IOException ex) { +381 LOGGER.log(Level.FINEST, "close error", ex); +382 } +383 } +384 } +385 } +386 return pomProperties; +387 } +388 +389 /** +390 * Searches a JarFile for pom.xml entries and returns a listing of these entries. +391 * +392 * @param jar the JarFile to search +393 * @return a list of pom.xml entries +394 * @throws IOException thrown if there is an exception reading a JarEntry +395 */ +396 private List<String> retrievePomListing(final JarFile jar) throws IOException { +397 final List<String> pomEntries = new ArrayList<String>(); +398 final Enumeration<JarEntry> entries = jar.entries(); +399 while (entries.hasMoreElements()) { +400 final JarEntry entry = entries.nextElement(); +401 final String entryName = (new File(entry.getName())).getName().toLowerCase(); +402 if (!entry.isDirectory() && "pom.xml".equals(entryName)) { +403 pomEntries.add(entry.getName()); +404 } +405 } +406 return pomEntries; +407 } +408 +409 /** +410 * Retrieves the specified POM from a jar file and converts it to a Model. +411 * +412 * @param path the path to the pom.xml file within the jar file +413 * @param jar the jar file to extract the pom from +414 * @param dependency the dependency being analyzed +415 * @return returns the POM object +416 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM +417 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object +418 */ +419 private Model extractPom(String path, JarFile jar, Dependency dependency) throws AnalysisException { +420 InputStream input = null; +421 FileOutputStream fos = null; +422 BufferedOutputStream bos = null; +423 final File tmpDir = getNextTempDirectory(); +424 final File file = new File(tmpDir, "pom.xml"); +425 try { +426 final ZipEntry entry = jar.getEntry(path); +427 input = jar.getInputStream(entry); +428 fos = new FileOutputStream(file); +429 bos = new BufferedOutputStream(fos, BUFFER_SIZE); +430 int count; +431 final byte data[] = new byte[BUFFER_SIZE]; +432 while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) { +433 bos.write(data, 0, count); +434 } +435 bos.flush(); +436 dependency.setActualFilePath(file.getAbsolutePath()); +437 } catch (IOException ex) { +438 final String msg = String.format("An error occurred reading '%s' from '%s'.", path, dependency.getFilePath()); +439 LOGGER.warning(msg); +440 LOGGER.log(Level.SEVERE, "", ex); +441 } finally { +442 closeStream(bos); +443 closeStream(fos); +444 closeStream(input); +445 } +446 Model model = null; +447 FileInputStream fis = null; +448 try { +449 fis = new FileInputStream(file); +450 final InputStreamReader reader = new InputStreamReader(fis, "UTF-8"); +451 final InputSource xml = new InputSource(reader); +452 final SAXSource source = new SAXSource(xml); +453 model = readPom(source); +454 } catch (FileNotFoundException ex) { +455 final String msg = String.format("Unable to parse pom '%s' in jar '%s' (File Not Found)", path, jar.getName()); +456 LOGGER.log(Level.WARNING, msg); +457 LOGGER.log(Level.FINE, "", ex); +458 throw new AnalysisException(ex); +459 } catch (UnsupportedEncodingException ex) { +460 final String msg = String.format("Unable to parse pom '%s' in jar '%s' (IO Exception)", path, jar.getName()); +461 LOGGER.log(Level.WARNING, msg); +462 LOGGER.log(Level.FINE, "", ex); +463 throw new AnalysisException(ex); +464 } catch (AnalysisException ex) { +465 final String msg = String.format("Unable to parse pom '%s' in jar '%s'", path, jar.getName()); +466 LOGGER.log(Level.WARNING, msg); +467 LOGGER.log(Level.FINE, "", ex); +468 throw ex; +469 } finally { +470 closeStream(fis); +471 } +472 return model; +473 } +474 +475 /** +476 * Silently closes an input stream ignoring errors. +477 * +478 * @param stream an input stream to close +479 */ +480 private void closeStream(InputStream stream) { +481 if (stream != null) { +482 try { +483 stream.close(); +484 } catch (IOException ex) { +485 LOGGER.log(Level.FINEST, null, ex); +486 } +487 } +488 } +489 +490 /** +491 * Silently closes an output stream ignoring errors. +492 * +493 * @param stream an output stream to close +494 */ +495 private void closeStream(OutputStream stream) { +496 if (stream != null) { +497 try { +498 stream.close(); +499 } catch (IOException ex) { +500 LOGGER.log(Level.FINEST, null, ex); +501 } +502 } +503 } +504 +505 /** +506 * Retrieves the specified POM from a jar file and converts it to a Model. +507 * +508 * @param path the path to the pom.xml file within the jar file +509 * @param jar the jar file to extract the pom from +510 * @return returns a +511 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM +512 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object +513 */ +514 private Model retrievePom(String path, JarFile jar) throws AnalysisException { +515 final ZipEntry entry = jar.getEntry(path); +516 Model model = null; +517 if (entry != null) { //should never be null +518 try { +519 final NonClosingStream stream = new NonClosingStream(jar.getInputStream(entry)); +520 final InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); +521 final InputSource xml = new InputSource(reader); +522 final SAXSource source = new SAXSource(xml); +523 model = readPom(source); +524 } catch (SecurityException ex) { +525 final String msg = String.format("Unable to parse pom '%s' in jar '%s'; invalid signature", path, jar.getName()); +526 LOGGER.log(Level.WARNING, msg); +527 LOGGER.log(Level.FINE, null, ex); +528 throw new AnalysisException(ex); +529 } catch (IOException ex) { +530 final String msg = String.format("Unable to parse pom '%s' in jar '%s' (IO Exception)", path, jar.getName()); +531 LOGGER.log(Level.WARNING, msg); +532 LOGGER.log(Level.FINE, "", ex); +533 throw new AnalysisException(ex); +534 } catch (Throwable ex) { +535 final String msg = String.format("Unexpected error during parsing of the pom '%s' in jar '%s'", path, jar.getName()); +536 LOGGER.log(Level.WARNING, msg); +537 LOGGER.log(Level.FINE, "", ex); +538 throw new AnalysisException(ex); +539 } +540 } +541 return model; +542 } +543 +544 /** +545 * Reads in the specified POM and converts it to a Model. +546 * +547 * @param file the pom.xml file +548 * @return returns a +549 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM +550 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object +551 */ +552 private Model retrievePom(File file) throws AnalysisException { +553 Model model = null; +554 try { +555 final FileInputStream stream = new FileInputStream(file); +556 final InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); +557 final InputSource xml = new InputSource(reader); +558 final SAXSource source = new SAXSource(xml); +559 model = readPom(source); +560 } catch (SecurityException ex) { +561 final String msg = String.format("Unable to parse pom '%s'; invalid signature", file.getPath()); +562 LOGGER.log(Level.WARNING, msg); +563 LOGGER.log(Level.FINE, null, ex); +564 throw new AnalysisException(ex); +565 } catch (IOException ex) { +566 final String msg = String.format("Unable to parse pom '%s'(IO Exception)", file.getPath()); +567 LOGGER.log(Level.WARNING, msg); +568 LOGGER.log(Level.FINE, "", ex); +569 throw new AnalysisException(ex); +570 } catch (Throwable ex) { +571 final String msg = String.format("Unexpected error during parsing of the pom '%s'", file.getPath()); +572 LOGGER.log(Level.WARNING, msg); +573 LOGGER.log(Level.FINE, "", ex); +574 throw new AnalysisException(ex); +575 } +576 return model; +577 } +578 +579 /** +580 * Retrieves the specified POM from a jar file and converts it to a Model. +581 * +582 * @param source the SAXSource input stream to read the POM from +583 * @return returns the POM object +584 * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM +585 * {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object +586 */ +587 private Model readPom(SAXSource source) throws AnalysisException { +588 Model model = null; +589 try { +590 final XMLFilter filter = new MavenNamespaceFilter(); +591 final SAXParserFactory spf = SAXParserFactory.newInstance(); +592 final SAXParser sp = spf.newSAXParser(); +593 final XMLReader xr = sp.getXMLReader(); +594 filter.setParent(xr); +595 final JAXBElement<Model> el = pomUnmarshaller.unmarshal(source, Model.class); +596 model = el.getValue(); +597 } catch (SecurityException ex) { +598 throw new AnalysisException(ex); +599 } catch (ParserConfigurationException ex) { +600 throw new AnalysisException(ex); +601 } catch (SAXException ex) { +602 throw new AnalysisException(ex); +603 } catch (JAXBException ex) { +604 throw new AnalysisException(ex); +605 } catch (Throwable ex) { +606 throw new AnalysisException(ex); +607 } +608 return model; +609 } +610 +611 /** +612 * Sets evidence from the pom on the supplied dependency. +613 * +614 * @param dependency the dependency to set data on +615 * @param pom the information from the pom +616 * @param pomProperties the pom properties file (null if none exists) +617 * @param classes a collection of ClassNameInformation - containing data about the fully qualified class names +618 * within the JAR file being analyzed +619 * @return true if there was evidence within the pom that we could use; otherwise false +620 */ +621 private boolean setPomEvidence(Dependency dependency, Model pom, Properties pomProperties, ArrayList<ClassNameInformation> classes) { +622 boolean foundSomething = false; +623 boolean addAsIdentifier = true; +624 if (pom == null) { +625 return foundSomething; +626 } +627 String groupid = interpolateString(pom.getGroupId(), pomProperties); +628 String parentGroupId = null; +629 +630 if (pom.getParent() != null) { +631 parentGroupId = interpolateString(pom.getParent().getGroupId(), pomProperties); +632 if ((groupid == null || groupid.isEmpty()) && parentGroupId != null && !parentGroupId.isEmpty()) { +633 groupid = parentGroupId; +634 } +635 } +636 final String originalGroupID = groupid; +637 +638 if (groupid != null && !groupid.isEmpty()) { +639 foundSomething = true; +640 dependency.getVendorEvidence().addEvidence("pom", "groupid", groupid, Confidence.HIGHEST); +641 dependency.getProductEvidence().addEvidence("pom", "groupid", groupid, Confidence.LOW); +642 addMatchingValues(classes, groupid, dependency.getVendorEvidence()); +643 addMatchingValues(classes, groupid, dependency.getProductEvidence()); +644 if (parentGroupId != null && !parentGroupId.isEmpty() && !parentGroupId.equals(groupid)) { +645 dependency.getVendorEvidence().addEvidence("pom", "parent-groupid", parentGroupId, Confidence.MEDIUM); +646 dependency.getProductEvidence().addEvidence("pom", "parent-groupid", parentGroupId, Confidence.LOW); +647 addMatchingValues(classes, parentGroupId, dependency.getVendorEvidence()); +648 addMatchingValues(classes, parentGroupId, dependency.getProductEvidence()); +649 } +650 } else { +651 addAsIdentifier = false; +652 } +653 +654 String artifactid = interpolateString(pom.getArtifactId(), pomProperties); +655 String parentArtifactId = null; 656 -657 // org name -658 final Organization org = pom.getOrganization(); -659 if (org != null && org.getName() != null) { -660 foundSomething = true; -661 final String orgName = interpolateString(org.getName(), pomProperties); -662 if (orgName != null && !orgName.isEmpty()) { -663 dependency.getVendorEvidence().addEvidence("pom", "organization name", orgName, Confidence.HIGH); -664 addMatchingValues(classes, orgName, dependency.getVendorEvidence()); -665 } -666 } -667 //pom name -668 final String pomName = interpolateString(pom.getName(), pomProperties); -669 if (pomName != null && !pomName.isEmpty()) { -670 foundSomething = true; -671 dependency.getProductEvidence().addEvidence("pom", "name", pomName, Confidence.HIGH); -672 dependency.getVendorEvidence().addEvidence("pom", "name", pomName, Confidence.HIGH); -673 addMatchingValues(classes, pomName, dependency.getVendorEvidence()); -674 addMatchingValues(classes, pomName, dependency.getProductEvidence()); -675 } -676 -677 //Description -678 if (pom.getDescription() != null) { -679 foundSomething = true; -680 final String description = interpolateString(pom.getDescription(), pomProperties); -681 if (description != null && !description.isEmpty()) { -682 final String trimmedDescription = addDescription(dependency, description, "pom", "description"); -683 addMatchingValues(classes, trimmedDescription, dependency.getVendorEvidence()); -684 addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence()); -685 } -686 } -687 extractLicense(pom, pomProperties, dependency); -688 return foundSomething; -689 } -690 -691 /** -692 * Analyzes the path information of the classes contained within the JarAnalyzer to try and determine possible -693 * vendor or product names. If any are found they are stored in the packageVendor and packageProduct hashSets. -694 * -695 * @param classNames a list of class names -696 * @param dependency a dependency to analyze -697 * @param addPackagesAsEvidence a flag indicating whether or not package names should be added as evidence. -698 */ -699 protected void analyzePackageNames(ArrayList<ClassNameInformation> classNames, -700 Dependency dependency, boolean addPackagesAsEvidence) { -701 final HashMap<String, Integer> vendorIdentifiers = new HashMap<String, Integer>(); -702 final HashMap<String, Integer> productIdentifiers = new HashMap<String, Integer>(); -703 analyzeFullyQualifiedClassNames(classNames, vendorIdentifiers, productIdentifiers); -704 -705 final int classCount = classNames.size(); -706 final EvidenceCollection vendor = dependency.getVendorEvidence(); -707 final EvidenceCollection product = dependency.getProductEvidence(); -708 -709 for (Map.Entry<String, Integer> entry : vendorIdentifiers.entrySet()) { -710 final float ratio = entry.getValue() / (float) classCount; -711 if (ratio > 0.5) { -712 //TODO remove weighting -713 vendor.addWeighting(entry.getKey()); -714 if (addPackagesAsEvidence && entry.getKey().length() > 1) { -715 vendor.addEvidence("jar", "package name", entry.getKey(), Confidence.LOW); -716 } -717 } -718 } -719 for (Map.Entry<String, Integer> entry : productIdentifiers.entrySet()) { -720 final float ratio = entry.getValue() / (float) classCount; -721 if (ratio > 0.5) { -722 product.addWeighting(entry.getKey()); -723 if (addPackagesAsEvidence && entry.getKey().length() > 1) { -724 product.addEvidence("jar", "package name", entry.getKey(), Confidence.LOW); -725 } -726 } -727 } -728 } -729 -730 /** -731 * <p> -732 * Reads the manifest from the JAR file and collects the entries. Some vendorKey entries are:</p> -733 * <ul><li>Implementation Title</li> -734 * <li>Implementation Version</li> <li>Implementation Vendor</li> -735 * <li>Implementation VendorId</li> <li>Bundle Name</li> <li>Bundle Version</li> <li>Bundle Vendor</li> <li>Bundle -736 * Description</li> <li>Main Class</li> </ul> -737 * However, all but a handful of specific entries are read in. -738 * -739 * @param dependency A reference to the dependency -740 * @param classInformation a collection of class information -741 * @return whether evidence was identified parsing the manifest -742 * @throws IOException if there is an issue reading the JAR file -743 */ -744 protected boolean parseManifest(Dependency dependency, ArrayList<ClassNameInformation> classInformation) throws IOException { -745 boolean foundSomething = false; -746 JarFile jar = null; -747 try { -748 jar = new JarFile(dependency.getActualFilePath()); -749 -750 final Manifest manifest = jar.getManifest(); -751 -752 if (manifest == null) { -753 //don't log this for javadoc or sources jar files -754 if (!dependency.getFileName().toLowerCase().endsWith("-sources.jar") -755 && !dependency.getFileName().toLowerCase().endsWith("-javadoc.jar") -756 && !dependency.getFileName().toLowerCase().endsWith("-src.jar") -757 && !dependency.getFileName().toLowerCase().endsWith("-doc.jar")) { -758 LOGGER.log(Level.FINE, -759 String.format("Jar file '%s' does not contain a manifest.", -760 dependency.getFileName())); -761 } -762 return false; -763 } -764 final Attributes atts = manifest.getMainAttributes(); -765 -766 final EvidenceCollection vendorEvidence = dependency.getVendorEvidence(); -767 final EvidenceCollection productEvidence = dependency.getProductEvidence(); -768 final EvidenceCollection versionEvidence = dependency.getVersionEvidence(); -769 -770 final String source = "Manifest"; -771 -772 for (Entry<Object, Object> entry : atts.entrySet()) { -773 String key = entry.getKey().toString(); -774 String value = atts.getValue(key); -775 if (HTML_DETECTION_PATTERN.matcher(value).find()) { -776 value = Jsoup.parse(value).text(); -777 } -778 if (IGNORE_VALUES.contains(value)) { -779 continue; -780 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_TITLE.toString())) { -781 foundSomething = true; -782 productEvidence.addEvidence(source, key, value, Confidence.HIGH); -783 addMatchingValues(classInformation, value, productEvidence); -784 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_VERSION.toString())) { -785 foundSomething = true; -786 versionEvidence.addEvidence(source, key, value, Confidence.HIGH); -787 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_VENDOR.toString())) { -788 foundSomething = true; -789 vendorEvidence.addEvidence(source, key, value, Confidence.HIGH); -790 addMatchingValues(classInformation, value, vendorEvidence); -791 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_VENDOR_ID.toString())) { -792 foundSomething = true; -793 vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -794 addMatchingValues(classInformation, value, vendorEvidence); -795 } else if (key.equalsIgnoreCase(BUNDLE_DESCRIPTION)) { -796 foundSomething = true; -797 addDescription(dependency, value, "manifest", key); -798 //productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -799 addMatchingValues(classInformation, value, productEvidence); -800 } else if (key.equalsIgnoreCase(BUNDLE_NAME)) { -801 foundSomething = true; -802 productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -803 addMatchingValues(classInformation, value, productEvidence); -804 } else if (key.equalsIgnoreCase(BUNDLE_VENDOR)) { -805 foundSomething = true; -806 vendorEvidence.addEvidence(source, key, value, Confidence.HIGH); -807 addMatchingValues(classInformation, value, vendorEvidence); -808 } else if (key.equalsIgnoreCase(BUNDLE_VERSION)) { -809 foundSomething = true; -810 versionEvidence.addEvidence(source, key, value, Confidence.HIGH); -811 } else if (key.equalsIgnoreCase(Attributes.Name.MAIN_CLASS.toString())) { -812 continue; -813 //skipping main class as if this has important information to add -814 // it will be added during class name analysis... if other fields -815 // have the information from the class name then they will get added... -816 // foundSomething = true; -817 // productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -818 // vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -819 // addMatchingValues(classInformation, value, vendorEvidence); -820 // addMatchingValues(classInformation, value, productEvidence); -821 } else { -822 key = key.toLowerCase(); -823 -824 if (!IGNORE_KEYS.contains(key) -825 && !key.endsWith("jdk") -826 && !key.contains("lastmodified") -827 && !key.endsWith("package") -828 && !key.endsWith("classpath") -829 && !key.endsWith("class-path") -830 && !key.endsWith("-scm") //todo change this to a regex? -831 && !key.startsWith("scm-") -832 && !value.trim().startsWith("scm:") -833 && !isImportPackage(key, value) -834 && !isPackage(key, value)) { -835 -836 foundSomething = true; -837 if (key.contains("version")) { -838 if (key.contains("specification")) { -839 versionEvidence.addEvidence(source, key, value, Confidence.LOW); -840 } else { -841 versionEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -842 } -843 } else if ("build-id".equals(key)) { -844 int pos = value.indexOf('('); -845 if (pos >= 0) { -846 value = value.substring(0, pos - 1); -847 } -848 pos = value.indexOf('['); -849 if (pos >= 0) { -850 value = value.substring(0, pos - 1); -851 } -852 versionEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -853 } else if (key.contains("title")) { -854 productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -855 addMatchingValues(classInformation, value, productEvidence); -856 } else if (key.contains("vendor")) { -857 if (key.contains("specification")) { -858 vendorEvidence.addEvidence(source, key, value, Confidence.LOW); -859 } else { -860 vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -861 addMatchingValues(classInformation, value, vendorEvidence); -862 } -863 } else if (key.contains("name")) { -864 productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -865 vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); -866 addMatchingValues(classInformation, value, vendorEvidence); -867 addMatchingValues(classInformation, value, productEvidence); -868 } else if (key.contains("license")) { -869 addLicense(dependency, value); -870 } else { -871 if (key.contains("description")) { -872 addDescription(dependency, value, "manifest", key); -873 } else { -874 productEvidence.addEvidence(source, key, value, Confidence.LOW); -875 vendorEvidence.addEvidence(source, key, value, Confidence.LOW); -876 addMatchingValues(classInformation, value, vendorEvidence); -877 addMatchingValues(classInformation, value, productEvidence); -878 if (value.matches(".*\\d.*")) { -879 final StringTokenizer tokenizer = new StringTokenizer(value, " "); -880 while (tokenizer.hasMoreElements()) { -881 final String s = tokenizer.nextToken(); -882 if (s.matches("^[0-9.]+$")) { -883 versionEvidence.addEvidence(source, key, s, Confidence.LOW); -884 } -885 } -886 } -887 } -888 } -889 } -890 } -891 } -892 } finally { -893 if (jar != null) { -894 jar.close(); -895 } -896 } -897 return foundSomething; -898 } -899 -900 /** -901 * Adds a description to the given dependency. If the description contains one of the following strings beyond 100 -902 * characters, then the description used will be trimmed to that position: -903 * <ul><li>"such as"</li><li>"like "</li><li>"will use "</li><li>"* uses "</li></ul> -904 * -905 * @param dependency a dependency -906 * @param description the description -907 * @param source the source of the evidence -908 * @param key the "name" of the evidence -909 * @return if the description is trimmed, the trimmed version is returned; otherwise the original description is -910 * returned -911 */ -912 private String addDescription(Dependency dependency, String description, String source, String key) { -913 if (dependency.getDescription() == null) { -914 dependency.setDescription(description); -915 } -916 String desc; -917 if (HTML_DETECTION_PATTERN.matcher(description).find()) { -918 desc = Jsoup.parse(description).text(); -919 } else { -920 desc = description; -921 } -922 dependency.setDescription(desc); -923 if (desc.length() > 100) { -924 desc = desc.replaceAll("\\s\\s+", " "); -925 final int posSuchAs = desc.toLowerCase().indexOf("such as ", 100); -926 final int posLike = desc.toLowerCase().indexOf("like ", 100); -927 final int posWillUse = desc.toLowerCase().indexOf("will use ", 100); -928 final int posUses = desc.toLowerCase().indexOf(" uses ", 100); -929 int pos = -1; -930 pos = Math.max(pos, posSuchAs); -931 if (pos >= 0 && posLike >= 0) { -932 pos = Math.min(pos, posLike); -933 } else { -934 pos = Math.max(pos, posLike); -935 } -936 if (pos >= 0 && posWillUse >= 0) { -937 pos = Math.min(pos, posWillUse); -938 } else { -939 pos = Math.max(pos, posWillUse); -940 } -941 if (pos >= 0 && posUses >= 0) { -942 pos = Math.min(pos, posUses); -943 } else { -944 pos = Math.max(pos, posUses); +657 if (pom.getParent() != null) { +658 parentArtifactId = interpolateString(pom.getParent().getArtifactId(), pomProperties); +659 if ((artifactid == null || artifactid.isEmpty()) && parentArtifactId != null && !parentArtifactId.isEmpty()) { +660 artifactid = parentArtifactId; +661 } +662 } +663 final String originalArtifactID = artifactid; +664 if (artifactid != null && !artifactid.isEmpty()) { +665 if (artifactid.startsWith("org.") || artifactid.startsWith("com.")) { +666 artifactid = artifactid.substring(4); +667 } +668 foundSomething = true; +669 dependency.getProductEvidence().addEvidence("pom", "artifactid", artifactid, Confidence.HIGHEST); +670 dependency.getVendorEvidence().addEvidence("pom", "artifactid", artifactid, Confidence.LOW); +671 addMatchingValues(classes, artifactid, dependency.getVendorEvidence()); +672 addMatchingValues(classes, artifactid, dependency.getProductEvidence()); +673 if (parentArtifactId != null && !parentArtifactId.isEmpty() && !parentArtifactId.equals(artifactid)) { +674 dependency.getProductEvidence().addEvidence("pom", "parent-artifactid", parentArtifactId, Confidence.MEDIUM); +675 dependency.getVendorEvidence().addEvidence("pom", "parent-artifactid", parentArtifactId, Confidence.LOW); +676 addMatchingValues(classes, parentArtifactId, dependency.getVendorEvidence()); +677 addMatchingValues(classes, parentArtifactId, dependency.getProductEvidence()); +678 } +679 } else { +680 addAsIdentifier = false; +681 } +682 //version +683 String version = interpolateString(pom.getVersion(), pomProperties); +684 String parentVersion = null; +685 +686 if (pom.getParent() != null) { +687 parentVersion = interpolateString(pom.getParent().getVersion(), pomProperties); +688 if ((version == null || version.isEmpty()) && parentVersion != null && !parentVersion.isEmpty()) { +689 version = parentVersion; +690 } +691 } +692 +693 if (version != null && !version.isEmpty()) { +694 foundSomething = true; +695 dependency.getVersionEvidence().addEvidence("pom", "version", version, Confidence.HIGHEST); +696 if (parentVersion != null && !parentVersion.isEmpty() && !parentVersion.equals(version)) { +697 dependency.getVersionEvidence().addEvidence("pom", "parent-version", version, Confidence.LOW); +698 } +699 } else { +700 addAsIdentifier = false; +701 } +702 +703 if (addAsIdentifier) { +704 dependency.addIdentifier("maven", String.format("%s:%s:%s", originalGroupID, originalArtifactID, version), null, Confidence.LOW); +705 } +706 +707 // org name +708 final Organization org = pom.getOrganization(); +709 if (org != null && org.getName() != null) { +710 foundSomething = true; +711 final String orgName = interpolateString(org.getName(), pomProperties); +712 if (orgName != null && !orgName.isEmpty()) { +713 dependency.getVendorEvidence().addEvidence("pom", "organization name", orgName, Confidence.HIGH); +714 addMatchingValues(classes, orgName, dependency.getVendorEvidence()); +715 } +716 } +717 //pom name +718 final String pomName = interpolateString(pom.getName(), pomProperties); +719 if (pomName != null && !pomName.isEmpty()) { +720 foundSomething = true; +721 dependency.getProductEvidence().addEvidence("pom", "name", pomName, Confidence.HIGH); +722 dependency.getVendorEvidence().addEvidence("pom", "name", pomName, Confidence.HIGH); +723 addMatchingValues(classes, pomName, dependency.getVendorEvidence()); +724 addMatchingValues(classes, pomName, dependency.getProductEvidence()); +725 } +726 +727 //Description +728 if (pom.getDescription() != null) { +729 foundSomething = true; +730 final String description = interpolateString(pom.getDescription(), pomProperties); +731 if (description != null && !description.isEmpty()) { +732 final String trimmedDescription = addDescription(dependency, description, "pom", "description"); +733 addMatchingValues(classes, trimmedDescription, dependency.getVendorEvidence()); +734 addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence()); +735 } +736 } +737 extractLicense(pom, pomProperties, dependency); +738 return foundSomething; +739 } +740 +741 /** +742 * Analyzes the path information of the classes contained within the JarAnalyzer to try and determine possible +743 * vendor or product names. If any are found they are stored in the packageVendor and packageProduct hashSets. +744 * +745 * @param classNames a list of class names +746 * @param dependency a dependency to analyze +747 * @param addPackagesAsEvidence a flag indicating whether or not package names should be added as evidence. +748 */ +749 protected void analyzePackageNames(ArrayList<ClassNameInformation> classNames, +750 Dependency dependency, boolean addPackagesAsEvidence) { +751 final HashMap<String, Integer> vendorIdentifiers = new HashMap<String, Integer>(); +752 final HashMap<String, Integer> productIdentifiers = new HashMap<String, Integer>(); +753 analyzeFullyQualifiedClassNames(classNames, vendorIdentifiers, productIdentifiers); +754 +755 final int classCount = classNames.size(); +756 final EvidenceCollection vendor = dependency.getVendorEvidence(); +757 final EvidenceCollection product = dependency.getProductEvidence(); +758 +759 for (Map.Entry<String, Integer> entry : vendorIdentifiers.entrySet()) { +760 final float ratio = entry.getValue() / (float) classCount; +761 if (ratio > 0.5) { +762 //TODO remove weighting +763 vendor.addWeighting(entry.getKey()); +764 if (addPackagesAsEvidence && entry.getKey().length() > 1) { +765 vendor.addEvidence("jar", "package name", entry.getKey(), Confidence.LOW); +766 } +767 } +768 } +769 for (Map.Entry<String, Integer> entry : productIdentifiers.entrySet()) { +770 final float ratio = entry.getValue() / (float) classCount; +771 if (ratio > 0.5) { +772 product.addWeighting(entry.getKey()); +773 if (addPackagesAsEvidence && entry.getKey().length() > 1) { +774 product.addEvidence("jar", "package name", entry.getKey(), Confidence.LOW); +775 } +776 } +777 } +778 } +779 +780 /** +781 * <p> +782 * Reads the manifest from the JAR file and collects the entries. Some vendorKey entries are:</p> +783 * <ul><li>Implementation Title</li> +784 * <li>Implementation Version</li> <li>Implementation Vendor</li> +785 * <li>Implementation VendorId</li> <li>Bundle Name</li> <li>Bundle Version</li> <li>Bundle Vendor</li> <li>Bundle +786 * Description</li> <li>Main Class</li> </ul> +787 * However, all but a handful of specific entries are read in. +788 * +789 * @param dependency A reference to the dependency +790 * @param classInformation a collection of class information +791 * @return whether evidence was identified parsing the manifest +792 * @throws IOException if there is an issue reading the JAR file +793 */ +794 protected boolean parseManifest(Dependency dependency, ArrayList<ClassNameInformation> classInformation) throws IOException { +795 boolean foundSomething = false; +796 JarFile jar = null; +797 try { +798 jar = new JarFile(dependency.getActualFilePath()); +799 +800 final Manifest manifest = jar.getManifest(); +801 +802 if (manifest == null) { +803 //don't log this for javadoc or sources jar files +804 if (!dependency.getFileName().toLowerCase().endsWith("-sources.jar") +805 && !dependency.getFileName().toLowerCase().endsWith("-javadoc.jar") +806 && !dependency.getFileName().toLowerCase().endsWith("-src.jar") +807 && !dependency.getFileName().toLowerCase().endsWith("-doc.jar")) { +808 LOGGER.log(Level.FINE, +809 String.format("Jar file '%s' does not contain a manifest.", +810 dependency.getFileName())); +811 } +812 return false; +813 } +814 final Attributes atts = manifest.getMainAttributes(); +815 +816 final EvidenceCollection vendorEvidence = dependency.getVendorEvidence(); +817 final EvidenceCollection productEvidence = dependency.getProductEvidence(); +818 final EvidenceCollection versionEvidence = dependency.getVersionEvidence(); +819 +820 final String source = "Manifest"; +821 +822 for (Entry<Object, Object> entry : atts.entrySet()) { +823 String key = entry.getKey().toString(); +824 String value = atts.getValue(key); +825 if (HTML_DETECTION_PATTERN.matcher(value).find()) { +826 value = Jsoup.parse(value).text(); +827 } +828 if (IGNORE_VALUES.contains(value)) { +829 continue; +830 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_TITLE.toString())) { +831 foundSomething = true; +832 productEvidence.addEvidence(source, key, value, Confidence.HIGH); +833 addMatchingValues(classInformation, value, productEvidence); +834 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_VERSION.toString())) { +835 foundSomething = true; +836 versionEvidence.addEvidence(source, key, value, Confidence.HIGH); +837 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_VENDOR.toString())) { +838 foundSomething = true; +839 vendorEvidence.addEvidence(source, key, value, Confidence.HIGH); +840 addMatchingValues(classInformation, value, vendorEvidence); +841 } else if (key.equalsIgnoreCase(Attributes.Name.IMPLEMENTATION_VENDOR_ID.toString())) { +842 foundSomething = true; +843 vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +844 addMatchingValues(classInformation, value, vendorEvidence); +845 } else if (key.equalsIgnoreCase(BUNDLE_DESCRIPTION)) { +846 foundSomething = true; +847 addDescription(dependency, value, "manifest", key); +848 //productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +849 addMatchingValues(classInformation, value, productEvidence); +850 } else if (key.equalsIgnoreCase(BUNDLE_NAME)) { +851 foundSomething = true; +852 productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +853 addMatchingValues(classInformation, value, productEvidence); +854 } else if (key.equalsIgnoreCase(BUNDLE_VENDOR)) { +855 foundSomething = true; +856 vendorEvidence.addEvidence(source, key, value, Confidence.HIGH); +857 addMatchingValues(classInformation, value, vendorEvidence); +858 } else if (key.equalsIgnoreCase(BUNDLE_VERSION)) { +859 foundSomething = true; +860 versionEvidence.addEvidence(source, key, value, Confidence.HIGH); +861 } else if (key.equalsIgnoreCase(Attributes.Name.MAIN_CLASS.toString())) { +862 continue; +863 //skipping main class as if this has important information to add +864 // it will be added during class name analysis... if other fields +865 // have the information from the class name then they will get added... +866 // foundSomething = true; +867 // productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +868 // vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +869 // addMatchingValues(classInformation, value, vendorEvidence); +870 // addMatchingValues(classInformation, value, productEvidence); +871 } else { +872 key = key.toLowerCase(); +873 +874 if (!IGNORE_KEYS.contains(key) +875 && !key.endsWith("jdk") +876 && !key.contains("lastmodified") +877 && !key.endsWith("package") +878 && !key.endsWith("classpath") +879 && !key.endsWith("class-path") +880 && !key.endsWith("-scm") //todo change this to a regex? +881 && !key.startsWith("scm-") +882 && !value.trim().startsWith("scm:") +883 && !isImportPackage(key, value) +884 && !isPackage(key, value)) { +885 +886 foundSomething = true; +887 if (key.contains("version")) { +888 if (key.contains("specification")) { +889 versionEvidence.addEvidence(source, key, value, Confidence.LOW); +890 } else { +891 versionEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +892 } +893 } else if ("build-id".equals(key)) { +894 int pos = value.indexOf('('); +895 if (pos >= 0) { +896 value = value.substring(0, pos - 1); +897 } +898 pos = value.indexOf('['); +899 if (pos >= 0) { +900 value = value.substring(0, pos - 1); +901 } +902 versionEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +903 } else if (key.contains("title")) { +904 productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +905 addMatchingValues(classInformation, value, productEvidence); +906 } else if (key.contains("vendor")) { +907 if (key.contains("specification")) { +908 vendorEvidence.addEvidence(source, key, value, Confidence.LOW); +909 } else { +910 vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +911 addMatchingValues(classInformation, value, vendorEvidence); +912 } +913 } else if (key.contains("name")) { +914 productEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +915 vendorEvidence.addEvidence(source, key, value, Confidence.MEDIUM); +916 addMatchingValues(classInformation, value, vendorEvidence); +917 addMatchingValues(classInformation, value, productEvidence); +918 } else if (key.contains("license")) { +919 addLicense(dependency, value); +920 } else { +921 if (key.contains("description")) { +922 addDescription(dependency, value, "manifest", key); +923 } else { +924 productEvidence.addEvidence(source, key, value, Confidence.LOW); +925 vendorEvidence.addEvidence(source, key, value, Confidence.LOW); +926 addMatchingValues(classInformation, value, vendorEvidence); +927 addMatchingValues(classInformation, value, productEvidence); +928 if (value.matches(".*\\d.*")) { +929 final StringTokenizer tokenizer = new StringTokenizer(value, " "); +930 while (tokenizer.hasMoreElements()) { +931 final String s = tokenizer.nextToken(); +932 if (s.matches("^[0-9.]+$")) { +933 versionEvidence.addEvidence(source, key, s, Confidence.LOW); +934 } +935 } +936 } +937 } +938 } +939 } +940 } +941 } +942 } finally { +943 if (jar != null) { +944 jar.close(); 945 } -946 -947 if (pos > 0) { -948 final StringBuilder sb = new StringBuilder(pos + 3); -949 sb.append(desc.substring(0, pos)); -950 sb.append("..."); -951 desc = sb.toString(); -952 } -953 dependency.getProductEvidence().addEvidence(source, key, desc, Confidence.LOW); -954 dependency.getVendorEvidence().addEvidence(source, key, desc, Confidence.LOW); -955 } else { -956 dependency.getProductEvidence().addEvidence(source, key, desc, Confidence.MEDIUM); -957 dependency.getVendorEvidence().addEvidence(source, key, desc, Confidence.MEDIUM); -958 } -959 return desc; -960 } -961 -962 /** -963 * Adds a license to the given dependency. -964 * -965 * @param d a dependency -966 * @param license the license -967 */ -968 private void addLicense(Dependency d, String license) { -969 if (d.getLicense() == null) { -970 d.setLicense(license); -971 } else if (!d.getLicense().contains(license)) { -972 d.setLicense(d.getLicense() + NEWLINE + license); -973 } -974 } -975 -976 /** -977 * The parent directory for the individual directories per archive. -978 */ -979 private File tempFileLocation = null; -980 -981 /** -982 * Initializes the JarAnalyzer. -983 * -984 * @throws Exception is thrown if there is an exception creating a temporary directory -985 */ -986 @Override -987 public void initializeFileTypeAnalyzer() throws Exception { -988 final File baseDir = Settings.getTempDirectory(); -989 tempFileLocation = File.createTempFile("check", "tmp", baseDir); -990 if (!tempFileLocation.delete()) { -991 final String msg = String.format("Unable to delete temporary file '%s'.", tempFileLocation.getAbsolutePath()); -992 throw new AnalysisException(msg); -993 } -994 if (!tempFileLocation.mkdirs()) { -995 final String msg = String.format("Unable to create directory '%s'.", tempFileLocation.getAbsolutePath()); -996 throw new AnalysisException(msg); -997 } -998 } -999 -1000 /** -1001 * Deletes any files extracted from the JAR during analysis. -1002 */ -1003 @Override -1004 public void close() { -1005 if (tempFileLocation != null && tempFileLocation.exists()) { -1006 LOGGER.log(Level.FINE, "Attempting to delete temporary files"); -1007 final boolean success = FileUtils.delete(tempFileLocation); -1008 if (!success) { -1009 LOGGER.log(Level.WARNING, -1010 "Failed to delete some temporary files, see the log for more details"); -1011 } -1012 } -1013 } -1014 -1015 /** -1016 * <p> -1017 * A utility function that will interpolate strings based on values given in the properties file. It will also -1018 * interpolate the strings contained within the properties file so that properties can reference other -1019 * properties.</p> -1020 * <p> -1021 * <b>Note:</b> if there is no property found the reference will be removed. In other words, if the interpolated -1022 * string will be replaced with an empty string. -1023 * </p> -1024 * <p> -1025 * Example:</p> -1026 * <code> -1027 * Properties p = new Properties(); -1028 * p.setProperty("key", "value"); -1029 * String s = interpolateString("'${key}' and '${nothing}'", p); -1030 * System.out.println(s); -1031 * </code> -1032 * <p> -1033 * Will result in:</p> -1034 * <code> -1035 * 'value' and '' -1036 * </code> -1037 * -1038 * @param text the string that contains references to properties. -1039 * @param properties a collection of properties that may be referenced within the text. -1040 * @return the interpolated text. -1041 */ -1042 protected String interpolateString(String text, Properties properties) { -1043 Properties props = properties; -1044 if (text == null) { -1045 return text; -1046 } -1047 if (props == null) { -1048 props = new Properties(); -1049 } -1050 -1051 final int pos = text.indexOf("${"); -1052 if (pos < 0) { -1053 return text; -1054 } -1055 final int end = text.indexOf("}"); -1056 if (end < pos) { -1057 return text; -1058 } -1059 -1060 final String propName = text.substring(pos + 2, end); -1061 String propValue = interpolateString(props.getProperty(propName), props); -1062 if (propValue == null) { -1063 propValue = ""; -1064 } -1065 final StringBuilder sb = new StringBuilder(propValue.length() + text.length()); -1066 sb.append(text.subSequence(0, pos)); -1067 sb.append(propValue); -1068 sb.append(text.substring(end + 1)); -1069 return interpolateString(sb.toString(), props); //yes yes, this should be a loop... -1070 } -1071 -1072 /** -1073 * Determines if the key value pair from the manifest is for an "import" type entry for package names. -1074 * -1075 * @param key the key from the manifest -1076 * @param value the value from the manifest -1077 * @return true or false depending on if it is believed the entry is an "import" entry -1078 */ -1079 private boolean isImportPackage(String key, String value) { -1080 final Pattern packageRx = Pattern.compile("^([a-zA-Z0-9_#\\$\\*\\.]+\\s*[,;]\\s*)+([a-zA-Z0-9_#\\$\\*\\.]+\\s*)?$"); -1081 final boolean matches = packageRx.matcher(value).matches(); -1082 return matches && (key.contains("import") || key.contains("include") || value.length() > 10); -1083 } -1084 -1085 /** -1086 * Cycles through an enumeration of JarEntries, contained within the dependency, and returns a list of the class -1087 * names. This does not include core Java package names (i.e. java.* or javax.*). -1088 * -1089 * @param dependency the dependency being analyzed -1090 * @return an list of fully qualified class names +946 } +947 return foundSomething; +948 } +949 +950 /** +951 * Adds a description to the given dependency. If the description contains one of the following strings beyond 100 +952 * characters, then the description used will be trimmed to that position: +953 * <ul><li>"such as"</li><li>"like "</li><li>"will use "</li><li>"* uses "</li></ul> +954 * +955 * @param dependency a dependency +956 * @param description the description +957 * @param source the source of the evidence +958 * @param key the "name" of the evidence +959 * @return if the description is trimmed, the trimmed version is returned; otherwise the original description is +960 * returned +961 */ +962 private String addDescription(Dependency dependency, String description, String source, String key) { +963 if (dependency.getDescription() == null) { +964 dependency.setDescription(description); +965 } +966 String desc; +967 if (HTML_DETECTION_PATTERN.matcher(description).find()) { +968 desc = Jsoup.parse(description).text(); +969 } else { +970 desc = description; +971 } +972 dependency.setDescription(desc); +973 if (desc.length() > 100) { +974 desc = desc.replaceAll("\\s\\s+", " "); +975 final int posSuchAs = desc.toLowerCase().indexOf("such as ", 100); +976 final int posLike = desc.toLowerCase().indexOf("like ", 100); +977 final int posWillUse = desc.toLowerCase().indexOf("will use ", 100); +978 final int posUses = desc.toLowerCase().indexOf(" uses ", 100); +979 int pos = -1; +980 pos = Math.max(pos, posSuchAs); +981 if (pos >= 0 && posLike >= 0) { +982 pos = Math.min(pos, posLike); +983 } else { +984 pos = Math.max(pos, posLike); +985 } +986 if (pos >= 0 && posWillUse >= 0) { +987 pos = Math.min(pos, posWillUse); +988 } else { +989 pos = Math.max(pos, posWillUse); +990 } +991 if (pos >= 0 && posUses >= 0) { +992 pos = Math.min(pos, posUses); +993 } else { +994 pos = Math.max(pos, posUses); +995 } +996 +997 if (pos > 0) { +998 final StringBuilder sb = new StringBuilder(pos + 3); +999 sb.append(desc.substring(0, pos)); +1000 sb.append("..."); +1001 desc = sb.toString(); +1002 } +1003 dependency.getProductEvidence().addEvidence(source, key, desc, Confidence.LOW); +1004 dependency.getVendorEvidence().addEvidence(source, key, desc, Confidence.LOW); +1005 } else { +1006 dependency.getProductEvidence().addEvidence(source, key, desc, Confidence.MEDIUM); +1007 dependency.getVendorEvidence().addEvidence(source, key, desc, Confidence.MEDIUM); +1008 } +1009 return desc; +1010 } +1011 +1012 /** +1013 * Adds a license to the given dependency. +1014 * +1015 * @param d a dependency +1016 * @param license the license +1017 */ +1018 private void addLicense(Dependency d, String license) { +1019 if (d.getLicense() == null) { +1020 d.setLicense(license); +1021 } else if (!d.getLicense().contains(license)) { +1022 d.setLicense(d.getLicense() + NEWLINE + license); +1023 } +1024 } +1025 +1026 /** +1027 * The parent directory for the individual directories per archive. +1028 */ +1029 private File tempFileLocation = null; +1030 +1031 /** +1032 * Initializes the JarAnalyzer. +1033 * +1034 * @throws Exception is thrown if there is an exception creating a temporary directory +1035 */ +1036 @Override +1037 public void initializeFileTypeAnalyzer() throws Exception { +1038 final File baseDir = Settings.getTempDirectory(); +1039 tempFileLocation = File.createTempFile("check", "tmp", baseDir); +1040 if (!tempFileLocation.delete()) { +1041 final String msg = String.format("Unable to delete temporary file '%s'.", tempFileLocation.getAbsolutePath()); +1042 throw new AnalysisException(msg); +1043 } +1044 if (!tempFileLocation.mkdirs()) { +1045 final String msg = String.format("Unable to create directory '%s'.", tempFileLocation.getAbsolutePath()); +1046 throw new AnalysisException(msg); +1047 } +1048 } +1049 +1050 /** +1051 * Deletes any files extracted from the JAR during analysis. +1052 */ +1053 @Override +1054 public void close() { +1055 if (tempFileLocation != null && tempFileLocation.exists()) { +1056 LOGGER.log(Level.FINE, "Attempting to delete temporary files"); +1057 final boolean success = FileUtils.delete(tempFileLocation); +1058 if (!success) { +1059 LOGGER.log(Level.WARNING, +1060 "Failed to delete some temporary files, see the log for more details"); +1061 } +1062 } +1063 } +1064 +1065 /** +1066 * <p> +1067 * A utility function that will interpolate strings based on values given in the properties file. It will also +1068 * interpolate the strings contained within the properties file so that properties can reference other +1069 * properties.</p> +1070 * <p> +1071 * <b>Note:</b> if there is no property found the reference will be removed. In other words, if the interpolated +1072 * string will be replaced with an empty string. +1073 * </p> +1074 * <p> +1075 * Example:</p> +1076 * <code> +1077 * Properties p = new Properties(); +1078 * p.setProperty("key", "value"); +1079 * String s = interpolateString("'${key}' and '${nothing}'", p); +1080 * System.out.println(s); +1081 * </code> +1082 * <p> +1083 * Will result in:</p> +1084 * <code> +1085 * 'value' and '' +1086 * </code> +1087 * +1088 * @param text the string that contains references to properties. +1089 * @param properties a collection of properties that may be referenced within the text. +1090 * @return the interpolated text. 1091 */ -1092 private ArrayList<ClassNameInformation> collectClassNames(Dependency dependency) { -1093 final ArrayList<ClassNameInformation> classNames = new ArrayList<ClassNameInformation>(); -1094 JarFile jar = null; -1095 try { -1096 jar = new JarFile(dependency.getActualFilePath()); -1097 final Enumeration entries = jar.entries(); -1098 while (entries.hasMoreElements()) { -1099 final JarEntry entry = (JarEntry) entries.nextElement(); -1100 final String name = entry.getName().toLowerCase(); -1101 //no longer stripping "|com\\.sun" - there are some com.sun jar files with CVEs. -1102 if (name.endsWith(".class") && !name.matches("^javax?\\..*$")) { -1103 final ClassNameInformation className = new ClassNameInformation(name.substring(0, name.length() - 6)); -1104 classNames.add(className); -1105 } -1106 } -1107 } catch (IOException ex) { -1108 final String msg = String.format("Unable to open jar file '%s'.", dependency.getFileName()); -1109 LOGGER.log(Level.WARNING, msg); -1110 LOGGER.log(Level.FINE, null, ex); -1111 } finally { -1112 if (jar != null) { -1113 try { -1114 jar.close(); -1115 } catch (IOException ex) { -1116 LOGGER.log(Level.FINEST, null, ex); -1117 } -1118 } -1119 } -1120 return classNames; -1121 } -1122 -1123 /** -1124 * Cycles through the list of class names and places the package levels 0-3 into the provided maps for vendor and -1125 * product. This is helpful when analyzing vendor/product as many times this is included in the package name. -1126 * -1127 * @param classNames a list of class names -1128 * @param vendor HashMap of possible vendor names from package names (e.g. owasp) -1129 * @param product HashMap of possible product names from package names (e.g. dependencycheck) -1130 */ -1131 private void analyzeFullyQualifiedClassNames(ArrayList<ClassNameInformation> classNames, -1132 HashMap<String, Integer> vendor, HashMap<String, Integer> product) { -1133 for (ClassNameInformation entry : classNames) { -1134 final ArrayList<String> list = entry.getPackageStructure(); -1135 addEntry(vendor, list.get(0)); -1136 -1137 if (list.size() == 2) { -1138 addEntry(product, list.get(1)); -1139 } -1140 if (list.size() == 3) { -1141 addEntry(vendor, list.get(1)); -1142 addEntry(product, list.get(1)); -1143 addEntry(product, list.get(2)); -1144 } -1145 if (list.size() >= 4) { -1146 addEntry(vendor, list.get(1)); -1147 addEntry(vendor, list.get(2)); -1148 addEntry(product, list.get(1)); -1149 addEntry(product, list.get(2)); -1150 addEntry(product, list.get(3)); -1151 } -1152 } -1153 } -1154 -1155 /** -1156 * Adds an entry to the specified collection and sets the Integer (e.g. the count) to 1. If the entry already exists -1157 * in the collection then the Integer is incremented by 1. -1158 * -1159 * @param collection a collection of strings and their occurrence count -1160 * @param key the key to add to the collection -1161 */ -1162 private void addEntry(HashMap<String, Integer> collection, String key) { -1163 if (collection.containsKey(key)) { -1164 collection.put(key, collection.get(key) + 1); -1165 } else { -1166 collection.put(key, 1); -1167 } -1168 } -1169 -1170 /** -1171 * Cycles through the collection of class name information to see if parts of the package names are contained in the -1172 * provided value. If found, it will be added as the HIGHEST confidence evidence because we have more then one -1173 * source corroborating the value. -1174 * -1175 * @param classes a collection of class name information -1176 * @param value the value to check to see if it contains a package name -1177 * @param evidence the evidence collection to add new entries too -1178 */ -1179 private void addMatchingValues(ArrayList<ClassNameInformation> classes, String value, EvidenceCollection evidence) { -1180 if (value == null || value.isEmpty() || classes == null || classes.isEmpty()) { -1181 return; -1182 } -1183 final String text = value.toLowerCase(); -1184 for (ClassNameInformation cni : classes) { -1185 for (String key : cni.getPackageStructure()) { -1186 if (text.contains(key)) { //note, package structure elements are already lowercase. -1187 evidence.addEvidence("jar", "package name", key, Confidence.HIGHEST); -1188 } +1092 protected String interpolateString(String text, Properties properties) { +1093 Properties props = properties; +1094 if (text == null) { +1095 return text; +1096 } +1097 if (props == null) { +1098 props = new Properties(); +1099 } +1100 +1101 final int pos = text.indexOf("${"); +1102 if (pos < 0) { +1103 return text; +1104 } +1105 final int end = text.indexOf("}"); +1106 if (end < pos) { +1107 return text; +1108 } +1109 +1110 final String propName = text.substring(pos + 2, end); +1111 String propValue = interpolateString(props.getProperty(propName), props); +1112 if (propValue == null) { +1113 propValue = ""; +1114 } +1115 final StringBuilder sb = new StringBuilder(propValue.length() + text.length()); +1116 sb.append(text.subSequence(0, pos)); +1117 sb.append(propValue); +1118 sb.append(text.substring(end + 1)); +1119 return interpolateString(sb.toString(), props); //yes yes, this should be a loop... +1120 } +1121 +1122 /** +1123 * Determines if the key value pair from the manifest is for an "import" type entry for package names. +1124 * +1125 * @param key the key from the manifest +1126 * @param value the value from the manifest +1127 * @return true or false depending on if it is believed the entry is an "import" entry +1128 */ +1129 private boolean isImportPackage(String key, String value) { +1130 final Pattern packageRx = Pattern.compile("^([a-zA-Z0-9_#\\$\\*\\.]+\\s*[,;]\\s*)+([a-zA-Z0-9_#\\$\\*\\.]+\\s*)?$"); +1131 final boolean matches = packageRx.matcher(value).matches(); +1132 return matches && (key.contains("import") || key.contains("include") || value.length() > 10); +1133 } +1134 +1135 /** +1136 * Cycles through an enumeration of JarEntries, contained within the dependency, and returns a list of the class +1137 * names. This does not include core Java package names (i.e. java.* or javax.*). +1138 * +1139 * @param dependency the dependency being analyzed +1140 * @return an list of fully qualified class names +1141 */ +1142 private ArrayList<ClassNameInformation> collectClassNames(Dependency dependency) { +1143 final ArrayList<ClassNameInformation> classNames = new ArrayList<ClassNameInformation>(); +1144 JarFile jar = null; +1145 try { +1146 jar = new JarFile(dependency.getActualFilePath()); +1147 final Enumeration entries = jar.entries(); +1148 while (entries.hasMoreElements()) { +1149 final JarEntry entry = (JarEntry) entries.nextElement(); +1150 final String name = entry.getName().toLowerCase(); +1151 //no longer stripping "|com\\.sun" - there are some com.sun jar files with CVEs. +1152 if (name.endsWith(".class") && !name.matches("^javax?\\..*$")) { +1153 final ClassNameInformation className = new ClassNameInformation(name.substring(0, name.length() - 6)); +1154 classNames.add(className); +1155 } +1156 } +1157 } catch (IOException ex) { +1158 final String msg = String.format("Unable to open jar file '%s'.", dependency.getFileName()); +1159 LOGGER.log(Level.WARNING, msg); +1160 LOGGER.log(Level.FINE, null, ex); +1161 } finally { +1162 if (jar != null) { +1163 try { +1164 jar.close(); +1165 } catch (IOException ex) { +1166 LOGGER.log(Level.FINEST, null, ex); +1167 } +1168 } +1169 } +1170 return classNames; +1171 } +1172 +1173 /** +1174 * Cycles through the list of class names and places the package levels 0-3 into the provided maps for vendor and +1175 * product. This is helpful when analyzing vendor/product as many times this is included in the package name. +1176 * +1177 * @param classNames a list of class names +1178 * @param vendor HashMap of possible vendor names from package names (e.g. owasp) +1179 * @param product HashMap of possible product names from package names (e.g. dependencycheck) +1180 */ +1181 private void analyzeFullyQualifiedClassNames(ArrayList<ClassNameInformation> classNames, +1182 HashMap<String, Integer> vendor, HashMap<String, Integer> product) { +1183 for (ClassNameInformation entry : classNames) { +1184 final ArrayList<String> list = entry.getPackageStructure(); +1185 addEntry(vendor, list.get(0)); +1186 +1187 if (list.size() == 2) { +1188 addEntry(product, list.get(1)); 1189 } -1190 } -1191 } -1192 -1193 /** -1194 * Simple check to see if the attribute from a manifest is just a package name. -1195 * -1196 * @param key the key of the value to check -1197 * @param value the value to check -1198 * @return true if the value looks like a java package name, otherwise false -1199 */ -1200 private boolean isPackage(String key, String value) { -1201 -1202 return !key.matches(".*(version|title|vendor|name|license|description).*") -1203 && value.matches("^([a-zA-Z_][a-zA-Z0-9_\\$]*(\\.[a-zA-Z_][a-zA-Z0-9_\\$]*)*)?$"); +1190 if (list.size() == 3) { +1191 addEntry(vendor, list.get(1)); +1192 addEntry(product, list.get(1)); +1193 addEntry(product, list.get(2)); +1194 } +1195 if (list.size() >= 4) { +1196 addEntry(vendor, list.get(1)); +1197 addEntry(vendor, list.get(2)); +1198 addEntry(product, list.get(1)); +1199 addEntry(product, list.get(2)); +1200 addEntry(product, list.get(3)); +1201 } +1202 } +1203 } 1204 -1205 } -1206 -1207 /** -1208 * Extracts the license information from the pom and adds it to the dependency. -1209 * -1210 * @param pom the pom object -1211 * @param pomProperties the properties, used for string interpolation -1212 * @param dependency the dependency to add license information too -1213 */ -1214 private void extractLicense(Model pom, Properties pomProperties, Dependency dependency) { -1215 //license -1216 if (pom.getLicenses() != null) { -1217 String license = null; -1218 for (License lic : pom.getLicenses().getLicense()) { -1219 String tmp = null; -1220 if (lic.getName() != null) { -1221 tmp = interpolateString(lic.getName(), pomProperties); -1222 } -1223 if (lic.getUrl() != null) { -1224 if (tmp == null) { -1225 tmp = interpolateString(lic.getUrl(), pomProperties); -1226 } else { -1227 tmp += ": " + interpolateString(lic.getUrl(), pomProperties); -1228 } -1229 } -1230 if (tmp == null) { -1231 continue; -1232 } -1233 if (HTML_DETECTION_PATTERN.matcher(tmp).find()) { -1234 tmp = Jsoup.parse(tmp).text(); -1235 } -1236 if (license == null) { -1237 license = tmp; -1238 } else { -1239 license += "\n" + tmp; -1240 } -1241 } -1242 if (license != null) { -1243 dependency.setLicense(license); -1244 } -1245 } -1246 } -1247 -1248 /** -1249 * Stores information about a class name. -1250 */ -1251 protected static class ClassNameInformation { -1252 -1253 /** -1254 * <p> -1255 * Stores information about a given class name. This class will keep the fully qualified class name and a list -1256 * of the important parts of the package structure. Up to the first four levels of the package structure are -1257 * stored, excluding a leading "org" or "com". Example:</p> -1258 * <code>ClassNameInformation obj = new ClassNameInformation("org.owasp.dependencycheck.analyzer.JarAnalyzer"); -1259 * System.out.println(obj.getName()); -1260 * for (String p : obj.getPackageStructure()) -1261 * System.out.println(p); -1262 * </code> -1263 * <p> -1264 * Would result in:</p> -1265 * <code>org.owasp.dependencycheck.analyzer.JarAnalyzer -1266 * owasp -1267 * dependencycheck -1268 * analyzer -1269 * jaranalyzer</code> -1270 * -1271 * @param className a fully qualified class name -1272 */ -1273 ClassNameInformation(String className) { -1274 name = className; -1275 if (name.contains("/")) { -1276 final String[] tmp = className.toLowerCase().split("/"); -1277 int start = 0; -1278 int end = 3; -1279 if ("com".equals(tmp[0]) || "org".equals(tmp[0])) { -1280 start = 1; -1281 end = 4; +1205 /** +1206 * Adds an entry to the specified collection and sets the Integer (e.g. the count) to 1. If the entry already exists +1207 * in the collection then the Integer is incremented by 1. +1208 * +1209 * @param collection a collection of strings and their occurrence count +1210 * @param key the key to add to the collection +1211 */ +1212 private void addEntry(HashMap<String, Integer> collection, String key) { +1213 if (collection.containsKey(key)) { +1214 collection.put(key, collection.get(key) + 1); +1215 } else { +1216 collection.put(key, 1); +1217 } +1218 } +1219 +1220 /** +1221 * Cycles through the collection of class name information to see if parts of the package names are contained in the +1222 * provided value. If found, it will be added as the HIGHEST confidence evidence because we have more then one +1223 * source corroborating the value. +1224 * +1225 * @param classes a collection of class name information +1226 * @param value the value to check to see if it contains a package name +1227 * @param evidence the evidence collection to add new entries too +1228 */ +1229 private void addMatchingValues(ArrayList<ClassNameInformation> classes, String value, EvidenceCollection evidence) { +1230 if (value == null || value.isEmpty() || classes == null || classes.isEmpty()) { +1231 return; +1232 } +1233 final String text = value.toLowerCase(); +1234 for (ClassNameInformation cni : classes) { +1235 for (String key : cni.getPackageStructure()) { +1236 if (text.contains(key)) { //note, package structure elements are already lowercase. +1237 evidence.addEvidence("jar", "package name", key, Confidence.HIGHEST); +1238 } +1239 } +1240 } +1241 } +1242 +1243 /** +1244 * Simple check to see if the attribute from a manifest is just a package name. +1245 * +1246 * @param key the key of the value to check +1247 * @param value the value to check +1248 * @return true if the value looks like a java package name, otherwise false +1249 */ +1250 private boolean isPackage(String key, String value) { +1251 +1252 return !key.matches(".*(version|title|vendor|name|license|description).*") +1253 && value.matches("^([a-zA-Z_][a-zA-Z0-9_\\$]*(\\.[a-zA-Z_][a-zA-Z0-9_\\$]*)*)?$"); +1254 +1255 } +1256 +1257 /** +1258 * Extracts the license information from the pom and adds it to the dependency. +1259 * +1260 * @param pom the pom object +1261 * @param pomProperties the properties, used for string interpolation +1262 * @param dependency the dependency to add license information too +1263 */ +1264 private void extractLicense(Model pom, Properties pomProperties, Dependency dependency) { +1265 //license +1266 if (pom.getLicenses() != null) { +1267 String license = null; +1268 for (License lic : pom.getLicenses().getLicense()) { +1269 String tmp = null; +1270 if (lic.getName() != null) { +1271 tmp = interpolateString(lic.getName(), pomProperties); +1272 } +1273 if (lic.getUrl() != null) { +1274 if (tmp == null) { +1275 tmp = interpolateString(lic.getUrl(), pomProperties); +1276 } else { +1277 tmp += ": " + interpolateString(lic.getUrl(), pomProperties); +1278 } +1279 } +1280 if (tmp == null) { +1281 continue; 1282 } -1283 if (tmp.length <= end) { -1284 end = tmp.length - 1; +1283 if (HTML_DETECTION_PATTERN.matcher(tmp).find()) { +1284 tmp = Jsoup.parse(tmp).text(); 1285 } -1286 for (int i = start; i <= end; i++) { -1287 packageStructure.add(tmp[i]); -1288 } -1289 } else { -1290 packageStructure.add(name); +1286 if (license == null) { +1287 license = tmp; +1288 } else { +1289 license += "\n" + tmp; +1290 } 1291 } -1292 } -1293 /** -1294 * The fully qualified class name. -1295 */ -1296 private String name; +1292 if (license != null) { +1293 dependency.setLicense(license); +1294 } +1295 } +1296 } 1297 -1298 /** -1299 * Get the value of name -1300 * -1301 * @return the value of name -1302 */ -1303 public String getName() { -1304 return name; -1305 } -1306 -1307 /** -1308 * Set the value of name -1309 * -1310 * @param name new value of name -1311 */ -1312 public void setName(String name) { -1313 this.name = name; -1314 } -1315 /** -1316 * Up to the first four levels of the package structure, excluding a leading "org" or "com". -1317 */ -1318 private final ArrayList<String> packageStructure = new ArrayList<String>(); -1319 -1320 /** -1321 * Get the value of packageStructure -1322 * -1323 * @return the value of packageStructure -1324 */ -1325 public ArrayList<String> getPackageStructure() { -1326 return packageStructure; -1327 } -1328 } -1329 -1330 /** -1331 * Retrieves the next temporary directory to extract an archive too. -1332 * -1333 * @return a directory -1334 * @throws AnalysisException thrown if unable to create temporary directory -1335 */ -1336 private File getNextTempDirectory() throws AnalysisException { -1337 dirCount += 1; -1338 final File directory = new File(tempFileLocation, String.valueOf(dirCount)); -1339 //getting an exception for some directories not being able to be created; might be because the directory already exists? -1340 if (directory.exists()) { -1341 return getNextTempDirectory(); +1298 /** +1299 * Stores information about a class name. +1300 */ +1301 protected static class ClassNameInformation { +1302 +1303 /** +1304 * <p> +1305 * Stores information about a given class name. This class will keep the fully qualified class name and a list +1306 * of the important parts of the package structure. Up to the first four levels of the package structure are +1307 * stored, excluding a leading "org" or "com". Example:</p> +1308 * <code>ClassNameInformation obj = new ClassNameInformation("org.owasp.dependencycheck.analyzer.JarAnalyzer"); +1309 * System.out.println(obj.getName()); +1310 * for (String p : obj.getPackageStructure()) +1311 * System.out.println(p); +1312 * </code> +1313 * <p> +1314 * Would result in:</p> +1315 * <code>org.owasp.dependencycheck.analyzer.JarAnalyzer +1316 * owasp +1317 * dependencycheck +1318 * analyzer +1319 * jaranalyzer</code> +1320 * +1321 * @param className a fully qualified class name +1322 */ +1323 ClassNameInformation(String className) { +1324 name = className; +1325 if (name.contains("/")) { +1326 final String[] tmp = className.toLowerCase().split("/"); +1327 int start = 0; +1328 int end = 3; +1329 if ("com".equals(tmp[0]) || "org".equals(tmp[0])) { +1330 start = 1; +1331 end = 4; +1332 } +1333 if (tmp.length <= end) { +1334 end = tmp.length - 1; +1335 } +1336 for (int i = start; i <= end; i++) { +1337 packageStructure.add(tmp[i]); +1338 } +1339 } else { +1340 packageStructure.add(name); +1341 } 1342 } -1343 if (!directory.mkdirs()) { -1344 final String msg = String.format("Unable to create temp directory '%s'.", directory.getAbsolutePath()); -1345 throw new AnalysisException(msg); -1346 } -1347 return directory; -1348 } -1349 } +1343 /** +1344 * The fully qualified class name. +1345 */ +1346 private String name; +1347 +1348 /** +1349 * Get the value of name +1350 * +1351 * @return the value of name +1352 */ +1353 public String getName() { +1354 return name; +1355 } +1356 +1357 /** +1358 * Set the value of name +1359 * +1360 * @param name new value of name +1361 */ +1362 public void setName(String name) { +1363 this.name = name; +1364 } +1365 /** +1366 * Up to the first four levels of the package structure, excluding a leading "org" or "com". +1367 */ +1368 private final ArrayList<String> packageStructure = new ArrayList<String>(); +1369 +1370 /** +1371 * Get the value of packageStructure +1372 * +1373 * @return the value of packageStructure +1374 */ +1375 public ArrayList<String> getPackageStructure() { +1376 return packageStructure; +1377 } +1378 } +1379 +1380 /** +1381 * Retrieves the next temporary directory to extract an archive too. +1382 * +1383 * @return a directory +1384 * @throws AnalysisException thrown if unable to create temporary directory +1385 */ +1386 private File getNextTempDirectory() throws AnalysisException { +1387 dirCount += 1; +1388 final File directory = new File(tempFileLocation, String.valueOf(dirCount)); +1389 //getting an exception for some directories not being able to be created; might be because the directory already exists? +1390 if (directory.exists()) { +1391 return getNextTempDirectory(); +1392 } +1393 if (!directory.mkdirs()) { +1394 final String msg = String.format("Unable to create temp directory '%s'.", directory.getAbsolutePath()); +1395 throw new AnalysisException(msg); +1396 } +1397 return directory; +1398 } +1399 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/NexusAnalyzer.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/NexusAnalyzer.html index a8f9d8ff9..79ac2d6d7 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/NexusAnalyzer.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/NexusAnalyzer.html @@ -38,7 +38,7 @@ 30 import org.owasp.dependencycheck.data.nexus.NexusSearch; 31 import org.owasp.dependencycheck.dependency.Confidence; 32 import org.owasp.dependencycheck.dependency.Dependency; -33 import org.owasp.dependencycheck.dependency.Identifier; +33 import org.owasp.dependencycheck.utils.InvalidSettingException; 34 import org.owasp.dependencycheck.utils.Settings; 35 36 /** @@ -58,144 +58,171 @@ 50 public class NexusAnalyzer extends AbstractFileTypeAnalyzer { 51 52 /** -53 * The logger. +53 * The default URL - this will be used by the CentralAnalyzer to determine whether to enable this. 54 */ -55 private static final Logger LOGGER = Logger.getLogger(NexusAnalyzer.class.getName()); +55 public static final String DEFAULT_URL = "https://repository.sonatype.org/service/local/"; 56 57 /** -58 * The name of the analyzer. +58 * The logger. 59 */ -60 private static final String ANALYZER_NAME = "Nexus Analyzer"; +60 private static final Logger LOGGER = Logger.getLogger(NexusAnalyzer.class.getName()); 61 62 /** -63 * The phase in which the analyzer runs. +63 * The name of the analyzer. 64 */ -65 private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.INFORMATION_COLLECTION; +65 private static final String ANALYZER_NAME = "Nexus Analyzer"; 66 67 /** -68 * The types of files on which this will work. +68 * The phase in which the analyzer runs. 69 */ -70 private static final Set<String> SUPPORTED_EXTENSIONS = newHashSet("jar"); +70 private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.INFORMATION_COLLECTION; 71 72 /** -73 * The Nexus Search to be set up for this analyzer. +73 * The types of files on which this will work. 74 */ -75 private NexusSearch searcher; +75 private static final Set<String> SUPPORTED_EXTENSIONS = newHashSet("jar"); 76 77 /** -78 * Initializes the analyzer once before any analysis is performed. -79 * -80 * @throws Exception if there's an error during initialization -81 */ -82 @Override -83 public void initializeFileTypeAnalyzer() throws Exception { -84 LOGGER.fine("Initializing Nexus Analyzer"); -85 LOGGER.fine(String.format("Nexus Analyzer enabled: %s", isEnabled())); -86 if (isEnabled()) { -87 final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL); -88 LOGGER.fine(String.format("Nexus Analyzer URL: %s", searchUrl)); -89 try { -90 searcher = new NexusSearch(new URL(searchUrl)); -91 if (!searcher.preflightRequest()) { -92 LOGGER.warning("There was an issue getting Nexus status. Disabling analyzer."); -93 setEnabled(false); -94 } -95 } catch (MalformedURLException mue) { -96 // I know that initialize can throw an exception, but we'll -97 // just disable the analyzer if the URL isn't valid -98 LOGGER.warning(String.format("Property %s not a valid URL. Nexus Analyzer disabled", searchUrl)); -99 setEnabled(false); -100 } -101 } -102 } -103 -104 /** -105 * Returns the analyzer's name. -106 * -107 * @return the name of the analyzer -108 */ -109 @Override -110 public String getName() { -111 return ANALYZER_NAME; -112 } -113 -114 /** -115 * Returns the key used in the properties file to reference the analyzer's enabled property. -116 * -117 * @return the analyzer's enabled property setting key -118 */ -119 @Override -120 protected String getAnalyzerEnabledSettingKey() { -121 return Settings.KEYS.ANALYZER_NEXUS_ENABLED; -122 } -123 -124 /** -125 * Returns the analysis phase under which the analyzer runs. -126 * -127 * @return the phase under which this analyzer runs -128 */ -129 @Override -130 public AnalysisPhase getAnalysisPhase() { -131 return ANALYSIS_PHASE; -132 } -133 -134 /** -135 * Returns the extensions for which this Analyzer runs. -136 * -137 * @return the extensions for which this Analyzer runs -138 */ -139 @Override -140 public Set<String> getSupportedExtensions() { -141 return SUPPORTED_EXTENSIONS; -142 } -143 -144 /** -145 * Performs the analysis. -146 * -147 * @param dependency the dependency to analyze -148 * @param engine the engine -149 * @throws AnalysisException when there's an exception during analysis -150 */ -151 @Override -152 public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException { -153 try { -154 final MavenArtifact ma = searcher.searchSha1(dependency.getSha1sum()); -155 if (ma.getGroupId() != null && !"".equals(ma.getGroupId())) { -156 dependency.getVendorEvidence().addEvidence("nexus", "groupid", ma.getGroupId(), Confidence.HIGH); -157 } -158 if (ma.getArtifactId() != null && !"".equals(ma.getArtifactId())) { -159 dependency.getProductEvidence().addEvidence("nexus", "artifactid", ma.getArtifactId(), Confidence.HIGH); -160 } -161 if (ma.getVersion() != null && !"".equals(ma.getVersion())) { -162 dependency.getVersionEvidence().addEvidence("nexus", "version", ma.getVersion(), Confidence.HIGH); -163 } -164 if (ma.getArtifactUrl() != null && !"".equals(ma.getArtifactUrl())) { -165 boolean found = false; -166 for (Identifier i : dependency.getIdentifiers()) { -167 if ("maven".equals(i.getType()) && i.getValue().equals(ma.toString())) { -168 found = true; -169 i.setConfidence(Confidence.HIGHEST); -170 i.setUrl(ma.getArtifactUrl()); -171 break; -172 } -173 } -174 if (!found) { -175 dependency.addIdentifier("maven", ma.toString(), ma.getArtifactUrl(), Confidence.HIGHEST); -176 } -177 } -178 } catch (IllegalArgumentException iae) { -179 //dependency.addAnalysisException(new AnalysisException("Invalid SHA-1")); -180 LOGGER.info(String.format("invalid sha-1 hash on %s", dependency.getFileName())); -181 } catch (FileNotFoundException fnfe) { -182 //dependency.addAnalysisException(new AnalysisException("Artifact not found on repository")); -183 LOGGER.fine(String.format("Artifact not found in repository '%s'", dependency.getFileName())); -184 LOGGER.log(Level.FINE, fnfe.getMessage(), fnfe); -185 } catch (IOException ioe) { -186 //dependency.addAnalysisException(new AnalysisException("Could not connect to repository", ioe)); -187 LOGGER.log(Level.FINE, "Could not connect to nexus repository", ioe); -188 } -189 } -190 } +78 * The Nexus Search to be set up for this analyzer. +79 */ +80 private NexusSearch searcher; +81 +82 /** +83 * Field indicating if the analyzer is enabled. +84 */ +85 private final boolean enabled = checkEnabled(); +86 +87 /** +88 * Determines if this analyzer is enabled +89 * +90 * @return <code>true</code> if the analyzer is enabled; otherwise <code>false</code> +91 */ +92 private boolean checkEnabled() { +93 /* Enable this analyzer ONLY if the Nexus URL has been set to something +94 other than the default one (if it's the default one, we'll use the +95 central one) and it's enabled by the user. +96 */ +97 boolean retval = false; +98 try { +99 if ((!DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL))) +100 && Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)) { +101 LOGGER.info("Enabling Nexus analyzer"); +102 retval = true; +103 } else { +104 LOGGER.info("Nexus analyzer disabled, using Central instead"); +105 } +106 } catch (InvalidSettingException ise) { +107 LOGGER.warning("Invalid setting. Disabling Nexus analyzer"); +108 } +109 +110 return retval; +111 } +112 +113 /** +114 * Determine whether to enable this analyzer or not. +115 * +116 * @return whether the analyzer should be enabled +117 */ +118 @Override +119 public boolean isEnabled() { +120 return enabled; +121 } +122 +123 /** +124 * Initializes the analyzer once before any analysis is performed. +125 * +126 * @throws Exception if there's an error during initialization +127 */ +128 @Override +129 public void initializeFileTypeAnalyzer() throws Exception { +130 LOGGER.fine("Initializing Nexus Analyzer"); +131 LOGGER.fine(String.format("Nexus Analyzer enabled: %s", isEnabled())); +132 if (isEnabled()) { +133 final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL); +134 LOGGER.fine(String.format("Nexus Analyzer URL: %s", searchUrl)); +135 try { +136 searcher = new NexusSearch(new URL(searchUrl)); +137 if (!searcher.preflightRequest()) { +138 LOGGER.warning("There was an issue getting Nexus status. Disabling analyzer."); +139 setEnabled(false); +140 } +141 } catch (MalformedURLException mue) { +142 // I know that initialize can throw an exception, but we'll +143 // just disable the analyzer if the URL isn't valid +144 LOGGER.warning(String.format("Property %s not a valid URL. Nexus Analyzer disabled", searchUrl)); +145 setEnabled(false); +146 } +147 } +148 } +149 +150 /** +151 * Returns the analyzer's name. +152 * +153 * @return the name of the analyzer +154 */ +155 @Override +156 public String getName() { +157 return ANALYZER_NAME; +158 } +159 +160 /** +161 * Returns the key used in the properties file to reference the analyzer's enabled property. +162 * +163 * @return the analyzer's enabled property setting key +164 */ +165 @Override +166 protected String getAnalyzerEnabledSettingKey() { +167 return Settings.KEYS.ANALYZER_NEXUS_ENABLED; +168 } +169 +170 /** +171 * Returns the analysis phase under which the analyzer runs. +172 * +173 * @return the phase under which this analyzer runs +174 */ +175 @Override +176 public AnalysisPhase getAnalysisPhase() { +177 return ANALYSIS_PHASE; +178 } +179 +180 /** +181 * Returns the extensions for which this Analyzer runs. +182 * +183 * @return the extensions for which this Analyzer runs +184 */ +185 @Override +186 public Set<String> getSupportedExtensions() { +187 return SUPPORTED_EXTENSIONS; +188 } +189 +190 /** +191 * Performs the analysis. +192 * +193 * @param dependency the dependency to analyze +194 * @param engine the engine +195 * @throws AnalysisException when there's an exception during analysis +196 */ +197 @Override +198 public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException { +199 if (!isEnabled()) { +200 return; +201 } +202 try { +203 final MavenArtifact ma = searcher.searchSha1(dependency.getSha1sum()); +204 dependency.addAsEvidence("nexus", ma, Confidence.HIGH); +205 } catch (IllegalArgumentException iae) { +206 //dependency.addAnalysisException(new AnalysisException("Invalid SHA-1")); +207 LOGGER.info(String.format("invalid sha-1 hash on %s", dependency.getFileName())); +208 } catch (FileNotFoundException fnfe) { +209 //dependency.addAnalysisException(new AnalysisException("Artifact not found on repository")); +210 LOGGER.fine(String.format("Artifact not found in repository '%s'", dependency.getFileName())); +211 LOGGER.log(Level.FINE, fnfe.getMessage(), fnfe); +212 } catch (IOException ioe) { +213 //dependency.addAnalysisException(new AnalysisException("Could not connect to repository", ioe)); +214 LOGGER.log(Level.FINE, "Could not connect to nexus repository", ioe); +215 } +216 } +217 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-frame.html index 967bf0ff8..a23db218e 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.analyzer.exception + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.analyzer.exception diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-summary.html index b9c729632..c33783dd6 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/exception/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.analyzer.exception + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.analyzer.exception diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-frame.html index 054c83e52..f4ce4a4ef 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.analyzer + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.analyzer @@ -41,6 +41,9 @@
  • CPEAnalyzer +
  • +
  • + CentralAnalyzer
  • ClassNameInformation diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-summary.html index 5bee9e09c..331f84646 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/analyzer/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.analyzer + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.analyzer @@ -79,6 +79,11 @@
  • CPEAnalyzer
    + CentralAnalyzer +
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/central/CentralSearch.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/central/CentralSearch.html new file mode 100644 index 000000000..a9117928e --- /dev/null +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/central/CentralSearch.html @@ -0,0 +1,164 @@ + + + +CentralSearch xref + + + +
    +1   /*
    +2    * This file is part of dependency-check-core.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *     http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   *
    +16   * Copyright (c) 2014 Jeremy Long. All Rights Reserved.
    +17   */
    +18  package org.owasp.dependencycheck.data.central;
    +19  
    +20  import java.io.FileNotFoundException;
    +21  import java.io.IOException;
    +22  import java.net.HttpURLConnection;
    +23  import java.net.URL;
    +24  import java.util.ArrayList;
    +25  import java.util.List;
    +26  import java.util.logging.Logger;
    +27  import javax.xml.parsers.DocumentBuilder;
    +28  import javax.xml.parsers.DocumentBuilderFactory;
    +29  import javax.xml.xpath.XPath;
    +30  import javax.xml.xpath.XPathConstants;
    +31  import javax.xml.xpath.XPathFactory;
    +32  import org.owasp.dependencycheck.data.nexus.MavenArtifact;
    +33  import org.owasp.dependencycheck.utils.Settings;
    +34  import org.owasp.dependencycheck.utils.URLConnectionFactory;
    +35  import org.w3c.dom.Document;
    +36  import org.w3c.dom.NodeList;
    +37  
    +38  /**
    +39   * Class of methods to search Maven Central via Central.
    +40   *
    +41   * @author colezlaw
    +42   */
    +43  public class CentralSearch {
    +44  
    +45      /**
    +46       * The URL for the Central service
    +47       */
    +48      private final URL rootURL;
    +49  
    +50      /**
    +51       * Whether to use the Proxy when making requests
    +52       */
    +53      private boolean useProxy;
    +54  
    +55      /**
    +56       * Used for logging.
    +57       */
    +58      private static final Logger LOGGER = Logger.getLogger(CentralSearch.class.getName());
    +59  
    +60      /**
    +61       * Creates a NexusSearch for the given repository URL.
    +62       *
    +63       * @param rootURL the URL of the repository on which searches should execute. Only parameters are added to this (so
    +64       * it should end in /select)
    +65       */
    +66      public CentralSearch(URL rootURL) {
    +67          this.rootURL = rootURL;
    +68          if (null != Settings.getString(Settings.KEYS.PROXY_SERVER)) {
    +69              useProxy = true;
    +70              LOGGER.fine("Using proxy");
    +71          } else {
    +72              useProxy = false;
    +73              LOGGER.fine("Not using proxy");
    +74          }
    +75      }
    +76  
    +77      /**
    +78       * Searches the configured Central URL for the given sha1 hash. If the artifact is found, a
    +79       * <code>MavenArtifact</code> is populated with the GAV.
    +80       *
    +81       * @param sha1 the SHA-1 hash string for which to search
    +82       * @return the populated Maven GAV.
    +83       * @throws IOException if it's unable to connect to the specified repository or if the specified artifact is not
    +84       * found.
    +85       */
    +86      public List<MavenArtifact> searchSha1(String sha1) throws IOException {
    +87          if (null == sha1 || !sha1.matches("^[0-9A-Fa-f]{40}$")) {
    +88              throw new IllegalArgumentException("Invalid SHA1 format");
    +89          }
    +90  
    +91          final URL url = new URL(rootURL + String.format("?q=1:\"%s\"&wt=xml", sha1));
    +92  
    +93          LOGGER.fine(String.format("Searching Central url %s", url.toString()));
    +94  
    +95          // Determine if we need to use a proxy. The rules:
    +96          // 1) If the proxy is set, AND the setting is set to true, use the proxy
    +97          // 2) Otherwise, don't use the proxy (either the proxy isn't configured,
    +98          // or proxy is specifically set to false)
    +99          final HttpURLConnection conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
    +100 
    +101         conn.setDoOutput(true);
    +102 
    +103         // JSON would be more elegant, but there's not currently a dependency
    +104         // on JSON, so don't want to add one just for this
    +105         conn.addRequestProperty("Accept", "application/xml");
    +106         conn.connect();
    +107 
    +108         if (conn.getResponseCode() == 200) {
    +109             boolean missing = false;
    +110             try {
    +111                 final DocumentBuilder builder = DocumentBuilderFactory
    +112                         .newInstance().newDocumentBuilder();
    +113                 final Document doc = builder.parse(conn.getInputStream());
    +114                 final XPath xpath = XPathFactory.newInstance().newXPath();
    +115                 final String numFound = xpath.evaluate("/response/result/@numFound", doc);
    +116                 if ("0".equals(numFound)) {
    +117                     missing = true;
    +118                 } else {
    +119                     final ArrayList<MavenArtifact> result = new ArrayList<MavenArtifact>();
    +120                     final NodeList docs = (NodeList) xpath.evaluate("/response/result/doc", doc, XPathConstants.NODESET);
    +121                     for (int i = 0; i < docs.getLength(); i++) {
    +122                         final String g = xpath.evaluate("./str[@name='g']", docs.item(i));
    +123                         LOGGER.finest(String.format("GroupId: %s", g));
    +124                         final String a = xpath.evaluate("./str[@name='a']", docs.item(i));
    +125                         LOGGER.finest(String.format("ArtifactId: %s", a));
    +126                         final String v = xpath.evaluate("./str[@name='v']", docs.item(i));
    +127                         LOGGER.finest(String.format("Version: %s", v));
    +128                         result.add(new MavenArtifact(g, a, v, url.toString()));
    +129                     }
    +130 
    +131                     return result;
    +132                 }
    +133             } catch (Throwable e) {
    +134                 // Anything else is jacked up XML stuff that we really can't recover
    +135                 // from well
    +136                 throw new IOException(e.getMessage(), e);
    +137             }
    +138 
    +139             if (missing) {
    +140                 throw new FileNotFoundException("Artifact not found in Central");
    +141             }
    +142         } else {
    +143             final String msg = String.format("Could not connect to Central received response code: %d %s",
    +144                     conn.getResponseCode(), conn.getResponseMessage());
    +145             LOGGER.fine(msg);
    +146             throw new IOException(msg);
    +147         }
    +148 
    +149         return null;
    +150     }
    +151 }
    +
    +
    + + + diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/central/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/central/package-frame.html new file mode 100644 index 000000000..f534a2eb4 --- /dev/null +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/central/package-frame.html @@ -0,0 +1,24 @@ + + + + + + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.central + + + + +

    + org.owasp.dependencycheck.data.central +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/central/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/central/package-summary.html new file mode 100644 index 000000000..d5fb146e8 --- /dev/null +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/central/package-summary.html @@ -0,0 +1,69 @@ + + + + + + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.central + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.data.central

    + + + + + + + + + + + + +
    Class Summary
    + CentralSearch +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.html index de28934f3..c8429fed0 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.html @@ -62,277 +62,278 @@ 54 * @author Jeremy Long <jeremy.long@owasp.org> 55 */ 56 public final class CpeMemoryIndex { -57 /** -58 * The logger. -59 */ -60 private static final Logger LOGGER = Logger.getLogger(CpeMemoryIndex.class.getName()); -61 /** -62 * singleton instance. -63 */ -64 private static CpeMemoryIndex instance = new CpeMemoryIndex(); -65 -66 /** -67 * private constructor for singleton. -68 */ -69 private CpeMemoryIndex() { -70 } -71 -72 /** -73 * Gets the singleton instance of the CpeMemoryIndex. -74 * -75 * @return the instance of the CpeMemoryIndex -76 */ -77 public static CpeMemoryIndex getInstance() { -78 return instance; -79 } -80 /** -81 * The in memory Lucene index. -82 */ -83 private RAMDirectory index; -84 /** -85 * The Lucene IndexReader. -86 */ -87 private IndexReader indexReader; -88 /** -89 * The Lucene IndexSearcher. -90 */ -91 private IndexSearcher indexSearcher; -92 /** -93 * The Lucene Analyzer used for Searching. -94 */ -95 private Analyzer searchingAnalyzer; -96 /** -97 * The Lucene QueryParser used for Searching. -98 */ -99 private QueryParser queryParser; -100 /** -101 * The search field analyzer for the product field. -102 */ -103 private SearchFieldAnalyzer productSearchFieldAnalyzer; -104 /** -105 * The search field analyzer for the vendor field. -106 */ -107 private SearchFieldAnalyzer vendorSearchFieldAnalyzer; -108 -109 /** -110 * Creates and loads data into an in memory index. -111 * -112 * @param cve the data source to retrieve the cpe data -113 * @throws IndexException thrown if there is an error creating the index -114 */ -115 public void open(CveDB cve) throws IndexException { -116 if (!openState) { -117 index = new RAMDirectory(); -118 buildIndex(cve); -119 try { -120 indexReader = DirectoryReader.open(index); -121 } catch (IOException ex) { -122 throw new IndexException(ex); -123 } -124 indexSearcher = new IndexSearcher(indexReader); -125 searchingAnalyzer = createSearchingAnalyzer(); -126 queryParser = new QueryParser(LuceneUtils.CURRENT_VERSION, Fields.DOCUMENT_KEY, searchingAnalyzer); -127 openState = true; -128 } -129 } -130 /** -131 * A flag indicating whether or not the index is open. -132 */ -133 private boolean openState = false; -134 -135 /** -136 * returns whether or not the index is open. -137 * -138 * @return whether or not the index is open -139 */ -140 public boolean isOpen() { -141 return openState; -142 } -143 -144 /** -145 * Creates the indexing analyzer for the CPE Index. -146 * -147 * @return the CPE Analyzer. -148 */ -149 @SuppressWarnings("unchecked") -150 private Analyzer createIndexingAnalyzer() { -151 final Map fieldAnalyzers = new HashMap(); -152 fieldAnalyzers.put(Fields.DOCUMENT_KEY, new KeywordAnalyzer()); -153 return new PerFieldAnalyzerWrapper(new FieldAnalyzer(LuceneUtils.CURRENT_VERSION), fieldAnalyzers); -154 } -155 -156 /** -157 * Creates an Analyzer for searching the CPE Index. -158 * -159 * @return the CPE Analyzer. -160 */ -161 @SuppressWarnings("unchecked") -162 private Analyzer createSearchingAnalyzer() { -163 final Map fieldAnalyzers = new HashMap(); -164 fieldAnalyzers.put(Fields.DOCUMENT_KEY, new KeywordAnalyzer()); -165 productSearchFieldAnalyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION); -166 vendorSearchFieldAnalyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION); -167 fieldAnalyzers.put(Fields.PRODUCT, productSearchFieldAnalyzer); -168 fieldAnalyzers.put(Fields.VENDOR, vendorSearchFieldAnalyzer); -169 -170 return new PerFieldAnalyzerWrapper(new FieldAnalyzer(LuceneUtils.CURRENT_VERSION), fieldAnalyzers); -171 } -172 -173 /** -174 * Saves a CPE IndexEntry into the Lucene index. -175 * -176 * @param vendor the vendor to index -177 * @param product the product to index -178 * @param indexWriter the index writer to write the entry into -179 * @throws CorruptIndexException is thrown if the index is corrupt -180 * @throws IOException is thrown if an IOException occurs -181 */ -182 public void saveEntry(String vendor, String product, IndexWriter indexWriter) throws CorruptIndexException, IOException { -183 final Document doc = new Document(); -184 final Field v = new TextField(Fields.VENDOR, vendor, Field.Store.YES); -185 final Field p = new TextField(Fields.PRODUCT, product, Field.Store.YES); -186 doc.add(v); -187 doc.add(p); -188 indexWriter.addDocument(doc); -189 } -190 -191 /** -192 * Closes the CPE Index. -193 */ -194 public void close() { -195 if (searchingAnalyzer != null) { -196 searchingAnalyzer.close(); -197 searchingAnalyzer = null; -198 } -199 if (indexReader != null) { -200 try { -201 indexReader.close(); -202 } catch (IOException ex) { -203 LOGGER.log(Level.FINEST, null, ex); -204 } -205 indexReader = null; -206 } -207 queryParser = null; -208 indexSearcher = null; -209 if (index != null) { -210 index.close(); -211 index = null; -212 } -213 openState = false; -214 } -215 -216 /** -217 * Builds the CPE Lucene Index based off of the data within the CveDB. -218 * -219 * @param cve the data base containing the CPE data -220 * @throws IndexException thrown if there is an issue creating the index -221 */ -222 private void buildIndex(CveDB cve) throws IndexException { -223 Analyzer analyzer = null; -224 IndexWriter indexWriter = null; -225 try { -226 analyzer = createIndexingAnalyzer(); -227 final IndexWriterConfig conf = new IndexWriterConfig(LuceneUtils.CURRENT_VERSION, analyzer); -228 indexWriter = new IndexWriter(index, conf); -229 try { -230 final Set<Pair<String, String>> data = cve.getVendorProductList(); -231 for (Pair<String, String> pair : data) { -232 saveEntry(pair.getLeft(), pair.getRight(), indexWriter); -233 } -234 } catch (DatabaseException ex) { -235 LOGGER.log(Level.FINE, null, ex); -236 throw new IndexException("Error reading CPE data", ex); -237 } -238 } catch (CorruptIndexException ex) { -239 throw new IndexException("Unable to close an in-memory index", ex); -240 } catch (IOException ex) { -241 throw new IndexException("Unable to close an in-memory index", ex); -242 } finally { -243 if (indexWriter != null) { -244 try { -245 try { -246 indexWriter.commit(); -247 } finally { -248 indexWriter.close(true); -249 } -250 } catch (CorruptIndexException ex) { -251 throw new IndexException("Unable to close an in-memory index", ex); -252 } catch (IOException ex) { -253 throw new IndexException("Unable to close an in-memory index", ex); -254 } -255 if (analyzer != null) { -256 analyzer.close(); -257 } -258 } -259 } -260 } -261 -262 /** -263 * Resets the searching analyzers -264 */ -265 private void resetSearchingAnalyzer() { -266 if (productSearchFieldAnalyzer != null) { -267 productSearchFieldAnalyzer.clear(); -268 } -269 if (vendorSearchFieldAnalyzer != null) { -270 vendorSearchFieldAnalyzer.clear(); -271 } -272 } -273 -274 /** -275 * Searches the index using the given search string. -276 * -277 * @param searchString the query text -278 * @param maxQueryResults the maximum number of documents to return -279 * @return the TopDocs found by the search -280 * @throws ParseException thrown when the searchString is invalid -281 * @throws IOException is thrown if there is an issue with the underlying Index -282 */ -283 public TopDocs search(String searchString, int maxQueryResults) throws ParseException, IOException { -284 if (searchString == null || searchString.trim().isEmpty()) { -285 throw new ParseException("Query is null or empty"); -286 } -287 final Query query = queryParser.parse(searchString); -288 return indexSearcher.search(query, maxQueryResults); -289 } -290 -291 /** -292 * Searches the index using the given query. -293 * -294 * @param query the query used to search the index -295 * @param maxQueryResults the max number of results to return -296 * @return the TopDocs found be the query -297 * @throws CorruptIndexException thrown if the Index is corrupt -298 * @throws IOException thrown if there is an IOException -299 */ -300 public TopDocs search(Query query, int maxQueryResults) throws CorruptIndexException, IOException { -301 resetSearchingAnalyzer(); -302 return indexSearcher.search(query, maxQueryResults); -303 } -304 -305 /** -306 * Retrieves a document from the Index. -307 * -308 * @param documentId the id of the document to retrieve -309 * @return the Document -310 * @throws IOException thrown if there is an IOException -311 */ -312 public Document getDocument(int documentId) throws IOException { -313 return indexSearcher.doc(documentId); -314 } -315 -316 /** -317 * Returns the number of CPE entries stored in the index. -318 * -319 * @return the number of CPE entries stored in the index -320 */ -321 public int numDocs() { -322 if (indexReader == null) { -323 return -1; -324 } -325 return indexReader.numDocs(); -326 } -327 } +57 +58 /** +59 * The logger. +60 */ +61 private static final Logger LOGGER = Logger.getLogger(CpeMemoryIndex.class.getName()); +62 /** +63 * singleton instance. +64 */ +65 private static CpeMemoryIndex instance = new CpeMemoryIndex(); +66 +67 /** +68 * private constructor for singleton. +69 */ +70 private CpeMemoryIndex() { +71 } +72 +73 /** +74 * Gets the singleton instance of the CpeMemoryIndex. +75 * +76 * @return the instance of the CpeMemoryIndex +77 */ +78 public static CpeMemoryIndex getInstance() { +79 return instance; +80 } +81 /** +82 * The in memory Lucene index. +83 */ +84 private RAMDirectory index; +85 /** +86 * The Lucene IndexReader. +87 */ +88 private IndexReader indexReader; +89 /** +90 * The Lucene IndexSearcher. +91 */ +92 private IndexSearcher indexSearcher; +93 /** +94 * The Lucene Analyzer used for Searching. +95 */ +96 private Analyzer searchingAnalyzer; +97 /** +98 * The Lucene QueryParser used for Searching. +99 */ +100 private QueryParser queryParser; +101 /** +102 * The search field analyzer for the product field. +103 */ +104 private SearchFieldAnalyzer productSearchFieldAnalyzer; +105 /** +106 * The search field analyzer for the vendor field. +107 */ +108 private SearchFieldAnalyzer vendorSearchFieldAnalyzer; +109 +110 /** +111 * Creates and loads data into an in memory index. +112 * +113 * @param cve the data source to retrieve the cpe data +114 * @throws IndexException thrown if there is an error creating the index +115 */ +116 public void open(CveDB cve) throws IndexException { +117 if (!openState) { +118 index = new RAMDirectory(); +119 buildIndex(cve); +120 try { +121 indexReader = DirectoryReader.open(index); +122 } catch (IOException ex) { +123 throw new IndexException(ex); +124 } +125 indexSearcher = new IndexSearcher(indexReader); +126 searchingAnalyzer = createSearchingAnalyzer(); +127 queryParser = new QueryParser(LuceneUtils.CURRENT_VERSION, Fields.DOCUMENT_KEY, searchingAnalyzer); +128 openState = true; +129 } +130 } +131 /** +132 * A flag indicating whether or not the index is open. +133 */ +134 private boolean openState = false; +135 +136 /** +137 * returns whether or not the index is open. +138 * +139 * @return whether or not the index is open +140 */ +141 public boolean isOpen() { +142 return openState; +143 } +144 +145 /** +146 * Creates the indexing analyzer for the CPE Index. +147 * +148 * @return the CPE Analyzer. +149 */ +150 @SuppressWarnings("unchecked") +151 private Analyzer createIndexingAnalyzer() { +152 final Map fieldAnalyzers = new HashMap(); +153 fieldAnalyzers.put(Fields.DOCUMENT_KEY, new KeywordAnalyzer()); +154 return new PerFieldAnalyzerWrapper(new FieldAnalyzer(LuceneUtils.CURRENT_VERSION), fieldAnalyzers); +155 } +156 +157 /** +158 * Creates an Analyzer for searching the CPE Index. +159 * +160 * @return the CPE Analyzer. +161 */ +162 @SuppressWarnings("unchecked") +163 private Analyzer createSearchingAnalyzer() { +164 final Map<String, Analyzer> fieldAnalyzers = new HashMap<String, Analyzer>(); +165 fieldAnalyzers.put(Fields.DOCUMENT_KEY, new KeywordAnalyzer()); +166 productSearchFieldAnalyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION); +167 vendorSearchFieldAnalyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION); +168 fieldAnalyzers.put(Fields.PRODUCT, productSearchFieldAnalyzer); +169 fieldAnalyzers.put(Fields.VENDOR, vendorSearchFieldAnalyzer); +170 +171 return new PerFieldAnalyzerWrapper(new FieldAnalyzer(LuceneUtils.CURRENT_VERSION), fieldAnalyzers); +172 } +173 +174 /** +175 * Saves a CPE IndexEntry into the Lucene index. +176 * +177 * @param vendor the vendor to index +178 * @param product the product to index +179 * @param indexWriter the index writer to write the entry into +180 * @throws CorruptIndexException is thrown if the index is corrupt +181 * @throws IOException is thrown if an IOException occurs +182 */ +183 public void saveEntry(String vendor, String product, IndexWriter indexWriter) throws CorruptIndexException, IOException { +184 final Document doc = new Document(); +185 final Field v = new TextField(Fields.VENDOR, vendor, Field.Store.YES); +186 final Field p = new TextField(Fields.PRODUCT, product, Field.Store.YES); +187 doc.add(v); +188 doc.add(p); +189 indexWriter.addDocument(doc); +190 } +191 +192 /** +193 * Closes the CPE Index. +194 */ +195 public void close() { +196 if (searchingAnalyzer != null) { +197 searchingAnalyzer.close(); +198 searchingAnalyzer = null; +199 } +200 if (indexReader != null) { +201 try { +202 indexReader.close(); +203 } catch (IOException ex) { +204 LOGGER.log(Level.FINEST, null, ex); +205 } +206 indexReader = null; +207 } +208 queryParser = null; +209 indexSearcher = null; +210 if (index != null) { +211 index.close(); +212 index = null; +213 } +214 openState = false; +215 } +216 +217 /** +218 * Builds the CPE Lucene Index based off of the data within the CveDB. +219 * +220 * @param cve the data base containing the CPE data +221 * @throws IndexException thrown if there is an issue creating the index +222 */ +223 private void buildIndex(CveDB cve) throws IndexException { +224 Analyzer analyzer = null; +225 IndexWriter indexWriter = null; +226 try { +227 analyzer = createIndexingAnalyzer(); +228 final IndexWriterConfig conf = new IndexWriterConfig(LuceneUtils.CURRENT_VERSION, analyzer); +229 indexWriter = new IndexWriter(index, conf); +230 try { +231 final Set<Pair<String, String>> data = cve.getVendorProductList(); +232 for (Pair<String, String> pair : data) { +233 saveEntry(pair.getLeft(), pair.getRight(), indexWriter); +234 } +235 } catch (DatabaseException ex) { +236 LOGGER.log(Level.FINE, null, ex); +237 throw new IndexException("Error reading CPE data", ex); +238 } +239 } catch (CorruptIndexException ex) { +240 throw new IndexException("Unable to close an in-memory index", ex); +241 } catch (IOException ex) { +242 throw new IndexException("Unable to close an in-memory index", ex); +243 } finally { +244 if (indexWriter != null) { +245 try { +246 try { +247 indexWriter.commit(); +248 } finally { +249 indexWriter.close(true); +250 } +251 } catch (CorruptIndexException ex) { +252 throw new IndexException("Unable to close an in-memory index", ex); +253 } catch (IOException ex) { +254 throw new IndexException("Unable to close an in-memory index", ex); +255 } +256 if (analyzer != null) { +257 analyzer.close(); +258 } +259 } +260 } +261 } +262 +263 /** +264 * Resets the searching analyzers +265 */ +266 private void resetSearchingAnalyzer() { +267 if (productSearchFieldAnalyzer != null) { +268 productSearchFieldAnalyzer.clear(); +269 } +270 if (vendorSearchFieldAnalyzer != null) { +271 vendorSearchFieldAnalyzer.clear(); +272 } +273 } +274 +275 /** +276 * Searches the index using the given search string. +277 * +278 * @param searchString the query text +279 * @param maxQueryResults the maximum number of documents to return +280 * @return the TopDocs found by the search +281 * @throws ParseException thrown when the searchString is invalid +282 * @throws IOException is thrown if there is an issue with the underlying Index +283 */ +284 public TopDocs search(String searchString, int maxQueryResults) throws ParseException, IOException { +285 if (searchString == null || searchString.trim().isEmpty()) { +286 throw new ParseException("Query is null or empty"); +287 } +288 final Query query = queryParser.parse(searchString); +289 return indexSearcher.search(query, maxQueryResults); +290 } +291 +292 /** +293 * Searches the index using the given query. +294 * +295 * @param query the query used to search the index +296 * @param maxQueryResults the max number of results to return +297 * @return the TopDocs found be the query +298 * @throws CorruptIndexException thrown if the Index is corrupt +299 * @throws IOException thrown if there is an IOException +300 */ +301 public TopDocs search(Query query, int maxQueryResults) throws CorruptIndexException, IOException { +302 resetSearchingAnalyzer(); +303 return indexSearcher.search(query, maxQueryResults); +304 } +305 +306 /** +307 * Retrieves a document from the Index. +308 * +309 * @param documentId the id of the document to retrieve +310 * @return the Document +311 * @throws IOException thrown if there is an IOException +312 */ +313 public Document getDocument(int documentId) throws IOException { +314 return indexSearcher.doc(documentId); +315 } +316 +317 /** +318 * Returns the number of CPE entries stored in the index. +319 * +320 * @return the number of CPE entries stored in the index +321 */ +322 public int numDocs() { +323 if (indexReader == null) { +324 return -1; +325 } +326 return indexReader.numDocs(); +327 } +328 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-frame.html index b4962b030..58eb6628c 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cpe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cpe diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-summary.html index fbb5bfea8..853dbd8fb 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/cpe/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cpe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cpe diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/CweDB.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/CweDB.html index 0024a7b18..2cf5e146d 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/CweDB.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/CweDB.html @@ -37,65 +37,69 @@ 29 * @author Jeremy Long <jeremy.long@owasp.org> 30 */ 31 public final class CweDB { -32 /** -33 * The Logger. -34 */ -35 private static final Logger LOGGER = Logger.getLogger(CweDB.class.getName()); -36 /** -37 * Empty private constructor as this is a utility class. -38 */ -39 private CweDB() { -40 //empty -41 } -42 /** -43 * A HashMap of the CWE data. -44 */ -45 private static final HashMap<String, String> CWE = loadData(); -46 -47 /** -48 * Loads a HashMap containing the CWE data from a resource found in the jar. -49 * -50 * @return a HashMap of CWE data -51 */ -52 private static HashMap<String, String> loadData() { -53 ObjectInputStream oin = null; -54 try { -55 final String filePath = "data/cwe.hashmap.serialized"; -56 final InputStream input = CweDB.class.getClassLoader().getResourceAsStream(filePath); -57 oin = new ObjectInputStream(input); -58 return (HashMap<String, String>) oin.readObject(); -59 } catch (ClassNotFoundException ex) { -60 LOGGER.log(Level.WARNING, "Unable to load CWE data. This should not be an issue."); -61 LOGGER.log(Level.FINE, null, ex); -62 } catch (IOException ex) { -63 LOGGER.log(Level.WARNING, "Unable to load CWE data due to an IO Error. This should not be an issue."); -64 LOGGER.log(Level.FINE, null, ex); -65 } finally { -66 if (oin != null) { -67 try { -68 oin.close(); -69 } catch (IOException ex) { -70 LOGGER.log(Level.FINEST, null, ex); -71 } -72 } -73 } -74 return null; -75 } -76 -77 /** -78 * <p> -79 * Returns the full CWE name from the CWE ID.</p> -80 * -81 * @param cweId the CWE ID -82 * @return the full name of the CWE -83 */ -84 public static String getCweName(String cweId) { -85 if (cweId != null) { -86 return CWE.get(cweId); -87 } -88 return null; -89 } -90 } +32 +33 /** +34 * The Logger. +35 */ +36 private static final Logger LOGGER = Logger.getLogger(CweDB.class.getName()); +37 +38 /** +39 * Empty private constructor as this is a utility class. +40 */ +41 private CweDB() { +42 //empty +43 } +44 /** +45 * A HashMap of the CWE data. +46 */ +47 private static final HashMap<String, String> CWE = loadData(); +48 +49 /** +50 * Loads a HashMap containing the CWE data from a resource found in the jar. +51 * +52 * @return a HashMap of CWE data +53 */ +54 private static HashMap<String, String> loadData() { +55 ObjectInputStream oin = null; +56 try { +57 final String filePath = "data/cwe.hashmap.serialized"; +58 final InputStream input = CweDB.class.getClassLoader().getResourceAsStream(filePath); +59 oin = new ObjectInputStream(input); +60 @SuppressWarnings("unchecked") +61 final HashMap<String, String> ret = (HashMap<String, String>) oin.readObject(); +62 return ret; +63 } catch (ClassNotFoundException ex) { +64 LOGGER.log(Level.WARNING, "Unable to load CWE data. This should not be an issue."); +65 LOGGER.log(Level.FINE, null, ex); +66 } catch (IOException ex) { +67 LOGGER.log(Level.WARNING, "Unable to load CWE data due to an IO Error. This should not be an issue."); +68 LOGGER.log(Level.FINE, null, ex); +69 } finally { +70 if (oin != null) { +71 try { +72 oin.close(); +73 } catch (IOException ex) { +74 LOGGER.log(Level.FINEST, null, ex); +75 } +76 } +77 } +78 return null; +79 } +80 +81 /** +82 * <p> +83 * Returns the full CWE name from the CWE ID.</p> +84 * +85 * @param cweId the CWE ID +86 * @return the full name of the CWE +87 */ +88 public static String getCweName(String cweId) { +89 if (cweId != null) { +90 return CWE.get(cweId); +91 } +92 return null; +93 } +94 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-frame.html index 6e93f8a45..f776b11e5 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cwe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cwe diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-summary.html index 54cfde0f4..6e83a4ec9 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/cwe/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.cwe + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.cwe diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-frame.html index f231a34a3..5c0b3b39c 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.lucene + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.lucene diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-summary.html index 77d47eb2c..481cd4108 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/lucene/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.lucene + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.lucene diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-frame.html index c03583b23..88b38c1f1 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nexus + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nexus diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-summary.html index 351d24f0f..3e606306b 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nexus/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nexus + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nexus diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-frame.html index 0fcb98ded..8dc820380 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nuget + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nuget diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-summary.html index 0cf7fcbdb..d4995ceae 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nuget/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nuget + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nuget diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/CveDB.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/CveDB.html index 6ba517007..76627963e 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/CveDB.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/CveDB.html @@ -314,14 +314,14 @@ 306 * @throws DatabaseException thrown when there is an error retrieving the data from the DB 307 */ 308 public Set<Pair<String, String>> getVendorProductList() throws DatabaseException { -309 final HashSet data = new HashSet<Pair<String, String>>(); +309 final Set<Pair<String, String>> data = new HashSet<Pair<String, String>>(); 310 ResultSet rs = null; 311 PreparedStatement ps = null; 312 try { 313 ps = getConnection().prepareStatement(SELECT_VENDOR_PRODUCT_LIST); 314 rs = ps.executeQuery(); 315 while (rs.next()) { -316 data.add(new Pair(rs.getString(1), rs.getString(2))); +316 data.add(new Pair<String, String>(rs.getString(1), rs.getString(2))); 317 } 318 } catch (SQLException ex) { 319 final String msg = "An unexpected SQL Exception occurred; please see the verbose log for more details."; @@ -739,7 +739,7 @@ 731 * @param previous a flag indicating if previous versions of the product are vulnerable 732 * @return true if the identified version is affected, otherwise false 733 */ -734 private boolean isAffected(String vendor, String product, DependencyVersion identifiedVersion, String cpeId, String previous) { +734 protected boolean isAffected(String vendor, String product, DependencyVersion identifiedVersion, String cpeId, String previous) { 735 boolean affected = false; 736 final boolean isStruts = "apache".equals(vendor) && "struts".equals(product); 737 final DependencyVersion v = parseDependencyVersion(cpeId); diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.html index 468564d11..0b50f9bc5 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.html @@ -150,8 +150,8 @@ 142 * 143 * @return a map of the database meta data 144 */ -145 public Map getMetaData() { -146 final TreeMap map = new TreeMap(); +145 public Map<String, String> getMetaData() { +146 final TreeMap<String, String> map = new TreeMap<String, String>(); 147 for (Entry<Object, Object> entry : properties.entrySet()) { 148 final String key = (String) entry.getKey(); 149 if (!"version".equals(key)) { @@ -164,10 +164,10 @@ 156 map.put(key, formatted); 157 } catch (Throwable ex) { //deliberately being broad in this catch clause 158 LOGGER.log(Level.FINE, "Unable to parse timestamp from DB", ex); -159 map.put(key, entry.getValue()); +159 map.put(key, (String) entry.getValue()); 160 } 161 } else { -162 map.put(key, entry.getValue()); +162 map.put(key, (String) entry.getValue()); 163 } 164 } 165 } diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-frame.html index 401c7ec04..0b6dd3a19 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nvdcve + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nvdcve diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-summary.html index f6a9999c8..6ed1bf0f7 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/nvdcve/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.nvdcve + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.nvdcve diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-frame.html index e6213907b..14b31a504 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.exception + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.exception diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-summary.html index 0fd312b35..b6585531f 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/exception/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.exception + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.exception diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-frame.html index d675c0138..6d847c66c 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-summary.html index 87f241b71..9d62e3b62 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/DownloadTask.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/DownloadTask.html index 4e2c6e325..dd832a3d4 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/DownloadTask.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/DownloadTask.html @@ -26,226 +26,283 @@ 18 package org.owasp.dependencycheck.data.update.task; 19 20 import java.io.File; -21 import java.io.IOException; -22 import java.net.URL; -23 import java.util.concurrent.Callable; -24 import java.util.concurrent.ExecutorService; -25 import java.util.concurrent.Future; -26 import java.util.logging.Level; -27 import java.util.logging.Logger; -28 import org.owasp.dependencycheck.data.nvdcve.CveDB; -29 import org.owasp.dependencycheck.data.update.NvdCveInfo; -30 import org.owasp.dependencycheck.data.update.exception.UpdateException; -31 import org.owasp.dependencycheck.utils.DownloadFailedException; -32 import org.owasp.dependencycheck.utils.Downloader; -33 import org.owasp.dependencycheck.utils.Settings; -34 -35 /** -36 * A callable object to download two files. -37 * -38 * @author Jeremy Long <jeremy.long@owasp.org> -39 */ -40 public class DownloadTask implements Callable<Future<ProcessTask>> { -41 -42 /** -43 * The Logger. -44 */ -45 private static final Logger LOGGER = Logger.getLogger(DownloadTask.class.getName()); +21 import java.io.FileInputStream; +22 import java.io.FileNotFoundException; +23 import java.io.FileOutputStream; +24 import java.io.IOException; +25 import java.net.URL; +26 import java.util.concurrent.Callable; +27 import java.util.concurrent.ExecutorService; +28 import java.util.concurrent.Future; +29 import java.util.logging.Level; +30 import java.util.logging.Logger; +31 import java.util.zip.GZIPInputStream; +32 import org.apache.commons.io.FileUtils; +33 import org.owasp.dependencycheck.data.nvdcve.CveDB; +34 import org.owasp.dependencycheck.data.update.NvdCveInfo; +35 import org.owasp.dependencycheck.data.update.exception.UpdateException; +36 import org.owasp.dependencycheck.utils.DownloadFailedException; +37 import org.owasp.dependencycheck.utils.Downloader; +38 import org.owasp.dependencycheck.utils.Settings; +39 +40 /** +41 * A callable object to download two files. +42 * +43 * @author Jeremy Long <jeremy.long@owasp.org> +44 */ +45 public class DownloadTask implements Callable<Future<ProcessTask>> { 46 47 /** -48 * Simple constructor for the callable download task. -49 * -50 * @param nvdCveInfo the NVD CVE info -51 * @param processor the processor service to submit the downloaded files to -52 * @param cveDB the CVE DB to use to store the vulnerability data -53 * @param settings a reference to the global settings object; this is necessary so that when the thread is started -54 * the dependencies have a correct reference to the global settings. -55 * @throws UpdateException thrown if temporary files could not be created -56 */ -57 public DownloadTask(NvdCveInfo nvdCveInfo, ExecutorService processor, CveDB cveDB, Settings settings) throws UpdateException { -58 this.nvdCveInfo = nvdCveInfo; -59 this.processorService = processor; -60 this.cveDB = cveDB; -61 this.settings = settings; -62 -63 final File file1; -64 final File file2; -65 -66 try { -67 file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml", Settings.getTempDirectory()); -68 file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml", Settings.getTempDirectory()); -69 } catch (IOException ex) { -70 throw new UpdateException("Unable to create temporary files", ex); -71 } -72 this.first = file1; -73 this.second = file2; -74 -75 } -76 /** -77 * The CVE DB to use when processing the files. -78 */ -79 private CveDB cveDB; -80 /** -81 * The processor service to pass the results of the download to. -82 */ -83 private ExecutorService processorService; -84 /** -85 * The NVD CVE Meta Data. -86 */ -87 private NvdCveInfo nvdCveInfo; -88 /** -89 * A reference to the global settings object. -90 */ -91 private Settings settings; -92 +48 * The Logger. +49 */ +50 private static final Logger LOGGER = Logger.getLogger(DownloadTask.class.getName()); +51 +52 /** +53 * Simple constructor for the callable download task. +54 * +55 * @param nvdCveInfo the NVD CVE info +56 * @param processor the processor service to submit the downloaded files to +57 * @param cveDB the CVE DB to use to store the vulnerability data +58 * @param settings a reference to the global settings object; this is necessary so that when the thread is started +59 * the dependencies have a correct reference to the global settings. +60 * @throws UpdateException thrown if temporary files could not be created +61 */ +62 public DownloadTask(NvdCveInfo nvdCveInfo, ExecutorService processor, CveDB cveDB, Settings settings) throws UpdateException { +63 this.nvdCveInfo = nvdCveInfo; +64 this.processorService = processor; +65 this.cveDB = cveDB; +66 this.settings = settings; +67 +68 final File file1; +69 final File file2; +70 +71 try { +72 file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml", Settings.getTempDirectory()); +73 file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml", Settings.getTempDirectory()); +74 } catch (IOException ex) { +75 throw new UpdateException("Unable to create temporary files", ex); +76 } +77 this.first = file1; +78 this.second = file2; +79 +80 } +81 /** +82 * The CVE DB to use when processing the files. +83 */ +84 private CveDB cveDB; +85 /** +86 * The processor service to pass the results of the download to. +87 */ +88 private ExecutorService processorService; +89 /** +90 * The NVD CVE Meta Data. +91 */ +92 private NvdCveInfo nvdCveInfo; 93 /** -94 * Get the value of nvdCveInfo. -95 * -96 * @return the value of nvdCveInfo -97 */ -98 public NvdCveInfo getNvdCveInfo() { -99 return nvdCveInfo; -100 } -101 -102 /** -103 * Set the value of nvdCveInfo. -104 * -105 * @param nvdCveInfo new value of nvdCveInfo -106 */ -107 public void setNvdCveInfo(NvdCveInfo nvdCveInfo) { -108 this.nvdCveInfo = nvdCveInfo; -109 } -110 /** -111 * a file. -112 */ -113 private File first; -114 +94 * A reference to the global settings object. +95 */ +96 private Settings settings; +97 +98 /** +99 * Get the value of nvdCveInfo. +100 * +101 * @return the value of nvdCveInfo +102 */ +103 public NvdCveInfo getNvdCveInfo() { +104 return nvdCveInfo; +105 } +106 +107 /** +108 * Set the value of nvdCveInfo. +109 * +110 * @param nvdCveInfo new value of nvdCveInfo +111 */ +112 public void setNvdCveInfo(NvdCveInfo nvdCveInfo) { +113 this.nvdCveInfo = nvdCveInfo; +114 } 115 /** -116 * Get the value of first. -117 * -118 * @return the value of first -119 */ -120 public File getFirst() { -121 return first; -122 } -123 -124 /** -125 * Set the value of first. -126 * -127 * @param first new value of first -128 */ -129 public void setFirst(File first) { -130 this.first = first; -131 } -132 /** -133 * a file. -134 */ -135 private File second; -136 +116 * a file. +117 */ +118 private File first; +119 +120 /** +121 * Get the value of first. +122 * +123 * @return the value of first +124 */ +125 public File getFirst() { +126 return first; +127 } +128 +129 /** +130 * Set the value of first. +131 * +132 * @param first new value of first +133 */ +134 public void setFirst(File first) { +135 this.first = first; +136 } 137 /** -138 * Get the value of second. -139 * -140 * @return the value of second -141 */ -142 public File getSecond() { -143 return second; -144 } -145 -146 /** -147 * Set the value of second. -148 * -149 * @param second new value of second -150 */ -151 public void setSecond(File second) { -152 this.second = second; -153 } -154 /** -155 * A placeholder for an exception. -156 */ -157 private Exception exception = null; -158 +138 * a file. +139 */ +140 private File second; +141 +142 /** +143 * Get the value of second. +144 * +145 * @return the value of second +146 */ +147 public File getSecond() { +148 return second; +149 } +150 +151 /** +152 * Set the value of second. +153 * +154 * @param second new value of second +155 */ +156 public void setSecond(File second) { +157 this.second = second; +158 } 159 /** -160 * Get the value of exception. -161 * -162 * @return the value of exception -163 */ -164 public Exception getException() { -165 return exception; -166 } -167 -168 /** -169 * returns whether or not an exception occurred during download. -170 * -171 * @return whether or not an exception occurred during download -172 */ -173 public boolean hasException() { -174 return exception != null; -175 } -176 -177 @Override -178 public Future<ProcessTask> call() throws Exception { -179 try { -180 Settings.setInstance(settings); -181 final URL url1 = new URL(nvdCveInfo.getUrl()); -182 final URL url2 = new URL(nvdCveInfo.getOldSchemaVersionUrl()); -183 String msg = String.format("Download Started for NVD CVE - %s", nvdCveInfo.getId()); -184 LOGGER.log(Level.INFO, msg); -185 try { -186 Downloader.fetchFile(url1, first); -187 Downloader.fetchFile(url2, second); -188 } catch (DownloadFailedException ex) { -189 msg = String.format("Download Failed for NVD CVE - %s%nSome CVEs may not be reported.", nvdCveInfo.getId()); -190 LOGGER.log(Level.WARNING, msg); -191 if (Settings.getString(Settings.KEYS.PROXY_SERVER) == null) { -192 LOGGER.log(Level.INFO, -193 "If you are behind a proxy you may need to configure dependency-check to use the proxy."); -194 } -195 LOGGER.log(Level.FINE, null, ex); -196 return null; -197 } -198 -199 msg = String.format("Download Complete for NVD CVE - %s", nvdCveInfo.getId()); -200 LOGGER.log(Level.INFO, msg); -201 -202 final ProcessTask task = new ProcessTask(cveDB, this, settings); -203 return this.processorService.submit(task); -204 -205 } catch (Throwable ex) { -206 final String msg = String.format("An exception occurred downloading NVD CVE - %s%nSome CVEs may not be reported.", nvdCveInfo.getId()); -207 LOGGER.log(Level.WARNING, msg); -208 LOGGER.log(Level.FINE, "Download Task Failed", ex); -209 } finally { -210 Settings.cleanup(false); -211 } -212 return null; -213 } -214 -215 /** -216 * Attempts to delete the files that were downloaded. -217 */ -218 public void cleanup() { -219 boolean deleted = false; -220 try { -221 if (first != null && first.exists()) { -222 deleted = first.delete(); -223 } -224 } finally { -225 if (first != null && (first.exists() || !deleted)) { -226 first.deleteOnExit(); -227 } -228 } -229 try { -230 deleted = false; -231 if (second != null && second.exists()) { -232 deleted = second.delete(); -233 } -234 } finally { -235 if (second != null && (second.exists() || !deleted)) { -236 second.deleteOnExit(); -237 } -238 } -239 } -240 } +160 * A placeholder for an exception. +161 */ +162 private Exception exception = null; +163 +164 /** +165 * Get the value of exception. +166 * +167 * @return the value of exception +168 */ +169 public Exception getException() { +170 return exception; +171 } +172 +173 /** +174 * returns whether or not an exception occurred during download. +175 * +176 * @return whether or not an exception occurred during download +177 */ +178 public boolean hasException() { +179 return exception != null; +180 } +181 +182 @Override +183 public Future<ProcessTask> call() throws Exception { +184 try { +185 Settings.setInstance(settings); +186 final URL url1 = new URL(nvdCveInfo.getUrl()); +187 final URL url2 = new URL(nvdCveInfo.getOldSchemaVersionUrl()); +188 String msg = String.format("Download Started for NVD CVE - %s", nvdCveInfo.getId()); +189 LOGGER.log(Level.INFO, msg); +190 try { +191 Downloader.fetchFile(url1, first); +192 Downloader.fetchFile(url2, second); +193 } catch (DownloadFailedException ex) { +194 msg = String.format("Download Failed for NVD CVE - %s%nSome CVEs may not be reported.", nvdCveInfo.getId()); +195 LOGGER.log(Level.WARNING, msg); +196 if (Settings.getString(Settings.KEYS.PROXY_SERVER) == null) { +197 LOGGER.log(Level.INFO, +198 "If you are behind a proxy you may need to configure dependency-check to use the proxy."); +199 } +200 LOGGER.log(Level.FINE, null, ex); +201 return null; +202 } +203 if (url1.toExternalForm().endsWith(".xml.gz")) { +204 extractGzip(first); +205 } +206 if (url2.toExternalForm().endsWith(".xml.gz")) { +207 extractGzip(second); +208 } +209 +210 msg = String.format("Download Complete for NVD CVE - %s", nvdCveInfo.getId()); +211 LOGGER.log(Level.INFO, msg); +212 if (this.processorService == null) { +213 return null; +214 } +215 final ProcessTask task = new ProcessTask(cveDB, this, settings); +216 return this.processorService.submit(task); +217 +218 } catch (Throwable ex) { +219 final String msg = String.format("An exception occurred downloading NVD CVE - %s%nSome CVEs may not be reported.", nvdCveInfo.getId()); +220 LOGGER.log(Level.WARNING, msg); +221 LOGGER.log(Level.FINE, "Download Task Failed", ex); +222 } finally { +223 Settings.cleanup(false); +224 } +225 return null; +226 } +227 +228 /** +229 * Attempts to delete the files that were downloaded. +230 */ +231 public void cleanup() { +232 boolean deleted = false; +233 try { +234 if (first != null && first.exists()) { +235 deleted = first.delete(); +236 } +237 } finally { +238 if (first != null && (first.exists() || !deleted)) { +239 first.deleteOnExit(); +240 } +241 } +242 try { +243 deleted = false; +244 if (second != null && second.exists()) { +245 deleted = second.delete(); +246 } +247 } finally { +248 if (second != null && (second.exists() || !deleted)) { +249 second.deleteOnExit(); +250 } +251 } +252 } +253 +254 /** +255 * Extracts the file contained in a gzip archive. The extracted file is placed in the exact same path as the file +256 * specified. +257 * +258 * @param file the archive file +259 * @throws FileNotFoundException thrown if the file does not exist +260 * @throws IOException thrown if there is an error extracting the file. +261 */ +262 private void extractGzip(File file) throws FileNotFoundException, IOException { +263 final String originalPath = file.getPath(); +264 File gzip = new File(originalPath + ".gz"); +265 if (gzip.isFile()) { +266 gzip.delete(); +267 } +268 if (!file.renameTo(gzip)) { +269 throw new IOException("Unable to rename '" + file.getPath() + "'"); +270 } +271 final File newfile = new File(originalPath); +272 +273 final byte[] buffer = new byte[4096]; +274 +275 GZIPInputStream cin = null; +276 FileOutputStream out = null; +277 try { +278 cin = new GZIPInputStream(new FileInputStream(gzip)); +279 out = new FileOutputStream(newfile); +280 +281 int len; +282 while ((len = cin.read(buffer)) > 0) { +283 out.write(buffer, 0, len); +284 } +285 } finally { +286 if (cin != null) { +287 cin.close(); +288 } +289 if (out != null) { +290 out.close(); +291 } +292 if (gzip.isFile()) { +293 FileUtils.deleteQuietly(gzip); +294 } +295 } +296 } +297 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-frame.html index 88857601f..15a69221e 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.task + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.task diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-summary.html index b565938fc..5a434ebdd 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/task/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.task + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.task diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-frame.html index b61bd3b3f..89464822f 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.xml + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.xml diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-summary.html index 260d1af06..45c90b5f7 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/data/update/xml/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.data.update.xml + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.data.update.xml diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/dependency/Dependency.html b/dependency-check-core/xref/org/owasp/dependencycheck/dependency/Dependency.html index 8f6094210..1a77a2e42 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/dependency/Dependency.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/dependency/Dependency.html @@ -34,658 +34,699 @@ 26 import java.util.TreeSet; 27 import java.util.logging.Level; 28 import java.util.logging.Logger; -29 import org.owasp.dependencycheck.utils.Checksum; -30 import org.owasp.dependencycheck.utils.FileUtils; -31 -32 /** -33 * A program dependency. This object is one of the core components within DependencyCheck. It is used to collect -34 * information about the dependency in the form of evidence. The Evidence is then used to determine if there are any -35 * known, published, vulnerabilities associated with the program dependency. -36 * -37 * @author Jeremy Long <jeremy.long@owasp.org> -38 */ -39 public class Dependency implements Serializable, Comparable<Dependency> { -40 -41 /** -42 * The logger. -43 */ -44 private static final Logger LOGGER = Logger.getLogger(Dependency.class.getName()); -45 /** -46 * The actual file path of the dependency on disk. -47 */ -48 private String actualFilePath; -49 /** -50 * The file path to display. -51 */ -52 private String filePath; -53 /** -54 * The file name of the dependency. -55 */ -56 private String fileName; -57 /** -58 * The file extension of the dependency. -59 */ -60 private String fileExtension; -61 /** -62 * The md5 hash of the dependency. -63 */ -64 private String md5sum; -65 /** -66 * The SHA1 hash of the dependency. -67 */ -68 private String sha1sum; -69 /** -70 * A list of Identifiers. -71 */ -72 private Set<Identifier> identifiers; -73 /** -74 * A collection of vendor evidence. -75 */ -76 private final EvidenceCollection vendorEvidence; -77 /** -78 * A collection of product evidence. -79 */ -80 private final EvidenceCollection productEvidence; -81 /** -82 * A collection of version evidence. -83 */ -84 private final EvidenceCollection versionEvidence; -85 -86 /** -87 * Constructs a new Dependency object. -88 */ -89 public Dependency() { -90 vendorEvidence = new EvidenceCollection(); -91 productEvidence = new EvidenceCollection(); -92 versionEvidence = new EvidenceCollection(); -93 identifiers = new TreeSet<Identifier>(); -94 vulnerabilities = new TreeSet<Vulnerability>(new VulnerabilityComparator()); -95 suppressedIdentifiers = new TreeSet<Identifier>(); -96 suppressedVulnerabilities = new TreeSet<Vulnerability>(new VulnerabilityComparator()); -97 } -98 -99 /** -100 * Constructs a new Dependency object. -101 * -102 * @param file the File to create the dependency object from. -103 */ -104 public Dependency(File file) { -105 this(); -106 this.actualFilePath = file.getPath(); -107 this.filePath = this.actualFilePath; -108 this.fileName = file.getName(); -109 this.fileExtension = FileUtils.getFileExtension(fileName); -110 determineHashes(file); -111 } -112 -113 /** -114 * Returns the file name of the dependency. -115 * -116 * @return the file name of the dependency -117 */ -118 public String getFileName() { -119 return this.fileName; -120 } -121 -122 /** -123 * Returns the file name of the dependency with the backslash escaped for use in JavaScript. This is a complete hack -124 * as I could not get the replace to work in the template itself. -125 * -126 * @return the file name of the dependency with the backslash escaped for use in JavaScript -127 */ -128 public String getFileNameForJavaScript() { -129 return this.fileName.replace("\\", "\\\\"); -130 } -131 -132 /** -133 * Sets the file name of the dependency. -134 * -135 * @param fileName the file name of the dependency -136 */ -137 public void setFileName(String fileName) { -138 this.fileName = fileName; -139 } -140 -141 /** -142 * Sets the actual file path of the dependency on disk. -143 * -144 * @param actualFilePath the file path of the dependency -145 */ -146 public void setActualFilePath(String actualFilePath) { -147 this.actualFilePath = actualFilePath; -148 if (this.sha1sum == null) { -149 final File file = new File(this.actualFilePath); -150 determineHashes(file); -151 } -152 } -153 -154 /** -155 * Gets the file path of the dependency. -156 * -157 * @return the file path of the dependency -158 */ -159 public String getActualFilePath() { -160 return this.actualFilePath; -161 } -162 -163 /** -164 * Gets a reference to the File object. -165 * -166 * @return the File object -167 */ -168 public File getActualFile() { -169 return new File(this.actualFilePath); -170 } -171 -172 /** -173 * Sets the file path of the dependency. -174 * -175 * @param filePath the file path of the dependency -176 */ -177 public void setFilePath(String filePath) { -178 this.filePath = filePath; -179 } -180 -181 /** -182 * The file name to display in reports. -183 */ -184 private String displayName = null; -185 -186 /** -187 * Sets the file name to display in reports. -188 * -189 * @param displayName the name to display -190 */ -191 public void setDisplayFileName(String displayName) { -192 this.displayName = displayName; -193 } -194 -195 /** -196 * Returns the file name to display in reports; if no display file name has been set it will default to the actual -197 * file name. -198 * -199 * @return the file name to display -200 */ -201 public String getDisplayFileName() { -202 if (displayName == null) { -203 return this.fileName; -204 } -205 return this.displayName; -206 } -207 -208 /** -209 * <p> -210 * Gets the file path of the dependency.</p> -211 * <p> -212 * <b>NOTE:</b> This may not be the actual path of the file on disk. The actual path of the file on disk can be -213 * obtained via the getActualFilePath().</p> -214 * -215 * @return the file path of the dependency -216 */ -217 public String getFilePath() { -218 return this.filePath; -219 } -220 -221 /** -222 * Sets the file name of the dependency. -223 * -224 * @param fileExtension the file name of the dependency -225 */ -226 public void setFileExtension(String fileExtension) { -227 this.fileExtension = fileExtension; -228 } -229 -230 /** -231 * Gets the file extension of the dependency. -232 * -233 * @return the file extension of the dependency -234 */ -235 public String getFileExtension() { -236 return this.fileExtension; -237 } -238 -239 /** -240 * Returns the MD5 Checksum of the dependency file. -241 * -242 * @return the MD5 Checksum -243 */ -244 public String getMd5sum() { -245 return this.md5sum; -246 } -247 -248 /** -249 * Sets the MD5 Checksum of the dependency. -250 * -251 * @param md5sum the MD5 Checksum -252 */ -253 public void setMd5sum(String md5sum) { -254 this.md5sum = md5sum; -255 } -256 -257 /** -258 * Returns the SHA1 Checksum of the dependency. -259 * -260 * @return the SHA1 Checksum -261 */ -262 public String getSha1sum() { -263 return this.sha1sum; -264 } -265 -266 /** -267 * Sets the SHA1 Checksum of the dependency. -268 * -269 * @param sha1sum the SHA1 Checksum -270 */ -271 public void setSha1sum(String sha1sum) { -272 this.sha1sum = sha1sum; -273 } -274 -275 /** -276 * Returns a List of Identifiers. -277 * -278 * @return an ArrayList of Identifiers -279 */ -280 public Set<Identifier> getIdentifiers() { -281 return this.identifiers; -282 } -283 -284 /** -285 * Sets a List of Identifiers. -286 * -287 * @param identifiers A list of Identifiers -288 */ -289 public void setIdentifiers(Set<Identifier> identifiers) { -290 this.identifiers = identifiers; -291 } -292 -293 /** -294 * Adds an entry to the list of detected Identifiers for the dependency file. -295 * -296 * @param type the type of identifier (such as CPE) -297 * @param value the value of the identifier -298 * @param url the URL of the identifier -299 */ -300 public void addIdentifier(String type, String value, String url) { -301 final Identifier i = new Identifier(type, value, url); -302 this.identifiers.add(i); -303 } -304 -305 /** -306 * Adds an entry to the list of detected Identifiers for the dependency file. -307 * -308 * @param type the type of identifier (such as CPE) -309 * @param value the value of the identifier -310 * @param url the URL of the identifier -311 * @param confidence the confidence in the Identifier being accurate -312 */ -313 public void addIdentifier(String type, String value, String url, Confidence confidence) { -314 final Identifier i = new Identifier(type, value, url); -315 i.setConfidence(confidence); -316 this.identifiers.add(i); -317 } -318 -319 /** -320 * Adds an entry to the list of detected Identifiers for the dependency file. -321 * -322 * @param identifier the identifier to add -323 */ -324 public void addIdentifier(Identifier identifier) { -325 this.identifiers.add(identifier); -326 } -327 /** -328 * A set of identifiers that have been suppressed. -329 */ -330 private Set<Identifier> suppressedIdentifiers; -331 -332 /** -333 * Get the value of suppressedIdentifiers. -334 * -335 * @return the value of suppressedIdentifiers -336 */ -337 public Set<Identifier> getSuppressedIdentifiers() { -338 return suppressedIdentifiers; -339 } -340 -341 /** -342 * Set the value of suppressedIdentifiers. -343 * -344 * @param suppressedIdentifiers new value of suppressedIdentifiers -345 */ -346 public void setSuppressedIdentifiers(Set<Identifier> suppressedIdentifiers) { -347 this.suppressedIdentifiers = suppressedIdentifiers; -348 } -349 -350 /** -351 * Adds an identifier to the list of suppressed identifiers. -352 * -353 * @param identifier an identifier that was suppressed. -354 */ -355 public void addSuppressedIdentifier(Identifier identifier) { -356 this.suppressedIdentifiers.add(identifier); -357 } -358 -359 /** -360 * A set of vulnerabilities that have been suppressed. -361 */ -362 private SortedSet<Vulnerability> suppressedVulnerabilities; +29 import org.owasp.dependencycheck.data.nexus.MavenArtifact; +30 import org.owasp.dependencycheck.utils.Checksum; +31 import org.owasp.dependencycheck.utils.FileUtils; +32 +33 /** +34 * A program dependency. This object is one of the core components within DependencyCheck. It is used to collect +35 * information about the dependency in the form of evidence. The Evidence is then used to determine if there are any +36 * known, published, vulnerabilities associated with the program dependency. +37 * +38 * @author Jeremy Long <jeremy.long@owasp.org> +39 */ +40 public class Dependency implements Serializable, Comparable<Dependency> { +41 +42 /** +43 * The logger. +44 */ +45 private static final Logger LOGGER = Logger.getLogger(Dependency.class.getName()); +46 /** +47 * The actual file path of the dependency on disk. +48 */ +49 private String actualFilePath; +50 /** +51 * The file path to display. +52 */ +53 private String filePath; +54 /** +55 * The file name of the dependency. +56 */ +57 private String fileName; +58 /** +59 * The file extension of the dependency. +60 */ +61 private String fileExtension; +62 /** +63 * The md5 hash of the dependency. +64 */ +65 private String md5sum; +66 /** +67 * The SHA1 hash of the dependency. +68 */ +69 private String sha1sum; +70 /** +71 * A list of Identifiers. +72 */ +73 private Set<Identifier> identifiers; +74 /** +75 * A collection of vendor evidence. +76 */ +77 private final EvidenceCollection vendorEvidence; +78 /** +79 * A collection of product evidence. +80 */ +81 private final EvidenceCollection productEvidence; +82 /** +83 * A collection of version evidence. +84 */ +85 private final EvidenceCollection versionEvidence; +86 +87 /** +88 * Constructs a new Dependency object. +89 */ +90 public Dependency() { +91 vendorEvidence = new EvidenceCollection(); +92 productEvidence = new EvidenceCollection(); +93 versionEvidence = new EvidenceCollection(); +94 identifiers = new TreeSet<Identifier>(); +95 vulnerabilities = new TreeSet<Vulnerability>(new VulnerabilityComparator()); +96 suppressedIdentifiers = new TreeSet<Identifier>(); +97 suppressedVulnerabilities = new TreeSet<Vulnerability>(new VulnerabilityComparator()); +98 } +99 +100 /** +101 * Constructs a new Dependency object. +102 * +103 * @param file the File to create the dependency object from. +104 */ +105 public Dependency(File file) { +106 this(); +107 this.actualFilePath = file.getPath(); +108 this.filePath = this.actualFilePath; +109 this.fileName = file.getName(); +110 this.fileExtension = FileUtils.getFileExtension(fileName); +111 determineHashes(file); +112 } +113 +114 /** +115 * Returns the file name of the dependency. +116 * +117 * @return the file name of the dependency +118 */ +119 public String getFileName() { +120 return this.fileName; +121 } +122 +123 /** +124 * Returns the file name of the dependency with the backslash escaped for use in JavaScript. This is a complete hack +125 * as I could not get the replace to work in the template itself. +126 * +127 * @return the file name of the dependency with the backslash escaped for use in JavaScript +128 */ +129 public String getFileNameForJavaScript() { +130 return this.fileName.replace("\\", "\\\\"); +131 } +132 +133 /** +134 * Sets the file name of the dependency. +135 * +136 * @param fileName the file name of the dependency +137 */ +138 public void setFileName(String fileName) { +139 this.fileName = fileName; +140 } +141 +142 /** +143 * Sets the actual file path of the dependency on disk. +144 * +145 * @param actualFilePath the file path of the dependency +146 */ +147 public void setActualFilePath(String actualFilePath) { +148 this.actualFilePath = actualFilePath; +149 if (this.sha1sum == null) { +150 final File file = new File(this.actualFilePath); +151 determineHashes(file); +152 } +153 } +154 +155 /** +156 * Gets the file path of the dependency. +157 * +158 * @return the file path of the dependency +159 */ +160 public String getActualFilePath() { +161 return this.actualFilePath; +162 } +163 +164 /** +165 * Gets a reference to the File object. +166 * +167 * @return the File object +168 */ +169 public File getActualFile() { +170 return new File(this.actualFilePath); +171 } +172 +173 /** +174 * Sets the file path of the dependency. +175 * +176 * @param filePath the file path of the dependency +177 */ +178 public void setFilePath(String filePath) { +179 this.filePath = filePath; +180 } +181 +182 /** +183 * The file name to display in reports. +184 */ +185 private String displayName = null; +186 +187 /** +188 * Sets the file name to display in reports. +189 * +190 * @param displayName the name to display +191 */ +192 public void setDisplayFileName(String displayName) { +193 this.displayName = displayName; +194 } +195 +196 /** +197 * Returns the file name to display in reports; if no display file name has been set it will default to the actual +198 * file name. +199 * +200 * @return the file name to display +201 */ +202 public String getDisplayFileName() { +203 if (displayName == null) { +204 return this.fileName; +205 } +206 return this.displayName; +207 } +208 +209 /** +210 * <p> +211 * Gets the file path of the dependency.</p> +212 * <p> +213 * <b>NOTE:</b> This may not be the actual path of the file on disk. The actual path of the file on disk can be +214 * obtained via the getActualFilePath().</p> +215 * +216 * @return the file path of the dependency +217 */ +218 public String getFilePath() { +219 return this.filePath; +220 } +221 +222 /** +223 * Sets the file name of the dependency. +224 * +225 * @param fileExtension the file name of the dependency +226 */ +227 public void setFileExtension(String fileExtension) { +228 this.fileExtension = fileExtension; +229 } +230 +231 /** +232 * Gets the file extension of the dependency. +233 * +234 * @return the file extension of the dependency +235 */ +236 public String getFileExtension() { +237 return this.fileExtension; +238 } +239 +240 /** +241 * Returns the MD5 Checksum of the dependency file. +242 * +243 * @return the MD5 Checksum +244 */ +245 public String getMd5sum() { +246 return this.md5sum; +247 } +248 +249 /** +250 * Sets the MD5 Checksum of the dependency. +251 * +252 * @param md5sum the MD5 Checksum +253 */ +254 public void setMd5sum(String md5sum) { +255 this.md5sum = md5sum; +256 } +257 +258 /** +259 * Returns the SHA1 Checksum of the dependency. +260 * +261 * @return the SHA1 Checksum +262 */ +263 public String getSha1sum() { +264 return this.sha1sum; +265 } +266 +267 /** +268 * Sets the SHA1 Checksum of the dependency. +269 * +270 * @param sha1sum the SHA1 Checksum +271 */ +272 public void setSha1sum(String sha1sum) { +273 this.sha1sum = sha1sum; +274 } +275 +276 /** +277 * Returns a List of Identifiers. +278 * +279 * @return an ArrayList of Identifiers +280 */ +281 public Set<Identifier> getIdentifiers() { +282 return this.identifiers; +283 } +284 +285 /** +286 * Sets a List of Identifiers. +287 * +288 * @param identifiers A list of Identifiers +289 */ +290 public void setIdentifiers(Set<Identifier> identifiers) { +291 this.identifiers = identifiers; +292 } +293 +294 /** +295 * Adds an entry to the list of detected Identifiers for the dependency file. +296 * +297 * @param type the type of identifier (such as CPE) +298 * @param value the value of the identifier +299 * @param url the URL of the identifier +300 */ +301 public void addIdentifier(String type, String value, String url) { +302 final Identifier i = new Identifier(type, value, url); +303 this.identifiers.add(i); +304 } +305 +306 /** +307 * Adds an entry to the list of detected Identifiers for the dependency file. +308 * +309 * @param type the type of identifier (such as CPE) +310 * @param value the value of the identifier +311 * @param url the URL of the identifier +312 * @param confidence the confidence in the Identifier being accurate +313 */ +314 public void addIdentifier(String type, String value, String url, Confidence confidence) { +315 final Identifier i = new Identifier(type, value, url); +316 i.setConfidence(confidence); +317 this.identifiers.add(i); +318 } +319 +320 /** +321 * Adds the maven artifact as evidence. +322 * +323 * @param source The source of the evidence +324 * @param mavenArtifact The maven artifact +325 * @param confidence The confidence level of this evidence +326 */ +327 public void addAsEvidence(String source, MavenArtifact mavenArtifact, Confidence confidence) { +328 if (mavenArtifact.getGroupId() != null && !mavenArtifact.getGroupId().isEmpty()) { +329 this.getVendorEvidence().addEvidence(source, "groupid", mavenArtifact.getGroupId(), confidence); +330 } +331 if (mavenArtifact.getArtifactId() != null && !mavenArtifact.getArtifactId().isEmpty()) { +332 this.getProductEvidence().addEvidence(source, "artifactid", mavenArtifact.getArtifactId(), confidence); +333 } +334 if (mavenArtifact.getVersion() != null && !mavenArtifact.getVersion().isEmpty()) { +335 this.getVersionEvidence().addEvidence(source, "version", mavenArtifact.getVersion(), confidence); +336 } +337 if (mavenArtifact.getArtifactUrl() != null && !mavenArtifact.getArtifactUrl().isEmpty()) { +338 boolean found = false; +339 for (Identifier i : this.getIdentifiers()) { +340 if ("maven".equals(i.getType()) && i.getValue().equals(mavenArtifact.toString())) { +341 found = true; +342 i.setConfidence(Confidence.HIGHEST); +343 i.setUrl(mavenArtifact.getArtifactUrl()); +344 LOGGER.fine(String.format("Already found identifier %s. Confidence set to highest", i.getValue())); +345 break; +346 } +347 } +348 if (!found) { +349 LOGGER.fine(String.format("Adding new maven identifier %s", mavenArtifact.toString())); +350 this.addIdentifier("maven", mavenArtifact.toString(), mavenArtifact.getArtifactUrl(), Confidence.HIGHEST); +351 } +352 } +353 } +354 +355 /** +356 * Adds an entry to the list of detected Identifiers for the dependency file. +357 * +358 * @param identifier the identifier to add +359 */ +360 public void addIdentifier(Identifier identifier) { +361 this.identifiers.add(identifier); +362 } 363 364 /** -365 * Get the value of suppressedVulnerabilities. -366 * -367 * @return the value of suppressedVulnerabilities -368 */ -369 public SortedSet<Vulnerability> getSuppressedVulnerabilities() { -370 return suppressedVulnerabilities; -371 } -372 -373 /** -374 * Set the value of suppressedVulnerabilities. -375 * -376 * @param suppressedVulnerabilities new value of suppressedVulnerabilities -377 */ -378 public void setSuppressedVulnerabilities(SortedSet<Vulnerability> suppressedVulnerabilities) { -379 this.suppressedVulnerabilities = suppressedVulnerabilities; -380 } -381 -382 /** -383 * Adds a vulnerability to the set of suppressed vulnerabilities. -384 * -385 * @param vulnerability the vulnerability that was suppressed -386 */ -387 public void addSuppressedVulnerability(Vulnerability vulnerability) { -388 this.suppressedVulnerabilities.add(vulnerability); -389 } -390 -391 /** -392 * Returns the evidence used to identify this dependency. -393 * -394 * @return an EvidenceCollection. -395 */ -396 public EvidenceCollection getEvidence() { -397 return EvidenceCollection.merge(this.productEvidence, this.vendorEvidence, this.versionEvidence); -398 } -399 -400 /** -401 * Returns the evidence used to identify this dependency. -402 * -403 * @return an EvidenceCollection. -404 */ -405 public Set<Evidence> getEvidenceForDisplay() { -406 return EvidenceCollection.mergeForDisplay(this.productEvidence, this.vendorEvidence, this.versionEvidence); -407 } -408 -409 /** -410 * Returns the evidence used to identify this dependency. -411 * -412 * @return an EvidenceCollection. -413 */ -414 public EvidenceCollection getEvidenceUsed() { -415 return EvidenceCollection.mergeUsed(this.productEvidence, this.vendorEvidence, this.versionEvidence); -416 } -417 -418 /** -419 * Gets the Vendor Evidence. -420 * -421 * @return an EvidenceCollection. -422 */ -423 public EvidenceCollection getVendorEvidence() { -424 return this.vendorEvidence; -425 } -426 -427 /** -428 * Gets the Product Evidence. -429 * -430 * @return an EvidenceCollection. -431 */ -432 public EvidenceCollection getProductEvidence() { -433 return this.productEvidence; -434 } -435 -436 /** -437 * Gets the Version Evidence. -438 * -439 * @return an EvidenceCollection. -440 */ -441 public EvidenceCollection getVersionEvidence() { -442 return this.versionEvidence; -443 } -444 /** -445 * The description of the JAR file. -446 */ -447 private String description; -448 -449 /** -450 * Get the value of description. -451 * -452 * @return the value of description -453 */ -454 public String getDescription() { -455 return description; -456 } -457 -458 /** -459 * Set the value of description. -460 * -461 * @param description new value of description -462 */ -463 public void setDescription(String description) { -464 this.description = description; -465 } -466 /** -467 * The license that this dependency uses. +365 * A set of identifiers that have been suppressed. +366 */ +367 private Set<Identifier> suppressedIdentifiers; +368 +369 /** +370 * Get the value of suppressedIdentifiers. +371 * +372 * @return the value of suppressedIdentifiers +373 */ +374 public Set<Identifier> getSuppressedIdentifiers() { +375 return suppressedIdentifiers; +376 } +377 +378 /** +379 * Set the value of suppressedIdentifiers. +380 * +381 * @param suppressedIdentifiers new value of suppressedIdentifiers +382 */ +383 public void setSuppressedIdentifiers(Set<Identifier> suppressedIdentifiers) { +384 this.suppressedIdentifiers = suppressedIdentifiers; +385 } +386 +387 /** +388 * Adds an identifier to the list of suppressed identifiers. +389 * +390 * @param identifier an identifier that was suppressed. +391 */ +392 public void addSuppressedIdentifier(Identifier identifier) { +393 this.suppressedIdentifiers.add(identifier); +394 } +395 +396 /** +397 * A set of vulnerabilities that have been suppressed. +398 */ +399 private SortedSet<Vulnerability> suppressedVulnerabilities; +400 +401 /** +402 * Get the value of suppressedVulnerabilities. +403 * +404 * @return the value of suppressedVulnerabilities +405 */ +406 public SortedSet<Vulnerability> getSuppressedVulnerabilities() { +407 return suppressedVulnerabilities; +408 } +409 +410 /** +411 * Set the value of suppressedVulnerabilities. +412 * +413 * @param suppressedVulnerabilities new value of suppressedVulnerabilities +414 */ +415 public void setSuppressedVulnerabilities(SortedSet<Vulnerability> suppressedVulnerabilities) { +416 this.suppressedVulnerabilities = suppressedVulnerabilities; +417 } +418 +419 /** +420 * Adds a vulnerability to the set of suppressed vulnerabilities. +421 * +422 * @param vulnerability the vulnerability that was suppressed +423 */ +424 public void addSuppressedVulnerability(Vulnerability vulnerability) { +425 this.suppressedVulnerabilities.add(vulnerability); +426 } +427 +428 /** +429 * Returns the evidence used to identify this dependency. +430 * +431 * @return an EvidenceCollection. +432 */ +433 public EvidenceCollection getEvidence() { +434 return EvidenceCollection.merge(this.productEvidence, this.vendorEvidence, this.versionEvidence); +435 } +436 +437 /** +438 * Returns the evidence used to identify this dependency. +439 * +440 * @return an EvidenceCollection. +441 */ +442 public Set<Evidence> getEvidenceForDisplay() { +443 return EvidenceCollection.mergeForDisplay(this.productEvidence, this.vendorEvidence, this.versionEvidence); +444 } +445 +446 /** +447 * Returns the evidence used to identify this dependency. +448 * +449 * @return an EvidenceCollection. +450 */ +451 public EvidenceCollection getEvidenceUsed() { +452 return EvidenceCollection.mergeUsed(this.productEvidence, this.vendorEvidence, this.versionEvidence); +453 } +454 +455 /** +456 * Gets the Vendor Evidence. +457 * +458 * @return an EvidenceCollection. +459 */ +460 public EvidenceCollection getVendorEvidence() { +461 return this.vendorEvidence; +462 } +463 +464 /** +465 * Gets the Product Evidence. +466 * +467 * @return an EvidenceCollection. 468 */ -469 private String license; -470 -471 /** -472 * Get the value of license. -473 * -474 * @return the value of license -475 */ -476 public String getLicense() { -477 return license; -478 } -479 -480 /** -481 * Set the value of license. -482 * -483 * @param license new value of license +469 public EvidenceCollection getProductEvidence() { +470 return this.productEvidence; +471 } +472 +473 /** +474 * Gets the Version Evidence. +475 * +476 * @return an EvidenceCollection. +477 */ +478 public EvidenceCollection getVersionEvidence() { +479 return this.versionEvidence; +480 } +481 +482 /** +483 * The description of the JAR file. 484 */ -485 public void setLicense(String license) { -486 this.license = license; -487 } -488 /** -489 * A list of vulnerabilities for this dependency. -490 */ -491 private SortedSet<Vulnerability> vulnerabilities; -492 -493 /** -494 * Get the list of vulnerabilities. -495 * -496 * @return the list of vulnerabilities -497 */ -498 public SortedSet<Vulnerability> getVulnerabilities() { -499 return vulnerabilities; -500 } -501 -502 /** -503 * Set the value of vulnerabilities. -504 * -505 * @param vulnerabilities new value of vulnerabilities -506 */ -507 public void setVulnerabilities(SortedSet<Vulnerability> vulnerabilities) { -508 this.vulnerabilities = vulnerabilities; -509 } -510 -511 /** -512 * Determines the sha1 and md5 sum for the given file. -513 * -514 * @param file the file to create checksums for -515 */ -516 private void determineHashes(File file) { -517 String md5 = null; -518 String sha1 = null; -519 try { -520 md5 = Checksum.getMD5Checksum(file); -521 sha1 = Checksum.getSHA1Checksum(file); -522 } catch (IOException ex) { -523 final String msg = String.format("Unable to read '%s' to determine hashes.", file.getName()); -524 LOGGER.log(Level.WARNING, msg); -525 LOGGER.log(Level.FINE, null, ex); -526 } catch (NoSuchAlgorithmException ex) { -527 final String msg = "Unable to use MD5 of SHA1 checksums."; -528 LOGGER.log(Level.WARNING, msg); -529 LOGGER.log(Level.FINE, null, ex); -530 } -531 this.setMd5sum(md5); -532 this.setSha1sum(sha1); -533 } -534 -535 /** -536 * Adds a vulnerability to the dependency. -537 * -538 * @param vulnerability a vulnerability outlining a vulnerability. -539 */ -540 public void addVulnerability(Vulnerability vulnerability) { -541 this.vulnerabilities.add(vulnerability); -542 } -543 /** -544 * A collection of related dependencies. -545 */ -546 private Set<Dependency> relatedDependencies = new TreeSet<Dependency>(); -547 -548 /** -549 * Get the value of relatedDependencies. -550 * -551 * @return the value of relatedDependencies -552 */ -553 public Set<Dependency> getRelatedDependencies() { -554 return relatedDependencies; -555 } -556 -557 /** -558 * Set the value of relatedDependencies. -559 * -560 * @param relatedDependencies new value of relatedDependencies -561 */ -562 public void setRelatedDependencies(Set<Dependency> relatedDependencies) { -563 this.relatedDependencies = relatedDependencies; -564 } -565 -566 /** -567 * Adds a related dependency. -568 * -569 * @param dependency a reference to the related dependency -570 */ -571 public void addRelatedDependency(Dependency dependency) { -572 relatedDependencies.add(dependency); +485 private String description; +486 +487 /** +488 * Get the value of description. +489 * +490 * @return the value of description +491 */ +492 public String getDescription() { +493 return description; +494 } +495 +496 /** +497 * Set the value of description. +498 * +499 * @param description new value of description +500 */ +501 public void setDescription(String description) { +502 this.description = description; +503 } +504 +505 /** +506 * The license that this dependency uses. +507 */ +508 private String license; +509 +510 /** +511 * Get the value of license. +512 * +513 * @return the value of license +514 */ +515 public String getLicense() { +516 return license; +517 } +518 +519 /** +520 * Set the value of license. +521 * +522 * @param license new value of license +523 */ +524 public void setLicense(String license) { +525 this.license = license; +526 } +527 +528 /** +529 * A list of vulnerabilities for this dependency. +530 */ +531 private SortedSet<Vulnerability> vulnerabilities; +532 +533 /** +534 * Get the list of vulnerabilities. +535 * +536 * @return the list of vulnerabilities +537 */ +538 public SortedSet<Vulnerability> getVulnerabilities() { +539 return vulnerabilities; +540 } +541 +542 /** +543 * Set the value of vulnerabilities. +544 * +545 * @param vulnerabilities new value of vulnerabilities +546 */ +547 public void setVulnerabilities(SortedSet<Vulnerability> vulnerabilities) { +548 this.vulnerabilities = vulnerabilities; +549 } +550 +551 /** +552 * Determines the sha1 and md5 sum for the given file. +553 * +554 * @param file the file to create checksums for +555 */ +556 private void determineHashes(File file) { +557 String md5 = null; +558 String sha1 = null; +559 try { +560 md5 = Checksum.getMD5Checksum(file); +561 sha1 = Checksum.getSHA1Checksum(file); +562 } catch (IOException ex) { +563 final String msg = String.format("Unable to read '%s' to determine hashes.", file.getName()); +564 LOGGER.log(Level.WARNING, msg); +565 LOGGER.log(Level.FINE, null, ex); +566 } catch (NoSuchAlgorithmException ex) { +567 final String msg = "Unable to use MD5 of SHA1 checksums."; +568 LOGGER.log(Level.WARNING, msg); +569 LOGGER.log(Level.FINE, null, ex); +570 } +571 this.setMd5sum(md5); +572 this.setSha1sum(sha1); 573 } 574 575 /** -576 * Implementation of the Comparable<Dependency> interface. The comparison is solely based on the file name. +576 * Adds a vulnerability to the dependency. 577 * -578 * @param o a dependency to compare -579 * @return an integer representing the natural ordering -580 */ -581 public int compareTo(Dependency o) { -582 return this.getFileName().compareToIgnoreCase(o.getFileName()); -583 } -584 -585 /** -586 * Implementation of the equals method. -587 * -588 * @param obj the object to compare -589 * @return true if the objects are equal, otherwise false -590 */ -591 @Override -592 public boolean equals(Object obj) { -593 if (obj == null) { -594 return false; -595 } -596 if (getClass() != obj.getClass()) { -597 return false; -598 } -599 final Dependency other = (Dependency) obj; -600 if ((this.actualFilePath == null) ? (other.actualFilePath != null) : !this.actualFilePath.equals(other.actualFilePath)) { -601 return false; -602 } -603 if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { -604 return false; -605 } -606 if ((this.fileName == null) ? (other.fileName != null) : !this.fileName.equals(other.fileName)) { -607 return false; -608 } -609 if ((this.fileExtension == null) ? (other.fileExtension != null) : !this.fileExtension.equals(other.fileExtension)) { -610 return false; -611 } -612 if ((this.md5sum == null) ? (other.md5sum != null) : !this.md5sum.equals(other.md5sum)) { -613 return false; -614 } -615 if ((this.sha1sum == null) ? (other.sha1sum != null) : !this.sha1sum.equals(other.sha1sum)) { -616 return false; -617 } -618 if (this.identifiers != other.identifiers && (this.identifiers == null || !this.identifiers.equals(other.identifiers))) { -619 return false; -620 } -621 if (this.vendorEvidence != other.vendorEvidence && (this.vendorEvidence == null || !this.vendorEvidence.equals(other.vendorEvidence))) { -622 return false; -623 } -624 if (this.productEvidence != other.productEvidence && (this.productEvidence == null || !this.productEvidence.equals(other.productEvidence))) { -625 return false; -626 } -627 if (this.versionEvidence != other.versionEvidence && (this.versionEvidence == null || !this.versionEvidence.equals(other.versionEvidence))) { -628 return false; -629 } -630 if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) { -631 return false; -632 } -633 if ((this.license == null) ? (other.license != null) : !this.license.equals(other.license)) { -634 return false; -635 } -636 if (this.vulnerabilities != other.vulnerabilities && (this.vulnerabilities == null || !this.vulnerabilities.equals(other.vulnerabilities))) { -637 return false; -638 } -639 if (this.relatedDependencies != other.relatedDependencies -640 && (this.relatedDependencies == null || !this.relatedDependencies.equals(other.relatedDependencies))) { -641 return false; -642 } -643 return true; -644 } -645 -646 /** -647 * Generates the HashCode. -648 * -649 * @return the HashCode -650 */ -651 @Override -652 public int hashCode() { -653 int hash = 3; -654 hash = 47 * hash + (this.actualFilePath != null ? this.actualFilePath.hashCode() : 0); -655 hash = 47 * hash + (this.filePath != null ? this.filePath.hashCode() : 0); -656 hash = 47 * hash + (this.fileName != null ? this.fileName.hashCode() : 0); -657 hash = 47 * hash + (this.fileExtension != null ? this.fileExtension.hashCode() : 0); -658 hash = 47 * hash + (this.md5sum != null ? this.md5sum.hashCode() : 0); -659 hash = 47 * hash + (this.sha1sum != null ? this.sha1sum.hashCode() : 0); -660 hash = 47 * hash + (this.identifiers != null ? this.identifiers.hashCode() : 0); -661 hash = 47 * hash + (this.vendorEvidence != null ? this.vendorEvidence.hashCode() : 0); -662 hash = 47 * hash + (this.productEvidence != null ? this.productEvidence.hashCode() : 0); -663 hash = 47 * hash + (this.versionEvidence != null ? this.versionEvidence.hashCode() : 0); -664 hash = 47 * hash + (this.description != null ? this.description.hashCode() : 0); -665 hash = 47 * hash + (this.license != null ? this.license.hashCode() : 0); -666 hash = 47 * hash + (this.vulnerabilities != null ? this.vulnerabilities.hashCode() : 0); -667 hash = 47 * hash + (this.relatedDependencies != null ? this.relatedDependencies.hashCode() : 0); -668 return hash; -669 } -670 -671 /** -672 * Standard toString() implementation showing the filename, actualFilePath, and filePath. -673 * -674 * @return the string representation of the file -675 */ -676 @Override -677 public String toString() { -678 return "Dependency{ fileName='" + fileName + "', actualFilePath='" + actualFilePath + "', filePath='" + filePath + "'}"; -679 } -680 } +578 * @param vulnerability a vulnerability outlining a vulnerability. +579 */ +580 public void addVulnerability(Vulnerability vulnerability) { +581 this.vulnerabilities.add(vulnerability); +582 } +583 +584 /** +585 * A collection of related dependencies. +586 */ +587 private Set<Dependency> relatedDependencies = new TreeSet<Dependency>(); +588 +589 /** +590 * Get the value of relatedDependencies. +591 * +592 * @return the value of relatedDependencies +593 */ +594 public Set<Dependency> getRelatedDependencies() { +595 return relatedDependencies; +596 } +597 +598 /** +599 * Set the value of relatedDependencies. +600 * +601 * @param relatedDependencies new value of relatedDependencies +602 */ +603 public void setRelatedDependencies(Set<Dependency> relatedDependencies) { +604 this.relatedDependencies = relatedDependencies; +605 } +606 +607 /** +608 * Adds a related dependency. +609 * +610 * @param dependency a reference to the related dependency +611 */ +612 public void addRelatedDependency(Dependency dependency) { +613 relatedDependencies.add(dependency); +614 } +615 +616 /** +617 * Implementation of the Comparable<Dependency> interface. The comparison is solely based on the file name. +618 * +619 * @param o a dependency to compare +620 * @return an integer representing the natural ordering +621 */ +622 public int compareTo(Dependency o) { +623 return this.getFilePath().compareToIgnoreCase(o.getFilePath()); +624 } +625 +626 /** +627 * Implementation of the equals method. +628 * +629 * @param obj the object to compare +630 * @return true if the objects are equal, otherwise false +631 */ +632 @Override +633 public boolean equals(Object obj) { +634 if (obj == null) { +635 return false; +636 } +637 if (getClass() != obj.getClass()) { +638 return false; +639 } +640 final Dependency other = (Dependency) obj; +641 if ((this.actualFilePath == null) ? (other.actualFilePath != null) : !this.actualFilePath.equals(other.actualFilePath)) { +642 return false; +643 } +644 if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { +645 return false; +646 } +647 if ((this.fileName == null) ? (other.fileName != null) : !this.fileName.equals(other.fileName)) { +648 return false; +649 } +650 if ((this.fileExtension == null) ? (other.fileExtension != null) : !this.fileExtension.equals(other.fileExtension)) { +651 return false; +652 } +653 if ((this.md5sum == null) ? (other.md5sum != null) : !this.md5sum.equals(other.md5sum)) { +654 return false; +655 } +656 if ((this.sha1sum == null) ? (other.sha1sum != null) : !this.sha1sum.equals(other.sha1sum)) { +657 return false; +658 } +659 if (this.identifiers != other.identifiers && (this.identifiers == null || !this.identifiers.equals(other.identifiers))) { +660 return false; +661 } +662 if (this.vendorEvidence != other.vendorEvidence && (this.vendorEvidence == null || !this.vendorEvidence.equals(other.vendorEvidence))) { +663 return false; +664 } +665 if (this.productEvidence != other.productEvidence && (this.productEvidence == null || !this.productEvidence.equals(other.productEvidence))) { +666 return false; +667 } +668 if (this.versionEvidence != other.versionEvidence && (this.versionEvidence == null || !this.versionEvidence.equals(other.versionEvidence))) { +669 return false; +670 } +671 if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) { +672 return false; +673 } +674 if ((this.license == null) ? (other.license != null) : !this.license.equals(other.license)) { +675 return false; +676 } +677 if (this.vulnerabilities != other.vulnerabilities && (this.vulnerabilities == null || !this.vulnerabilities.equals(other.vulnerabilities))) { +678 return false; +679 } +680 if (this.relatedDependencies != other.relatedDependencies +681 && (this.relatedDependencies == null || !this.relatedDependencies.equals(other.relatedDependencies))) { +682 return false; +683 } +684 return true; +685 } +686 +687 /** +688 * Generates the HashCode. +689 * +690 * @return the HashCode +691 */ +692 @Override +693 public int hashCode() { +694 int hash = 3; +695 hash = 47 * hash + (this.actualFilePath != null ? this.actualFilePath.hashCode() : 0); +696 hash = 47 * hash + (this.filePath != null ? this.filePath.hashCode() : 0); +697 hash = 47 * hash + (this.fileName != null ? this.fileName.hashCode() : 0); +698 hash = 47 * hash + (this.fileExtension != null ? this.fileExtension.hashCode() : 0); +699 hash = 47 * hash + (this.md5sum != null ? this.md5sum.hashCode() : 0); +700 hash = 47 * hash + (this.sha1sum != null ? this.sha1sum.hashCode() : 0); +701 hash = 47 * hash + (this.identifiers != null ? this.identifiers.hashCode() : 0); +702 hash = 47 * hash + (this.vendorEvidence != null ? this.vendorEvidence.hashCode() : 0); +703 hash = 47 * hash + (this.productEvidence != null ? this.productEvidence.hashCode() : 0); +704 hash = 47 * hash + (this.versionEvidence != null ? this.versionEvidence.hashCode() : 0); +705 hash = 47 * hash + (this.description != null ? this.description.hashCode() : 0); +706 hash = 47 * hash + (this.license != null ? this.license.hashCode() : 0); +707 hash = 47 * hash + (this.vulnerabilities != null ? this.vulnerabilities.hashCode() : 0); +708 hash = 47 * hash + (this.relatedDependencies != null ? this.relatedDependencies.hashCode() : 0); +709 return hash; +710 } +711 +712 /** +713 * Standard toString() implementation showing the filename, actualFilePath, and filePath. +714 * +715 * @return the string representation of the file +716 */ +717 @Override +718 public String toString() { +719 return "Dependency{ fileName='" + fileName + "', actualFilePath='" + actualFilePath + "', filePath='" + filePath + "'}"; +720 } +721 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-frame.html index 852887688..7747e89b5 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.dependency + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.dependency diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-summary.html index 15e9086f6..a3ee8fd15 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/dependency/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.dependency + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.dependency diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-frame.html index b769db0d5..553ddd3bb 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.exception + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.exception diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-summary.html index ed324c648..32457e463 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/exception/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.exception + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.exception diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-frame.html index 6a34981be..369dc1a57 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.jaxb.pom.generated + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.jaxb.pom.generated diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-summary.html index 99cd42f53..4cabd35a7 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/generated/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.jaxb.pom.generated + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.jaxb.pom.generated diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-frame.html index d38eaf882..534cb45c7 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.jaxb.pom + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.jaxb.pom diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-summary.html index c8399d054..a5c9c0c39 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/jaxb/pom/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.jaxb.pom + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.jaxb.pom diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/package-frame.html index b2e08f58b..05920dfbb 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/package-summary.html index b2210ea40..d34f4968d 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/reporting/ReportGenerator.html b/dependency-check-core/xref/org/owasp/dependencycheck/reporting/ReportGenerator.html index 123aa5590..d49b8c96d 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/reporting/ReportGenerator.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/reporting/ReportGenerator.html @@ -175,96 +175,109 @@ 167 */ 168 public void generateReports(String outputDir, String outputFormat) throws IOException, Exception { 169 final String format = outputFormat.toUpperCase(); -170 if (format.matches("^(XML|HTML|VULN|ALL)$")) { -171 if ("XML".equalsIgnoreCase(format)) { -172 generateReports(outputDir, Format.XML); -173 } -174 if ("HTML".equalsIgnoreCase(format)) { -175 generateReports(outputDir, Format.HTML); -176 } -177 if ("VULN".equalsIgnoreCase(format)) { -178 generateReports(outputDir, Format.VULN); -179 } -180 if ("ALL".equalsIgnoreCase(format)) { -181 generateReports(outputDir, Format.ALL); -182 } -183 } -184 } -185 -186 /** -187 * Generates a report from a given Velocity Template. The template name provided can be the name of a template -188 * contained in the jar file, such as 'XmlReport' or 'HtmlReport', or the template name can be the path to a -189 * template file. -190 * -191 * @param templateName the name of the template to load. -192 * @param outFileName the filename and path to write the report to. -193 * @throws IOException is thrown when the template file does not exist. -194 * @throws Exception is thrown when an exception occurs. -195 */ -196 protected void generateReport(String templateName, String outFileName) throws IOException, Exception { -197 InputStream input = null; -198 String templatePath = null; -199 final File f = new File(templateName); -200 if (f.exists() && f.isFile()) { -201 try { -202 templatePath = templateName; -203 input = new FileInputStream(f); -204 } catch (FileNotFoundException ex) { -205 final String msg = "Unable to generate the report, the report template file could not be found."; -206 LOGGER.log(Level.SEVERE, msg); -207 LOGGER.log(Level.FINE, null, ex); -208 } -209 } else { -210 templatePath = "templates/" + templateName + ".vsl"; -211 input = this.getClass().getClassLoader().getResourceAsStream(templatePath); -212 } -213 if (input == null) { -214 throw new IOException("Template file doesn't exist"); -215 } -216 -217 final InputStreamReader reader = new InputStreamReader(input, "UTF-8"); -218 OutputStreamWriter writer = null; -219 OutputStream outputStream = null; -220 -221 try { -222 final File outDir = new File(outFileName).getParentFile(); -223 if (!outDir.exists()) { -224 final boolean created = outDir.mkdirs(); -225 if (!created) { -226 throw new Exception("Unable to create directory '" + outDir.getAbsolutePath() + "'."); -227 } -228 } +170 final String pathToCheck = outputDir.toLowerCase(); +171 if (format.matches("^(XML|HTML|VULN|ALL)$")) { +172 if ("XML".equalsIgnoreCase(format)) { +173 if (pathToCheck.endsWith(".xml")) { +174 generateReport("XmlReport", outputDir); +175 } else { +176 generateReports(outputDir, Format.XML); +177 } +178 } +179 if ("HTML".equalsIgnoreCase(format)) { +180 if (pathToCheck.endsWith(".html") || pathToCheck.endsWith(".htm")) { +181 generateReport("HtmlReport", outputDir); +182 } else { +183 generateReports(outputDir, Format.HTML); +184 } +185 } +186 if ("VULN".equalsIgnoreCase(format)) { +187 if (pathToCheck.endsWith(".html") || pathToCheck.endsWith(".htm")) { +188 generateReport("VulnReport", outputDir); +189 } else { +190 generateReports(outputDir, Format.VULN); +191 } +192 } +193 if ("ALL".equalsIgnoreCase(format)) { +194 generateReports(outputDir, Format.ALL); +195 } +196 } +197 } +198 +199 /** +200 * Generates a report from a given Velocity Template. The template name provided can be the name of a template +201 * contained in the jar file, such as 'XmlReport' or 'HtmlReport', or the template name can be the path to a +202 * template file. +203 * +204 * @param templateName the name of the template to load. +205 * @param outFileName the filename and path to write the report to. +206 * @throws IOException is thrown when the template file does not exist. +207 * @throws Exception is thrown when an exception occurs. +208 */ +209 protected void generateReport(String templateName, String outFileName) throws IOException, Exception { +210 InputStream input = null; +211 String templatePath = null; +212 final File f = new File(templateName); +213 if (f.exists() && f.isFile()) { +214 try { +215 templatePath = templateName; +216 input = new FileInputStream(f); +217 } catch (FileNotFoundException ex) { +218 final String msg = "Unable to generate the report, the report template file could not be found."; +219 LOGGER.log(Level.SEVERE, msg); +220 LOGGER.log(Level.FINE, null, ex); +221 } +222 } else { +223 templatePath = "templates/" + templateName + ".vsl"; +224 input = this.getClass().getClassLoader().getResourceAsStream(templatePath); +225 } +226 if (input == null) { +227 throw new IOException("Template file doesn't exist"); +228 } 229 -230 outputStream = new FileOutputStream(outFileName); -231 writer = new OutputStreamWriter(outputStream, "UTF-8"); -232 -233 if (!engine.evaluate(context, writer, templatePath, reader)) { -234 throw new Exception("Failed to convert the template into html."); -235 } -236 writer.flush(); -237 } finally { -238 if (writer != null) { -239 try { -240 writer.close(); -241 } catch (IOException ex) { -242 LOGGER.log(Level.FINEST, null, ex); -243 } -244 } -245 if (outputStream != null) { -246 try { -247 outputStream.close(); -248 } catch (IOException ex) { -249 LOGGER.log(Level.FINEST, null, ex); -250 } -251 } -252 try { -253 reader.close(); -254 } catch (IOException ex) { -255 LOGGER.log(Level.FINEST, null, ex); -256 } -257 } -258 } -259 } +230 final InputStreamReader reader = new InputStreamReader(input, "UTF-8"); +231 OutputStreamWriter writer = null; +232 OutputStream outputStream = null; +233 +234 try { +235 final File outDir = new File(outFileName).getParentFile(); +236 if (!outDir.exists()) { +237 final boolean created = outDir.mkdirs(); +238 if (!created) { +239 throw new Exception("Unable to create directory '" + outDir.getAbsolutePath() + "'."); +240 } +241 } +242 +243 outputStream = new FileOutputStream(outFileName); +244 writer = new OutputStreamWriter(outputStream, "UTF-8"); +245 +246 if (!engine.evaluate(context, writer, templatePath, reader)) { +247 throw new Exception("Failed to convert the template into html."); +248 } +249 writer.flush(); +250 } finally { +251 if (writer != null) { +252 try { +253 writer.close(); +254 } catch (IOException ex) { +255 LOGGER.log(Level.FINEST, null, ex); +256 } +257 } +258 if (outputStream != null) { +259 try { +260 outputStream.close(); +261 } catch (IOException ex) { +262 LOGGER.log(Level.FINEST, null, ex); +263 } +264 } +265 try { +266 reader.close(); +267 } catch (IOException ex) { +268 LOGGER.log(Level.FINEST, null, ex); +269 } +270 } +271 } +272 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-frame.html index d23497425..50767911a 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.reporting + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.reporting diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-summary.html index 74a030fbe..d3b3499bb 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/reporting/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.reporting + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.reporting diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionParseException.html b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionParseException.html index 98f2a279f..a9b76cf3b 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionParseException.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionParseException.html @@ -35,45 +35,40 @@ 27 public class SuppressionParseException extends IOException { 28 29 /** -30 * The serial version UID. +30 * Creates a new SuppressionParseException. 31 */ -32 private static final long serialVersionUID = 1L; -33 -34 /** -35 * Creates a new SuppressionParseException. -36 */ -37 public SuppressionParseException() { -38 super(); -39 } -40 -41 /** -42 * Creates a new SuppressionParseException. -43 * -44 * @param msg a message for the exception. -45 */ -46 public SuppressionParseException(String msg) { -47 super(msg); -48 } -49 -50 /** -51 * Creates a new SuppressionParseException. -52 * -53 * @param ex the cause of the download failure. -54 */ -55 public SuppressionParseException(Throwable ex) { -56 super(ex); -57 } -58 -59 /** -60 * Creates a new SuppressionParseException. -61 * -62 * @param msg a message for the exception. -63 * @param ex the cause of the download failure. -64 */ -65 public SuppressionParseException(String msg, Throwable ex) { -66 super(msg, ex); -67 } -68 } +32 public SuppressionParseException() { +33 super(); +34 } +35 +36 /** +37 * Creates a new SuppressionParseException. +38 * +39 * @param msg a message for the exception. +40 */ +41 public SuppressionParseException(String msg) { +42 super(msg); +43 } +44 +45 /** +46 * Creates a new SuppressionParseException. +47 * +48 * @param ex the cause of the parse exception +49 */ +50 public SuppressionParseException(Throwable ex) { +51 super(ex); +52 } +53 +54 /** +55 * Creates a new SuppressionParseException. +56 * +57 * @param msg a message for the exception. +58 * @param ex the cause of the parse exception +59 */ +60 public SuppressionParseException(String msg, Throwable ex) { +61 super(msg, ex); +62 } +63 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionRule.html b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionRule.html index 174403973..6bbc0de3b 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionRule.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/SuppressionRule.html @@ -274,218 +274,222 @@ 266 return gav != null; 267 } 268 -269 private boolean base; -270 -271 /** -272 * Get the value of base -273 * -274 * @return the value of base -275 */ -276 public boolean isBase() { -277 return base; -278 } -279 -280 /** -281 * Set the value of base -282 * -283 * @param base new value of base -284 */ -285 public void setBase(boolean base) { -286 this.base = base; -287 } -288 -289 /** -290 * Processes a given dependency to determine if any CPE, CVE, CWE, or CVSS scores should be suppressed. If any -291 * should be, they are removed from the dependency. -292 * -293 * @param dependency a project dependency to analyze -294 */ -295 public void process(Dependency dependency) { -296 if (filePath != null && !filePath.matches(dependency.getFilePath())) { -297 return; -298 } -299 if (sha1 != null && !sha1.equalsIgnoreCase(dependency.getSha1sum())) { -300 return; -301 } -302 if (gav != null) { -303 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); -304 boolean gavFound = false; -305 while (itr.hasNext()) { -306 final Identifier i = itr.next(); -307 if (identifierMatches("maven", this.gav, i)) { -308 gavFound = true; -309 break; -310 } -311 } -312 if (!gavFound) { -313 return; -314 } -315 } -316 -317 if (this.hasCpe()) { -318 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); -319 while (itr.hasNext()) { -320 final Identifier i = itr.next(); -321 for (PropertyType c : this.cpe) { -322 if (identifierMatches("cpe", c, i)) { -323 if (!isBase()) { -324 dependency.addSuppressedIdentifier(i); -325 } -326 itr.remove(); -327 break; -328 } -329 } -330 } -331 } -332 if (hasCve() || hasCwe() || hasCvssBelow()) { -333 final Iterator<Vulnerability> itr = dependency.getVulnerabilities().iterator(); -334 while (itr.hasNext()) { -335 boolean remove = false; -336 final Vulnerability v = itr.next(); -337 for (String entry : this.cve) { -338 if (entry.equalsIgnoreCase(v.getName())) { -339 remove = true; -340 break; -341 } -342 } -343 if (!remove) { -344 for (String entry : this.cwe) { -345 if (v.getCwe() != null) { -346 final String toMatch = String.format("CWE-%s ", entry); -347 final String toTest = v.getCwe().substring(0, toMatch.length()).toUpperCase(); -348 if (toTest.equals(toMatch)) { -349 remove = true; -350 break; -351 } -352 } -353 } -354 } -355 if (!remove) { -356 for (float cvss : this.cvssBelow) { -357 if (v.getCvssScore() < cvss) { -358 remove = true; -359 break; -360 } -361 } -362 } -363 if (remove) { -364 if (!isBase()) { -365 dependency.addSuppressedVulnerability(v); -366 } -367 itr.remove(); -368 } -369 } -370 } -371 } -372 -373 /** -374 * Identifies if the cpe specified by the cpe suppression rule does not specify a version. -375 * -376 * @param c a suppression rule identifier -377 * @return true if the property type does not specify a version; otherwise false -378 */ -379 boolean cpeHasNoVersion(PropertyType c) { -380 if (c.isRegex()) { -381 return false; -382 } -383 if (countCharacter(c.getValue(), ':') == 3) { -384 return true; -385 } -386 return false; -387 } -388 -389 /** -390 * Counts the number of occurrences of the character found within the string. -391 * -392 * @param str the string to check -393 * @param c the character to count -394 * @return the number of times the character is found in the string -395 */ -396 int countCharacter(String str, char c) { -397 int count = 0; -398 int pos = str.indexOf(c) + 1; -399 while (pos > 0) { -400 count += 1; -401 pos = str.indexOf(c, pos) + 1; -402 } -403 return count; -404 } -405 -406 /** -407 * Determines if the cpeEntry specified as a PropertyType matches the given Identifier. -408 * -409 * @param identifierType the type of identifier ("cpe", "maven", etc.) -410 * @param suppressionEntry a suppression rule entry -411 * @param identifier a CPE identifier to check -412 * @return true if the entry matches; otherwise false -413 */ -414 boolean identifierMatches(String identifierType, PropertyType suppressionEntry, Identifier identifier) { -415 if (identifierType.equals(identifier.getType())) { -416 if (suppressionEntry.matches(identifier.getValue())) { -417 return true; -418 } else if ("cpe".equals(identifierType) && cpeHasNoVersion(suppressionEntry)) { -419 if (suppressionEntry.isCaseSensitive()) { -420 return identifier.getValue().startsWith(suppressionEntry.getValue()); -421 } else { -422 final String id = identifier.getValue().toLowerCase(); -423 final String check = suppressionEntry.getValue().toLowerCase(); -424 return id.startsWith(check); -425 } -426 } -427 } -428 return false; -429 } -430 -431 /** -432 * Standard toString implementation. -433 * -434 * @return a string representation of this object -435 */ -436 @Override -437 public String toString() { -438 final StringBuilder sb = new StringBuilder(); -439 sb.append("SuppressionRule{"); -440 if (filePath != null) { -441 sb.append("filePath=").append(filePath).append(","); -442 } -443 if (sha1 != null) { -444 sb.append("sha1=").append(sha1).append(","); -445 } -446 if (gav != null) { -447 sb.append("gav=").append(gav).append(","); -448 } -449 if (cpe != null && cpe.size() > 0) { -450 sb.append("cpe={"); -451 for (PropertyType pt : cpe) { -452 sb.append(pt).append(","); -453 } -454 sb.append("}"); -455 } -456 if (cwe != null && cwe.size() > 0) { -457 sb.append("cwe={"); -458 for (String s : cwe) { -459 sb.append(s).append(","); -460 } -461 sb.append("}"); -462 } -463 if (cve != null && cve.size() > 0) { -464 sb.append("cve={"); -465 for (String s : cve) { -466 sb.append(s).append(","); -467 } -468 sb.append("}"); -469 } -470 if (cvssBelow != null && cvssBelow.size() > 0) { -471 sb.append("cvssBelow={"); -472 for (Float s : cvssBelow) { -473 sb.append(s).append(","); -474 } -475 sb.append("}"); -476 } -477 sb.append("}"); -478 return sb.toString(); -479 } -480 } +269 /** +270 * A flag indicating whether or not the suppression rule is a core/base rule that should not be included in the +271 * resulting report in the "suppressed" section. +272 */ +273 private boolean base; +274 +275 /** +276 * Get the value of base. +277 * +278 * @return the value of base +279 */ +280 public boolean isBase() { +281 return base; +282 } +283 +284 /** +285 * Set the value of base. +286 * +287 * @param base new value of base +288 */ +289 public void setBase(boolean base) { +290 this.base = base; +291 } +292 +293 /** +294 * Processes a given dependency to determine if any CPE, CVE, CWE, or CVSS scores should be suppressed. If any +295 * should be, they are removed from the dependency. +296 * +297 * @param dependency a project dependency to analyze +298 */ +299 public void process(Dependency dependency) { +300 if (filePath != null && !filePath.matches(dependency.getFilePath())) { +301 return; +302 } +303 if (sha1 != null && !sha1.equalsIgnoreCase(dependency.getSha1sum())) { +304 return; +305 } +306 if (gav != null) { +307 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); +308 boolean gavFound = false; +309 while (itr.hasNext()) { +310 final Identifier i = itr.next(); +311 if (identifierMatches("maven", this.gav, i)) { +312 gavFound = true; +313 break; +314 } +315 } +316 if (!gavFound) { +317 return; +318 } +319 } +320 +321 if (this.hasCpe()) { +322 final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); +323 while (itr.hasNext()) { +324 final Identifier i = itr.next(); +325 for (PropertyType c : this.cpe) { +326 if (identifierMatches("cpe", c, i)) { +327 if (!isBase()) { +328 dependency.addSuppressedIdentifier(i); +329 } +330 itr.remove(); +331 break; +332 } +333 } +334 } +335 } +336 if (hasCve() || hasCwe() || hasCvssBelow()) { +337 final Iterator<Vulnerability> itr = dependency.getVulnerabilities().iterator(); +338 while (itr.hasNext()) { +339 boolean remove = false; +340 final Vulnerability v = itr.next(); +341 for (String entry : this.cve) { +342 if (entry.equalsIgnoreCase(v.getName())) { +343 remove = true; +344 break; +345 } +346 } +347 if (!remove) { +348 for (String entry : this.cwe) { +349 if (v.getCwe() != null) { +350 final String toMatch = String.format("CWE-%s ", entry); +351 final String toTest = v.getCwe().substring(0, toMatch.length()).toUpperCase(); +352 if (toTest.equals(toMatch)) { +353 remove = true; +354 break; +355 } +356 } +357 } +358 } +359 if (!remove) { +360 for (float cvss : this.cvssBelow) { +361 if (v.getCvssScore() < cvss) { +362 remove = true; +363 break; +364 } +365 } +366 } +367 if (remove) { +368 if (!isBase()) { +369 dependency.addSuppressedVulnerability(v); +370 } +371 itr.remove(); +372 } +373 } +374 } +375 } +376 +377 /** +378 * Identifies if the cpe specified by the cpe suppression rule does not specify a version. +379 * +380 * @param c a suppression rule identifier +381 * @return true if the property type does not specify a version; otherwise false +382 */ +383 boolean cpeHasNoVersion(PropertyType c) { +384 if (c.isRegex()) { +385 return false; +386 } +387 if (countCharacter(c.getValue(), ':') == 3) { +388 return true; +389 } +390 return false; +391 } +392 +393 /** +394 * Counts the number of occurrences of the character found within the string. +395 * +396 * @param str the string to check +397 * @param c the character to count +398 * @return the number of times the character is found in the string +399 */ +400 int countCharacter(String str, char c) { +401 int count = 0; +402 int pos = str.indexOf(c) + 1; +403 while (pos > 0) { +404 count += 1; +405 pos = str.indexOf(c, pos) + 1; +406 } +407 return count; +408 } +409 +410 /** +411 * Determines if the cpeEntry specified as a PropertyType matches the given Identifier. +412 * +413 * @param identifierType the type of identifier ("cpe", "maven", etc.) +414 * @param suppressionEntry a suppression rule entry +415 * @param identifier a CPE identifier to check +416 * @return true if the entry matches; otherwise false +417 */ +418 boolean identifierMatches(String identifierType, PropertyType suppressionEntry, Identifier identifier) { +419 if (identifierType.equals(identifier.getType())) { +420 if (suppressionEntry.matches(identifier.getValue())) { +421 return true; +422 } else if ("cpe".equals(identifierType) && cpeHasNoVersion(suppressionEntry)) { +423 if (suppressionEntry.isCaseSensitive()) { +424 return identifier.getValue().startsWith(suppressionEntry.getValue()); +425 } else { +426 final String id = identifier.getValue().toLowerCase(); +427 final String check = suppressionEntry.getValue().toLowerCase(); +428 return id.startsWith(check); +429 } +430 } +431 } +432 return false; +433 } +434 +435 /** +436 * Standard toString implementation. +437 * +438 * @return a string representation of this object +439 */ +440 @Override +441 public String toString() { +442 final StringBuilder sb = new StringBuilder(); +443 sb.append("SuppressionRule{"); +444 if (filePath != null) { +445 sb.append("filePath=").append(filePath).append(","); +446 } +447 if (sha1 != null) { +448 sb.append("sha1=").append(sha1).append(","); +449 } +450 if (gav != null) { +451 sb.append("gav=").append(gav).append(","); +452 } +453 if (cpe != null && cpe.size() > 0) { +454 sb.append("cpe={"); +455 for (PropertyType pt : cpe) { +456 sb.append(pt).append(","); +457 } +458 sb.append("}"); +459 } +460 if (cwe != null && cwe.size() > 0) { +461 sb.append("cwe={"); +462 for (String s : cwe) { +463 sb.append(s).append(","); +464 } +465 sb.append("}"); +466 } +467 if (cve != null && cve.size() > 0) { +468 sb.append("cve={"); +469 for (String s : cve) { +470 sb.append(s).append(","); +471 } +472 sb.append("}"); +473 } +474 if (cvssBelow != null && cvssBelow.size() > 0) { +475 sb.append("cvssBelow={"); +476 for (Float s : cvssBelow) { +477 sb.append(s).append(","); +478 } +479 sb.append("}"); +480 } +481 sb.append("}"); +482 return sb.toString(); +483 } +484 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-frame.html index 9486eb4c2..93401221f 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.suppression + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.suppression diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-summary.html index a490c6421..4264970b7 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/suppression/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.suppression + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.suppression diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/utils/DBUtils.html b/dependency-check-core/xref/org/owasp/dependencycheck/utils/DBUtils.html index fdaf8071d..214d91ce1 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/utils/DBUtils.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/utils/DBUtils.html @@ -62,46 +62,48 @@ 54 int id = 0; 55 try { 56 rs = statement.getGeneratedKeys(); -57 rs.next(); -58 id = rs.getInt(1); -59 } catch (SQLException ex) { -60 throw new DatabaseException("Unable to get primary key for inserted row"); -61 } finally { -62 closeResultSet(rs); -63 } -64 return id; -65 } -66 -67 /** -68 * Closes the given statement object ignoring any exceptions that occur. -69 * -70 * @param statement a Statement object -71 */ -72 public static void closeStatement(Statement statement) { -73 if (statement != null) { -74 try { -75 statement.close(); -76 } catch (SQLException ex) { -77 LOGGER.log(Level.FINEST, statement.toString(), ex); -78 } -79 } -80 } -81 -82 /** -83 * Closes the result set capturing and ignoring any SQLExceptions that occur. -84 * -85 * @param rs a ResultSet to close -86 */ -87 public static void closeResultSet(ResultSet rs) { -88 if (rs != null) { -89 try { -90 rs.close(); -91 } catch (SQLException ex) { -92 LOGGER.log(Level.FINEST, rs.toString(), ex); -93 } -94 } -95 } -96 } +57 if (!rs.next()) { +58 throw new DatabaseException("Unable to get primary key for inserted row"); +59 } +60 id = rs.getInt(1); +61 } catch (SQLException ex) { +62 throw new DatabaseException("Unable to get primary key for inserted row"); +63 } finally { +64 closeResultSet(rs); +65 } +66 return id; +67 } +68 +69 /** +70 * Closes the given statement object ignoring any exceptions that occur. +71 * +72 * @param statement a Statement object +73 */ +74 public static void closeStatement(Statement statement) { +75 if (statement != null) { +76 try { +77 statement.close(); +78 } catch (SQLException ex) { +79 LOGGER.log(Level.FINEST, statement.toString(), ex); +80 } +81 } +82 } +83 +84 /** +85 * Closes the result set capturing and ignoring any SQLExceptions that occur. +86 * +87 * @param rs a ResultSet to close +88 */ +89 public static void closeResultSet(ResultSet rs) { +90 if (rs != null) { +91 try { +92 rs.close(); +93 } catch (SQLException ex) { +94 LOGGER.log(Level.FINEST, rs.toString(), ex); +95 } +96 } +97 } +98 }
    diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersion.html b/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersion.html index 63380d61c..0fe296227 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersion.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersion.html @@ -73,7 +73,7 @@ 65 public final void parseVersion(String version) { 66 versionParts = new ArrayList<String>(); 67 if (version != null) { -68 final Pattern rx = Pattern.compile("(\\d+|[a-z]+\\d+|(release|beta|alpha)$)"); +68 final Pattern rx = Pattern.compile("(\\d+[a-z]{1,3}$|[a-z]+\\d+|\\d+|(release|beta|alpha)$)"); 69 final Matcher matcher = rx.matcher(version.toLowerCase()); 70 while (matcher.find()) { 71 versionParts.add(matcher.group()); @@ -206,8 +206,8 @@ 198 199 boolean ret = true; 200 for (int i = 0; i < max; i++) { -201 String thisVersion = this.versionParts.get(i); -202 String otherVersion = version.getVersionParts().get(i); +201 final String thisVersion = this.versionParts.get(i); +202 final String otherVersion = version.getVersionParts().get(i); 203 if (i >= 3) { 204 if (thisVersion.compareToIgnoreCase(otherVersion) >= 0) { 205 ret = false; diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersionUtil.html b/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersionUtil.html index 246742c98..7a206edc0 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersionUtil.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/utils/DependencyVersionUtil.html @@ -40,7 +40,7 @@ 32 /** 33 * Regular expression to extract version numbers from file names. 34 */ -35 private static final Pattern RX_VERSION = Pattern.compile("\\d+(\\.\\d{1,6})+(\\.?([_-](release|beta|alpha)|[a-zA-Z_-]{1,3}\\d{1,8}))?"); +35 private static final Pattern RX_VERSION = Pattern.compile("\\d+(\\.\\d{1,6})+(\\.?([_-](release|beta|alpha|\\d+)|[a-zA-Z_-]{1,3}\\d{0,8}))?"); 36 /** 37 * Regular expression to extract a single version number without periods. This is a last ditch effort just to check 38 * in case we are missing a version number using the previous regex. diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-frame.html b/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-frame.html index b4a761ea2..2dc071204 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-frame.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-summary.html b/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-summary.html index eb8b664d1..e2b7538be 100644 --- a/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-summary.html +++ b/dependency-check-core/xref/org/owasp/dependencycheck/utils/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Core 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-core/xref/overview-frame.html b/dependency-check-core/xref/overview-frame.html index e30838387..16382768c 100644 --- a/dependency-check-core/xref/overview-frame.html +++ b/dependency-check-core/xref/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference + Dependency-Check Core 1.2.6 Reference @@ -26,6 +26,9 @@
  • org.owasp.dependencycheck.analyzer.exception +
  • +
  • + org.owasp.dependencycheck.data.central
  • org.owasp.dependencycheck.data.cpe diff --git a/dependency-check-core/xref/overview-summary.html b/dependency-check-core/xref/overview-summary.html index 61ff8dd43..d93f3faf6 100644 --- a/dependency-check-core/xref/overview-summary.html +++ b/dependency-check-core/xref/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Core 1.2.5 Reference + Dependency-Check Core 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Core 1.2.5 Reference

    +

    Dependency-Check Core 1.2.6 Reference

    @@ -52,6 +52,11 @@ + + + - +
    org.owasp.dependencycheck.analyzer.exception
    + org.owasp.dependencycheck.data.central +
    diff --git a/dependency-check-jenkins/index.html b/dependency-check-jenkins/index.html index f78aba029..44445ed87 100644 --- a/dependency-check-jenkins/index.html +++ b/dependency-check-jenkins/index.html @@ -1,13 +1,13 @@ - + dependency-check-jenkins - @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-jenkins/license.html b/dependency-check-jenkins/license.html index 964a632f5..07dd0f4d9 100644 --- a/dependency-check-jenkins/license.html +++ b/dependency-check-jenkins/license.html @@ -1,13 +1,13 @@ - + dependency-check-jenkins - Project License @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-jenkins/project-info.html b/dependency-check-jenkins/project-info.html index b7c231ce2..8a486bebe 100644 --- a/dependency-check-jenkins/project-info.html +++ b/dependency-check-jenkins/project-info.html @@ -1,13 +1,13 @@ - + dependency-check-jenkins - Project Information @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-jenkins/project-summary.html b/dependency-check-jenkins/project-summary.html index 42cfcb7e1..319b51817 100644 --- a/dependency-check-jenkins/project-summary.html +++ b/dependency-check-jenkins/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check-jenkins - Project Summary @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -196,7 +196,7 @@
    dependency-check-jenkins
    Version1.2.5
    1.2.6
    Type pom
    diff --git a/dependency-check-maven/apidocs/allclasses-frame.html b/dependency-check-maven/apidocs/allclasses-frame.html index 0d8750a7a..2fc880542 100644 --- a/dependency-check-maven/apidocs/allclasses-frame.html +++ b/dependency-check-maven/apidocs/allclasses-frame.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Maven Plugin 1.2.5 API) - +All Classes (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/allclasses-noframe.html b/dependency-check-maven/apidocs/allclasses-noframe.html index 81483d18e..9cddfd719 100644 --- a/dependency-check-maven/apidocs/allclasses-noframe.html +++ b/dependency-check-maven/apidocs/allclasses-noframe.html @@ -2,10 +2,10 @@ - + -All Classes (Dependency-Check Maven Plugin 1.2.5 API) - +All Classes (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/constant-values.html b/dependency-check-maven/apidocs/constant-values.html index 451945e11..b872ba3dc 100644 --- a/dependency-check-maven/apidocs/constant-values.html +++ b/dependency-check-maven/apidocs/constant-values.html @@ -2,16 +2,16 @@ - + -Constant Field Values (Dependency-Check Maven Plugin 1.2.5 API) - +Constant Field Values (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/deprecated-list.html b/dependency-check-maven/apidocs/deprecated-list.html index 02f479c7a..f23bd3744 100644 --- a/dependency-check-maven/apidocs/deprecated-list.html +++ b/dependency-check-maven/apidocs/deprecated-list.html @@ -2,16 +2,16 @@ - + -Deprecated List (Dependency-Check Maven Plugin 1.2.5 API) - +Deprecated List (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/help-doc.html b/dependency-check-maven/apidocs/help-doc.html index bd7c0f722..ce733bfb0 100644 --- a/dependency-check-maven/apidocs/help-doc.html +++ b/dependency-check-maven/apidocs/help-doc.html @@ -2,16 +2,16 @@ - + -API Help (Dependency-Check Maven Plugin 1.2.5 API) - +API Help (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/index-all.html b/dependency-check-maven/apidocs/index-all.html index 01c8ae053..e33c8c96a 100644 --- a/dependency-check-maven/apidocs/index-all.html +++ b/dependency-check-maven/apidocs/index-all.html @@ -2,16 +2,16 @@ - + -Index (Dependency-Check Maven Plugin 1.2.5 API) - +Index (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/index.html b/dependency-check-maven/apidocs/index.html index e8e905784..bb215b96f 100644 --- a/dependency-check-maven/apidocs/index.html +++ b/dependency-check-maven/apidocs/index.html @@ -2,9 +2,9 @@ - + -Dependency-Check Maven Plugin 1.2.5 API +Dependency-Check Maven Plugin 1.2.6 API diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/HelpMojo.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/HelpMojo.html index 32950a32a..7c6a6395b 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/HelpMojo.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/HelpMojo.html @@ -2,16 +2,16 @@ - + -HelpMojo (Dependency-Check Maven Plugin 1.2.5 API) - +HelpMojo (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/ReportAggregationMojo.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/ReportAggregationMojo.html index 87a077126..b429f8e2d 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/ReportAggregationMojo.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/ReportAggregationMojo.html @@ -2,16 +2,16 @@ - + -ReportAggregationMojo (Dependency-Check Maven Plugin 1.2.5 API) - +ReportAggregationMojo (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/DependencyCheckMojo.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/DependencyCheckMojo.html index 9168d827d..5856ad259 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/DependencyCheckMojo.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/DependencyCheckMojo.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.maven.DependencyCheckMojo (Dependency-Check Maven Plugin 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.maven.DependencyCheckMojo (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/HelpMojo.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/HelpMojo.html index 7628b42bf..aa519944f 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/HelpMojo.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/HelpMojo.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.maven.HelpMojo (Dependency-Check Maven Plugin 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.maven.HelpMojo (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/ReportAggregationMojo.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/ReportAggregationMojo.html index c8dcb30a6..77aa43104 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/ReportAggregationMojo.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/class-use/ReportAggregationMojo.html @@ -2,16 +2,16 @@ - + -Uses of Class org.owasp.dependencycheck.maven.ReportAggregationMojo (Dependency-Check Maven Plugin 1.2.5 API) - +Uses of Class org.owasp.dependencycheck.maven.ReportAggregationMojo (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-frame.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-frame.html index 3721697c0..2fea09f8f 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-frame.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-frame.html @@ -2,10 +2,10 @@ - + -org.owasp.dependencycheck.maven (Dependency-Check Maven Plugin 1.2.5 API) - +org.owasp.dependencycheck.maven (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-summary.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-summary.html index 07fb8e2e0..c62c93812 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-summary.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-summary.html @@ -2,16 +2,16 @@ - + -org.owasp.dependencycheck.maven (Dependency-Check Maven Plugin 1.2.5 API) - +org.owasp.dependencycheck.maven (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-tree.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-tree.html index 4713e1adb..e169cb087 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-tree.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-tree.html @@ -2,16 +2,16 @@ - + -org.owasp.dependencycheck.maven Class Hierarchy (Dependency-Check Maven Plugin 1.2.5 API) - +org.owasp.dependencycheck.maven Class Hierarchy (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-use.html b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-use.html index 82519b125..f85c8ca2f 100644 --- a/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-use.html +++ b/dependency-check-maven/apidocs/org/owasp/dependencycheck/maven/package-use.html @@ -2,16 +2,16 @@ - + -Uses of Package org.owasp.dependencycheck.maven (Dependency-Check Maven Plugin 1.2.5 API) - +Uses of Package org.owasp.dependencycheck.maven (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/apidocs/overview-tree.html b/dependency-check-maven/apidocs/overview-tree.html index afb165ac4..70a4df21d 100644 --- a/dependency-check-maven/apidocs/overview-tree.html +++ b/dependency-check-maven/apidocs/overview-tree.html @@ -2,16 +2,16 @@ - + -Class Hierarchy (Dependency-Check Maven Plugin 1.2.5 API) - +Class Hierarchy (Dependency-Check Maven Plugin 1.2.6 API) + diff --git a/dependency-check-maven/check-mojo.html b/dependency-check-maven/check-mojo.html index b0c427651..a07d73e09 100644 --- a/dependency-check-maven/check-mojo.html +++ b/dependency-check-maven/check-mojo.html @@ -1,13 +1,13 @@ - + dependency-check-maven - dependency-check:check @@ -55,7 +55,7 @@
  • - + /
  • @@ -69,9 +69,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -165,7 +165,7 @@

    Full name:

    -

    org.owasp:dependency-check-maven:1.2.5:check

    +

    org.owasp:dependency-check-maven:1.2.6:check

    Description:

    diff --git a/dependency-check-maven/checkstyle.html b/dependency-check-maven/checkstyle.html index 1cea0aae5..570986770 100644 --- a/dependency-check-maven/checkstyle.html +++ b/dependency-check-maven/checkstyle.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Checkstyle Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-maven/cobertura/frame-summary-org.owasp.dependencycheck.maven.html b/dependency-check-maven/cobertura/frame-summary-org.owasp.dependencycheck.maven.html index c6e872445..2e43d28e6 100644 --- a/dependency-check-maven/cobertura/frame-summary-org.owasp.dependencycheck.maven.html +++ b/dependency-check-maven/cobertura/frame-summary-org.owasp.dependencycheck.maven.html @@ -16,7 +16,7 @@ - +
    Package # Classes Line Coverage Branch Coverage Complexity
    org.owasp.dependencycheck.maven4
    0%
    0/807
    0%
    0/404
    4.036
    org.owasp.dependencycheck.maven4
    0%
    0/816
    0%
    0/410
    4.072
    - + diff --git a/dependency-check-maven/cobertura/frame-summary.html b/dependency-check-maven/cobertura/frame-summary.html index ebef30df5..e710d70da 100644 --- a/dependency-check-maven/cobertura/frame-summary.html +++ b/dependency-check-maven/cobertura/frame-summary.html @@ -16,8 +16,8 @@ - - + +
    Package # Classes Line Coverage Branch Coverage Complexity
    All Packages4
    0%
    0/807
    0%
    0/404
    4.036
    org.owasp.dependencycheck.maven4
    0%
    0/807
    0%
    0/404
    4.036
    All Packages4
    0%
    0/816
    0%
    0/410
    4.072
    org.owasp.dependencycheck.maven4
    0%
    0/816
    0%
    0/410
    4.072
    - + diff --git a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.DependencyCheckMojo.html b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.DependencyCheckMojo.html index 6d75e862f..520c7e8e2 100644 --- a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.DependencyCheckMojo.html +++ b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.DependencyCheckMojo.html @@ -12,7 +12,7 @@
     
    - +
    Classes in this File Line Coverage Branch Coverage Complexity
    DependencyCheckMojo
    0%
    0/316
    0%
    0/184
    5.96
    DependencyCheckMojo
    0%
    0/325
    0%
    0/190
    6.08
     
    @@ -114,1149 +114,1147 @@
     48  
     import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
     49  
     import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
     import org.owasp.dependencycheck.data.nexus.MavenArtifact;
     50  
     import org.owasp.dependencycheck.dependency.Dependency;
     import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
     51  
     import org.owasp.dependencycheck.dependency.Identifier;
     import org.owasp.dependencycheck.dependency.Confidence;
     52  
     import org.owasp.dependencycheck.dependency.Vulnerability;
     import org.owasp.dependencycheck.dependency.Dependency;
     53  
     import org.owasp.dependencycheck.utils.LogUtils;
     import org.owasp.dependencycheck.dependency.Identifier;
     54  
     import org.owasp.dependencycheck.utils.Settings;
     import org.owasp.dependencycheck.dependency.Vulnerability;
     55  
     
     import org.owasp.dependencycheck.utils.LogUtils;
     56  
     /**
     import org.owasp.dependencycheck.utils.Settings;
     57  
      * Maven Plugin that checks project dependencies to see if they have any known published vulnerabilities.
     
     58  
      *
     /**
     59  
      * @author Jeremy Long <jeremy.long@owasp.org>
      * Maven Plugin that checks project dependencies to see if they have any known published vulnerabilities.
     60  
      */
      *
     61  
     @Mojo(name = "check", defaultPhase = LifecyclePhase.COMPILE, threadSafe = true,
      * @author Jeremy Long <jeremy.long@owasp.org>
     62  
             requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM,
      */
     63  
             requiresOnline = true)
     @Mojo(
     64  
     public class DependencyCheckMojo extends ReportAggregationMojo {
             name = "check",
     65  
     
             defaultPhase = LifecyclePhase.COMPILE,
     66  
         //<editor-fold defaultstate="collapsed" desc="Private fields">
             threadSafe = true,
     67  
         /**
             requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM,
     68  
          * Logger field reference.
             requiresOnline = true
     69  
          */
     70  0
         private static final Logger LOGGER = Logger.getLogger(DependencyCheckMojo.class.getName());
     )
     70  
     public class DependencyCheckMojo extends ReportAggregationMojo {
     71  
         /**
     72  
          * The properties file location.
     73  
          */
     74  
         private static final String PROPERTIES_FILE = "mojo.properties";
     75  
         /**
     76  
          * Name of the logging properties file.
     77  
          */
     78  
         private static final String LOG_PROPERTIES_FILE = "log.properties";
     79  
         /**
     80  
          * System specific new line character.
     81  
          */
     82  0
         private static final String NEW_LINE = System.getProperty("line.separator", "\n").intern();
     83  
         /**
     84  
          * The dependency-check engine used to scan the project.
     85  
          */
     86  0
         private Engine engine = null;
     87  
         //</editor-fold>
     88  
     
     72  
         //<editor-fold defaultstate="collapsed" desc="Private fields">
     73  
         /**
     74  
          * Logger field reference.
     75  
          */
     76  0
         private static final Logger LOGGER = Logger.getLogger(DependencyCheckMojo.class.getName());
     77  
         /**
     78  
          * The properties file location.
     79  
          */
     80  
         private static final String PROPERTIES_FILE = "mojo.properties";
     81  
         /**
     82  
          * Name of the logging properties file.
     83  
          */
     84  
         private static final String LOG_PROPERTIES_FILE = "log.properties";
     85  
         /**
     86  
          * System specific new line character.
     87  
          */
     88  0
         private static final String NEW_LINE = System.getProperty("line.separator", "\n").intern();
     89  
         // <editor-fold defaultstate="collapsed" desc="Maven bound parameters and components">
         /**
     90  
         /**
          * The dependency-check engine used to scan the project.
     91  
          * The path to the verbose log.
     92  
          */
     93  0
         @Parameter(property = "logfile", defaultValue = "")
     92  0
         private Engine engine = null;
     93  
         //</editor-fold>
     94  
         private String logFile = null;
     
     95  
         /**
         // <editor-fold defaultstate="collapsed" desc="Maven bound parameters and components">
     96  
          * The output directory. This generally maps to "target".
     97  
          */
     98  
         @Parameter(defaultValue = "${project.build.directory}", required = true)
     99  
         private File outputDirectory;
     100  
         /**
     97  
          * The path to the verbose log.
     98  
          */
     99  0
         @Parameter(property = "logfile", defaultValue = "")
     100  
         private String logFile = null;
     101  
          * Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11
         /**
     102  
          * which means since the CVSS scores are 0-10, by default the build will never fail.
          * The output directory. This generally maps to "target".
     103  
          */
     104  0
         @SuppressWarnings("CanBeFinal")
     104  
         @Parameter(defaultValue = "${project.build.directory}", required = true)
     105  
         @Parameter(property = "failBuildOnCVSS", defaultValue = "11", required = true)
         private File outputDirectory;
     106  
         private float failBuildOnCVSS = 11;
         /**
     107  
         /**
          * Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11
     108  
          * Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to
          * which means since the CVSS scores are 0-10, by default the build will never fail.
     109  
          * false. Default is true.
     110  
          */
     111  0
         @SuppressWarnings("CanBeFinal")
     110  0
         @SuppressWarnings("CanBeFinal")
     111  
         @Parameter(property = "failBuildOnCVSS", defaultValue = "11", required = true)
     112  
         @Parameter(property = "autoupdate", defaultValue = "true", required = true)
         private float failBuildOnCVSS = 11;
     113  
         private boolean autoUpdate = true;
         /**
     114  
         /**
          * Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to
     115  
          * The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this
          * false. Default is true.
     116  
          * within the Site plugin unless the externalReport is set to true. Default is HTML.
     117  
          */
     118  0
         @SuppressWarnings("CanBeFinal")
     117  0
         @SuppressWarnings("CanBeFinal")
     118  
         @Parameter(property = "autoupdate", defaultValue = "true", required = true)
     119  
         @Parameter(property = "format", defaultValue = "HTML", required = true)
         private boolean autoUpdate = true;
     120  
         private String format = "HTML";
     121  
         /**
     121  
          * The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this
     122  
          * The maven settings.
          * within the Site plugin unless the externalReport is set to true. Default is HTML.
     123  
          */
     124  
         @Parameter(property = "mavenSettings", defaultValue = "${settings}", required = false)
     124  0
         @SuppressWarnings("CanBeFinal")
     125  
         private org.apache.maven.settings.Settings mavenSettings;
         @Parameter(property = "format", defaultValue = "HTML", required = true)
     126  
     
         private String format = "HTML";
     127  
         /**
     128  
          * The maven settings proxy id.
          * The maven settings.
     129  
          */
     130  
         @SuppressWarnings("CanBeFinal")
         @Parameter(property = "mavenSettings", defaultValue = "${settings}", required = false)
     131  
         @Parameter(property = "mavenSettingsProxyId", required = false)
         private org.apache.maven.settings.Settings mavenSettings;
     132  
         private String mavenSettingsProxyId;
     133  
     
     134  
     133  
         /**
     134  
          * The maven settings proxy id.
     135  
          * The Connection Timeout.
     136  
          */
     137  0
         @SuppressWarnings("CanBeFinal")
     136  
         @SuppressWarnings("CanBeFinal")
     137  
         @Parameter(property = "mavenSettingsProxyId", required = false)
     138  
         @Parameter(property = "connectionTimeout", defaultValue = "", required = false)
         private String mavenSettingsProxyId;
     139  
         private String connectionTimeout = null;
     
     140  
         /**
     141  
          * The path to the suppression file.
          * The Connection Timeout.
     142  
          */
     143  0
         @SuppressWarnings("CanBeFinal")
     144  
         @Parameter(property = "suppressionFile", defaultValue = "", required = false)
         @Parameter(property = "connectionTimeout", defaultValue = "", required = false)
     145  
         private String suppressionFile = null;
         private String connectionTimeout = null;
     146  
         /**
     147  
          * Flag indicating whether or not to show a summary in the output.
          * The path to the suppression file.
     148  
          */
     149  0
         @SuppressWarnings("CanBeFinal")
     150  
         @Parameter(property = "showSummary", defaultValue = "true", required = false)
         @Parameter(property = "suppressionFile", defaultValue = "", required = false)
     151  
         private boolean showSummary = true;
         private String suppressionFile = null;
     152  
     
         /**
     153  
         /**
          * Flag indicating whether or not to show a summary in the output.
     154  
          * Whether or not the Jar Analyzer is enabled.
     155  
          */
     156  0
         @SuppressWarnings("CanBeFinal")
     155  0
         @SuppressWarnings("CanBeFinal")
     156  
         @Parameter(property = "showSummary", defaultValue = "true", required = false)
     157  
         @Parameter(property = "jarAnalyzerEnabled", defaultValue = "true", required = false)
         private boolean showSummary = true;
     158  
         private boolean jarAnalyzerEnabled = true;
     
     159  
     
         /**
     160  
         /**
          * Whether or not the Jar Analyzer is enabled.
     161  
          * Whether or not the Archive Analyzer is enabled.
     162  
          */
     163  0
         @SuppressWarnings("CanBeFinal")
     162  0
         @SuppressWarnings("CanBeFinal")
     163  
         @Parameter(property = "jarAnalyzerEnabled", defaultValue = "true", required = false)
     164  
         @Parameter(property = "archiveAnalyzerEnabled", defaultValue = "true", required = false)
         private boolean jarAnalyzerEnabled = true;
     165  
         private boolean archiveAnalyzerEnabled = true;
     
     166  
     
         /**
     167  
         /**
          * Whether or not the Archive Analyzer is enabled.
     168  
          * Whether or not the .NET Assembly Analyzer is enabled.
     169  
          */
     170  0
         @SuppressWarnings("CanBeFinal")
     169  0
         @SuppressWarnings("CanBeFinal")
     170  
         @Parameter(property = "archiveAnalyzerEnabled", defaultValue = "true", required = false)
     171  
         @Parameter(property = "assemblyAnalyzerEnabled", defaultValue = "true", required = false)
         private boolean archiveAnalyzerEnabled = true;
     172  
         private boolean assemblyAnalyzerEnabled = true;
     
     173  
     
         /**
     174  
         /**
          * Whether or not the .NET Assembly Analyzer is enabled.
     175  
          * Whether or not the .NET Nuspec Analyzer is enabled.
     176  
          */
     177  0
         @SuppressWarnings("CanBeFinal")
     176  0
         @SuppressWarnings("CanBeFinal")
     177  
         @Parameter(property = "assemblyAnalyzerEnabled", defaultValue = "true", required = false)
     178  
         @Parameter(property = "nuspecAnalyzerEnabled", defaultValue = "true", required = false)
         private boolean assemblyAnalyzerEnabled = true;
     179  
         private boolean nuspecAnalyzerEnabled = true;
     180  
     
     181  
     180  
         /**
     181  
          * Whether or not the .NET Nuspec Analyzer is enabled.
     182  
          * Whether or not the Nexus Analyzer is enabled.
     183  
          */
     184  0
         @SuppressWarnings("CanBeFinal")
     183  0
         @SuppressWarnings("CanBeFinal")
     184  
         @Parameter(property = "nuspecAnalyzerEnabled", defaultValue = "true", required = false)
     185  
         @Parameter(property = "nexusAnalyzerEnabled", defaultValue = "true", required = false)
         private boolean nuspecAnalyzerEnabled = true;
     186  
         private boolean nexusAnalyzerEnabled = true;
     
     187  
         /**
     188  
          * Whether or not the Nexus Analyzer is enabled.
     189  
          */
     190  
         @Parameter(property = "nexusUrl", defaultValue = "", required = false)
     190  0
         @SuppressWarnings("CanBeFinal")
     191  
         private String nexusUrl;
         @Parameter(property = "nexusAnalyzerEnabled", defaultValue = "true", required = false)
     192  
         /**
         private boolean nexusAnalyzerEnabled = true;
     193  
          * Whether or not the configured proxy is used to connect to Nexus.
         /**
     194  
          * Whether or not the Nexus Analyzer is enabled.
     195  
          */
     195  0
         @Parameter(property = "nexusUsesProxy", defaultValue = "true", required = false)
     196  
         private boolean nexusUsesProxy = true;
         @Parameter(property = "nexusUrl", defaultValue = "", required = false)
     197  
         /**
         private String nexusUrl;
     198  
          * The database connection string.
         /**
     199  
          */
          * Whether or not the configured proxy is used to connect to Nexus.
     200  
         @Parameter(property = "connectionString", defaultValue = "", required = false)
     201  
         private String connectionString;
          */
     201  0
         @Parameter(property = "nexusUsesProxy", defaultValue = "true", required = false)
     202  
         /**
         private boolean nexusUsesProxy = true;
     203  
          * The database driver name. An example would be org.h2.Driver.
         /**
     204  
          */
          * The database connection string.
     205  
         @Parameter(property = "databaseDriverName", defaultValue = "", required = false)
          */
     206  
         private String databaseDriverName;
         @Parameter(property = "connectionString", defaultValue = "", required = false)
     207  
         /**
         private String connectionString;
     208  
          * The path to the database driver if it is not on the class path.
         /**
     209  
          */
          * The database driver name. An example would be org.h2.Driver.
     210  
         @Parameter(property = "databaseDriverPath", defaultValue = "", required = false)
          */
     211  
         private String databaseDriverPath;
         @Parameter(property = "databaseDriverName", defaultValue = "", required = false)
     212  
         /**
         private String databaseDriverName;
     213  
          * The database user name.
         /**
     214  
          */
          * The path to the database driver if it is not on the class path.
     215  
         @Parameter(property = "databaseUser", defaultValue = "", required = false)
          */
     216  
         private String databaseUser;
         @Parameter(property = "databaseDriverPath", defaultValue = "", required = false)
     217  
         /**
         private String databaseDriverPath;
     218  
          * The password to use when connecting to the database.
         /**
     219  
          */
          * The database user name.
     220  
         @Parameter(property = "databasePassword", defaultValue = "", required = false)
          */
     221  
         private String databasePassword;
         @Parameter(property = "databaseUser", defaultValue = "", required = false)
     222  
         /**
         private String databaseUser;
     223  
          * A comma-separated list of file extensions to add to analysis next to jar, zip, ....
     224  
          */
     225  
         @Parameter(property = "zipExtensions", required = false)
     226  
         private String zipExtensions;
     227  
         /**
     228  
          * Skip Analysis for Test Scope Dependencies.
     229  
     224  
          * The password to use when connecting to the database.
     225  
          */
     226  
         @Parameter(property = "databasePassword", defaultValue = "", required = false)
     227  
         private String databasePassword;
     228  
         /**
     229  
          * A comma-separated list of file extensions to add to analysis next to jar, zip, ....
     230  
          */
     230  0
         @SuppressWarnings("CanBeFinal")
     231  
         @Parameter(property = "skipTestScope", defaultValue = "true", required = false)
         @Parameter(property = "zipExtensions", required = false)
     232  
         private boolean skipTestScope = true;
         private String zipExtensions;
     233  
         /**
     234  
          * Skip Analysis for Runtime Scope Dependencies.
          * Skip Analysis for Test Scope Dependencies.
     235  
          */
     236  0
         @SuppressWarnings("CanBeFinal")
     237  
         @Parameter(property = "skipRuntimeScope", defaultValue = "false", required = false)
         @Parameter(property = "skipTestScope", defaultValue = "true", required = false)
     238  
         private boolean skipRuntimeScope = false;
         private boolean skipTestScope = true;
     239  
         /**
     240  
          * Skip Analysis for Provided Scope Dependencies.
          * Skip Analysis for Runtime Scope Dependencies.
     241  
          */
     242  0
         @SuppressWarnings("CanBeFinal")
     243  
         @Parameter(property = "skipProvidedScope", defaultValue = "false", required = false)
         @Parameter(property = "skipRuntimeScope", defaultValue = "false", required = false)
     244  
         private boolean skipProvidedScope = false;
         private boolean skipRuntimeScope = false;
     245  
         /**
     246  
          * The data directory, hold DC SQL DB.
          * Skip Analysis for Provided Scope Dependencies.
     247  
          */
     248  
         @Parameter(property = "dataDirectory", defaultValue = "", required = false)
     248  0
         @SuppressWarnings("CanBeFinal")
     249  
         private String dataDirectory;
         @Parameter(property = "skipProvidedScope", defaultValue = "false", required = false)
     250  
         /**
         private boolean skipProvidedScope = false;
     251  
          * Data Mirror URL for CVE 1.2.
         /**
     252  
          */
          * The data directory, hold DC SQL DB.
     253  
         @Parameter(property = "cveUrl12Modified", defaultValue = "", required = false)
          */
     254  
         private String cveUrl12Modified;
         @Parameter(property = "dataDirectory", defaultValue = "", required = false)
     255  
         /**
         private String dataDirectory;
     256  
          * Data Mirror URL for CVE 2.0.
         /**
     257  
          */
          * Data Mirror URL for CVE 1.2.
     258  
         @Parameter(property = "cveUrl20Modified", defaultValue = "", required = false)
          */
     259  
         private String cveUrl20Modified;
         @Parameter(property = "cveUrl12Modified", defaultValue = "", required = false)
     260  
         /**
         private String cveUrl12Modified;
     261  
          * Base Data Mirror URL for CVE 1.2.
     262  
          */
     263  
         @Parameter(property = "cveUrl12Base", defaultValue = "", required = false)
     264  
         private String cveUrl12Base;
     265  
         /**
     266  
     262  
          * Data Mirror URL for CVE 2.0.
     267  
     263  
          */
     264  
         @Parameter(property = "cveUrl20Modified", defaultValue = "", required = false)
     265  
         private String cveUrl20Modified;
     266  
         /**
     267  
          * Base Data Mirror URL for CVE 1.2.
     268  
         @Parameter(property = "cveUrl20Base", defaultValue = "", required = false)
          */
     269  
         private String cveUrl20Base;
         @Parameter(property = "cveUrl12Base", defaultValue = "", required = false)
     270  
     
         private String cveUrl12Base;
     271  
         /**
     272  
          * The path to mono for .NET Assembly analysis on non-windows systems.
          * Data Mirror URL for CVE 2.0.
     273  
          */
     274  
         @Parameter(property = "pathToMono", defaultValue = "", required = false)
         @Parameter(property = "cveUrl20Base", defaultValue = "", required = false)
     275  
         private String pathToMono;
         private String cveUrl20Base;
     276  
     
     277  
         /**
     278  
          * The Proxy URL.
          * The path to mono for .NET Assembly analysis on non-windows systems.
     279  
          *
          */
     280  
          * @deprecated Please use mavenSettings instead
         @Parameter(property = "pathToMono", defaultValue = "", required = false)
     281  
          */
     282  0
         @SuppressWarnings("CanBeFinal")
         private String pathToMono;
     282  
     
     283  
         @Parameter(property = "proxyUrl", defaultValue = "", required = false)
         /**
     284  
         @Deprecated
          * The Proxy URL.
     285  
         private String proxyUrl = null;
          *
     286  
         /**
          * @deprecated Please use mavenSettings instead
     287  
          * Sets whether or not the external report format should be used.
     288  
          *
          */
     288  0
         @SuppressWarnings("CanBeFinal")
     289  
          * @deprecated the internal report is no longer supported
         @Parameter(property = "proxyUrl", defaultValue = "", required = false)
     290  
          */
     291  0
         @SuppressWarnings("CanBeFinal")
     292  
         @Parameter(property = "externalReport")
     293  
         @Deprecated
     291  
         private String proxyUrl = null;
     292  
         /**
     293  
          * Sets whether or not the external report format should be used.
     294  
         private String externalReport = null;
          *
     295  
         // </editor-fold>
          * @deprecated the internal report is no longer supported
     296  
         /**
     297  
          * Constructs a new dependency-check-mojo.
          */
     297  0
         @SuppressWarnings("CanBeFinal")
     298  
          */
     299  0
         public DependencyCheckMojo() {
     300  0
             final InputStream in = DependencyCheckMojo.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE);
     301  0
             LogUtils.prepareLogger(in, logFile);
     302  0
         }
         @Parameter(property = "externalReport")
     299  
         @Deprecated
     300  
         private String externalReport = null;
     301  
     
     302  
         // </editor-fold>
     303  
     
         /**
     304  
         /**
          * Constructs a new dependency-check-mojo.
     305  
          * Executes the Dependency-Check on the dependent libraries.
     306  
          *
     307  
          * @return the Engine used to scan the dependencies.
     308  
          * @throws DatabaseException thrown if there is an exception connecting to the database
     309  
          */
     306  0
         public DependencyCheckMojo() {
     307  0
             final InputStream in = DependencyCheckMojo.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE);
     308  0
             LogUtils.prepareLogger(in, logFile);
     309  0
         }
     310  
         private Engine executeDependencyCheck() throws DatabaseException {
     311  0
             return executeDependencyCheck(getProject());
     
     311  
         /**
     312  
         }
     313  
     
     314  
         /**
     315  
          * Executes the Dependency-Check on the dependent libraries.
     316  
     313  
          *
     317  
          * @param project the project to run dependency-check on
     318  
     314  
          * @return the Engine used to scan the dependencies.
     319  
     315  
          * @throws DatabaseException thrown if there is an exception connecting to the database
     316  
          */
     317  
         private Engine executeDependencyCheck() throws DatabaseException {
     318  0
             return executeDependencyCheck(getProject());
     319  
         }
     320  
          */
     
     321  
         private Engine executeDependencyCheck(MavenProject project) throws DatabaseException {
     322  0
             final Engine localEngine = initializeEngine();
         /**
     322  
          * Executes the Dependency-Check on the dependent libraries.
     323  
     
     324  0
             final Set<Artifact> artifacts = project.getArtifacts();
     325  0
             for (Artifact a : artifacts) {
     326  0
                 if (excludeFromScan(a)) {
     327  0
                     continue;
          *
     324  
          * @param project the project to run dependency-check on
     325  
          * @return the Engine used to scan the dependencies.
     326  
          * @throws DatabaseException thrown if there is an exception connecting to the database
     327  
          */
     328  
                 }
     329  
         private Engine executeDependencyCheck(MavenProject project) throws DatabaseException {
     329  0
             final Engine localEngine = initializeEngine();
     330  
     
     330  0
                 localEngine.scan(a.getFile().getAbsolutePath());
     331  0
             }
     332  0
             localEngine.analyzeDependencies();
     333  
     
     334  0
             return localEngine;
     331  0
             final Set<Artifact> artifacts = project.getArtifacts();
     332  0
             for (Artifact a : artifacts) {
     333  0
                 if (excludeFromScan(a)) {
     334  0
                     continue;
     335  
         }
     336  
     
     337  
         /**
     338  
          * Initializes a new <code>Engine</code> that can be used for scanning.
     339  
          *
     340  
          * @return a newly instantiated <code>Engine</code>
     341  
          * @throws DatabaseException thrown if there is a database exception
     342  
          */
                 }
     336  0
                 final List<Dependency> deps = localEngine.scan(a.getFile().getAbsoluteFile());
     337  0
                 if (deps != null) {
     338  0
                     if (deps.size() == 1) {
     339  0
                         final Dependency d = deps.get(0);
     340  0
                         if (d != null) {
     341  0
                             final MavenArtifact ma = new MavenArtifact(a.getGroupId(), a.getArtifactId(), a.getVersion());
     342  0
                             d.addAsEvidence("pom", ma, Confidence.HIGHEST);
     343  
         private Engine initializeEngine() throws DatabaseException {
     344  0
             populateSettings();
     345  0
             final Engine localEngine = new Engine();
     346  0
             return localEngine;
     347  
         }
                         }
     344  0
                     } else {
     345  0
                         final String msg = String.format("More then 1 dependency was identified in first pass scan of '%s:%s:%s'",
     346  
                                 a.getGroupId(), a.getArtifactId(), a.getVersion());
     347  0
                         LOGGER.info(msg);
     348  
     
                     }
     349  
         /**
     350  
          * Tests is the artifact should be included in the scan (i.e. is the dependency in a scope that is being scanned).
     351  
          *
                 }
     350  0
             }
     351  0
             localEngine.analyzeDependencies();
     352  
          * @param a the Artifact to test
     353  
          * @return <code>true</code> if the artifact is in an excluded scope; otherwise <code>false</code>
     
     353  0
             return localEngine;
     354  
          */
         }
     355  
         private boolean excludeFromScan(Artifact a) {
     356  0
             if (skipTestScope && Artifact.SCOPE_TEST.equals(a.getScope())) {
     357  0
                 return true;
     
     356  
         /**
     357  
          * Initializes a new <code>Engine</code> that can be used for scanning.
     358  
             }
     359  0
             if (skipProvidedScope && Artifact.SCOPE_PROVIDED.equals(a.getScope())) {
     360  0
                 return true;
          *
     359  
          * @return a newly instantiated <code>Engine</code>
     360  
          * @throws DatabaseException thrown if there is a database exception
     361  
             }
     362  0
             if (skipRuntimeScope && !Artifact.SCOPE_RUNTIME.equals(a.getScope())) {
     363  0
                 return true;
     364  
             }
     365  0
             return false;
          */
     362  
         private Engine initializeEngine() throws DatabaseException {
     363  0
             populateSettings();
     364  0
             final Engine localEngine = new Engine();
     365  0
             return localEngine;
     366  
         }
     367  
     
     368  
         //<editor-fold defaultstate="collapsed" desc="Methods to populate global settings">
     369  
         /**
     369  
          * Tests is the artifact should be included in the scan (i.e. is the dependency in a scope that is being scanned).
     370  
          * Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system
          *
     371  
          * properties required to change the proxy url, port, and connection timeout.
          * @param a the Artifact to test
     372  
          */
          * @return <code>true</code> if the artifact is in an excluded scope; otherwise <code>false</code>
     373  
         private void populateSettings() {
     374  0
             Settings.initialize();
     375  0
             InputStream mojoProperties = null;
     376  
             try {
     377  0
                 mojoProperties = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE);
     378  0
                 Settings.mergeProperties(mojoProperties);
     379  0
             } catch (IOException ex) {
     380  0
                 LOGGER.log(Level.WARNING, "Unable to load the dependency-check ant task.properties file.");
     381  0
                 LOGGER.log(Level.FINE, null, ex);
     382  
             } finally {
     383  0
                 if (mojoProperties != null) {
     384  
                     try {
     385  0
                         mojoProperties.close();
     386  0
                     } catch (IOException ex) {
     387  0
                         LOGGER.log(Level.FINEST, null, ex);
     388  0
                     }
          */
     374  
         private boolean excludeFromScan(Artifact a) {
     375  0
             if (skipTestScope && Artifact.SCOPE_TEST.equals(a.getScope())) {
     376  0
                 return true;
     377  
             }
     378  0
             if (skipProvidedScope && Artifact.SCOPE_PROVIDED.equals(a.getScope())) {
     379  0
                 return true;
     380  
             }
     381  0
             if (skipRuntimeScope && !Artifact.SCOPE_RUNTIME.equals(a.getScope())) {
     382  0
                 return true;
     383  
             }
     384  0
             return false;
     385  
         }
     386  
     
     387  
         //<editor-fold defaultstate="collapsed" desc="Methods to populate global settings">
     388  
         /**
     389  
                 }
          * Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system
     390  
             }
          * properties required to change the proxy url, port, and connection timeout.
     391  
     
     392  0
             Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
     393  0
             if (externalReport != null) {
     394  0
                 LOGGER.warning("The 'externalReport' option was set; this configuration option has been removed. "
          */
     392  
         private void populateSettings() {
     393  0
             Settings.initialize();
     394  0
             InputStream mojoProperties = null;
     395  
                         + "Please update the dependency-check-maven plugin's configuration");
     396  
             }
     397  
     
     398  0
             if (proxyUrl != null && !proxyUrl.isEmpty()) {
     399  0
                 LOGGER.warning("Deprecated configuration detected, proxyUrl will be ignored; use the maven settings "
     400  
                         + "to configure the proxy instead");
             try {
     396  0
                 mojoProperties = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE);
     397  0
                 Settings.mergeProperties(mojoProperties);
     398  0
             } catch (IOException ex) {
     399  0
                 LOGGER.log(Level.WARNING, "Unable to load the dependency-check ant task.properties file.");
     400  0
                 LOGGER.log(Level.FINE, null, ex);
     401  
             } finally {
     402  0
                 if (mojoProperties != null) {
     403  
                     try {
     404  0
                         mojoProperties.close();
     405  0
                     } catch (IOException ex) {
     406  0
                         LOGGER.log(Level.FINEST, null, ex);
     407  0
                     }
     408  
                 }
     409  
             }
     402  0
             final Proxy proxy = getMavenProxy();
     403  0
             if (proxy != null) {
     404  0
                 Settings.setString(Settings.KEYS.PROXY_SERVER, proxy.getHost());
     405  0
                 Settings.setString(Settings.KEYS.PROXY_PORT, Integer.toString(proxy.getPort()));
     406  0
                 final String userName = proxy.getUsername();
     407  0
                 final String password = proxy.getPassword();
     408  0
                 if (userName != null) {
     409  0
                     Settings.setString(Settings.KEYS.PROXY_USERNAME, userName);
     410  
                 }
     411  0
                 if (password != null) {
     412  0
                     Settings.setString(Settings.KEYS.PROXY_PASSWORD, password);
     413  
                 }
     414  
     
     411  0
             Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
     412  0
             if (externalReport != null) {
     413  0
                 LOGGER.warning("The 'externalReport' option was set; this configuration option has been removed. "
     414  
                         + "Please update the dependency-check-maven plugin's configuration");
     415  
             }
     416  
     
     417  0
             if (connectionTimeout != null && !connectionTimeout.isEmpty()) {
     418  0
                 Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout);
     417  0
             if (proxyUrl != null && !proxyUrl.isEmpty()) {
     418  0
                 LOGGER.warning("Deprecated configuration detected, proxyUrl will be ignored; use the maven settings " + "to configure the proxy instead");
     419  
             }
     420  0
             if (suppressionFile != null && !suppressionFile.isEmpty()) {
     421  0
                 Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile);
     422  
             }
     423  
     420  0
             final Proxy proxy = getMavenProxy();
     421  0
             if (proxy != null) {
     422  0
                 Settings.setString(Settings.KEYS.PROXY_SERVER, proxy.getHost());
     423  0
                 Settings.setString(Settings.KEYS.PROXY_PORT, Integer.toString(proxy.getPort()));
     424  0
                 final String userName = proxy.getUsername();
     425  0
                 final String password = proxy.getPassword();
     426  0
                 if (userName != null) {
     427  0
                     Settings.setString(Settings.KEYS.PROXY_USERNAME, userName);
     428  
                 }
     429  0
                 if (password != null) {
     430  0
                     Settings.setString(Settings.KEYS.PROXY_PASSWORD, password);
     431  
                 }
     432  
     
     424  
             //File Type Analyzer Settings
     425  
             //JAR ANALYZER
     426  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, jarAnalyzerEnabled);
     427  
             //NUSPEC ANALYZER
     428  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, nuspecAnalyzerEnabled);
     429  
             //NEXUS ANALYZER
     430  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, nexusAnalyzerEnabled);
     431  0
             if (nexusUrl != null && !nexusUrl.isEmpty()) {
     432  0
                 Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl);
     433  
             }
     434  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy);
     435  
             //ARCHIVE ANALYZER
     436  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, archiveAnalyzerEnabled);
     437  0
             if (zipExtensions != null && !zipExtensions.isEmpty()) {
     438  0
                 Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, zipExtensions);
     439  
     434  
     
     435  0
             if (connectionTimeout != null && !connectionTimeout.isEmpty()) {
     436  0
                 Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout);
     437  
             }
     438  0
             if (suppressionFile != null && !suppressionFile.isEmpty()) {
     439  0
                 Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile);
     440  
             //ASSEMBLY ANALYZER
     441  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, assemblyAnalyzerEnabled);
     442  0
             if (pathToMono != null && !pathToMono.isEmpty()) {
     443  0
                 Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono);
     444  
             }
     441  
     
     442  
             //File Type Analyzer Settings
     443  
             //JAR ANALYZER
     444  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, jarAnalyzerEnabled);
     445  
     
     446  
             //Database configuration
     447  0
             if (databaseDriverName != null && !databaseDriverName.isEmpty()) {
     448  0
                 Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName);
     449  
             //NUSPEC ANALYZER
     446  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, nuspecAnalyzerEnabled);
     447  
             //NEXUS ANALYZER
     448  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, nexusAnalyzerEnabled);
     449  0
             if (nexusUrl != null && !nexusUrl.isEmpty()) {
     450  0
                 Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl);
     451  
             }
     450  0
             if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) {
     451  0
                 Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath);
     452  
     452  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy);
     453  
             //ARCHIVE ANALYZER
     454  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, archiveAnalyzerEnabled);
     455  0
             if (zipExtensions != null && !zipExtensions.isEmpty()) {
     456  0
                 Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, zipExtensions);
     457  
             }
     453  0
             if (connectionString != null && !connectionString.isEmpty()) {
     454  0
                 Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
     455  
             }
     456  0
             if (databaseUser != null && !databaseUser.isEmpty()) {
     457  0
                 Settings.setString(Settings.KEYS.DB_USER, databaseUser);
     458  
             }
     459  0
             if (databasePassword != null && !databasePassword.isEmpty()) {
     460  0
                 Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword);
     461  
             }
             //ASSEMBLY ANALYZER
     459  0
             Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, assemblyAnalyzerEnabled);
     460  0
             if (pathToMono != null && !pathToMono.isEmpty()) {
     461  0
                 Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono);
     462  
             // Data Directory
     463  0
             if (dataDirectory != null && !dataDirectory.isEmpty()) {
     464  0
                 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory);
     465  
             }
     466  
     463  
     
     464  
             //Database configuration
     465  0
             if (databaseDriverName != null && !databaseDriverName.isEmpty()) {
     466  0
                 Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName);
     467  
             // Scope Exclusion
     468  0
             Settings.setBoolean(Settings.KEYS.SKIP_TEST_SCOPE, skipTestScope);
     469  0
             Settings.setBoolean(Settings.KEYS.SKIP_RUNTIME_SCOPE, skipRuntimeScope);
     470  0
             Settings.setBoolean(Settings.KEYS.SKIP_PROVIDED_SCOPE, skipProvidedScope);
     471  
     
     472  
             // CVE Data Mirroring
     473  0
             if (cveUrl12Modified != null && !cveUrl12Modified.isEmpty()) {
     474  0
                 Settings.setString(Settings.KEYS.CVE_MODIFIED_12_URL, cveUrl12Modified);
     475  
             }
     476  0
             if (cveUrl20Modified != null && !cveUrl20Modified.isEmpty()) {
     477  0
                 Settings.setString(Settings.KEYS.CVE_MODIFIED_20_URL, cveUrl20Modified);
     478  
     468  0
             if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) {
     469  0
                 Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath);
     470  
             }
     479  0
             if (cveUrl12Base != null && !cveUrl12Base.isEmpty()) {
     480  0
                 Settings.setString(Settings.KEYS.CVE_SCHEMA_1_2, cveUrl12Base);
     481  
     471  0
             if (connectionString != null && !connectionString.isEmpty()) {
     472  0
                 Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
     473  
             }
     474  0
             if (databaseUser != null && !databaseUser.isEmpty()) {
     475  0
                 Settings.setString(Settings.KEYS.DB_USER, databaseUser);
     476  
             }
     477  0
             if (databasePassword != null && !databasePassword.isEmpty()) {
     478  0
                 Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword);
     479  
             }
     480  
             // Data Directory
     481  0
             if (dataDirectory != null && !dataDirectory.isEmpty()) {
     482  0
                 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory);
     483  
             }
     482  0
             if (cveUrl20Base != null && !cveUrl20Base.isEmpty()) {
     483  0
                 Settings.setString(Settings.KEYS.CVE_SCHEMA_2_0, cveUrl20Base);
     484  
             }
     485  0
         }
     486  
     
     487  
         /**
     488  
          * Returns the maven proxy.
     485  
             // Scope Exclusion
     486  0
             Settings.setBoolean(Settings.KEYS.SKIP_TEST_SCOPE, skipTestScope);
     487  0
             Settings.setBoolean(Settings.KEYS.SKIP_RUNTIME_SCOPE, skipRuntimeScope);
     488  0
             Settings.setBoolean(Settings.KEYS.SKIP_PROVIDED_SCOPE, skipProvidedScope);
     489  
          *
     
     490  
          * @return the maven proxy
     491  
          */
     492  
         private Proxy getMavenProxy() {
     493  0
             if (mavenSettings != null) {
     494  0
                 final List<Proxy> proxies = mavenSettings.getProxies();
     495  0
                 if (proxies != null && proxies.size() > 0) {
     496  0
                     if (mavenSettingsProxyId != null) {
     497  0
                         for (Proxy proxy : proxies) {
     498  0
                             if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) {
     499  0
                                 return proxy;
     500  
                             }
     501  0
                         }
     502  0
                     } else if (proxies.size() == 1) {
     503  0
                         return proxies.get(0);
     504  
                     } else {
     505  0
                         LOGGER.warning("Multiple proxy defentiions exist in the Maven settings. In the dependency-check "
     506  
                                 + "configuration set the maveSettingsProxyId so that the correct proxy will be used.");
     507  0
                         throw new IllegalStateException("Ambiguous proxy definition");
     508  
                     }
     509  
                 }
     510  
             // CVE Data Mirroring
     491  0
             if (cveUrl12Modified != null && !cveUrl12Modified.isEmpty()) {
     492  0
                 Settings.setString(Settings.KEYS.CVE_MODIFIED_12_URL, cveUrl12Modified);
     493  
             }
     511  0
             return null;
     512  
         }
     513  
         //</editor-fold>
     514  
     494  0
             if (cveUrl20Modified != null && !cveUrl20Modified.isEmpty()) {
     495  0
                 Settings.setString(Settings.KEYS.CVE_MODIFIED_20_URL, cveUrl20Modified);
     496  
             }
     497  0
             if (cveUrl12Base != null && !cveUrl12Base.isEmpty()) {
     498  0
                 Settings.setString(Settings.KEYS.CVE_SCHEMA_1_2, cveUrl12Base);
     499  
             }
     500  0
             if (cveUrl20Base != null && !cveUrl20Base.isEmpty()) {
     501  0
                 Settings.setString(Settings.KEYS.CVE_SCHEMA_2_0, cveUrl20Base);
     502  
             }
     503  0
         }
     504  
     
     515  
     505  
         /**
     516  
          * Executes the dependency-check and generates the report.
     517  
     506  
          * Returns the maven proxy.
     507  
          *
     518  
          * @throws MojoExecutionException if a maven exception occurs
     519  
          * @throws MojoFailureException thrown if a CVSS score is found that is higher then the configured level
     520  
     508  
          * @return the maven proxy
     509  
          */
     521  
         @Override
     510  
         private Proxy getMavenProxy() {
     511  0
             if (mavenSettings != null) {
     512  0
                 final List<Proxy> proxies = mavenSettings.getProxies();
     513  0
                 if (proxies != null && proxies.size() > 0) {
     514  0
                     if (mavenSettingsProxyId != null) {
     515  0
                         for (Proxy proxy : proxies) {
     516  0
                             if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) {
     517  0
                                 return proxy;
     518  
                             }
     519  0
                         }
     520  0
                     } else if (proxies.size() == 1) {
     521  0
                         return proxies.get(0);
     522  
         protected void performExecute() throws MojoExecutionException, MojoFailureException {
     523  
             try {
     524  0
                 engine = executeDependencyCheck();
     525  0
                 ReportingUtil.generateExternalReports(engine, outputDirectory, getProject().getName(), format);
     526  0
                 if (this.showSummary) {
     527  0
                     showSummary(engine.getDependencies());
                     } else {
     523  0
                         LOGGER.warning("Multiple proxy defentiions exist in the Maven settings. In the dependency-check "
     524  
                                 + "configuration set the maveSettingsProxyId so that the correct proxy will be used.");
     525  0
                         throw new IllegalStateException("Ambiguous proxy definition");
     526  
                     }
     527  
                 }
     528  
                 }
     529  0
                 if (this.failBuildOnCVSS <= 10) {
     530  0
                     checkForFailure(engine.getDependencies());
             }
     529  0
             return null;
     530  
         }
     531  
                 }
     532  0
             } catch (DatabaseException ex) {
     533  0
                 LOGGER.log(Level.SEVERE,
     534  
                         "Unable to connect to the dependency-check database; analysis has stopped");
     535  0
                 LOGGER.log(Level.FINE, "", ex);
     536  0
             }
     537  0
         }
     538  
     
     532  
         //</editor-fold>
     533  
         /**
     534  
          * Executes the dependency-check and generates the report.
     535  
          *
     536  
          * @throws MojoExecutionException if a maven exception occurs
     537  
          * @throws MojoFailureException thrown if a CVSS score is found that is higher then the configured level
     538  
          */
     539  
         @Override
     540  
         protected void postExecute() throws MojoExecutionException, MojoFailureException {
         protected void performExecute() throws MojoExecutionException, MojoFailureException {
     541  
             try {
     542  0
                 super.postExecute();
     543  
             } finally {
     544  0
                 cleanupEngine();
     545  0
             }
     546  0
         }
     547  
     
     548  
         @Override
     542  0
                 engine = executeDependencyCheck();
     543  0
                 ReportingUtil.generateExternalReports(engine, outputDirectory, getProject().getName(), format);
     544  0
                 if (this.showSummary) {
     545  0
                     showSummary(engine.getDependencies());
     546  
                 }
     547  0
                 if (this.failBuildOnCVSS <= 10) {
     548  0
                     checkForFailure(engine.getDependencies());
     549  
         protected void postGenerate() throws MavenReportException {
     550  
             try {
     551  0
                 super.postGenerate();
     552  
             } finally {
     553  0
                 cleanupEngine();
     554  0
             }
     555  0
         }
                 }
     550  0
             } catch (DatabaseException ex) {
     551  0
                 LOGGER.log(Level.SEVERE, "Unable to connect to the dependency-check database; analysis has stopped");
     552  0
                 LOGGER.log(Level.FINE, "", ex);
     553  0
             }
     554  0
         }
     555  
     
     556  
     
         @Override
     557  
         /**
         protected void postExecute() throws MojoExecutionException, MojoFailureException {
     558  
          * Calls <code>engine.cleanup()</code> to release resources.
     559  
          */
     560  
         private void cleanupEngine() {
     561  0
             if (engine != null) {
     562  0
                 engine.cleanup();
     563  0
                 engine = null;
     564  
             }
     565  0
             Settings.cleanup(true);
     566  0
         }
     567  
     
     568  
         /**
     569  
          * Generates the Dependency-Check Site Report.
     570  
          *
     571  
          * @param locale the locale to use when generating the report
     572  
          * @throws MavenReportException if a maven report exception occurs
     573  
          */
     574  
         @Override
     575  
         protected void executeNonAggregateReport(Locale locale) throws MavenReportException {
     576  
     
     577  0
             final List<Dependency> deps = readDataFile();
     578  0
             if (deps != null) {
     579  
                 try {
     580  0
                     engine = initializeEngine();
     581  0
                     engine.getDependencies().addAll(deps);
     582  0
                 } catch (DatabaseException ex) {
     583  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s",
     584  
                             getProject().getName());
     585  0
                     throw new MavenReportException(msg, ex);
     586  0
                 }
     587  
             } else {
     588  
                 try {
     589  0
                     engine = executeDependencyCheck();
     590  0
                 } catch (DatabaseException ex) {
     591  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s",
     592  
                             getProject().getName());
     593  0
                     throw new MavenReportException(msg, ex);
     594  0
                 }
     595  
             }
     596  0
             ReportingUtil.generateExternalReports(engine, getReportOutputDirectory(), getProject().getName(), format);
     597  0
         }
     598  
     
     599  
         @Override
     600  
         protected void executeAggregateReport(MavenProject project, Locale locale) throws MavenReportException {
     601  0
             List<Dependency> deps = readDataFile(project);
     602  0
             if (deps != null) {
     603  
                 try {
     604  0
                     engine = initializeEngine();
     605  0
                     engine.getDependencies().addAll(deps);
     606  0
                 } catch (DatabaseException ex) {
     607  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s",
     608  
                             project.getName());
     609  0
                     throw new MavenReportException(msg, ex);
     610  0
                 }
     611  
             } else {
     612  
                 try {
     613  0
                     engine = executeDependencyCheck(project);
     614  0
                 } catch (DatabaseException ex) {
     615  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s",
     616  
                             project.getName());
     617  0
                     throw new MavenReportException(msg, ex);
     618  0
                 }
     619  
             }
     620  0
             for (MavenProject child : getAllChildren(project)) {
     621  0
                 deps = readDataFile(child);
     622  0
                 if (deps == null) {
     623  0
                     final String msg = String.format("Unable to include information on %s in the dependency-check aggregate report", child.getName());
     624  0
                     LOGGER.severe(msg);
     625  0
                 } else {
     626  0
                     engine.getDependencies().addAll(deps);
     627  
                 }
     628  0
             }
     629  0
             final DependencyBundlingAnalyzer bundler = new DependencyBundlingAnalyzer();
     630  
             try {
     631  0
                 bundler.analyze(null, engine);
     632  0
             } catch (AnalysisException ex) {
     633  0
                 LOGGER.log(Level.WARNING, "An error occured grouping the dependencies; duplicate entries may exist in the report", ex);
     634  0
                 LOGGER.log(Level.FINE, "Bundling Exception", ex);
     635  0
             }
     636  0
             final File outputDir = getReportOutputDirectory(project);
     637  0
             if (outputDir != null) {
     638  0
                 ReportingUtil.generateExternalReports(engine, outputDir, project.getName(), format);
     639  
             }
     640  0
         }
     641  
     559  0
                 super.postExecute();
     560  
             } finally {
     561  0
                 cleanupEngine();
     562  0
             }
     563  0
         }
     564  
     
     642  
         // <editor-fold defaultstate="collapsed" desc="Mojo interface/abstract required setter/getter methods">
     643  
         /**
     644  
          * Returns the output name.
     645  
          *
     646  
          * @return the output name
     647  
          */
     648  
         public String getOutputName() {
     649  0
             if ("HTML".equalsIgnoreCase(this.format)
     650  
                     || "ALL".equalsIgnoreCase(this.format)) {
     651  0
                 return "dependency-check-report";
     652  0
             } else if ("XML".equalsIgnoreCase(this.format)) {
     653  0
                 return "dependency-check-report.xml#";
     654  0
             } else if ("VULN".equalsIgnoreCase(this.format)) {
     655  0
                 return "dependency-check-vulnerability";
     656  
             } else {
     657  0
                 LOGGER.log(Level.WARNING, "Unknown report format used during site generation.");
     658  0
                 return "dependency-check-report";
     659  
             }
     660  
         }
     661  
     
     662  
         /**
     663  
          * Returns the category name.
     664  
          *
     665  
          * @return the category name
     666  
          */
     667  
         public String getCategoryName() {
     668  0
             return MavenReport.CATEGORY_PROJECT_REPORTS;
     669  
         }
     670  
     
     671  
         /**
     672  
          * Returns the report name.
     673  
          *
     674  
          * @param locale the location
     675  
          * @return the report name
     676  
          */
     677  
         public String getName(Locale locale) {
     678  0
             return "dependency-check";
     679  
         }
     680  
     
     681  
         /**
     682  
          * Gets the description of the Dependency-Check report to be displayed in the Maven Generated Reports page.
     683  
          *
     684  
          * @param locale The Locale to get the description for
     685  
          * @return the description
     686  
          */
     687  
         public String getDescription(Locale locale) {
     688  0
             return "A report providing details on any published "
     689  
                     + "vulnerabilities within project dependencies. This report is a best effort but may contain "
     690  
                     + "false positives and false negatives.";
     691  
         }
     692  
     
     693  
         /**
     694  
          * Returns whether or not a report can be generated.
     695  
          *
     696  
          * @return <code>true</code> if a report can be generated; otherwise <code>false</code>
     697  
          */
     698  
         public boolean canGenerateReport() {
     699  0
             if (canGenerateAggregateReport() || (isAggregate() && isMultiModule())) {
     700  0
                 return true;
     701  
             }
     702  0
             if (canGenerateNonAggregateReport()) {
     703  0
                 return true;
     704  
             } else {
     705  
                 final String msg;
     706  0
                 if (getProject().getArtifacts().size() > 0) {
     707  0
                     msg = "No project dependencies exist in the included scope - dependency-check:check is unable to generate a report.";
     708  
                 } else {
     709  0
                     msg = "No project dependencies exist - dependency-check:check is unable to generate a report.";
     710  
                 }
     711  0
                 LOGGER.warning(msg);
     712  
             }
     713  
     
     714  0
             return false;
     715  
         }
     716  
     
     717  
         /**
     718  
          * Returns whether or not a non-aggregate report can be generated.
     719  
          *
     720  
          * @return <code>true</code> if a non-aggregate report can be generated; otherwise <code>false</code>
     721  
          */
     722  
     565  
         @Override
     723  
         protected boolean canGenerateNonAggregateReport() {
     724  0
             boolean ability = false;
     725  0
             for (Artifact a : getProject().getArtifacts()) {
     726  0
                 if (!excludeFromScan(a)) {
     727  0
                     ability = true;
     728  0
                     break;
     729  
     566  
         protected void postGenerate() throws MavenReportException {
     567  
             try {
     568  0
                 super.postGenerate();
     569  
             } finally {
     570  0
                 cleanupEngine();
     571  0
             }
     572  0
         }
     573  
     
     574  
         /**
     575  
          * Calls <code>engine.cleanup()</code> to release resources.
     576  
          */
     577  
         private void cleanupEngine() {
     578  0
             if (engine != null) {
     579  0
                 engine.cleanup();
     580  0
                 engine = null;
     581  
             }
     582  0
             Settings.cleanup(true);
     583  0
         }
     584  
     
     585  
         /**
     586  
          * Generates the Dependency-Check Site Report.
     587  
          *
     588  
          * @param locale the locale to use when generating the report
     589  
          * @throws MavenReportException if a maven report exception occurs
     590  
          */
     591  
         @Override
     592  
         protected void executeNonAggregateReport(Locale locale) throws MavenReportException {
     593  
     
     594  0
             final List<Dependency> deps = readDataFile();
     595  0
             if (deps != null) {
     596  
                 try {
     597  0
                     engine = initializeEngine();
     598  0
                     engine.getDependencies().addAll(deps);
     599  0
                 } catch (DatabaseException ex) {
     600  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s",
     601  
                             getProject().getName());
     602  0
                     throw new MavenReportException(msg, ex);
     603  0
                 }
     604  
             } else {
     605  
                 try {
     606  0
                     engine = executeDependencyCheck();
     607  0
                 } catch (DatabaseException ex) {
     608  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s",
     609  
                             getProject().getName());
     610  0
                     throw new MavenReportException(msg, ex);
     611  0
                 }
     612  
             }
     613  0
             ReportingUtil.generateExternalReports(engine, getReportOutputDirectory(), getProject().getName(), format);
     614  0
         }
     615  
     
     616  
         @Override
     617  
         protected void executeAggregateReport(MavenProject project, Locale locale) throws MavenReportException {
     618  0
             List<Dependency> deps = readDataFile(project);
     619  0
             if (deps != null) {
     620  
                 try {
     621  0
                     engine = initializeEngine();
     622  0
                     engine.getDependencies().addAll(deps);
     623  0
                 } catch (DatabaseException ex) {
     624  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s",
     625  
                             project.getName());
     626  0
                     throw new MavenReportException(msg, ex);
     627  0
                 }
     628  
             } else {
     629  
                 try {
     630  0
                     engine = executeDependencyCheck(project);
     631  0
                 } catch (DatabaseException ex) {
     632  0
                     final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s",
     633  
                             project.getName());
     634  0
                     throw new MavenReportException(msg, ex);
     635  0
                 }
     636  
             }
     637  0
             for (MavenProject child : getAllChildren(project)) {
     638  0
                 deps = readDataFile(child);
     639  0
                 if (deps == null) {
     640  0
                     final String msg = String.format("Unable to include information on %s in the dependency-check aggregate report",
     641  
                             child.getName());
     642  0
                     LOGGER.severe(msg);
     643  0
                 } else {
     644  0
                     engine.getDependencies().addAll(deps);
     645  
                 }
     730  0
             }
     731  0
             return ability;
     646  0
             }
     647  0
             final DependencyBundlingAnalyzer bundler = new DependencyBundlingAnalyzer();
     648  
             try {
     649  0
                 bundler.analyze(null, engine);
     650  0
             } catch (AnalysisException ex) {
     651  0
                 LOGGER.log(Level.WARNING, "An error occured grouping the dependencies; duplicate entries may exist in the report", ex);
     652  0
                 LOGGER.log(Level.FINE, "Bundling Exception", ex);
     653  0
             }
     654  0
             final File outputDir = getReportOutputDirectory(project);
     655  0
             if (outputDir != null) {
     656  0
                 ReportingUtil.generateExternalReports(engine, outputDir, project.getName(), format);
     657  
             }
     658  0
         }
     659  
     
     660  
         // <editor-fold defaultstate="collapsed" desc="Mojo interface/abstract required setter/getter methods">
     661  
         /**
     662  
          * Returns the output name.
     663  
          *
     664  
          * @return the output name
     665  
          */
     666  
         public String getOutputName() {
     667  0
             if ("HTML".equalsIgnoreCase(this.format) || "ALL".equalsIgnoreCase(this.format)) {
     668  0
                 return "dependency-check-report";
     669  0
             } else if ("XML".equalsIgnoreCase(this.format)) {
     670  0
                 return "dependency-check-report.xml#";
     671  0
             } else if ("VULN".equalsIgnoreCase(this.format)) {
     672  0
                 return "dependency-check-vulnerability";
     673  
             } else {
     674  0
                 LOGGER.log(Level.WARNING, "Unknown report format used during site generation.");
     675  0
                 return "dependency-check-report";
     676  
             }
     677  
         }
     678  
     
     679  
         /**
     680  
          * Returns the category name.
     681  
          *
     682  
          * @return the category name
     683  
          */
     684  
         public String getCategoryName() {
     685  0
             return MavenReport.CATEGORY_PROJECT_REPORTS;
     686  
         }
     687  
     
     688  
         /**
     689  
          * Returns the report name.
     690  
          *
     691  
          * @param locale the location
     692  
          * @return the report name
     693  
          */
     694  
         public String getName(Locale locale) {
     695  0
             return "dependency-check";
     696  
         }
     697  
     
     698  
         /**
     699  
          * Gets the description of the Dependency-Check report to be displayed in the Maven Generated Reports page.
     700  
          *
     701  
          * @param locale The Locale to get the description for
     702  
          * @return the description
     703  
          */
     704  
         public String getDescription(Locale locale) {
     705  0
             return "A report providing details on any published "
     706  
                     + "vulnerabilities within project dependencies. This report is a best effort but may contain "
     707  
                     + "false positives and false negatives.";
     708  
         }
     709  
     
     710  
         /**
     711  
          * Returns whether or not a report can be generated.
     712  
          *
     713  
          * @return <code>true</code> if a report can be generated; otherwise <code>false</code>
     714  
          */
     715  
         public boolean canGenerateReport() {
     716  0
             if (canGenerateAggregateReport() || (isAggregate() && isMultiModule())) {
     717  0
                 return true;
     718  
             }
     719  0
             if (canGenerateNonAggregateReport()) {
     720  0
                 return true;
     721  
             } else {
     722  
                 final String msg;
     723  0
                 if (getProject().getArtifacts().size() > 0) {
     724  0
                     msg = "No project dependencies exist in the included scope - dependency-check:check is unable to generate a report.";
     725  
                 } else {
     726  0
                     msg = "No project dependencies exist - dependency-check:check is unable to generate a report.";
     727  
                 }
     728  0
                 LOGGER.warning(msg);
     729  
             }
     730  
     
     731  0
             return false;
     732  
         }
     733  
     734  
         /**
     735  
          * Returns whether or not an aggregate report can be generated.
          * Returns whether or not a non-aggregate report can be generated.
     736  
          *
     737  
          * @return <code>true</code> if an aggregate report can be generated; otherwise <code>false</code>
          * @return <code>true</code> if a non-aggregate report can be generated; otherwise <code>false</code>
     738  
          */
     739  
         @Override
     740  
         protected boolean canGenerateAggregateReport() {
     741  0
             return isAggregate() && isLastProject();
     742  
         }
     743  
         // </editor-fold>
     744  
     
     745  
         //<editor-fold defaultstate="collapsed" desc="Methods to fail build or show summary">
         protected boolean canGenerateNonAggregateReport() {
     741  0
             boolean ability = false;
     742  0
             for (Artifact a : getProject().getArtifacts()) {
     743  0
                 if (!excludeFromScan(a)) {
     744  0
                     ability = true;
     745  0
                     break;
     746  
         /**
     747  
          * Checks to see if a vulnerability has been identified with a CVSS score that is above the threshold set in the
     748  
          * configuration.
                 }
     747  0
             }
     748  0
             return ability;
     749  
          *
         }
     750  
          * @param dependencies the list of dependency objects
     
     751  
          * @throws MojoFailureException thrown if a CVSS score is found that is higher then the threshold set
         /**
     752  
          */
          * Returns whether or not an aggregate report can be generated.
     753  
         private void checkForFailure(List<Dependency> dependencies) throws MojoFailureException {
     754  0
             final StringBuilder ids = new StringBuilder();
     755  0
             for (Dependency d : dependencies) {
     756  0
                 boolean addName = true;
     757  0
                 for (Vulnerability v : d.getVulnerabilities()) {
     758  0
                     if (v.getCvssScore() >= failBuildOnCVSS) {
     759  0
                         if (addName) {
     760  0
                             addName = false;
     761  0
                             ids.append(NEW_LINE).append(d.getFileName()).append(": ");
     762  0
                             ids.append(v.getName());
     763  
                         } else {
     764  0
                             ids.append(", ").append(v.getName());
     765  
                         }
     766  
                     }
     767  0
                 }
     768  0
             }
     769  0
             if (ids.length() > 0) {
     770  0
                 final String msg = String.format("%n%nDependency-Check Failure:%n"
     771  
                         + "One or more dependencies were identified with vulnerabilities that have a CVSS score greater then '%.1f': %s%n"
     772  
                         + "See the dependency-check report for more details.%n%n", failBuildOnCVSS, ids.toString());
     773  0
                 throw new MojoFailureException(msg);
     774  
             }
     775  0
         }
     776  
     
     777  
         /**
     778  
          * Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.
     779  
          *
     780  
          * @param dependencies a list of dependency objects
     781  
     754  
          * @return <code>true</code> if an aggregate report can be generated; otherwise <code>false</code>
     755  
          */
     782  
         private void showSummary(List<Dependency> dependencies) {
     783  0
             final StringBuilder summary = new StringBuilder();
     784  0
             for (Dependency d : dependencies) {
     785  0
                 boolean firstEntry = true;
     786  0
                 final StringBuilder ids = new StringBuilder();
     787  0
                 for (Vulnerability v : d.getVulnerabilities()) {
     788  0
                     if (firstEntry) {
     789  0
                         firstEntry = false;
     790  
                     } else {
     791  0
                         ids.append(", ");
     792  
                     }
     793  0
                     ids.append(v.getName());
     794  0
                 }
     795  0
                 if (ids.length() > 0) {
     796  0
                     summary.append(d.getFileName()).append(" (");
     797  0
                     firstEntry = true;
     798  0
                     for (Identifier id : d.getIdentifiers()) {
     799  0
                         if (firstEntry) {
     800  0
                             firstEntry = false;
     801  
                         } else {
     802  0
                             summary.append(", ");
     803  
                         }
     804  0
                         summary.append(id.getValue());
     805  0
                     }
     806  0
                     summary.append(") : ").append(ids).append(NEW_LINE);
     807  
                 }
     808  0
             }
     809  0
             if (summary.length() > 0) {
     810  0
                 final String msg = String.format("%n%n"
     811  
                         + "One or more dependencies were identified with known vulnerabilities:%n%n%s"
     812  
                         + "%n%nSee the dependency-check report for more details.%n%n", summary.toString());
     813  0
                 LOGGER.log(Level.WARNING, msg);
     814  
             }
     815  0
         }
     816  
         //</editor-fold>
     817  
     
     818  
         //<editor-fold defaultstate="collapsed" desc="Methods to read/write the serialized data file">
     819  
         /**
     820  
          * Writes the scan data to disk. This is used to serialize the scan data between the "check" and "aggregate" phase.
     821  
          *
     822  
          * @return the File object referencing the data file that was written
     823  
          */
     824  
     756  
         @Override
     825  
         protected File writeDataFile() {
     826  0
             File file = null;
     827  0
             if (engine != null && getProject().getContextValue(this.getDataFileContextKey()) == null) {
     828  0
                 file = new File(getProject().getBuild().getDirectory(), getDataFileName());
     829  0
                 OutputStream os = null;
     830  0
                 OutputStream bos = null;
     831  0
                 ObjectOutputStream out = null;
     757  
         protected boolean canGenerateAggregateReport() {
     758  0
             return isAggregate() && isLastProject();
     759  
         }
     760  
     
     761  
         // </editor-fold>
     762  
         //<editor-fold defaultstate="collapsed" desc="Methods to fail build or show summary">
     763  
         /**
     764  
          * Checks to see if a vulnerability has been identified with a CVSS score that is above the threshold set in the
     765  
          * configuration.
     766  
          *
     767  
          * @param dependencies the list of dependency objects
     768  
          * @throws MojoFailureException thrown if a CVSS score is found that is higher then the threshold set
     769  
          */
     770  
         private void checkForFailure(List<Dependency> dependencies) throws MojoFailureException {
     771  0
             final StringBuilder ids = new StringBuilder();
     772  0
             for (Dependency d : dependencies) {
     773  0
                 boolean addName = true;
     774  0
                 for (Vulnerability v : d.getVulnerabilities()) {
     775  0
                     if (v.getCvssScore() >= failBuildOnCVSS) {
     776  0
                         if (addName) {
     777  0
                             addName = false;
     778  0
                             ids.append(NEW_LINE).append(d.getFileName()).append(": ");
     779  0
                             ids.append(v.getName());
     780  
                         } else {
     781  0
                             ids.append(", ").append(v.getName());
     782  
                         }
     783  
                     }
     784  0
                 }
     785  0
             }
     786  0
             if (ids.length() > 0) {
     787  0
                 final String msg = String.format("%n%nDependency-Check Failure:%n"
     788  
                         + "One or more dependencies were identified with vulnerabilities that have a CVSS score greater then '%.1f': %s%n"
     789  
                         + "See the dependency-check report for more details.%n%n", failBuildOnCVSS, ids.toString());
     790  0
                 throw new MojoFailureException(msg);
     791  
             }
     792  0
         }
     793  
     
     794  
         /**
     795  
          * Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.
     796  
          *
     797  
          * @param dependencies a list of dependency objects
     798  
          */
     799  
         private void showSummary(List<Dependency> dependencies) {
     800  0
             final StringBuilder summary = new StringBuilder();
     801  0
             for (Dependency d : dependencies) {
     802  0
                 boolean firstEntry = true;
     803  0
                 final StringBuilder ids = new StringBuilder();
     804  0
                 for (Vulnerability v : d.getVulnerabilities()) {
     805  0
                     if (firstEntry) {
     806  0
                         firstEntry = false;
     807  
                     } else {
     808  0
                         ids.append(", ");
     809  
                     }
     810  0
                     ids.append(v.getName());
     811  0
                 }
     812  0
                 if (ids.length() > 0) {
     813  0
                     summary.append(d.getFileName()).append(" (");
     814  0
                     firstEntry = true;
     815  0
                     for (Identifier id : d.getIdentifiers()) {
     816  0
                         if (firstEntry) {
     817  0
                             firstEntry = false;
     818  
                         } else {
     819  0
                             summary.append(", ");
     820  
                         }
     821  0
                         summary.append(id.getValue());
     822  0
                     }
     823  0
                     summary.append(") : ").append(ids).append(NEW_LINE);
     824  
                 }
     825  0
             }
     826  0
             if (summary.length() > 0) {
     827  0
                 final String msg = String.format("%n%n" + "One or more dependencies were identified with known vulnerabilities:%n%n%s"
     828  
                         + "%n%nSee the dependency-check report for more details.%n%n", summary.toString());
     829  0
                 LOGGER.log(Level.WARNING, msg);
     830  
             }
     831  0
         }
     832  
                 try {
     833  0
                     os = new FileOutputStream(file);
     834  0
                     bos = new BufferedOutputStream(os);
     835  0
                     out = new ObjectOutputStream(bos);
     836  0
                     out.writeObject(engine.getDependencies());
     837  0
                     out.flush();
     838  
     
     839  
                     //call reset to prevent resource leaks per
     840  
                     //https://www.securecoding.cert.org/confluence/display/java/SER10-J.+Avoid+memory+and+resource+leaks+during+serialization
     841  0
                     out.reset();
     842  
     
     843  0
                 } catch (IOException ex) {
     844  0
                     LOGGER.log(Level.WARNING, "Unable to create data file used for report aggregation; "
     845  
                             + "if report aggregation is being used the results may be incomplete.");
     846  0
                     LOGGER.log(Level.FINE, ex.getMessage(), ex);
     847  
                 } finally {
     848  0
                     if (out != null) {
     849  
                         try {
     850  0
                             out.close();
     851  0
                         } catch (IOException ex) {
     852  0
                             LOGGER.log(Level.FINEST, "ignore", ex);
     853  0
                         }
     854  
                     }
     855  0
                     if (bos != null) {
     856  
                         try {
     857  0
                             bos.close();
     858  0
                         } catch (IOException ex) {
     859  0
                             LOGGER.log(Level.FINEST, "ignore", ex);
     860  0
                         }
     861  
                     }
     862  0
                     if (os != null) {
     863  
                         try {
     864  0
                             os.close();
     865  0
                         } catch (IOException ex) {
     866  0
                             LOGGER.log(Level.FINEST, "ignore", ex);
     867  0
                         }
     868  
                     }
     869  
                 }
     870  
             }
     871  0
             return file;
     872  
         }
     873  
     
     874  
         /**
     875  
          * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and
     876  
          * "aggregate" phase.
     877  
          *
     878  
          * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise
     879  
          * <code>null</code> is returned
     880  
          */
     881  
         protected List<Dependency> readDataFile() {
     882  0
             return readDataFile(getProject());
     883  
         }
     884  
     
     885  
         /**
     886  
          * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and
     887  
          * "aggregate" phase.
     888  
          *
     889  
          * @param project the Maven project to read the data file from
     890  
          * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise
     891  
          * <code>null</code> is returned
     892  
          */
     893  
         protected List<Dependency> readDataFile(MavenProject project) {
     894  0
             final Object oPath = project.getContextValue(this.getDataFileContextKey());
     895  0
             if (oPath == null) {
     896  0
                 return null;
     897  
             }
     898  0
             List<Dependency> ret = null;
     899  0
             final String path = (String) oPath;
     900  0
             ObjectInputStream ois = null;
     901  
             try {
     902  0
                 ois = new ObjectInputStream(new FileInputStream(path));
     903  0
                 ret = (List<Dependency>) ois.readObject();
     904  0
             } catch (FileNotFoundException ex) {
     905  
                 //TODO fix logging
     906  0
                 LOGGER.log(Level.SEVERE, null, ex);
     907  0
             } catch (IOException ex) {
     908  0
                 LOGGER.log(Level.SEVERE, null, ex);
     909  0
             } catch (ClassNotFoundException ex) {
     910  0
                 LOGGER.log(Level.SEVERE, null, ex);
     911  
             } finally {
     912  0
                 if (ois != null) {
     913  
                     try {
     914  0
                         ois.close();
     915  0
                     } catch (IOException ex) {
     916  0
                         LOGGER.log(Level.SEVERE, null, ex);
     917  0
                     }
     918  
                 }
     919  
             }
     920  0
             return ret;
     921  
         }
     922  
     833  
         //</editor-fold>
     923  
     834  
         //<editor-fold defaultstate="collapsed" desc="Methods to read/write the serialized data file">
     835  
         /**
     836  
          * Writes the scan data to disk. This is used to serialize the scan data between the "check" and "aggregate" phase.
     837  
          *
     838  
          * @return the File object referencing the data file that was written
     839  
          */
     840  
         @Override
     841  
         protected File writeDataFile() {
     842  0
             File file = null;
     843  0
             if (engine != null && getProject().getContextValue(this.getDataFileContextKey()) == null) {
     844  0
                 file = new File(getProject().getBuild().getDirectory(), getDataFileName());
     845  0
                 OutputStream os = null;
     846  0
                 OutputStream bos = null;
     847  0
                 ObjectOutputStream out = null;
     848  
                 try {
     849  0
                     os = new FileOutputStream(file);
     850  0
                     bos = new BufferedOutputStream(os);
     851  0
                     out = new ObjectOutputStream(bos);
     852  0
                     out.writeObject(engine.getDependencies());
     853  0
                     out.flush();
     854  
     
     855  
                     //call reset to prevent resource leaks per
     856  
                     //https://www.securecoding.cert.org/confluence/display/java/SER10-J.+Avoid+memory+and+resource+leaks+during+serialization
     857  0
                     out.reset();
     858  
     
     859  0
                 } catch (IOException ex) {
     860  0
                     LOGGER.log(Level.WARNING, "Unable to create data file used for report aggregation; "
     861  
                             + "if report aggregation is being used the results may be incomplete.");
     862  0
                     LOGGER.log(Level.FINE, ex.getMessage(), ex);
     863  
                 } finally {
     864  0
                     if (out != null) {
     865  
                         try {
     866  0
                             out.close();
     867  0
                         } catch (IOException ex) {
     868  0
                             LOGGER.log(Level.FINEST, "ignore", ex);
     869  0
                         }
     870  
                     }
     871  0
                     if (bos != null) {
     872  
                         try {
     873  0
                             bos.close();
     874  0
                         } catch (IOException ex) {
     875  0
                             LOGGER.log(Level.FINEST, "ignore", ex);
     876  0
                         }
     877  
                     }
     878  0
                     if (os != null) {
     879  
                         try {
     880  0
                             os.close();
     881  0
                         } catch (IOException ex) {
     882  0
                             LOGGER.log(Level.FINEST, "ignore", ex);
     883  0
                         }
     884  
                     }
     885  
                 }
     886  
             }
     887  0
             return file;
     888  
         }
     889  
     
     890  
         /**
     891  
          * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and
     892  
          * "aggregate" phase.
     893  
          *
     894  
          * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise
     895  
          * <code>null</code> is returned
     896  
          */
     897  
         protected List<Dependency> readDataFile() {
     898  0
             return readDataFile(getProject());
     899  
         }
     900  
     
     901  
         /**
     902  
          * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and
     903  
          * "aggregate" phase.
     904  
          *
     905  
          * @param project the Maven project to read the data file from
     906  
          * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise
     907  
          * <code>null</code> is returned
     908  
          */
     909  
         protected List<Dependency> readDataFile(MavenProject project) {
     910  0
             final Object oPath = project.getContextValue(this.getDataFileContextKey());
     911  0
             if (oPath == null) {
     912  0
                 return null;
     913  
             }
     914  0
             List<Dependency> ret = null;
     915  0
             final String path = (String) oPath;
     916  0
             ObjectInputStream ois = null;
     917  
             try {
     918  0
                 ois = new ObjectInputStream(new FileInputStream(path));
     919  0
                 ret = (List<Dependency>) ois.readObject();
     920  0
             } catch (FileNotFoundException ex) {
     921  
                 //TODO fix logging
     922  0
                 LOGGER.log(Level.SEVERE, null, ex);
     923  0
             } catch (IOException ex) {
     924  0
                 LOGGER.log(Level.SEVERE, null, ex);
     925  0
             } catch (ClassNotFoundException ex) {
     926  0
                 LOGGER.log(Level.SEVERE, null, ex);
     927  
             } finally {
     928  0
                 if (ois != null) {
     929  
                     try {
     930  0
                         ois.close();
     931  0
                     } catch (IOException ex) {
     932  0
                         LOGGER.log(Level.SEVERE, null, ex);
     933  0
                     }
     934  
                 }
     935  
             }
     936  0
             return ret;
     937  
         }
     938  
         //</editor-fold>
     939  
     }
    - + diff --git a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.HelpMojo.html b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.HelpMojo.html index 9157f91ac..78553f0ed 100644 --- a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.HelpMojo.html +++ b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.HelpMojo.html @@ -744,6 +744,6 @@
     }
    - + diff --git a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportAggregationMojo.html b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportAggregationMojo.html index 4c000f950..22cc81e13 100644 --- a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportAggregationMojo.html +++ b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportAggregationMojo.html @@ -856,6 +856,6 @@
     }
    - + diff --git a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportingUtil.html b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportingUtil.html index 4457a7bf1..1a8353a86 100644 --- a/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportingUtil.html +++ b/dependency-check-maven/cobertura/org.owasp.dependencycheck.maven.ReportingUtil.html @@ -678,6 +678,6 @@
     }
    - + diff --git a/dependency-check-maven/configuration.html b/dependency-check-maven/configuration.html index 9f9387182..7efa58497 100644 --- a/dependency-check-maven/configuration.html +++ b/dependency-check-maven/configuration.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Configuration @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -317,9 +317,9 @@ nexusUrl -Defines the Nexus URL. +Defines the Nexus Pro Server URL. If not set the Nexus Analyzer will be disabled. -https://repository.sonatype.org/service/local/ +  @@ -353,7 +353,7 @@ pathToMono -The path to Mono for .NET assembly analysis on non-windows systems +The path to Mono for .NET assembly analysis on non-windows systems.   diff --git a/dependency-check-maven/dependency-updates-report.html b/dependency-check-maven/dependency-updates-report.html index 05fa851cd..358482bba 100644 --- a/dependency-check-maven/dependency-updates-report.html +++ b/dependency-check-maven/dependency-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Dependency Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -380,7 +380,7 @@ org.owasp dependency-check-core -1.2.5 +1.2.6 compile jar @@ -392,7 +392,7 @@ org.owasp dependency-check-utils -1.2.5 +1.2.6 compile jar @@ -441,7 +441,7 @@ jar Newer versions -4.12-beta-1 Next Incremental +4.12-beta-1 Next Incremental
    4.12-beta-2
    4.12-beta-3 Latest Incremental

    org.apache.maven:maven-core

    @@ -642,7 +642,7 @@ - + @@ -666,7 +666,7 @@ - + diff --git a/dependency-check-maven/findbugs.html b/dependency-check-maven/findbugs.html index 0ed23e954..4529eb52c 100644 --- a/dependency-check-maven/findbugs.html +++ b/dependency-check-maven/findbugs.html @@ -1,13 +1,13 @@ - + dependency-check-maven - FindBugs Bug Detector Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-maven/help-mojo.html b/dependency-check-maven/help-mojo.html index d8ff713f5..93441b9b7 100644 --- a/dependency-check-maven/help-mojo.html +++ b/dependency-check-maven/help-mojo.html @@ -1,13 +1,13 @@ - + dependency-check-maven - dependency-check:help @@ -55,7 +55,7 @@
  • - + /
  • @@ -69,9 +69,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -163,7 +163,7 @@

    Full name:

    -

    org.owasp:dependency-check-maven:1.2.5:help

    +

    org.owasp:dependency-check-maven:1.2.6:help

    Description:

    diff --git a/dependency-check-maven/index.html b/dependency-check-maven/index.html index bcc5b13e8..4212dc661 100644 --- a/dependency-check-maven/index.html +++ b/dependency-check-maven/index.html @@ -1,13 +1,13 @@ - + dependency-check-maven - About @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-maven/license.html b/dependency-check-maven/license.html index 5ce846900..3dc943327 100644 --- a/dependency-check-maven/license.html +++ b/dependency-check-maven/license.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Project License @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-maven/plugin-info.html b/dependency-check-maven/plugin-info.html index 265bd544e..947dd9bbe 100644 --- a/dependency-check-maven/plugin-info.html +++ b/dependency-check-maven/plugin-info.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Plugin Documentation @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -286,7 +286,7 @@ Call mvn dependency-check:help -Ddetail=true <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> </plugin> ... </plugins> @@ -296,7 +296,7 @@ Call mvn dependency-check:help -Ddetail=true <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> </plugin> ... </plugins> @@ -308,7 +308,7 @@ Call mvn dependency-check:help -Ddetail=true <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> </plugin> ... </plugins> diff --git a/dependency-check-maven/plugin-updates-report.html b/dependency-check-maven/plugin-updates-report.html index e07af35c7..7f6781049 100644 --- a/dependency-check-maven/plugin-updates-report.html +++ b/dependency-check-maven/plugin-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Plugin Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -245,7 +245,7 @@
    - + @@ -257,7 +257,7 @@ - + @@ -343,13 +343,13 @@ - + - - + + @@ -363,13 +363,13 @@ - + - - + + @@ -413,13 +413,13 @@ - + - - + + @@ -470,7 +470,7 @@
    dependency-check-core
    Current Version1.2.5
    1.2.6
    Scope compile
    dependency-check-utils
    Current Version1.2.5
    1.2.6
    Scope compile
    # of plugins using the latest version available3
    0
    # of plugins where the next version available is smaller than an incremental version update
    # of plugins where the next version available is a minor version update10
    13
    # of plugins where the next version available is a major version updateNext Major Dependency status
    com.github.github site-maven-plugin0.90.9 0.10
    org.apache.maven.plugins maven-compiler-plugin3.13.1 3.2
    org.apache.maven.plugins maven-plugin-plugin3.23.2 3.3
    - + @@ -479,7 +479,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id com.github.github
    site-maven-plugin
    Current Version0.9
    +0.9 + +Newer versions +0.10 Next Minor

    Plugin org.apache.maven.plugins:maven-antrun-plugin

    @@ -515,7 +518,7 @@ -
    2.2-beta-5
    Newer versions2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4 Latest Minor
    +2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4
    2.4.1
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-clean-plugin

    @@ -533,13 +536,13 @@ -
    2.4.1
    Newer versions2.5 Next Minor
    +2.5 Next Minor
    2.6
    2.6.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-compiler-plugin

    - + @@ -548,7 +551,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-compiler-plugin
    Current Version3.1
    +3.1 + +Newer versions +3.2 Next Minor

    Plugin org.apache.maven.plugins:maven-dependency-plugin

    @@ -566,7 +572,7 @@ -
    2.1
    Newer versions2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8 Latest Minor
    +2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8
    2.9 Latest Minor

    Plugin org.apache.maven.plugins:maven-deploy-plugin

    @@ -584,7 +590,7 @@ -
    2.7
    Newer versions2.8 Next Minor
    2.8.1 Latest Minor
    +2.8 Next Minor
    2.8.1
    2.8.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-enforcer-plugin

    @@ -620,7 +626,7 @@ -
    2.3.1
    Newer versions2.4 Next Minor
    2.5
    2.5.1 Latest Minor
    +2.4 Next Minor
    2.5
    2.5.1
    2.5.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-jar-plugin

    @@ -638,13 +644,13 @@ -
    2.3.1
    Newer versions2.3.2 Next Incremental
    2.4 Next Minor
    +2.3.2 Next Incremental
    2.4 Next Minor
    2.5 Latest Minor

    Plugin org.apache.maven.plugins:maven-plugin-plugin

    - + @@ -653,7 +659,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-plugin-plugin
    Current Version3.2
    +3.2 + +Newer versions +3.3 Next Minor

    Plugin org.apache.maven.plugins:maven-release-plugin

    @@ -671,7 +680,7 @@ -
    2.0
    Newer versions2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2 Latest Minor
    +2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-resources-plugin

    @@ -689,7 +698,7 @@ -
    2.5
    Newer versions2.6 Next Minor
    +2.6 Next Minor
    2.7 Latest Minor

    Plugin org.apache.maven.plugins:maven-site-plugin

    @@ -785,7 +794,7 @@ -
    2.10
    Newer versions2.11 Next Minor
    2.12
    2.12.1
    2.12.2
    2.12.3
    2.12.4
    2.13
    2.14
    2.14.1
    2.15
    2.16 Latest Minor
    +2.11 Next Minor
    2.12
    2.12.1
    2.12.2
    2.12.3
    2.12.4
    2.13
    2.14
    2.14.1
    2.15
    2.16
    2.17
    2.18 Latest Minor diff --git a/dependency-check-maven/pmd.html b/dependency-check-maven/pmd.html index 1f521b45a..db6494f46 100644 --- a/dependency-check-maven/pmd.html +++ b/dependency-check-maven/pmd.html @@ -1,13 +1,13 @@ - + dependency-check-maven - PMD Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -251,7 +251,7 @@ Line Useless parentheses. -699 +716 diff --git a/dependency-check-maven/project-info.html b/dependency-check-maven/project-info.html index 6114a72f8..79e7e1bc2 100644 --- a/dependency-check-maven/project-info.html +++ b/dependency-check-maven/project-info.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Project Information @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-maven/project-reports.html b/dependency-check-maven/project-reports.html index d80c8be37..63b2ec0c6 100644 --- a/dependency-check-maven/project-reports.html +++ b/dependency-check-maven/project-reports.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Generated Reports @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-maven/project-summary.html b/dependency-check-maven/project-summary.html index 5ce4bd91e..9f8aee55d 100644 --- a/dependency-check-maven/project-summary.html +++ b/dependency-check-maven/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Project Summary @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -218,7 +218,7 @@ dependency-check-maven Version -1.2.5 +1.2.6 Type maven-plugin diff --git a/dependency-check-maven/surefire-report.html b/dependency-check-maven/surefire-report.html index c228f509b..29e9d7dbf 100644 --- a/dependency-check-maven/surefire-report.html +++ b/dependency-check-maven/surefire-report.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Surefire Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -274,7 +274,7 @@ function toggleDisplay(elementId) { 0 0 100% -0.164
    +0.077

    Note: failures are anticipated and checked for with assertions while errors are unanticipated.


    Package List

    @@ -295,7 +295,7 @@ function toggleDisplay(elementId) { 0 0 100% -0.164
    +0.077

    Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.

    org.owasp.dependencycheck.maven

    @@ -317,7 +317,7 @@ function toggleDisplay(elementId) { 0 0 100% -0.164

    +0.077

    Test Cases

    [Summary] [Package List] [Test Cases]

    @@ -327,7 +327,7 @@ function toggleDisplay(elementId) { testGenerate_Sink_SinkFactory_Locale -0.006

    +0.002
    diff --git a/dependency-check-maven/taglist.html b/dependency-check-maven/taglist.html index a4f48cec9..25c1585c3 100644 --- a/dependency-check-maven/taglist.html +++ b/dependency-check-maven/taglist.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Tag List report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -260,7 +260,7 @@ Line fix logging -905 +921 org.owasp.dependencycheck.maven.DependencyCheckMojoTest Line diff --git a/dependency-check-maven/usage.html b/dependency-check-maven/usage.html index f4f0b037c..38e0ec940 100644 --- a/dependency-check-maven/usage.html +++ b/dependency-check-maven/usage.html @@ -1,13 +1,13 @@ - + dependency-check-maven - Usage @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -171,7 +171,7 @@ <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> <executions> <execution> <goals> @@ -202,7 +202,7 @@ <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> <configuration> <aggregate>true</aggregate> </configuration> @@ -236,7 +236,7 @@ <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> <configuration> <failBuildOnCVSS>8</failBuildOnCVSS> </configuration> @@ -269,7 +269,7 @@ <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> <configuration> <skipProvidedScope>true</skipProvidedScope> <skipRuntimeScope>true</skipRuntimeScope> @@ -303,7 +303,7 @@ <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>1.2.5</version> + <version>1.2.6</version> <configuration> <cveUrl12Modified>http://internal-mirror.mycorp.com/downloads/nist/nvdcve-modified.xml</cveUrl12Modified> <cveUrl20Modified>http://internal-mirror.mycorp.com/downloads/nist/nvdcve-2.0-modified.xml</cveUrl20Modified> diff --git a/dependency-check-maven/xref-test/index.html b/dependency-check-maven/xref-test/index.html index ac4632c06..f3ceb7a7f 100644 --- a/dependency-check-maven/xref-test/index.html +++ b/dependency-check-maven/xref-test/index.html @@ -4,7 +4,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference + Dependency-Check Maven Plugin 1.2.6 Reference diff --git a/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-frame.html b/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-frame.html index 1ca4ba145..b2c488dfb 100644 --- a/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-frame.html +++ b/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference Package org.owasp.dependencycheck.maven + Dependency-Check Maven Plugin 1.2.6 Reference Package org.owasp.dependencycheck.maven diff --git a/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-summary.html b/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-summary.html index 053b34b67..fabf13cd7 100644 --- a/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-summary.html +++ b/dependency-check-maven/xref-test/org/owasp/dependencycheck/maven/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference Package org.owasp.dependencycheck.maven + Dependency-Check Maven Plugin 1.2.6 Reference Package org.owasp.dependencycheck.maven diff --git a/dependency-check-maven/xref-test/overview-frame.html b/dependency-check-maven/xref-test/overview-frame.html index 1dcb2eb31..4708992a8 100644 --- a/dependency-check-maven/xref-test/overview-frame.html +++ b/dependency-check-maven/xref-test/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference + Dependency-Check Maven Plugin 1.2.6 Reference diff --git a/dependency-check-maven/xref-test/overview-summary.html b/dependency-check-maven/xref-test/overview-summary.html index cfa7a5fe6..6ccf78671 100644 --- a/dependency-check-maven/xref-test/overview-summary.html +++ b/dependency-check-maven/xref-test/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference + Dependency-Check Maven Plugin 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Maven Plugin 1.2.5 Reference

    +

    Dependency-Check Maven Plugin 1.2.6 Reference

    diff --git a/dependency-check-maven/xref/index.html b/dependency-check-maven/xref/index.html index ac4632c06..f3ceb7a7f 100644 --- a/dependency-check-maven/xref/index.html +++ b/dependency-check-maven/xref/index.html @@ -4,7 +4,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference + Dependency-Check Maven Plugin 1.2.6 Reference diff --git a/dependency-check-maven/xref/org/owasp/dependencycheck/maven/DependencyCheckMojo.html b/dependency-check-maven/xref/org/owasp/dependencycheck/maven/DependencyCheckMojo.html index 6a6944612..110bfea1d 100644 --- a/dependency-check-maven/xref/org/owasp/dependencycheck/maven/DependencyCheckMojo.html +++ b/dependency-check-maven/xref/org/owasp/dependencycheck/maven/DependencyCheckMojo.html @@ -54,881 +54,897 @@ 46import org.owasp.dependencycheck.Engine; 47import org.owasp.dependencycheck.analyzer.DependencyBundlingAnalyzer; 48import org.owasp.dependencycheck.analyzer.exception.AnalysisException; -49import org.owasp.dependencycheck.data.nvdcve.DatabaseException; -50import org.owasp.dependencycheck.dependency.Dependency; -51import org.owasp.dependencycheck.dependency.Identifier; -52import org.owasp.dependencycheck.dependency.Vulnerability; -53import org.owasp.dependencycheck.utils.LogUtils; -54import org.owasp.dependencycheck.utils.Settings; -55 -56/** -57 * Maven Plugin that checks project dependencies to see if they have any known published vulnerabilities. -58 * -59 * @author Jeremy Long <jeremy.long@owasp.org> -60 */ -61 @Mojo(name = "check", defaultPhase = LifecyclePhase.COMPILE, threadSafe = true, -62 requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM, -63 requiresOnline = true) -64publicclassDependencyCheckMojoextendsReportAggregationMojo { -65 -66//<editor-fold defaultstate="collapsed" desc="Private fields"> -67/** -68 * Logger field reference. -69 */ -70privatestaticfinal Logger LOGGER = Logger.getLogger(DependencyCheckMojo.class.getName()); -71/** -72 * The properties file location. -73 */ -74privatestaticfinal String PROPERTIES_FILE = "mojo.properties"; -75/** -76 * Name of the logging properties file. -77 */ -78privatestaticfinal String LOG_PROPERTIES_FILE = "log.properties"; -79/** -80 * System specific new line character. -81 */ -82privatestaticfinal String NEW_LINE = System.getProperty("line.separator", "\n").intern(); -83/** -84 * The dependency-check engine used to scan the project. -85 */ -86private Engine engine = null; -87//</editor-fold> -88 -89// <editor-fold defaultstate="collapsed" desc="Maven bound parameters and components"> -90/** -91 * The path to the verbose log. -92 */ -93 @Parameter(property = "logfile", defaultValue = "") -94private String logFile = null; -95/** -96 * The output directory. This generally maps to "target". -97 */ -98 @Parameter(defaultValue = "${project.build.directory}", required = true) -99private File outputDirectory; -100/** -101 * Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11 -102 * which means since the CVSS scores are 0-10, by default the build will never fail. +49import org.owasp.dependencycheck.data.nexus.MavenArtifact; +50import org.owasp.dependencycheck.data.nvdcve.DatabaseException; +51import org.owasp.dependencycheck.dependency.Confidence; +52import org.owasp.dependencycheck.dependency.Dependency; +53import org.owasp.dependencycheck.dependency.Identifier; +54import org.owasp.dependencycheck.dependency.Vulnerability; +55import org.owasp.dependencycheck.utils.LogUtils; +56import org.owasp.dependencycheck.utils.Settings; +57 +58/** +59 * Maven Plugin that checks project dependencies to see if they have any known published vulnerabilities. +60 * +61 * @author Jeremy Long <jeremy.long@owasp.org> +62 */ +63 @Mojo( +64 name = "check", +65 defaultPhase = LifecyclePhase.COMPILE, +66 threadSafe = true, +67 requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM, +68 requiresOnline = true +69 ) +70publicclassDependencyCheckMojoextendsReportAggregationMojo { +71 +72//<editor-fold defaultstate="collapsed" desc="Private fields"> +73/** +74 * Logger field reference. +75 */ +76privatestaticfinal Logger LOGGER = Logger.getLogger(DependencyCheckMojo.class.getName()); +77/** +78 * The properties file location. +79 */ +80privatestaticfinal String PROPERTIES_FILE = "mojo.properties"; +81/** +82 * Name of the logging properties file. +83 */ +84privatestaticfinal String LOG_PROPERTIES_FILE = "log.properties"; +85/** +86 * System specific new line character. +87 */ +88privatestaticfinal String NEW_LINE = System.getProperty("line.separator", "\n").intern(); +89/** +90 * The dependency-check engine used to scan the project. +91 */ +92private Engine engine = null; +93//</editor-fold> +94 +95// <editor-fold defaultstate="collapsed" desc="Maven bound parameters and components"> +96/** +97 * The path to the verbose log. +98 */ +99 @Parameter(property = "logfile", defaultValue = "") +100private String logFile = null; +101/** +102 * The output directory. This generally maps to "target".103 */ -104 @SuppressWarnings("CanBeFinal") -105 @Parameter(property = "failBuildOnCVSS", defaultValue = "11", required = true) -106privatefloat failBuildOnCVSS = 11; -107/** -108 * Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to -109 * false. Default is true. -110 */ -111 @SuppressWarnings("CanBeFinal") -112 @Parameter(property = "autoupdate", defaultValue = "true", required = true) -113privateboolean autoUpdate = true; -114/** -115 * The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this -116 * within the Site plugin unless the externalReport is set to true. Default is HTML. -117 */ -118 @SuppressWarnings("CanBeFinal") -119 @Parameter(property = "format", defaultValue = "HTML", required = true) -120private String format = "HTML"; -121/** -122 * The maven settings. +104 @Parameter(defaultValue = "${project.build.directory}", required = true) +105private File outputDirectory; +106/** +107 * Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11 +108 * which means since the CVSS scores are 0-10, by default the build will never fail. +109 */ +110 @SuppressWarnings("CanBeFinal") +111 @Parameter(property = "failBuildOnCVSS", defaultValue = "11", required = true) +112privatefloat failBuildOnCVSS = 11; +113/** +114 * Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to +115 * false. Default is true. +116 */ +117 @SuppressWarnings("CanBeFinal") +118 @Parameter(property = "autoupdate", defaultValue = "true", required = true) +119privateboolean autoUpdate = true; +120/** +121 * The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this +122 * within the Site plugin unless the externalReport is set to true. Default is HTML.123 */ -124 @Parameter(property = "mavenSettings", defaultValue = "${settings}", required = false) -125private org.apache.maven.settings.Settings mavenSettings; -126 +124 @SuppressWarnings("CanBeFinal") +125 @Parameter(property = "format", defaultValue = "HTML", required = true) +126private String format = "HTML"; 127/** -128 * The maven settings proxy id. +128 * The maven settings.129 */ -130 @SuppressWarnings("CanBeFinal") -131 @Parameter(property = "mavenSettingsProxyId", required = false) -132private String mavenSettingsProxyId; -133 -134/** -135 * The Connection Timeout. -136 */ -137 @SuppressWarnings("CanBeFinal") -138 @Parameter(property = "connectionTimeout", defaultValue = "", required = false) -139private String connectionTimeout = null; +130 @Parameter(property = "mavenSettings", defaultValue = "${settings}", required = false) +131private org.apache.maven.settings.Settings mavenSettings; +132 +133/** +134 * The maven settings proxy id. +135 */ +136 @SuppressWarnings("CanBeFinal") +137 @Parameter(property = "mavenSettingsProxyId", required = false) +138private String mavenSettingsProxyId; +139140/** -141 * The path to the suppression file. +141 * The Connection Timeout.142 */143 @SuppressWarnings("CanBeFinal") -144 @Parameter(property = "suppressionFile", defaultValue = "", required = false) -145private String suppressionFile = null; +144 @Parameter(property = "connectionTimeout", defaultValue = "", required = false) +145private String connectionTimeout = null; 146/** -147 * Flag indicating whether or not to show a summary in the output. +147 * The path to the suppression file.148 */149 @SuppressWarnings("CanBeFinal") -150 @Parameter(property = "showSummary", defaultValue = "true", required = false) -151privateboolean showSummary = true; -152 -153/** -154 * Whether or not the Jar Analyzer is enabled. -155 */ -156 @SuppressWarnings("CanBeFinal") -157 @Parameter(property = "jarAnalyzerEnabled", defaultValue = "true", required = false) -158privateboolean jarAnalyzerEnabled = true; -159 -160/** -161 * Whether or not the Archive Analyzer is enabled. -162 */ -163 @SuppressWarnings("CanBeFinal") -164 @Parameter(property = "archiveAnalyzerEnabled", defaultValue = "true", required = false) -165privateboolean archiveAnalyzerEnabled = true; -166 -167/** -168 * Whether or not the .NET Assembly Analyzer is enabled. -169 */ -170 @SuppressWarnings("CanBeFinal") -171 @Parameter(property = "assemblyAnalyzerEnabled", defaultValue = "true", required = false) -172privateboolean assemblyAnalyzerEnabled = true; -173 -174/** -175 * Whether or not the .NET Nuspec Analyzer is enabled. -176 */ -177 @SuppressWarnings("CanBeFinal") -178 @Parameter(property = "nuspecAnalyzerEnabled", defaultValue = "true", required = false) -179privateboolean nuspecAnalyzerEnabled = true; -180 -181/** -182 * Whether or not the Nexus Analyzer is enabled. -183 */ -184 @SuppressWarnings("CanBeFinal") -185 @Parameter(property = "nexusAnalyzerEnabled", defaultValue = "true", required = false) -186privateboolean nexusAnalyzerEnabled = true; +150 @Parameter(property = "suppressionFile", defaultValue = "", required = false) +151private String suppressionFile = null; +152/** +153 * Flag indicating whether or not to show a summary in the output. +154 */ +155 @SuppressWarnings("CanBeFinal") +156 @Parameter(property = "showSummary", defaultValue = "true", required = false) +157privateboolean showSummary = true; +158 +159/** +160 * Whether or not the Jar Analyzer is enabled. +161 */ +162 @SuppressWarnings("CanBeFinal") +163 @Parameter(property = "jarAnalyzerEnabled", defaultValue = "true", required = false) +164privateboolean jarAnalyzerEnabled = true; +165 +166/** +167 * Whether or not the Archive Analyzer is enabled. +168 */ +169 @SuppressWarnings("CanBeFinal") +170 @Parameter(property = "archiveAnalyzerEnabled", defaultValue = "true", required = false) +171privateboolean archiveAnalyzerEnabled = true; +172 +173/** +174 * Whether or not the .NET Assembly Analyzer is enabled. +175 */ +176 @SuppressWarnings("CanBeFinal") +177 @Parameter(property = "assemblyAnalyzerEnabled", defaultValue = "true", required = false) +178privateboolean assemblyAnalyzerEnabled = true; +179 +180/** +181 * Whether or not the .NET Nuspec Analyzer is enabled. +182 */ +183 @SuppressWarnings("CanBeFinal") +184 @Parameter(property = "nuspecAnalyzerEnabled", defaultValue = "true", required = false) +185privateboolean nuspecAnalyzerEnabled = true; +186187/**188 * Whether or not the Nexus Analyzer is enabled.189 */ -190 @Parameter(property = "nexusUrl", defaultValue = "", required = false) -191private String nexusUrl; -192/** -193 * Whether or not the configured proxy is used to connect to Nexus. -194 */ -195 @Parameter(property = "nexusUsesProxy", defaultValue = "true", required = false) -196privateboolean nexusUsesProxy = true; -197/** -198 * The database connection string. -199 */ -200 @Parameter(property = "connectionString", defaultValue = "", required = false) -201private String connectionString; -202/** -203 * The database driver name. An example would be org.h2.Driver. -204 */ -205 @Parameter(property = "databaseDriverName", defaultValue = "", required = false) -206private String databaseDriverName; -207/** -208 * The path to the database driver if it is not on the class path. -209 */ -210 @Parameter(property = "databaseDriverPath", defaultValue = "", required = false) -211private String databaseDriverPath; -212/** -213 * The database user name. -214 */ -215 @Parameter(property = "databaseUser", defaultValue = "", required = false) -216private String databaseUser; -217/** -218 * The password to use when connecting to the database. -219 */ -220 @Parameter(property = "databasePassword", defaultValue = "", required = false) -221private String databasePassword; -222/** -223 * A comma-separated list of file extensions to add to analysis next to jar, zip, .... -224 */ -225 @Parameter(property = "zipExtensions", required = false) -226private String zipExtensions; -227/** -228 * Skip Analysis for Test Scope Dependencies. -229 */ -230 @SuppressWarnings("CanBeFinal") -231 @Parameter(property = "skipTestScope", defaultValue = "true", required = false) -232privateboolean skipTestScope = true; +190 @SuppressWarnings("CanBeFinal") +191 @Parameter(property = "nexusAnalyzerEnabled", defaultValue = "true", required = false) +192privateboolean nexusAnalyzerEnabled = true; +193/** +194 * Whether or not the Nexus Analyzer is enabled. +195 */ +196 @Parameter(property = "nexusUrl", defaultValue = "", required = false) +197private String nexusUrl; +198/** +199 * Whether or not the configured proxy is used to connect to Nexus. +200 */ +201 @Parameter(property = "nexusUsesProxy", defaultValue = "true", required = false) +202privateboolean nexusUsesProxy = true; +203/** +204 * The database connection string. +205 */ +206 @Parameter(property = "connectionString", defaultValue = "", required = false) +207private String connectionString; +208/** +209 * The database driver name. An example would be org.h2.Driver. +210 */ +211 @Parameter(property = "databaseDriverName", defaultValue = "", required = false) +212private String databaseDriverName; +213/** +214 * The path to the database driver if it is not on the class path. +215 */ +216 @Parameter(property = "databaseDriverPath", defaultValue = "", required = false) +217private String databaseDriverPath; +218/** +219 * The database user name. +220 */ +221 @Parameter(property = "databaseUser", defaultValue = "", required = false) +222private String databaseUser; +223/** +224 * The password to use when connecting to the database. +225 */ +226 @Parameter(property = "databasePassword", defaultValue = "", required = false) +227private String databasePassword; +228/** +229 * A comma-separated list of file extensions to add to analysis next to jar, zip, .... +230 */ +231 @Parameter(property = "zipExtensions", required = false) +232private String zipExtensions; 233/** -234 * Skip Analysis for Runtime Scope Dependencies. +234 * Skip Analysis for Test Scope Dependencies.235 */236 @SuppressWarnings("CanBeFinal") -237 @Parameter(property = "skipRuntimeScope", defaultValue = "false", required = false) -238privateboolean skipRuntimeScope = false; +237 @Parameter(property = "skipTestScope", defaultValue = "true", required = false) +238privateboolean skipTestScope = true; 239/** -240 * Skip Analysis for Provided Scope Dependencies. +240 * Skip Analysis for Runtime Scope Dependencies.241 */242 @SuppressWarnings("CanBeFinal") -243 @Parameter(property = "skipProvidedScope", defaultValue = "false", required = false) -244privateboolean skipProvidedScope = false; +243 @Parameter(property = "skipRuntimeScope", defaultValue = "false", required = false) +244privateboolean skipRuntimeScope = false; 245/** -246 * The data directory, hold DC SQL DB. +246 * Skip Analysis for Provided Scope Dependencies.247 */ -248 @Parameter(property = "dataDirectory", defaultValue = "", required = false) -249private String dataDirectory; -250/** -251 * Data Mirror URL for CVE 1.2. -252 */ -253 @Parameter(property = "cveUrl12Modified", defaultValue = "", required = false) -254private String cveUrl12Modified; -255/** -256 * Data Mirror URL for CVE 2.0. -257 */ -258 @Parameter(property = "cveUrl20Modified", defaultValue = "", required = false) -259private String cveUrl20Modified; -260/** -261 * Base Data Mirror URL for CVE 1.2. -262 */ -263 @Parameter(property = "cveUrl12Base", defaultValue = "", required = false) -264private String cveUrl12Base; -265/** -266 * Data Mirror URL for CVE 2.0. -267 */ -268 @Parameter(property = "cveUrl20Base", defaultValue = "", required = false) -269private String cveUrl20Base; -270 +248 @SuppressWarnings("CanBeFinal") +249 @Parameter(property = "skipProvidedScope", defaultValue = "false", required = false) +250privateboolean skipProvidedScope = false; +251/** +252 * The data directory, hold DC SQL DB. +253 */ +254 @Parameter(property = "dataDirectory", defaultValue = "", required = false) +255private String dataDirectory; +256/** +257 * Data Mirror URL for CVE 1.2. +258 */ +259 @Parameter(property = "cveUrl12Modified", defaultValue = "", required = false) +260private String cveUrl12Modified; +261/** +262 * Data Mirror URL for CVE 2.0. +263 */ +264 @Parameter(property = "cveUrl20Modified", defaultValue = "", required = false) +265private String cveUrl20Modified; +266/** +267 * Base Data Mirror URL for CVE 1.2. +268 */ +269 @Parameter(property = "cveUrl12Base", defaultValue = "", required = false) +270private String cveUrl12Base; 271/** -272 * The path to mono for .NET Assembly analysis on non-windows systems. +272 * Data Mirror URL for CVE 2.0.273 */ -274 @Parameter(property = "pathToMono", defaultValue = "", required = false) -275private String pathToMono; +274 @Parameter(property = "cveUrl20Base", defaultValue = "", required = false) +275private String cveUrl20Base; 276277/** -278 * The Proxy URL. -279 * -280 * @deprecated Please use mavenSettings instead -281 */ -282 @SuppressWarnings("CanBeFinal") -283 @Parameter(property = "proxyUrl", defaultValue = "", required = false) -284 @Deprecated -285private String proxyUrl = null; -286/** -287 * Sets whether or not the external report format should be used. -288 * -289 * @deprecated the internal report is no longer supported -290 */ -291 @SuppressWarnings("CanBeFinal") -292 @Parameter(property = "externalReport") -293 @Deprecated -294private String externalReport = null; -295// </editor-fold> -296/** -297 * Constructs a new dependency-check-mojo. -298 */ -299publicDependencyCheckMojo() { -300final InputStream in = DependencyCheckMojo.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE); -301 LogUtils.prepareLogger(in, logFile); -302 } -303 -304/** -305 * Executes the Dependency-Check on the dependent libraries. -306 * -307 * @return the Engine used to scan the dependencies. -308 * @throws DatabaseException thrown if there is an exception connecting to the database -309 */ -310private Engine executeDependencyCheck() throws DatabaseException { -311return executeDependencyCheck(getProject()); -312 } -313 -314/** -315 * Executes the Dependency-Check on the dependent libraries. -316 * -317 * @param project the project to run dependency-check on -318 * @return the Engine used to scan the dependencies. -319 * @throws DatabaseException thrown if there is an exception connecting to the database -320 */ -321private Engine executeDependencyCheck(MavenProject project) throws DatabaseException { -322final Engine localEngine = initializeEngine(); -323 -324final Set<Artifact> artifacts = project.getArtifacts(); -325for (Artifact a : artifacts) { -326if (excludeFromScan(a)) { -327continue; -328 } -329 -330 localEngine.scan(a.getFile().getAbsolutePath()); -331 } -332 localEngine.analyzeDependencies(); -333 -334return localEngine; -335 } -336 -337/** -338 * Initializes a new <code>Engine</code> that can be used for scanning. -339 * -340 * @return a newly instantiated <code>Engine</code> -341 * @throws DatabaseException thrown if there is a database exception -342 */ -343private Engine initializeEngine() throws DatabaseException { -344 populateSettings(); -345final Engine localEngine = new Engine(); -346return localEngine; -347 } -348 -349/** -350 * Tests is the artifact should be included in the scan (i.e. is the dependency in a scope that is being scanned). -351 * -352 * @param a the Artifact to test -353 * @return <code>true</code> if the artifact is in an excluded scope; otherwise <code>false</code> -354 */ -355privateboolean excludeFromScan(Artifact a) { -356if (skipTestScope && Artifact.SCOPE_TEST.equals(a.getScope())) { -357returntrue; -358 } -359if (skipProvidedScope && Artifact.SCOPE_PROVIDED.equals(a.getScope())) { -360returntrue; -361 } -362if (skipRuntimeScope && !Artifact.SCOPE_RUNTIME.equals(a.getScope())) { -363returntrue; -364 } -365return false; +278 * The path to mono for .NET Assembly analysis on non-windows systems. +279 */ +280 @Parameter(property = "pathToMono", defaultValue = "", required = false) +281private String pathToMono; +282 +283/** +284 * The Proxy URL. +285 * +286 * @deprecated Please use mavenSettings instead +287 */ +288 @SuppressWarnings("CanBeFinal") +289 @Parameter(property = "proxyUrl", defaultValue = "", required = false) +290 @Deprecated +291private String proxyUrl = null; +292/** +293 * Sets whether or not the external report format should be used. +294 * +295 * @deprecated the internal report is no longer supported +296 */ +297 @SuppressWarnings("CanBeFinal") +298 @Parameter(property = "externalReport") +299 @Deprecated +300private String externalReport = null; +301 +302// </editor-fold> +303/** +304 * Constructs a new dependency-check-mojo. +305 */ +306publicDependencyCheckMojo() { +307final InputStream in = DependencyCheckMojo.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE); +308 LogUtils.prepareLogger(in, logFile); +309 } +310 +311/** +312 * Executes the Dependency-Check on the dependent libraries. +313 * +314 * @return the Engine used to scan the dependencies. +315 * @throws DatabaseException thrown if there is an exception connecting to the database +316 */ +317private Engine executeDependencyCheck() throws DatabaseException { +318return executeDependencyCheck(getProject()); +319 } +320 +321/** +322 * Executes the Dependency-Check on the dependent libraries. +323 * +324 * @param project the project to run dependency-check on +325 * @return the Engine used to scan the dependencies. +326 * @throws DatabaseException thrown if there is an exception connecting to the database +327 */ +328private Engine executeDependencyCheck(MavenProject project) throws DatabaseException { +329final Engine localEngine = initializeEngine(); +330 +331final Set<Artifact> artifacts = project.getArtifacts(); +332for (Artifact a : artifacts) { +333if (excludeFromScan(a)) { +334continue; +335 } +336final List<Dependency> deps = localEngine.scan(a.getFile().getAbsoluteFile()); +337if (deps != null) { +338if (deps.size() == 1) { +339final Dependency d = deps.get(0); +340if (d != null) { +341final MavenArtifact ma = new MavenArtifact(a.getGroupId(), a.getArtifactId(), a.getVersion()); +342 d.addAsEvidence("pom", ma, Confidence.HIGHEST); +343 } +344 } else { +345final String msg = String.format("More then 1 dependency was identified in first pass scan of '%s:%s:%s'", +346 a.getGroupId(), a.getArtifactId(), a.getVersion()); +347 LOGGER.info(msg); +348 } +349 } +350 } +351 localEngine.analyzeDependencies(); +352 +353return localEngine; +354 } +355 +356/** +357 * Initializes a new <code>Engine</code> that can be used for scanning. +358 * +359 * @return a newly instantiated <code>Engine</code> +360 * @throws DatabaseException thrown if there is a database exception +361 */ +362private Engine initializeEngine() throws DatabaseException { +363 populateSettings(); +364final Engine localEngine = new Engine(); +365return localEngine; 366 } 367 -368//<editor-fold defaultstate="collapsed" desc="Methods to populate global settings"> -369/** -370 * Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system -371 * properties required to change the proxy url, port, and connection timeout. -372 */ -373privatevoid populateSettings() { -374 Settings.initialize(); -375 InputStream mojoProperties = null; -376try { -377 mojoProperties = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE); -378 Settings.mergeProperties(mojoProperties); -379 } catch (IOException ex) { -380 LOGGER.log(Level.WARNING, "Unable to load the dependency-check ant task.properties file."); -381 LOGGER.log(Level.FINE, null, ex); -382 } finally { -383if (mojoProperties != null) { -384try { -385 mojoProperties.close(); -386 } catch (IOException ex) { -387 LOGGER.log(Level.FINEST, null, ex); -388 } -389 } -390 } -391 -392 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); -393if (externalReport != null) { -394 LOGGER.warning("The 'externalReport' option was set; this configuration option has been removed. " -395 + "Please update the dependency-check-maven plugin's configuration"); -396 } -397 -398if (proxyUrl != null && !proxyUrl.isEmpty()) { -399 LOGGER.warning("Deprecated configuration detected, proxyUrl will be ignored; use the maven settings " -400 + "to configure the proxy instead"); -401 } -402final Proxy proxy = getMavenProxy(); -403if (proxy != null) { -404 Settings.setString(Settings.KEYS.PROXY_SERVER, proxy.getHost()); -405 Settings.setString(Settings.KEYS.PROXY_PORT, Integer.toString(proxy.getPort())); -406final String userName = proxy.getUsername(); -407final String password = proxy.getPassword(); -408if (userName != null) { -409 Settings.setString(Settings.KEYS.PROXY_USERNAME, userName); -410 } -411if (password != null) { -412 Settings.setString(Settings.KEYS.PROXY_PASSWORD, password); -413 } -414 +368/** +369 * Tests is the artifact should be included in the scan (i.e. is the dependency in a scope that is being scanned). +370 * +371 * @param a the Artifact to test +372 * @return <code>true</code> if the artifact is in an excluded scope; otherwise <code>false</code> +373 */ +374privateboolean excludeFromScan(Artifact a) { +375if (skipTestScope && Artifact.SCOPE_TEST.equals(a.getScope())) { +376returntrue; +377 } +378if (skipProvidedScope && Artifact.SCOPE_PROVIDED.equals(a.getScope())) { +379returntrue; +380 } +381if (skipRuntimeScope && !Artifact.SCOPE_RUNTIME.equals(a.getScope())) { +382returntrue; +383 } +384return false; +385 } +386 +387//<editor-fold defaultstate="collapsed" desc="Methods to populate global settings"> +388/** +389 * Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system +390 * properties required to change the proxy url, port, and connection timeout. +391 */ +392privatevoid populateSettings() { +393 Settings.initialize(); +394 InputStream mojoProperties = null; +395try { +396 mojoProperties = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE); +397 Settings.mergeProperties(mojoProperties); +398 } catch (IOException ex) { +399 LOGGER.log(Level.WARNING, "Unable to load the dependency-check ant task.properties file."); +400 LOGGER.log(Level.FINE, null, ex); +401 } finally { +402if (mojoProperties != null) { +403try { +404 mojoProperties.close(); +405 } catch (IOException ex) { +406 LOGGER.log(Level.FINEST, null, ex); +407 } +408 } +409 } +410 +411 Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); +412if (externalReport != null) { +413 LOGGER.warning("The 'externalReport' option was set; this configuration option has been removed. " +414 + "Please update the dependency-check-maven plugin's configuration"); 415 } 416 -417if (connectionTimeout != null && !connectionTimeout.isEmpty()) { -418 Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout); +417if (proxyUrl != null && !proxyUrl.isEmpty()) { +418 LOGGER.warning("Deprecated configuration detected, proxyUrl will be ignored; use the maven settings " + "to configure the proxy instead"); 419 } -420if (suppressionFile != null && !suppressionFile.isEmpty()) { -421 Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile); -422 } -423 -424//File Type Analyzer Settings -425//JAR ANALYZER -426 Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, jarAnalyzerEnabled); -427//NUSPEC ANALYZER -428 Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, nuspecAnalyzerEnabled); -429//NEXUS ANALYZER -430 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, nexusAnalyzerEnabled); -431if (nexusUrl != null && !nexusUrl.isEmpty()) { -432 Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl); +420final Proxy proxy = getMavenProxy(); +421if (proxy != null) { +422 Settings.setString(Settings.KEYS.PROXY_SERVER, proxy.getHost()); +423 Settings.setString(Settings.KEYS.PROXY_PORT, Integer.toString(proxy.getPort())); +424final String userName = proxy.getUsername(); +425final String password = proxy.getPassword(); +426if (userName != null) { +427 Settings.setString(Settings.KEYS.PROXY_USERNAME, userName); +428 } +429if (password != null) { +430 Settings.setString(Settings.KEYS.PROXY_PASSWORD, password); +431 } +432433 } -434 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy); -435//ARCHIVE ANALYZER -436 Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, archiveAnalyzerEnabled); -437if (zipExtensions != null && !zipExtensions.isEmpty()) { -438 Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, zipExtensions); -439 } -440//ASSEMBLY ANALYZER -441 Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, assemblyAnalyzerEnabled); -442if (pathToMono != null && !pathToMono.isEmpty()) { -443 Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono); -444 } -445 -446//Database configuration -447if (databaseDriverName != null && !databaseDriverName.isEmpty()) { -448 Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName); -449 } -450if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) { -451 Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath); -452 } -453if (connectionString != null && !connectionString.isEmpty()) { -454 Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString); -455 } -456if (databaseUser != null && !databaseUser.isEmpty()) { -457 Settings.setString(Settings.KEYS.DB_USER, databaseUser); -458 } -459if (databasePassword != null && !databasePassword.isEmpty()) { -460 Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword); -461 } -462// Data Directory -463if (dataDirectory != null && !dataDirectory.isEmpty()) { -464 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory); -465 } -466 -467// Scope Exclusion -468 Settings.setBoolean(Settings.KEYS.SKIP_TEST_SCOPE, skipTestScope); -469 Settings.setBoolean(Settings.KEYS.SKIP_RUNTIME_SCOPE, skipRuntimeScope); -470 Settings.setBoolean(Settings.KEYS.SKIP_PROVIDED_SCOPE, skipProvidedScope); -471 -472// CVE Data Mirroring -473if (cveUrl12Modified != null && !cveUrl12Modified.isEmpty()) { -474 Settings.setString(Settings.KEYS.CVE_MODIFIED_12_URL, cveUrl12Modified); -475 } -476if (cveUrl20Modified != null && !cveUrl20Modified.isEmpty()) { -477 Settings.setString(Settings.KEYS.CVE_MODIFIED_20_URL, cveUrl20Modified); -478 } -479if (cveUrl12Base != null && !cveUrl12Base.isEmpty()) { -480 Settings.setString(Settings.KEYS.CVE_SCHEMA_1_2, cveUrl12Base); -481 } -482if (cveUrl20Base != null && !cveUrl20Base.isEmpty()) { -483 Settings.setString(Settings.KEYS.CVE_SCHEMA_2_0, cveUrl20Base); -484 } -485 } -486 -487/** -488 * Returns the maven proxy. -489 * -490 * @return the maven proxy -491 */ -492private Proxy getMavenProxy() { -493if (mavenSettings != null) { -494final List<Proxy> proxies = mavenSettings.getProxies(); -495if (proxies != null && proxies.size() > 0) { -496if (mavenSettingsProxyId != null) { -497for (Proxy proxy : proxies) { -498if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) { -499return proxy; -500 } -501 } -502 } elseif (proxies.size() == 1) { -503return proxies.get(0); -504 } else { -505 LOGGER.warning("Multiple proxy defentiions exist in the Maven settings. In the dependency-check " -506 + "configuration set the maveSettingsProxyId so that the correct proxy will be used."); -507thrownew IllegalStateException("Ambiguous proxy definition"); -508 } -509 } -510 } -511returnnull; -512 } -513//</editor-fold> -514 -515/** -516 * Executes the dependency-check and generates the report. -517 * -518 * @throws MojoExecutionException if a maven exception occurs -519 * @throws MojoFailureException thrown if a CVSS score is found that is higher then the configured level -520 */ -521 @Override -522protectedvoid performExecute() throws MojoExecutionException, MojoFailureException { -523try { -524 engine = executeDependencyCheck(); -525 ReportingUtil.generateExternalReports(engine, outputDirectory, getProject().getName(), format); -526if (this.showSummary) { -527 showSummary(engine.getDependencies()); -528 } -529if (this.failBuildOnCVSS <= 10) { -530 checkForFailure(engine.getDependencies()); -531 } -532 } catch (DatabaseException ex) { -533 LOGGER.log(Level.SEVERE, -534"Unable to connect to the dependency-check database; analysis has stopped"); -535 LOGGER.log(Level.FINE, "", ex); -536 } -537 } -538 +434 +435if (connectionTimeout != null && !connectionTimeout.isEmpty()) { +436 Settings.setString(Settings.KEYS.CONNECTION_TIMEOUT, connectionTimeout); +437 } +438if (suppressionFile != null && !suppressionFile.isEmpty()) { +439 Settings.setString(Settings.KEYS.SUPPRESSION_FILE, suppressionFile); +440 } +441 +442//File Type Analyzer Settings +443//JAR ANALYZER +444 Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, jarAnalyzerEnabled); +445//NUSPEC ANALYZER +446 Settings.setBoolean(Settings.KEYS.ANALYZER_NUSPEC_ENABLED, nuspecAnalyzerEnabled); +447//NEXUS ANALYZER +448 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED, nexusAnalyzerEnabled); +449if (nexusUrl != null && !nexusUrl.isEmpty()) { +450 Settings.setString(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl); +451 } +452 Settings.setBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY, nexusUsesProxy); +453//ARCHIVE ANALYZER +454 Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, archiveAnalyzerEnabled); +455if (zipExtensions != null && !zipExtensions.isEmpty()) { +456 Settings.setString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS, zipExtensions); +457 } +458//ASSEMBLY ANALYZER +459 Settings.setBoolean(Settings.KEYS.ANALYZER_ASSEMBLY_ENABLED, assemblyAnalyzerEnabled); +460if (pathToMono != null && !pathToMono.isEmpty()) { +461 Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, pathToMono); +462 } +463 +464//Database configuration +465if (databaseDriverName != null && !databaseDriverName.isEmpty()) { +466 Settings.setString(Settings.KEYS.DB_DRIVER_NAME, databaseDriverName); +467 } +468if (databaseDriverPath != null && !databaseDriverPath.isEmpty()) { +469 Settings.setString(Settings.KEYS.DB_DRIVER_PATH, databaseDriverPath); +470 } +471if (connectionString != null && !connectionString.isEmpty()) { +472 Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString); +473 } +474if (databaseUser != null && !databaseUser.isEmpty()) { +475 Settings.setString(Settings.KEYS.DB_USER, databaseUser); +476 } +477if (databasePassword != null && !databasePassword.isEmpty()) { +478 Settings.setString(Settings.KEYS.DB_PASSWORD, databasePassword); +479 } +480// Data Directory +481if (dataDirectory != null && !dataDirectory.isEmpty()) { +482 Settings.setString(Settings.KEYS.DATA_DIRECTORY, dataDirectory); +483 } +484 +485// Scope Exclusion +486 Settings.setBoolean(Settings.KEYS.SKIP_TEST_SCOPE, skipTestScope); +487 Settings.setBoolean(Settings.KEYS.SKIP_RUNTIME_SCOPE, skipRuntimeScope); +488 Settings.setBoolean(Settings.KEYS.SKIP_PROVIDED_SCOPE, skipProvidedScope); +489 +490// CVE Data Mirroring +491if (cveUrl12Modified != null && !cveUrl12Modified.isEmpty()) { +492 Settings.setString(Settings.KEYS.CVE_MODIFIED_12_URL, cveUrl12Modified); +493 } +494if (cveUrl20Modified != null && !cveUrl20Modified.isEmpty()) { +495 Settings.setString(Settings.KEYS.CVE_MODIFIED_20_URL, cveUrl20Modified); +496 } +497if (cveUrl12Base != null && !cveUrl12Base.isEmpty()) { +498 Settings.setString(Settings.KEYS.CVE_SCHEMA_1_2, cveUrl12Base); +499 } +500if (cveUrl20Base != null && !cveUrl20Base.isEmpty()) { +501 Settings.setString(Settings.KEYS.CVE_SCHEMA_2_0, cveUrl20Base); +502 } +503 } +504 +505/** +506 * Returns the maven proxy. +507 * +508 * @return the maven proxy +509 */ +510private Proxy getMavenProxy() { +511if (mavenSettings != null) { +512final List<Proxy> proxies = mavenSettings.getProxies(); +513if (proxies != null && proxies.size() > 0) { +514if (mavenSettingsProxyId != null) { +515for (Proxy proxy : proxies) { +516if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) { +517return proxy; +518 } +519 } +520 } elseif (proxies.size() == 1) { +521return proxies.get(0); +522 } else { +523 LOGGER.warning("Multiple proxy defentiions exist in the Maven settings. In the dependency-check " +524 + "configuration set the maveSettingsProxyId so that the correct proxy will be used."); +525thrownew IllegalStateException("Ambiguous proxy definition"); +526 } +527 } +528 } +529returnnull; +530 } +531 +532//</editor-fold> +533/** +534 * Executes the dependency-check and generates the report. +535 * +536 * @throws MojoExecutionException if a maven exception occurs +537 * @throws MojoFailureException thrown if a CVSS score is found that is higher then the configured level +538 */539 @Override -540protectedvoid postExecute() throws MojoExecutionException, MojoFailureException { +540protectedvoid performExecute() throws MojoExecutionException, MojoFailureException { 541try { -542super.postExecute(); -543 } finally { -544 cleanupEngine(); -545 } -546 } -547 -548 @Override -549protectedvoid postGenerate() throws MavenReportException { -550try { -551super.postGenerate(); -552 } finally { -553 cleanupEngine(); -554 } -555 } -556 -557/** -558 * Calls <code>engine.cleanup()</code> to release resources. -559 */ -560privatevoid cleanupEngine() { -561if (engine != null) { -562 engine.cleanup(); -563 engine = null; -564 } -565 Settings.cleanup(true); -566 } -567 -568/** -569 * Generates the Dependency-Check Site Report. -570 * -571 * @param locale the locale to use when generating the report -572 * @throws MavenReportException if a maven report exception occurs -573 */ -574 @Override -575protectedvoid executeNonAggregateReport(Locale locale) throws MavenReportException { -576 -577final List<Dependency> deps = readDataFile(); -578if (deps != null) { -579try { -580 engine = initializeEngine(); -581 engine.getDependencies().addAll(deps); -582 } catch (DatabaseException ex) { -583final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s", -584 getProject().getName()); -585thrownew MavenReportException(msg, ex); -586 } -587 } else { -588try { -589 engine = executeDependencyCheck(); -590 } catch (DatabaseException ex) { -591final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s", -592 getProject().getName()); -593thrownew MavenReportException(msg, ex); -594 } -595 } -596 ReportingUtil.generateExternalReports(engine, getReportOutputDirectory(), getProject().getName(), format); -597 } -598 -599 @Override -600protectedvoid executeAggregateReport(MavenProject project, Locale locale) throws MavenReportException { -601 List<Dependency> deps = readDataFile(project); -602if (deps != null) { -603try { -604 engine = initializeEngine(); -605 engine.getDependencies().addAll(deps); -606 } catch (DatabaseException ex) { -607final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s", -608 project.getName()); -609thrownew MavenReportException(msg, ex); -610 } -611 } else { -612try { -613 engine = executeDependencyCheck(project); -614 } catch (DatabaseException ex) { -615final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s", -616 project.getName()); -617thrownew MavenReportException(msg, ex); -618 } -619 } -620for (MavenProject child : getAllChildren(project)) { -621 deps = readDataFile(child); -622if (deps == null) { -623final String msg = String.format("Unable to include information on %s in the dependency-check aggregate report", child.getName()); -624 LOGGER.severe(msg); -625 } else { -626 engine.getDependencies().addAll(deps); +542 engine = executeDependencyCheck(); +543 ReportingUtil.generateExternalReports(engine, outputDirectory, getProject().getName(), format); +544if (this.showSummary) { +545 showSummary(engine.getDependencies()); +546 } +547if (this.failBuildOnCVSS <= 10) { +548 checkForFailure(engine.getDependencies()); +549 } +550 } catch (DatabaseException ex) { +551 LOGGER.log(Level.SEVERE, "Unable to connect to the dependency-check database; analysis has stopped"); +552 LOGGER.log(Level.FINE, "", ex); +553 } +554 } +555 +556 @Override +557protectedvoid postExecute() throws MojoExecutionException, MojoFailureException { +558try { +559super.postExecute(); +560 } finally { +561 cleanupEngine(); +562 } +563 } +564 +565 @Override +566protectedvoid postGenerate() throws MavenReportException { +567try { +568super.postGenerate(); +569 } finally { +570 cleanupEngine(); +571 } +572 } +573 +574/** +575 * Calls <code>engine.cleanup()</code> to release resources. +576 */ +577privatevoid cleanupEngine() { +578if (engine != null) { +579 engine.cleanup(); +580 engine = null; +581 } +582 Settings.cleanup(true); +583 } +584 +585/** +586 * Generates the Dependency-Check Site Report. +587 * +588 * @param locale the locale to use when generating the report +589 * @throws MavenReportException if a maven report exception occurs +590 */ +591 @Override +592protectedvoid executeNonAggregateReport(Locale locale) throws MavenReportException { +593 +594final List<Dependency> deps = readDataFile(); +595if (deps != null) { +596try { +597 engine = initializeEngine(); +598 engine.getDependencies().addAll(deps); +599 } catch (DatabaseException ex) { +600final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s", +601 getProject().getName()); +602thrownew MavenReportException(msg, ex); +603 } +604 } else { +605try { +606 engine = executeDependencyCheck(); +607 } catch (DatabaseException ex) { +608final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s", +609 getProject().getName()); +610thrownew MavenReportException(msg, ex); +611 } +612 } +613 ReportingUtil.generateExternalReports(engine, getReportOutputDirectory(), getProject().getName(), format); +614 } +615 +616 @Override +617protectedvoid executeAggregateReport(MavenProject project, Locale locale) throws MavenReportException { +618 List<Dependency> deps = readDataFile(project); +619if (deps != null) { +620try { +621 engine = initializeEngine(); +622 engine.getDependencies().addAll(deps); +623 } catch (DatabaseException ex) { +624final String msg = String.format("An unrecoverable exception with the dependency-check initialization occured while scanning %s", +625 project.getName()); +626thrownew MavenReportException(msg, ex); 627 } -628 } -629final DependencyBundlingAnalyzer bundler = new DependencyBundlingAnalyzer(); -630try { -631 bundler.analyze(null, engine); -632 } catch (AnalysisException ex) { -633 LOGGER.log(Level.WARNING, "An error occured grouping the dependencies; duplicate entries may exist in the report", ex); -634 LOGGER.log(Level.FINE, "Bundling Exception", ex); -635 } -636final File outputDir = getReportOutputDirectory(project); -637if (outputDir != null) { -638 ReportingUtil.generateExternalReports(engine, outputDir, project.getName(), format); -639 } -640 } -641 -642// <editor-fold defaultstate="collapsed" desc="Mojo interface/abstract required setter/getter methods"> -643/** -644 * Returns the output name. -645 * -646 * @return the output name -647 */ -648public String getOutputName() { -649if ("HTML".equalsIgnoreCase(this.format) -650 || "ALL".equalsIgnoreCase(this.format)) { -651return"dependency-check-report"; -652 } elseif ("XML".equalsIgnoreCase(this.format)) { -653return"dependency-check-report.xml#"; -654 } elseif ("VULN".equalsIgnoreCase(this.format)) { -655return"dependency-check-vulnerability"; -656 } else { -657 LOGGER.log(Level.WARNING, "Unknown report format used during site generation."); -658return"dependency-check-report"; -659 } -660 } -661 -662/** -663 * Returns the category name. -664 * -665 * @return the category name -666 */ -667public String getCategoryName() { -668return MavenReport.CATEGORY_PROJECT_REPORTS; -669 } -670 -671/** -672 * Returns the report name. -673 * -674 * @param locale the location -675 * @return the report name -676 */ -677public String getName(Locale locale) { -678return"dependency-check"; -679 } -680 -681/** -682 * Gets the description of the Dependency-Check report to be displayed in the Maven Generated Reports page. -683 * -684 * @param locale The Locale to get the description for -685 * @return the description -686 */ -687public String getDescription(Locale locale) { -688return"A report providing details on any published " -689 + "vulnerabilities within project dependencies. This report is a best effort but may contain " -690 + "false positives and false negatives."; -691 } -692 -693/** -694 * Returns whether or not a report can be generated. -695 * -696 * @return <code>true</code> if a report can be generated; otherwise <code>false</code> -697 */ -698publicboolean canGenerateReport() { -699if (canGenerateAggregateReport() || (isAggregate() && isMultiModule())) { -700returntrue; -701 } -702if (canGenerateNonAggregateReport()) { -703returntrue; -704 } else { -705final String msg; -706if (getProject().getArtifacts().size() > 0) { -707 msg = "No project dependencies exist in the included scope - dependency-check:check is unable to generate a report."; -708 } else { -709 msg = "No project dependencies exist - dependency-check:check is unable to generate a report."; -710 } -711 LOGGER.warning(msg); -712 } -713 -714return false; -715 } -716 -717/** -718 * Returns whether or not a non-aggregate report can be generated. -719 * -720 * @return <code>true</code> if a non-aggregate report can be generated; otherwise <code>false</code> -721 */ -722 @Override -723protectedboolean canGenerateNonAggregateReport() { -724boolean ability = false; -725for (Artifact a : getProject().getArtifacts()) { -726if (!excludeFromScan(a)) { -727 ability = true; -728break; -729 } -730 } -731return ability; +628 } else { +629try { +630 engine = executeDependencyCheck(project); +631 } catch (DatabaseException ex) { +632final String msg = String.format("An unrecoverable exception with the dependency-check scan occured while scanning %s", +633 project.getName()); +634thrownew MavenReportException(msg, ex); +635 } +636 } +637for (MavenProject child : getAllChildren(project)) { +638 deps = readDataFile(child); +639if (deps == null) { +640final String msg = String.format("Unable to include information on %s in the dependency-check aggregate report", +641 child.getName()); +642 LOGGER.severe(msg); +643 } else { +644 engine.getDependencies().addAll(deps); +645 } +646 } +647final DependencyBundlingAnalyzer bundler = new DependencyBundlingAnalyzer(); +648try { +649 bundler.analyze(null, engine); +650 } catch (AnalysisException ex) { +651 LOGGER.log(Level.WARNING, "An error occured grouping the dependencies; duplicate entries may exist in the report", ex); +652 LOGGER.log(Level.FINE, "Bundling Exception", ex); +653 } +654final File outputDir = getReportOutputDirectory(project); +655if (outputDir != null) { +656 ReportingUtil.generateExternalReports(engine, outputDir, project.getName(), format); +657 } +658 } +659 +660// <editor-fold defaultstate="collapsed" desc="Mojo interface/abstract required setter/getter methods"> +661/** +662 * Returns the output name. +663 * +664 * @return the output name +665 */ +666public String getOutputName() { +667if ("HTML".equalsIgnoreCase(this.format) || "ALL".equalsIgnoreCase(this.format)) { +668return"dependency-check-report"; +669 } elseif ("XML".equalsIgnoreCase(this.format)) { +670return"dependency-check-report.xml#"; +671 } elseif ("VULN".equalsIgnoreCase(this.format)) { +672return"dependency-check-vulnerability"; +673 } else { +674 LOGGER.log(Level.WARNING, "Unknown report format used during site generation."); +675return"dependency-check-report"; +676 } +677 } +678 +679/** +680 * Returns the category name. +681 * +682 * @return the category name +683 */ +684public String getCategoryName() { +685return MavenReport.CATEGORY_PROJECT_REPORTS; +686 } +687 +688/** +689 * Returns the report name. +690 * +691 * @param locale the location +692 * @return the report name +693 */ +694public String getName(Locale locale) { +695return"dependency-check"; +696 } +697 +698/** +699 * Gets the description of the Dependency-Check report to be displayed in the Maven Generated Reports page. +700 * +701 * @param locale The Locale to get the description for +702 * @return the description +703 */ +704public String getDescription(Locale locale) { +705return"A report providing details on any published " +706 + "vulnerabilities within project dependencies. This report is a best effort but may contain " +707 + "false positives and false negatives."; +708 } +709 +710/** +711 * Returns whether or not a report can be generated. +712 * +713 * @return <code>true</code> if a report can be generated; otherwise <code>false</code> +714 */ +715publicboolean canGenerateReport() { +716if (canGenerateAggregateReport() || (isAggregate() && isMultiModule())) { +717returntrue; +718 } +719if (canGenerateNonAggregateReport()) { +720returntrue; +721 } else { +722final String msg; +723if (getProject().getArtifacts().size() > 0) { +724 msg = "No project dependencies exist in the included scope - dependency-check:check is unable to generate a report."; +725 } else { +726 msg = "No project dependencies exist - dependency-check:check is unable to generate a report."; +727 } +728 LOGGER.warning(msg); +729 } +730 +731return false; 732 } 733734/** -735 * Returns whether or not an aggregate report can be generated. +735 * Returns whether or not a non-aggregate report can be generated.736 * -737 * @return <code>true</code> if an aggregate report can be generated; otherwise <code>false</code> +737 * @return <code>true</code> if a non-aggregate report can be generated; otherwise <code>false</code>738 */739 @Override -740protectedboolean canGenerateAggregateReport() { -741return isAggregate() && isLastProject(); -742 } -743// </editor-fold> -744 -745//<editor-fold defaultstate="collapsed" desc="Methods to fail build or show summary"> -746/** -747 * Checks to see if a vulnerability has been identified with a CVSS score that is above the threshold set in the -748 * configuration. -749 * -750 * @param dependencies the list of dependency objects -751 * @throws MojoFailureException thrown if a CVSS score is found that is higher then the threshold set -752 */ -753privatevoid checkForFailure(List<Dependency> dependencies) throws MojoFailureException { -754final StringBuilder ids = new StringBuilder(); -755for (Dependency d : dependencies) { -756boolean addName = true; -757for (Vulnerability v : d.getVulnerabilities()) { -758if (v.getCvssScore() >= failBuildOnCVSS) { -759if (addName) { -760 addName = false; -761 ids.append(NEW_LINE).append(d.getFileName()).append(": "); -762 ids.append(v.getName()); -763 } else { -764 ids.append(", ").append(v.getName()); -765 } -766 } -767 } -768 } -769if (ids.length() > 0) { -770final String msg = String.format("%n%nDependency-Check Failure:%n" -771 + "One or more dependencies were identified with vulnerabilities that have a CVSS score greater then '%.1f': %s%n" -772 + "See the dependency-check report for more details.%n%n", failBuildOnCVSS, ids.toString()); -773thrownew MojoFailureException(msg); -774 } -775 } -776 -777/** -778 * Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries. -779 * -780 * @param dependencies a list of dependency objects -781 */ -782privatevoid showSummary(List<Dependency> dependencies) { -783final StringBuilder summary = new StringBuilder(); -784for (Dependency d : dependencies) { -785boolean firstEntry = true; -786final StringBuilder ids = new StringBuilder(); -787for (Vulnerability v : d.getVulnerabilities()) { -788if (firstEntry) { -789 firstEntry = false; -790 } else { -791 ids.append(", "); -792 } -793 ids.append(v.getName()); -794 } -795if (ids.length() > 0) { -796 summary.append(d.getFileName()).append(" ("); -797 firstEntry = true; -798for (Identifier id : d.getIdentifiers()) { -799if (firstEntry) { -800 firstEntry = false; -801 } else { -802 summary.append(", "); -803 } -804 summary.append(id.getValue()); -805 } -806 summary.append(") : ").append(ids).append(NEW_LINE); -807 } -808 } -809if (summary.length() > 0) { -810final String msg = String.format("%n%n" -811 + "One or more dependencies were identified with known vulnerabilities:%n%n%s" -812 + "%n%nSee the dependency-check report for more details.%n%n", summary.toString()); -813 LOGGER.log(Level.WARNING, msg); -814 } -815 } -816//</editor-fold> -817 -818//<editor-fold defaultstate="collapsed" desc="Methods to read/write the serialized data file"> -819/** -820 * Writes the scan data to disk. This is used to serialize the scan data between the "check" and "aggregate" phase. -821 * -822 * @return the File object referencing the data file that was written -823 */ -824 @Override -825protected File writeDataFile() { -826 File file = null; -827if (engine != null && getProject().getContextValue(this.getDataFileContextKey()) == null) { -828 file = new File(getProject().getBuild().getDirectory(), getDataFileName()); -829 OutputStream os = null; -830 OutputStream bos = null; -831 ObjectOutputStream out = null; -832try { -833 os = new FileOutputStream(file); -834 bos = new BufferedOutputStream(os); -835 out = new ObjectOutputStream(bos); -836 out.writeObject(engine.getDependencies()); -837 out.flush(); -838 -839//call reset to prevent resource leaks per -840//https://www.securecoding.cert.org/confluence/display/java/SER10-J.+Avoid+memory+and+resource+leaks+during+serialization -841 out.reset(); -842 -843 } catch (IOException ex) { -844 LOGGER.log(Level.WARNING, "Unable to create data file used for report aggregation; " -845 + "if report aggregation is being used the results may be incomplete."); -846 LOGGER.log(Level.FINE, ex.getMessage(), ex); -847 } finally { -848if (out != null) { -849try { -850 out.close(); -851 } catch (IOException ex) { -852 LOGGER.log(Level.FINEST, "ignore", ex); -853 } -854 } -855if (bos != null) { -856try { -857 bos.close(); -858 } catch (IOException ex) { -859 LOGGER.log(Level.FINEST, "ignore", ex); -860 } -861 } -862if (os != null) { -863try { -864 os.close(); -865 } catch (IOException ex) { -866 LOGGER.log(Level.FINEST, "ignore", ex); -867 } -868 } -869 } -870 } -871return file; -872 } -873 -874/** -875 * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and -876 * "aggregate" phase. -877 * -878 * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise -879 * <code>null</code> is returned -880 */ -881protected List<Dependency> readDataFile() { -882return readDataFile(getProject()); -883 } -884 -885/** -886 * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and -887 * "aggregate" phase. -888 * -889 * @param project the Maven project to read the data file from -890 * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise -891 * <code>null</code> is returned -892 */ -893protected List<Dependency> readDataFile(MavenProject project) { -894final Object oPath = project.getContextValue(this.getDataFileContextKey()); -895if (oPath == null) { -896returnnull; -897 } -898 List<Dependency> ret = null; -899final String path = (String) oPath; -900 ObjectInputStream ois = null; -901try { -902 ois = new ObjectInputStream(new FileInputStream(path)); -903 ret = (List<Dependency>) ois.readObject(); -904 } catch (FileNotFoundException ex) { -905//TODO fix logging -906 LOGGER.log(Level.SEVERE, null, ex); -907 } catch (IOException ex) { -908 LOGGER.log(Level.SEVERE, null, ex); -909 } catch (ClassNotFoundException ex) { -910 LOGGER.log(Level.SEVERE, null, ex); -911 } finally { -912if (ois != null) { -913try { -914 ois.close(); -915 } catch (IOException ex) { -916 LOGGER.log(Level.SEVERE, null, ex); -917 } -918 } -919 } -920return ret; -921 } -922//</editor-fold> -923 } +740protectedboolean canGenerateNonAggregateReport() { +741boolean ability = false; +742for (Artifact a : getProject().getArtifacts()) { +743if (!excludeFromScan(a)) { +744 ability = true; +745break; +746 } +747 } +748return ability; +749 } +750 +751/** +752 * Returns whether or not an aggregate report can be generated. +753 * +754 * @return <code>true</code> if an aggregate report can be generated; otherwise <code>false</code> +755 */ +756 @Override +757protectedboolean canGenerateAggregateReport() { +758return isAggregate() && isLastProject(); +759 } +760 +761// </editor-fold> +762//<editor-fold defaultstate="collapsed" desc="Methods to fail build or show summary"> +763/** +764 * Checks to see if a vulnerability has been identified with a CVSS score that is above the threshold set in the +765 * configuration. +766 * +767 * @param dependencies the list of dependency objects +768 * @throws MojoFailureException thrown if a CVSS score is found that is higher then the threshold set +769 */ +770privatevoid checkForFailure(List<Dependency> dependencies) throws MojoFailureException { +771final StringBuilder ids = new StringBuilder(); +772for (Dependency d : dependencies) { +773boolean addName = true; +774for (Vulnerability v : d.getVulnerabilities()) { +775if (v.getCvssScore() >= failBuildOnCVSS) { +776if (addName) { +777 addName = false; +778 ids.append(NEW_LINE).append(d.getFileName()).append(": "); +779 ids.append(v.getName()); +780 } else { +781 ids.append(", ").append(v.getName()); +782 } +783 } +784 } +785 } +786if (ids.length() > 0) { +787final String msg = String.format("%n%nDependency-Check Failure:%n" +788 + "One or more dependencies were identified with vulnerabilities that have a CVSS score greater then '%.1f': %s%n" +789 + "See the dependency-check report for more details.%n%n", failBuildOnCVSS, ids.toString()); +790thrownew MojoFailureException(msg); +791 } +792 } +793 +794/** +795 * Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries. +796 * +797 * @param dependencies a list of dependency objects +798 */ +799privatevoid showSummary(List<Dependency> dependencies) { +800final StringBuilder summary = new StringBuilder(); +801for (Dependency d : dependencies) { +802boolean firstEntry = true; +803final StringBuilder ids = new StringBuilder(); +804for (Vulnerability v : d.getVulnerabilities()) { +805if (firstEntry) { +806 firstEntry = false; +807 } else { +808 ids.append(", "); +809 } +810 ids.append(v.getName()); +811 } +812if (ids.length() > 0) { +813 summary.append(d.getFileName()).append(" ("); +814 firstEntry = true; +815for (Identifier id : d.getIdentifiers()) { +816if (firstEntry) { +817 firstEntry = false; +818 } else { +819 summary.append(", "); +820 } +821 summary.append(id.getValue()); +822 } +823 summary.append(") : ").append(ids).append(NEW_LINE); +824 } +825 } +826if (summary.length() > 0) { +827final String msg = String.format("%n%n" + "One or more dependencies were identified with known vulnerabilities:%n%n%s" +828 + "%n%nSee the dependency-check report for more details.%n%n", summary.toString()); +829 LOGGER.log(Level.WARNING, msg); +830 } +831 } +832 +833//</editor-fold> +834//<editor-fold defaultstate="collapsed" desc="Methods to read/write the serialized data file"> +835/** +836 * Writes the scan data to disk. This is used to serialize the scan data between the "check" and "aggregate" phase. +837 * +838 * @return the File object referencing the data file that was written +839 */ +840 @Override +841protected File writeDataFile() { +842 File file = null; +843if (engine != null && getProject().getContextValue(this.getDataFileContextKey()) == null) { +844 file = new File(getProject().getBuild().getDirectory(), getDataFileName()); +845 OutputStream os = null; +846 OutputStream bos = null; +847 ObjectOutputStream out = null; +848try { +849 os = new FileOutputStream(file); +850 bos = new BufferedOutputStream(os); +851 out = new ObjectOutputStream(bos); +852 out.writeObject(engine.getDependencies()); +853 out.flush(); +854 +855//call reset to prevent resource leaks per +856//https://www.securecoding.cert.org/confluence/display/java/SER10-J.+Avoid+memory+and+resource+leaks+during+serialization +857 out.reset(); +858 +859 } catch (IOException ex) { +860 LOGGER.log(Level.WARNING, "Unable to create data file used for report aggregation; " +861 + "if report aggregation is being used the results may be incomplete."); +862 LOGGER.log(Level.FINE, ex.getMessage(), ex); +863 } finally { +864if (out != null) { +865try { +866 out.close(); +867 } catch (IOException ex) { +868 LOGGER.log(Level.FINEST, "ignore", ex); +869 } +870 } +871if (bos != null) { +872try { +873 bos.close(); +874 } catch (IOException ex) { +875 LOGGER.log(Level.FINEST, "ignore", ex); +876 } +877 } +878if (os != null) { +879try { +880 os.close(); +881 } catch (IOException ex) { +882 LOGGER.log(Level.FINEST, "ignore", ex); +883 } +884 } +885 } +886 } +887return file; +888 } +889 +890/** +891 * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and +892 * "aggregate" phase. +893 * +894 * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise +895 * <code>null</code> is returned +896 */ +897protected List<Dependency> readDataFile() { +898return readDataFile(getProject()); +899 } +900 +901/** +902 * Reads the serialized scan data from disk. This is used to serialize the scan data between the "check" and +903 * "aggregate" phase. +904 * +905 * @param project the Maven project to read the data file from +906 * @return a <code>Engine</code> object populated with dependencies if the serialized data file exists; otherwise +907 * <code>null</code> is returned +908 */ +909protected List<Dependency> readDataFile(MavenProject project) { +910final Object oPath = project.getContextValue(this.getDataFileContextKey()); +911if (oPath == null) { +912returnnull; +913 } +914 List<Dependency> ret = null; +915final String path = (String) oPath; +916 ObjectInputStream ois = null; +917try { +918 ois = new ObjectInputStream(new FileInputStream(path)); +919 ret = (List<Dependency>) ois.readObject(); +920 } catch (FileNotFoundException ex) { +921//TODO fix logging +922 LOGGER.log(Level.SEVERE, null, ex); +923 } catch (IOException ex) { +924 LOGGER.log(Level.SEVERE, null, ex); +925 } catch (ClassNotFoundException ex) { +926 LOGGER.log(Level.SEVERE, null, ex); +927 } finally { +928if (ois != null) { +929try { +930 ois.close(); +931 } catch (IOException ex) { +932 LOGGER.log(Level.SEVERE, null, ex); +933 } +934 } +935 } +936return ret; +937 } +938//</editor-fold> +939 }
    diff --git a/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-frame.html b/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-frame.html index 1c24ca41a..d0a6b8e68 100644 --- a/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-frame.html +++ b/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference Package org.owasp.dependencycheck.maven + Dependency-Check Maven Plugin 1.2.6 Reference Package org.owasp.dependencycheck.maven diff --git a/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-summary.html b/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-summary.html index 605bda809..c1036c80d 100644 --- a/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-summary.html +++ b/dependency-check-maven/xref/org/owasp/dependencycheck/maven/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference Package org.owasp.dependencycheck.maven + Dependency-Check Maven Plugin 1.2.6 Reference Package org.owasp.dependencycheck.maven diff --git a/dependency-check-maven/xref/overview-frame.html b/dependency-check-maven/xref/overview-frame.html index 1dcb2eb31..4708992a8 100644 --- a/dependency-check-maven/xref/overview-frame.html +++ b/dependency-check-maven/xref/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference + Dependency-Check Maven Plugin 1.2.6 Reference diff --git a/dependency-check-maven/xref/overview-summary.html b/dependency-check-maven/xref/overview-summary.html index cfa7a5fe6..6ccf78671 100644 --- a/dependency-check-maven/xref/overview-summary.html +++ b/dependency-check-maven/xref/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Maven Plugin 1.2.5 Reference + Dependency-Check Maven Plugin 1.2.6 Reference @@ -24,7 +24,7 @@ -

    Dependency-Check Maven Plugin 1.2.5 Reference

    +

    Dependency-Check Maven Plugin 1.2.6 Reference

    diff --git a/dependency-check-utils/apidocs/allclasses-frame.html b/dependency-check-utils/apidocs/allclasses-frame.html index 39083e9a7..02dc65933 100644 --- a/dependency-check-utils/apidocs/allclasses-frame.html +++ b/dependency-check-utils/apidocs/allclasses-frame.html @@ -2,28 +2,56 @@ - + -All Classes (Dependency-Check Utils 1.2.5 API) - +All Classes (Dependency-Check Utils 1.2.6 API) +

    All Classes

    diff --git a/dependency-check-utils/apidocs/allclasses-noframe.html b/dependency-check-utils/apidocs/allclasses-noframe.html index 60073a27d..036b97b82 100644 --- a/dependency-check-utils/apidocs/allclasses-noframe.html +++ b/dependency-check-utils/apidocs/allclasses-noframe.html @@ -2,28 +2,56 @@ - + -All Classes (Dependency-Check Utils 1.2.5 API) - +All Classes (Dependency-Check Utils 1.2.6 API) +

    All Classes

    diff --git a/dependency-check-utils/apidocs/constant-values.html b/dependency-check-utils/apidocs/constant-values.html index e5c19ba51..6f2b3ccb2 100644 --- a/dependency-check-utils/apidocs/constant-values.html +++ b/dependency-check-utils/apidocs/constant-values.html @@ -2,16 +2,16 @@ - + -Constant Field Values (Dependency-Check Utils 1.2.5 API) - +Constant Field Values (Dependency-Check Utils 1.2.6 API) + @@ -25,10 +25,11 @@
    + + + + + + + + + + + + + + + + + + +
    org.owasp.dependencycheck.org.apache.tools.ant.DirectoryScanner 
    Modifier and TypeConstant FieldValue
    + +public static final StringDOES_NOT_EXIST_POSTFIX" does not exist."
    + +public static final intMAX_LEVELS_OF_SYMLINKS5
    + + +
      +
    • + + + + + + + + + + + + + + + + + + + +
      org.owasp.dependencycheck.org.apache.tools.ant.launch.Locator 
      Modifier and TypeConstant FieldValue
      + +public static final StringERROR_NOT_FILE_URI"Can only handle valid file: URIs, not "
      + +public static final StringURI_ENCODING"UTF-8"
      +
    • +
    + +
      +
    • + + + + + + + + + + + + + + + + + + + +
      org.owasp.dependencycheck.org.apache.tools.ant.types.Resource 
      Modifier and TypeConstant FieldValue
      + +public static final longUNKNOWN_DATETIME0L
      + +public static final longUNKNOWN_SIZE-1L
      +
    • +
    +
      +
    • + + + + + + + + + + + + + + +
      org.owasp.dependencycheck.org.apache.tools.ant.types.selectors.SelectorUtils 
      Modifier and TypeConstant FieldValue
      + +public static final StringDEEP_TREE_MATCH"**"
      +
    • +
    + + + + + +
      +
    • + + + + + + + + + + + +
      Deprecated Constructors 
      Constructor and Description
      org.owasp.dependencycheck.org.apache.tools.ant.types.Reference() +
      since 1.7. Please use Reference#Reference(Project,String) instead.
      +
      org.owasp.dependencycheck.org.apache.tools.ant.types.Reference(String) +
      since 1.7. Please use Reference#Reference(Project,String) instead.
      +
    • @@ -124,10 +232,11 @@ diff --git a/dependency-check-utils/license.html b/dependency-check-utils/license.html index 799022483..850c053ad 100644 --- a/dependency-check-utils/license.html +++ b/dependency-check-utils/license.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Project License @@ -54,7 +54,7 @@
    • - + /
    • @@ -67,9 +67,9 @@ -
    • | Last Published: 2014-09-16
    • +
    • | Last Published: 2014-11-16
    • - Version: 1.2.5 + Version: 1.2.6
    diff --git a/dependency-check-utils/plugin-updates-report.html b/dependency-check-utils/plugin-updates-report.html index e8eb91b13..372a9b71d 100644 --- a/dependency-check-utils/plugin-updates-report.html +++ b/dependency-check-utils/plugin-updates-report.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Plugin Updates Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -230,7 +230,7 @@ # of plugins using the latest version available -5 +1 # of plugins where the next version available is smaller than an incremental version update @@ -242,7 +242,7 @@ # of plugins where the next version available is a minor version update -9 +13 # of plugins where the next version available is a major version update @@ -328,13 +328,13 @@ Next Major Dependency status - + com.github.github site-maven-plugin -0.9 - +0.9 +0.10 @@ -348,13 +348,13 @@ - + org.apache.maven.plugins maven-compiler-plugin -3.1 - +3.1 +3.2 @@ -368,13 +368,13 @@ - + org.apache.maven.plugins maven-failsafe-plugin -2.16 - +2.16 +2.17 @@ -418,13 +418,13 @@ - + org.apache.maven.plugins maven-surefire-plugin -2.16 - +2.16 +2.17 @@ -455,7 +455,7 @@ - + @@ -464,7 +464,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id com.github.github
    site-maven-plugin
    Current Version0.9
    +0.9 + +Newer versions +0.10 Next Minor

    Plugin org.apache.maven.plugins:maven-antrun-plugin

    @@ -500,7 +503,7 @@ -
    2.2-beta-5
    Newer versions2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4 Latest Minor
    +2.2 Next Version
    2.2.1 Next Incremental
    2.2.2 Latest Incremental
    2.3 Next Minor
    2.4
    2.4.1
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-clean-plugin

    @@ -518,13 +521,13 @@ -
    2.4.1
    Newer versions2.5 Next Minor
    +2.5 Next Minor
    2.6
    2.6.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-compiler-plugin

    - + @@ -533,7 +536,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-compiler-plugin
    Current Version3.1
    +3.1 + +Newer versions +3.2 Next Minor

    Plugin org.apache.maven.plugins:maven-dependency-plugin

    @@ -551,7 +557,7 @@ -
    2.1
    Newer versions2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8 Latest Minor
    +2.2 Next Minor
    2.3
    2.4
    2.5
    2.5.1
    2.6
    2.7
    2.8
    2.9 Latest Minor

    Plugin org.apache.maven.plugins:maven-deploy-plugin

    @@ -569,13 +575,13 @@ -
    2.7
    Newer versions2.8 Next Minor
    2.8.1 Latest Minor
    +2.8 Next Minor
    2.8.1
    2.8.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-failsafe-plugin

    - + @@ -584,7 +590,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-failsafe-plugin
    Current Version2.16
    +2.16 + +Newer versions +2.17 Next Minor
    2.18 Latest Minor

    Plugin org.apache.maven.plugins:maven-install-plugin

    @@ -602,7 +611,7 @@ -
    2.3.1
    Newer versions2.4 Next Minor
    2.5
    2.5.1 Latest Minor
    +2.4 Next Minor
    2.5
    2.5.1
    2.5.2 Latest Minor

    Plugin org.apache.maven.plugins:maven-jar-plugin

    @@ -620,7 +629,7 @@ -
    2.3.2
    Newer versions2.4 Next Minor
    +2.4 Next Minor
    2.5 Latest Minor

    Plugin org.apache.maven.plugins:maven-release-plugin

    @@ -638,7 +647,7 @@ -
    2.0
    Newer versions2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2 Latest Minor
    +2.1 Next Minor
    2.2
    2.2.1
    2.2.2
    2.3
    2.3.1
    2.3.2
    2.4
    2.4.1
    2.4.2
    2.5
    2.5.1 Latest Minor

    Plugin org.apache.maven.plugins:maven-resources-plugin

    @@ -656,7 +665,7 @@ -
    2.5
    Newer versions2.6 Next Minor
    +2.6 Next Minor
    2.7 Latest Minor

    Plugin org.apache.maven.plugins:maven-site-plugin

    @@ -740,7 +749,7 @@
    - + @@ -749,7 +758,10 @@ -
    Status No newer versions available.
     There is at least one newer minor version available. Minor updates are sometimes passive.
    Group Id org.apache.maven.plugins
    maven-surefire-plugin
    Current Version2.16
    +2.16 + +Newer versions +2.17 Next Minor
    2.18 Latest Minor

    Plugin org.codehaus.mojo:cobertura-maven-plugin

    diff --git a/dependency-check-utils/pmd.html b/dependency-check-utils/pmd.html index cd5eb0d0c..94a65b483 100644 --- a/dependency-check-utils/pmd.html +++ b/dependency-check-utils/pmd.html @@ -1,13 +1,13 @@ - + dependency-check-ant - PMD Results @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-utils/project-info.html b/dependency-check-utils/project-info.html index 83a8c8aca..a85c615f5 100644 --- a/dependency-check-utils/project-info.html +++ b/dependency-check-utils/project-info.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Project Information @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-utils/project-reports.html b/dependency-check-utils/project-reports.html index caab7ca75..c5d276e45 100644 --- a/dependency-check-utils/project-reports.html +++ b/dependency-check-utils/project-reports.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Generated Reports @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/dependency-check-utils/project-summary.html b/dependency-check-utils/project-summary.html index fffae35d2..6f7d2e38c 100644 --- a/dependency-check-utils/project-summary.html +++ b/dependency-check-utils/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Project Summary @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -203,7 +203,7 @@ - + diff --git a/dependency-check-utils/surefire-report.html b/dependency-check-utils/surefire-report.html index 3abe4fac3..9deb24eee 100644 --- a/dependency-check-utils/surefire-report.html +++ b/dependency-check-utils/surefire-report.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Surefire Report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -254,12 +254,12 @@ function toggleDisplay(elementId) { - + -
    dependency-check-utils
    Version1.2.5
    1.2.6
    Type jar
    Success Rate Time
    2125 0 0 0 100%0.263

    +0.137

    Note: failures are anticipated and checked for with assertions while errors are unanticipated.


    Package List

    @@ -274,15 +274,44 @@ function toggleDisplay(elementId) { Success Rate Time +org.owasp.dependencycheck.org.apache.tools.ant +4 +0 +0 +0 +100% +0.136 + org.owasp.dependencycheck.utils 21 0 0 0 100% -0.263
    +0.001

    Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.

    +

    org.owasp.dependencycheck.org.apache.tools.ant

    + + + + + + + + + + + + + + + + + + +
    ClassTestsErrors FailuresSkippedSuccess RateTime
    DirectoryScannerTest4000100%0.136
    +

    org.owasp.dependencycheck.utils

    @@ -302,7 +331,7 @@ function toggleDisplay(elementId) { - + @@ -334,16 +363,35 @@ function toggleDisplay(elementId) {

    Test Cases

    [Summary] [Package List] [Test Cases]

    +

    DirectoryScannerTest

    +
    0 0 100%0.263
    0.001
    DownloaderTest
    + + + + + + + + + + + + + + + +
    testMatchPatternStart_String_String0.121
    testMatchPath_String_String0
    testMatchPatternStart_3args0
    testExpectedUse0.015
    +

    ChecksumTest

    - + - + @@ -359,7 +407,7 @@ function toggleDisplay(elementId) { -
    testGetChecksum_NoSuchAlgorithm0.26
    0.001
    testGetChecksum0.002
    0
    testGetMD5Checksum
    testGetSHA1Checksum0.001
    +0

    DownloaderTest

    diff --git a/dependency-check-utils/taglist.html b/dependency-check-utils/taglist.html index 43b7d3686..089f24c55 100644 --- a/dependency-check-utils/taglist.html +++ b/dependency-check-utils/taglist.html @@ -1,13 +1,13 @@ - + dependency-check-ant - Tag List report @@ -54,7 +54,7 @@
  • - + /
  • @@ -67,9 +67,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -233,14 +233,158 @@ - +
    Tag strings used by tag class
    Todo Work147 todo, FIXME

    Each tag is detailed below:

    Todo Work

    -

    Number of occurrences found in the code: 1

    +

    Number of occurrences found in the code: 47

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dependency-check-utils/xref-test/allclasses-frame.html b/dependency-check-utils/xref-test/allclasses-frame.html index b875633aa..e96969609 100644 --- a/dependency-check-utils/xref-test/allclasses-frame.html +++ b/dependency-check-utils/xref-test/allclasses-frame.html @@ -16,6 +16,9 @@
  • ChecksumTest +
  • +
  • + DirectoryScannerTest
  • DownloaderIntegrationTest diff --git a/dependency-check-utils/xref-test/index.html b/dependency-check-utils/xref-test/index.html index 11a59e267..c8f1ba916 100644 --- a/dependency-check-utils/xref-test/index.html +++ b/dependency-check-utils/xref-test/index.html @@ -4,7 +4,7 @@ - Dependency-Check Utils 1.2.5 Reference + Dependency-Check Utils 1.2.6 Reference diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/DirectoryScannerTest.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/DirectoryScannerTest.html new file mode 100644 index 000000000..9edf39652 --- /dev/null +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/DirectoryScannerTest.html @@ -0,0 +1,745 @@ + + + +DirectoryScannerTest xref + + + +
    +1   /*
    +2    * Copyright 2014 OWASP.
    +3    *
    +4    * Licensed under the Apache License, Version 2.0 (the "License");
    +5    * you may not use this file except in compliance with the License.
    +6    * You may obtain a copy of the License at
    +7    *
    +8    *      http://www.apache.org/licenses/LICENSE-2.0
    +9    *
    +10   * Unless required by applicable law or agreed to in writing, software
    +11   * distributed under the License is distributed on an "AS IS" BASIS,
    +12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +13   * See the License for the specific language governing permissions and
    +14   * limitations under the License.
    +15   */
    +16  package org.owasp.dependencycheck.org.apache.tools.ant;
    +17  
    +18  import org.owasp.dependencycheck.org.apache.tools.ant.DirectoryScanner;
    +19  import java.io.File;
    +20  import org.junit.After;
    +21  import org.junit.AfterClass;
    +22  import static org.junit.Assert.assertEquals;
    +23  import static org.junit.Assert.assertTrue;
    +24  import org.junit.Before;
    +25  import org.junit.BeforeClass;
    +26  import org.junit.Test;
    +27  
    +28  /**
    +29   *
    +30   * @author Jeremy Long <jeremy.long@owasp.org>
    +31   */
    +32  public class DirectoryScannerTest {
    +33  
    +34      public DirectoryScannerTest() {
    +35      }
    +36  
    +37      @BeforeClass
    +38      public static void setUpClass() {
    +39      }
    +40  
    +41      @AfterClass
    +42      public static void tearDownClass() {
    +43      }
    +44  
    +45      @Before
    +46      public void setUp() {
    +47      }
    +48  
    +49      @After
    +50      public void tearDown() {
    +51      }
    +52  
    +53      /**
    +54       * Testing the expected use of the directory scanner.
    +55       */
    +56      @Test
    +57      public void testExpectedUse() {
    +58          DirectoryScanner scanner = new DirectoryScanner();
    +59          scanner.setBasedir("./target");
    +60          scanner.setIncludes("/test-classes/**");
    +61          scanner.scan();
    +62  
    +63          File base = new File("./target");
    +64          for (String t : scanner.getIncludedFiles()) {
    +65              assertTrue(t.startsWith("test-classes"));
    +66              File test = new File(base, t);
    +67              assertTrue(test.exists());
    +68          }
    +69      }
    +70  
    +71      /**
    +72       * Test of matchPatternStart method, of class DirectoryScanner.
    +73       */
    +74      @Test
    +75      public void testMatchPatternStart_String_String() {
    +76          String pattern = "alpha/be?a/**";
    +77          String str = "alpha/beta/gamma/";
    +78          boolean expResult = true;
    +79          boolean result = DirectoryScanner.matchPatternStart(pattern, str);
    +80          assertEquals(expResult, result);
    +81      }
    +82  
    +83      /**
    +84       * Test of matchPatternStart method, of class DirectoryScanner.
    +85       */
    +86      @Test
    +87      public void testMatchPatternStart_3args() {
    +88          String pattern = "Alpha/be?a/**";
    +89          String str = "alpha/beta/gamma/";
    +90          boolean isCaseSensitive = true;
    +91          boolean expResult = false;
    +92          boolean result = DirectoryScanner.matchPatternStart(pattern, str, isCaseSensitive);
    +93          assertEquals(expResult, result);
    +94  
    +95          isCaseSensitive = false;
    +96          expResult = true;
    +97          result = DirectoryScanner.matchPatternStart(pattern, str, isCaseSensitive);
    +98          assertEquals(expResult, result);
    +99      }
    +100 
    +101     /**
    +102      * Test of matchPath method, of class DirectoryScanner.
    +103      */
    +104     @Test
    +105     public void testMatchPath_String_String() {
    +106         String pattern = "alpha/be?a/**";
    +107         String str = "alpha/beta/gamma/";
    +108         boolean expResult = true;
    +109         boolean result = DirectoryScanner.matchPath(pattern, str);
    +110         assertEquals(expResult, result);
    +111     }
    +112 //
    +113 //    /**
    +114 //     * Test of matchPath method, of class DirectoryScanner.
    +115 //     */
    +116 //    @Test
    +117 //    public void testMatchPath_3args() {
    +118 //        System.out.println("matchPath");
    +119 //        String pattern = "";
    +120 //        String str = "";
    +121 //        boolean isCaseSensitive = false;
    +122 //        boolean expResult = false;
    +123 //        boolean result = DirectoryScanner.matchPath(pattern, str, isCaseSensitive);
    +124 //        assertEquals(expResult, result);
    +125 //        // TODO review the generated test code and remove the default call to fail.
    +126 //        fail("The test case is a prototype.");
    +127 //    }
    +128 //
    +129 //    /**
    +130 //     * Test of match method, of class DirectoryScanner.
    +131 //     */
    +132 //    @Test
    +133 //    public void testMatch_String_String() {
    +134 //        System.out.println("match");
    +135 //        String pattern = "";
    +136 //        String str = "";
    +137 //        boolean expResult = false;
    +138 //        boolean result = DirectoryScanner.match(pattern, str);
    +139 //        assertEquals(expResult, result);
    +140 //        // TODO review the generated test code and remove the default call to fail.
    +141 //        fail("The test case is a prototype.");
    +142 //    }
    +143 //
    +144 //    /**
    +145 //     * Test of match method, of class DirectoryScanner.
    +146 //     */
    +147 //    @Test
    +148 //    public void testMatch_3args() {
    +149 //        System.out.println("match");
    +150 //        String pattern = "";
    +151 //        String str = "";
    +152 //        boolean isCaseSensitive = false;
    +153 //        boolean expResult = false;
    +154 //        boolean result = DirectoryScanner.match(pattern, str, isCaseSensitive);
    +155 //        assertEquals(expResult, result);
    +156 //        // TODO review the generated test code and remove the default call to fail.
    +157 //        fail("The test case is a prototype.");
    +158 //    }
    +159 //
    +160 //    /**
    +161 //     * Test of getDefaultExcludes method, of class DirectoryScanner.
    +162 //     */
    +163 //    @Test
    +164 //    public void testGetDefaultExcludes() {
    +165 //        System.out.println("getDefaultExcludes");
    +166 //        String[] expResult = null;
    +167 //        String[] result = DirectoryScanner.getDefaultExcludes();
    +168 //        assertArrayEquals(expResult, result);
    +169 //        // TODO review the generated test code and remove the default call to fail.
    +170 //        fail("The test case is a prototype.");
    +171 //    }
    +172 //
    +173 //    /**
    +174 //     * Test of addDefaultExclude method, of class DirectoryScanner.
    +175 //     */
    +176 //    @Test
    +177 //    public void testAddDefaultExclude() {
    +178 //        System.out.println("addDefaultExclude");
    +179 //        String s = "";
    +180 //        boolean expResult = false;
    +181 //        boolean result = DirectoryScanner.addDefaultExclude(s);
    +182 //        assertEquals(expResult, result);
    +183 //        // TODO review the generated test code and remove the default call to fail.
    +184 //        fail("The test case is a prototype.");
    +185 //    }
    +186 //
    +187 //    /**
    +188 //     * Test of removeDefaultExclude method, of class DirectoryScanner.
    +189 //     */
    +190 //    @Test
    +191 //    public void testRemoveDefaultExclude() {
    +192 //        System.out.println("removeDefaultExclude");
    +193 //        String s = "";
    +194 //        boolean expResult = false;
    +195 //        boolean result = DirectoryScanner.removeDefaultExclude(s);
    +196 //        assertEquals(expResult, result);
    +197 //        // TODO review the generated test code and remove the default call to fail.
    +198 //        fail("The test case is a prototype.");
    +199 //    }
    +200 //
    +201 //    /**
    +202 //     * Test of resetDefaultExcludes method, of class DirectoryScanner.
    +203 //     */
    +204 //    @Test
    +205 //    public void testResetDefaultExcludes() {
    +206 //        System.out.println("resetDefaultExcludes");
    +207 //        DirectoryScanner.resetDefaultExcludes();
    +208 //        // TODO review the generated test code and remove the default call to fail.
    +209 //        fail("The test case is a prototype.");
    +210 //    }
    +211 //
    +212 //    /**
    +213 //     * Test of setBasedir method, of class DirectoryScanner.
    +214 //     */
    +215 //    @Test
    +216 //    public void testSetBasedir_String() {
    +217 //        System.out.println("setBasedir");
    +218 //        String basedir = "";
    +219 //        DirectoryScanner instance = new DirectoryScanner();
    +220 //        instance.setBasedir(basedir);
    +221 //        // TODO review the generated test code and remove the default call to fail.
    +222 //        fail("The test case is a prototype.");
    +223 //    }
    +224 //
    +225 //    /**
    +226 //     * Test of setBasedir method, of class DirectoryScanner.
    +227 //     */
    +228 //    @Test
    +229 //    public void testSetBasedir_File() {
    +230 //        System.out.println("setBasedir");
    +231 //        File basedir = null;
    +232 //        DirectoryScanner instance = new DirectoryScanner();
    +233 //        instance.setBasedir(basedir);
    +234 //        // TODO review the generated test code and remove the default call to fail.
    +235 //        fail("The test case is a prototype.");
    +236 //    }
    +237 //
    +238 //    /**
    +239 //     * Test of getBasedir method, of class DirectoryScanner.
    +240 //     */
    +241 //    @Test
    +242 //    public void testGetBasedir() {
    +243 //        System.out.println("getBasedir");
    +244 //        DirectoryScanner instance = new DirectoryScanner();
    +245 //        File expResult = null;
    +246 //        File result = instance.getBasedir();
    +247 //        assertEquals(expResult, result);
    +248 //        // TODO review the generated test code and remove the default call to fail.
    +249 //        fail("The test case is a prototype.");
    +250 //    }
    +251 //
    +252 //    /**
    +253 //     * Test of isCaseSensitive method, of class DirectoryScanner.
    +254 //     */
    +255 //    @Test
    +256 //    public void testIsCaseSensitive() {
    +257 //        System.out.println("isCaseSensitive");
    +258 //        DirectoryScanner instance = new DirectoryScanner();
    +259 //        boolean expResult = false;
    +260 //        boolean result = instance.isCaseSensitive();
    +261 //        assertEquals(expResult, result);
    +262 //        // TODO review the generated test code and remove the default call to fail.
    +263 //        fail("The test case is a prototype.");
    +264 //    }
    +265 //
    +266 //    /**
    +267 //     * Test of setCaseSensitive method, of class DirectoryScanner.
    +268 //     */
    +269 //    @Test
    +270 //    public void testSetCaseSensitive() {
    +271 //        System.out.println("setCaseSensitive");
    +272 //        boolean isCaseSensitive = false;
    +273 //        DirectoryScanner instance = new DirectoryScanner();
    +274 //        instance.setCaseSensitive(isCaseSensitive);
    +275 //        // TODO review the generated test code and remove the default call to fail.
    +276 //        fail("The test case is a prototype.");
    +277 //    }
    +278 //
    +279 //    /**
    +280 //     * Test of setErrorOnMissingDir method, of class DirectoryScanner.
    +281 //     */
    +282 //    @Test
    +283 //    public void testSetErrorOnMissingDir() {
    +284 //        System.out.println("setErrorOnMissingDir");
    +285 //        boolean errorOnMissingDir = false;
    +286 //        DirectoryScanner instance = new DirectoryScanner();
    +287 //        instance.setErrorOnMissingDir(errorOnMissingDir);
    +288 //        // TODO review the generated test code and remove the default call to fail.
    +289 //        fail("The test case is a prototype.");
    +290 //    }
    +291 //
    +292 //    /**
    +293 //     * Test of isFollowSymlinks method, of class DirectoryScanner.
    +294 //     */
    +295 //    @Test
    +296 //    public void testIsFollowSymlinks() {
    +297 //        System.out.println("isFollowSymlinks");
    +298 //        DirectoryScanner instance = new DirectoryScanner();
    +299 //        boolean expResult = false;
    +300 //        boolean result = instance.isFollowSymlinks();
    +301 //        assertEquals(expResult, result);
    +302 //        // TODO review the generated test code and remove the default call to fail.
    +303 //        fail("The test case is a prototype.");
    +304 //    }
    +305 //
    +306 //    /**
    +307 //     * Test of setFollowSymlinks method, of class DirectoryScanner.
    +308 //     */
    +309 //    @Test
    +310 //    public void testSetFollowSymlinks() {
    +311 //        System.out.println("setFollowSymlinks");
    +312 //        boolean followSymlinks = false;
    +313 //        DirectoryScanner instance = new DirectoryScanner();
    +314 //        instance.setFollowSymlinks(followSymlinks);
    +315 //        // TODO review the generated test code and remove the default call to fail.
    +316 //        fail("The test case is a prototype.");
    +317 //    }
    +318 //
    +319 //    /**
    +320 //     * Test of setMaxLevelsOfSymlinks method, of class DirectoryScanner.
    +321 //     */
    +322 //    @Test
    +323 //    public void testSetMaxLevelsOfSymlinks() {
    +324 //        System.out.println("setMaxLevelsOfSymlinks");
    +325 //        int max = 0;
    +326 //        DirectoryScanner instance = new DirectoryScanner();
    +327 //        instance.setMaxLevelsOfSymlinks(max);
    +328 //        // TODO review the generated test code and remove the default call to fail.
    +329 //        fail("The test case is a prototype.");
    +330 //    }
    +331 //
    +332 //    /**
    +333 //     * Test of setIncludes method, of class DirectoryScanner.
    +334 //     */
    +335 //    @Test
    +336 //    public void testSetIncludes() {
    +337 //        System.out.println("setIncludes");
    +338 //        String[] includes = null;
    +339 //        DirectoryScanner instance = new DirectoryScanner();
    +340 //        instance.setIncludes(includes);
    +341 //        // TODO review the generated test code and remove the default call to fail.
    +342 //        fail("The test case is a prototype.");
    +343 //    }
    +344 //
    +345 //    /**
    +346 //     * Test of setExcludes method, of class DirectoryScanner.
    +347 //     */
    +348 //    @Test
    +349 //    public void testSetExcludes() {
    +350 //        System.out.println("setExcludes");
    +351 //        String[] excludes = null;
    +352 //        DirectoryScanner instance = new DirectoryScanner();
    +353 //        instance.setExcludes(excludes);
    +354 //        // TODO review the generated test code and remove the default call to fail.
    +355 //        fail("The test case is a prototype.");
    +356 //    }
    +357 //
    +358 //    /**
    +359 //     * Test of addExcludes method, of class DirectoryScanner.
    +360 //     */
    +361 //    @Test
    +362 //    public void testAddExcludes() {
    +363 //        System.out.println("addExcludes");
    +364 //        String[] excludes = null;
    +365 //        DirectoryScanner instance = new DirectoryScanner();
    +366 //        instance.addExcludes(excludes);
    +367 //        // TODO review the generated test code and remove the default call to fail.
    +368 //        fail("The test case is a prototype.");
    +369 //    }
    +370 //
    +371 //    /**
    +372 //     * Test of setSelectors method, of class DirectoryScanner.
    +373 //     */
    +374 //    @Test
    +375 //    public void testSetSelectors() {
    +376 //        System.out.println("setSelectors");
    +377 //        FileSelector[] selectors = null;
    +378 //        DirectoryScanner instance = new DirectoryScanner();
    +379 //        instance.setSelectors(selectors);
    +380 //        // TODO review the generated test code and remove the default call to fail.
    +381 //        fail("The test case is a prototype.");
    +382 //    }
    +383 //
    +384 //    /**
    +385 //     * Test of isEverythingIncluded method, of class DirectoryScanner.
    +386 //     */
    +387 //    @Test
    +388 //    public void testIsEverythingIncluded() {
    +389 //        System.out.println("isEverythingIncluded");
    +390 //        DirectoryScanner instance = new DirectoryScanner();
    +391 //        boolean expResult = false;
    +392 //        boolean result = instance.isEverythingIncluded();
    +393 //        assertEquals(expResult, result);
    +394 //        // TODO review the generated test code and remove the default call to fail.
    +395 //        fail("The test case is a prototype.");
    +396 //    }
    +397 //
    +398 //    /**
    +399 //     * Test of scan method, of class DirectoryScanner.
    +400 //     */
    +401 //    @Test
    +402 //    public void testScan() {
    +403 //        System.out.println("scan");
    +404 //        DirectoryScanner instance = new DirectoryScanner();
    +405 //        instance.scan();
    +406 //        // TODO review the generated test code and remove the default call to fail.
    +407 //        fail("The test case is a prototype.");
    +408 //    }
    +409 //
    +410 //    /**
    +411 //     * Test of clearResults method, of class DirectoryScanner.
    +412 //     */
    +413 //    @Test
    +414 //    public void testClearResults() {
    +415 //        System.out.println("clearResults");
    +416 //        DirectoryScanner instance = new DirectoryScanner();
    +417 //        instance.clearResults();
    +418 //        // TODO review the generated test code and remove the default call to fail.
    +419 //        fail("The test case is a prototype.");
    +420 //    }
    +421 //
    +422 //    /**
    +423 //     * Test of slowScan method, of class DirectoryScanner.
    +424 //     */
    +425 //    @Test
    +426 //    public void testSlowScan() {
    +427 //        System.out.println("slowScan");
    +428 //        DirectoryScanner instance = new DirectoryScanner();
    +429 //        instance.slowScan();
    +430 //        // TODO review the generated test code and remove the default call to fail.
    +431 //        fail("The test case is a prototype.");
    +432 //    }
    +433 //
    +434 //    /**
    +435 //     * Test of scandir method, of class DirectoryScanner.
    +436 //     */
    +437 //    @Test
    +438 //    public void testScandir() {
    +439 //        System.out.println("scandir");
    +440 //        File dir = null;
    +441 //        String vpath = "";
    +442 //        boolean fast = false;
    +443 //        DirectoryScanner instance = new DirectoryScanner();
    +444 //        instance.scandir(dir, vpath, fast);
    +445 //        // TODO review the generated test code and remove the default call to fail.
    +446 //        fail("The test case is a prototype.");
    +447 //    }
    +448 //
    +449 //    /**
    +450 //     * Test of isIncluded method, of class DirectoryScanner.
    +451 //     */
    +452 //    @Test
    +453 //    public void testIsIncluded() {
    +454 //        System.out.println("isIncluded");
    +455 //        String name = "";
    +456 //        DirectoryScanner instance = new DirectoryScanner();
    +457 //        boolean expResult = false;
    +458 //        boolean result = instance.isIncluded(name);
    +459 //        assertEquals(expResult, result);
    +460 //        // TODO review the generated test code and remove the default call to fail.
    +461 //        fail("The test case is a prototype.");
    +462 //    }
    +463 //
    +464 //    /**
    +465 //     * Test of couldHoldIncluded method, of class DirectoryScanner.
    +466 //     */
    +467 //    @Test
    +468 //    public void testCouldHoldIncluded() {
    +469 //        System.out.println("couldHoldIncluded");
    +470 //        String name = "";
    +471 //        DirectoryScanner instance = new DirectoryScanner();
    +472 //        boolean expResult = false;
    +473 //        boolean result = instance.couldHoldIncluded(name);
    +474 //        assertEquals(expResult, result);
    +475 //        // TODO review the generated test code and remove the default call to fail.
    +476 //        fail("The test case is a prototype.");
    +477 //    }
    +478 //
    +479 //    /**
    +480 //     * Test of contentsExcluded method, of class DirectoryScanner.
    +481 //     */
    +482 //    @Test
    +483 //    public void testContentsExcluded() {
    +484 //        System.out.println("contentsExcluded");
    +485 //        TokenizedPath path = null;
    +486 //        DirectoryScanner instance = new DirectoryScanner();
    +487 //        boolean expResult = false;
    +488 //        boolean result = instance.contentsExcluded(path);
    +489 //        assertEquals(expResult, result);
    +490 //        // TODO review the generated test code and remove the default call to fail.
    +491 //        fail("The test case is a prototype.");
    +492 //    }
    +493 //
    +494 //    /**
    +495 //     * Test of isExcluded method, of class DirectoryScanner.
    +496 //     */
    +497 //    @Test
    +498 //    public void testIsExcluded() {
    +499 //        System.out.println("isExcluded");
    +500 //        String name = "";
    +501 //        DirectoryScanner instance = new DirectoryScanner();
    +502 //        boolean expResult = false;
    +503 //        boolean result = instance.isExcluded(name);
    +504 //        assertEquals(expResult, result);
    +505 //        // TODO review the generated test code and remove the default call to fail.
    +506 //        fail("The test case is a prototype.");
    +507 //    }
    +508 //
    +509 //    /**
    +510 //     * Test of isSelected method, of class DirectoryScanner.
    +511 //     */
    +512 //    @Test
    +513 //    public void testIsSelected() {
    +514 //        System.out.println("isSelected");
    +515 //        String name = "";
    +516 //        File file = null;
    +517 //        DirectoryScanner instance = new DirectoryScanner();
    +518 //        boolean expResult = false;
    +519 //        boolean result = instance.isSelected(name, file);
    +520 //        assertEquals(expResult, result);
    +521 //        // TODO review the generated test code and remove the default call to fail.
    +522 //        fail("The test case is a prototype.");
    +523 //    }
    +524 //
    +525 //    /**
    +526 //     * Test of getIncludedFiles method, of class DirectoryScanner.
    +527 //     */
    +528 //    @Test
    +529 //    public void testGetIncludedFiles() {
    +530 //        System.out.println("getIncludedFiles");
    +531 //        DirectoryScanner instance = new DirectoryScanner();
    +532 //        String[] expResult = null;
    +533 //        String[] result = instance.getIncludedFiles();
    +534 //        assertArrayEquals(expResult, result);
    +535 //        // TODO review the generated test code and remove the default call to fail.
    +536 //        fail("The test case is a prototype.");
    +537 //    }
    +538 //
    +539 //    /**
    +540 //     * Test of getIncludedFilesCount method, of class DirectoryScanner.
    +541 //     */
    +542 //    @Test
    +543 //    public void testGetIncludedFilesCount() {
    +544 //        System.out.println("getIncludedFilesCount");
    +545 //        DirectoryScanner instance = new DirectoryScanner();
    +546 //        int expResult = 0;
    +547 //        int result = instance.getIncludedFilesCount();
    +548 //        assertEquals(expResult, result);
    +549 //        // TODO review the generated test code and remove the default call to fail.
    +550 //        fail("The test case is a prototype.");
    +551 //    }
    +552 //
    +553 //    /**
    +554 //     * Test of getNotIncludedFiles method, of class DirectoryScanner.
    +555 //     */
    +556 //    @Test
    +557 //    public void testGetNotIncludedFiles() {
    +558 //        System.out.println("getNotIncludedFiles");
    +559 //        DirectoryScanner instance = new DirectoryScanner();
    +560 //        String[] expResult = null;
    +561 //        String[] result = instance.getNotIncludedFiles();
    +562 //        assertArrayEquals(expResult, result);
    +563 //        // TODO review the generated test code and remove the default call to fail.
    +564 //        fail("The test case is a prototype.");
    +565 //    }
    +566 //
    +567 //    /**
    +568 //     * Test of getExcludedFiles method, of class DirectoryScanner.
    +569 //     */
    +570 //    @Test
    +571 //    public void testGetExcludedFiles() {
    +572 //        System.out.println("getExcludedFiles");
    +573 //        DirectoryScanner instance = new DirectoryScanner();
    +574 //        String[] expResult = null;
    +575 //        String[] result = instance.getExcludedFiles();
    +576 //        assertArrayEquals(expResult, result);
    +577 //        // TODO review the generated test code and remove the default call to fail.
    +578 //        fail("The test case is a prototype.");
    +579 //    }
    +580 //
    +581 //    /**
    +582 //     * Test of getDeselectedFiles method, of class DirectoryScanner.
    +583 //     */
    +584 //    @Test
    +585 //    public void testGetDeselectedFiles() {
    +586 //        System.out.println("getDeselectedFiles");
    +587 //        DirectoryScanner instance = new DirectoryScanner();
    +588 //        String[] expResult = null;
    +589 //        String[] result = instance.getDeselectedFiles();
    +590 //        assertArrayEquals(expResult, result);
    +591 //        // TODO review the generated test code and remove the default call to fail.
    +592 //        fail("The test case is a prototype.");
    +593 //    }
    +594 //
    +595 //    /**
    +596 //     * Test of getIncludedDirectories method, of class DirectoryScanner.
    +597 //     */
    +598 //    @Test
    +599 //    public void testGetIncludedDirectories() {
    +600 //        System.out.println("getIncludedDirectories");
    +601 //        DirectoryScanner instance = new DirectoryScanner();
    +602 //        String[] expResult = null;
    +603 //        String[] result = instance.getIncludedDirectories();
    +604 //        assertArrayEquals(expResult, result);
    +605 //        // TODO review the generated test code and remove the default call to fail.
    +606 //        fail("The test case is a prototype.");
    +607 //    }
    +608 //
    +609 //    /**
    +610 //     * Test of getIncludedDirsCount method, of class DirectoryScanner.
    +611 //     */
    +612 //    @Test
    +613 //    public void testGetIncludedDirsCount() {
    +614 //        System.out.println("getIncludedDirsCount");
    +615 //        DirectoryScanner instance = new DirectoryScanner();
    +616 //        int expResult = 0;
    +617 //        int result = instance.getIncludedDirsCount();
    +618 //        assertEquals(expResult, result);
    +619 //        // TODO review the generated test code and remove the default call to fail.
    +620 //        fail("The test case is a prototype.");
    +621 //    }
    +622 //
    +623 //    /**
    +624 //     * Test of getNotIncludedDirectories method, of class DirectoryScanner.
    +625 //     */
    +626 //    @Test
    +627 //    public void testGetNotIncludedDirectories() {
    +628 //        System.out.println("getNotIncludedDirectories");
    +629 //        DirectoryScanner instance = new DirectoryScanner();
    +630 //        String[] expResult = null;
    +631 //        String[] result = instance.getNotIncludedDirectories();
    +632 //        assertArrayEquals(expResult, result);
    +633 //        // TODO review the generated test code and remove the default call to fail.
    +634 //        fail("The test case is a prototype.");
    +635 //    }
    +636 //
    +637 //    /**
    +638 //     * Test of getExcludedDirectories method, of class DirectoryScanner.
    +639 //     */
    +640 //    @Test
    +641 //    public void testGetExcludedDirectories() {
    +642 //        System.out.println("getExcludedDirectories");
    +643 //        DirectoryScanner instance = new DirectoryScanner();
    +644 //        String[] expResult = null;
    +645 //        String[] result = instance.getExcludedDirectories();
    +646 //        assertArrayEquals(expResult, result);
    +647 //        // TODO review the generated test code and remove the default call to fail.
    +648 //        fail("The test case is a prototype.");
    +649 //    }
    +650 //
    +651 //    /**
    +652 //     * Test of getDeselectedDirectories method, of class DirectoryScanner.
    +653 //     */
    +654 //    @Test
    +655 //    public void testGetDeselectedDirectories() {
    +656 //        System.out.println("getDeselectedDirectories");
    +657 //        DirectoryScanner instance = new DirectoryScanner();
    +658 //        String[] expResult = null;
    +659 //        String[] result = instance.getDeselectedDirectories();
    +660 //        assertArrayEquals(expResult, result);
    +661 //        // TODO review the generated test code and remove the default call to fail.
    +662 //        fail("The test case is a prototype.");
    +663 //    }
    +664 //
    +665 //    /**
    +666 //     * Test of getNotFollowedSymlinks method, of class DirectoryScanner.
    +667 //     */
    +668 //    @Test
    +669 //    public void testGetNotFollowedSymlinks() {
    +670 //        System.out.println("getNotFollowedSymlinks");
    +671 //        DirectoryScanner instance = new DirectoryScanner();
    +672 //        String[] expResult = null;
    +673 //        String[] result = instance.getNotFollowedSymlinks();
    +674 //        assertArrayEquals(expResult, result);
    +675 //        // TODO review the generated test code and remove the default call to fail.
    +676 //        fail("The test case is a prototype.");
    +677 //    }
    +678 //
    +679 //    /**
    +680 //     * Test of addDefaultExcludes method, of class DirectoryScanner.
    +681 //     */
    +682 //    @Test
    +683 //    public void testAddDefaultExcludes() {
    +684 //        System.out.println("addDefaultExcludes");
    +685 //        DirectoryScanner instance = new DirectoryScanner();
    +686 //        instance.addDefaultExcludes();
    +687 //        // TODO review the generated test code and remove the default call to fail.
    +688 //        fail("The test case is a prototype.");
    +689 //    }
    +690 //
    +691 //    /**
    +692 //     * Test of getResource method, of class DirectoryScanner.
    +693 //     */
    +694 //    @Test
    +695 //    public void testGetResource() {
    +696 //        System.out.println("getResource");
    +697 //        String name = "";
    +698 //        DirectoryScanner instance = new DirectoryScanner();
    +699 //        Resource expResult = null;
    +700 //        Resource result = instance.getResource(name);
    +701 //        assertEquals(expResult, result);
    +702 //        // TODO review the generated test code and remove the default call to fail.
    +703 //        fail("The test case is a prototype.");
    +704 //    }
    +705 //
    +706 //    /**
    +707 //     * Test of getScannedDirs method, of class DirectoryScanner.
    +708 //     */
    +709 //    @Test
    +710 //    public void testGetScannedDirs() {
    +711 //        System.out.println("getScannedDirs");
    +712 //        DirectoryScanner instance = new DirectoryScanner();
    +713 //        Set<String> expResult = null;
    +714 //        Set<String> result = instance.getScannedDirs();
    +715 //        assertEquals(expResult, result);
    +716 //        // TODO review the generated test code and remove the default call to fail.
    +717 //        fail("The test case is a prototype.");
    +718 //    }
    +719 //
    +720 //    /**
    +721 //     * Test of ensureNonPatternSetsReady method, of class DirectoryScanner.
    +722 //     */
    +723 //    @Test
    +724 //    public void testEnsureNonPatternSetsReady() {
    +725 //        System.out.println("ensureNonPatternSetsReady");
    +726 //        DirectoryScanner instance = new DirectoryScanner();
    +727 //        instance.ensureNonPatternSetsReady();
    +728 //        // TODO review the generated test code and remove the default call to fail.
    +729 //        fail("The test case is a prototype.");
    +730 //    }
    +731 
    +732 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/package-frame.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/package-frame.html new file mode 100644 index 000000000..4975d61d9 --- /dev/null +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/package-frame.html @@ -0,0 +1,24 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/package-summary.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/package-summary.html new file mode 100644 index 000000000..4f06fe057 --- /dev/null +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/org/apache/tools/ant/package-summary.html @@ -0,0 +1,69 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant

    + +
  • org.owasp.dependencycheck.org.apache.tools.ant.DirectoryScannerTestLine
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }125
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }140
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }156
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }169
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }183
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }197
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }208
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }221
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }234
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }248
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }262
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }275
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }288
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }302
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }315
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }328
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }341
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }354
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }367
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }380
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }394
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }406
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }418
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }430
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }445
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }460
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }475
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }490
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }505
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }521
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }535
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }549
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }563
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }577
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }591
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }605
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }619
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }633
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }647
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }661
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }675
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }687
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }702
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }716
    review the generated test code and remove the default call to fail. fail("The test case is a prototype."); }728
    org.owasp.dependencycheck.org.apache.tools.ant.launch.LocatorLine
    should use java.net.URI now that we can rely on 1.4... but check for UNC-related regressions, e.g. #42275 (and remember that \\server\share\file -> file:////server/share/file rather than -> file://server/share/file as it should; fixed only in JDK 7's java.nio.file.Path.toUri) return fromUriJava14(uri);184
    org.owasp.dependencycheck.utils.Downloader Line
    + + + + + + + + + + +
    Class Summary
    + DirectoryScannerTest +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/ChecksumTest.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/ChecksumTest.html index 90972288b..261c6d88e 100644 --- a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/ChecksumTest.html +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/ChecksumTest.html @@ -28,134 +28,112 @@ 20 import java.io.File; 21 import java.io.IOException; 22 import java.security.NoSuchAlgorithmException; -23 import org.junit.After; -24 import org.junit.AfterClass; -25 import org.junit.Assert; -26 import org.junit.Before; -27 import org.junit.BeforeClass; -28 import org.junit.Test; +23 +24 import org.junit.Assert; +25 import org.junit.Rule; +26 import org.junit.Test; +27 import org.junit.rules.ExpectedException; +28 import org.owasp.dependencycheck.utils.Checksum; 29 import org.owasp.dependencycheck.utils.Checksum; -30 import org.owasp.dependencycheck.utils.Checksum; -31 -32 /** -33 * -34 * @author Jeremy Long <jeremy.long@owasp.org> -35 */ -36 public class ChecksumTest { -37 -38 @BeforeClass -39 public static void setUpClass() throws Exception { -40 } -41 -42 @AfterClass -43 public static void tearDownClass() throws Exception { -44 } -45 -46 @Before -47 public void setUp() throws Exception { -48 } -49 -50 @After -51 public void tearDown() throws Exception { -52 } -53 -54 /** -55 * Test of getChecksum method, of class Checksum. -56 * -57 * @throws Exception thrown when an exception occurs. -58 */ -59 @Test -60 public void testGetChecksum() throws Exception { -61 String algorithm = "MD5"; -62 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); -63 byte[] expResult = {-16, -111, 92, 95, 70, -72, -49, -94, -125, -27, -83, 103, -96, -101, 55, -109}; -64 byte[] result = Checksum.getChecksum(algorithm, file); -65 boolean arraysAreEqual = true; -66 if (expResult.length == result.length) { -67 for (int i = 0; arraysAreEqual && i < result.length; i++) { -68 arraysAreEqual = result[i] == expResult[i]; -69 } -70 } else { -71 Assert.fail("Checksum results do not match expected results."); -72 } -73 Assert.assertTrue(arraysAreEqual); -74 } -75 -76 /** -77 * Test of getChecksum method, of class Checksum. This checks that an exception is thrown when an invalid path is -78 * specified. -79 * -80 * @throws Exception is thrown when an exception occurs. -81 */ -82 @Test -83 public void testGetChecksum_FileNotFound() throws Exception { -84 String algorithm = "MD5"; -85 File file = new File("not a valid file"); -86 boolean exceptionThrown = false; -87 try { -88 byte[] result = Checksum.getChecksum(algorithm, file); -89 } catch (IOException ex) { -90 exceptionThrown = true; -91 } -92 Assert.assertTrue(exceptionThrown); -93 } -94 -95 /** -96 * Test of getChecksum method, of class Checksum. This checks that an exception is thrown when an invalid algorithm -97 * is specified. -98 * -99 * @throws Exception is thrown when an exception occurs. -100 */ -101 @Test -102 public void testGetChecksum_NoSuchAlgorithm() throws Exception { -103 String algorithm = "some unknown algorithm"; -104 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); -105 boolean exceptionThrown = false; -106 try { -107 byte[] result = Checksum.getChecksum(algorithm, file); -108 } catch (NoSuchAlgorithmException ex) { -109 exceptionThrown = true; -110 } -111 Assert.assertTrue(exceptionThrown); -112 } -113 -114 /** -115 * Test of getMD5Checksum method, of class Checksum. -116 * -117 * @throws Exception is thrown when an exception occurs. -118 */ -119 @Test -120 public void testGetMD5Checksum() throws Exception { -121 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); -122 String expResult = "F0915C5F46B8CFA283E5AD67A09B3793"; -123 String result = Checksum.getMD5Checksum(file); -124 Assert.assertEquals(expResult, result); -125 } -126 -127 /** -128 * Test of getSHA1Checksum method, of class Checksum. -129 * -130 * @throws Exception is thrown when an exception occurs. -131 */ -132 @Test -133 public void testGetSHA1Checksum() throws Exception { -134 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); -135 String expResult = "B8A9FF28B21BCB1D0B50E24A5243D8B51766851A"; -136 String result = Checksum.getSHA1Checksum(file); -137 Assert.assertEquals(expResult, result); -138 } -139 -140 /** -141 * Test of getHex method, of class Checksum. -142 */ -143 @Test -144 public void testGetHex() { -145 byte[] raw = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; -146 String expResult = "000102030405060708090A0B0C0D0E0F10"; -147 String result = Checksum.getHex(raw); -148 Assert.assertEquals(expResult, result); -149 } -150 } +30 +31 /** +32 * +33 * @author Jeremy Long <jeremy.long@owasp.org> +34 */ +35 public class ChecksumTest { +36 +37 @Rule +38 public ExpectedException expectedException = ExpectedException.none(); +39 +40 /** +41 * Test of getChecksum method, of class Checksum. +42 * +43 * @throws Exception thrown when an exception occurs. +44 */ +45 @Test +46 public void testGetChecksum() throws Exception { +47 String algorithm = "MD5"; +48 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); +49 byte[] expResult = {-16, -111, 92, 95, 70, -72, -49, -94, -125, -27, -83, 103, -96, -101, 55, -109}; +50 byte[] result = Checksum.getChecksum(algorithm, file); +51 boolean arraysAreEqual = true; +52 if (expResult.length == result.length) { +53 for (int i = 0; arraysAreEqual && i < result.length; i++) { +54 arraysAreEqual = result[i] == expResult[i]; +55 } +56 } else { +57 Assert.fail("Checksum results do not match expected results."); +58 } +59 Assert.assertTrue(arraysAreEqual); +60 } +61 +62 /** +63 * Test of getChecksum method, of class Checksum. This checks that an exception is thrown when an invalid path is +64 * specified. +65 * +66 * @throws Exception is thrown when an exception occurs. +67 */ +68 @Test +69 public void testGetChecksum_FileNotFound() throws Exception { +70 String algorithm = "MD5"; +71 File file = new File("not a valid file"); +72 +73 expectedException.expect(IOException.class); +74 Checksum.getChecksum(algorithm, file); +75 } +76 +77 /** +78 * Test of getChecksum method, of class Checksum. This checks that an exception is thrown when an invalid algorithm +79 * is specified. +80 * +81 * @throws Exception is thrown when an exception occurs. +82 */ +83 @Test +84 public void testGetChecksum_NoSuchAlgorithm() throws Exception { +85 String algorithm = "some unknown algorithm"; +86 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); +87 +88 expectedException.expect(NoSuchAlgorithmException.class); +89 Checksum.getChecksum(algorithm, file); +90 } +91 +92 /** +93 * Test of getMD5Checksum method, of class Checksum. +94 * +95 * @throws Exception is thrown when an exception occurs. +96 */ +97 @Test +98 public void testGetMD5Checksum() throws Exception { +99 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); +100 String expResult = "F0915C5F46B8CFA283E5AD67A09B3793"; +101 String result = Checksum.getMD5Checksum(file); +102 Assert.assertEquals(expResult, result); +103 } +104 +105 /** +106 * Test of getSHA1Checksum method, of class Checksum. +107 * +108 * @throws Exception is thrown when an exception occurs. +109 */ +110 @Test +111 public void testGetSHA1Checksum() throws Exception { +112 File file = new File(this.getClass().getClassLoader().getResource("checkSumTest.file").getPath()); +113 String expResult = "B8A9FF28B21BCB1D0B50E24A5243D8B51766851A"; +114 String result = Checksum.getSHA1Checksum(file); +115 Assert.assertEquals(expResult, result); +116 } +117 +118 /** +119 * Test of getHex method, of class Checksum. +120 */ +121 @Test +122 public void testGetHex() { +123 byte[] raw = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; +124 String expResult = "000102030405060708090A0B0C0D0E0F10"; +125 String result = Checksum.getHex(raw); +126 Assert.assertEquals(expResult, result); +127 } +128 }
    diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/DownloaderIntegrationTest.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/DownloaderIntegrationTest.html index acb7cedd5..6624139e5 100644 --- a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/DownloaderIntegrationTest.html +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/DownloaderIntegrationTest.html @@ -50,12 +50,12 @@ 42 URL url = new URL(Settings.getString(Settings.KEYS.CVE_MODIFIED_20_URL)); 43 File outputPath = new File("target/downloaded_cve.xml"); 44 Downloader.fetchFile(url, outputPath); -45 +45 assertTrue(outputPath.isFile()); 46 } 47 48 @Test 49 public void testGetLastModified() throws Exception { -50 URL url = new URL("http://nvd.nist.gov/download/nvdcve-2012.xml"); +50 URL url = new URL(Settings.getString(Settings.KEYS.CVE_MODIFIED_20_URL)); 51 long timestamp = Downloader.getLastModified(url); 52 assertTrue("timestamp equal to zero?", timestamp > 0); 53 } diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-frame.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-frame.html index 7dac3172e..e5e77d11e 100644 --- a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-frame.html +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-summary.html b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-summary.html index bda36d226..728bdf2a0 100644 --- a/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-summary.html +++ b/dependency-check-utils/xref-test/org/owasp/dependencycheck/utils/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-utils/xref-test/overview-frame.html b/dependency-check-utils/xref-test/overview-frame.html index 879cf6ab8..974df1df8 100644 --- a/dependency-check-utils/xref-test/overview-frame.html +++ b/dependency-check-utils/xref-test/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference + Dependency-Check Utils 1.2.6 Reference @@ -16,6 +16,9 @@ diff --git a/dependency-check-utils/xref-test/overview-summary.html b/dependency-check-utils/xref-test/overview-summary.html index 2cb4f6f35..d120d5c55 100644 --- a/dependency-check-utils/xref-test/overview-summary.html +++ b/dependency-check-utils/xref-test/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference + Dependency-Check Utils 1.2.6 Reference @@ -24,7 +24,7 @@
    -

    Dependency-Check Utils 1.2.5 Reference

    +

    Dependency-Check Utils 1.2.6 Reference

    @@ -34,6 +34,11 @@ + + + diff --git a/dependency-check-utils/xref/allclasses-frame.html b/dependency-check-utils/xref/allclasses-frame.html index 72142d0a8..8635442a4 100644 --- a/dependency-check-utils/xref/allclasses-frame.html +++ b/dependency-check-utils/xref/allclasses-frame.html @@ -12,40 +12,124 @@ diff --git a/dependency-check-utils/xref/index.html b/dependency-check-utils/xref/index.html index 11a59e267..c8f1ba916 100644 --- a/dependency-check-utils/xref/index.html +++ b/dependency-check-utils/xref/index.html @@ -4,7 +4,7 @@ - Dependency-Check Utils 1.2.5 Reference + Dependency-Check Utils 1.2.6 Reference diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/BuildException.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/BuildException.html new file mode 100644 index 000000000..d943026ea --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/BuildException.html @@ -0,0 +1,166 @@ + + + +BuildException xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant;
    +19  
    +20  /**
    +21   * Signals an error condition during a build
    +22   */
    +23  public class BuildException extends RuntimeException {
    +24  
    +25      private static final long serialVersionUID = -5419014565354664240L;
    +26  
    +27      /** Location in the build file where the exception occurred */
    +28      private Location location = Location.UNKNOWN_LOCATION;
    +29  
    +30      /**
    +31       * Constructs a build exception with no descriptive information.
    +32       */
    +33      public BuildException() {
    +34          super();
    +35      }
    +36  
    +37      /**
    +38       * Constructs an exception with the given descriptive message.
    +39       *
    +40       * @param message A description of or information about the exception.
    +41       *            Should not be <code>null</code>.
    +42       */
    +43      public BuildException(String message) {
    +44          super(message);
    +45      }
    +46  
    +47      /**
    +48       * Constructs an exception with the given message and exception as
    +49       * a root cause.
    +50       *
    +51       * @param message A description of or information about the exception.
    +52       *            Should not be <code>null</code> unless a cause is specified.
    +53       * @param cause The exception that might have caused this one.
    +54       *              May be <code>null</code>.
    +55       */
    +56      public BuildException(String message, Throwable cause) {
    +57          super(message, cause);
    +58      }
    +59  
    +60      /**
    +61       * Constructs an exception with the given message and exception as
    +62       * a root cause and a location in a file.
    +63       *
    +64       * @param msg A description of or information about the exception.
    +65       *            Should not be <code>null</code> unless a cause is specified.
    +66       * @param cause The exception that might have caused this one.
    +67       *              May be <code>null</code>.
    +68       * @param location The location in the project file where the error
    +69       *                 occurred. Must not be <code>null</code>.
    +70       */
    +71      public BuildException(String msg, Throwable cause, Location location) {
    +72          this(msg, cause);
    +73          this.location = location;
    +74      }
    +75  
    +76      /**
    +77       * Constructs an exception with the given exception as a root cause.
    +78       *
    +79       * @param cause The exception that might have caused this one.
    +80       *              Should not be <code>null</code>.
    +81       */
    +82      public BuildException(Throwable cause) {
    +83          super(cause);
    +84      }
    +85  
    +86      /**
    +87       * Constructs an exception with the given descriptive message and a
    +88       * location in a file.
    +89       *
    +90       * @param message A description of or information about the exception.
    +91       *            Should not be <code>null</code>.
    +92       * @param location The location in the project file where the error
    +93       *                 occurred. Must not be <code>null</code>.
    +94       */
    +95      public BuildException(String message, Location location) {
    +96          super(message);
    +97          this.location = location;
    +98      }
    +99  
    +100     /**
    +101      * Constructs an exception with the given exception as
    +102      * a root cause and a location in a file.
    +103      *
    +104      * @param cause The exception that might have caused this one.
    +105      *              Should not be <code>null</code>.
    +106      * @param location The location in the project file where the error
    +107      *                 occurred. Must not be <code>null</code>.
    +108      */
    +109     public BuildException(Throwable cause, Location location) {
    +110         this(cause);
    +111         this.location = location;
    +112     }
    +113 
    +114     /**
    +115      * Returns the nested exception, if any.
    +116      *
    +117      * @return the nested exception, or <code>null</code> if no
    +118      *         exception is associated with this one
    +119      * @deprecated Use {@link #getCause} instead.
    +120      */
    +121     public Throwable getException() {
    +122         return getCause();
    +123     }
    +124 
    +125     /**
    +126      * Returns the location of the error and the error message.
    +127      *
    +128      * @return the location of the error and the error message
    +129      */
    +130     public String toString() {
    +131         return location.toString() + getMessage();
    +132     }
    +133 
    +134     /**
    +135      * Sets the file location where the error occurred.
    +136      *
    +137      * @param location The file location where the error occurred.
    +138      *                 Must not be <code>null</code>.
    +139      */
    +140     public void setLocation(Location location) {
    +141         this.location = location;
    +142     }
    +143 
    +144     /**
    +145      * Returns the file location where the error occurred.
    +146      *
    +147      * @return the file location where the error occurred.
    +148      */
    +149     public Location getLocation() {
    +150         return location;
    +151     }
    +152 
    +153 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/DirectoryScanner.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/DirectoryScanner.html new file mode 100644 index 000000000..51ea92740 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/DirectoryScanner.html @@ -0,0 +1,1829 @@ + + + +DirectoryScanner xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant;
    +19  
    +20  import java.io.File;
    +21  import java.io.IOException;
    +22  import java.util.ArrayList;
    +23  import java.util.Arrays;
    +24  import java.util.HashMap;
    +25  import java.util.HashSet;
    +26  import java.util.Iterator;
    +27  import java.util.LinkedList;
    +28  import java.util.Map;
    +29  import java.util.Set;
    +30  import java.util.Vector;
    +31  import org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition.Os;
    +32  import org.owasp.dependencycheck.org.apache.tools.ant.types.Resource;
    +33  import org.owasp.dependencycheck.org.apache.tools.ant.types.ResourceFactory;
    +34  import org.owasp.dependencycheck.org.apache.tools.ant.types.resources.FileResource;
    +35  import org.owasp.dependencycheck.org.apache.tools.ant.types.selectors.FileSelector;
    +36  import org.owasp.dependencycheck.org.apache.tools.ant.types.selectors.SelectorScanner;
    +37  import org.owasp.dependencycheck.org.apache.tools.ant.types.selectors.SelectorUtils;
    +38  import org.owasp.dependencycheck.org.apache.tools.ant.types.selectors.TokenizedPath;
    +39  import org.owasp.dependencycheck.org.apache.tools.ant.types.selectors.TokenizedPattern;
    +40  import org.owasp.dependencycheck.org.apache.tools.ant.util.CollectionUtils;
    +41  import org.owasp.dependencycheck.org.apache.tools.ant.util.FileUtils;
    +42  import org.owasp.dependencycheck.org.apache.tools.ant.util.SymbolicLinkUtils;
    +43  import org.owasp.dependencycheck.org.apache.tools.ant.util.VectorSet;
    +44  
    +45  /**
    +46   * Class for scanning a directory for files/directories which match certain criteria.
    +47   * <p>
    +48   * These criteria consist of selectors and patterns which have been specified. With the selectors you can select which
    +49   * files you want to have included. Files which are not selected are excluded. With patterns you can include or exclude
    +50   * files based on their filename.
    +51   * <p>
    +52   * The idea is simple. A given directory is recursively scanned for all files and directories. Each file/directory is
    +53   * matched against a set of selectors, including special support for matching against filenames with include and and
    +54   * exclude patterns. Only files/directories which match at least one pattern of the include pattern list or other file
    +55   * selector, and don't match any pattern of the exclude pattern list or fail to match against a required selector will
    +56   * be placed in the list of files/directories found.
    +57   * <p>
    +58   * When no list of include patterns is supplied, "**" will be used, which means that everything will be matched. When no
    +59   * list of exclude patterns is supplied, an empty list is used, such that nothing will be excluded. When no selectors
    +60   * are supplied, none are applied.
    +61   * <p>
    +62   * The filename pattern matching is done as follows: The name to be matched is split up in path segments. A path segment
    +63   * is the name of a directory or file, which is bounded by <code>File.separator</code> ('/' under UNIX, '\' under
    +64   * Windows). For example, "abc/def/ghi/xyz.java" is split up in the segments "abc", "def","ghi" and "xyz.java". The same
    +65   * is done for the pattern against which should be matched.
    +66   * <p>
    +67   * The segments of the name and the pattern are then matched against each other. When '**' is used for a path segment in
    +68   * the pattern, it matches zero or more path segments of the name.
    +69   * <p>
    +70   * There is a special case regarding the use of <code>File.separator</code>s at the beginning of the pattern and the
    +71   * string to match:<br>
    +72   * When a pattern starts with a <code>File.separator</code>, the string to match must also start with a
    +73   * <code>File.separator</code>. When a pattern does not start with a <code>File.separator</code>, the string to match
    +74   * may not start with a <code>File.separator</code>. When one of these rules is not obeyed, the string will not match.
    +75   * <p>
    +76   * When a name path segment is matched against a pattern path segment, the following special characters can be used:<br>
    +77   * '*' matches zero or more characters<br>
    +78   * '?' matches one character.
    +79   * <p>
    +80   * Examples:
    +81   * <p>
    +82   * "**\*.class" matches all .class files/dirs in a directory tree.
    +83   * <p>
    +84   * "test\a??.java" matches all files/dirs which start with an 'a', then two more characters and then ".java", in a
    +85   * directory called test.
    +86   * <p>
    +87   * "**" matches everything in a directory tree.
    +88   * <p>
    +89   * "**\test\**\XYZ*" matches all files/dirs which start with "XYZ" and where there is a parent directory called test
    +90   * (e.g. "abc\test\def\ghi\XYZ123").
    +91   * <p>
    +92   * Case sensitivity may be turned off if necessary. By default, it is turned on.
    +93   * <p>
    +94   * Example of usage:
    +95   * <pre>
    +96   *   String[] includes = {"**\\*.class"};
    +97   *   String[] excludes = {"modules\\*\\**"};
    +98   *   ds.setIncludes(includes);
    +99   *   ds.setExcludes(excludes);
    +100  *   ds.setBasedir(new File("test"));
    +101  *   ds.setCaseSensitive(true);
    +102  *   ds.scan();
    +103  *
    +104  *   System.out.println("FILES:");
    +105  *   String[] files = ds.getIncludedFiles();
    +106  *   for (int i = 0; i &lt; files.length; i++) {
    +107  *     System.out.println(files[i]);
    +108  *   }
    +109  * </pre> This will scan a directory called test for .class files, but excludes all files in all proper subdirectories
    +110  * of a directory called "modules".
    +111  *
    +112  */
    +113 public class DirectoryScanner
    +114         implements FileScanner, SelectorScanner, ResourceFactory {
    +115 
    +116     /**
    +117      * Is OpenVMS the operating system we're running on?
    +118      */
    +119     private static final boolean ON_VMS = Os.isFamily("openvms");
    +120 
    +121     /**
    +122      * Patterns which should be excluded by default.
    +123      *
    +124      * <p>
    +125      * Note that you can now add patterns to the list of default excludes. Added patterns will not become part of this
    +126      * array that has only been kept around for backwards compatibility reasons.</p>
    +127      *
    +128      * @deprecated since 1.6.x. Use the {@link #getDefaultExcludes getDefaultExcludes} method instead.
    +129      */
    +130     protected static final String[] DEFAULTEXCLUDES = {
    +131         // Miscellaneous typical temporary files
    +132         SelectorUtils.DEEP_TREE_MATCH + "/*~",
    +133         SelectorUtils.DEEP_TREE_MATCH + "/#*#",
    +134         SelectorUtils.DEEP_TREE_MATCH + "/.#*",
    +135         SelectorUtils.DEEP_TREE_MATCH + "/%*%",
    +136         SelectorUtils.DEEP_TREE_MATCH + "/._*",
    +137         // CVS
    +138         SelectorUtils.DEEP_TREE_MATCH + "/CVS",
    +139         SelectorUtils.DEEP_TREE_MATCH + "/CVS/" + SelectorUtils.DEEP_TREE_MATCH,
    +140         SelectorUtils.DEEP_TREE_MATCH + "/.cvsignore",
    +141         // SCCS
    +142         SelectorUtils.DEEP_TREE_MATCH + "/SCCS",
    +143         SelectorUtils.DEEP_TREE_MATCH + "/SCCS/" + SelectorUtils.DEEP_TREE_MATCH,
    +144         // Visual SourceSafe
    +145         SelectorUtils.DEEP_TREE_MATCH + "/vssver.scc",
    +146         // Subversion
    +147         SelectorUtils.DEEP_TREE_MATCH + "/.svn",
    +148         SelectorUtils.DEEP_TREE_MATCH + "/.svn/" + SelectorUtils.DEEP_TREE_MATCH,
    +149         // Git
    +150         SelectorUtils.DEEP_TREE_MATCH + "/.git",
    +151         SelectorUtils.DEEP_TREE_MATCH + "/.git/" + SelectorUtils.DEEP_TREE_MATCH,
    +152         SelectorUtils.DEEP_TREE_MATCH + "/.gitattributes",
    +153         SelectorUtils.DEEP_TREE_MATCH + "/.gitignore",
    +154         SelectorUtils.DEEP_TREE_MATCH + "/.gitmodules",
    +155         // Mercurial
    +156         SelectorUtils.DEEP_TREE_MATCH + "/.hg",
    +157         SelectorUtils.DEEP_TREE_MATCH + "/.hg/" + SelectorUtils.DEEP_TREE_MATCH,
    +158         SelectorUtils.DEEP_TREE_MATCH + "/.hgignore",
    +159         SelectorUtils.DEEP_TREE_MATCH + "/.hgsub",
    +160         SelectorUtils.DEEP_TREE_MATCH + "/.hgsubstate",
    +161         SelectorUtils.DEEP_TREE_MATCH + "/.hgtags",
    +162         // Bazaar
    +163         SelectorUtils.DEEP_TREE_MATCH + "/.bzr",
    +164         SelectorUtils.DEEP_TREE_MATCH + "/.bzr/" + SelectorUtils.DEEP_TREE_MATCH,
    +165         SelectorUtils.DEEP_TREE_MATCH + "/.bzrignore",
    +166         // Mac
    +167         SelectorUtils.DEEP_TREE_MATCH + "/.DS_Store"
    +168     };
    +169 
    +170     /**
    +171      * default value for {@link #maxLevelsOfSymlinks maxLevelsOfSymlinks}
    +172      *
    +173      * @since Ant 1.8.0
    +174      */
    +175     public static final int MAX_LEVELS_OF_SYMLINKS = 5;
    +176     /**
    +177      * The end of the exception message if something that should be there doesn't exist.
    +178      */
    +179     public static final String DOES_NOT_EXIST_POSTFIX = " does not exist.";
    +180 
    +181     /**
    +182      * Helper.
    +183      */
    +184     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
    +185 
    +186     /**
    +187      * Helper.
    +188      */
    +189     private static final SymbolicLinkUtils SYMLINK_UTILS
    +190             = SymbolicLinkUtils.getSymbolicLinkUtils();
    +191 
    +192     /**
    +193      * Patterns which should be excluded by default.
    +194      *
    +195      * @see #addDefaultExcludes()
    +196      */
    +197     private static final Set<String> defaultExcludes = new HashSet<String>();
    +198 
    +199     static {
    +200         resetDefaultExcludes();
    +201     }
    +202 
    +203     // CheckStyle:VisibilityModifier OFF - bc
    +204     /**
    +205      * The base directory to be scanned.
    +206      */
    +207     protected File basedir;
    +208 
    +209     /**
    +210      * The patterns for the files to be included.
    +211      */
    +212     protected String[] includes;
    +213 
    +214     /**
    +215      * The patterns for the files to be excluded.
    +216      */
    +217     protected String[] excludes;
    +218 
    +219     /**
    +220      * Selectors that will filter which files are in our candidate list.
    +221      */
    +222     protected FileSelector[] selectors = null;
    +223 
    +224     /**
    +225      * The files which matched at least one include and no excludes and were selected.
    +226      */
    +227     protected Vector<String> filesIncluded;
    +228 
    +229     /**
    +230      * The files which did not match any includes or selectors.
    +231      */
    +232     protected Vector<String> filesNotIncluded;
    +233 
    +234     /**
    +235      * The files which matched at least one include and at least one exclude.
    +236      */
    +237     protected Vector<String> filesExcluded;
    +238 
    +239     /**
    +240      * The directories which matched at least one include and no excludes and were selected.
    +241      */
    +242     protected Vector<String> dirsIncluded;
    +243 
    +244     /**
    +245      * The directories which were found and did not match any includes.
    +246      */
    +247     protected Vector<String> dirsNotIncluded;
    +248 
    +249     /**
    +250      * The directories which matched at least one include and at least one exclude.
    +251      */
    +252     protected Vector<String> dirsExcluded;
    +253 
    +254     /**
    +255      * The files which matched at least one include and no excludes and which a selector discarded.
    +256      */
    +257     protected Vector<String> filesDeselected;
    +258 
    +259     /**
    +260      * The directories which matched at least one include and no excludes but which a selector discarded.
    +261      */
    +262     protected Vector<String> dirsDeselected;
    +263 
    +264     /**
    +265      * Whether or not our results were built by a slow scan.
    +266      */
    +267     protected boolean haveSlowResults = false;
    +268 
    +269     /**
    +270      * Whether or not the file system should be treated as a case sensitive one.
    +271      */
    +272     protected boolean isCaseSensitive = true;
    +273 
    +274     /**
    +275      * Whether a missing base directory is an error.
    +276      *
    +277      * @since Ant 1.7.1
    +278      */
    +279     protected boolean errorOnMissingDir = true;
    +280 
    +281     /**
    +282      * Whether or not symbolic links should be followed.
    +283      *
    +284      * @since Ant 1.5
    +285      */
    +286     private boolean followSymlinks = true;
    +287 
    +288     /**
    +289      * Whether or not everything tested so far has been included.
    +290      */
    +291     protected boolean everythingIncluded = true;
    +292 
    +293     // CheckStyle:VisibilityModifier ON
    +294     /**
    +295      * List of all scanned directories.
    +296      *
    +297      * @since Ant 1.6
    +298      */
    +299     private Set<String> scannedDirs = new HashSet<String>();
    +300 
    +301     /**
    +302      * Map of all include patterns that are full file names and don't contain any wildcards.
    +303      *
    +304      * <p>
    +305      * Maps pattern string to TokenizedPath.</p>
    +306      *
    +307      * <p>
    +308      * If this instance is not case sensitive, the file names get turned to upper case.</p>
    +309      *
    +310      * <p>
    +311      * Gets lazily initialized on the first invocation of isIncluded or isExcluded and cleared at the end of the scan
    +312      * method (cleared in clearCaches, actually).</p>
    +313      *
    +314      * @since Ant 1.8.0
    +315      */
    +316     private Map<String, TokenizedPath> includeNonPatterns = new HashMap<String, TokenizedPath>();
    +317 
    +318     /**
    +319      * Map of all exclude patterns that are full file names and don't contain any wildcards.
    +320      *
    +321      * <p>
    +322      * Maps pattern string to TokenizedPath.</p>
    +323      *
    +324      * <p>
    +325      * If this instance is not case sensitive, the file names get turned to upper case.</p>
    +326      *
    +327      * <p>
    +328      * Gets lazily initialized on the first invocation of isIncluded or isExcluded and cleared at the end of the scan
    +329      * method (cleared in clearCaches, actually).</p>
    +330      *
    +331      * @since Ant 1.8.0
    +332      */
    +333     private Map<String, TokenizedPath> excludeNonPatterns = new HashMap<String, TokenizedPath>();
    +334 
    +335     /**
    +336      * Array of all include patterns that contain wildcards.
    +337      *
    +338      * <p>
    +339      * Gets lazily initialized on the first invocation of isIncluded or isExcluded and cleared at the end of the scan
    +340      * method (cleared in clearCaches, actually).</p>
    +341      */
    +342     private TokenizedPattern[] includePatterns;
    +343 
    +344     /**
    +345      * Array of all exclude patterns that contain wildcards.
    +346      *
    +347      * <p>
    +348      * Gets lazily initialized on the first invocation of isIncluded or isExcluded and cleared at the end of the scan
    +349      * method (cleared in clearCaches, actually).</p>
    +350      */
    +351     private TokenizedPattern[] excludePatterns;
    +352 
    +353     /**
    +354      * Have the non-pattern sets and pattern arrays for in- and excludes been initialized?
    +355      *
    +356      * @since Ant 1.6.3
    +357      */
    +358     private boolean areNonPatternSetsReady = false;
    +359 
    +360     /**
    +361      * Scanning flag.
    +362      *
    +363      * @since Ant 1.6.3
    +364      */
    +365     private boolean scanning = false;
    +366 
    +367     /**
    +368      * Scanning lock.
    +369      *
    +370      * @since Ant 1.6.3
    +371      */
    +372     private Object scanLock = new Object();
    +373 
    +374     /**
    +375      * Slow scanning flag.
    +376      *
    +377      * @since Ant 1.6.3
    +378      */
    +379     private boolean slowScanning = false;
    +380 
    +381     /**
    +382      * Slow scanning lock.
    +383      *
    +384      * @since Ant 1.6.3
    +385      */
    +386     private Object slowScanLock = new Object();
    +387 
    +388     /**
    +389      * Exception thrown during scan.
    +390      *
    +391      * @since Ant 1.6.3
    +392      */
    +393     private IllegalStateException illegal = null;
    +394 
    +395     /**
    +396      * The maximum number of times a symbolic link may be followed during a scan.
    +397      *
    +398      * @since Ant 1.8.0
    +399      */
    +400     private int maxLevelsOfSymlinks = MAX_LEVELS_OF_SYMLINKS;
    +401 
    +402     /**
    +403      * Absolute paths of all symlinks that haven't been followed but would have been if followsymlinks had been true or
    +404      * maxLevelsOfSymlinks had been higher.
    +405      *
    +406      * @since Ant 1.8.0
    +407      */
    +408     private Set<String> notFollowedSymlinks = new HashSet<String>();
    +409 
    +410     /**
    +411      * Sole constructor.
    +412      */
    +413     public DirectoryScanner() {
    +414     }
    +415 
    +416     /**
    +417      * Test whether or not a given path matches the start of a given pattern up to the first "**".
    +418      * <p>
    +419      * This is not a general purpose test and should only be used if you can live with false positives. For example,
    +420      * <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.
    +421      *
    +422      * @param pattern The pattern to match against. Must not be <code>null</code>.
    +423      * @param str The path to match, as a String. Must not be <code>null</code>.
    +424      *
    +425      * @return whether or not a given path matches the start of a given pattern up to the first "**".
    +426      */
    +427     protected static boolean matchPatternStart(String pattern, String str) {
    +428         return SelectorUtils.matchPatternStart(pattern, str);
    +429     }
    +430 
    +431     /**
    +432      * Test whether or not a given path matches the start of a given pattern up to the first "**".
    +433      * <p>
    +434      * This is not a general purpose test and should only be used if you can live with false positives. For example,
    +435      * <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.
    +436      *
    +437      * @param pattern The pattern to match against. Must not be <code>null</code>.
    +438      * @param str The path to match, as a String. Must not be <code>null</code>.
    +439      * @param isCaseSensitive Whether or not matching should be performed case sensitively.
    +440      *
    +441      * @return whether or not a given path matches the start of a given pattern up to the first "**".
    +442      */
    +443     protected static boolean matchPatternStart(String pattern, String str,
    +444             boolean isCaseSensitive) {
    +445         return SelectorUtils.matchPatternStart(pattern, str, isCaseSensitive);
    +446     }
    +447 
    +448     /**
    +449      * Test whether or not a given path matches a given pattern.
    +450      *
    +451      * @param pattern The pattern to match against. Must not be <code>null</code>.
    +452      * @param str The path to match, as a String. Must not be <code>null</code>.
    +453      *
    +454      * @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise.
    +455      */
    +456     protected static boolean matchPath(String pattern, String str) {
    +457         return SelectorUtils.matchPath(pattern, str);
    +458     }
    +459 
    +460     /**
    +461      * Test whether or not a given path matches a given pattern.
    +462      *
    +463      * @param pattern The pattern to match against. Must not be <code>null</code>.
    +464      * @param str The path to match, as a String. Must not be <code>null</code>.
    +465      * @param isCaseSensitive Whether or not matching should be performed case sensitively.
    +466      *
    +467      * @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise.
    +468      */
    +469     protected static boolean matchPath(String pattern, String str,
    +470             boolean isCaseSensitive) {
    +471         return SelectorUtils.matchPath(pattern, str, isCaseSensitive);
    +472     }
    +473 
    +474     /**
    +475      * Test whether or not a string matches against a pattern. The pattern may contain two special characters:<br>
    +476      * '*' means zero or more characters<br>
    +477      * '?' means one and only one character
    +478      *
    +479      * @param pattern The pattern to match against. Must not be <code>null</code>.
    +480      * @param str The string which must be matched against the pattern. Must not be <code>null</code>.
    +481      *
    +482      * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
    +483      */
    +484     public static boolean match(String pattern, String str) {
    +485         return SelectorUtils.match(pattern, str);
    +486     }
    +487 
    +488     /**
    +489      * Test whether or not a string matches against a pattern. The pattern may contain two special characters:<br>
    +490      * '*' means zero or more characters<br>
    +491      * '?' means one and only one character
    +492      *
    +493      * @param pattern The pattern to match against. Must not be <code>null</code>.
    +494      * @param str The string which must be matched against the pattern. Must not be <code>null</code>.
    +495      * @param isCaseSensitive Whether or not matching should be performed case sensitively.
    +496      *
    +497      *
    +498      * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
    +499      */
    +500     protected static boolean match(String pattern, String str,
    +501             boolean isCaseSensitive) {
    +502         return SelectorUtils.match(pattern, str, isCaseSensitive);
    +503     }
    +504 
    +505     /**
    +506      * Get the list of patterns that should be excluded by default.
    +507      *
    +508      * @return An array of <code>String</code> based on the current contents of the <code>defaultExcludes</code>
    +509      * <code>Set</code>.
    +510      *
    +511      * @since Ant 1.6
    +512      */
    +513     public static String[] getDefaultExcludes() {
    +514         synchronized (defaultExcludes) {
    +515             return (String[]) defaultExcludes.toArray(new String[defaultExcludes
    +516                     .size()]);
    +517         }
    +518     }
    +519 
    +520     /**
    +521      * Add a pattern to the default excludes unless it is already a default exclude.
    +522      *
    +523      * @param s A string to add as an exclude pattern.
    +524      * @return    <code>true</code> if the string was added; <code>false</code> if it already existed.
    +525      *
    +526      * @since Ant 1.6
    +527      */
    +528     public static boolean addDefaultExclude(String s) {
    +529         synchronized (defaultExcludes) {
    +530             return defaultExcludes.add(s);
    +531         }
    +532     }
    +533 
    +534     /**
    +535      * Remove a string if it is a default exclude.
    +536      *
    +537      * @param s The string to attempt to remove.
    +538      * @return    <code>true</code> if <code>s</code> was a default exclude (and thus was removed); <code>false</code> if
    +539      * <code>s</code> was not in the default excludes list to begin with.
    +540      *
    +541      * @since Ant 1.6
    +542      */
    +543     public static boolean removeDefaultExclude(String s) {
    +544         synchronized (defaultExcludes) {
    +545             return defaultExcludes.remove(s);
    +546         }
    +547     }
    +548 
    +549     /**
    +550      * Go back to the hardwired default exclude patterns.
    +551      *
    +552      * @since Ant 1.6
    +553      */
    +554     public static void resetDefaultExcludes() {
    +555         synchronized (defaultExcludes) {
    +556             defaultExcludes.clear();
    +557             for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
    +558                 defaultExcludes.add(DEFAULTEXCLUDES[i]);
    +559             }
    +560         }
    +561     }
    +562 
    +563     /**
    +564      * Set the base directory to be scanned. This is the directory which is scanned recursively. All '/' and '\'
    +565      * characters are replaced by <code>File.separatorChar</code>, so the separator used need not match
    +566      * <code>File.separatorChar</code>.
    +567      *
    +568      * @param basedir The base directory to scan.
    +569      */
    +570     public void setBasedir(String basedir) {
    +571         setBasedir(basedir == null ? (File) null
    +572                 : new File(basedir.replace('/', File.separatorChar).replace(
    +573                                 '\\', File.separatorChar)));
    +574     }
    +575 
    +576     /**
    +577      * Set the base directory to be scanned. This is the directory which is scanned recursively.
    +578      *
    +579      * @param basedir The base directory for scanning.
    +580      */
    +581     public synchronized void setBasedir(File basedir) {
    +582         this.basedir = basedir;
    +583     }
    +584 
    +585     /**
    +586      * Return the base directory to be scanned. This is the directory which is scanned recursively.
    +587      *
    +588      * @return the base directory to be scanned.
    +589      */
    +590     public synchronized File getBasedir() {
    +591         return basedir;
    +592     }
    +593 
    +594     /**
    +595      * Find out whether include exclude patterns are matched in a case sensitive way.
    +596      *
    +597      * @return whether or not the scanning is case sensitive.
    +598      * @since Ant 1.6
    +599      */
    +600     public synchronized boolean isCaseSensitive() {
    +601         return isCaseSensitive;
    +602     }
    +603 
    +604     /**
    +605      * Set whether or not include and exclude patterns are matched in a case sensitive way.
    +606      *
    +607      * @param isCaseSensitive whether or not the file system should be regarded as a case sensitive one.
    +608      */
    +609     public synchronized void setCaseSensitive(boolean isCaseSensitive) {
    +610         this.isCaseSensitive = isCaseSensitive;
    +611     }
    +612 
    +613     /**
    +614      * Sets whether or not a missing base directory is an error
    +615      *
    +616      * @param errorOnMissingDir whether or not a missing base directory is an error
    +617      * @since Ant 1.7.1
    +618      */
    +619     public void setErrorOnMissingDir(boolean errorOnMissingDir) {
    +620         this.errorOnMissingDir = errorOnMissingDir;
    +621     }
    +622 
    +623     /**
    +624      * Get whether or not a DirectoryScanner follows symbolic links.
    +625      *
    +626      * @return flag indicating whether symbolic links should be followed.
    +627      *
    +628      * @since Ant 1.6
    +629      */
    +630     public synchronized boolean isFollowSymlinks() {
    +631         return followSymlinks;
    +632     }
    +633 
    +634     /**
    +635      * Set whether or not symbolic links should be followed.
    +636      *
    +637      * @param followSymlinks whether or not symbolic links should be followed.
    +638      */
    +639     public synchronized void setFollowSymlinks(boolean followSymlinks) {
    +640         this.followSymlinks = followSymlinks;
    +641     }
    +642 
    +643     /**
    +644      * The maximum number of times a symbolic link may be followed during a scan.
    +645      *
    +646      * @since Ant 1.8.0
    +647      */
    +648     public void setMaxLevelsOfSymlinks(int max) {
    +649         maxLevelsOfSymlinks = max;
    +650     }
    +651 
    +652     /**
    +653      * Set the list of include patterns to use. All '/' and '\' characters are replaced by
    +654      * <code>File.separatorChar</code>, so the separator used need not match <code>File.separatorChar</code>.
    +655      * <p>
    +656      * When a pattern ends with a '/' or '\', "**" is appended.
    +657      *
    +658      * @param includes A list of include patterns. May be <code>null</code>, indicating that all files should be
    +659      * included. If a non-<code>null</code> list is given, all elements must be non-<code>null</code>.
    +660      */
    +661     public synchronized void setIncludes(String[] includes) {
    +662         if (includes == null) {
    +663             this.includes = null;
    +664         } else {
    +665             this.includes = new String[includes.length];
    +666             for (int i = 0; i < includes.length; i++) {
    +667                 this.includes[i] = normalizePattern(includes[i]);
    +668             }
    +669         }
    +670     }
    +671 
    +672     public synchronized void setIncludes(String include) {
    +673         if (include == null) {
    +674             this.includes = null;
    +675         } else {
    +676             this.includes = new String[1];
    +677             this.includes[0] = normalizePattern(include);
    +678         }
    +679     }
    +680 
    +681     /**
    +682      * Set the list of exclude patterns to use. All '/' and '\' characters are replaced by
    +683      * <code>File.separatorChar</code>, so the separator used need not match <code>File.separatorChar</code>.
    +684      * <p>
    +685      * When a pattern ends with a '/' or '\', "**" is appended.
    +686      *
    +687      * @param excludes A list of exclude patterns. May be <code>null</code>, indicating that no files should be
    +688      * excluded. If a non-<code>null</code> list is given, all elements must be non-<code>null</code>.
    +689      */
    +690     public synchronized void setExcludes(String[] excludes) {
    +691         if (excludes == null) {
    +692             this.excludes = null;
    +693         } else {
    +694             this.excludes = new String[excludes.length];
    +695             for (int i = 0; i < excludes.length; i++) {
    +696                 this.excludes[i] = normalizePattern(excludes[i]);
    +697             }
    +698         }
    +699     }
    +700 
    +701     /**
    +702      * Add to the list of exclude patterns to use. All '/' and '\' characters are replaced by
    +703      * <code>File.separatorChar</code>, so the separator used need not match <code>File.separatorChar</code>.
    +704      * <p>
    +705      * When a pattern ends with a '/' or '\', "**" is appended.
    +706      *
    +707      * @param excludes A list of exclude patterns. May be <code>null</code>, in which case the exclude patterns don't
    +708      * get changed at all.
    +709      *
    +710      * @since Ant 1.6.3
    +711      */
    +712     public synchronized void addExcludes(String[] excludes) {
    +713         if (excludes != null && excludes.length > 0) {
    +714             if (this.excludes != null && this.excludes.length > 0) {
    +715                 String[] tmp = new String[excludes.length
    +716                         + this.excludes.length];
    +717                 System.arraycopy(this.excludes, 0, tmp, 0,
    +718                         this.excludes.length);
    +719                 for (int i = 0; i < excludes.length; i++) {
    +720                     tmp[this.excludes.length + i]
    +721                             = normalizePattern(excludes[i]);
    +722                 }
    +723                 this.excludes = tmp;
    +724             } else {
    +725                 setExcludes(excludes);
    +726             }
    +727         }
    +728     }
    +729 
    +730     /**
    +731      * All '/' and '\' characters are replaced by <code>File.separatorChar</code>, so the separator used need not match
    +732      * <code>File.separatorChar</code>.
    +733      *
    +734      * <p>
    +735      * When a pattern ends with a '/' or '\', "**" is appended.
    +736      *
    +737      * @since Ant 1.6.3
    +738      */
    +739     private static String normalizePattern(String p) {
    +740         String pattern = p.replace('/', File.separatorChar)
    +741                 .replace('\\', File.separatorChar);
    +742         if (pattern.endsWith(File.separator)) {
    +743             pattern += SelectorUtils.DEEP_TREE_MATCH;
    +744         }
    +745         return pattern;
    +746     }
    +747 
    +748     /**
    +749      * Set the selectors that will select the filelist.
    +750      *
    +751      * @param selectors specifies the selectors to be invoked on a scan.
    +752      */
    +753     public synchronized void setSelectors(FileSelector[] selectors) {
    +754         this.selectors = selectors;
    +755     }
    +756 
    +757     /**
    +758      * Return whether or not the scanner has included all the files or directories it has come across so far.
    +759      *
    +760      * @return <code>true</code> if all files and directories which have been found so far have been included.
    +761      */
    +762     public synchronized boolean isEverythingIncluded() {
    +763         return everythingIncluded;
    +764     }
    +765 
    +766     /**
    +767      * Scan for files which match at least one include pattern and don't match any exclude patterns. If there are
    +768      * selectors then the files must pass muster there, as well. Scans under basedir, if set; otherwise the include
    +769      * patterns without leading wildcards specify the absolute paths of the files that may be included.
    +770      *
    +771      * @exception IllegalStateException if the base directory was set incorrectly (i.e. if it doesn't exist or isn't a
    +772      * directory).
    +773      */
    +774     public void scan() throws IllegalStateException {
    +775         synchronized (scanLock) {
    +776             if (scanning) {
    +777                 while (scanning) {
    +778                     try {
    +779                         scanLock.wait();
    +780                     } catch (InterruptedException e) {
    +781                         continue;
    +782                     }
    +783                 }
    +784                 if (illegal != null) {
    +785                     throw illegal;
    +786                 }
    +787                 return;
    +788             }
    +789             scanning = true;
    +790         }
    +791         File savedBase = basedir;
    +792         try {
    +793             synchronized (this) {
    +794                 illegal = null;
    +795                 clearResults();
    +796 
    +797                 // set in/excludes to reasonable defaults if needed:
    +798                 boolean nullIncludes = (includes == null);
    +799                 includes = nullIncludes
    +800                         ? new String[]{SelectorUtils.DEEP_TREE_MATCH} : includes;
    +801                 boolean nullExcludes = (excludes == null);
    +802                 excludes = nullExcludes ? new String[0] : excludes;
    +803 
    +804                 if (basedir != null && !followSymlinks
    +805                         && SYMLINK_UTILS.isSymbolicLink(basedir)) {
    +806                     notFollowedSymlinks.add(basedir.getAbsolutePath());
    +807                     basedir = null;
    +808                 }
    +809 
    +810                 if (basedir == null) {
    +811                     // if no basedir and no includes, nothing to do:
    +812                     if (nullIncludes) {
    +813                         return;
    +814                     }
    +815                 } else {
    +816                     if (!basedir.exists()) {
    +817                         if (errorOnMissingDir) {
    +818                             illegal = new IllegalStateException("basedir "
    +819                                     + basedir
    +820                                     + DOES_NOT_EXIST_POSTFIX);
    +821                         } else {
    +822                             // Nothing to do - basedir does not exist
    +823                             return;
    +824                         }
    +825                     } else if (!basedir.isDirectory()) {
    +826                         illegal = new IllegalStateException("basedir "
    +827                                 + basedir
    +828                                 + " is not a"
    +829                                 + " directory.");
    +830                     }
    +831                     if (illegal != null) {
    +832                         throw illegal;
    +833                     }
    +834                 }
    +835                 if (isIncluded(TokenizedPath.EMPTY_PATH)) {
    +836                     if (!isExcluded(TokenizedPath.EMPTY_PATH)) {
    +837                         if (isSelected("", basedir)) {
    +838                             dirsIncluded.addElement("");
    +839                         } else {
    +840                             dirsDeselected.addElement("");
    +841                         }
    +842                     } else {
    +843                         dirsExcluded.addElement("");
    +844                     }
    +845                 } else {
    +846                     dirsNotIncluded.addElement("");
    +847                 }
    +848                 checkIncludePatterns();
    +849                 clearCaches();
    +850                 includes = nullIncludes ? null : includes;
    +851                 excludes = nullExcludes ? null : excludes;
    +852             }
    +853         } catch (IOException ex) {
    +854             throw new BuildException(ex);
    +855         } finally {
    +856             basedir = savedBase;
    +857             synchronized (scanLock) {
    +858                 scanning = false;
    +859                 scanLock.notifyAll();
    +860             }
    +861         }
    +862     }
    +863 
    +864     /**
    +865      * This routine is actually checking all the include patterns in order to avoid scanning everything under base dir.
    +866      *
    +867      * @since Ant 1.6
    +868      */
    +869     private void checkIncludePatterns() {
    +870         ensureNonPatternSetsReady();
    +871         Map<TokenizedPath, String> newroots = new HashMap<TokenizedPath, String>();
    +872 
    +873         // put in the newroots map the include patterns without
    +874         // wildcard tokens
    +875         for (int i = 0; i < includePatterns.length; i++) {
    +876             String pattern = includePatterns[i].toString();
    +877             if (!shouldSkipPattern(pattern)) {
    +878                 newroots.put(includePatterns[i].rtrimWildcardTokens(),
    +879                         pattern);
    +880             }
    +881         }
    +882         for (Map.Entry<String, TokenizedPath> entry : includeNonPatterns.entrySet()) {
    +883             String pattern = entry.getKey();
    +884             if (!shouldSkipPattern(pattern)) {
    +885                 newroots.put(entry.getValue(), pattern);
    +886             }
    +887         }
    +888 
    +889         if (newroots.containsKey(TokenizedPath.EMPTY_PATH)
    +890                 && basedir != null) {
    +891             // we are going to scan everything anyway
    +892             scandir(basedir, "", true);
    +893         } else {
    +894             File canonBase = null;
    +895             if (basedir != null) {
    +896                 try {
    +897                     canonBase = basedir.getCanonicalFile();
    +898                 } catch (IOException ex) {
    +899                     throw new BuildException(ex);
    +900                 }
    +901             }
    +902             // only scan directories that can include matched files or
    +903             // directories
    +904             for (Map.Entry<TokenizedPath, String> entry : newroots.entrySet()) {
    +905                 TokenizedPath currentPath = entry.getKey();
    +906                 String currentelement = currentPath.toString();
    +907                 if (basedir == null
    +908                         && !FileUtils.isAbsolutePath(currentelement)) {
    +909                     continue;
    +910                 }
    +911                 File myfile = new File(basedir, currentelement);
    +912 
    +913                 if (myfile.exists()) {
    +914                     // may be on a case insensitive file system.  We want
    +915                     // the results to show what's really on the disk, so
    +916                     // we need to double check.
    +917                     try {
    +918                         String path = (basedir == null)
    +919                                 ? myfile.getCanonicalPath()
    +920                                 : FILE_UTILS.removeLeadingPath(canonBase,
    +921                                         myfile.getCanonicalFile());
    +922                         if (!path.equals(currentelement) || ON_VMS) {
    +923                             myfile = currentPath.findFile(basedir, true);
    +924                             if (myfile != null && basedir != null) {
    +925                                 currentelement = FILE_UTILS.removeLeadingPath(
    +926                                         basedir, myfile);
    +927                                 if (!currentPath.toString()
    +928                                         .equals(currentelement)) {
    +929                                     currentPath
    +930                                             = new TokenizedPath(currentelement);
    +931                                 }
    +932                             }
    +933                         }
    +934                     } catch (IOException ex) {
    +935                         throw new BuildException(ex);
    +936                     }
    +937                 }
    +938 
    +939                 if ((myfile == null || !myfile.exists()) && !isCaseSensitive()) {
    +940                     File f = currentPath.findFile(basedir, false);
    +941                     if (f != null && f.exists()) {
    +942                         // adapt currentelement to the case we've
    +943                         // actually found
    +944                         currentelement = (basedir == null)
    +945                                 ? f.getAbsolutePath()
    +946                                 : FILE_UTILS.removeLeadingPath(basedir, f);
    +947                         myfile = f;
    +948                         currentPath = new TokenizedPath(currentelement);
    +949                     }
    +950                 }
    +951 
    +952                 if (myfile != null && myfile.exists()) {
    +953                     if (!followSymlinks && currentPath.isSymlink(basedir)) {
    +954                         accountForNotFollowedSymlink(currentPath, myfile);
    +955                         continue;
    +956                     }
    +957                     if (myfile.isDirectory()) {
    +958                         if (isIncluded(currentPath)
    +959                                 && currentelement.length() > 0) {
    +960                             accountForIncludedDir(currentPath, myfile, true);
    +961                         } else {
    +962                             scandir(myfile, currentPath, true);
    +963                         }
    +964                     } else if (myfile.isFile()) {
    +965                         String originalpattern = (String) entry.getValue();
    +966                         boolean included = isCaseSensitive()
    +967                                 ? originalpattern.equals(currentelement)
    +968                                 : originalpattern.equalsIgnoreCase(currentelement);
    +969                         if (included) {
    +970                             accountForIncludedFile(currentPath, myfile);
    +971                         }
    +972                     }
    +973                 }
    +974             }
    +975         }
    +976     }
    +977 
    +978     /**
    +979      * true if the pattern specifies a relative path without basedir or an absolute path not inside basedir.
    +980      *
    +981      * @since Ant 1.8.0
    +982      */
    +983     private boolean shouldSkipPattern(String pattern) {
    +984         if (FileUtils.isAbsolutePath(pattern)) {
    +985             //skip abs. paths not under basedir, if set:
    +986             if (basedir != null
    +987                     && !SelectorUtils.matchPatternStart(pattern,
    +988                             basedir.getAbsolutePath(),
    +989                             isCaseSensitive())) {
    +990                 return true;
    +991             }
    +992         } else if (basedir == null) {
    +993             //skip non-abs. paths if basedir == null:
    +994             return true;
    +995         }
    +996         return false;
    +997     }
    +998 
    +999     /**
    +1000      * Clear the result caches for a scan.
    +1001      */
    +1002     protected synchronized void clearResults() {
    +1003         filesIncluded = new VectorSet<String>();
    +1004         filesNotIncluded = new VectorSet<String>();
    +1005         filesExcluded = new VectorSet<String>();
    +1006         filesDeselected = new VectorSet<String>();
    +1007         dirsIncluded = new VectorSet<String>();
    +1008         dirsNotIncluded = new VectorSet<String>();
    +1009         dirsExcluded = new VectorSet<String>();
    +1010         dirsDeselected = new VectorSet<String>();
    +1011         everythingIncluded = (basedir != null);
    +1012         scannedDirs.clear();
    +1013         notFollowedSymlinks.clear();
    +1014     }
    +1015 
    +1016     /**
    +1017      * Top level invocation for a slow scan. A slow scan builds up a full list of excluded/included files/directories,
    +1018      * whereas a fast scan will only have full results for included files, as it ignores directories which can't
    +1019      * possibly hold any included files/directories.
    +1020      * <p>
    +1021      * Returns immediately if a slow scan has already been completed.
    +1022      */
    +1023     protected void slowScan() {
    +1024         synchronized (slowScanLock) {
    +1025             if (haveSlowResults) {
    +1026                 return;
    +1027             }
    +1028             if (slowScanning) {
    +1029                 while (slowScanning) {
    +1030                     try {
    +1031                         slowScanLock.wait();
    +1032                     } catch (InterruptedException e) {
    +1033                         // Empty
    +1034                     }
    +1035                 }
    +1036                 return;
    +1037             }
    +1038             slowScanning = true;
    +1039         }
    +1040         try {
    +1041             synchronized (this) {
    +1042 
    +1043                 // set in/excludes to reasonable defaults if needed:
    +1044                 boolean nullIncludes = (includes == null);
    +1045                 includes = nullIncludes
    +1046                         ? new String[]{SelectorUtils.DEEP_TREE_MATCH} : includes;
    +1047                 boolean nullExcludes = (excludes == null);
    +1048                 excludes = nullExcludes ? new String[0] : excludes;
    +1049 
    +1050                 String[] excl = new String[dirsExcluded.size()];
    +1051                 dirsExcluded.copyInto(excl);
    +1052 
    +1053                 String[] notIncl = new String[dirsNotIncluded.size()];
    +1054                 dirsNotIncluded.copyInto(notIncl);
    +1055 
    +1056                 ensureNonPatternSetsReady();
    +1057 
    +1058                 processSlowScan(excl);
    +1059                 processSlowScan(notIncl);
    +1060                 clearCaches();
    +1061                 includes = nullIncludes ? null : includes;
    +1062                 excludes = nullExcludes ? null : excludes;
    +1063             }
    +1064         } finally {
    +1065             synchronized (slowScanLock) {
    +1066                 haveSlowResults = true;
    +1067                 slowScanning = false;
    +1068                 slowScanLock.notifyAll();
    +1069             }
    +1070         }
    +1071     }
    +1072 
    +1073     private void processSlowScan(String[] arr) {
    +1074         for (int i = 0; i < arr.length; i++) {
    +1075             TokenizedPath path = new TokenizedPath(arr[i]);
    +1076             if (!couldHoldIncluded(path) || contentsExcluded(path)) {
    +1077                 scandir(new File(basedir, arr[i]), path, false);
    +1078             }
    +1079         }
    +1080     }
    +1081 
    +1082     /**
    +1083      * Scan the given directory for files and directories. Found files and directories are placed in their respective
    +1084      * collections, based on the matching of includes, excludes, and the selectors. When a directory is found, it is
    +1085      * scanned recursively.
    +1086      *
    +1087      * @param dir The directory to scan. Must not be <code>null</code>.
    +1088      * @param vpath The path relative to the base directory (needed to prevent problems with an absolute path when using
    +1089      * dir). Must not be <code>null</code>.
    +1090      * @param fast Whether or not this call is part of a fast scan.
    +1091      *
    +1092      * @see #filesIncluded
    +1093      * @see #filesNotIncluded
    +1094      * @see #filesExcluded
    +1095      * @see #dirsIncluded
    +1096      * @see #dirsNotIncluded
    +1097      * @see #dirsExcluded
    +1098      * @see #slowScan
    +1099      */
    +1100     protected void scandir(File dir, String vpath, boolean fast) {
    +1101         scandir(dir, new TokenizedPath(vpath), fast);
    +1102     }
    +1103 
    +1104     /**
    +1105      * Scan the given directory for files and directories. Found files and directories are placed in their respective
    +1106      * collections, based on the matching of includes, excludes, and the selectors. When a directory is found, it is
    +1107      * scanned recursively.
    +1108      *
    +1109      * @param dir The directory to scan. Must not be <code>null</code>.
    +1110      * @param path The path relative to the base directory (needed to prevent problems with an absolute path when using
    +1111      * dir). Must not be <code>null</code>.
    +1112      * @param fast Whether or not this call is part of a fast scan.
    +1113      *
    +1114      * @see #filesIncluded
    +1115      * @see #filesNotIncluded
    +1116      * @see #filesExcluded
    +1117      * @see #dirsIncluded
    +1118      * @see #dirsNotIncluded
    +1119      * @see #dirsExcluded
    +1120      * @see #slowScan
    +1121      */
    +1122     private void scandir(File dir, TokenizedPath path, boolean fast) {
    +1123         if (dir == null) {
    +1124             throw new BuildException("dir must not be null.");
    +1125         }
    +1126         String[] newfiles = dir.list();
    +1127         if (newfiles == null) {
    +1128             if (!dir.exists()) {
    +1129                 throw new BuildException(dir + DOES_NOT_EXIST_POSTFIX);
    +1130             } else if (!dir.isDirectory()) {
    +1131                 throw new BuildException(dir + " is not a directory.");
    +1132             } else {
    +1133                 throw new BuildException("IO error scanning directory '"
    +1134                         + dir.getAbsolutePath() + "'");
    +1135             }
    +1136         }
    +1137         scandir(dir, path, fast, newfiles, new LinkedList<String>());
    +1138     }
    +1139 
    +1140     private void scandir(File dir, TokenizedPath path, boolean fast,
    +1141             String[] newfiles, LinkedList<String> directoryNamesFollowed) {
    +1142         String vpath = path.toString();
    +1143         if (vpath.length() > 0 && !vpath.endsWith(File.separator)) {
    +1144             vpath += File.separator;
    +1145         }
    +1146 
    +1147         // avoid double scanning of directories, can only happen in fast mode
    +1148         if (fast && hasBeenScanned(vpath)) {
    +1149             return;
    +1150         }
    +1151         if (!followSymlinks) {
    +1152             ArrayList<String> noLinks = new ArrayList<String>();
    +1153             for (int i = 0; i < newfiles.length; i++) {
    +1154                 try {
    +1155                     if (SYMLINK_UTILS.isSymbolicLink(dir, newfiles[i])) {
    +1156                         String name = vpath + newfiles[i];
    +1157                         File file = new File(dir, newfiles[i]);
    +1158                         if (file.isDirectory()) {
    +1159                             dirsExcluded.addElement(name);
    +1160                         } else if (file.isFile()) {
    +1161                             filesExcluded.addElement(name);
    +1162                         }
    +1163                         accountForNotFollowedSymlink(name, file);
    +1164                     } else {
    +1165                         noLinks.add(newfiles[i]);
    +1166                     }
    +1167                 } catch (IOException ioe) {
    +1168                     String msg = "IOException caught while checking "
    +1169                             + "for links, couldn't get canonical path!";
    +1170                     // will be caught and redirected to Ant's logging system
    +1171                     System.err.println(msg);
    +1172                     noLinks.add(newfiles[i]);
    +1173                 }
    +1174             }
    +1175             newfiles = (String[]) (noLinks.toArray(new String[noLinks.size()]));
    +1176         } else {
    +1177             directoryNamesFollowed.addFirst(dir.getName());
    +1178         }
    +1179 
    +1180         for (int i = 0; i < newfiles.length; i++) {
    +1181             String name = vpath + newfiles[i];
    +1182             TokenizedPath newPath = new TokenizedPath(path, newfiles[i]);
    +1183             File file = new File(dir, newfiles[i]);
    +1184             String[] children = file.list();
    +1185             if (children == null || (children.length == 0 && file.isFile())) {
    +1186                 if (isIncluded(newPath)) {
    +1187                     accountForIncludedFile(newPath, file);
    +1188                 } else {
    +1189                     everythingIncluded = false;
    +1190                     filesNotIncluded.addElement(name);
    +1191                 }
    +1192             } else if (file.isDirectory()) { // dir
    +1193 
    +1194                 if (followSymlinks
    +1195                         && causesIllegalSymlinkLoop(newfiles[i], dir,
    +1196                                 directoryNamesFollowed)) {
    +1197                     // will be caught and redirected to Ant's logging system
    +1198                     System.err.println("skipping symbolic link "
    +1199                             + file.getAbsolutePath()
    +1200                             + " -- too many levels of symbolic"
    +1201                             + " links.");
    +1202                     notFollowedSymlinks.add(file.getAbsolutePath());
    +1203                     continue;
    +1204                 }
    +1205 
    +1206                 if (isIncluded(newPath)) {
    +1207                     accountForIncludedDir(newPath, file, fast, children,
    +1208                             directoryNamesFollowed);
    +1209                 } else {
    +1210                     everythingIncluded = false;
    +1211                     dirsNotIncluded.addElement(name);
    +1212                     if (fast && couldHoldIncluded(newPath)
    +1213                             && !contentsExcluded(newPath)) {
    +1214                         scandir(file, newPath, fast, children,
    +1215                                 directoryNamesFollowed);
    +1216                     }
    +1217                 }
    +1218                 if (!fast) {
    +1219                     scandir(file, newPath, fast, children, directoryNamesFollowed);
    +1220                 }
    +1221             }
    +1222         }
    +1223 
    +1224         if (followSymlinks) {
    +1225             directoryNamesFollowed.removeFirst();
    +1226         }
    +1227     }
    +1228 
    +1229     /**
    +1230      * Process included file.
    +1231      *
    +1232      * @param name path of the file relative to the directory of the FileSet.
    +1233      * @param file included File.
    +1234      */
    +1235     private void accountForIncludedFile(TokenizedPath name, File file) {
    +1236         processIncluded(name, file, filesIncluded, filesExcluded,
    +1237                 filesDeselected);
    +1238     }
    +1239 
    +1240     /**
    +1241      * Process included directory.
    +1242      *
    +1243      * @param name path of the directory relative to the directory of the FileSet.
    +1244      * @param file directory as File.
    +1245      * @param fast whether to perform fast scans.
    +1246      */
    +1247     private void accountForIncludedDir(TokenizedPath name, File file,
    +1248             boolean fast) {
    +1249         processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected);
    +1250         if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) {
    +1251             scandir(file, name, fast);
    +1252         }
    +1253     }
    +1254 
    +1255     private void accountForIncludedDir(TokenizedPath name,
    +1256             File file, boolean fast,
    +1257             String[] children,
    +1258             LinkedList<String> directoryNamesFollowed) {
    +1259         processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected);
    +1260         if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) {
    +1261             scandir(file, name, fast, children, directoryNamesFollowed);
    +1262         }
    +1263     }
    +1264 
    +1265     private void accountForNotFollowedSymlink(String name, File file) {
    +1266         accountForNotFollowedSymlink(new TokenizedPath(name), file);
    +1267     }
    +1268 
    +1269     private void accountForNotFollowedSymlink(TokenizedPath name, File file) {
    +1270         if (!isExcluded(name)
    +1271                 && (isIncluded(name)
    +1272                 || (file.isDirectory() && couldHoldIncluded(name)
    +1273                 && !contentsExcluded(name)))) {
    +1274             notFollowedSymlinks.add(file.getAbsolutePath());
    +1275         }
    +1276     }
    +1277 
    +1278     private void processIncluded(TokenizedPath path,
    +1279             File file, Vector<String> inc, Vector<String> exc,
    +1280             Vector<String> des) {
    +1281         String name = path.toString();
    +1282         if (inc.contains(name) || exc.contains(name) || des.contains(name)) {
    +1283             return;
    +1284         }
    +1285 
    +1286         boolean included = false;
    +1287         if (isExcluded(path)) {
    +1288             exc.add(name);
    +1289         } else if (isSelected(name, file)) {
    +1290             included = true;
    +1291             inc.add(name);
    +1292         } else {
    +1293             des.add(name);
    +1294         }
    +1295         everythingIncluded &= included;
    +1296     }
    +1297 
    +1298     /**
    +1299      * Test whether or not a name matches against at least one include pattern.
    +1300      *
    +1301      * @param name The name to match. Must not be <code>null</code>.
    +1302      * @return <code>true</code> when the name matches against at least one include pattern, or <code>false</code>
    +1303      * otherwise.
    +1304      */
    +1305     protected boolean isIncluded(String name) {
    +1306         return isIncluded(new TokenizedPath(name));
    +1307     }
    +1308 
    +1309     /**
    +1310      * Test whether or not a name matches against at least one include pattern.
    +1311      *
    +1312      * @param name The name to match. Must not be <code>null</code>.
    +1313      * @return <code>true</code> when the name matches against at least one include pattern, or <code>false</code>
    +1314      * otherwise.
    +1315      */
    +1316     private boolean isIncluded(TokenizedPath path) {
    +1317         ensureNonPatternSetsReady();
    +1318 
    +1319         if (isCaseSensitive()
    +1320                 ? includeNonPatterns.containsKey(path.toString())
    +1321                 : includeNonPatterns.containsKey(path.toString().toUpperCase())) {
    +1322             return true;
    +1323         }
    +1324         for (int i = 0; i < includePatterns.length; i++) {
    +1325             if (includePatterns[i].matchPath(path, isCaseSensitive())) {
    +1326                 return true;
    +1327             }
    +1328         }
    +1329         return false;
    +1330     }
    +1331 
    +1332     /**
    +1333      * Test whether or not a name matches the start of at least one include pattern.
    +1334      *
    +1335      * @param name The name to match. Must not be <code>null</code>.
    +1336      * @return <code>true</code> when the name matches against the start of at least one include pattern, or
    +1337      * <code>false</code> otherwise.
    +1338      */
    +1339     protected boolean couldHoldIncluded(String name) {
    +1340         return couldHoldIncluded(new TokenizedPath(name));
    +1341     }
    +1342 
    +1343     /**
    +1344      * Test whether or not a name matches the start of at least one include pattern.
    +1345      *
    +1346      * @param tokenizedName The name to match. Must not be <code>null</code>.
    +1347      * @return <code>true</code> when the name matches against the start of at least one include pattern, or
    +1348      * <code>false</code> otherwise.
    +1349      */
    +1350     private boolean couldHoldIncluded(TokenizedPath tokenizedName) {
    +1351         for (int i = 0; i < includePatterns.length; i++) {
    +1352             if (couldHoldIncluded(tokenizedName, includePatterns[i])) {
    +1353                 return true;
    +1354             }
    +1355         }
    +1356         for (Iterator<TokenizedPath> iter = includeNonPatterns.values().iterator();
    +1357                 iter.hasNext();) {
    +1358             if (couldHoldIncluded(tokenizedName,
    +1359                     iter.next().toPattern())) {
    +1360                 return true;
    +1361             }
    +1362         }
    +1363         return false;
    +1364     }
    +1365 
    +1366     /**
    +1367      * Test whether or not a name matches the start of the given include pattern.
    +1368      *
    +1369      * @param tokenizedName The name to match. Must not be <code>null</code>.
    +1370      * @return <code>true</code> when the name matches against the start of the include pattern, or <code>false</code>
    +1371      * otherwise.
    +1372      */
    +1373     private boolean couldHoldIncluded(TokenizedPath tokenizedName,
    +1374             TokenizedPattern tokenizedInclude) {
    +1375         return tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive())
    +1376                 && isMorePowerfulThanExcludes(tokenizedName.toString())
    +1377                 && isDeeper(tokenizedInclude, tokenizedName);
    +1378     }
    +1379 
    +1380     /**
    +1381      * Verify that a pattern specifies files deeper than the level of the specified file.
    +1382      *
    +1383      * @param pattern the pattern to check.
    +1384      * @param name the name to check.
    +1385      * @return whether the pattern is deeper than the name.
    +1386      * @since Ant 1.6.3
    +1387      */
    +1388     private boolean isDeeper(TokenizedPattern pattern, TokenizedPath name) {
    +1389         return pattern.containsPattern(SelectorUtils.DEEP_TREE_MATCH)
    +1390                 || pattern.depth() > name.depth();
    +1391     }
    +1392 
    +1393     /**
    +1394      * Find out whether one particular include pattern is more powerful than all the excludes. Note: the power
    +1395      * comparison is based on the length of the include pattern and of the exclude patterns without the wildcards.
    +1396      * Ideally the comparison should be done based on the depth of the match; that is to say how many file separators
    +1397      * have been matched before the first ** or the end of the pattern.
    +1398      *
    +1399      * IMPORTANT : this function should return false "with care".
    +1400      *
    +1401      * @param name the relative path to test.
    +1402      * @return true if there is no exclude pattern more powerful than this include pattern.
    +1403      * @since Ant 1.6
    +1404      */
    +1405     private boolean isMorePowerfulThanExcludes(String name) {
    +1406         final String soughtexclude
    +1407                 = name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH;
    +1408         for (int counter = 0; counter < excludePatterns.length; counter++) {
    +1409             if (excludePatterns[counter].toString().equals(soughtexclude)) {
    +1410                 return false;
    +1411             }
    +1412         }
    +1413         return true;
    +1414     }
    +1415 
    +1416     /**
    +1417      * Test whether all contents of the specified directory must be excluded.
    +1418      *
    +1419      * @param path the path to check.
    +1420      * @return whether all the specified directory's contents are excluded.
    +1421      */
    +1422     /* package */ boolean contentsExcluded(TokenizedPath path) {
    +1423         for (int i = 0; i < excludePatterns.length; i++) {
    +1424             if (excludePatterns[i].endsWith(SelectorUtils.DEEP_TREE_MATCH)
    +1425                     && excludePatterns[i].withoutLastToken()
    +1426                     .matchPath(path, isCaseSensitive())) {
    +1427                 return true;
    +1428             }
    +1429         }
    +1430         return false;
    +1431     }
    +1432 
    +1433     /**
    +1434      * Test whether or not a name matches against at least one exclude pattern.
    +1435      *
    +1436      * @param name The name to match. Must not be <code>null</code>.
    +1437      * @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code>
    +1438      * otherwise.
    +1439      */
    +1440     protected boolean isExcluded(String name) {
    +1441         return isExcluded(new TokenizedPath(name));
    +1442     }
    +1443 
    +1444     /**
    +1445      * Test whether or not a name matches against at least one exclude pattern.
    +1446      *
    +1447      * @param name The name to match. Must not be <code>null</code>.
    +1448      * @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code>
    +1449      * otherwise.
    +1450      */
    +1451     private boolean isExcluded(TokenizedPath name) {
    +1452         ensureNonPatternSetsReady();
    +1453 
    +1454         if (isCaseSensitive()
    +1455                 ? excludeNonPatterns.containsKey(name.toString())
    +1456                 : excludeNonPatterns.containsKey(name.toString().toUpperCase())) {
    +1457             return true;
    +1458         }
    +1459         for (int i = 0; i < excludePatterns.length; i++) {
    +1460             if (excludePatterns[i].matchPath(name, isCaseSensitive())) {
    +1461                 return true;
    +1462             }
    +1463         }
    +1464         return false;
    +1465     }
    +1466 
    +1467     /**
    +1468      * Test whether a file should be selected.
    +1469      *
    +1470      * @param name the filename to check for selecting.
    +1471      * @param file the java.io.File object for this filename.
    +1472      * @return <code>false</code> when the selectors says that the file should not be selected, <code>true</code>
    +1473      * otherwise.
    +1474      */
    +1475     protected boolean isSelected(String name, File file) {
    +1476         if (selectors != null) {
    +1477             for (int i = 0; i < selectors.length; i++) {
    +1478                 if (!selectors[i].isSelected(basedir, name, file)) {
    +1479                     return false;
    +1480                 }
    +1481             }
    +1482         }
    +1483         return true;
    +1484     }
    +1485 
    +1486     /**
    +1487      * Return the names of the files which matched at least one of the include patterns and none of the exclude
    +1488      * patterns. The names are relative to the base directory.
    +1489      *
    +1490      * @return the names of the files which matched at least one of the include patterns and none of the exclude
    +1491      * patterns.
    +1492      */
    +1493     public String[] getIncludedFiles() {
    +1494         String[] files;
    +1495         synchronized (this) {
    +1496             if (filesIncluded == null) {
    +1497                 throw new IllegalStateException("Must call scan() first");
    +1498             }
    +1499             files = new String[filesIncluded.size()];
    +1500             filesIncluded.copyInto(files);
    +1501         }
    +1502         Arrays.sort(files);
    +1503         return files;
    +1504     }
    +1505 
    +1506     /**
    +1507      * Return the count of included files.
    +1508      *
    +1509      * @return <code>int</code>.
    +1510      * @since Ant 1.6.3
    +1511      */
    +1512     public synchronized int getIncludedFilesCount() {
    +1513         if (filesIncluded == null) {
    +1514             throw new IllegalStateException("Must call scan() first");
    +1515         }
    +1516         return filesIncluded.size();
    +1517     }
    +1518 
    +1519     /**
    +1520      * Return the names of the files which matched none of the include patterns. The names are relative to the base
    +1521      * directory. This involves performing a slow scan if one has not already been completed.
    +1522      *
    +1523      * @return the names of the files which matched none of the include patterns.
    +1524      *
    +1525      * @see #slowScan
    +1526      */
    +1527     public synchronized String[] getNotIncludedFiles() {
    +1528         slowScan();
    +1529         String[] files = new String[filesNotIncluded.size()];
    +1530         filesNotIncluded.copyInto(files);
    +1531         return files;
    +1532     }
    +1533 
    +1534     /**
    +1535      * Return the names of the files which matched at least one of the include patterns and at least one of the exclude
    +1536      * patterns. The names are relative to the base directory. This involves performing a slow scan if one has not
    +1537      * already been completed.
    +1538      *
    +1539      * @return the names of the files which matched at least one of the include patterns and at least one of the exclude
    +1540      * patterns.
    +1541      *
    +1542      * @see #slowScan
    +1543      */
    +1544     public synchronized String[] getExcludedFiles() {
    +1545         slowScan();
    +1546         String[] files = new String[filesExcluded.size()];
    +1547         filesExcluded.copyInto(files);
    +1548         return files;
    +1549     }
    +1550 
    +1551     /**
    +1552      * <p>
    +1553      * Return the names of the files which were selected out and therefore not ultimately included.</p>
    +1554      *
    +1555      * <p>
    +1556      * The names are relative to the base directory. This involves performing a slow scan if one has not already been
    +1557      * completed.</p>
    +1558      *
    +1559      * @return the names of the files which were deselected.
    +1560      *
    +1561      * @see #slowScan
    +1562      */
    +1563     public synchronized String[] getDeselectedFiles() {
    +1564         slowScan();
    +1565         String[] files = new String[filesDeselected.size()];
    +1566         filesDeselected.copyInto(files);
    +1567         return files;
    +1568     }
    +1569 
    +1570     /**
    +1571      * Return the names of the directories which matched at least one of the include patterns and none of the exclude
    +1572      * patterns. The names are relative to the base directory.
    +1573      *
    +1574      * @return the names of the directories which matched at least one of the include patterns and none of the exclude
    +1575      * patterns.
    +1576      */
    +1577     public String[] getIncludedDirectories() {
    +1578         String[] directories;
    +1579         synchronized (this) {
    +1580             if (dirsIncluded == null) {
    +1581                 throw new IllegalStateException("Must call scan() first");
    +1582             }
    +1583             directories = new String[dirsIncluded.size()];
    +1584             dirsIncluded.copyInto(directories);
    +1585         }
    +1586         Arrays.sort(directories);
    +1587         return directories;
    +1588     }
    +1589 
    +1590     /**
    +1591      * Return the count of included directories.
    +1592      *
    +1593      * @return <code>int</code>.
    +1594      * @since Ant 1.6.3
    +1595      */
    +1596     public synchronized int getIncludedDirsCount() {
    +1597         if (dirsIncluded == null) {
    +1598             throw new IllegalStateException("Must call scan() first");
    +1599         }
    +1600         return dirsIncluded.size();
    +1601     }
    +1602 
    +1603     /**
    +1604      * Return the names of the directories which matched none of the include patterns. The names are relative to the
    +1605      * base directory. This involves performing a slow scan if one has not already been completed.
    +1606      *
    +1607      * @return the names of the directories which matched none of the include patterns.
    +1608      *
    +1609      * @see #slowScan
    +1610      */
    +1611     public synchronized String[] getNotIncludedDirectories() {
    +1612         slowScan();
    +1613         String[] directories = new String[dirsNotIncluded.size()];
    +1614         dirsNotIncluded.copyInto(directories);
    +1615         return directories;
    +1616     }
    +1617 
    +1618     /**
    +1619      * Return the names of the directories which matched at least one of the include patterns and at least one of the
    +1620      * exclude patterns. The names are relative to the base directory. This involves performing a slow scan if one has
    +1621      * not already been completed.
    +1622      *
    +1623      * @return the names of the directories which matched at least one of the include patterns and at least one of the
    +1624      * exclude patterns.
    +1625      *
    +1626      * @see #slowScan
    +1627      */
    +1628     public synchronized String[] getExcludedDirectories() {
    +1629         slowScan();
    +1630         String[] directories = new String[dirsExcluded.size()];
    +1631         dirsExcluded.copyInto(directories);
    +1632         return directories;
    +1633     }
    +1634 
    +1635     /**
    +1636      * <p>
    +1637      * Return the names of the directories which were selected out and therefore not ultimately included.</p>
    +1638      *
    +1639      * <p>
    +1640      * The names are relative to the base directory. This involves performing a slow scan if one has not already been
    +1641      * completed.</p>
    +1642      *
    +1643      * @return the names of the directories which were deselected.
    +1644      *
    +1645      * @see #slowScan
    +1646      */
    +1647     public synchronized String[] getDeselectedDirectories() {
    +1648         slowScan();
    +1649         String[] directories = new String[dirsDeselected.size()];
    +1650         dirsDeselected.copyInto(directories);
    +1651         return directories;
    +1652     }
    +1653 
    +1654     /**
    +1655      * Absolute paths of all symbolic links that haven't been followed but would have been followed had followsymlinks
    +1656      * been true or maxLevelsOfSymlinks been bigger.
    +1657      *
    +1658      * @return sorted array of not followed symlinks
    +1659      * @since Ant 1.8.0
    +1660      * @see #notFollowedSymlinks
    +1661      */
    +1662     public synchronized String[] getNotFollowedSymlinks() {
    +1663         String[] links;
    +1664         synchronized (this) {
    +1665             links = (String[]) notFollowedSymlinks
    +1666                     .toArray(new String[notFollowedSymlinks.size()]);
    +1667         }
    +1668         Arrays.sort(links);
    +1669         return links;
    +1670     }
    +1671 
    +1672     /**
    +1673      * Add default exclusions to the current exclusions set.
    +1674      */
    +1675     public synchronized void addDefaultExcludes() {
    +1676         int excludesLength = excludes == null ? 0 : excludes.length;
    +1677         String[] newExcludes;
    +1678         String[] defaultExcludesTemp = getDefaultExcludes();
    +1679         newExcludes = new String[excludesLength + defaultExcludesTemp.length];
    +1680         if (excludesLength > 0) {
    +1681             System.arraycopy(excludes, 0, newExcludes, 0, excludesLength);
    +1682         }
    +1683         for (int i = 0; i < defaultExcludesTemp.length; i++) {
    +1684             newExcludes[i + excludesLength]
    +1685                     = defaultExcludesTemp[i].replace('/', File.separatorChar)
    +1686                     .replace('\\', File.separatorChar);
    +1687         }
    +1688         excludes = newExcludes;
    +1689     }
    +1690 
    +1691     /**
    +1692      * Get the named resource.
    +1693      *
    +1694      * @param name path name of the file relative to the dir attribute.
    +1695      *
    +1696      * @return the resource with the given name.
    +1697      * @since Ant 1.5.2
    +1698      */
    +1699     public synchronized Resource getResource(String name) {
    +1700         return new FileResource(basedir, name);
    +1701     }
    +1702 
    +1703     /**
    +1704      * Has the directory with the given path relative to the base directory already been scanned?
    +1705      *
    +1706      * <p>
    +1707      * Registers the given directory as scanned as a side effect.</p>
    +1708      *
    +1709      * @since Ant 1.6
    +1710      */
    +1711     private boolean hasBeenScanned(String vpath) {
    +1712         return !scannedDirs.add(vpath);
    +1713     }
    +1714 
    +1715     /**
    +1716      * This method is of interest for testing purposes. The returned Set is live and should not be modified.
    +1717      *
    +1718      * @return the Set of relative directory names that have been scanned.
    +1719      */
    +1720     /* package-private */ Set<String> getScannedDirs() {
    +1721         return scannedDirs;
    +1722     }
    +1723 
    +1724     /**
    +1725      * Clear internal caches.
    +1726      *
    +1727      * @since Ant 1.6
    +1728      */
    +1729     private synchronized void clearCaches() {
    +1730         includeNonPatterns.clear();
    +1731         excludeNonPatterns.clear();
    +1732         includePatterns = null;
    +1733         excludePatterns = null;
    +1734         areNonPatternSetsReady = false;
    +1735     }
    +1736 
    +1737     /**
    +1738      * Ensure that the in|exclude &quot;patterns&quot; have been properly divided up.
    +1739      *
    +1740      * @since Ant 1.6.3
    +1741      */
    +1742     /* package */ synchronized void ensureNonPatternSetsReady() {
    +1743         if (!areNonPatternSetsReady) {
    +1744             includePatterns = fillNonPatternSet(includeNonPatterns, includes);
    +1745             excludePatterns = fillNonPatternSet(excludeNonPatterns, excludes);
    +1746             areNonPatternSetsReady = true;
    +1747         }
    +1748     }
    +1749 
    +1750     /**
    +1751      * Add all patterns that are not real patterns (do not contain wildcards) to the set and returns the real patterns.
    +1752      *
    +1753      * @param map Map to populate.
    +1754      * @param patterns String[] of patterns.
    +1755      * @since Ant 1.8.0
    +1756      */
    +1757     private TokenizedPattern[] fillNonPatternSet(Map<String, TokenizedPath> map, String[] patterns) {
    +1758         ArrayList<TokenizedPattern> al = new ArrayList<TokenizedPattern>(patterns.length);
    +1759         for (int i = 0; i < patterns.length; i++) {
    +1760             if (!SelectorUtils.hasWildcards(patterns[i])) {
    +1761                 String s = isCaseSensitive()
    +1762                         ? patterns[i] : patterns[i].toUpperCase();
    +1763                 map.put(s, new TokenizedPath(s));
    +1764             } else {
    +1765                 al.add(new TokenizedPattern(patterns[i]));
    +1766             }
    +1767         }
    +1768         return (TokenizedPattern[]) al.toArray(new TokenizedPattern[al.size()]);
    +1769     }
    +1770 
    +1771     /**
    +1772      * Would following the given directory cause a loop of symbolic links deeper than allowed?
    +1773      *
    +1774      * <p>
    +1775      * Can only happen if the given directory has been seen at least more often than allowed during the current scan and
    +1776      * it is a symbolic link and enough other occurrences of the same name higher up are symbolic links that point to
    +1777      * the same place.</p>
    +1778      *
    +1779      * @since Ant 1.8.0
    +1780      */
    +1781     private boolean causesIllegalSymlinkLoop(String dirName, File parent,
    +1782             LinkedList<String> directoryNamesFollowed) {
    +1783         try {
    +1784             if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks
    +1785                     && CollectionUtils.frequency(directoryNamesFollowed, dirName)
    +1786                     >= maxLevelsOfSymlinks
    +1787                     && SYMLINK_UTILS.isSymbolicLink(parent, dirName)) {
    +1788 
    +1789                 ArrayList<String> files = new ArrayList<String>();
    +1790                 File f = FILE_UTILS.resolveFile(parent, dirName);
    +1791                 String target = f.getCanonicalPath();
    +1792                 files.add(target);
    +1793 
    +1794                 String relPath = "";
    +1795                 for (String dir : directoryNamesFollowed) {
    +1796                     relPath += "../";
    +1797                     if (dirName.equals(dir)) {
    +1798                         f = FILE_UTILS.resolveFile(parent, relPath + dir);
    +1799                         files.add(f.getCanonicalPath());
    +1800                         if (files.size() > maxLevelsOfSymlinks
    +1801                                 && CollectionUtils.frequency(files, target)
    +1802                                 > maxLevelsOfSymlinks) {
    +1803                             return true;
    +1804                         }
    +1805                     }
    +1806                 }
    +1807 
    +1808             }
    +1809             return false;
    +1810         } catch (IOException ex) {
    +1811             throw new BuildException("Caught error while checking for"
    +1812                     + " symbolic links", ex);
    +1813         }
    +1814     }
    +1815 
    +1816 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/FileScanner.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/FileScanner.html new file mode 100644 index 000000000..a2e273346 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/FileScanner.html @@ -0,0 +1,171 @@ + + + +FileScanner xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant;
    +19  
    +20  import java.io.File;
    +21  
    +22  /**
    +23   * An interface used to describe the actions required of any type of
    +24   * directory scanner.
    +25   *
    +26   */
    +27  public interface FileScanner {
    +28      /**
    +29       * Adds default exclusions to the current exclusions set.
    +30       */
    +31      void addDefaultExcludes();
    +32  
    +33      /**
    +34       * Returns the base directory to be scanned.
    +35       * This is the directory which is scanned recursively.
    +36       *
    +37       * @return the base directory to be scanned
    +38       */
    +39      File getBasedir();
    +40  
    +41      /**
    +42       * Returns the names of the directories which matched at least one of the
    +43       * include patterns and at least one of the exclude patterns.
    +44       * The names are relative to the base directory.
    +45       *
    +46       * @return the names of the directories which matched at least one of the
    +47       * include patterns and at least one of the exclude patterns.
    +48       */
    +49      String[] getExcludedDirectories();
    +50  
    +51      /**
    +52       * Returns the names of the files which matched at least one of the
    +53       * include patterns and at least one of the exclude patterns.
    +54       * The names are relative to the base directory.
    +55       *
    +56       * @return the names of the files which matched at least one of the
    +57       *         include patterns and at least one of the exclude patterns.
    +58       *
    +59       */
    +60      String[] getExcludedFiles();
    +61  
    +62      /**
    +63       * Returns the names of the directories which matched at least one of the
    +64       * include patterns and none of the exclude patterns.
    +65       * The names are relative to the base directory.
    +66       *
    +67       * @return the names of the directories which matched at least one of the
    +68       * include patterns and none of the exclude patterns.
    +69       */
    +70      String[] getIncludedDirectories();
    +71  
    +72      /**
    +73       * Returns the names of the files which matched at least one of the
    +74       * include patterns and none of the exclude patterns.
    +75       * The names are relative to the base directory.
    +76       *
    +77       * @return the names of the files which matched at least one of the
    +78       *         include patterns and none of the exclude patterns.
    +79       */
    +80      String[] getIncludedFiles();
    +81  
    +82      /**
    +83       * Returns the names of the directories which matched none of the include
    +84       * patterns. The names are relative to the base directory.
    +85       *
    +86       * @return the names of the directories which matched none of the include
    +87       * patterns.
    +88       */
    +89      String[] getNotIncludedDirectories();
    +90  
    +91      /**
    +92       * Returns the names of the files which matched none of the include
    +93       * patterns. The names are relative to the base directory.
    +94       *
    +95       * @return the names of the files which matched none of the include
    +96       *         patterns.
    +97       */
    +98      String[] getNotIncludedFiles();
    +99  
    +100     /**
    +101      * Scans the base directory for files which match at least one include
    +102      * pattern and don't match any exclude patterns.
    +103      *
    +104      * @exception IllegalStateException if the base directory was set
    +105      *            incorrectly (i.e. if it is <code>null</code>, doesn't exist,
    +106      *            or isn't a directory).
    +107      */
    +108     void scan() throws IllegalStateException;
    +109 
    +110     /**
    +111      * Sets the base directory to be scanned. This is the directory which is
    +112      * scanned recursively. All '/' and '\' characters should be replaced by
    +113      * <code>File.separatorChar</code>, so the separator used need not match
    +114      * <code>File.separatorChar</code>.
    +115      *
    +116      * @param basedir The base directory to scan.
    +117      *                Must not be <code>null</code>.
    +118      */
    +119     void setBasedir(String basedir);
    +120 
    +121     /**
    +122      * Sets the base directory to be scanned. This is the directory which is
    +123      * scanned recursively.
    +124      *
    +125      * @param basedir The base directory for scanning.
    +126      *                Should not be <code>null</code>.
    +127      */
    +128     void setBasedir(File basedir);
    +129 
    +130     /**
    +131      * Sets the list of exclude patterns to use.
    +132      *
    +133      * @param excludes A list of exclude patterns.
    +134      *                 May be <code>null</code>, indicating that no files
    +135      *                 should be excluded. If a non-<code>null</code> list is
    +136      *                 given, all elements must be non-<code>null</code>.
    +137      */
    +138     void setExcludes(String[] excludes);
    +139 
    +140     /**
    +141      * Sets the list of include patterns to use.
    +142      *
    +143      * @param includes A list of include patterns.
    +144      *                 May be <code>null</code>, indicating that all files
    +145      *                 should be included. If a non-<code>null</code>
    +146      *                 list is given, all elements must be
    +147      * non-<code>null</code>.
    +148      */
    +149     void setIncludes(String[] includes);
    +150 
    +151     /**
    +152      * Sets whether or not the file system should be regarded as case sensitive.
    +153      *
    +154      * @param isCaseSensitive whether or not the file system should be
    +155      *                        regarded as a case sensitive one
    +156      */
    +157     void setCaseSensitive(boolean isCaseSensitive);
    +158 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/Location.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/Location.html new file mode 100644 index 000000000..cd1315cd1 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/Location.html @@ -0,0 +1,191 @@ + + + +Location xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant;
    +20  
    +21  import java.io.Serializable;
    +22  import org.owasp.dependencycheck.org.apache.tools.ant.util.FileUtils;
    +23  import org.xml.sax.Locator;
    +24  
    +25  /**
    +26   * Stores the location of a piece of text within a file (file name,
    +27   * line number and column number). Note that the column number is
    +28   * currently ignored.
    +29   *
    +30   */
    +31  public class Location implements Serializable {
    +32      private static final long serialVersionUID = 1L;
    +33  
    +34      /** Name of the file. */
    +35      private final String fileName;
    +36      /** Line number within the file. */
    +37      private final int lineNumber;
    +38      /** Column number within the file. */
    +39      private final int columnNumber;
    +40  
    +41      /** Location to use when one is needed but no information is available */
    +42      public static final Location UNKNOWN_LOCATION = new Location();
    +43  
    +44      private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
    +45  
    +46      /**
    +47       * Creates an "unknown" location.
    +48       */
    +49      private Location() {
    +50          this(null, 0, 0);
    +51      }
    +52  
    +53      /**
    +54       * Creates a location consisting of a file name but no line number or
    +55       * column number.
    +56       *
    +57       * @param fileName The name of the file. May be <code>null</code>,
    +58       *                 in which case the location is equivalent to
    +59       *                 {@link #UNKNOWN_LOCATION UNKNOWN_LOCATION}.
    +60       */
    +61      public Location(String fileName) {
    +62          this(fileName, 0, 0);
    +63      }
    +64  
    +65      /**
    +66       * Creates a location from the SAX locator using the system ID as
    +67       * the filename.
    +68       *
    +69       * @param loc Must not be <code>null</code>.
    +70       *
    +71       * @since Ant 1.6
    +72       */
    +73      public Location(Locator loc) {
    +74          this(loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber());
    +75      }
    +76  
    +77      /**
    +78       * Creates a location consisting of a file name, line number and
    +79       * column number.
    +80       *
    +81       * @param fileName The name of the file. May be <code>null</code>,
    +82       *                 in which case the location is equivalent to
    +83       *                 {@link #UNKNOWN_LOCATION UNKNOWN_LOCATION}.
    +84       *
    +85       * @param lineNumber Line number within the file. Use 0 for unknown
    +86       *                   positions within a file.
    +87       * @param columnNumber Column number within the line.
    +88       */
    +89      public Location(String fileName, int lineNumber, int columnNumber) {
    +90          if (fileName != null && fileName.startsWith("file:")) {
    +91              this.fileName = FILE_UTILS.fromURI(fileName);
    +92          } else {
    +93              this.fileName = fileName;
    +94          }
    +95          this.lineNumber = lineNumber;
    +96          this.columnNumber = columnNumber;
    +97      }
    +98  
    +99      /**
    +100      * @return the filename portion of the location
    +101      * @since Ant 1.6
    +102      */
    +103     public String getFileName() {
    +104         return fileName;
    +105     }
    +106 
    +107     /**
    +108      * @return the line number
    +109      * @since Ant 1.6
    +110      */
    +111     public int getLineNumber() {
    +112         return lineNumber;
    +113     }
    +114 
    +115     /**
    +116      * @return the column number
    +117      * @since Ant 1.7
    +118      */
    +119     public int getColumnNumber() {
    +120         return columnNumber;
    +121     }
    +122 
    +123     /**
    +124      * Returns the file name, line number, a colon and a trailing space.
    +125      * An error message can be appended easily. For unknown locations, an
    +126      * empty string is returned.
    +127      *
    +128      * @return a String of the form <code>"fileName:lineNumber: "</code>
    +129      *         if both file name and line number are known,
    +130      *         <code>"fileName: "</code> if only the file name is known,
    +131      *         and the empty string for unknown locations.
    +132      */
    +133     public String toString() {
    +134         StringBuffer buf = new StringBuffer();
    +135 
    +136         if (fileName != null) {
    +137             buf.append(fileName);
    +138 
    +139             if (lineNumber != 0) {
    +140                 buf.append(":");
    +141                 buf.append(lineNumber);
    +142             }
    +143 
    +144             buf.append(": ");
    +145         }
    +146 
    +147         return buf.toString();
    +148     }
    +149 
    +150     /**
    +151      * Equality operation.
    +152      * @param other the object to compare to.
    +153      * @return true if the other object contains the same information
    +154      *              as this object.
    +155      * @since Ant 1.6.3
    +156      */
    +157     public boolean equals(Object other) {
    +158         if (this == other) {
    +159             return true;
    +160         }
    +161         if (other == null) {
    +162             return false;
    +163         }
    +164         if (!(other.getClass() == getClass())) {
    +165             return false;
    +166         }
    +167         return toString().equals(other.toString());
    +168     }
    +169 
    +170     /**
    +171      * Hash operation.
    +172      * @return a hash code value for this location.
    +173      * @since Ant 1.6.3
    +174      */
    +175     public int hashCode() {
    +176         return toString().hashCode();
    +177     }
    +178 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/PathTokenizer.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/PathTokenizer.html new file mode 100644 index 000000000..343aacfb2 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/PathTokenizer.html @@ -0,0 +1,178 @@ + + + +PathTokenizer xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant;
    +19  
    +20  import java.io.File;
    +21  import java.util.NoSuchElementException;
    +22  import java.util.StringTokenizer;
    +23  import org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition.Os;
    +24  
    +25  /**
    +26   * A Path tokenizer takes a path and returns the components that make up
    +27   * that path.
    +28   *
    +29   * The path can use path separators of either ':' or ';' and file separators
    +30   * of either '/' or '\'.
    +31   *
    +32   */
    +33  public class PathTokenizer {
    +34      /**
    +35       * A tokenizer to break the string up based on the ':' or ';' separators.
    +36       */
    +37      private StringTokenizer tokenizer;
    +38  
    +39      /**
    +40       * A String which stores any path components which have been read ahead
    +41       * due to DOS filesystem compensation.
    +42       */
    +43      private String lookahead = null;
    +44  
    +45      /**
    +46       * A boolean that determines if we are running on Novell NetWare, which
    +47       * exhibits slightly different path name characteristics (multi-character
    +48       * volume / drive names)
    +49       */
    +50      private boolean onNetWare = Os.isFamily("netware");
    +51  
    +52      /**
    +53       * Flag to indicate whether or not we are running on a platform with a
    +54       * DOS style filesystem
    +55       */
    +56      private boolean dosStyleFilesystem;
    +57  
    +58      /**
    +59       * Constructs a path tokenizer for the specified path.
    +60       *
    +61       * @param path The path to tokenize. Must not be <code>null</code>.
    +62       */
    +63      public PathTokenizer(String path) {
    +64          if (onNetWare) {
    +65              // For NetWare, use the boolean=true mode, so we can use delimiter
    +66              // information to make a better decision later.
    +67              tokenizer = new StringTokenizer(path, ":;", true);
    +68          } else {
    +69              // on Windows and Unix, we can ignore delimiters and still have
    +70              // enough information to tokenize correctly.
    +71              tokenizer = new StringTokenizer(path, ":;", false);
    +72          }
    +73          dosStyleFilesystem = File.pathSeparatorChar == ';';
    +74      }
    +75  
    +76      /**
    +77       * Tests if there are more path elements available from this tokenizer's
    +78       * path. If this method returns <code>true</code>, then a subsequent call
    +79       * to nextToken will successfully return a token.
    +80       *
    +81       * @return <code>true</code> if and only if there is at least one token
    +82       * in the string after the current position; <code>false</code> otherwise.
    +83       */
    +84      public boolean hasMoreTokens() {
    +85          if (lookahead != null) {
    +86              return true;
    +87          }
    +88  
    +89          return tokenizer.hasMoreTokens();
    +90      }
    +91  
    +92      /**
    +93       * Returns the next path element from this tokenizer.
    +94       *
    +95       * @return the next path element from this tokenizer.
    +96       *
    +97       * @exception NoSuchElementException if there are no more elements in this
    +98       *            tokenizer's path.
    +99       */
    +100     public String nextToken() throws NoSuchElementException {
    +101         String token = null;
    +102         if (lookahead != null) {
    +103             token = lookahead;
    +104             lookahead = null;
    +105         } else {
    +106             token = tokenizer.nextToken().trim();
    +107         }
    +108 
    +109         if (!onNetWare) {
    +110             if (token.length() == 1 && Character.isLetter(token.charAt(0))
    +111                                     && dosStyleFilesystem
    +112                                     && tokenizer.hasMoreTokens()) {
    +113                 // we are on a dos style system so this path could be a drive
    +114                 // spec. We look at the next token
    +115                 String nextToken = tokenizer.nextToken().trim();
    +116                 if (nextToken.startsWith("\\") || nextToken.startsWith("/")) {
    +117                     // we know we are on a DOS style platform and the next path
    +118                     // starts with a slash or backslash, so we know this is a
    +119                     // drive spec
    +120                     token += ":" + nextToken;
    +121                 } else {
    +122                     // store the token just read for next time
    +123                     lookahead = nextToken;
    +124                 }
    +125             }
    +126         } else {
    +127             // we are on NetWare, tokenizing is handled a little differently,
    +128             // due to the fact that NetWare has multiple-character volume names.
    +129             if (token.equals(File.pathSeparator) || token.equals(":")) {
    +130                 // ignore ";" and get the next token
    +131                 token = tokenizer.nextToken().trim();
    +132             }
    +133 
    +134             if (tokenizer.hasMoreTokens()) {
    +135                 // this path could be a drive spec, so look at the next token
    +136                 String nextToken = tokenizer.nextToken().trim();
    +137 
    +138                 // make sure we aren't going to get the path separator next
    +139                 if (!nextToken.equals(File.pathSeparator)) {
    +140                     if (nextToken.equals(":")) {
    +141                         if (!token.startsWith("/") && !token.startsWith("\\")
    +142                             && !token.startsWith(".")
    +143                             && !token.startsWith("..")) {
    +144                             // it indeed is a drive spec, get the next bit
    +145                             String oneMore = tokenizer.nextToken().trim();
    +146                             if (!oneMore.equals(File.pathSeparator)) {
    +147                                 token += ":" + oneMore;
    +148                             } else {
    +149                                 token += ":";
    +150                                 lookahead = oneMore;
    +151                             }
    +152                         }
    +153                         // implicit else: ignore the ':' since we have either a
    +154                         // UNIX or a relative path
    +155                     } else {
    +156                         // store the token just read for next time
    +157                         lookahead = nextToken;
    +158                     }
    +159                 }
    +160             }
    +161         }
    +162         return token;
    +163     }
    +164 }
    +165 
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/ProjectComponent.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/ProjectComponent.html new file mode 100644 index 000000000..a37a4c811 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/ProjectComponent.html @@ -0,0 +1,174 @@ + + + +ProjectComponent xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant;
    +19  
    +20  /**
    +21   * Base class for components of a project, including tasks and data types. Provides common facilities.
    +22   *
    +23   */
    +24  public abstract class ProjectComponent implements Cloneable {
    +25  
    +26  //    // CheckStyle:VisibilityModifier OFF - bc
    +27  //    /**
    +28  //     * Project object of this component.
    +29  //     * @deprecated since 1.6.x.
    +30  //     *             You should not be directly accessing this variable directly.
    +31  //     *             You should access project object via the getProject()
    +32  //     *             or setProject() accessor/mutators.
    +33  //     */
    +34  //    protected Project project;
    +35      /**
    +36       * Location within the build file of this task definition.
    +37       *
    +38       * @deprecated since 1.6.x. You should not be accessing this variable directly. Please use the
    +39       * {@link #getLocation()} method.
    +40       */
    +41      protected Location location = Location.UNKNOWN_LOCATION;
    +42  
    +43      /**
    +44       * Description of this component, if any.
    +45       *
    +46       * @deprecated since 1.6.x. You should not be accessing this variable directly.
    +47       */
    +48      protected String description;
    +49      // CheckStyle:VisibilityModifier ON
    +50  
    +51      /**
    +52       * Sole constructor.
    +53       */
    +54      public ProjectComponent() {
    +55      }
    +56  
    +57  //    /**
    +58  //     * Sets the project object of this component. This method is used by
    +59  //     * Project when a component is added to it so that the component has
    +60  //     * access to the functions of the project. It should not be used
    +61  //     * for any other purpose.
    +62  //     *
    +63  //     * @param project Project in whose scope this component belongs.
    +64  //     *                Must not be <code>null</code>.
    +65  //     */
    +66  //    public void setProject(Project project) {
    +67  //        this.project = project;
    +68  //    }
    +69  //
    +70  //    /**
    +71  //     * Returns the project to which this component belongs.
    +72  //     *
    +73  //     * @return the components's project.
    +74  //     */
    +75  //    public Project getProject() {
    +76  //        return project;
    +77  //    }
    +78      /**
    +79       * Returns the file/location where this task was defined.
    +80       *
    +81       * @return the file/location where this task was defined. Should not return <code>null</code>.
    +82       * Location.UNKNOWN_LOCATION is used for unknown locations.
    +83       *
    +84       * @see Location#UNKNOWN_LOCATION
    +85       */
    +86      public Location getLocation() {
    +87          return location;
    +88      }
    +89  
    +90      /**
    +91       * Sets the file/location where this task was defined.
    +92       *
    +93       * @param location The file/location where this task was defined. Should not be <code>null</code>--use
    +94       * Location.UNKNOWN_LOCATION if the location isn't known.
    +95       *
    +96       * @see Location#UNKNOWN_LOCATION
    +97       */
    +98      public void setLocation(Location location) {
    +99          this.location = location;
    +100     }
    +101 
    +102     /**
    +103      * Sets a description of the current action. This may be used for logging purposes.
    +104      *
    +105      * @param desc Description of the current action. May be <code>null</code>, indicating that no description is
    +106      * available.
    +107      *
    +108      */
    +109     public void setDescription(String desc) {
    +110         description = desc;
    +111     }
    +112 
    +113     /**
    +114      * Returns the description of the current action.
    +115      *
    +116      * @return the description of the current action, or <code>null</code> if no description is available.
    +117      */
    +118     public String getDescription() {
    +119         return description;
    +120     }
    +121 
    +122     /**
    +123      * Logs a message with the default (INFO) priority.
    +124      *
    +125      * @param msg The message to be logged. Should not be <code>null</code>.
    +126      */
    +127     public void log(String msg) {
    +128 //        log(msg, Project.MSG_INFO);
    +129     }
    +130 
    +131     /**
    +132      * Logs a message with the given priority.
    +133      *
    +134      * @param msg The message to be logged. Should not be <code>null</code>.
    +135      * @param msgLevel the message priority at which this message is to be logged.
    +136      */
    +137     public void log(String msg, int msgLevel) {
    +138 //        if (getProject() != null) {
    +139 //            getProject().log(msg, msgLevel);
    +140 //        } else {
    +141 //            // 'reasonable' default, if the component is used without
    +142 //            // a Project ( for example as a standalone Bean ).
    +143 //            // Most ant components can be used this way.
    +144 //            if (msgLevel <= Project.MSG_INFO) {
    +145 //                System.err.println(msg);
    +146 //            }
    +147 //        }
    +148     }
    +149 
    +150     /**
    +151      * @since Ant 1.7
    +152      * @return a shallow copy of this projectcomponent.
    +153      * @throws CloneNotSupportedException does not happen, but is declared to allow subclasses to do so.
    +154      */
    +155     public Object clone() throws CloneNotSupportedException {
    +156         ProjectComponent pc = (ProjectComponent) super.clone();
    +157         pc.setLocation(getLocation());
    +158         //pc.setProject(getProject());
    +159         return pc;
    +160     }
    +161 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/Locator.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/Locator.html new file mode 100644 index 000000000..1ab5f62cd --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/Locator.html @@ -0,0 +1,543 @@ + + + +Locator xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.launch;
    +19  
    +20  import java.net.MalformedURLException;
    +21  import java.net.URL;
    +22  import java.io.File;
    +23  import java.io.FilenameFilter;
    +24  import java.io.ByteArrayOutputStream;
    +25  import java.io.UnsupportedEncodingException;
    +26  import java.text.CharacterIterator;
    +27  import java.text.StringCharacterIterator;
    +28  import java.util.Locale;
    +29  
    +30  import org.owasp.dependencycheck.org.apache.tools.ant.util.FileUtils;
    +31  
    +32  // CheckStyle:LineLengthCheck OFF - urls are long!
    +33  /**
    +34   * The Locator is a utility class which is used to find certain items
    +35   * in the environment.
    +36   *
    +37   * It is used at boot time in the launcher, and cannot make use of any of Ant's other classes.
    +38   *
    +39   * This is a surprisingly brittle piece of code, and has had lots of bugs filed against it.
    +40   * {@link <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42275">running ant off a network share can cause Ant to fail</a>}
    +41   * {@link <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=8031">use File.toURI().toURL().toExternalForm()</a>}
    +42   * {@link <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42222">Locator implementation not encoding URI strings properly: spaces in paths</a>}
    +43   * It also breaks Eclipse 3.3 Betas
    +44   * {@link <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=183283">Exception if installation path has spaces</a>}
    +45   *
    +46   * Be very careful when making changes to this class, as a break will upset a lot of people.
    +47   * @since Ant 1.6
    +48   */
    +49  // CheckStyle:LineLengthCheck ON - urls are long!
    +50  public final class Locator {
    +51  
    +52      private static final int NIBBLE = 4;
    +53      private static final int NIBBLE_MASK   = 0xF;
    +54  
    +55      private static final int ASCII_SIZE = 128;
    +56  
    +57      private static final int BYTE_SIZE = 256;
    +58  
    +59      private static final int WORD = 16;
    +60  
    +61      private static final int SPACE = 0x20;
    +62      private static final int DEL = 0x7F;
    +63  
    +64      /**
    +65       * encoding used to represent URIs
    +66       */
    +67      public static final String URI_ENCODING = "UTF-8";
    +68      // stolen from org.apache.xerces.impl.XMLEntityManager#getUserDir()
    +69      // of the Xerces-J team
    +70      // which ASCII characters need to be escaped
    +71      private static boolean[] gNeedEscaping = new boolean[ASCII_SIZE];
    +72      // the first hex character if a character needs to be escaped
    +73      private static char[] gAfterEscaping1 = new char[ASCII_SIZE];
    +74      // the second hex character if a character needs to be escaped
    +75      private static char[] gAfterEscaping2 = new char[ASCII_SIZE];
    +76      private static char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
    +77                                       '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    +78      /** Error string used when an invalid uri is seen */
    +79      public static final String ERROR_NOT_FILE_URI
    +80          = "Can only handle valid file: URIs, not ";
    +81  
    +82      // initialize the above 3 arrays
    +83      static {
    +84          for (int i = 0; i < SPACE; i++) {
    +85              gNeedEscaping[i] = true;
    +86              gAfterEscaping1[i] = gHexChs[i >> NIBBLE];
    +87              gAfterEscaping2[i] = gHexChs[i & NIBBLE_MASK];
    +88          }
    +89          gNeedEscaping[DEL] = true;
    +90          gAfterEscaping1[DEL] = '7';
    +91          gAfterEscaping2[DEL] = 'F';
    +92          char[] escChs = {' ', '<', '>', '#', '%', '"', '{', '}',
    +93                           '|', '\\', '^', '~', '[', ']', '`'};
    +94          int len = escChs.length;
    +95          char ch;
    +96          for (int i = 0; i < len; i++) {
    +97              ch = escChs[i];
    +98              gNeedEscaping[ch] = true;
    +99              gAfterEscaping1[ch] = gHexChs[ch >> NIBBLE];
    +100             gAfterEscaping2[ch] = gHexChs[ch & NIBBLE_MASK];
    +101         }
    +102     }
    +103     /**
    +104      * Not instantiable
    +105      */
    +106     private Locator() {
    +107     }
    +108 
    +109     /**
    +110      * Find the directory or jar file the class has been loaded from.
    +111      *
    +112      * @param c the class whose location is required.
    +113      * @return the file or jar with the class or null if we cannot
    +114      *         determine the location.
    +115      *
    +116      * @since Ant 1.6
    +117      */
    +118     public static File getClassSource(Class<?> c) {
    +119         String classResource = c.getName().replace('.', '/') + ".class";
    +120         return getResourceSource(c.getClassLoader(), classResource);
    +121     }
    +122 
    +123     /**
    +124      * Find the directory or jar a given resource has been loaded from.
    +125      *
    +126      * @param c the classloader to be consulted for the source.
    +127      * @param resource the resource whose location is required.
    +128      *
    +129      * @return the file with the resource source or null if
    +130      *         we cannot determine the location.
    +131      *
    +132      * @since Ant 1.6
    +133      */
    +134     public static File getResourceSource(ClassLoader c, String resource) {
    +135         if (c == null) {
    +136             c = Locator.class.getClassLoader();
    +137         }
    +138         URL url = null;
    +139         if (c == null) {
    +140             url = ClassLoader.getSystemResource(resource);
    +141         } else {
    +142             url = c.getResource(resource);
    +143         }
    +144         if (url != null) {
    +145             String u = url.toString();
    +146             try {
    +147                 if (u.startsWith("jar:file:")) {
    +148                     return new File(fromJarURI(u));
    +149                 } else if (u.startsWith("file:")) {
    +150                     int tail = u.indexOf(resource);
    +151                     String dirName = u.substring(0, tail);
    +152                     return new File(fromURI(dirName));
    +153                 }
    +154             } catch (IllegalArgumentException e) {
    +155                 //unable to determine the URI for reasons unknown.
    +156                 return null;
    +157             }
    +158         }
    +159         return null;
    +160     }
    +161 
    +162 
    +163 
    +164     /**
    +165      * Constructs a file path from a <code>file:</code> URI.
    +166      *
    +167      * <p>Will be an absolute path if the given URI is absolute.</p>
    +168      *
    +169      * <p>Prior to Java 1.4,<!-- TODO is JDK version actually relevant? -->
    +170      * swallows '%' that are not followed by two characters.</p>
    +171      *
    +172      * See <a href="http://www.w3.org/TR/xml11/#dt-sysid">dt-sysid</a>
    +173      * which makes some mention of how
    +174      * characters not supported by URI Reference syntax should be escaped.
    +175      *
    +176      * @param uri the URI designating a file in the local filesystem.
    +177      * @return the local file system path for the file.
    +178      * @throws IllegalArgumentException if the URI is malformed or not a legal file: URL
    +179      * @since Ant 1.6
    +180      */
    +181     public static String fromURI(String uri) {
    +182         return fromURIJava13(uri);
    +183         // #buzilla8031: first try Java 1.4.
    +184         // TODO should use java.net.URI now that we can rely on 1.4...
    +185         // but check for UNC-related regressions, e.g. #42275
    +186         // (and remember that \\server\share\file -> file:////server/share/file
    +187         // rather than -> file://server/share/file as it should;
    +188         // fixed only in JDK 7's java.nio.file.Path.toUri)
    +189         // return fromUriJava14(uri);
    +190     }
    +191 
    +192     /**
    +193      * Java1.4+ code to extract the path from the URI.
    +194      * @param uri
    +195      * @return null if a conversion was not possible
    +196      */
    +197     /* currently unused:
    +198     private static String fromUriJava14(String uri) {
    +199         // Also check for properly formed URIs. Ant formerly recommended using
    +200         // nonsense URIs such as "file:./foo.xml" in XML includes. You shouldn't
    +201         // do that (just "foo.xml" is correct) but for compatibility we special-case
    +202         // things when the path is not absolute, and fall back to the old parsing behavior.
    +203         if (uri.startsWith("file:/")) {
    +204             try {
    +205                 File f = new File(URI.create(encodeURI(uri)));
    +206                 //bug #42227 forgot to decode before returning
    +207                 return decodeUri(f.getAbsolutePath());
    +208             } catch (IllegalArgumentException e) {
    +209                 // Bad URI, pass this on.
    +210                 // no, this is downgraded to a warning after various
    +211                 // JRE bugs surfaced. Hand off
    +212                 // to our built in code on a failure
    +213                 //throw new IllegalArgumentException(
    +214                 //   "Bad URI " + uri + ":" + e.getMessage(), e);
    +215                 e.printStackTrace();
    +216             } catch (Exception e) {
    +217                 // Unexpected exception? Should not happen.
    +218                 e.printStackTrace();
    +219             }
    +220         }
    +221         return null;
    +222     }
    +223      */
    +224 
    +225     /**
    +226      * @param uri uri to expand
    +227      * @return the decoded URI
    +228      * @since Ant1.7.1
    +229      */
    +230     private static String fromURIJava13(String uri) {
    +231         // Fallback method for Java 1.3 or earlier.
    +232 
    +233         URL url = null;
    +234         try {
    +235             url = new URL(uri);
    +236         } catch (MalformedURLException emYouEarlEx) {
    +237             // Ignore malformed exception
    +238         }
    +239         if (url == null || !("file".equals(url.getProtocol()))) {
    +240             throw new IllegalArgumentException(ERROR_NOT_FILE_URI + uri);
    +241         }
    +242         StringBuffer buf = new StringBuffer(url.getHost());
    +243         if (buf.length() > 0) {
    +244             buf.insert(0, File.separatorChar).insert(0, File.separatorChar);
    +245         }
    +246         String file = url.getFile();
    +247         int queryPos = file.indexOf('?');
    +248         buf.append((queryPos < 0) ? file : file.substring(0, queryPos));
    +249 
    +250         uri = buf.toString().replace('/', File.separatorChar);
    +251 
    +252         if (File.pathSeparatorChar == ';' && uri.startsWith("\\") && uri.length() > 2
    +253             && Character.isLetter(uri.charAt(1)) && uri.lastIndexOf(':') > -1) {
    +254             uri = uri.substring(1);
    +255         }
    +256         String path = null;
    +257         try {
    +258             path = decodeUri(uri);
    +259             //consider adding the current directory. This is not done when
    +260             //the path is a UNC name
    +261             String cwd = System.getProperty("user.dir");
    +262             int posi = cwd.indexOf(':');
    +263             boolean pathStartsWithFileSeparator = path.startsWith(File.separator);
    +264             boolean pathStartsWithUNC = path.startsWith("" + File.separator + File.separator);
    +265             if ((posi > 0) && pathStartsWithFileSeparator && !pathStartsWithUNC) {
    +266                 path = cwd.substring(0, posi + 1) + path;
    +267             }
    +268         } catch (UnsupportedEncodingException exc) {
    +269             // not sure whether this is clean, but this method is
    +270             // declared not to throw exceptions.
    +271             throw new IllegalStateException(
    +272                 "Could not convert URI " + uri + " to path: "
    +273                 + exc.getMessage());
    +274         }
    +275         return path;
    +276     }
    +277 
    +278     /**
    +279      * Crack a JAR URI.
    +280      * This method is public for testing; we may delete it without any warning -it is not part of Ant's stable API.
    +281      * @param uri uri to expand; contains jar: somewhere in it
    +282      * @return the decoded URI
    +283      * @since Ant1.7.1
    +284      */
    +285     public static String fromJarURI(String uri) {
    +286         int pling = uri.indexOf("!/");
    +287         String jarName = uri.substring("jar:".length(), pling);
    +288         return fromURI(jarName);
    +289     }
    +290 
    +291     /**
    +292      * Decodes an Uri with % characters.
    +293      * The URI is escaped
    +294      * @param uri String with the uri possibly containing % characters.
    +295      * @return The decoded Uri
    +296      * @throws UnsupportedEncodingException if UTF-8 is not available
    +297      * @since Ant 1.7
    +298      */
    +299     public static String decodeUri(String uri) throws UnsupportedEncodingException {
    +300         if (uri.indexOf('%') == -1) {
    +301             return uri;
    +302         }
    +303         ByteArrayOutputStream sb = new ByteArrayOutputStream(uri.length());
    +304         CharacterIterator iter = new StringCharacterIterator(uri);
    +305         for (char c = iter.first(); c != CharacterIterator.DONE;
    +306              c = iter.next()) {
    +307             if (c == '%') {
    +308                 char c1 = iter.next();
    +309                 if (c1 != CharacterIterator.DONE) {
    +310                     int i1 = Character.digit(c1, WORD);
    +311                     char c2 = iter.next();
    +312                     if (c2 != CharacterIterator.DONE) {
    +313                         int i2 = Character.digit(c2, WORD);
    +314                         sb.write((char) ((i1 << NIBBLE) + i2));
    +315                     }
    +316                 }
    +317             } else if (c >= 0x0000 && c < 0x0080) {
    +318                 sb.write(c);
    +319             } else { // #50543
    +320                 byte[] bytes = String.valueOf(c).getBytes(URI_ENCODING);
    +321                 sb.write(bytes, 0, bytes.length);
    +322             }
    +323         }
    +324         return sb.toString(URI_ENCODING);
    +325     }
    +326 
    +327     /**
    +328      * Encodes an Uri with % characters.
    +329      * The URI is escaped
    +330      * @param path String to encode.
    +331      * @return The encoded string, according to URI norms
    +332      * @throws UnsupportedEncodingException if UTF-8 is not available
    +333      * @since Ant 1.7
    +334      */
    +335     public static String encodeURI(String path) throws UnsupportedEncodingException {
    +336         int i = 0;
    +337         int len = path.length();
    +338         int ch = 0;
    +339         StringBuffer sb = null;
    +340         for (; i < len; i++) {
    +341             ch = path.charAt(i);
    +342             // if it's not an ASCII character, break here, and use UTF-8 encoding
    +343             if (ch >= ASCII_SIZE) {
    +344                 break;
    +345             }
    +346             if (gNeedEscaping[ch]) {
    +347                 if (sb == null) {
    +348                     sb = new StringBuffer(path.substring(0, i));
    +349                 }
    +350                 sb.append('%');
    +351                 sb.append(gAfterEscaping1[ch]);
    +352                 sb.append(gAfterEscaping2[ch]);
    +353                 // record the fact that it's escaped
    +354             } else if (sb != null) {
    +355                 sb.append((char) ch);
    +356             }
    +357         }
    +358 
    +359         // we saw some non-ascii character
    +360         if (i < len) {
    +361             if (sb == null) {
    +362                 sb = new StringBuffer(path.substring(0, i));
    +363             }
    +364             // get UTF-8 bytes for the remaining sub-string
    +365             byte[] bytes = null;
    +366             byte b;
    +367             bytes = path.substring(i).getBytes(URI_ENCODING);
    +368             len = bytes.length;
    +369 
    +370             // for each byte
    +371             for (i = 0; i < len; i++) {
    +372                 b = bytes[i];
    +373                 // for non-ascii character: make it positive, then escape
    +374                 if (b < 0) {
    +375                     ch = b + BYTE_SIZE;
    +376                     sb.append('%');
    +377                     sb.append(gHexChs[ch >> NIBBLE]);
    +378                     sb.append(gHexChs[ch & NIBBLE_MASK]);
    +379                 } else if (gNeedEscaping[b]) {
    +380                     sb.append('%');
    +381                     sb.append(gAfterEscaping1[b]);
    +382                     sb.append(gAfterEscaping2[b]);
    +383                 } else {
    +384                     sb.append((char) b);
    +385                 }
    +386             }
    +387         }
    +388         return sb == null ? path : sb.toString();
    +389     }
    +390 
    +391     /**
    +392      * Convert a File to a URL.
    +393      * File.toURL() does not encode characters like #.
    +394      * File.toURI() has been introduced in java 1.4, so
    +395      * Ant cannot use it (except by reflection) <!-- TODO no longer true -->
    +396      * FileUtils.toURI() cannot be used by Locator.java
    +397      * Implemented this way.
    +398      * File.toURL() adds file: and changes '\' to '/' for dos OSes
    +399      * encodeURI converts characters like ' ' and '#' to %DD
    +400      * @param file the file to convert
    +401      * @return URL the converted File
    +402      * @throws MalformedURLException on error
    +403      * @deprecated since 1.9, use {@link FileUtils#getFileURL(File)}
    +404      */
    +405     @Deprecated
    +406     public static URL fileToURL(File file)
    +407         throws MalformedURLException {
    +408         return new URL(file.toURI().toASCIIString());
    +409     }
    +410 
    +411     /**
    +412      * Get the File necessary to load the Sun compiler tools. If the classes
    +413      * are available to this class, then no additional URL is required and
    +414      * null is returned. This may be because the classes are explicitly in the
    +415      * class path or provided by the JVM directly.
    +416      *
    +417      * @return the tools jar as a File if required, null otherwise.
    +418      */
    +419     public static File getToolsJar() {
    +420         // firstly check if the tools jar is already in the classpath
    +421         boolean toolsJarAvailable = false;
    +422         try {
    +423             // just check whether this throws an exception
    +424             Class.forName("com.sun.tools.javac.Main");
    +425             toolsJarAvailable = true;
    +426         } catch (Exception e) {
    +427             try {
    +428                 Class.forName("sun.tools.javac.Main");
    +429                 toolsJarAvailable = true;
    +430             } catch (Exception e2) {
    +431                 // ignore
    +432             }
    +433         }
    +434         if (toolsJarAvailable) {
    +435             return null;
    +436         }
    +437         // couldn't find compiler - try to find tools.jar
    +438         // based on java.home setting
    +439         String libToolsJar
    +440             = File.separator + "lib" + File.separator + "tools.jar";
    +441         String javaHome = System.getProperty("java.home");
    +442         File toolsJar = new File(javaHome + libToolsJar);
    +443         if (toolsJar.exists()) {
    +444             // Found in java.home as given
    +445             return toolsJar;
    +446         }
    +447         if (javaHome.toLowerCase(Locale.ENGLISH).endsWith(File.separator + "jre")) {
    +448             javaHome = javaHome.substring(
    +449                 0, javaHome.length() - "/jre".length());
    +450             toolsJar = new File(javaHome + libToolsJar);
    +451         }
    +452         if (!toolsJar.exists()) {
    +453             System.out.println("Unable to locate tools.jar. "
    +454                  + "Expected to find it in " + toolsJar.getPath());
    +455             return null;
    +456         }
    +457         return toolsJar;
    +458     }
    +459 
    +460     /**
    +461      * Get an array of URLs representing all of the jar files in the
    +462      * given location. If the location is a file, it is returned as the only
    +463      * element of the array. If the location is a directory, it is scanned for
    +464      * jar files.
    +465      *
    +466      * @param location the location to scan for Jars.
    +467      *
    +468      * @return an array of URLs for all jars in the given location.
    +469      *
    +470      * @exception MalformedURLException if the URLs for the jars cannot be
    +471      *            formed.
    +472      */
    +473     public static URL[] getLocationURLs(File location)
    +474          throws MalformedURLException {
    +475         return getLocationURLs(location, new String[]{".jar"});
    +476     }
    +477 
    +478     /**
    +479      * Get an array of URLs representing all of the files of a given set of
    +480      * extensions in the given location. If the location is a file, it is
    +481      * returned as the only element of the array. If the location is a
    +482      * directory, it is scanned for matching files.
    +483      *
    +484      * @param location the location to scan for files.
    +485      * @param extensions an array of extension that are to match in the
    +486      *        directory search.
    +487      *
    +488      * @return an array of URLs of matching files.
    +489      * @exception MalformedURLException if the URLs for the files cannot be
    +490      *            formed.
    +491      */
    +492     public static URL[] getLocationURLs(File location,
    +493                                         final String[] extensions)
    +494          throws MalformedURLException {
    +495         URL[] urls = new URL[0];
    +496 
    +497         if (!location.exists()) {
    +498             return urls;
    +499         }
    +500         if (!location.isDirectory()) {
    +501             urls = new URL[1];
    +502             String path = location.getPath();
    +503             String littlePath = path.toLowerCase(Locale.ENGLISH);
    +504             for (int i = 0; i < extensions.length; ++i) {
    +505                 if (littlePath.endsWith(extensions[i])) {
    +506                     urls[0] = fileToURL(location);
    +507                     break;
    +508                 }
    +509             }
    +510             return urls;
    +511         }
    +512         File[] matches = location.listFiles(
    +513             new FilenameFilter() {
    +514                 public boolean accept(File dir, String name) {
    +515                     String littleName = name.toLowerCase(Locale.ENGLISH);
    +516                     for (int i = 0; i < extensions.length; ++i) {
    +517                         if (littleName.endsWith(extensions[i])) {
    +518                             return true;
    +519                         }
    +520                     }
    +521                     return false;
    +522                 }
    +523             });
    +524         urls = new URL[matches.length];
    +525         for (int i = 0; i < matches.length; ++i) {
    +526             urls[i] = fileToURL(matches[i]);
    +527         }
    +528         return urls;
    +529     }
    +530 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/package-frame.html new file mode 100644 index 000000000..02ce443fd --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/package-frame.html @@ -0,0 +1,24 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.launch + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant.launch +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/package-summary.html new file mode 100644 index 000000000..0db967be9 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/launch/package-summary.html @@ -0,0 +1,69 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.launch + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant.launch

    + +
    + org.owasp.dependencycheck.org.apache.tools.ant +
    org.owasp.dependencycheck.utils
    + + + + + + + + + + +
    Class Summary
    + Locator +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/package-frame.html new file mode 100644 index 000000000..f4c926429 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/package-frame.html @@ -0,0 +1,39 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/package-summary.html new file mode 100644 index 000000000..94b859c27 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/package-summary.html @@ -0,0 +1,94 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary
    + BuildException +
    + DirectoryScanner +
    + FileScanner +
    + Location +
    + PathTokenizer +
    + ProjectComponent +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/Condition.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/Condition.html new file mode 100644 index 000000000..8248fe820 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/Condition.html @@ -0,0 +1,48 @@ + + + +Condition xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition;
    +20  
    +21  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +22  
    +23  /**
    +24   * Interface for conditions to use inside the &lt;condition&gt; task.
    +25   *
    +26   */
    +27  public interface Condition {
    +28      /**
    +29       * Is this condition true?
    +30       * @return true if the condition is true
    +31       * @exception BuildException if an error occurs
    +32       */
    +33      boolean eval() throws BuildException;
    +34  }
    +35  
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/Os.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/Os.html new file mode 100644 index 000000000..47fa4b00d --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/Os.html @@ -0,0 +1,334 @@ + + + +Os xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition;
    +20  
    +21  import java.util.Locale;
    +22  
    +23  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +24  
    +25  /**
    +26   * Condition that tests the OS type.
    +27   *
    +28   * @since Ant 1.4
    +29   */
    +30  public class Os implements Condition {
    +31      private static final String OS_NAME =
    +32          System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
    +33      private static final String OS_ARCH =
    +34          System.getProperty("os.arch").toLowerCase(Locale.ENGLISH);
    +35      private static final String OS_VERSION =
    +36          System.getProperty("os.version").toLowerCase(Locale.ENGLISH);
    +37      private static final String PATH_SEP =
    +38          System.getProperty("path.separator");
    +39  
    +40      /**
    +41       * OS family to look for
    +42       */
    +43      private String family;
    +44      /**
    +45       * Name of OS
    +46       */
    +47      private String name;
    +48      /**
    +49       * version of OS
    +50       */
    +51      private String version;
    +52      /**
    +53       * OS architecture
    +54       */
    +55      private String arch;
    +56      /**
    +57       * OS family that can be tested for. {@value}
    +58       */
    +59      public static final String FAMILY_WINDOWS = "windows";
    +60      /**
    +61       * OS family that can be tested for. {@value}
    +62       */
    +63      public static final String FAMILY_9X = "win9x";
    +64      /**
    +65       * OS family that can be tested for. {@value}
    +66       */
    +67      public static final String FAMILY_NT = "winnt";
    +68      /**
    +69       * OS family that can be tested for. {@value}
    +70       */
    +71      public static final String FAMILY_OS2 = "os/2";
    +72      /**
    +73       * OS family that can be tested for. {@value}
    +74       */
    +75      public static final String FAMILY_NETWARE = "netware";
    +76      /**
    +77       * OS family that can be tested for. {@value}
    +78       */
    +79      public static final String FAMILY_DOS = "dos";
    +80      /**
    +81       * OS family that can be tested for. {@value}
    +82       */
    +83      public static final String FAMILY_MAC = "mac";
    +84      /**
    +85       * OS family that can be tested for. {@value}
    +86       */
    +87      public static final String FAMILY_TANDEM = "tandem";
    +88      /**
    +89       * OS family that can be tested for. {@value}
    +90       */
    +91      public static final String FAMILY_UNIX = "unix";
    +92      /**
    +93       * OS family that can be tested for. {@value}
    +94       */
    +95      public static final String FAMILY_VMS = "openvms";
    +96      /**
    +97       * OS family that can be tested for. {@value}
    +98       */
    +99      public static final String FAMILY_ZOS = "z/os";
    +100     /** OS family that can be tested for. {@value} */
    +101     public static final String FAMILY_OS400 = "os/400";
    +102 
    +103     /**
    +104      * OpenJDK is reported to call MacOS X "Darwin"
    +105      * @see https://issues.apache.org/bugzilla/show_bug.cgi?id=44889
    +106      * @see https://issues.apache.org/jira/browse/HADOOP-3318
    +107      */
    +108     private static final String DARWIN = "darwin";
    +109 
    +110     /**
    +111      * Default constructor
    +112      *
    +113      */
    +114     public Os() {
    +115         //default
    +116     }
    +117 
    +118     /**
    +119      * Constructor that sets the family attribute
    +120      * @param family a String value
    +121      */
    +122     public Os(String family) {
    +123         setFamily(family);
    +124     }
    +125 
    +126     /**
    +127      * Sets the desired OS family type
    +128      *
    +129      * @param f      The OS family type desired<br>
    +130      *               Possible values:<br>
    +131      *               <ul>
    +132      *               <li>dos</li>
    +133      *               <li>mac</li>
    +134      *               <li>netware</li>
    +135      *               <li>os/2</li>
    +136      *               <li>tandem</li>
    +137      *               <li>unix</li>
    +138      *               <li>windows</li>
    +139      *               <li>win9x</li>
    +140      *               <li>z/os</li>
    +141      *               <li>os/400</li>
    +142      *               </ul>
    +143      */
    +144     public void setFamily(String f) {
    +145         family = f.toLowerCase(Locale.ENGLISH);
    +146     }
    +147 
    +148     /**
    +149      * Sets the desired OS name
    +150      *
    +151      * @param name   The OS name
    +152      */
    +153     public void setName(String name) {
    +154         this.name = name.toLowerCase(Locale.ENGLISH);
    +155     }
    +156 
    +157     /**
    +158      * Sets the desired OS architecture
    +159      *
    +160      * @param arch   The OS architecture
    +161      */
    +162     public void setArch(String arch) {
    +163         this.arch = arch.toLowerCase(Locale.ENGLISH);
    +164     }
    +165 
    +166     /**
    +167      * Sets the desired OS version
    +168      *
    +169      * @param version   The OS version
    +170      */
    +171     public void setVersion(String version) {
    +172         this.version = version.toLowerCase(Locale.ENGLISH);
    +173     }
    +174 
    +175     /**
    +176      * Determines if the OS on which Ant is executing matches the type of
    +177      * that set in setFamily.
    +178      * @return true if the os matches.
    +179      * @throws BuildException if there is an error.
    +180      * @see Os#setFamily(String)
    +181      */
    +182     public boolean eval() throws BuildException {
    +183         return isOs(family, name, arch, version);
    +184     }
    +185 
    +186     /**
    +187      * Determines if the OS on which Ant is executing matches the
    +188      * given OS family.
    +189      * @param family the family to check for
    +190      * @return true if the OS matches
    +191      * @since 1.5
    +192      */
    +193     public static boolean isFamily(String family) {
    +194         return isOs(family, null, null, null);
    +195     }
    +196 
    +197     /**
    +198      * Determines if the OS on which Ant is executing matches the
    +199      * given OS name.
    +200      *
    +201      * @param name the OS name to check for
    +202      * @return true if the OS matches
    +203      * @since 1.7
    +204      */
    +205     public static boolean isName(String name) {
    +206         return isOs(null, name, null, null);
    +207     }
    +208 
    +209     /**
    +210      * Determines if the OS on which Ant is executing matches the
    +211      * given OS architecture.
    +212      *
    +213      * @param arch the OS architecture to check for
    +214      * @return true if the OS matches
    +215      * @since 1.7
    +216      */
    +217     public static boolean isArch(String arch) {
    +218         return isOs(null, null, arch, null);
    +219     }
    +220 
    +221     /**
    +222      * Determines if the OS on which Ant is executing matches the
    +223      * given OS version.
    +224      *
    +225      * @param version the OS version to check for
    +226      * @return true if the OS matches
    +227      * @since 1.7
    +228      */
    +229     public static boolean isVersion(String version) {
    +230         return isOs(null, null, null, version);
    +231     }
    +232 
    +233     /**
    +234      * Determines if the OS on which Ant is executing matches the
    +235      * given OS family, name, architecture and version
    +236      *
    +237      * @param family   The OS family
    +238      * @param name   The OS name
    +239      * @param arch   The OS architecture
    +240      * @param version   The OS version
    +241      * @return true if the OS matches
    +242      * @since 1.7
    +243      */
    +244     public static boolean isOs(String family, String name, String arch,
    +245                                String version) {
    +246         boolean retValue = false;
    +247 
    +248         if (family != null || name != null || arch != null
    +249             || version != null) {
    +250 
    +251             boolean isFamily = true;
    +252             boolean isName = true;
    +253             boolean isArch = true;
    +254             boolean isVersion = true;
    +255 
    +256             if (family != null) {
    +257 
    +258                 //windows probing logic relies on the word 'windows' in
    +259                 //the OS
    +260                 boolean isWindows = OS_NAME.indexOf(FAMILY_WINDOWS) > -1;
    +261                 boolean is9x = false;
    +262                 boolean isNT = false;
    +263                 if (isWindows) {
    +264                     //there are only four 9x platforms that we look for
    +265                     is9x = (OS_NAME.indexOf("95") >= 0
    +266                             || OS_NAME.indexOf("98") >= 0
    +267                             || OS_NAME.indexOf("me") >= 0
    +268                             //wince isn't really 9x, but crippled enough to
    +269                             //be a muchness. Ant doesnt run on CE, anyway.
    +270                             || OS_NAME.indexOf("ce") >= 0);
    +271                     isNT = !is9x;
    +272                 }
    +273                 if (family.equals(FAMILY_WINDOWS)) {
    +274                     isFamily = isWindows;
    +275                 } else if (family.equals(FAMILY_9X)) {
    +276                     isFamily = isWindows && is9x;
    +277                 } else if (family.equals(FAMILY_NT)) {
    +278                     isFamily = isWindows && isNT;
    +279                 } else if (family.equals(FAMILY_OS2)) {
    +280                     isFamily = OS_NAME.indexOf(FAMILY_OS2) > -1;
    +281                 } else if (family.equals(FAMILY_NETWARE)) {
    +282                     isFamily = OS_NAME.indexOf(FAMILY_NETWARE) > -1;
    +283                 } else if (family.equals(FAMILY_DOS)) {
    +284                     isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE);
    +285                 } else if (family.equals(FAMILY_MAC)) {
    +286                     isFamily = OS_NAME.indexOf(FAMILY_MAC) > -1
    +287                         || OS_NAME.indexOf(DARWIN) > -1;
    +288                 } else if (family.equals(FAMILY_TANDEM)) {
    +289                     isFamily = OS_NAME.indexOf("nonstop_kernel") > -1;
    +290                 } else if (family.equals(FAMILY_UNIX)) {
    +291                     isFamily = PATH_SEP.equals(":")
    +292                         && !isFamily(FAMILY_VMS)
    +293                         && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x")
    +294                             || OS_NAME.indexOf(DARWIN) > -1);
    +295                 } else if (family.equals(FAMILY_ZOS)) {
    +296                     isFamily = OS_NAME.indexOf(FAMILY_ZOS) > -1
    +297                         || OS_NAME.indexOf("os/390") > -1;
    +298                 } else if (family.equals(FAMILY_OS400)) {
    +299                     isFamily = OS_NAME.indexOf(FAMILY_OS400) > -1;
    +300                 } else if (family.equals(FAMILY_VMS)) {
    +301                     isFamily = OS_NAME.indexOf(FAMILY_VMS) > -1;
    +302                 } else {
    +303                     throw new BuildException(
    +304                         "Don\'t know how to detect os family \""
    +305                         + family + "\"");
    +306                 }
    +307             }
    +308             if (name != null) {
    +309                 isName = name.equals(OS_NAME);
    +310             }
    +311             if (arch != null) {
    +312                 isArch = arch.equals(OS_ARCH);
    +313             }
    +314             if (version != null) {
    +315                 isVersion = version.equals(OS_VERSION);
    +316             }
    +317             retValue = isFamily && isName && isArch && isVersion;
    +318         }
    +319         return retValue;
    +320     }
    +321 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/package-frame.html new file mode 100644 index 000000000..dcb206387 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/package-frame.html @@ -0,0 +1,27 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/package-summary.html new file mode 100644 index 000000000..d648c94c2 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/taskdefs/condition/package-summary.html @@ -0,0 +1,74 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition

    + + + + + + + + + + + + + + + +
    Class Summary
    + Condition +
    + Os +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/DataType.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/DataType.html new file mode 100644 index 000000000..72240bfa0 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/DataType.html @@ -0,0 +1,366 @@ + + + +DataType xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types;
    +19  
    +20  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +21  import org.owasp.dependencycheck.org.apache.tools.ant.ProjectComponent;
    +22  
    +23  /**
    +24   * Base class for those classes that can appear inside the build file as stand alone data types.
    +25   *
    +26   * <p>
    +27   * This class handles the common description attribute and provides a default implementation for reference handling and
    +28   * checking for circular references that is appropriate for types that can not be nested inside elements of the same
    +29   * type (i.e. &lt;patternset&gt; but not &lt;path&gt;).</p>
    +30   *
    +31   */
    +32  public abstract class DataType extends ProjectComponent implements Cloneable {
    +33      // CheckStyle:VisibilityModifier OFF
    +34  
    +35      /**
    +36       * Value to the refid attribute.
    +37       *
    +38       * @deprecated since 1.7. The user should not be directly referencing variable. Please use {@link #getRefid}
    +39       * instead.
    +40       */
    +41      protected Reference ref;
    +42  
    +43      /**
    +44       * Are we sure we don't hold circular references?
    +45       *
    +46       * <p>
    +47       * Subclasses are responsible for setting this value to false if we'd need to investigate this condition (usually
    +48       * because a child element has been added that is a subclass of DataType).</p>
    +49       *
    +50       * @deprecated since 1.7. The user should not be directly referencing variable. Please use {@link #setChecked} or
    +51       * {@link #isChecked} instead.
    +52       */
    +53      protected boolean checked = true;
    +54      // CheckStyle:VisibilityModifier ON
    +55  
    +56      /**
    +57       * Has the refid attribute of this element been set?
    +58       *
    +59       * @return true if the refid attribute has been set
    +60       */
    +61      public boolean isReference() {
    +62          return ref != null;
    +63      }
    +64  
    +65      /**
    +66       * Set the value of the refid attribute.
    +67       *
    +68       * <p>
    +69       * Subclasses may need to check whether any other attributes have been set as well or child elements have been
    +70       * created and thus override this method. if they do the must call <code>super.setRefid</code>.</p>
    +71       *
    +72       * @param ref the reference to use
    +73       */
    +74      public void setRefid(final Reference ref) {
    +75          this.ref = ref;
    +76          checked = false;
    +77      }
    +78  
    +79  //    /**
    +80  //     * Gets as descriptive as possible a name used for this datatype instance.
    +81  //     *
    +82  //     * @return <code>String</code> name.
    +83  //     */
    +84  //    protected String getDataTypeName() {
    +85  //        return ComponentHelper.getElementName(getProject(), this, true);
    +86  //    }
    +87  //    /**
    +88  //     * Convenience method.
    +89  //     * @since Ant 1.7
    +90  //     */
    +91  //    protected void dieOnCircularReference() {
    +92  //        dieOnCircularReference(getProject());
    +93  //    }
    +94  //
    +95  //    /**
    +96  //     * Convenience method.
    +97  //     * @param p the Ant Project instance against which to resolve references.
    +98  //     * @since Ant 1.7
    +99  //     */
    +100 //    protected void dieOnCircularReference(Project p) {
    +101 //        if (checked || !isReference()) {
    +102 //            return;
    +103 //        }
    +104 //        dieOnCircularReference(new IdentityStack<Object>(this), p);
    +105 //    }
    +106 //
    +107 //    /**
    +108 //     * Check to see whether any DataType we hold references to is
    +109 //     * included in the Stack (which holds all DataType instances that
    +110 //     * directly or indirectly reference this instance, including this
    +111 //     * instance itself).
    +112 //     *
    +113 //     * <p>If one is included, throw a BuildException created by {@link
    +114 //     * #circularReference circularReference}.</p>
    +115 //     *
    +116 //     * <p>This implementation is appropriate only for a DataType that
    +117 //     * cannot hold other DataTypes as children.</p>
    +118 //     *
    +119 //     * <p>The general contract of this method is that it shouldn't do
    +120 //     * anything if {@link #checked <code>checked</code>} is true and
    +121 //     * set it to true on exit.</p>
    +122 //     * @param stack the stack of references to check.
    +123 //     * @param project the project to use to dereference the references.
    +124 //     * @throws BuildException on error.
    +125 //     */
    +126 //    protected void dieOnCircularReference(final Stack<Object> stack,
    +127 //                                          final Project project)
    +128 //        throws BuildException {
    +129 //
    +130 //        if (checked || !isReference()) {
    +131 //            return;
    +132 //        }
    +133 //        Object o = ref.getReferencedObject(project);
    +134 //
    +135 //        if (o instanceof DataType) {
    +136 //            IdentityStack<Object> id = IdentityStack.getInstance(stack);
    +137 //
    +138 //            if (id.contains(o)) {
    +139 //                throw circularReference();
    +140 //            } else {
    +141 //                id.push(o);
    +142 //                ((DataType) o).dieOnCircularReference(id, project);
    +143 //                id.pop();
    +144 //            }
    +145 //        }
    +146 //        checked = true;
    +147 //    }
    +148 //    /**
    +149 //     * Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.
    +150 //     *
    +151 //     * @param dt the DataType to check.
    +152 //     * @param stk the stack of references to check.
    +153 //     * @param p the project to use to dereference the references.
    +154 //     * @throws BuildException on error.
    +155 //     * @since Ant 1.7
    +156 //     */
    +157 //    public static void invokeCircularReferenceCheck(DataType dt, Stack<Object> stk,
    +158 //            Project p) {
    +159 //        dt.dieOnCircularReference(stk, p);
    +160 //    }
    +161 //
    +162 //    /**
    +163 //     * Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.
    +164 //     *
    +165 //     * <p>
    +166 //     * Pushes dt on the stack, runs dieOnCircularReference and pops it again.</p>
    +167 //     *
    +168 //     * @param dt the DataType to check.
    +169 //     * @param stk the stack of references to check.
    +170 //     * @param p the project to use to dereference the references.
    +171 //     * @throws BuildException on error.
    +172 //     * @since Ant 1.8.0
    +173 //     */
    +174 //    public static void pushAndInvokeCircularReferenceCheck(DataType dt,
    +175 //            Stack<Object> stk,
    +176 //            Project p) {
    +177 //        stk.push(dt);
    +178 //        dt.dieOnCircularReference(stk, p);
    +179 //        stk.pop();
    +180 //    }
    +181 //    /**
    +182 //     * Performs the check for circular references and returns the referenced object.
    +183 //     *
    +184 //     * @return the dereferenced object.
    +185 //     * @throws BuildException if the reference is invalid (circular ref, wrong class, etc).
    +186 //     * @since Ant 1.7
    +187 //     */
    +188 //    protected Object getCheckedRef() {
    +189 //        return getCheckedRef(getProject());
    +190 //    }
    +191 //
    +192 //    /**
    +193 //     * Performs the check for circular references and returns the referenced object.
    +194 //     *
    +195 //     * @param p the Ant Project instance against which to resolve references.
    +196 //     * @return the dereferenced object.
    +197 //     * @throws BuildException if the reference is invalid (circular ref, wrong class, etc).
    +198 //     * @since Ant 1.7
    +199 //     */
    +200 //    protected Object getCheckedRef(Project p) {
    +201 //        return getCheckedRef(getClass(), getDataTypeName(), p);
    +202 //    }
    +203 //
    +204 //    /**
    +205 //     * Performs the check for circular references and returns the referenced object.
    +206 //     *
    +207 //     * @param requiredClass the class that this reference should be a subclass of.
    +208 //     * @param dataTypeName the name of the datatype that the reference should be (error message use only).
    +209 //     * @return the dereferenced object.
    +210 //     * @throws BuildException if the reference is invalid (circular ref, wrong class, etc).
    +211 //     */
    +212 //    protected <T> T getCheckedRef(final Class<T> requiredClass,
    +213 //            final String dataTypeName) {
    +214 //        return getCheckedRef(requiredClass, dataTypeName, getProject());
    +215 //    }
    +216 //
    +217 //    /**
    +218 //     * Performs the check for circular references and returns the referenced object. This version allows the fallback
    +219 //     * Project instance to be specified.
    +220 //     *
    +221 //     * @param requiredClass the class that this reference should be a subclass of.
    +222 //     * @param dataTypeName the name of the datatype that the reference should be (error message use only).
    +223 //     * @param project the fallback Project instance for dereferencing.
    +224 //     * @return the dereferenced object.
    +225 //     * @throws BuildException if the reference is invalid (circular ref, wrong class, etc), or if <code>project</code>
    +226 //     * is <code>null</code>.
    +227 //     * @since Ant 1.7
    +228 //     */
    +229 //    protected <T> T getCheckedRef(final Class<T> requiredClass,
    +230 //            final String dataTypeName, final Project project) {
    +231 //        if (project == null) {
    +232 //            throw new BuildException("No Project specified");
    +233 //        }
    +234 //        dieOnCircularReference(project);
    +235 //        Object o = ref.getReferencedObject(project);
    +236 //        if (!(requiredClass.isAssignableFrom(o.getClass()))) {
    +237 //            log("Class " + o.getClass() + " is not a subclass of " + requiredClass,
    +238 //                    Project.MSG_VERBOSE);
    +239 //            String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName;
    +240 //            throw new BuildException(msg);
    +241 //        }
    +242 //        @SuppressWarnings("unchecked")
    +243 //        final T result = (T) o;
    +244 //        return result;
    +245 //    }
    +246     /**
    +247      * Creates an exception that indicates that refid has to be the only attribute if it is set.
    +248      *
    +249      * @return the exception to throw
    +250      */
    +251     protected BuildException tooManyAttributes() {
    +252         return new BuildException("You must not specify more than one "
    +253                 + "attribute when using refid");
    +254     }
    +255 
    +256     /**
    +257      * Creates an exception that indicates that this XML element must not have child elements if the refid attribute is
    +258      * set.
    +259      *
    +260      * @return the exception to throw
    +261      */
    +262     protected BuildException noChildrenAllowed() {
    +263         return new BuildException("You must not specify nested elements "
    +264                 + "when using refid");
    +265     }
    +266 
    +267     /**
    +268      * Creates an exception that indicates the user has generated a loop of data types referencing each other.
    +269      *
    +270      * @return the exception to throw
    +271      */
    +272     protected BuildException circularReference() {
    +273         return new BuildException("This data type contains a circular "
    +274                 + "reference.");
    +275     }
    +276 
    +277     /**
    +278      * The flag that is used to indicate that circular references have been checked.
    +279      *
    +280      * @return true if circular references have been checked
    +281      */
    +282     protected boolean isChecked() {
    +283         return checked;
    +284     }
    +285 
    +286     /**
    +287      * Set the flag that is used to indicate that circular references have been checked.
    +288      *
    +289      * @param checked if true, if circular references have been checked
    +290      */
    +291     protected void setChecked(final boolean checked) {
    +292         this.checked = checked;
    +293     }
    +294 
    +295     /**
    +296      * get the reference set on this object
    +297      *
    +298      * @return the reference or null
    +299      */
    +300     public Reference getRefid() {
    +301         return ref;
    +302     }
    +303 
    +304     /**
    +305      * check that it is ok to set attributes, i.e that no reference is defined
    +306      *
    +307      * @since Ant 1.6
    +308      * @throws BuildException if not allowed
    +309      */
    +310     protected void checkAttributesAllowed() {
    +311         if (isReference()) {
    +312             throw tooManyAttributes();
    +313         }
    +314     }
    +315 
    +316     /**
    +317      * check that it is ok to add children, i.e that no reference is defined
    +318      *
    +319      * @since Ant 1.6
    +320      * @throws BuildException if not allowed
    +321      */
    +322     protected void checkChildrenAllowed() {
    +323         if (isReference()) {
    +324             throw noChildrenAllowed();
    +325         }
    +326     }
    +327 
    +328     /**
    +329      * Basic DataType toString().
    +330      *
    +331      * @return this DataType formatted as a String.
    +332      */
    +333     public String toString() {
    +334         String d = getDescription();
    +335         //return d == null ? getDataTypeName() : getDataTypeName() + " " + d;
    +336         return d == null ? "DataType" : d;
    +337     }
    +338 
    +339     /**
    +340      * @since Ant 1.7
    +341      * @return a shallow copy of this DataType.
    +342      * @throws CloneNotSupportedException if there is a problem.
    +343      */
    +344     public Object clone() throws CloneNotSupportedException {
    +345         DataType dt = (DataType) super.clone();
    +346         dt.setDescription(getDescription());
    +347         if (getRefid() != null) {
    +348             dt.setRefid(getRefid());
    +349         }
    +350         dt.setChecked(isChecked());
    +351         return dt;
    +352     }
    +353 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/Reference.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/Reference.html new file mode 100644 index 000000000..4d6e2fe3a --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/Reference.html @@ -0,0 +1,139 @@ + + + +Reference xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types;
    +19  
    +20  /**
    +21   * Class to hold a reference to another object in the project.
    +22   *
    +23   */
    +24  public class Reference {
    +25  
    +26      private String refid;
    +27      //private Project project;
    +28  
    +29      /**
    +30       * Create a reference.
    +31       *
    +32       * @deprecated since 1.7. Please use {@link Reference#Reference(Project,String)} instead.
    +33       */
    +34      public Reference() {
    +35      }
    +36  
    +37      /**
    +38       * Create a reference to a named ID.
    +39       *
    +40       * @param id the name of this reference
    +41       * @deprecated since 1.7. Please use {@link Reference#Reference(Project,String)} instead.
    +42       */
    +43      public Reference(String id) {
    +44          setRefId(id);
    +45      }
    +46  //
    +47  //    /**
    +48  //     * Create a reference to a named ID in a particular project.
    +49  //     * @param p the project this reference is associated with
    +50  //     * @param id the name of this reference
    +51  //     * @since Ant 1.6.3
    +52  //     */
    +53  //    public Reference(Project p, String id) {
    +54  //        setRefId(id);
    +55  //        setProject(p);
    +56  //    }
    +57  
    +58      /**
    +59       * Set the reference id. Should not normally be necessary; use {@link Reference#Reference(Project, String)}.
    +60       *
    +61       * @param id the reference id to use
    +62       */
    +63      public void setRefId(String id) {
    +64          refid = id;
    +65      }
    +66  
    +67      /**
    +68       * Get the reference id of this reference.
    +69       *
    +70       * @return the reference id
    +71       */
    +72      public String getRefId() {
    +73          return refid;
    +74      }
    +75  
    +76  //    /**
    +77  //     * Set the associated project. Should not normally be necessary;
    +78  //     * use {@link Reference#Reference(Project,String)}.
    +79  //     * @param p the project to use
    +80  //     * @since Ant 1.6.3
    +81  //     */
    +82  //    public void setProject(Project p) {
    +83  //        this.project = p;
    +84  //    }
    +85  //
    +86  //    /**
    +87  //     * Get the associated project, if any; may be null.
    +88  //     * @return the associated project
    +89  //     * @since Ant 1.6.3
    +90  //     */
    +91  //    public Project getProject() {
    +92  //        return project;
    +93  //    }
    +94  //    /**
    +95  //     * Resolve the reference, using the associated project if
    +96  //     * it set, otherwise use the passed in project.
    +97  //     * @param fallback the fallback project to use if the project attribute of
    +98  //     *                 reference is not set.
    +99  //     * @return the dereferenced object.
    +100 //     * @throws BuildException if the reference cannot be dereferenced.
    +101 //     */
    +102 //    public Object getReferencedObject(Project fallback) throws BuildException {
    +103 //        if (refid == null) {
    +104 //            throw new BuildException("No reference specified");
    +105 //        }
    +106 //
    +107 //        Object o = project == null ? fallback.getReference(refid) : project.getReference(refid);
    +108 //        if (o == null) {
    +109 //            throw new BuildException("Reference " + refid + " not found.");
    +110 //        }
    +111 //        return o;
    +112 //    }
    +113 //    /**
    +114 //     * Resolve the reference, looking in the associated project.
    +115 //     * @see Project#getReference
    +116 //     * @return the dereferenced object.
    +117 //     * @throws BuildException if the project is null or the reference cannot be dereferenced
    +118 //     * @since Ant 1.6.3
    +119 //     */
    +120 //    public Object getReferencedObject() throws BuildException {
    +121 //        if (project == null) {
    +122 //            throw new BuildException("No project set on reference to " + refid);
    +123 //        }
    +124 //        return getReferencedObject(project);
    +125 //    }
    +126 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/Resource.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/Resource.html new file mode 100644 index 000000000..c8db24c55 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/Resource.html @@ -0,0 +1,475 @@ + + + +Resource xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types;
    +19  
    +20  import java.io.IOException;
    +21  import java.io.InputStream;
    +22  import java.io.OutputStream;
    +23  import java.math.BigInteger;
    +24  import java.util.Iterator;
    +25  import java.util.NoSuchElementException;
    +26  import org.owasp.dependencycheck.org.apache.tools.ant.types.resources.FileProvider;
    +27  
    +28  /**
    +29   * Describes a "File-like" resource (File, ZipEntry, etc.).
    +30   *
    +31   * This class is meant to be used by classes needing to record path and date/time information about a file, a zip entry
    +32   * or some similar resource (URL, archive in a version control repository, ...).
    +33   *
    +34   * @since Ant 1.5.2
    +35   * @see org.apache.tools.ant.types.resources.Touchable
    +36   */
    +37  public class Resource extends DataType implements Comparable<Resource>, ResourceCollection {
    +38  
    +39      /**
    +40       * Constant unknown size
    +41       */
    +42      public static final long UNKNOWN_SIZE = -1;
    +43  
    +44      /**
    +45       * Constant unknown datetime for getLastModified
    +46       */
    +47      public static final long UNKNOWN_DATETIME = 0L;
    +48  
    +49      /**
    +50       * Magic number
    +51       */
    +52      protected static final int MAGIC = getMagicNumber("Resource".getBytes());
    +53  
    +54      private static final int NULL_NAME = getMagicNumber("null name".getBytes());
    +55  
    +56      /**
    +57       * Create a "magic number" for use in hashCode calculations.
    +58       *
    +59       * @param seed byte[] to seed with.
    +60       * @return a magic number as int.
    +61       */
    +62      protected static int getMagicNumber(byte[] seed) {
    +63          return new BigInteger(seed).intValue();
    +64      }
    +65  
    +66      private String name = null;
    +67      private Boolean exists = null;
    +68      private Long lastmodified = null;
    +69      private Boolean directory = null;
    +70      private Long size = null;
    +71  
    +72      /**
    +73       * Default constructor.
    +74       */
    +75      public Resource() {
    +76      }
    +77  
    +78      /**
    +79       * Only sets the name.
    +80       *
    +81       * <p>
    +82       * This is a dummy, used for not existing resources.</p>
    +83       *
    +84       * @param name relative path of the resource. Expects &quot;/&quot; to be used as the directory separator.
    +85       */
    +86      public Resource(String name) {
    +87          this(name, false, 0, false);
    +88      }
    +89  
    +90      /**
    +91       * Sets the name, lastmodified flag, and exists flag.
    +92       *
    +93       * @param name relative path of the resource. Expects &quot;/&quot; to be used as the directory separator.
    +94       * @param exists if true, this resource exists.
    +95       * @param lastmodified the last modification time of this resource.
    +96       */
    +97      public Resource(String name, boolean exists, long lastmodified) {
    +98          this(name, exists, lastmodified, false);
    +99      }
    +100 
    +101     /**
    +102      * Sets the name, lastmodified flag, exists flag, and directory flag.
    +103      *
    +104      * @param name relative path of the resource. Expects &quot;/&quot; to be used as the directory separator.
    +105      * @param exists if true the resource exists
    +106      * @param lastmodified the last modification time of the resource
    +107      * @param directory if true, this resource is a directory
    +108      */
    +109     public Resource(String name, boolean exists, long lastmodified, boolean directory) {
    +110         this(name, exists, lastmodified, directory, UNKNOWN_SIZE);
    +111     }
    +112 
    +113     /**
    +114      * Sets the name, lastmodified flag, exists flag, directory flag, and size.
    +115      *
    +116      * @param name relative path of the resource. Expects &quot;/&quot; to be used as the directory separator.
    +117      * @param exists if true the resource exists
    +118      * @param lastmodified the last modification time of the resource
    +119      * @param directory if true, this resource is a directory
    +120      * @param size the size of this resource.
    +121      */
    +122     public Resource(String name, boolean exists, long lastmodified, boolean directory, long size) {
    +123         this.name = name;
    +124         setName(name);
    +125         setExists(exists);
    +126         setLastModified(lastmodified);
    +127         setDirectory(directory);
    +128         setSize(size);
    +129     }
    +130 
    +131     /**
    +132      * Name attribute will contain the path of a file relative to the root directory of its fileset or the recorded path
    +133      * of a zip entry.
    +134      *
    +135      * <p>
    +136      * example for a file with fullpath /var/opt/adm/resource.txt in a file set with root dir /var/opt it will be
    +137      * adm/resource.txt.</p>
    +138      *
    +139      * <p>
    +140      * &quot;/&quot; will be used as the directory separator.</p>
    +141      *
    +142      * @return the name of this resource.
    +143      */
    +144     public String getName() {
    +145         //return isReference() ? ((Resource) getCheckedRef()).getName() : name;
    +146         return name;
    +147     }
    +148 
    +149     /**
    +150      * Set the name of this Resource.
    +151      *
    +152      * @param name relative path of the resource. Expects &quot;/&quot; to be used as the directory separator.
    +153      */
    +154     public void setName(String name) {
    +155         checkAttributesAllowed();
    +156         this.name = name;
    +157     }
    +158 
    +159     /**
    +160      * The exists attribute tells whether a resource exists.
    +161      *
    +162      * @return true if this resource exists.
    +163      */
    +164     public boolean isExists() {
    +165 //        if (isReference()) {
    +166 //            return ((Resource) getCheckedRef()).isExists();
    +167 //        }
    +168         //default true:
    +169         return exists == null || exists.booleanValue();
    +170     }
    +171 
    +172     /**
    +173      * Set the exists attribute.
    +174      *
    +175      * @param exists if true, this resource exists.
    +176      */
    +177     public void setExists(boolean exists) {
    +178         checkAttributesAllowed();
    +179         this.exists = exists ? Boolean.TRUE : Boolean.FALSE;
    +180     }
    +181 
    +182     /**
    +183      * Tells the modification time in milliseconds since 01.01.1970 (the "epoch").
    +184      *
    +185      * @return the modification time, if that is meaningful (e.g. for a file resource which exists); 0 if the resource
    +186      * does not exist, to mirror the behavior of {@link java.io.File#lastModified}; or 0 if the notion of modification
    +187      * time is meaningless for this class of resource (e.g. an inline string)
    +188      */
    +189     public long getLastModified() {
    +190 //        if (isReference()) {
    +191 //            return ((Resource) getCheckedRef()).getLastModified();
    +192 //        }
    +193         if (!isExists() || lastmodified == null) {
    +194             return UNKNOWN_DATETIME;
    +195         }
    +196         long result = lastmodified.longValue();
    +197         return result < UNKNOWN_DATETIME ? UNKNOWN_DATETIME : result;
    +198     }
    +199 
    +200     /**
    +201      * Set the last modification attribute.
    +202      *
    +203      * @param lastmodified the modification time in milliseconds since 01.01.1970.
    +204      */
    +205     public void setLastModified(long lastmodified) {
    +206         checkAttributesAllowed();
    +207         this.lastmodified = new Long(lastmodified);
    +208     }
    +209 
    +210     /**
    +211      * Tells if the resource is a directory.
    +212      *
    +213      * @return boolean flag indicating if the resource is a directory.
    +214      */
    +215     public boolean isDirectory() {
    +216 //        if (isReference()) {
    +217 //            return ((Resource) getCheckedRef()).isDirectory();
    +218 //        }
    +219         //default false:
    +220         return directory != null && directory.booleanValue();
    +221     }
    +222 
    +223     /**
    +224      * Set the directory attribute.
    +225      *
    +226      * @param directory if true, this resource is a directory.
    +227      */
    +228     public void setDirectory(boolean directory) {
    +229         checkAttributesAllowed();
    +230         this.directory = directory ? Boolean.TRUE : Boolean.FALSE;
    +231     }
    +232 
    +233     /**
    +234      * Set the size of this Resource.
    +235      *
    +236      * @param size the size, as a long.
    +237      * @since Ant 1.6.3
    +238      */
    +239     public void setSize(long size) {
    +240         checkAttributesAllowed();
    +241         this.size = new Long(size > UNKNOWN_SIZE ? size : UNKNOWN_SIZE);
    +242     }
    +243 
    +244     /**
    +245      * Get the size of this Resource.
    +246      *
    +247      * @return the size, as a long, 0 if the Resource does not exist (for compatibility with java.io.File), or
    +248      * UNKNOWN_SIZE if not known.
    +249      * @since Ant 1.6.3
    +250      */
    +251     public long getSize() {
    +252 //        if (isReference()) {
    +253 //            return ((Resource) getCheckedRef()).getSize();
    +254 //        }
    +255         return isExists()
    +256                 ? (size != null ? size.longValue() : UNKNOWN_SIZE)
    +257                 : 0L;
    +258     }
    +259 
    +260     /**
    +261      * Clone this Resource.
    +262      *
    +263      * @return copy of this.
    +264      */
    +265     public Object clone() {
    +266         try {
    +267             return super.clone();
    +268         } catch (CloneNotSupportedException e) {
    +269             throw new UnsupportedOperationException(
    +270                     "CloneNotSupportedException for a Resource caught. "
    +271                     + "Derived classes must support cloning.");
    +272         }
    +273     }
    +274 
    +275     /**
    +276      * Delegates to a comparison of names.
    +277      *
    +278      * @param other the object to compare to.
    +279      * @return a negative integer, zero, or a positive integer as this Resource is less than, equal to, or greater than
    +280      * the specified Resource.
    +281      * @since Ant 1.6
    +282      */
    +283     public int compareTo(Resource other) {
    +284 //        if (isReference()) {
    +285 //            return ((Resource) getCheckedRef()).compareTo(other);
    +286 //        }
    +287         return toString().compareTo(other.toString());
    +288     }
    +289 
    +290     /**
    +291      * Implement basic Resource equality.
    +292      *
    +293      * @param other the object to check against.
    +294      * @return true if the specified Object is equal to this Resource.
    +295      * @since Ant 1.7
    +296      */
    +297     public boolean equals(Object other) {
    +298 //        if (isReference()) {
    +299 //            return getCheckedRef().equals(other);
    +300 //        }
    +301         return other != null && other.getClass().equals(getClass())
    +302                 && compareTo((Resource) other) == 0;
    +303     }
    +304 
    +305     /**
    +306      * Get the hash code for this Resource.
    +307      *
    +308      * @return hash code as int.
    +309      * @since Ant 1.7
    +310      */
    +311     public int hashCode() {
    +312 //        if (isReference()) {
    +313 //            return getCheckedRef().hashCode();
    +314 //        }
    +315         String name = getName();
    +316         return MAGIC * (name == null ? NULL_NAME : name.hashCode());
    +317     }
    +318 
    +319     /**
    +320      * Get an InputStream for the Resource.
    +321      *
    +322      * @return an InputStream containing this Resource's content.
    +323      * @throws IOException if unable to provide the content of this Resource as a stream.
    +324      * @throws UnsupportedOperationException if InputStreams are not supported for this Resource type.
    +325      * @since Ant 1.7
    +326      */
    +327     public InputStream getInputStream() throws IOException {
    +328 //        if (isReference()) {
    +329 //            return ((Resource) getCheckedRef()).getInputStream();
    +330 //        }
    +331         throw new UnsupportedOperationException();
    +332     }
    +333 
    +334     /**
    +335      * Get an OutputStream for the Resource.
    +336      *
    +337      * @return an OutputStream to which content can be written.
    +338      * @throws IOException if unable to provide the content of this Resource as a stream.
    +339      * @throws UnsupportedOperationException if OutputStreams are not supported for this Resource type.
    +340      * @since Ant 1.7
    +341      */
    +342     public OutputStream getOutputStream() throws IOException {
    +343 //        if (isReference()) {
    +344 //            return ((Resource) getCheckedRef()).getOutputStream();
    +345 //        }
    +346         throw new UnsupportedOperationException();
    +347     }
    +348 
    +349     /**
    +350      * Fulfill the ResourceCollection contract.
    +351      *
    +352      * @return an Iterator of Resources.
    +353      * @since Ant 1.7
    +354      */
    +355     public Iterator<Resource> iterator() {
    +356         //return isReference() ? ((Resource) getCheckedRef()).iterator()
    +357         //        : new Iterator<Resource>() {
    +358         return new Iterator<Resource>() {
    +359             private boolean done = false;
    +360 
    +361             public boolean hasNext() {
    +362                 return !done;
    +363             }
    +364 
    +365             public Resource next() {
    +366                 if (done) {
    +367                     throw new NoSuchElementException();
    +368                 }
    +369                 done = true;
    +370                 return Resource.this;
    +371             }
    +372 
    +373             public void remove() {
    +374                 throw new UnsupportedOperationException();
    +375             }
    +376         };
    +377     }
    +378 
    +379     /**
    +380      * Fulfill the ResourceCollection contract.
    +381      *
    +382      * @return the size of this ResourceCollection.
    +383      * @since Ant 1.7
    +384      */
    +385     public int size() {
    +386         //return isReference() ? ((Resource) getCheckedRef()).size() : 1;
    +387         return 1;
    +388     }
    +389 
    +390     /**
    +391      * Fulfill the ResourceCollection contract.
    +392      *
    +393      * @return whether this Resource is a FileProvider.
    +394      * @since Ant 1.7
    +395      */
    +396     public boolean isFilesystemOnly() {
    +397 //        return (isReference() && ((Resource) getCheckedRef()).isFilesystemOnly())
    +398 //                || this.as(FileProvider.class) != null;
    +399         return this.as(FileProvider.class) != null;
    +400     }
    +401 
    +402     /**
    +403      * Get the string representation of this Resource.
    +404      *
    +405      * @return this Resource formatted as a String.
    +406      * @since Ant 1.7
    +407      */
    +408     public String toString() {
    +409 //        if (isReference()) {
    +410 //            return getCheckedRef().toString();
    +411 //        }
    +412         String n = getName();
    +413         return n == null ? "(anonymous)" : n;
    +414     }
    +415 
    +416     /**
    +417      * Get a long String representation of this Resource. This typically should be the value of <code>toString()</code>
    +418      * prefixed by a type description.
    +419      *
    +420      * @return this Resource formatted as a long String.
    +421      * @since Ant 1.7
    +422      */
    +423     public final String toLongString() {
    +424 //        return isReference() ? ((Resource) getCheckedRef()).toLongString()
    +425 //            : getDataTypeName() + " \"" + toString() + '"';
    +426         return toString();
    +427     }
    +428 
    +429     /**
    +430      * Overrides the base version.
    +431      *
    +432      * @param r the Reference to set.
    +433      */
    +434     public void setRefid(Reference r) {
    +435         if (name != null
    +436                 || exists != null
    +437                 || lastmodified != null
    +438                 || directory != null
    +439                 || size != null) {
    +440             throw tooManyAttributes();
    +441         }
    +442         super.setRefid(r);
    +443     }
    +444 
    +445     /**
    +446      * Returns a view of this resource that implements the interface given as the argument or null if there is no such
    +447      * view.
    +448      *
    +449      * <p>
    +450      * This allows extension interfaces to be added to resources without growing the number of permutations of
    +451      * interfaces decorators/adapters need to implement.</p>
    +452      *
    +453      * <p>
    +454      * This implementation of the method will return the current instance itself if it can be assigned to the given
    +455      * class.</p>
    +456      *
    +457      * @since Ant 1.8.0
    +458      */
    +459     public <T> T as(Class<T> clazz) {
    +460         return clazz.isAssignableFrom(getClass()) ? clazz.cast(this) : null;
    +461     }
    +462 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/ResourceCollection.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/ResourceCollection.html new file mode 100644 index 000000000..c637598d9 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/ResourceCollection.html @@ -0,0 +1,63 @@ + + + +ResourceCollection xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types;
    +19  
    +20  import java.util.Iterator;
    +21  import org.owasp.dependencycheck.org.apache.tools.ant.types.resources.FileProvider;
    +22  
    +23  /**
    +24   * Interface describing a collection of Resources.
    +25   * @since Ant 1.7
    +26   */
    +27  public interface ResourceCollection extends Iterable<Resource> {
    +28  
    +29      /**
    +30       * Gets the contents of this collection.
    +31       * @return all resources in the collection
    +32       */
    +33      Iterator<Resource> iterator();
    +34  
    +35      /**
    +36       * Learn the number of contained Resources.
    +37       * @return number of elements as int.
    +38       */
    +39      int size();
    +40  
    +41      /**
    +42       * Indicate whether this ResourceCollection is composed entirely of
    +43       * Resources accessible via local filesystem conventions.  If true,
    +44       * all resources returned from this collection should
    +45       * respond with a {@link FileProvider} when asked via {@link Resource#as}.
    +46       * @return whether this is a filesystem-only resource collection.
    +47       */
    +48      boolean isFilesystemOnly();
    +49  
    +50  }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/ResourceFactory.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/ResourceFactory.html new file mode 100644 index 000000000..d32f61f97 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/ResourceFactory.html @@ -0,0 +1,51 @@ + + + +ResourceFactory xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types;
    +19  
    +20  /**
    +21   * this interface should be implemented by classes (Scanners) needing
    +22   * to deliver information about resources.
    +23   *
    +24   * @since Ant 1.5.2
    +25   */
    +26  public interface ResourceFactory {
    +27  
    +28      /**
    +29       * Query a resource (file, zipentry, ...) by name
    +30       *
    +31       * @param name relative path of the resource about which
    +32       * information is sought.  Expects &quot;/&quot; to be used as the
    +33       * directory separator.
    +34       * @return instance of Resource; the exists attribute of Resource
    +35       * will tell whether the sought resource exists
    +36       */
    +37      Resource getResource(String name);
    +38  }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/package-frame.html new file mode 100644 index 000000000..fd7abaf2f --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/package-frame.html @@ -0,0 +1,36 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.types + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant.types +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/package-summary.html new file mode 100644 index 000000000..720c7b498 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/package-summary.html @@ -0,0 +1,89 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.types + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant.types

    + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary
    + DataType +
    + Reference +
    + Resource +
    + ResourceCollection +
    + ResourceFactory +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/Appendable.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/Appendable.html new file mode 100644 index 000000000..5fb9529b0 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/Appendable.html @@ -0,0 +1,48 @@ + + + +Appendable xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types.resources;
    +19  
    +20  import java.io.IOException;
    +21  import java.io.OutputStream;
    +22  
    +23  /**
    +24   * Interface to be implemented by "appendable" resources.
    +25   * @since Ant 1.8
    +26   */
    +27  public interface Appendable {
    +28  
    +29      /**
    +30       * Get an appending OutputStream.
    +31       * @return OutputStream
    +32       * @throws IOException if anything goes wrong
    +33       */
    +34      OutputStream getAppendOutputStream() throws IOException;
    +35  }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/FileProvider.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/FileProvider.html new file mode 100644 index 000000000..f34aa6ecd --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/FileProvider.html @@ -0,0 +1,49 @@ + + + +FileProvider xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.types.resources;
    +20  
    +21  import java.io.File;
    +22  
    +23  /**
    +24   * This is an interface that resources that can provide a file should implement.
    +25   * This is a refactoring of {@link FileResource}, to allow other resources
    +26   * to act as sources of files (and to make components that only support
    +27   * file-based resources from only support FileResource resources.
    +28   * @since Ant 1.8
    +29   */
    +30  public interface FileProvider {
    +31      /**
    +32       * Get the file represented by this Resource.
    +33       * @return the file.
    +34       */
    +35      File getFile();
    +36  }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/FileResource.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/FileResource.html new file mode 100644 index 000000000..5567caa3f --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/FileResource.html @@ -0,0 +1,427 @@ + + + +FileResource xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types.resources;
    +19  
    +20  import java.io.File;
    +21  import java.io.FileInputStream;
    +22  import java.io.FileOutputStream;
    +23  import java.io.IOException;
    +24  import java.io.InputStream;
    +25  import java.io.OutputStream;
    +26  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +27  import org.owasp.dependencycheck.org.apache.tools.ant.types.Reference;
    +28  import org.owasp.dependencycheck.org.apache.tools.ant.types.Resource;
    +29  import org.owasp.dependencycheck.org.apache.tools.ant.types.ResourceFactory;
    +30  import org.owasp.dependencycheck.org.apache.tools.ant.util.FileUtils;
    +31  
    +32  /**
    +33   * A Resource representation of a File.
    +34   *
    +35   * @since Ant 1.7
    +36   */
    +37  public class FileResource extends Resource implements Touchable, FileProvider,
    +38          ResourceFactory, Appendable {
    +39  
    +40      private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
    +41      private static final int NULL_FILE
    +42              = Resource.getMagicNumber("null file".getBytes());
    +43  
    +44      private File file;
    +45      private File baseDir;
    +46  
    +47      /**
    +48       * Default constructor.
    +49       */
    +50      public FileResource() {
    +51      }
    +52  
    +53      /**
    +54       * Construct a new FileResource using the specified basedir and relative name.
    +55       *
    +56       * @param b the basedir as File.
    +57       * @param name the relative filename.
    +58       */
    +59      public FileResource(File b, String name) {
    +60          this.baseDir = b;
    +61          this.file = FILE_UTILS.resolveFile(b, name);
    +62      }
    +63  
    +64      /**
    +65       * Construct a new FileResource from a File.
    +66       *
    +67       * @param f the File represented.
    +68       */
    +69      public FileResource(File f) {
    +70          setFile(f);
    +71      }
    +72  
    +73  //    /**
    +74  //     * Create a new FileResource.
    +75  //     * @param p Project
    +76  //     * @param f File represented
    +77  //     * @since Ant 1.8
    +78  //     */
    +79  //    public FileResource(Project p, File f) {
    +80  //        this(f);
    +81  //        setProject(p);
    +82  //    }
    +83  //
    +84  //    /**
    +85  //     * Constructor for Ant attribute introspection.
    +86  //     * @param p the Project against which to resolve <code>s</code>.
    +87  //     * @param s the absolute or Project-relative filename as a String.
    +88  //     * @see org.apache.tools.ant.IntrospectionHelper
    +89  //     */
    +90  //    public FileResource(Project p, String s) {
    +91  //        this(p, p.resolveFile(s));
    +92  //    }
    +93      /**
    +94       * Set the File for this FileResource.
    +95       *
    +96       * @param f the File to be represented.
    +97       */
    +98      public void setFile(File f) {
    +99          checkAttributesAllowed();
    +100         file = f;
    +101         if (f != null && (getBaseDir() == null || !FILE_UTILS.isLeadingPath(getBaseDir(), f))) {
    +102             setBaseDir(f.getParentFile());
    +103         }
    +104     }
    +105 
    +106     /**
    +107      * Get the file represented by this FileResource.
    +108      *
    +109      * @return the File.
    +110      */
    +111     public File getFile() {
    +112 //        if (isReference()) {
    +113 //            return ((FileResource) getCheckedRef()).getFile();
    +114 //        }
    +115 //        dieOnCircularReference();
    +116         synchronized (this) {
    +117             if (file == null) {
    +118                 //try to resolve file set via basedir/name property setters:
    +119                 File d = getBaseDir();
    +120                 String n = super.getName();
    +121                 if (n != null) {
    +122                     setFile(FILE_UTILS.resolveFile(d, n));
    +123                 }
    +124             }
    +125         }
    +126         return file;
    +127     }
    +128 
    +129     /**
    +130      * Set the basedir for this FileResource.
    +131      *
    +132      * @param b the basedir as File.
    +133      */
    +134     public void setBaseDir(File b) {
    +135         checkAttributesAllowed();
    +136         baseDir = b;
    +137     }
    +138 
    +139     /**
    +140      * Return the basedir to which the name is relative.
    +141      *
    +142      * @return the basedir as File.
    +143      */
    +144     public File getBaseDir() {
    +145 //        if (isReference()) {
    +146 //            return ((FileResource) getCheckedRef()).getBaseDir();
    +147 //        }
    +148 //        dieOnCircularReference();
    +149         return baseDir;
    +150     }
    +151 
    +152     /**
    +153      * Overrides the super version.
    +154      *
    +155      * @param r the Reference to set.
    +156      */
    +157     public void setRefid(Reference r) {
    +158         if (file != null || baseDir != null) {
    +159             throw tooManyAttributes();
    +160         }
    +161         super.setRefid(r);
    +162     }
    +163 
    +164     /**
    +165      * Get the name of this FileResource. If the basedir is set, the name will be relative to that. Otherwise the
    +166      * basename only will be returned.
    +167      *
    +168      * @return the name of this resource.
    +169      */
    +170     public String getName() {
    +171 //        if (isReference()) {
    +172 //            return ((Resource) getCheckedRef()).getName();
    +173 //        }
    +174         File b = getBaseDir();
    +175         return b == null ? getNotNullFile().getName()
    +176                 : FILE_UTILS.removeLeadingPath(b, getNotNullFile());
    +177     }
    +178 
    +179     /**
    +180      * Learn whether this file exists.
    +181      *
    +182      * @return true if this resource exists.
    +183      */
    +184     public boolean isExists() {
    +185 //        return isReference() ? ((Resource) getCheckedRef()).isExists()
    +186 //                : getNotNullFile().exists();
    +187         return getNotNullFile().exists();
    +188     }
    +189 
    +190     /**
    +191      * Get the modification time in milliseconds since 01.01.1970 .
    +192      *
    +193      * @return 0 if the resource does not exist.
    +194      */
    +195     public long getLastModified() {
    +196 //        return isReference()
    +197 //                ? ((Resource) getCheckedRef()).getLastModified()
    +198 //                : getNotNullFile().lastModified();
    +199         return getNotNullFile().lastModified();
    +200     }
    +201 
    +202     /**
    +203      * Learn whether the resource is a directory.
    +204      *
    +205      * @return boolean flag indicating if the resource is a directory.
    +206      */
    +207     public boolean isDirectory() {
    +208 //        return isReference() ? ((Resource) getCheckedRef()).isDirectory()
    +209 //                : getNotNullFile().isDirectory();
    +210         return getNotNullFile().isDirectory();
    +211     }
    +212 
    +213     /**
    +214      * Get the size of this Resource.
    +215      *
    +216      * @return the size, as a long, 0 if the Resource does not exist.
    +217      */
    +218     public long getSize() {
    +219 //        return isReference() ? ((Resource) getCheckedRef()).getSize()
    +220 //                : getNotNullFile().length();
    +221         return getNotNullFile().length();
    +222     }
    +223 
    +224     /**
    +225      * Return an InputStream for reading the contents of this Resource.
    +226      *
    +227      * @return an InputStream object.
    +228      * @throws IOException if an error occurs.
    +229      */
    +230     public InputStream getInputStream() throws IOException {
    +231 //        return isReference()
    +232 //                ? ((Resource) getCheckedRef()).getInputStream()
    +233 //                : new FileInputStream(getNotNullFile());
    +234         return new FileInputStream(getNotNullFile());
    +235     }
    +236 
    +237     /**
    +238      * Get an OutputStream for the Resource.
    +239      *
    +240      * @return an OutputStream to which content can be written.
    +241      * @throws IOException if unable to provide the content of this Resource as a stream.
    +242      * @throws UnsupportedOperationException if OutputStreams are not supported for this Resource type.
    +243      */
    +244     public OutputStream getOutputStream() throws IOException {
    +245 //        if (isReference()) {
    +246 //            return ((FileResource) getCheckedRef()).getOutputStream();
    +247 //        }
    +248         return getOutputStream(false);
    +249     }
    +250 
    +251     /**
    +252      * {@inheritDoc}
    +253      */
    +254     public OutputStream getAppendOutputStream() throws IOException {
    +255 //        if (isReference()) {
    +256 //            return ((FileResource) getCheckedRef()).getAppendOutputStream();
    +257 //        }
    +258         return getOutputStream(true);
    +259     }
    +260 
    +261     private OutputStream getOutputStream(boolean append) throws IOException {
    +262         File f = getNotNullFile();
    +263         if (f.exists()) {
    +264             if (f.isFile() && !append) {
    +265                 f.delete();
    +266             }
    +267         } else {
    +268             File p = f.getParentFile();
    +269             if (p != null && !(p.exists())) {
    +270                 p.mkdirs();
    +271             }
    +272         }
    +273         return append ? new FileOutputStream(f.getAbsolutePath(), true) : new FileOutputStream(f);
    +274     }
    +275 
    +276     /**
    +277      * Compare this FileResource to another Resource.
    +278      *
    +279      * @param another the other Resource against which to compare.
    +280      * @return a negative integer, zero, or a positive integer as this FileResource is less than, equal to, or greater
    +281      * than the specified Resource.
    +282      */
    +283     public int compareTo(Resource another) {
    +284 //        if (isReference()) {
    +285 //            return ((Resource) getCheckedRef()).compareTo(another);
    +286 //        }
    +287         if (this.equals(another)) {
    +288             return 0;
    +289         }
    +290         FileProvider otherFP = another.as(FileProvider.class);
    +291         if (otherFP != null) {
    +292             File f = getFile();
    +293             if (f == null) {
    +294                 return -1;
    +295             }
    +296             File of = otherFP.getFile();
    +297             if (of == null) {
    +298                 return 1;
    +299             }
    +300             return f.compareTo(of);
    +301         }
    +302         return super.compareTo(another);
    +303     }
    +304 
    +305     /**
    +306      * Compare another Object to this FileResource for equality.
    +307      *
    +308      * @param another the other Object to compare.
    +309      * @return true if another is a FileResource representing the same file.
    +310      */
    +311     public boolean equals(Object another) {
    +312         if (this == another) {
    +313             return true;
    +314         }
    +315 //        if (isReference()) {
    +316 //            return getCheckedRef().equals(another);
    +317 //        }
    +318         if (another == null || !(another.getClass().equals(getClass()))) {
    +319             return false;
    +320         }
    +321         FileResource otherfr = (FileResource) another;
    +322         return getFile() == null
    +323                 ? otherfr.getFile() == null
    +324                 : getFile().equals(otherfr.getFile());
    +325     }
    +326 
    +327     /**
    +328      * Get the hash code for this Resource.
    +329      *
    +330      * @return hash code as int.
    +331      */
    +332     public int hashCode() {
    +333 //        if (isReference()) {
    +334 //            return getCheckedRef().hashCode();
    +335 //        }
    +336         return MAGIC * (getFile() == null ? NULL_FILE : getFile().hashCode());
    +337     }
    +338 
    +339     /**
    +340      * Get the string representation of this Resource.
    +341      *
    +342      * @return this FileResource formatted as a String.
    +343      */
    +344     public String toString() {
    +345 //        if (isReference()) {
    +346 //            return getCheckedRef().toString();
    +347 //        }
    +348         if (file == null) {
    +349             return "(unbound file resource)";
    +350         }
    +351         String absolutePath = file.getAbsolutePath();
    +352         return FILE_UTILS.normalize(absolutePath).getAbsolutePath();
    +353     }
    +354 
    +355     /**
    +356      * Fulfill the ResourceCollection contract.
    +357      *
    +358      * @return whether this Resource is a FileResource.
    +359      */
    +360     public boolean isFilesystemOnly() {
    +361 //        if (isReference()) {
    +362 //            return ((FileResource) getCheckedRef()).isFilesystemOnly();
    +363 //        }
    +364 //        dieOnCircularReference();
    +365         return true;
    +366     }
    +367 
    +368     /**
    +369      * Implement the Touchable interface.
    +370      *
    +371      * @param modTime new last modification time.
    +372      */
    +373     public void touch(long modTime) {
    +374 //        if (isReference()) {
    +375 //            ((FileResource) getCheckedRef()).touch(modTime);
    +376 //            return;
    +377 //        }
    +378         if (!getNotNullFile().setLastModified(modTime)) {
    +379             //log("Failed to change file modification time", Project.MSG_WARN);
    +380         }
    +381     }
    +382 
    +383     /**
    +384      * Get the file represented by this FileResource, ensuring it is not null.
    +385      *
    +386      * @return the not-null File.
    +387      * @throws BuildException if file is null.
    +388      */
    +389     protected File getNotNullFile() {
    +390         if (getFile() == null) {
    +391             throw new BuildException("file attribute is null!");
    +392         }
    +393 //        dieOnCircularReference();
    +394         return getFile();
    +395     }
    +396 
    +397     /**
    +398      * Create a new resource that matches a relative or absolute path. If the current instance has a compatible baseDir
    +399      * attribute, it is copied.
    +400      *
    +401      * @param path relative/absolute path to a resource
    +402      * @return a new resource of type FileResource
    +403      * @throws BuildException if desired
    +404      * @since Ant1.8
    +405      */
    +406     public Resource getResource(String path) {
    +407         File newfile = FILE_UTILS.resolveFile(getFile(), path);
    +408         FileResource fileResource = new FileResource(newfile);
    +409         if (FILE_UTILS.isLeadingPath(getBaseDir(), newfile)) {
    +410             fileResource.setBaseDir(getBaseDir());
    +411         }
    +412         return fileResource;
    +413     }
    +414 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/Touchable.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/Touchable.html new file mode 100644 index 000000000..f6cce89db --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/Touchable.html @@ -0,0 +1,45 @@ + + + +Touchable xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types.resources;
    +19  
    +20  /**
    +21   * Interface to be implemented by "touchable" resources;
    +22   * that is, those whose modification time can be altered.
    +23   * @since Ant 1.7
    +24   */
    +25  public interface Touchable {
    +26      /**
    +27       * Method called to "touch" the resource.
    +28       * @param modTime the time to set the modified "field" of the resource,
    +29       *                measured in milliseconds since the epoch.
    +30       */
    +31      void touch(long modTime);
    +32  }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/package-frame.html new file mode 100644 index 000000000..3902aba74 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/package-frame.html @@ -0,0 +1,33 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.types.resources + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant.types.resources +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/package-summary.html new file mode 100644 index 000000000..8e478ccb2 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/resources/package-summary.html @@ -0,0 +1,84 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.types.resources + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant.types.resources

    + + + + + + + + + + + + + + + + + + + + + +
    Class Summary
    + Appendable +
    + FileProvider +
    + FileResource +
    + Touchable +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/FileSelector.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/FileSelector.html new file mode 100644 index 000000000..e61b56aef --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/FileSelector.html @@ -0,0 +1,61 @@ + + + +FileSelector xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors;
    +20  
    +21  import java.io.File;
    +22  
    +23  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +24  
    +25  /**
    +26   * This is the interface to be used by all selectors.
    +27   *
    +28   * @since 1.5
    +29   */
    +30  public interface FileSelector {
    +31  
    +32      /**
    +33       * Method that each selector will implement to create their
    +34       * selection behaviour. If there is a problem with the setup
    +35       * of a selector, it can throw a BuildException to indicate
    +36       * the problem.
    +37       *
    +38       * @param basedir A java.io.File object for the base directory
    +39       * @param filename The name of the file to check
    +40       * @param file A File object for this filename
    +41       * @return whether the file should be selected or not
    +42       * @exception BuildException if the selector was not configured correctly
    +43       */
    +44      boolean isSelected(File basedir, String filename, File file)
    +45              throws BuildException;
    +46  
    +47  }
    +48  
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/SelectorScanner.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/SelectorScanner.html new file mode 100644 index 000000000..7694e0264 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/SelectorScanner.html @@ -0,0 +1,62 @@ + + + +SelectorScanner xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors;
    +19  
    +20  /**
    +21   * An interface used to describe the actions required by any type of
    +22   * directory scanner that supports Selectors.
    +23   *
    +24   * @since 1.5
    +25   */
    +26  public interface SelectorScanner {
    +27      /**
    +28       * Sets the selectors the scanner should use.
    +29       *
    +30       * @param selectors the list of selectors
    +31       */
    +32      void setSelectors(FileSelector[] selectors);
    +33  
    +34      /**
    +35       * Directories which were selected out of a scan.
    +36       *
    +37       * @return list of directories not selected
    +38       */
    +39      String[] getDeselectedDirectories();
    +40  
    +41      /**
    +42       * Files which were selected out of a scan.
    +43       *
    +44       * @return list of files not selected
    +45       */
    +46      String[] getDeselectedFiles();
    +47  
    +48  
    +49  }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/SelectorUtils.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/SelectorUtils.html new file mode 100644 index 000000000..11c736aa8 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/SelectorUtils.html @@ -0,0 +1,708 @@ + + + +SelectorUtils xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors;
    +20  
    +21  import java.io.File;
    +22  import java.util.StringTokenizer;
    +23  import java.util.Vector;
    +24  
    +25  import org.owasp.dependencycheck.org.apache.tools.ant.types.Resource;
    +26  import org.owasp.dependencycheck.org.apache.tools.ant.util.FileUtils;
    +27  
    +28  /**
    +29   * <p>This is a utility class used by selectors and DirectoryScanner. The
    +30   * functionality more properly belongs just to selectors, but unfortunately
    +31   * DirectoryScanner exposed these as protected methods. Thus we have to
    +32   * support any subclasses of DirectoryScanner that may access these methods.
    +33   * </p>
    +34   * <p>This is a Singleton.</p>
    +35   *
    +36   * @since 1.5
    +37   */
    +38  public final class SelectorUtils {
    +39  
    +40      /**
    +41       * The pattern that matches an arbitrary number of directories.
    +42       * @since Ant 1.8.0
    +43       */
    +44      public static final String DEEP_TREE_MATCH = "**";
    +45  
    +46      private static final SelectorUtils instance = new SelectorUtils();
    +47      private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
    +48  
    +49      /**
    +50       * Private Constructor
    +51       */
    +52      private SelectorUtils() {
    +53      }
    +54  
    +55      /**
    +56       * Retrieves the instance of the Singleton.
    +57       * @return singleton instance
    +58       */
    +59      public static SelectorUtils getInstance() {
    +60          return instance;
    +61      }
    +62  
    +63      /**
    +64       * Tests whether or not a given path matches the start of a given
    +65       * pattern up to the first "**".
    +66       * <p>
    +67       * This is not a general purpose test and should only be used if you
    +68       * can live with false positives. For example, <code>pattern=**\a</code>
    +69       * and <code>str=b</code> will yield <code>true</code>.
    +70       *
    +71       * @param pattern The pattern to match against. Must not be
    +72       *                <code>null</code>.
    +73       * @param str     The path to match, as a String. Must not be
    +74       *                <code>null</code>.
    +75       *
    +76       * @return whether or not a given path matches the start of a given
    +77       * pattern up to the first "**".
    +78       */
    +79      public static boolean matchPatternStart(String pattern, String str) {
    +80          return matchPatternStart(pattern, str, true);
    +81      }
    +82  
    +83      /**
    +84       * Tests whether or not a given path matches the start of a given
    +85       * pattern up to the first "**".
    +86       * <p>
    +87       * This is not a general purpose test and should only be used if you
    +88       * can live with false positives. For example, <code>pattern=**\a</code>
    +89       * and <code>str=b</code> will yield <code>true</code>.
    +90       *
    +91       * @param pattern The pattern to match against. Must not be
    +92       *                <code>null</code>.
    +93       * @param str     The path to match, as a String. Must not be
    +94       *                <code>null</code>.
    +95       * @param isCaseSensitive Whether or not matching should be performed
    +96       *                        case sensitively.
    +97       *
    +98       * @return whether or not a given path matches the start of a given
    +99       * pattern up to the first "**".
    +100      */
    +101     public static boolean matchPatternStart(String pattern, String str,
    +102                                             boolean isCaseSensitive) {
    +103         // When str starts with a File.separator, pattern has to start with a
    +104         // File.separator.
    +105         // When pattern starts with a File.separator, str has to start with a
    +106         // File.separator.
    +107         if (str.startsWith(File.separator)
    +108                 != pattern.startsWith(File.separator)) {
    +109             return false;
    +110         }
    +111 
    +112         String[] patDirs = tokenizePathAsArray(pattern);
    +113         String[] strDirs = tokenizePathAsArray(str);
    +114         return matchPatternStart(patDirs, strDirs, isCaseSensitive);
    +115     }
    +116 
    +117 
    +118     /**
    +119      * Tests whether or not a given path matches the start of a given
    +120      * pattern up to the first "**".
    +121      * <p>
    +122      * This is not a general purpose test and should only be used if you
    +123      * can live with false positives. For example, <code>pattern=**\a</code>
    +124      * and <code>str=b</code> will yield <code>true</code>.
    +125      *
    +126      * @param patDirs The tokenized pattern to match against. Must not be
    +127      *                <code>null</code>.
    +128      * @param strDirs The tokenized path to match. Must not be
    +129      *                <code>null</code>.
    +130      * @param isCaseSensitive Whether or not matching should be performed
    +131      *                        case sensitively.
    +132      *
    +133      * @return whether or not a given path matches the start of a given
    +134      * pattern up to the first "**".
    +135      */
    +136     static boolean matchPatternStart(String[] patDirs, String[] strDirs,
    +137                                      boolean isCaseSensitive) {
    +138         int patIdxStart = 0;
    +139         int patIdxEnd = patDirs.length - 1;
    +140         int strIdxStart = 0;
    +141         int strIdxEnd = strDirs.length - 1;
    +142 
    +143         // up to first '**'
    +144         while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
    +145             String patDir = patDirs[patIdxStart];
    +146             if (patDir.equals(DEEP_TREE_MATCH)) {
    +147                 break;
    +148             }
    +149             if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) {
    +150                 return false;
    +151             }
    +152             patIdxStart++;
    +153             strIdxStart++;
    +154         }
    +155 
    +156         // CheckStyle:SimplifyBooleanReturnCheck OFF
    +157         // Check turned off as the code needs the comments for the various
    +158         // code paths.
    +159         if (strIdxStart > strIdxEnd) {
    +160             // String is exhausted
    +161             return true;
    +162         } else if (patIdxStart > patIdxEnd) {
    +163             // String not exhausted, but pattern is. Failure.
    +164             return false;
    +165         } else {
    +166             // pattern now holds ** while string is not exhausted
    +167             // this will generate false positives but we can live with that.
    +168             return true;
    +169         }
    +170     }
    +171 
    +172     /**
    +173      * Tests whether or not a given path matches a given pattern.
    +174      *
    +175      * If you need to call this method multiple times with the same
    +176      * pattern you should rather use TokenizedPath
    +177      *
    +178      * @see TokenizedPath
    +179      *
    +180      * @param pattern The pattern to match against. Must not be
    +181      *                <code>null</code>.
    +182      * @param str     The path to match, as a String. Must not be
    +183      *                <code>null</code>.
    +184      *
    +185      * @return <code>true</code> if the pattern matches against the string,
    +186      *         or <code>false</code> otherwise.
    +187      */
    +188     public static boolean matchPath(String pattern, String str) {
    +189         String[] patDirs = tokenizePathAsArray(pattern);
    +190         return matchPath(patDirs, tokenizePathAsArray(str), true);
    +191     }
    +192 
    +193     /**
    +194      * Tests whether or not a given path matches a given pattern.
    +195      *
    +196      * If you need to call this method multiple times with the same
    +197      * pattern you should rather use TokenizedPattern
    +198      *
    +199      * @see TokenizedPattern
    +200      *
    +201      * @param pattern The pattern to match against. Must not be
    +202      *                <code>null</code>.
    +203      * @param str     The path to match, as a String. Must not be
    +204      *                <code>null</code>.
    +205      * @param isCaseSensitive Whether or not matching should be performed
    +206      *                        case sensitively.
    +207      *
    +208      * @return <code>true</code> if the pattern matches against the string,
    +209      *         or <code>false</code> otherwise.
    +210      */
    +211     public static boolean matchPath(String pattern, String str,
    +212                                     boolean isCaseSensitive) {
    +213         String[] patDirs = tokenizePathAsArray(pattern);
    +214         return matchPath(patDirs, tokenizePathAsArray(str), isCaseSensitive);
    +215     }
    +216 
    +217     /**
    +218      * Core implementation of matchPath.  It is isolated so that it
    +219      * can be called from TokenizedPattern.
    +220      */
    +221     static boolean matchPath(String[] tokenizedPattern, String[] strDirs,
    +222                              boolean isCaseSensitive) {
    +223         int patIdxStart = 0;
    +224         int patIdxEnd = tokenizedPattern.length - 1;
    +225         int strIdxStart = 0;
    +226         int strIdxEnd = strDirs.length - 1;
    +227 
    +228         // up to first '**'
    +229         while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
    +230             String patDir = tokenizedPattern[patIdxStart];
    +231             if (patDir.equals(DEEP_TREE_MATCH)) {
    +232                 break;
    +233             }
    +234             if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) {
    +235                 return false;
    +236             }
    +237             patIdxStart++;
    +238             strIdxStart++;
    +239         }
    +240         if (strIdxStart > strIdxEnd) {
    +241             // String is exhausted
    +242             for (int i = patIdxStart; i <= patIdxEnd; i++) {
    +243                 if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
    +244                     return false;
    +245                 }
    +246             }
    +247             return true;
    +248         } else {
    +249             if (patIdxStart > patIdxEnd) {
    +250                 // String not exhausted, but pattern is. Failure.
    +251                 return false;
    +252             }
    +253         }
    +254 
    +255         // up to last '**'
    +256         while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
    +257             String patDir = tokenizedPattern[patIdxEnd];
    +258             if (patDir.equals(DEEP_TREE_MATCH)) {
    +259                 break;
    +260             }
    +261             if (!match(patDir, strDirs[strIdxEnd], isCaseSensitive)) {
    +262                 return false;
    +263             }
    +264             patIdxEnd--;
    +265             strIdxEnd--;
    +266         }
    +267         if (strIdxStart > strIdxEnd) {
    +268             // String is exhausted
    +269             for (int i = patIdxStart; i <= patIdxEnd; i++) {
    +270                 if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
    +271                     return false;
    +272                 }
    +273             }
    +274             return true;
    +275         }
    +276 
    +277         while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
    +278             int patIdxTmp = -1;
    +279             for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
    +280                 if (tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
    +281                     patIdxTmp = i;
    +282                     break;
    +283                 }
    +284             }
    +285             if (patIdxTmp == patIdxStart + 1) {
    +286                 // '**/**' situation, so skip one
    +287                 patIdxStart++;
    +288                 continue;
    +289             }
    +290             // Find the pattern between padIdxStart & padIdxTmp in str between
    +291             // strIdxStart & strIdxEnd
    +292             int patLength = (patIdxTmp - patIdxStart - 1);
    +293             int strLength = (strIdxEnd - strIdxStart + 1);
    +294             int foundIdx = -1;
    +295             strLoop:
    +296                         for (int i = 0; i <= strLength - patLength; i++) {
    +297                             for (int j = 0; j < patLength; j++) {
    +298                                 String subPat = tokenizedPattern[patIdxStart + j + 1];
    +299                                 String subStr = strDirs[strIdxStart + i + j];
    +300                                 if (!match(subPat, subStr, isCaseSensitive)) {
    +301                                     continue strLoop;
    +302                                 }
    +303                             }
    +304 
    +305                             foundIdx = strIdxStart + i;
    +306                             break;
    +307                         }
    +308 
    +309             if (foundIdx == -1) {
    +310                 return false;
    +311             }
    +312 
    +313             patIdxStart = patIdxTmp;
    +314             strIdxStart = foundIdx + patLength;
    +315         }
    +316 
    +317         for (int i = patIdxStart; i <= patIdxEnd; i++) {
    +318             if (!tokenizedPattern[i].equals(DEEP_TREE_MATCH)) {
    +319                 return false;
    +320             }
    +321         }
    +322 
    +323         return true;
    +324     }
    +325 
    +326     /**
    +327      * Tests whether or not a string matches against a pattern.
    +328      * The pattern may contain two special characters:<br>
    +329      * '*' means zero or more characters<br>
    +330      * '?' means one and only one character
    +331      *
    +332      * @param pattern The pattern to match against.
    +333      *                Must not be <code>null</code>.
    +334      * @param str     The string which must be matched against the pattern.
    +335      *                Must not be <code>null</code>.
    +336      *
    +337      * @return <code>true</code> if the string matches against the pattern,
    +338      *         or <code>false</code> otherwise.
    +339      */
    +340     public static boolean match(String pattern, String str) {
    +341         return match(pattern, str, true);
    +342     }
    +343 
    +344     /**
    +345      * Tests whether or not a string matches against a pattern.
    +346      * The pattern may contain two special characters:<br>
    +347      * '*' means zero or more characters<br>
    +348      * '?' means one and only one character
    +349      *
    +350      * @param pattern The pattern to match against.
    +351      *                Must not be <code>null</code>.
    +352      * @param str     The string which must be matched against the pattern.
    +353      *                Must not be <code>null</code>.
    +354      * @param caseSensitive Whether or not matching should be performed
    +355      *                        case sensitively.
    +356      *
    +357      *
    +358      * @return <code>true</code> if the string matches against the pattern,
    +359      *         or <code>false</code> otherwise.
    +360      */
    +361     public static boolean match(String pattern, String str,
    +362                                 boolean caseSensitive) {
    +363         char[] patArr = pattern.toCharArray();
    +364         char[] strArr = str.toCharArray();
    +365         int patIdxStart = 0;
    +366         int patIdxEnd = patArr.length - 1;
    +367         int strIdxStart = 0;
    +368         int strIdxEnd = strArr.length - 1;
    +369         char ch;
    +370 
    +371         boolean containsStar = false;
    +372         for (int i = 0; i < patArr.length; i++) {
    +373             if (patArr[i] == '*') {
    +374                 containsStar = true;
    +375                 break;
    +376             }
    +377         }
    +378 
    +379         if (!containsStar) {
    +380             // No '*'s, so we make a shortcut
    +381             if (patIdxEnd != strIdxEnd) {
    +382                 return false; // Pattern and string do not have the same size
    +383             }
    +384             for (int i = 0; i <= patIdxEnd; i++) {
    +385                 ch = patArr[i];
    +386                 if (ch != '?') {
    +387                     if (different(caseSensitive, ch, strArr[i])) {
    +388                         return false; // Character mismatch
    +389                     }
    +390                 }
    +391             }
    +392             return true; // String matches against pattern
    +393         }
    +394 
    +395         if (patIdxEnd == 0) {
    +396             return true; // Pattern contains only '*', which matches anything
    +397         }
    +398 
    +399         // Process characters before first star
    +400         while (true) {
    +401             ch = patArr[patIdxStart];
    +402             if (ch == '*' || strIdxStart > strIdxEnd) {
    +403                 break;
    +404             }
    +405             if (ch != '?') {
    +406                 if (different(caseSensitive, ch, strArr[strIdxStart])) {
    +407                     return false; // Character mismatch
    +408                 }
    +409             }
    +410             patIdxStart++;
    +411             strIdxStart++;
    +412         }
    +413         if (strIdxStart > strIdxEnd) {
    +414             // All characters in the string are used. Check if only '*'s are
    +415             // left in the pattern. If so, we succeeded. Otherwise failure.
    +416             return allStars(patArr, patIdxStart, patIdxEnd);
    +417         }
    +418 
    +419         // Process characters after last star
    +420         while (true) {
    +421             ch = patArr[patIdxEnd];
    +422             if (ch == '*' || strIdxStart > strIdxEnd) {
    +423                 break;
    +424             }
    +425             if (ch != '?') {
    +426                 if (different(caseSensitive, ch, strArr[strIdxEnd])) {
    +427                     return false; // Character mismatch
    +428                 }
    +429             }
    +430             patIdxEnd--;
    +431             strIdxEnd--;
    +432         }
    +433         if (strIdxStart > strIdxEnd) {
    +434             // All characters in the string are used. Check if only '*'s are
    +435             // left in the pattern. If so, we succeeded. Otherwise failure.
    +436             return allStars(patArr, patIdxStart, patIdxEnd);
    +437         }
    +438 
    +439         // process pattern between stars. padIdxStart and patIdxEnd point
    +440         // always to a '*'.
    +441         while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
    +442             int patIdxTmp = -1;
    +443             for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
    +444                 if (patArr[i] == '*') {
    +445                     patIdxTmp = i;
    +446                     break;
    +447                 }
    +448             }
    +449             if (patIdxTmp == patIdxStart + 1) {
    +450                 // Two stars next to each other, skip the first one.
    +451                 patIdxStart++;
    +452                 continue;
    +453             }
    +454             // Find the pattern between padIdxStart & padIdxTmp in str between
    +455             // strIdxStart & strIdxEnd
    +456             int patLength = (patIdxTmp - patIdxStart - 1);
    +457             int strLength = (strIdxEnd - strIdxStart + 1);
    +458             int foundIdx = -1;
    +459             strLoop:
    +460             for (int i = 0; i <= strLength - patLength; i++) {
    +461                 for (int j = 0; j < patLength; j++) {
    +462                     ch = patArr[patIdxStart + j + 1];
    +463                     if (ch != '?') {
    +464                         if (different(caseSensitive, ch,
    +465                                       strArr[strIdxStart + i + j])) {
    +466                             continue strLoop;
    +467                         }
    +468                     }
    +469                 }
    +470 
    +471                 foundIdx = strIdxStart + i;
    +472                 break;
    +473             }
    +474 
    +475             if (foundIdx == -1) {
    +476                 return false;
    +477             }
    +478 
    +479             patIdxStart = patIdxTmp;
    +480             strIdxStart = foundIdx + patLength;
    +481         }
    +482 
    +483         // All characters in the string are used. Check if only '*'s are left
    +484         // in the pattern. If so, we succeeded. Otherwise failure.
    +485         return allStars(patArr, patIdxStart, patIdxEnd);
    +486     }
    +487 
    +488     private static boolean allStars(char[] chars, int start, int end) {
    +489         for (int i = start; i <= end; ++i) {
    +490             if (chars[i] != '*') {
    +491                 return false;
    +492             }
    +493         }
    +494         return true;
    +495     }
    +496 
    +497     private static boolean different(
    +498         boolean caseSensitive, char ch, char other) {
    +499         return caseSensitive
    +500             ? ch != other
    +501             : Character.toUpperCase(ch) != Character.toUpperCase(other);
    +502     }
    +503 
    +504     /**
    +505      * Breaks a path up into a Vector of path elements, tokenizing on
    +506      * <code>File.separator</code>.
    +507      *
    +508      * @param path Path to tokenize. Must not be <code>null</code>.
    +509      *
    +510      * @return a Vector of path elements from the tokenized path
    +511      */
    +512     public static Vector<String> tokenizePath(String path) {
    +513         return tokenizePath(path, File.separator);
    +514     }
    +515 
    +516     /**
    +517      * Breaks a path up into a Vector of path elements, tokenizing on
    +518      *
    +519      * @param path Path to tokenize. Must not be <code>null</code>.
    +520      * @param separator the separator against which to tokenize.
    +521      *
    +522      * @return a Vector of path elements from the tokenized path
    +523      * @since Ant 1.6
    +524      */
    +525     public static Vector<String> tokenizePath(String path, String separator) {
    +526         Vector<String> ret = new Vector<String>();
    +527         if (FileUtils.isAbsolutePath(path)) {
    +528             String[] s = FILE_UTILS.dissect(path);
    +529             ret.add(s[0]);
    +530             path = s[1];
    +531         }
    +532         StringTokenizer st = new StringTokenizer(path, separator);
    +533         while (st.hasMoreTokens()) {
    +534             ret.addElement(st.nextToken());
    +535         }
    +536         return ret;
    +537     }
    +538 
    +539     /**
    +540      * Same as {@link #tokenizePath tokenizePath} but hopefully faster.
    +541      */
    +542     /*package*/ static String[] tokenizePathAsArray(String path) {
    +543         String root = null;
    +544         if (FileUtils.isAbsolutePath(path)) {
    +545             String[] s = FILE_UTILS.dissect(path);
    +546             root = s[0];
    +547             path = s[1];
    +548         }
    +549         char sep = File.separatorChar;
    +550         int start = 0;
    +551         int len = path.length();
    +552         int count = 0;
    +553         for (int pos = 0; pos < len; pos++) {
    +554             if (path.charAt(pos) == sep) {
    +555                 if (pos != start) {
    +556                     count++;
    +557                 }
    +558                 start = pos + 1;
    +559             }
    +560         }
    +561         if (len != start) {
    +562             count++;
    +563         }
    +564         String[] l = new String[count + ((root == null) ? 0 : 1)];
    +565 
    +566         if (root != null) {
    +567             l[0] = root;
    +568             count = 1;
    +569         } else {
    +570             count = 0;
    +571         }
    +572         start = 0;
    +573         for (int pos = 0; pos < len; pos++) {
    +574             if (path.charAt(pos) == sep) {
    +575                 if (pos != start) {
    +576                     String tok = path.substring(start, pos);
    +577                     l[count++] = tok;
    +578                 }
    +579                 start = pos + 1;
    +580             }
    +581         }
    +582         if (len != start) {
    +583             String tok = path.substring(start);
    +584             l[count/*++*/] = tok;
    +585         }
    +586         return l;
    +587     }
    +588 
    +589     /**
    +590      * Returns dependency information on these two files. If src has been
    +591      * modified later than target, it returns true. If target doesn't exist,
    +592      * it likewise returns true. Otherwise, target is newer than src and
    +593      * is not out of date, thus the method returns false. It also returns
    +594      * false if the src file doesn't even exist, since how could the
    +595      * target then be out of date.
    +596      *
    +597      * @param src the original file
    +598      * @param target the file being compared against
    +599      * @param granularity the amount in seconds of slack we will give in
    +600      *        determining out of dateness
    +601      * @return whether the target is out of date
    +602      */
    +603     public static boolean isOutOfDate(File src, File target, int granularity) {
    +604         if (!src.exists()) {
    +605             return false;
    +606         }
    +607         if (!target.exists()) {
    +608             return true;
    +609         }
    +610         if ((src.lastModified() - granularity) > target.lastModified()) {
    +611             return true;
    +612         }
    +613         return false;
    +614     }
    +615 
    +616     /**
    +617      * Returns dependency information on these two resources. If src has been
    +618      * modified later than target, it returns true. If target doesn't exist,
    +619      * it likewise returns true. Otherwise, target is newer than src and
    +620      * is not out of date, thus the method returns false. It also returns
    +621      * false if the src file doesn't even exist, since how could the
    +622      * target then be out of date.
    +623      *
    +624      * @param src the original resource
    +625      * @param target the resource being compared against
    +626      * @param granularity the int amount in seconds of slack we will give in
    +627      *        determining out of dateness
    +628      * @return whether the target is out of date
    +629      */
    +630     public static boolean isOutOfDate(Resource src, Resource target,
    +631                                       int granularity) {
    +632         return isOutOfDate(src, target, (long) granularity);
    +633     }
    +634 
    +635     /**
    +636      * Returns dependency information on these two resources. If src has been
    +637      * modified later than target, it returns true. If target doesn't exist,
    +638      * it likewise returns true. Otherwise, target is newer than src and
    +639      * is not out of date, thus the method returns false. It also returns
    +640      * false if the src file doesn't even exist, since how could the
    +641      * target then be out of date.
    +642      *
    +643      * @param src the original resource
    +644      * @param target the resource being compared against
    +645      * @param granularity the long amount in seconds of slack we will give in
    +646      *        determining out of dateness
    +647      * @return whether the target is out of date
    +648      */
    +649     public static boolean isOutOfDate(Resource src, Resource target, long granularity) {
    +650         long sourceLastModified = src.getLastModified();
    +651         long targetLastModified = target.getLastModified();
    +652         return src.isExists()
    +653                 && (sourceLastModified == Resource.UNKNOWN_DATETIME
    +654                         || targetLastModified == Resource.UNKNOWN_DATETIME
    +655                                 || (sourceLastModified - granularity) > targetLastModified);
    +656     }
    +657 
    +658     /**
    +659      * "Flattens" a string by removing all whitespace (space, tab, linefeed,
    +660      * carriage return, and formfeed). This uses StringTokenizer and the
    +661      * default set of tokens as documented in the single argument constructor.
    +662      *
    +663      * @param input a String to remove all whitespace.
    +664      * @return a String that has had all whitespace removed.
    +665      */
    +666     public static String removeWhitespace(String input) {
    +667         StringBuffer result = new StringBuffer();
    +668         if (input != null) {
    +669             StringTokenizer st = new StringTokenizer(input);
    +670             while (st.hasMoreTokens()) {
    +671                 result.append(st.nextToken());
    +672             }
    +673         }
    +674         return result.toString();
    +675     }
    +676 
    +677     /**
    +678      * Tests if a string contains stars or question marks
    +679      * @param input a String which one wants to test for containing wildcard
    +680      * @return true if the string contains at least a star or a question mark
    +681      */
    +682     public static boolean hasWildcards(String input) {
    +683         return (input.indexOf('*') != -1 || input.indexOf('?') != -1);
    +684     }
    +685 
    +686     /**
    +687      * removes from a pattern all tokens to the right containing wildcards
    +688      * @param input the input string
    +689      * @return the leftmost part of the pattern without wildcards
    +690      */
    +691     public static String rtrimWildcardTokens(String input) {
    +692         return new TokenizedPattern(input).rtrimWildcardTokens().toString();
    +693     }
    +694 }
    +695 
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/TokenizedPath.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/TokenizedPath.html new file mode 100644 index 000000000..afe635c99 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/TokenizedPath.html @@ -0,0 +1,232 @@ + + + +TokenizedPath xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors;
    +20  
    +21  import java.io.File;
    +22  
    +23  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +24  import org.owasp.dependencycheck.org.apache.tools.ant.util.FileUtils;
    +25  import org.owasp.dependencycheck.org.apache.tools.ant.util.SymbolicLinkUtils;
    +26  
    +27  /**
    +28   * Container for a path that has been split into its components.
    +29   * @since 1.8.0
    +30   */
    +31  public class TokenizedPath {
    +32  
    +33      /**
    +34       * Instance that holds no tokens at all.
    +35       */
    +36      public static final TokenizedPath EMPTY_PATH =
    +37          new TokenizedPath("", new String[0]);
    +38  
    +39      /** Helper. */
    +40      private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
    +41      /** Helper. */
    +42      private static final SymbolicLinkUtils SYMLINK_UTILS =
    +43          SymbolicLinkUtils.getSymbolicLinkUtils();
    +44      /** iterations for case-sensitive scanning. */
    +45      private static final boolean[] CS_SCAN_ONLY = new boolean[] {true};
    +46      /** iterations for non-case-sensitive scanning. */
    +47      private static final boolean[] CS_THEN_NON_CS = new boolean[] {true, false};
    +48  
    +49      private final String path;
    +50      private final String[] tokenizedPath;
    +51  
    +52      /**
    +53      * Initialize the TokenizedPath by parsing it. 
    +54      * @param path The path to tokenize. Must not be
    +55      *                <code>null</code>.
    +56      */
    +57      public TokenizedPath(String path) {
    +58          this(path, SelectorUtils.tokenizePathAsArray(path));
    +59      }
    +60      
    +61      /**
    +62       * Creates a new path as a child of another path.
    +63       *
    +64       * @param parent the parent path
    +65       * @param child the child, must not contain the file separator
    +66       */
    +67      public TokenizedPath(TokenizedPath parent, String child) {
    +68          if (parent.path.length() > 0
    +69              && parent.path.charAt(parent.path.length() - 1)
    +70                 != File.separatorChar) {
    +71              path = parent.path + File.separatorChar + child;
    +72          } else {
    +73              path = parent.path + child;
    +74          }
    +75          tokenizedPath = new String[parent.tokenizedPath.length + 1];
    +76          System.arraycopy(parent.tokenizedPath, 0, tokenizedPath, 0,
    +77                           parent.tokenizedPath.length);
    +78          tokenizedPath[parent.tokenizedPath.length] = child;
    +79      }
    +80  
    +81      /* package */ TokenizedPath(String path, String[] tokens) {
    +82          this.path = path;
    +83          this.tokenizedPath = tokens;
    +84      }
    +85  
    +86      /**
    +87       * @return The original path String
    +88       */
    +89      public String toString() {
    +90          return path;
    +91      }
    +92      
    +93      /**
    +94       * The depth (or length) of a path.
    +95       */
    +96      public int depth() {
    +97          return tokenizedPath.length;
    +98      }
    +99  
    +100     /* package */ String[] getTokens() {
    +101         return tokenizedPath;
    +102     }
    +103 
    +104     /**
    +105      * From <code>base</code> traverse the filesystem in order to find
    +106      * a file that matches the given name.
    +107      *
    +108      * @param base base File (dir).
    +109      * @param cs whether to scan case-sensitively.
    +110      * @return File object that points to the file in question or null.
    +111      */
    +112     public File findFile(File base, final boolean cs) {
    +113         String[] tokens = tokenizedPath;
    +114         if (FileUtils.isAbsolutePath(path)) {
    +115             if (base == null) {
    +116                 String[] s = FILE_UTILS.dissect(path);
    +117                 base = new File(s[0]);
    +118                 tokens = SelectorUtils.tokenizePathAsArray(s[1]);
    +119             } else {
    +120                 File f = FILE_UTILS.normalize(path);
    +121                 String s = FILE_UTILS.removeLeadingPath(base, f);
    +122                 if (s.equals(f.getAbsolutePath())) {
    +123                     //removing base from path yields no change; path
    +124                     //not child of base
    +125                     return null;
    +126                 }
    +127                 tokens = SelectorUtils.tokenizePathAsArray(s);
    +128             }
    +129         }
    +130         return findFile(base, tokens, cs);
    +131     }
    +132 
    +133     /**
    +134      * Do we have to traverse a symlink when trying to reach path from
    +135      * basedir?
    +136      * @param base base File (dir).
    +137      */
    +138     public boolean isSymlink(File base) {
    +139         for (int i = 0; i < tokenizedPath.length; i++) {
    +140             try {
    +141                 if ((base != null
    +142                      && SYMLINK_UTILS.isSymbolicLink(base, tokenizedPath[i]))
    +143                     ||
    +144                     (base == null
    +145                      && SYMLINK_UTILS.isSymbolicLink(tokenizedPath[i]))
    +146                     ) {
    +147                     return true;
    +148                 }
    +149                 base = new File(base, tokenizedPath[i]);
    +150             } catch (java.io.IOException ioe) {
    +151                 String msg = "IOException caught while checking "
    +152                     + "for links, couldn't get canonical path!";
    +153                 // will be caught and redirected to Ant's logging system
    +154                 System.err.println(msg);
    +155             }
    +156         }
    +157         return false;
    +158     }
    +159 
    +160     /**
    +161      * true if the original paths are equal.
    +162      */
    +163     public boolean equals(Object o) {
    +164         return o instanceof TokenizedPath
    +165             && path.equals(((TokenizedPath) o).path);
    +166     }
    +167 
    +168     public int hashCode() {
    +169         return path.hashCode();
    +170     }
    +171 
    +172     /**
    +173      * From <code>base</code> traverse the filesystem in order to find
    +174      * a file that matches the given stack of names.
    +175      *
    +176      * @param base base File (dir) - must not be null.
    +177      * @param pathElements array of path elements (dirs...file).
    +178      * @param cs whether to scan case-sensitively.
    +179      * @return File object that points to the file in question or null.
    +180      */
    +181     private static File findFile(File base, final String[] pathElements,
    +182                                  final boolean cs) {
    +183         for (int current = 0; current < pathElements.length; current++) {
    +184             if (!base.isDirectory()) {
    +185                 return null;
    +186             }
    +187             String[] files = base.list();
    +188             if (files == null) {
    +189                 throw new BuildException("IO error scanning directory "
    +190                                          + base.getAbsolutePath());
    +191             }
    +192             boolean found = false;
    +193             boolean[] matchCase = cs ? CS_SCAN_ONLY : CS_THEN_NON_CS;
    +194             for (int i = 0; !found && i < matchCase.length; i++) {
    +195                 for (int j = 0; !found && j < files.length; j++) {
    +196                     if (matchCase[i]
    +197                         ? files[j].equals(pathElements[current])
    +198                         : files[j].equalsIgnoreCase(pathElements[current])) {
    +199                         base = new File(base, files[j]);
    +200                         found = true;
    +201                     }
    +202                 }
    +203             }
    +204             if (!found) {
    +205                 return null;
    +206             }
    +207         }
    +208         return pathElements.length == 0 && !base.isDirectory() ? null : base;
    +209     }
    +210 
    +211     /**
    +212      * Creates a TokenizedPattern from the same tokens that make up
    +213      * this path.
    +214      */
    +215     public TokenizedPattern toPattern() {
    +216         return new TokenizedPattern(path, tokenizedPath); 
    +217     }
    +218 
    +219 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/TokenizedPattern.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/TokenizedPattern.html new file mode 100644 index 000000000..5de30c672 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/TokenizedPattern.html @@ -0,0 +1,190 @@ + + + +TokenizedPattern xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  
    +19  package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors;
    +20  
    +21  import java.io.File;
    +22  
    +23  /**
    +24   * Provides reusable path pattern matching.  PathPattern is preferable
    +25   * to equivalent SelectorUtils methods if you need to execute multiple
    +26   * matching with the same pattern because here the pattern itself will
    +27   * be parsed only once.
    +28   * @see SelectorUtils#matchPath(String, String)
    +29   * @see SelectorUtils#matchPath(String, String, boolean)
    +30   * @since 1.8.0
    +31   */
    +32  public class TokenizedPattern {
    +33  
    +34      /**
    +35       * Instance that holds no tokens at all.
    +36       */
    +37      public static final TokenizedPattern EMPTY_PATTERN =
    +38          new TokenizedPattern("", new String[0]);
    +39  
    +40      private final String pattern;
    +41      private final String[] tokenizedPattern;
    +42  
    +43      /**
    +44      * Initialize the PathPattern by parsing it.
    +45      * @param pattern The pattern to match against. Must not be
    +46      *                <code>null</code>.
    +47      */
    +48      public TokenizedPattern(String pattern) {
    +49          this(pattern, SelectorUtils.tokenizePathAsArray(pattern));
    +50      }
    +51  
    +52      TokenizedPattern(String pattern, String[] tokens) {
    +53          this.pattern = pattern;
    +54          this.tokenizedPattern = tokens;
    +55      }
    +56  
    +57      /**
    +58       * Tests whether or not a given path matches a given pattern.
    +59       *
    +60       * @param path    The path to match, as a String. Must not be
    +61       *                <code>null</code>.
    +62       * @param isCaseSensitive Whether or not matching should be performed
    +63       *                        case sensitively.
    +64       *
    +65       * @return <code>true</code> if the pattern matches against the string,
    +66       *         or <code>false</code> otherwise.
    +67       */
    +68      public boolean matchPath(TokenizedPath path, boolean isCaseSensitive) {
    +69          return SelectorUtils.matchPath(tokenizedPattern, path.getTokens(),
    +70                                         isCaseSensitive);
    +71      }
    +72  
    +73      /**
    +74       * Tests whether or not this pattern matches the start of
    +75       * a path.
    +76       */
    +77      public boolean matchStartOf(TokenizedPath path,
    +78                                  boolean caseSensitive) {
    +79          return SelectorUtils.matchPatternStart(tokenizedPattern,
    +80                                                 path.getTokens(), caseSensitive);
    +81      }
    +82  
    +83      /**
    +84       * @return The pattern String
    +85       */
    +86      public String toString() {
    +87          return pattern;
    +88      }
    +89  
    +90      public String getPattern() {
    +91          return pattern;
    +92      }
    +93  
    +94      /**
    +95       * true if the original patterns are equal.
    +96       */
    +97      public boolean equals(Object o) {
    +98          return o instanceof TokenizedPattern
    +99              && pattern.equals(((TokenizedPattern) o).pattern);
    +100     }
    +101 
    +102     public int hashCode() {
    +103         return pattern.hashCode();
    +104     }
    +105 
    +106     /**
    +107      * The depth (or length) of a pattern.
    +108      */
    +109     public int depth() {
    +110         return tokenizedPattern.length;
    +111     }
    +112 
    +113     /**
    +114      * Does the tokenized pattern contain the given string?
    +115      */
    +116     public boolean containsPattern(String pat) {
    +117         for (int i = 0; i < tokenizedPattern.length; i++) {
    +118             if (tokenizedPattern[i].equals(pat)) {
    +119                 return true;
    +120             }
    +121         }
    +122         return false;
    +123     }
    +124 
    +125     /**
    +126      * Returns a new TokenizedPath where all tokens of this pattern to
    +127      * the right containing wildcards have been removed
    +128      * @return the leftmost part of the pattern without wildcards
    +129      */
    +130     public TokenizedPath rtrimWildcardTokens() {
    +131         StringBuilder sb = new StringBuilder();
    +132         int newLen = 0;
    +133         for (; newLen < tokenizedPattern.length; newLen++) {
    +134             if (SelectorUtils.hasWildcards(tokenizedPattern[newLen])) {
    +135                 break;
    +136             }
    +137             if (newLen > 0
    +138                 && sb.charAt(sb.length() - 1) != File.separatorChar) {
    +139                 sb.append(File.separator);
    +140             }
    +141             sb.append(tokenizedPattern[newLen]);
    +142         }
    +143         if (newLen == 0) {
    +144             return TokenizedPath.EMPTY_PATH;
    +145         }
    +146         String[] newPats = new String[newLen];
    +147         System.arraycopy(tokenizedPattern, 0, newPats, 0, newLen);
    +148         return new TokenizedPath(sb.toString(), newPats);
    +149     }
    +150 
    +151     /**
    +152      * true if the last token equals the given string.
    +153      */
    +154     public boolean endsWith(String s) {
    +155         return tokenizedPattern.length > 0
    +156             && tokenizedPattern[tokenizedPattern.length - 1].equals(s);
    +157     }
    +158 
    +159     /**
    +160      * Returns a new pattern without the last token of this pattern.
    +161      */
    +162     public TokenizedPattern withoutLastToken() {
    +163         if (tokenizedPattern.length == 0) {
    +164             throw new IllegalStateException("cant strip a token from nothing");
    +165         } else if (tokenizedPattern.length == 1) {
    +166             return EMPTY_PATTERN;
    +167         } else {
    +168             String toStrip = tokenizedPattern[tokenizedPattern.length - 1];
    +169             int index = pattern.lastIndexOf(toStrip);
    +170             String[] tokens = new String[tokenizedPattern.length - 1];
    +171             System.arraycopy(tokenizedPattern, 0, tokens, 0,
    +172                              tokenizedPattern.length - 1);
    +173             return new TokenizedPattern(pattern.substring(0, index), tokens);
    +174         }
    +175     }
    +176 
    +177 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/package-frame.html new file mode 100644 index 000000000..53a1dad32 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/package-frame.html @@ -0,0 +1,36 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant.types.selectors +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/package-summary.html new file mode 100644 index 000000000..1cb020a59 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/types/selectors/package-summary.html @@ -0,0 +1,89 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant.types.selectors

    + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary
    + FileSelector +
    + SelectorScanner +
    + SelectorUtils +
    + TokenizedPath +
    + TokenizedPattern +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/CollectionUtils.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/CollectionUtils.html new file mode 100644 index 000000000..975e801e6 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/CollectionUtils.html @@ -0,0 +1,278 @@ + + + +CollectionUtils xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.util;
    +19  
    +20  import java.util.ArrayList;
    +21  import java.util.Collection;
    +22  import java.util.Collections;
    +23  import java.util.Dictionary;
    +24  import java.util.Enumeration;
    +25  import java.util.Iterator;
    +26  import java.util.List;
    +27  import java.util.NoSuchElementException;
    +28  import java.util.Vector;
    +29  
    +30  // CheckStyle:HideUtilityClassConstructorCheck OFF - bc
    +31  
    +32  /**
    +33   * A set of helper methods related to collection manipulation.
    +34   *
    +35   * @since Ant 1.5
    +36   */
    +37  public class CollectionUtils {
    +38  
    +39      /**
    +40       * Collections.emptyList() is Java5+.
    +41       */
    +42      @SuppressWarnings("rawtypes")
    +43      @Deprecated
    +44      public static final List EMPTY_LIST = Collections.EMPTY_LIST;
    +45  
    +46      /**
    +47       * Please use Vector.equals() or List.equals().
    +48       * @param v1 the first vector.
    +49       * @param v2 the second vector.
    +50       * @return true if the vectors are equal.
    +51       * @since Ant 1.5
    +52       * @deprecated since 1.6.x.
    +53       */
    +54      public static boolean equals(Vector<?> v1, Vector<?> v2) {
    +55          if (v1 == v2) {
    +56              return true;
    +57          }
    +58  
    +59          if (v1 == null || v2 == null) {
    +60              return false;
    +61          }
    +62  
    +63          return v1.equals(v2);
    +64      }
    +65  
    +66      /**
    +67       * Dictionary does not have an equals.
    +68       * Please use  Map.equals().
    +69       *
    +70       * <p>Follows the equals contract of Java 2's Map.</p>
    +71       * @param d1 the first directory.
    +72       * @param d2 the second directory.
    +73       * @return true if the directories are equal.
    +74       * @since Ant 1.5
    +75       * @deprecated since 1.6.x.
    +76       */
    +77      public static boolean equals(Dictionary<?, ?> d1, Dictionary<?, ?> d2) {
    +78          if (d1 == d2) {
    +79              return true;
    +80          }
    +81  
    +82          if (d1 == null || d2 == null) {
    +83              return false;
    +84          }
    +85  
    +86          if (d1.size() != d2.size()) {
    +87              return false;
    +88          }
    +89  
    +90          Enumeration<?> e1 = d1.keys();
    +91          while (e1.hasMoreElements()) {
    +92              Object key = e1.nextElement();
    +93              Object value1 = d1.get(key);
    +94              Object value2 = d2.get(key);
    +95              if (value2 == null || !value1.equals(value2)) {
    +96                  return false;
    +97              }
    +98          }
    +99  
    +100         // don't need the opposite check as the Dictionaries have the
    +101         // same size, so we've also covered all keys of d2 already.
    +102 
    +103         return true;
    +104     }
    +105 
    +106     /**
    +107      * Creates a comma separated list of all values held in the given
    +108      * collection.
    +109      *
    +110      * @since Ant 1.8.0
    +111      */
    +112     public static String flattenToString(Collection<?> c) {
    +113         final StringBuilder sb = new StringBuilder();
    +114         for (Object o : c) {
    +115             if (sb.length() != 0) {
    +116                 sb.append(",");
    +117             }
    +118             sb.append(o);
    +119         }
    +120         return sb.toString();
    +121     }
    +122 
    +123     /**
    +124      * Dictionary does not know the putAll method. Please use Map.putAll().
    +125      * @param m1 the to directory.
    +126      * @param m2 the from directory.
    +127      * @since Ant 1.6
    +128      * @deprecated since 1.6.x.
    +129      */
    +130     public static <K, V> void putAll(Dictionary<? super K, ? super V> m1, Dictionary<? extends K, ? extends V> m2) {
    +131         for (Enumeration<? extends K> it = m2.keys(); it.hasMoreElements();) {
    +132             K key = it.nextElement();
    +133             m1.put(key, m2.get(key));
    +134         }
    +135     }
    +136 
    +137     /**
    +138      * An empty enumeration.
    +139      * @since Ant 1.6
    +140      */
    +141     public static final class EmptyEnumeration<E> implements Enumeration<E> {
    +142         /** Constructor for the EmptyEnumeration */
    +143         public EmptyEnumeration() {
    +144         }
    +145 
    +146         /**
    +147          * @return false always.
    +148          */
    +149         public boolean hasMoreElements() {
    +150             return false;
    +151         }
    +152 
    +153         /**
    +154          * @return nothing.
    +155          * @throws NoSuchElementException always.
    +156          */
    +157         public E nextElement() throws NoSuchElementException {
    +158             throw new NoSuchElementException();
    +159         }
    +160     }
    +161 
    +162     /**
    +163      * Append one enumeration to another.
    +164      * Elements are evaluated lazily.
    +165      * @param e1 the first enumeration.
    +166      * @param e2 the subsequent enumeration.
    +167      * @return an enumeration representing e1 followed by e2.
    +168      * @since Ant 1.6.3
    +169      */
    +170     public static <E> Enumeration<E> append(Enumeration<E> e1, Enumeration<E> e2) {
    +171         return new CompoundEnumeration<E>(e1, e2);
    +172     }
    +173 
    +174     /**
    +175      * Adapt the specified Iterator to the Enumeration interface.
    +176      * @param iter the Iterator to adapt.
    +177      * @return an Enumeration.
    +178      */
    +179     public static <E> Enumeration<E> asEnumeration(final Iterator<E> iter) {
    +180         return new Enumeration<E>() {
    +181             public boolean hasMoreElements() {
    +182                 return iter.hasNext();
    +183             }
    +184             public E nextElement() {
    +185                 return iter.next();
    +186             }
    +187         };
    +188     }
    +189 
    +190     /**
    +191      * Adapt the specified Enumeration to the Iterator interface.
    +192      * @param e the Enumeration to adapt.
    +193      * @return an Iterator.
    +194      */
    +195     public static <E> Iterator<E> asIterator(final Enumeration<E> e) {
    +196         return new Iterator<E>() {
    +197             public boolean hasNext() {
    +198                 return e.hasMoreElements();
    +199             }
    +200             public E next() {
    +201                 return e.nextElement();
    +202             }
    +203             public void remove() {
    +204                 throw new UnsupportedOperationException();
    +205             }
    +206         };
    +207     }
    +208 
    +209     /**
    +210      * Returns a collection containing all elements of the iterator.
    +211      *
    +212      * @since Ant 1.8.0
    +213      */
    +214     public static <T> Collection<T> asCollection(final Iterator<? extends T> iter) {
    +215         List<T> l = new ArrayList<T>();
    +216         while (iter.hasNext()) {
    +217             l.add(iter.next());
    +218         }
    +219         return l;
    +220     }
    +221 
    +222     private static final class CompoundEnumeration<E> implements Enumeration<E> {
    +223 
    +224         private final Enumeration<E> e1, e2;
    +225 
    +226         public CompoundEnumeration(Enumeration<E> e1, Enumeration<E> e2) {
    +227             this.e1 = e1;
    +228             this.e2 = e2;
    +229         }
    +230 
    +231         public boolean hasMoreElements() {
    +232             return e1.hasMoreElements() || e2.hasMoreElements();
    +233         }
    +234 
    +235         public E nextElement() throws NoSuchElementException {
    +236             if (e1.hasMoreElements()) {
    +237                 return e1.nextElement();
    +238             } else {
    +239                 return e2.nextElement();
    +240             }
    +241         }
    +242 
    +243     }
    +244 
    +245     /**
    +246      * Counts how often the given Object occurs in the given
    +247      * collection using equals() for comparison.
    +248      *
    +249      * @since Ant 1.8.0
    +250      */
    +251     public static int frequency(Collection<?> c, Object o) {
    +252         // same as Collections.frequency introduced with JDK 1.5
    +253         int freq = 0;
    +254         if (c != null) {
    +255             for (Iterator<?> i = c.iterator(); i.hasNext(); ) {
    +256                 Object test = i.next();
    +257                 if (o == null ? test == null : o.equals(test)) {
    +258                     freq++;
    +259                 }
    +260             }
    +261         }
    +262         return freq;
    +263     }
    +264 
    +265 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/FileUtils.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/FileUtils.html new file mode 100644 index 000000000..f5c16d268 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/FileUtils.html @@ -0,0 +1,1680 @@ + + + +FileUtils xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.util;
    +19  
    +20  import java.io.File;
    +21  import java.io.FilenameFilter;
    +22  import java.io.IOException;
    +23  import java.io.InputStream;
    +24  import java.io.InputStreamReader;
    +25  import java.io.OutputStream;
    +26  import java.io.Reader;
    +27  import java.io.Writer;
    +28  import java.net.HttpURLConnection;
    +29  import java.net.JarURLConnection;
    +30  import java.net.MalformedURLException;
    +31  import java.net.URL;
    +32  import java.net.URLConnection;
    +33  import java.nio.channels.Channel;
    +34  import java.text.DecimalFormat;
    +35  import java.util.ArrayList;
    +36  import java.util.Arrays;
    +37  import java.util.Iterator;
    +38  import java.util.List;
    +39  import java.util.Random;
    +40  import java.util.Stack;
    +41  import java.util.StringTokenizer;
    +42  import java.util.jar.JarFile;
    +43  import org.owasp.dependencycheck.org.apache.tools.ant.BuildException;
    +44  import org.owasp.dependencycheck.org.apache.tools.ant.PathTokenizer;
    +45  import org.owasp.dependencycheck.org.apache.tools.ant.launch.Locator;
    +46  import org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition.Os;
    +47  
    +48  /**
    +49   * This class also encapsulates methods which allow Files to be referred to using abstract path names which are
    +50   * translated to native system file paths at runtime as well as copying files or setting their last modification time.
    +51   *
    +52   */
    +53  public class FileUtils {
    +54  
    +55      private static final int DELETE_RETRY_SLEEP_MILLIS = 10;
    +56      private static final int EXPAND_SPACE = 50;
    +57      private static final FileUtils PRIMARY_INSTANCE = new FileUtils();
    +58  
    +59      //get some non-crypto-grade randomness from various places.
    +60      private static Random rand = new Random(System.currentTimeMillis()
    +61              + Runtime.getRuntime().freeMemory());
    +62  
    +63      private static final boolean ON_NETWARE = Os.isFamily("netware");
    +64      private static final boolean ON_DOS = Os.isFamily("dos");
    +65      private static final boolean ON_WIN9X = Os.isFamily("win9x");
    +66      private static final boolean ON_WINDOWS = Os.isFamily("windows");
    +67  
    +68      static final int BUF_SIZE = 8192;
    +69  
    +70      /**
    +71       * The granularity of timestamps under FAT.
    +72       */
    +73      public static final long FAT_FILE_TIMESTAMP_GRANULARITY = 2000;
    +74  
    +75      /**
    +76       * The granularity of timestamps under Unix.
    +77       */
    +78      public static final long UNIX_FILE_TIMESTAMP_GRANULARITY = 1000;
    +79  
    +80      /**
    +81       * The granularity of timestamps under the NT File System. NTFS has a granularity of 100 nanoseconds, which is less
    +82       * than 1 millisecond, so we round this up to 1 millisecond.
    +83       */
    +84      public static final long NTFS_FILE_TIMESTAMP_GRANULARITY = 1;
    +85  
    +86      /**
    +87       * A one item cache for fromUri. fromUri is called for each element when parseing ant build files. It is a costly
    +88       * operation. This just caches the result of the last call.
    +89       */
    +90      private Object cacheFromUriLock = new Object();
    +91      private String cacheFromUriRequest = null;
    +92      private String cacheFromUriResponse = null;
    +93  
    +94      /**
    +95       * Factory method.
    +96       *
    +97       * @return a new instance of FileUtils.
    +98       * @deprecated since 1.7. Use getFileUtils instead, FileUtils do not have state.
    +99       */
    +100     public static FileUtils newFileUtils() {
    +101         return new FileUtils();
    +102     }
    +103 
    +104     /**
    +105      * Method to retrieve The FileUtils, which is shared by all users of this method.
    +106      *
    +107      * @return an instance of FileUtils.
    +108      * @since Ant 1.6.3
    +109      */
    +110     public static FileUtils getFileUtils() {
    +111         return PRIMARY_INSTANCE;
    +112     }
    +113 
    +114     /**
    +115      * Empty constructor.
    +116      */
    +117     protected FileUtils() {
    +118     }
    +119 
    +120     /**
    +121      * Get the URL for a file taking into account # characters.
    +122      *
    +123      * @param file the file whose URL representation is required.
    +124      * @return The FileURL value.
    +125      * @throws MalformedURLException if the URL representation cannot be formed.
    +126      */
    +127     public URL getFileURL(File file) throws MalformedURLException {
    +128         return new URL(file.toURI().toASCIIString());
    +129     }
    +130 
    +131 //    /**
    +132 //     * Convenience method to copy a file from a source to a destination.
    +133 //     * No filtering is performed.
    +134 //     *
    +135 //     * @param sourceFile Name of file to copy from.
    +136 //     *                   Must not be <code>null</code>.
    +137 //     * @param destFile Name of file to copy to.
    +138 //     *                 Must not be <code>null</code>.
    +139 //     *
    +140 //     * @throws IOException if the copying fails.
    +141 //     */
    +142 //    public void copyFile(String sourceFile, String destFile) throws IOException {
    +143 //        copyFile(new File(sourceFile), new File(destFile), null, false, false);
    +144 //    }
    +145 //
    +146 //    /**
    +147 //     * Convenience method to copy a file from a source to a destination
    +148 //     * specifying if token filtering must be used.
    +149 //     *
    +150 //     * @param sourceFile Name of file to copy from.
    +151 //     *                   Must not be <code>null</code>.
    +152 //     * @param destFile Name of file to copy to.
    +153 //     *                 Must not be <code>null</code>.
    +154 //     * @param filters the collection of filters to apply to this copy.
    +155 //     *
    +156 //     * @throws IOException if the copying fails.
    +157 //     */
    +158 //    public void copyFile(String sourceFile, String destFile, FilterSetCollection filters)
    +159 //            throws IOException {
    +160 //        copyFile(new File(sourceFile), new File(destFile), filters, false, false);
    +161 //    }
    +162 //
    +163 //    /**
    +164 //     * Convenience method to copy a file from a source to a destination specifying if token
    +165 //     * filtering must be used and if source files may overwrite newer destination files.
    +166 //     *
    +167 //     * @param sourceFile Name of file to copy from. Must not be <code>null</code>.
    +168 //     * @param destFile Name of file to copy to. Must not be <code>null</code>.
    +169 //     * @param filters the collection of filters to apply to this copy.
    +170 //     * @param overwrite Whether or not the destination file should be overwritten if it already
    +171 //     *            exists.
    +172 //     *
    +173 //     * @throws IOException if the copying fails.
    +174 //     */
    +175 //    public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
    +176 //                         boolean overwrite) throws IOException {
    +177 //        copyFile(new File(sourceFile), new File(destFile), filters, overwrite, false);
    +178 //    }
    +179 //
    +180 //    /**
    +181 //     * Convenience method to copy a file from a source to a destination
    +182 //     * specifying if token
    +183 //     * filtering must be used, if source files may overwrite newer destination
    +184 //     * files and the last
    +185 //     * modified time of <code>destFile</code> file should be made equal to
    +186 //     * the last modified time
    +187 //     * of <code>sourceFile</code>.
    +188 //     *
    +189 //     * @param sourceFile Name of file to copy from. Must not be <code>null</code>.
    +190 //     * @param destFile Name of file to copy to. Must not be <code>null</code>.
    +191 //     * @param filters the collection of filters to apply to this copy.
    +192 //     * @param overwrite Whether or not the destination file should be
    +193 //     *            overwritten if it already exists.
    +194 //     * @param preserveLastModified Whether or not the last modified time of
    +195 //     *            the resulting file
    +196 //     *            should be set to that of the source file.
    +197 //     *
    +198 //     * @throws IOException if the copying fails.
    +199 //     */
    +200 //    public void copyFile(String sourceFile, String destFile,
    +201 //                         FilterSetCollection filters,
    +202 //                         boolean overwrite, boolean preserveLastModified)
    +203 //        throws IOException {
    +204 //        copyFile(new File(sourceFile), new File(destFile), filters, overwrite,
    +205 //                 preserveLastModified);
    +206 //    }
    +207 //
    +208 //    /**
    +209 //     * Convenience method to copy a file from a source to a destination specifying if token
    +210 //     * filtering must be used, if source files may overwrite newer destination files and the last
    +211 //     * modified time of <code>destFile</code> file should be made equal to the last modified time
    +212 //     * of <code>sourceFile</code>.
    +213 //     *
    +214 //     * @param sourceFile Name of file to copy from. Must not be <code>null</code>.
    +215 //     * @param destFile Name of file to copy to. Must not be <code>null</code>.
    +216 //     * @param filters the collection of filters to apply to this copy.
    +217 //     * @param overwrite Whether or not the destination file should be overwritten if it already
    +218 //     *            exists.
    +219 //     * @param preserveLastModified Whether or not the last modified time of the resulting file
    +220 //     *            should be set to that of the source file.
    +221 //     * @param encoding the encoding used to read and write the files.
    +222 //     *
    +223 //     * @throws IOException if the copying fails.
    +224 //     *
    +225 //     * @since Ant 1.5
    +226 //     */
    +227 //    public void copyFile(String sourceFile, String destFile,
    +228 //                         FilterSetCollection filters, boolean overwrite,
    +229 //                         boolean preserveLastModified, String encoding) throws IOException {
    +230 //        copyFile(new File(sourceFile), new File(destFile), filters,
    +231 //                 overwrite, preserveLastModified, encoding);
    +232 //    }
    +233 //    // CheckStyle:ParameterNumberCheck OFF - bc
    +234 //    /**
    +235 //     * Convenience method to copy a file from a source to a
    +236 //     * destination specifying if token filtering must be used, if
    +237 //     * filter chains must be used, if source files may overwrite
    +238 //     * newer destination files and the last modified time of
    +239 //     * <code>destFile</code> file should be made equal
    +240 //     * to the last modified time of <code>sourceFile</code>.
    +241 //     *
    +242 //     * @param sourceFile Name of file to copy from.
    +243 //     *                   Must not be <code>null</code>.
    +244 //     * @param destFile Name of file to copy to.
    +245 //     *                 Must not be <code>null</code>.
    +246 //     * @param filters the collection of filters to apply to this copy.
    +247 //     * @param filterChains filterChains to apply during the copy.
    +248 //     * @param overwrite Whether or not the destination file should be
    +249 //     *                  overwritten if it already exists.
    +250 //     * @param preserveLastModified Whether or not the last modified time of
    +251 //     *                             the resulting file should be set to that
    +252 //     *                             of the source file.
    +253 //     * @param encoding the encoding used to read and write the files.
    +254 //     * @param project the project instance.
    +255 //     *
    +256 //     * @throws IOException if the copying fails.
    +257 //     *
    +258 //     * @since Ant 1.5
    +259 //     */
    +260 //    public void copyFile(String sourceFile, String destFile,
    +261 //                         FilterSetCollection filters, Vector filterChains,
    +262 //                         boolean overwrite, boolean preserveLastModified,
    +263 //                         String encoding, Project project) throws IOException {
    +264 //        copyFile(new File(sourceFile), new File(destFile), filters, filterChains, overwrite,
    +265 //                preserveLastModified, encoding, project);
    +266 //    }
    +267 //
    +268 //    /**
    +269 //     * Convenience method to copy a file from a source to a destination specifying if token
    +270 //     * filtering must be used, if filter chains must be used, if source files may overwrite newer
    +271 //     * destination files and the last modified time of <code>destFile</code> file should be made
    +272 //     * equal to the last modified time of <code>sourceFile</code>.
    +273 //     *
    +274 //     * @param sourceFile Name of file to copy from. Must not be <code>null</code>.
    +275 //     * @param destFile Name of file to copy to. Must not be <code>null</code>.
    +276 //     * @param filters the collection of filters to apply to this copy.
    +277 //     * @param filterChains filterChains to apply during the copy.
    +278 //     * @param overwrite Whether or not the destination file should be overwritten if it already
    +279 //     *            exists.
    +280 //     * @param preserveLastModified Whether or not the last modified time of the resulting file
    +281 //     *            should be set to that of the source file.
    +282 //     * @param inputEncoding the encoding used to read the files.
    +283 //     * @param outputEncoding the encoding used to write the files.
    +284 //     * @param project the project instance.
    +285 //     *
    +286 //     * @throws IOException if the copying fails.
    +287 //     *
    +288 //     * @since Ant 1.6
    +289 //     */
    +290 //    public void copyFile(String sourceFile, String destFile,
    +291 //                         FilterSetCollection filters, Vector filterChains,
    +292 //                         boolean overwrite, boolean preserveLastModified,
    +293 //                         String inputEncoding, String outputEncoding,
    +294 //                         Project project) throws IOException {
    +295 //        copyFile(new File(sourceFile), new File(destFile), filters, filterChains, overwrite,
    +296 //                preserveLastModified, inputEncoding, outputEncoding, project);
    +297 //    }
    +298 //
    +299 //    /**
    +300 //     * Convenience method to copy a file from a source to a destination. No filtering is performed.
    +301 //     *
    +302 //     * @param sourceFile the file to copy from. Must not be <code>null</code>.
    +303 //     * @param destFile the file to copy to. Must not be <code>null</code>.
    +304 //     *
    +305 //     * @throws IOException if the copying fails.
    +306 //     */
    +307 //    public void copyFile(File sourceFile, File destFile) throws IOException {
    +308 //        copyFile(sourceFile, destFile, null, false, false);
    +309 //    }
    +310 //
    +311 //    /**
    +312 //     * Convenience method to copy a file from a source to a destination
    +313 //     * specifying if token filtering must be used.
    +314 //     *
    +315 //     * @param sourceFile the file to copy from.
    +316 //     *                   Must not be <code>null</code>.
    +317 //     * @param destFile the file to copy to.
    +318 //     *                 Must not be <code>null</code>.
    +319 //     * @param filters the collection of filters to apply to this copy.
    +320 //     *
    +321 //     * @throws IOException if the copying fails.
    +322 //     */
    +323 //    public void copyFile(File sourceFile, File destFile, FilterSetCollection filters)
    +324 //            throws IOException {
    +325 //        copyFile(sourceFile, destFile, filters, false, false);
    +326 //    }
    +327 //
    +328 //    /**
    +329 //     * Convenience method to copy a file from a source to a
    +330 //     * destination specifying if token filtering must be used and if
    +331 //     * source files may overwrite newer destination files.
    +332 //     *
    +333 //     * @param sourceFile the file to copy from.
    +334 //     *                   Must not be <code>null</code>.
    +335 //     * @param destFile the file to copy to.
    +336 //     *                 Must not be <code>null</code>.
    +337 //     * @param filters the collection of filters to apply to this copy.
    +338 //     * @param overwrite Whether or not the destination file should be
    +339 //     *                  overwritten if it already exists.
    +340 //     *
    +341 //     * @throws IOException if the copying fails.
    +342 //     */
    +343 //    public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
    +344 //                         boolean overwrite) throws IOException {
    +345 //        copyFile(sourceFile, destFile, filters, overwrite, false);
    +346 //    }
    +347 //
    +348 //    /**
    +349 //     * Convenience method to copy a file from a source to a
    +350 //     * destination specifying if token filtering must be used, if
    +351 //     * source files may overwrite newer destination files and the
    +352 //     * last modified time of <code>destFile</code> file should be made equal
    +353 //     * to the last modified time of <code>sourceFile</code>.
    +354 //     *
    +355 //     * @param sourceFile the file to copy from.
    +356 //     *                   Must not be <code>null</code>.
    +357 //     * @param destFile the file to copy to.
    +358 //     *                 Must not be <code>null</code>.
    +359 //     * @param filters the collection of filters to apply to this copy.
    +360 //     * @param overwrite Whether or not the destination file should be
    +361 //     *                  overwritten if it already exists.
    +362 //     * @param preserveLastModified Whether or not the last modified time of
    +363 //     *                             the resulting file should be set to that
    +364 //     *                             of the source file.
    +365 //     *
    +366 //     * @throws IOException if the copying fails.
    +367 //     */
    +368 //    public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
    +369 //                         boolean overwrite, boolean preserveLastModified) throws IOException {
    +370 //        copyFile(sourceFile, destFile, filters, overwrite, preserveLastModified, null);
    +371 //    }
    +372 //
    +373 //    /**
    +374 //     * Convenience method to copy a file from a source to a destination specifying if token
    +375 //     * filtering must be used, if source files may overwrite newer destination files, the last
    +376 //     * modified time of <code>destFile</code> file should be made equal to the last modified time
    +377 //     * of <code>sourceFile</code> and which character encoding to assume.
    +378 //     *
    +379 //     * @param sourceFile the file to copy from. Must not be <code>null</code>.
    +380 //     * @param destFile the file to copy to. Must not be <code>null</code>.
    +381 //     * @param filters the collection of filters to apply to this copy.
    +382 //     * @param overwrite Whether or not the destination file should be overwritten if it already
    +383 //     *            exists.
    +384 //     * @param preserveLastModified Whether or not the last modified time of the resulting file
    +385 //     *            should be set to that of the source file.
    +386 //     * @param encoding the encoding used to read and write the files.
    +387 //     *
    +388 //     * @throws IOException if the copying fails.
    +389 //     *
    +390 //     * @since Ant 1.5
    +391 //     */
    +392 //    public void copyFile(File sourceFile, File destFile,
    +393 //                         FilterSetCollection filters, boolean overwrite,
    +394 //                         boolean preserveLastModified, String encoding) throws IOException {
    +395 //        copyFile(sourceFile, destFile, filters, null, overwrite,
    +396 //                 preserveLastModified, encoding, null);
    +397 //    }
    +398 //    /**
    +399 //     * Convenience method to copy a file from a source to a
    +400 //     * destination specifying if token filtering must be used, if
    +401 //     * filter chains must be used, if source files may overwrite
    +402 //     * newer destination files and the last modified time of
    +403 //     * <code>destFile</code> file should be made equal
    +404 //     * to the last modified time of <code>sourceFile</code>.
    +405 //     *
    +406 //     * @param sourceFile the file to copy from.
    +407 //     *                   Must not be <code>null</code>.
    +408 //     * @param destFile the file to copy to.
    +409 //     *                 Must not be <code>null</code>.
    +410 //     * @param filters the collection of filters to apply to this copy.
    +411 //     * @param filterChains filterChains to apply during the copy.
    +412 //     * @param overwrite Whether or not the destination file should be
    +413 //     *                  overwritten if it already exists.
    +414 //     * @param preserveLastModified Whether or not the last modified time of
    +415 //     *                             the resulting file should be set to that
    +416 //     *                             of the source file.
    +417 //     * @param encoding the encoding used to read and write the files.
    +418 //     * @param project the project instance.
    +419 //     *
    +420 //     * @throws IOException if the copying fails.
    +421 //     *
    +422 //     * @since Ant 1.5
    +423 //     */
    +424 //    public void copyFile(File sourceFile, File destFile,
    +425 //                         FilterSetCollection filters, Vector filterChains,
    +426 //                         boolean overwrite, boolean preserveLastModified,
    +427 //                         String encoding, Project project) throws IOException {
    +428 //        copyFile(sourceFile, destFile, filters, filterChains,
    +429 //                 overwrite, preserveLastModified, encoding, encoding, project);
    +430 //    }
    +431 //
    +432 //    /**
    +433 //     * Convenience method to copy a file from a source to a
    +434 //     * destination specifying if token filtering must be used, if
    +435 //     * filter chains must be used, if source files may overwrite
    +436 //     * newer destination files and the last modified time of
    +437 //     * <code>destFile</code> file should be made equal
    +438 //     * to the last modified time of <code>sourceFile</code>.
    +439 //     *
    +440 //     * @param sourceFile the file to copy from.
    +441 //     *                   Must not be <code>null</code>.
    +442 //     * @param destFile the file to copy to.
    +443 //     *                 Must not be <code>null</code>.
    +444 //     * @param filters the collection of filters to apply to this copy.
    +445 //     * @param filterChains filterChains to apply during the copy.
    +446 //     * @param overwrite Whether or not the destination file should be
    +447 //     *                  overwritten if it already exists.
    +448 //     * @param preserveLastModified Whether or not the last modified time of
    +449 //     *                             the resulting file should be set to that
    +450 //     *                             of the source file.
    +451 //     * @param inputEncoding the encoding used to read the files.
    +452 //     * @param outputEncoding the encoding used to write the files.
    +453 //     * @param project the project instance.
    +454 //     *
    +455 //     *
    +456 //     * @throws IOException if the copying fails.
    +457 //     *
    +458 //     * @since Ant 1.6
    +459 //     */
    +460 //    public void copyFile(File sourceFile, File destFile,
    +461 //            FilterSetCollection filters, Vector filterChains,
    +462 //            boolean overwrite, boolean preserveLastModified,
    +463 //            String inputEncoding, String outputEncoding,
    +464 //            Project project) throws IOException {
    +465 //        copyFile(sourceFile, destFile, filters, filterChains, overwrite, preserveLastModified,
    +466 //                false, inputEncoding, outputEncoding, project);
    +467 //    }
    +468 //
    +469 //    /**
    +470 //     * Convenience method to copy a file from a source to a
    +471 //     * destination specifying if token filtering must be used, if
    +472 //     * filter chains must be used, if source files may overwrite
    +473 //     * newer destination files and the last modified time of
    +474 //     * <code>destFile</code> file should be made equal
    +475 //     * to the last modified time of <code>sourceFile</code>.
    +476 //     *
    +477 //     * @param sourceFile the file to copy from.
    +478 //     *                   Must not be <code>null</code>.
    +479 //     * @param destFile the file to copy to.
    +480 //     *                 Must not be <code>null</code>.
    +481 //     * @param filters the collection of filters to apply to this copy.
    +482 //     * @param filterChains filterChains to apply during the copy.
    +483 //     * @param overwrite Whether or not the destination file should be
    +484 //     *                  overwritten if it already exists.
    +485 //     * @param preserveLastModified Whether or not the last modified time of
    +486 //     *                             the resulting file should be set to that
    +487 //     *                             of the source file.
    +488 //     * @param append whether to append to the destination file.
    +489 //     * @param inputEncoding the encoding used to read the files.
    +490 //     * @param outputEncoding the encoding used to write the files.
    +491 //     * @param project the project instance.
    +492 //     *
    +493 //     *
    +494 //     * @throws IOException if the copying fails.
    +495 //     *
    +496 //     * @since Ant 1.8
    +497 //     */
    +498 //    public void copyFile(File sourceFile, File destFile,
    +499 //                         FilterSetCollection filters, Vector filterChains,
    +500 //                         boolean overwrite, boolean preserveLastModified,
    +501 //                         boolean append,
    +502 //                         String inputEncoding, String outputEncoding,
    +503 //                         Project project) throws IOException {
    +504 //        copyFile(sourceFile, destFile, filters, filterChains, overwrite,
    +505 //                 preserveLastModified, append, inputEncoding, outputEncoding,
    +506 //                 project, /* force: */ false);
    +507 //    }
    +508 //
    +509 //    /**
    +510 //     * Convenience method to copy a file from a source to a
    +511 //     * destination specifying if token filtering must be used, if
    +512 //     * filter chains must be used, if source files may overwrite
    +513 //     * newer destination files and the last modified time of
    +514 //     * <code>destFile</code> file should be made equal
    +515 //     * to the last modified time of <code>sourceFile</code>.
    +516 //     *
    +517 //     * @param sourceFile the file to copy from.
    +518 //     *                   Must not be <code>null</code>.
    +519 //     * @param destFile the file to copy to.
    +520 //     *                 Must not be <code>null</code>.
    +521 //     * @param filters the collection of filters to apply to this copy.
    +522 //     * @param filterChains filterChains to apply during the copy.
    +523 //     * @param overwrite Whether or not the destination file should be
    +524 //     *                  overwritten if it already exists.
    +525 //     * @param preserveLastModified Whether or not the last modified time of
    +526 //     *                             the resulting file should be set to that
    +527 //     *                             of the source file.
    +528 //     * @param append whether to append to the destination file.
    +529 //     * @param inputEncoding the encoding used to read the files.
    +530 //     * @param outputEncoding the encoding used to write the files.
    +531 //     * @param project the project instance.
    +532 //     * @param force whether to overwrite read-only destination files.
    +533 //     *
    +534 //     * @throws IOException if the copying fails.
    +535 //     *
    +536 //     * @since Ant 1.8.2
    +537 //     */
    +538 //    public void copyFile(File sourceFile, File destFile,
    +539 //                         FilterSetCollection filters, Vector filterChains,
    +540 //                         boolean overwrite, boolean preserveLastModified,
    +541 //                         boolean append,
    +542 //                         String inputEncoding, String outputEncoding,
    +543 //                         Project project, boolean force) throws IOException {
    +544 //        ResourceUtils.copyResource(new FileResource(sourceFile),
    +545 //                                   new FileResource(destFile),
    +546 //                                   filters, filterChains, overwrite,
    +547 //                                   preserveLastModified, append, inputEncoding,
    +548 //                                   outputEncoding, project, force);
    +549 //    }
    +550 //
    +551 //    // CheckStyle:ParameterNumberCheck ON
    +552 //
    +553 //    /**
    +554 //     * Calls File.setLastModified(long time). Originally written to
    +555 //     * to dynamically bind to that call on Java1.2+.
    +556 //     *
    +557 //     * @param file the file whose modified time is to be set
    +558 //     * @param time the time to which the last modified time is to be set.
    +559 //     *             if this is -1, the current time is used.
    +560 //     */
    +561 //    public void setFileLastModified(File file, long time) {
    +562 //        ResourceUtils.setLastModified(new FileResource(file), time);
    +563 //    }
    +564     /**
    +565      * Interpret the filename as a file relative to the given file unless the filename already represents an absolute
    +566      * filename. Differs from <code>new File(file, filename)</code> in that the resulting File's path will always be a
    +567      * normalized, absolute pathname. Also, if it is determined that <code>filename</code> is context-relative,
    +568      * <code>file</code> will be discarded and the reference will be resolved using available context/state information
    +569      * about the filesystem.
    +570      *
    +571      * @param file the "reference" file for relative paths. This instance must be an absolute file and must not contain
    +572      * &quot;./&quot; or &quot;../&quot; sequences (same for \ instead of /). If it is null, this call is equivalent to
    +573      * <code>new java.io.File(filename).getAbsoluteFile()</code>.
    +574      *
    +575      * @param filename a file name.
    +576      *
    +577      * @return an absolute file.
    +578      * @throws java.lang.NullPointerException if filename is null.
    +579      */
    +580     public File resolveFile(File file, String filename) {
    +581         if (!isAbsolutePath(filename)) {
    +582             char sep = File.separatorChar;
    +583             filename = filename.replace('/', sep).replace('\\', sep);
    +584             if (isContextRelativePath(filename)) {
    +585                 file = null;
    +586                 // on cygwin, our current directory can be a UNC;
    +587                 // assume user.dir is absolute or all hell breaks loose...
    +588                 String udir = System.getProperty("user.dir");
    +589                 if (filename.charAt(0) == sep && udir.charAt(0) == sep) {
    +590                     filename = dissect(udir)[0] + filename.substring(1);
    +591                 }
    +592             }
    +593             filename = new File(file, filename).getAbsolutePath();
    +594         }
    +595         return normalize(filename);
    +596     }
    +597 
    +598     /**
    +599      * On DOS and NetWare, the evaluation of certain file specifications is context-dependent. These are filenames
    +600      * beginning with a single separator (relative to current root directory) and filenames with a drive specification
    +601      * and no intervening separator (relative to current directory of the specified root).
    +602      *
    +603      * @param filename the filename to evaluate.
    +604      * @return true if the filename is relative to system context.
    +605      * @throws java.lang.NullPointerException if filename is null.
    +606      * @since Ant 1.7
    +607      */
    +608     public static boolean isContextRelativePath(String filename) {
    +609         if (!(ON_DOS || ON_NETWARE) || filename.length() == 0) {
    +610             return false;
    +611         }
    +612         char sep = File.separatorChar;
    +613         filename = filename.replace('/', sep).replace('\\', sep);
    +614         char c = filename.charAt(0);
    +615         int len = filename.length();
    +616         return (c == sep && (len == 1 || filename.charAt(1) != sep))
    +617                 || (Character.isLetter(c) && len > 1
    +618                 && filename.charAt(1) == ':'
    +619                 && (len == 2 || filename.charAt(2) != sep));
    +620     }
    +621 
    +622     /**
    +623      * Verifies that the specified filename represents an absolute path. Differs from new
    +624      * java.io.File("filename").isAbsolute() in that a path beginning with a double file separator--signifying a Windows
    +625      * UNC--must at minimum match "\\a\b" to be considered an absolute path.
    +626      *
    +627      * @param filename the filename to be checked.
    +628      * @return true if the filename represents an absolute path.
    +629      * @throws java.lang.NullPointerException if filename is null.
    +630      * @since Ant 1.6.3
    +631      */
    +632     public static boolean isAbsolutePath(String filename) {
    +633         int len = filename.length();
    +634         if (len == 0) {
    +635             return false;
    +636         }
    +637         char sep = File.separatorChar;
    +638         filename = filename.replace('/', sep).replace('\\', sep);
    +639         char c = filename.charAt(0);
    +640         if (!(ON_DOS || ON_NETWARE)) {
    +641             return (c == sep);
    +642         }
    +643         if (c == sep) {
    +644             // CheckStyle:MagicNumber OFF
    +645             if (!(ON_DOS && len > 4 && filename.charAt(1) == sep)) {
    +646                 return false;
    +647             }
    +648             // CheckStyle:MagicNumber ON
    +649             int nextsep = filename.indexOf(sep, 2);
    +650             return nextsep > 2 && nextsep + 1 < len;
    +651         }
    +652         int colon = filename.indexOf(':');
    +653         return (Character.isLetter(c) && colon == 1
    +654                 && filename.length() > 2 && filename.charAt(2) == sep)
    +655                 || (ON_NETWARE && colon > 0);
    +656     }
    +657 
    +658     /**
    +659      * Translate a path into its native (platform specific) format.
    +660      * <p>
    +661      * This method uses PathTokenizer to separate the input path into its components. This handles DOS style paths in a
    +662      * relatively sensible way. The file separators are then converted to their platform specific versions.
    +663      *
    +664      * @param toProcess The path to be translated. May be <code>null</code>.
    +665      *
    +666      * @return the native version of the specified path or an empty string if the path is <code>null</code> or empty.
    +667      *
    +668      * @since ant 1.7
    +669      * @see PathTokenizer
    +670      */
    +671     public static String translatePath(String toProcess) {
    +672         if (toProcess == null || toProcess.length() == 0) {
    +673             return "";
    +674         }
    +675         StringBuffer path = new StringBuffer(toProcess.length() + EXPAND_SPACE);
    +676         PathTokenizer tokenizer = new PathTokenizer(toProcess);
    +677         while (tokenizer.hasMoreTokens()) {
    +678             String pathComponent = tokenizer.nextToken();
    +679             pathComponent = pathComponent.replace('/', File.separatorChar);
    +680             pathComponent = pathComponent.replace('\\', File.separatorChar);
    +681             if (path.length() != 0) {
    +682                 path.append(File.pathSeparatorChar);
    +683             }
    +684             path.append(pathComponent);
    +685         }
    +686         return path.toString();
    +687     }
    +688 
    +689     /**
    +690      * &quot;Normalize&quot; the given absolute path.
    +691      *
    +692      * <p>
    +693      * This includes:
    +694      * <ul>
    +695      * <li>Uppercase the drive letter if there is one.</li>
    +696      * <li>Remove redundant slashes after the drive spec.</li>
    +697      * <li>Resolve all ./, .\, ../ and ..\ sequences.</li>
    +698      * <li>DOS style paths that start with a drive letter will have \ as the separator.</li>
    +699      * </ul>
    +700      * Unlike {@link File#getCanonicalPath()} this method specifically does not resolve symbolic links.
    +701      *
    +702      * @param path the path to be normalized.
    +703      * @return the normalized version of the path.
    +704      *
    +705      * @throws java.lang.NullPointerException if path is null.
    +706      */
    +707     public File normalize(final String path) {
    +708         Stack s = new Stack();
    +709         String[] dissect = dissect(path);
    +710         s.push(dissect[0]);
    +711 
    +712         StringTokenizer tok = new StringTokenizer(dissect[1], File.separator);
    +713         while (tok.hasMoreTokens()) {
    +714             String thisToken = tok.nextToken();
    +715             if (".".equals(thisToken)) {
    +716                 continue;
    +717             }
    +718             if ("..".equals(thisToken)) {
    +719                 if (s.size() < 2) {
    +720                     // Cannot resolve it, so skip it.
    +721                     return new File(path);
    +722                 }
    +723                 s.pop();
    +724             } else { // plain component
    +725                 s.push(thisToken);
    +726             }
    +727         }
    +728         StringBuffer sb = new StringBuffer();
    +729         final int size = s.size();
    +730         for (int i = 0; i < size; i++) {
    +731             if (i > 1) {
    +732                 // not before the filesystem root and not after it, since root
    +733                 // already contains one
    +734                 sb.append(File.separatorChar);
    +735             }
    +736             sb.append(s.elementAt(i));
    +737         }
    +738         return new File(sb.toString());
    +739     }
    +740 
    +741     /**
    +742      * Dissect the specified absolute path.
    +743      *
    +744      * @param path the path to dissect.
    +745      * @return String[] {root, remaining path}.
    +746      * @throws java.lang.NullPointerException if path is null.
    +747      * @since Ant 1.7
    +748      */
    +749     public String[] dissect(String path) {
    +750         char sep = File.separatorChar;
    +751         path = path.replace('/', sep).replace('\\', sep);
    +752 
    +753         // make sure we are dealing with an absolute path
    +754         if (!isAbsolutePath(path)) {
    +755             throw new BuildException(path + " is not an absolute path");
    +756         }
    +757         String root = null;
    +758         int colon = path.indexOf(':');
    +759         if (colon > 0 && (ON_DOS || ON_NETWARE)) {
    +760 
    +761             int next = colon + 1;
    +762             root = path.substring(0, next);
    +763             char[] ca = path.toCharArray();
    +764             root += sep;
    +765             //remove the initial separator; the root has it.
    +766             next = (ca[next] == sep) ? next + 1 : next;
    +767 
    +768             StringBuffer sbPath = new StringBuffer();
    +769             // Eliminate consecutive slashes after the drive spec:
    +770             for (int i = next; i < ca.length; i++) {
    +771                 if (ca[i] != sep || ca[i - 1] != sep) {
    +772                     sbPath.append(ca[i]);
    +773                 }
    +774             }
    +775             path = sbPath.toString();
    +776         } else if (path.length() > 1 && path.charAt(1) == sep) {
    +777             // UNC drive
    +778             int nextsep = path.indexOf(sep, 2);
    +779             nextsep = path.indexOf(sep, nextsep + 1);
    +780             root = (nextsep > 2) ? path.substring(0, nextsep + 1) : path;
    +781             path = path.substring(root.length());
    +782         } else {
    +783             root = File.separator;
    +784             path = path.substring(1);
    +785         }
    +786         return new String[]{root, path};
    +787     }
    +788 
    +789     /**
    +790      * Returns a VMS String representation of a <code>File</code> object. This is useful since the JVM by default
    +791      * internally converts VMS paths to Unix style. The returned String is always an absolute path.
    +792      *
    +793      * @param f The <code>File</code> to get the VMS path for.
    +794      * @return The absolute VMS path to <code>f</code>.
    +795      */
    +796     public String toVMSPath(File f) {
    +797         // format: "DEVICE:[DIR.SUBDIR]FILE"
    +798         String osPath;
    +799         String path = normalize(f.getAbsolutePath()).getPath();
    +800         String name = f.getName();
    +801         boolean isAbsolute = path.charAt(0) == File.separatorChar;
    +802         // treat directories specified using .DIR syntax as files
    +803         // CheckStyle:MagicNumber OFF
    +804         boolean isDirectory = f.isDirectory()
    +805                 && !name.regionMatches(true, name.length() - 4, ".DIR", 0, 4);
    +806         // CheckStyle:MagicNumber ON
    +807         String device = null;
    +808         StringBuffer directory = null;
    +809         String file = null;
    +810 
    +811         int index = 0;
    +812 
    +813         if (isAbsolute) {
    +814             index = path.indexOf(File.separatorChar, 1);
    +815             if (index == -1) {
    +816                 return path.substring(1) + ":[000000]";
    +817             }
    +818             device = path.substring(1, index++);
    +819         }
    +820         if (isDirectory) {
    +821             directory = new StringBuffer(path.substring(index).replace(File.separatorChar, '.'));
    +822         } else {
    +823             int dirEnd = path.lastIndexOf(File.separatorChar, path.length());
    +824             if (dirEnd == -1 || dirEnd < index) {
    +825                 file = path.substring(index);
    +826             } else {
    +827                 directory = new StringBuffer(path.substring(index, dirEnd).
    +828                         replace(File.separatorChar, '.'));
    +829                 index = dirEnd + 1;
    +830                 if (path.length() > index) {
    +831                     file = path.substring(index);
    +832                 }
    +833             }
    +834         }
    +835         if (!isAbsolute && directory != null) {
    +836             directory.insert(0, '.');
    +837         }
    +838         osPath = ((device != null) ? device + ":" : "")
    +839                 + ((directory != null) ? "[" + directory + "]" : "")
    +840                 + ((file != null) ? file : "");
    +841         return osPath;
    +842     }
    +843 
    +844     /**
    +845      * Create a File object for a temporary file in a given directory. Without actually creating the file.
    +846      *
    +847      * <p>
    +848      * The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent
    +849      * invocation of this method will yield a different file name.
    +850      * </p>
    +851      * <p>
    +852      * The filename is prefixNNNNNsuffix where NNNN is a random number.
    +853      * </p>
    +854      *
    +855      * @param prefix prefix before the random number.
    +856      * @param suffix file extension; include the '.'.
    +857      * @param parentDir Directory to create the temporary file in; java.io.tmpdir used if not specified.
    +858      *
    +859      * @deprecated since ant 1.7.1 use createTempFile(String, String, File, boolean, boolean) instead.
    +860      * @return a File reference to the new, nonexistent temporary file.
    +861      */
    +862     public File createTempFile(String prefix, String suffix, File parentDir) {
    +863         return createTempFile(prefix, suffix, parentDir, false, false);
    +864     }
    +865 
    +866     private static final String NULL_PLACEHOLDER = "null";
    +867 
    +868     /**
    +869      * Create a temporary file in a given directory.
    +870      *
    +871      * <p>
    +872      * The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent
    +873      * invocation of this method will yield a different file name.</p>
    +874      *
    +875      * @param prefix prefix before the random number.
    +876      * @param suffix file extension; include the '.'.
    +877      * @param parentDir Directory to create the temporary file in; java.io.tmpdir used if not specified.
    +878      * @param deleteOnExit whether to set the tempfile for deletion on normal VM exit.
    +879      * @param createFile true if the file must actually be created. If false chances exist that a file with the same
    +880      * name is created in the time between invoking this method and the moment the file is actually created. If possible
    +881      * set to true.
    +882      *
    +883      * @return a File reference to the new temporary file.
    +884      * @since Ant 1.7.1
    +885      */
    +886     public File createTempFile(String prefix, String suffix, File parentDir,
    +887             boolean deleteOnExit, boolean createFile) {
    +888         File result = null;
    +889         String parent = (parentDir == null)
    +890                 ? System.getProperty("java.io.tmpdir")
    +891                 : parentDir.getPath();
    +892         if (prefix == null) {
    +893             prefix = NULL_PLACEHOLDER;
    +894         }
    +895         if (suffix == null) {
    +896             suffix = NULL_PLACEHOLDER;
    +897         }
    +898 
    +899         if (createFile) {
    +900             try {
    +901                 result = File.createTempFile(prefix, suffix, new File(parent));
    +902             } catch (IOException e) {
    +903                 throw new BuildException("Could not create tempfile in "
    +904                         + parent, e);
    +905             }
    +906         } else {
    +907             DecimalFormat fmt = new DecimalFormat("#####");
    +908             synchronized (rand) {
    +909                 do {
    +910                     result = new File(parent, prefix
    +911                             + fmt.format(rand.nextInt(Integer.MAX_VALUE)) + suffix);
    +912                 } while (result.exists());
    +913             }
    +914         }
    +915 
    +916         if (deleteOnExit) {
    +917             result.deleteOnExit();
    +918         }
    +919         return result;
    +920     }
    +921 
    +922     /**
    +923      * Create a File object for a temporary file in a given directory. Without actually creating the file.
    +924      *
    +925      * <p>
    +926      * The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent
    +927      * invocation of this method will yield a different file name.
    +928      * </p>
    +929      * <p>
    +930      * The filename is prefixNNNNNsuffix where NNNN is a random number.
    +931      * </p>
    +932      *
    +933      * @param prefix prefix before the random number.
    +934      * @param suffix file extension; include the '.'.
    +935      * @param parentDir Directory to create the temporary file in; java.io.tmpdir used if not specified.
    +936      * @param deleteOnExit whether to set the tempfile for deletion on normal VM exit.
    +937      *
    +938      * @deprecated since ant 1.7.1 use createTempFile(String, String, File, boolean, boolean) instead.
    +939      * @return a File reference to the new, nonexistent temporary file.
    +940      */
    +941     public File createTempFile(String prefix, String suffix,
    +942             File parentDir, boolean deleteOnExit) {
    +943         return createTempFile(prefix, suffix, parentDir, deleteOnExit, false);
    +944     }
    +945 
    +946 //    /**
    +947 //     * Compares the contents of two files.
    +948 //     *
    +949 //     * @param f1 the file whose content is to be compared.
    +950 //     * @param f2 the other file whose content is to be compared.
    +951 //     *
    +952 //     * @return true if the content of the files is the same.
    +953 //     *
    +954 //     * @throws IOException if the files cannot be read.
    +955 //     */
    +956 //    public boolean contentEquals(File f1, File f2) throws IOException {
    +957 //        return contentEquals(f1, f2, false);
    +958 //    }
    +959 //
    +960 //    /**
    +961 //     * Compares the contents of two files.
    +962 //     *
    +963 //     * @param f1 the file whose content is to be compared.
    +964 //     * @param f2 the other file whose content is to be compared.
    +965 //     * @param textfile true if the file is to be treated as a text file and
    +966 //     *        differences in kind of line break are to be ignored.
    +967 //     *
    +968 //     * @return true if the content of the files is the same.
    +969 //     *
    +970 //     * @throws IOException if the files cannot be read.
    +971 //     * @since Ant 1.6.3
    +972 //     */
    +973 //    public boolean contentEquals(File f1, File f2, boolean textfile) throws IOException {
    +974 //        return ResourceUtils.contentEquals(new FileResource(f1), new FileResource(f2), textfile);
    +975 //    }
    +976     /**
    +977      * This was originally an emulation of {@link File#getParentFile} for JDK 1.1, but it is now implemented using that
    +978      * method (Ant 1.6.3 onwards).
    +979      *
    +980      * @param f the file whose parent is required.
    +981      * @return the given file's parent, or null if the file does not have a parent.
    +982      * @since 1.10
    +983      * @deprecated since 1.7. Just use {@link File#getParentFile} directly.
    +984      */
    +985     public File getParentFile(File f) {
    +986         return (f == null) ? null : f.getParentFile();
    +987     }
    +988 
    +989     /**
    +990      * Read from reader till EOF.
    +991      *
    +992      * @param rdr the reader from which to read.
    +993      * @return the contents read out of the given reader.
    +994      *
    +995      * @throws IOException if the contents could not be read out from the reader.
    +996      */
    +997     public static String readFully(Reader rdr) throws IOException {
    +998         return readFully(rdr, BUF_SIZE);
    +999     }
    +1000 
    +1001     /**
    +1002      * Read from reader till EOF.
    +1003      *
    +1004      * @param rdr the reader from which to read.
    +1005      * @param bufferSize the buffer size to use when reading.
    +1006      *
    +1007      * @return the contents read out of the given reader.
    +1008      *
    +1009      * @throws IOException if the contents could not be read out from the reader.
    +1010      */
    +1011     public static String readFully(Reader rdr, int bufferSize)
    +1012             throws IOException {
    +1013         if (bufferSize <= 0) {
    +1014             throw new IllegalArgumentException("Buffer size must be greater "
    +1015                     + "than 0");
    +1016         }
    +1017         final char[] buffer = new char[bufferSize];
    +1018         int bufferLength = 0;
    +1019         StringBuffer textBuffer = null;
    +1020         while (bufferLength != -1) {
    +1021             bufferLength = rdr.read(buffer);
    +1022             if (bufferLength > 0) {
    +1023                 textBuffer = (textBuffer == null) ? new StringBuffer() : textBuffer;
    +1024                 textBuffer.append(new String(buffer, 0, bufferLength));
    +1025             }
    +1026         }
    +1027         return (textBuffer == null) ? null : textBuffer.toString();
    +1028     }
    +1029 
    +1030     /**
    +1031      * Safe read fully - do not return a null for an empty reader.
    +1032      *
    +1033      * @param reader the input to read from.
    +1034      * @return the string.
    +1035      * @throws IOException if unable to read from reader.
    +1036      * @since Ant 1.7.1
    +1037      */
    +1038     public static String safeReadFully(Reader reader) throws IOException {
    +1039         String ret = readFully(reader);
    +1040         return ret == null ? "" : ret;
    +1041     }
    +1042 
    +1043     /**
    +1044      * This was originally an emulation of File.createNewFile for JDK 1.1, but it is now implemented using that method
    +1045      * (Ant 1.6.3 onwards).
    +1046      *
    +1047      * <p>
    +1048      * This method has historically <strong>not</strong> guaranteed that the operation was atomic. In its current
    +1049      * implementation it is.
    +1050      *
    +1051      * @param f the file to be created.
    +1052      * @return true if the file did not exist already.
    +1053      * @throws IOException on error.
    +1054      * @since Ant 1.5
    +1055      */
    +1056     public boolean createNewFile(File f) throws IOException {
    +1057         return f.createNewFile();
    +1058     }
    +1059 
    +1060     /**
    +1061      * Create a new file, optionally creating parent directories.
    +1062      *
    +1063      * @param f the file to be created.
    +1064      * @param mkdirs <code>boolean</code> whether to create parent directories.
    +1065      * @return true if the file did not exist already.
    +1066      * @throws IOException on error.
    +1067      * @since Ant 1.6.3
    +1068      */
    +1069     public boolean createNewFile(File f, boolean mkdirs) throws IOException {
    +1070         File parent = f.getParentFile();
    +1071         if (mkdirs && !(parent.exists())) {
    +1072             parent.mkdirs();
    +1073         }
    +1074         return f.createNewFile();
    +1075     }
    +1076 
    +1077     /**
    +1078      * Checks whether a given file is a symbolic link.
    +1079      *
    +1080      * <p>
    +1081      * It doesn't really test for symbolic links but whether the canonical and absolute paths of the file are
    +1082      * identical--this may lead to false positives on some platforms.</p>
    +1083      *
    +1084      * @param parent the parent directory of the file to test
    +1085      * @param name the name of the file to test.
    +1086      *
    +1087      * @return true if the file is a symbolic link.
    +1088      * @throws IOException on error.
    +1089      * @since Ant 1.5
    +1090      * @deprecated use SymbolicLinkUtils instead
    +1091      */
    +1092     public boolean isSymbolicLink(File parent, String name)
    +1093             throws IOException {
    +1094         SymbolicLinkUtils u = SymbolicLinkUtils.getSymbolicLinkUtils();
    +1095         if (parent == null) {
    +1096             return u.isSymbolicLink(name);
    +1097         }
    +1098         return u.isSymbolicLink(parent, name);
    +1099     }
    +1100 
    +1101     /**
    +1102      * Removes a leading path from a second path.
    +1103      *
    +1104      * @param leading The leading path, must not be null, must be absolute.
    +1105      * @param path The path to remove from, must not be null, must be absolute.
    +1106      *
    +1107      * @return path's normalized absolute if it doesn't start with leading; path's path with leading's path removed
    +1108      * otherwise.
    +1109      *
    +1110      * @since Ant 1.5
    +1111      */
    +1112     public String removeLeadingPath(File leading, File path) {
    +1113         String l = normalize(leading.getAbsolutePath()).getAbsolutePath();
    +1114         String p = normalize(path.getAbsolutePath()).getAbsolutePath();
    +1115         if (l.equals(p)) {
    +1116             return "";
    +1117         }
    +1118         // ensure that l ends with a /
    +1119         // so we never think /foo was a parent directory of /foobar
    +1120         if (!l.endsWith(File.separator)) {
    +1121             l += File.separator;
    +1122         }
    +1123         return (p.startsWith(l)) ? p.substring(l.length()) : p;
    +1124     }
    +1125 
    +1126     /**
    +1127      * Learn whether one path "leads" another.
    +1128      *
    +1129      * @param leading The leading path, must not be null, must be absolute.
    +1130      * @param path The path to remove from, must not be null, must be absolute.
    +1131      * @return true if path starts with leading; false otherwise.
    +1132      * @since Ant 1.7
    +1133      */
    +1134     public boolean isLeadingPath(File leading, File path) {
    +1135         String l = normalize(leading.getAbsolutePath()).getAbsolutePath();
    +1136         String p = normalize(path.getAbsolutePath()).getAbsolutePath();
    +1137         if (l.equals(p)) {
    +1138             return true;
    +1139         }
    +1140         // ensure that l ends with a /
    +1141         // so we never think /foo was a parent directory of /foobar
    +1142         if (!l.endsWith(File.separator)) {
    +1143             l += File.separator;
    +1144         }
    +1145         return p.startsWith(l);
    +1146     }
    +1147 
    +1148     /**
    +1149      * Constructs a <code>file:</code> URI that represents the external form of the given pathname.
    +1150      *
    +1151      * <p>
    +1152      * Will be an absolute URI if the given path is absolute.</p>
    +1153      *
    +1154      * <p>
    +1155      * This code encodes non ASCII characters too.</p>
    +1156      *
    +1157      * <p>
    +1158      * The coding of the output is the same as what File.toURI().toASCIIString() produces</p>
    +1159      *
    +1160      * See <a href="http://www.w3.org/TR/xml11/#dt-sysid">dt-sysid</a>
    +1161      * which makes some mention of how characters not supported by URI Reference syntax should be escaped.
    +1162      *
    +1163      * @param path the path in the local file system.
    +1164      * @return the URI version of the local path.
    +1165      * @since Ant 1.6
    +1166      */
    +1167     public String toURI(String path) {
    +1168         return new File(path).toURI().toASCIIString();
    +1169     }
    +1170 
    +1171     /**
    +1172      * Constructs a file path from a <code>file:</code> URI.
    +1173      *
    +1174      * <p>
    +1175      * Will be an absolute path if the given URI is absolute.</p>
    +1176      *
    +1177      * <p>
    +1178      * Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.</p>
    +1179      *
    +1180      * @param uri the URI designating a file in the local filesystem.
    +1181      * @return the local file system path for the file.
    +1182      * @since Ant 1.6
    +1183      */
    +1184     public String fromURI(String uri) {
    +1185         synchronized (cacheFromUriLock) {
    +1186             if (uri.equals(cacheFromUriRequest)) {
    +1187                 return cacheFromUriResponse;
    +1188             }
    +1189             String path = Locator.fromURI(uri);
    +1190             String ret = isAbsolutePath(path) ? normalize(path).getAbsolutePath() : path;
    +1191             cacheFromUriRequest = uri;
    +1192             cacheFromUriResponse = ret;
    +1193             return ret;
    +1194         }
    +1195     }
    +1196 
    +1197     /**
    +1198      * Compares two filenames.
    +1199      *
    +1200      * <p>
    +1201      * Unlike java.io.File#equals this method will try to compare the absolute paths and &quot;normalize&quot; the
    +1202      * filenames before comparing them.</p>
    +1203      *
    +1204      * @param f1 the file whose name is to be compared.
    +1205      * @param f2 the other file whose name is to be compared.
    +1206      *
    +1207      * @return true if the file are for the same file.
    +1208      *
    +1209      * @since Ant 1.5.3
    +1210      */
    +1211     public boolean fileNameEquals(File f1, File f2) {
    +1212         return normalize(f1.getAbsolutePath()).getAbsolutePath().equals(
    +1213                 normalize(f2.getAbsolutePath()).getAbsolutePath());
    +1214     }
    +1215 
    +1216     /**
    +1217      * Are the two File instances pointing to the same object on the file system?
    +1218      *
    +1219      * @since Ant 1.8.2
    +1220      */
    +1221     public boolean areSame(File f1, File f2) throws IOException {
    +1222         if (f1 == null && f2 == null) {
    +1223             return true;
    +1224         }
    +1225         if (f1 == null || f2 == null) {
    +1226             return false;
    +1227         }
    +1228         File f1Normalized = normalize(f1.getAbsolutePath());
    +1229         File f2Normalized = normalize(f2.getAbsolutePath());
    +1230         return f1Normalized.equals(f2Normalized)
    +1231                 || f1Normalized.getCanonicalFile().equals(f2Normalized
    +1232                         .getCanonicalFile());
    +1233     }
    +1234 //
    +1235 //    /**
    +1236 //     * Renames a file, even if that involves crossing file system boundaries.
    +1237 //     *
    +1238 //     * <p>
    +1239 //     * This will remove <code>to</code> (if it exists), ensure that <code>to</code>'s parent directory exists and move
    +1240 //     * <code>from</code>, which involves deleting <code>from</code> as well.</p>
    +1241 //     *
    +1242 //     * @param from the file to move.
    +1243 //     * @param to the new file name.
    +1244 //     *
    +1245 //     * @throws IOException if anything bad happens during this process. Note that <code>to</code> may have been deleted
    +1246 //     * already when this happens.
    +1247 //     *
    +1248 //     * @since Ant 1.6
    +1249 //     */
    +1250 //    public void rename(File from, File to) throws IOException {
    +1251 //        // identical logic lives in Move.renameFile():
    +1252 //        from = normalize(from.getAbsolutePath()).getCanonicalFile();
    +1253 //        to = normalize(to.getAbsolutePath());
    +1254 //        if (!from.exists()) {
    +1255 //            System.err.println("Cannot rename nonexistent file " + from);
    +1256 //            return;
    +1257 //        }
    +1258 //        if (from.getAbsolutePath().equals(to.getAbsolutePath())) {
    +1259 //            System.err.println("Rename of " + from + " to " + to + " is a no-op.");
    +1260 //            return;
    +1261 //        }
    +1262 //        if (to.exists() && !(areSame(from, to) || tryHardToDelete(to))) {
    +1263 //            throw new IOException("Failed to delete " + to + " while trying to rename " + from);
    +1264 //        }
    +1265 //        File parent = to.getParentFile();
    +1266 //        if (parent != null && !parent.isDirectory()
    +1267 //                && !(parent.mkdirs() || parent.isDirectory())) {
    +1268 //            throw new IOException("Failed to create directory " + parent
    +1269 //                    + " while trying to rename " + from);
    +1270 //        }
    +1271 //        if (!from.renameTo(to)) {
    +1272 //            copyFile(from, to);
    +1273 //            if (!tryHardToDelete(from)) {
    +1274 //                throw new IOException("Failed to delete " + from + " while trying to rename it.");
    +1275 //            }
    +1276 //        }
    +1277 //    }
    +1278 
    +1279     /**
    +1280      * Get the granularity of file timestamps. The choice is made based on OS, which is incorrect--it should really be
    +1281      * by filesystem. We do not have an easy way to probe for file systems, however, so this heuristic gives us a decent
    +1282      * default.
    +1283      *
    +1284      * @return the difference, in milliseconds, which two file timestamps must have in order for the two files to be
    +1285      * considered to have different timestamps.
    +1286      */
    +1287     public long getFileTimestampGranularity() {
    +1288         if (ON_WIN9X) {
    +1289             return FAT_FILE_TIMESTAMP_GRANULARITY;
    +1290         }
    +1291         if (ON_WINDOWS) {
    +1292             return NTFS_FILE_TIMESTAMP_GRANULARITY;
    +1293         }
    +1294         if (ON_DOS) {
    +1295             return FAT_FILE_TIMESTAMP_GRANULARITY;
    +1296         }
    +1297         return UNIX_FILE_TIMESTAMP_GRANULARITY;
    +1298     }
    +1299 
    +1300     /**
    +1301      * test whether a file or directory exists, with an error in the upper/lower case spelling of the name. Using this
    +1302      * method is only interesting on case insensitive file systems (Windows).<br/>
    +1303      * It will return true only if 3 conditions are met :
    +1304      * <br/>
    +1305      * <ul>
    +1306      * <li>operating system is case insensitive</li>
    +1307      * <li>file exists</li>
    +1308      * <li>actual name from directory reading is different from the supplied argument</li>
    +1309      * </ul>
    +1310      * <br/>
    +1311      * the purpose is to identify files or directories on case-insensitive filesystems whose case is not what is
    +1312      * expected.<br/>
    +1313      * Possibly to rename them afterwards to the desired upper/lowercase combination.
    +1314      * <br/>
    +1315      *
    +1316      * @param localFile file to test
    +1317      * @return true if the file exists and the case of the actual file is not the case of the parameter
    +1318      * @since Ant 1.7.1
    +1319      */
    +1320     public boolean hasErrorInCase(File localFile) {
    +1321         localFile = normalize(localFile.getAbsolutePath());
    +1322         if (!localFile.exists()) {
    +1323             return false;
    +1324         }
    +1325         final String localFileName = localFile.getName();
    +1326         FilenameFilter ff = new FilenameFilter() {
    +1327             public boolean accept(File dir, String name) {
    +1328                 return name.equalsIgnoreCase(localFileName) && (!name.equals(localFileName));
    +1329             }
    +1330         };
    +1331         String[] names = localFile.getParentFile().list(ff);
    +1332         return names != null && names.length == 1;
    +1333     }
    +1334 
    +1335     /**
    +1336      * Returns true if the source is older than the dest. If the dest file does not exist, then the test returns false;
    +1337      * it is implicitly not up do date.
    +1338      *
    +1339      * @param source source file (should be the older).
    +1340      * @param dest dest file (should be the newer).
    +1341      * @param granularity an offset added to the source time.
    +1342      * @return true if the source is older than the dest after accounting for granularity.
    +1343      * @since Ant 1.6.3
    +1344      */
    +1345     public boolean isUpToDate(File source, File dest, long granularity) {
    +1346         //do a check for the destination file existing
    +1347         if (!dest.exists()) {
    +1348             //if it does not, then the file is not up to date.
    +1349             return false;
    +1350         }
    +1351         long sourceTime = source.lastModified();
    +1352         long destTime = dest.lastModified();
    +1353         return isUpToDate(sourceTime, destTime, granularity);
    +1354     }
    +1355 
    +1356     /**
    +1357      * Returns true if the source is older than the dest.
    +1358      *
    +1359      * @param source source file (should be the older).
    +1360      * @param dest dest file (should be the newer).
    +1361      * @return true if the source is older than the dest, taking the granularity into account.
    +1362      * @since Ant 1.6.3
    +1363      */
    +1364     public boolean isUpToDate(File source, File dest) {
    +1365         return isUpToDate(source, dest, getFileTimestampGranularity());
    +1366     }
    +1367 
    +1368     /**
    +1369      * Compare two timestamps for being up to date using the specified granularity.
    +1370      *
    +1371      * @param sourceTime timestamp of source file.
    +1372      * @param destTime timestamp of dest file.
    +1373      * @param granularity os/filesys granularity.
    +1374      * @return true if the dest file is considered up to date.
    +1375      */
    +1376     public boolean isUpToDate(long sourceTime, long destTime, long granularity) {
    +1377         return destTime != -1 && destTime >= sourceTime + granularity;
    +1378     }
    +1379 
    +1380     /**
    +1381      * Compare two timestamps for being up to date using the current granularity.
    +1382      *
    +1383      * @param sourceTime timestamp of source file.
    +1384      * @param destTime timestamp of dest file.
    +1385      * @return true if the dest file is considered up to date.
    +1386      */
    +1387     public boolean isUpToDate(long sourceTime, long destTime) {
    +1388         return isUpToDate(sourceTime, destTime, getFileTimestampGranularity());
    +1389     }
    +1390 
    +1391     /**
    +1392      * Close a Writer without throwing any exception if something went wrong. Do not attempt to close it if the argument
    +1393      * is null.
    +1394      *
    +1395      * @param device output writer, can be null.
    +1396      */
    +1397     public static void close(Writer device) {
    +1398         if (null != device) {
    +1399             try {
    +1400                 device.close();
    +1401             } catch (IOException e) {
    +1402                 //ignore
    +1403             }
    +1404         }
    +1405     }
    +1406 
    +1407     /**
    +1408      * Close a Reader without throwing any exception if something went wrong. Do not attempt to close it if the argument
    +1409      * is null.
    +1410      *
    +1411      * @param device Reader, can be null.
    +1412      */
    +1413     public static void close(Reader device) {
    +1414         if (null != device) {
    +1415             try {
    +1416                 device.close();
    +1417             } catch (IOException e) {
    +1418                 //ignore
    +1419             }
    +1420         }
    +1421     }
    +1422 
    +1423     /**
    +1424      * Close a stream without throwing any exception if something went wrong. Do not attempt to close it if the argument
    +1425      * is null.
    +1426      *
    +1427      * @param device stream, can be null.
    +1428      */
    +1429     public static void close(OutputStream device) {
    +1430         if (null != device) {
    +1431             try {
    +1432                 device.close();
    +1433             } catch (IOException e) {
    +1434                 //ignore
    +1435             }
    +1436         }
    +1437     }
    +1438 
    +1439     /**
    +1440      * Close a stream without throwing any exception if something went wrong. Do not attempt to close it if the argument
    +1441      * is null.
    +1442      *
    +1443      * @param device stream, can be null.
    +1444      */
    +1445     public static void close(InputStream device) {
    +1446         if (null != device) {
    +1447             try {
    +1448                 device.close();
    +1449             } catch (IOException e) {
    +1450                 //ignore
    +1451             }
    +1452         }
    +1453     }
    +1454 
    +1455     /**
    +1456      * Close a Channel without throwing any exception if something went wrong. Do not attempt to close it if the
    +1457      * argument is null.
    +1458      *
    +1459      * @param device channel, can be null.
    +1460      * @since Ant 1.8.0
    +1461      */
    +1462     public static void close(Channel device) {
    +1463         if (null != device) {
    +1464             try {
    +1465                 device.close();
    +1466             } catch (IOException e) {
    +1467                 //ignore
    +1468             }
    +1469         }
    +1470     }
    +1471 
    +1472     /**
    +1473      * Closes an URLConnection if its concrete implementation provides a way to close it that Ant knows of.
    +1474      *
    +1475      * @param conn connection, can be null
    +1476      * @since Ant 1.8.0
    +1477      */
    +1478     public static void close(URLConnection conn) {
    +1479         if (conn != null) {
    +1480             try {
    +1481                 if (conn instanceof JarURLConnection) {
    +1482                     JarURLConnection juc = (JarURLConnection) conn;
    +1483                     JarFile jf = juc.getJarFile();
    +1484                     jf.close();
    +1485                     jf = null;
    +1486                 } else if (conn instanceof HttpURLConnection) {
    +1487                     ((HttpURLConnection) conn).disconnect();
    +1488                 }
    +1489             } catch (IOException exc) {
    +1490                 //ignore
    +1491             }
    +1492         }
    +1493     }
    +1494 
    +1495     /**
    +1496      * Delete the file with {@link File#delete()} if the argument is not null. Do nothing on a null argument.
    +1497      *
    +1498      * @param file file to delete.
    +1499      */
    +1500     public static void delete(File file) {
    +1501         if (file != null) {
    +1502             file.delete();
    +1503         }
    +1504     }
    +1505 
    +1506     /**
    +1507      * Accommodate Windows bug encountered in both Sun and IBM JDKs. Others possible. If the delete does not work, call
    +1508      * System.gc(), wait a little and try again.
    +1509      *
    +1510      * @return whether deletion was successful
    +1511      * @since Ant 1.8.0
    +1512      */
    +1513     public boolean tryHardToDelete(File f) {
    +1514         return tryHardToDelete(f, ON_WINDOWS);
    +1515     }
    +1516 
    +1517     /**
    +1518      * If delete does not work, call System.gc() if asked to, wait a little and try again.
    +1519      *
    +1520      * @return whether deletion was successful
    +1521      * @since Ant 1.8.3
    +1522      */
    +1523     public boolean tryHardToDelete(File f, boolean runGC) {
    +1524         if (!f.delete()) {
    +1525             if (runGC) {
    +1526                 System.gc();
    +1527             }
    +1528             try {
    +1529                 Thread.sleep(DELETE_RETRY_SLEEP_MILLIS);
    +1530             } catch (InterruptedException ex) {
    +1531                 // Ignore Exception
    +1532             }
    +1533             return f.delete();
    +1534         }
    +1535         return true;
    +1536     }
    +1537 
    +1538     /**
    +1539      * Calculates the relative path between two files.
    +1540      * <p>
    +1541      * Implementation note:<br/> This function may throw an IOException if an I/O error occurs because its use of the
    +1542      * canonical pathname may require filesystem queries.
    +1543      * </p>
    +1544      *
    +1545      * @param fromFile the <code>File</code> to calculate the path from
    +1546      * @param toFile the <code>File</code> to calculate the path to
    +1547      * @return the relative path between the files
    +1548      * @throws Exception for undocumented reasons
    +1549      * @see File#getCanonicalPath()
    +1550      *
    +1551      * @since Ant 1.7
    +1552      */
    +1553     public static String getRelativePath(File fromFile, File toFile) throws Exception {
    +1554         String fromPath = fromFile.getCanonicalPath();
    +1555         String toPath = toFile.getCanonicalPath();
    +1556 
    +1557         // build the path stack info to compare
    +1558         String[] fromPathStack = getPathStack(fromPath);
    +1559         String[] toPathStack = getPathStack(toPath);
    +1560 
    +1561         if (0 < toPathStack.length && 0 < fromPathStack.length) {
    +1562             if (!fromPathStack[0].equals(toPathStack[0])) {
    +1563                 // not the same device (would be "" on Linux/Unix)
    +1564 
    +1565                 return getPath(Arrays.asList(toPathStack));
    +1566             }
    +1567         } else {
    +1568             // no comparison possible
    +1569             return getPath(Arrays.asList(toPathStack));
    +1570         }
    +1571 
    +1572         int minLength = Math.min(fromPathStack.length, toPathStack.length);
    +1573         int same = 1; // Used outside the for loop
    +1574 
    +1575         // get index of parts which are equal
    +1576         for (;
    +1577                 same < minLength && fromPathStack[same].equals(toPathStack[same]);
    +1578                 same++) {
    +1579             // Do nothing
    +1580         }
    +1581 
    +1582         List relativePathStack = new ArrayList();
    +1583 
    +1584         // if "from" part is longer, fill it up with ".."
    +1585         // to reach path which is equal to both paths
    +1586         for (int i = same; i < fromPathStack.length; i++) {
    +1587             relativePathStack.add("..");
    +1588         }
    +1589 
    +1590         // fill it up path with parts which were not equal
    +1591         for (int i = same; i < toPathStack.length; i++) {
    +1592             relativePathStack.add(toPathStack[i]);
    +1593         }
    +1594 
    +1595         return getPath(relativePathStack);
    +1596     }
    +1597 
    +1598     /**
    +1599      * Gets all names of the path as an array of <code>String</code>s.
    +1600      *
    +1601      * @param path to get names from
    +1602      * @return <code>String</code>s, never <code>null</code>
    +1603      *
    +1604      * @since Ant 1.7
    +1605      */
    +1606     public static String[] getPathStack(String path) {
    +1607         String normalizedPath = path.replace(File.separatorChar, '/');
    +1608 
    +1609         return normalizedPath.split("/");
    +1610     }
    +1611 
    +1612     /**
    +1613      * Gets path from a <code>List</code> of <code>String</code>s.
    +1614      *
    +1615      * @param pathStack <code>List</code> of <code>String</code>s to be concatenated as a path.
    +1616      * @return <code>String</code>, never <code>null</code>
    +1617      *
    +1618      * @since Ant 1.7
    +1619      */
    +1620     public static String getPath(List pathStack) {
    +1621         // can safely use '/' because Windows understands '/' as separator
    +1622         return getPath(pathStack, '/');
    +1623     }
    +1624 
    +1625     /**
    +1626      * Gets path from a <code>List</code> of <code>String</code>s.
    +1627      *
    +1628      * @param pathStack <code>List</code> of <code>String</code>s to be concated as a path.
    +1629      * @param separatorChar <code>char</code> to be used as separator between names in path
    +1630      * @return <code>String</code>, never <code>null</code>
    +1631      *
    +1632      * @since Ant 1.7
    +1633      */
    +1634     public static String getPath(final List pathStack, final char separatorChar) {
    +1635         final StringBuffer buffer = new StringBuffer();
    +1636 
    +1637         final Iterator iter = pathStack.iterator();
    +1638         if (iter.hasNext()) {
    +1639             buffer.append(iter.next());
    +1640         }
    +1641         while (iter.hasNext()) {
    +1642             buffer.append(separatorChar);
    +1643             buffer.append(iter.next());
    +1644         }
    +1645         return buffer.toString();
    +1646     }
    +1647 
    +1648     /**
    +1649      * Get the default encoding. This is done by opening an InputStreamReader on a dummy InputStream and getting the
    +1650      * encoding. Could use System.getProperty("file.encoding"), but cannot see where this is documented.
    +1651      *
    +1652      * @return the default file encoding.
    +1653      */
    +1654     public String getDefaultEncoding() {
    +1655         InputStreamReader is = new InputStreamReader(
    +1656                 new InputStream() {
    +1657                     public int read() {
    +1658                         return -1;
    +1659                     }
    +1660                 });
    +1661         try {
    +1662             return is.getEncoding();
    +1663         } finally {
    +1664             close(is);
    +1665         }
    +1666     }
    +1667 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/SymbolicLinkUtils.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/SymbolicLinkUtils.html new file mode 100644 index 000000000..54d70de43 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/SymbolicLinkUtils.html @@ -0,0 +1,304 @@ + + + +SymbolicLinkUtils xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.util;
    +19  
    +20  import java.io.File;
    +21  import java.io.FilenameFilter;
    +22  import java.io.IOException;
    +23  //import org.apache.tools.ant.Task;
    +24  //import org.apache.tools.ant.taskdefs.Execute;
    +25  
    +26  /**
    +27   * Contains methods related to symbolic links - or what Ant thinks is a symbolic link based on the absent support for
    +28   * them in Java.
    +29   *
    +30   * @since Ant 1.8.0
    +31   */
    +32  public class SymbolicLinkUtils {
    +33  
    +34      private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
    +35  
    +36      /**
    +37       * Shared instance.
    +38       */
    +39      private static final SymbolicLinkUtils PRIMARY_INSTANCE
    +40              = new SymbolicLinkUtils();
    +41  
    +42      /**
    +43       * Method to retrieve The SymbolicLinkUtils, which is shared by all users of this method.
    +44       *
    +45       * @return an instance of SymbolicLinkUtils.
    +46       */
    +47      public static SymbolicLinkUtils getSymbolicLinkUtils() {
    +48          // keep the door open for Java X.Y specific subclass if symbolic
    +49          // links ever become supported in the classlib
    +50          return PRIMARY_INSTANCE;
    +51      }
    +52  
    +53      /**
    +54       * Empty constructor.
    +55       */
    +56      protected SymbolicLinkUtils() {
    +57      }
    +58  
    +59      /**
    +60       * Checks whether a given file is a symbolic link.
    +61       *
    +62       * <p>
    +63       * It doesn't really test for symbolic links but whether the canonical and absolute paths of the file are
    +64       * identical--this may lead to false positives on some platforms.</p>
    +65       *
    +66       * @param file the file to test. Must not be null.
    +67       *
    +68       * @return true if the file is a symbolic link.
    +69       * @throws IOException on error.
    +70       */
    +71      public boolean isSymbolicLink(File file) throws IOException {
    +72          return isSymbolicLink(file.getParentFile(), file.getName());
    +73      }
    +74  
    +75      /**
    +76       * Checks whether a given file is a symbolic link.
    +77       *
    +78       * <p>
    +79       * It doesn't really test for symbolic links but whether the canonical and absolute paths of the file are
    +80       * identical--this may lead to false positives on some platforms.</p>
    +81       *
    +82       * @param name the name of the file to test.
    +83       *
    +84       * @return true if the file is a symbolic link.
    +85       * @throws IOException on error.
    +86       */
    +87      public boolean isSymbolicLink(String name) throws IOException {
    +88          return isSymbolicLink(new File(name));
    +89      }
    +90  
    +91      /**
    +92       * Checks whether a given file is a symbolic link.
    +93       *
    +94       * <p>
    +95       * It doesn't really test for symbolic links but whether the canonical and absolute paths of the file are
    +96       * identical--this may lead to false positives on some platforms.</p>
    +97       *
    +98       * @param parent the parent directory of the file to test
    +99       * @param name the name of the file to test.
    +100      *
    +101      * @return true if the file is a symbolic link.
    +102      * @throws IOException on error.
    +103      */
    +104     public boolean isSymbolicLink(File parent, String name)
    +105             throws IOException {
    +106         File toTest = parent != null
    +107                 ? new File(parent.getCanonicalPath(), name)
    +108                 : new File(name);
    +109         return !toTest.getAbsolutePath().equals(toTest.getCanonicalPath());
    +110     }
    +111 
    +112     /**
    +113      * Checks whether a given file is a broken symbolic link.
    +114      *
    +115      * <p>
    +116      * It doesn't really test for symbolic links but whether Java reports that the File doesn't exist but its parent's
    +117      * child list contains it--this may lead to false positives on some platforms.</p>
    +118      *
    +119      * <p>
    +120      * Note that #isSymbolicLink returns false if this method returns true since Java won't produce a canonical name
    +121      * different from the abolute one if the link is broken.</p>
    +122      *
    +123      * @param name the name of the file to test.
    +124      *
    +125      * @return true if the file is a broken symbolic link.
    +126      * @throws IOException on error.
    +127      */
    +128     public boolean isDanglingSymbolicLink(String name) throws IOException {
    +129         return isDanglingSymbolicLink(new File(name));
    +130     }
    +131 
    +132     /**
    +133      * Checks whether a given file is a broken symbolic link.
    +134      *
    +135      * <p>
    +136      * It doesn't really test for symbolic links but whether Java reports that the File doesn't exist but its parent's
    +137      * child list contains it--this may lead to false positives on some platforms.</p>
    +138      *
    +139      * <p>
    +140      * Note that #isSymbolicLink returns false if this method returns true since Java won't produce a canonical name
    +141      * different from the abolute one if the link is broken.</p>
    +142      *
    +143      * @param file the file to test.
    +144      *
    +145      * @return true if the file is a broken symbolic link.
    +146      * @throws IOException on error.
    +147      */
    +148     public boolean isDanglingSymbolicLink(File file) throws IOException {
    +149         return isDanglingSymbolicLink(file.getParentFile(), file.getName());
    +150     }
    +151 
    +152     /**
    +153      * Checks whether a given file is a broken symbolic link.
    +154      *
    +155      * <p>
    +156      * It doesn't really test for symbolic links but whether Java reports that the File doesn't exist but its parent's
    +157      * child list contains it--this may lead to false positives on some platforms.</p>
    +158      *
    +159      * <p>
    +160      * Note that #isSymbolicLink returns false if this method returns true since Java won't produce a canonical name
    +161      * different from the abolute one if the link is broken.</p>
    +162      *
    +163      * @param parent the parent directory of the file to test
    +164      * @param name the name of the file to test.
    +165      *
    +166      * @return true if the file is a broken symbolic link.
    +167      * @throws IOException on error.
    +168      */
    +169     public boolean isDanglingSymbolicLink(File parent, String name)
    +170             throws IOException {
    +171         File f = new File(parent, name);
    +172         if (!f.exists()) {
    +173             final String localName = f.getName();
    +174             String[] c = parent.list(new FilenameFilter() {
    +175                 public boolean accept(File d, String n) {
    +176                     return localName.equals(n);
    +177                 }
    +178             });
    +179             return c != null && c.length > 0;
    +180         }
    +181         return false;
    +182     }
    +183 //
    +184 //    /**
    +185 //     * Delete a symlink (without deleting the associated resource).
    +186 //     *
    +187 //     * <p>This is a utility method that removes a unix symlink without
    +188 //     * removing the resource that the symlink points to. If it is
    +189 //     * accidentally invoked on a real file, the real file will not be
    +190 //     * harmed, but silently ignored.</p>
    +191 //     *
    +192 //     * <p>Normally this method works by
    +193 //     * getting the canonical path of the link, using the canonical path to
    +194 //     * rename the resource (breaking the link) and then deleting the link.
    +195 //     * The resource is then returned to its original name inside a finally
    +196 //     * block to ensure that the resource is unharmed even in the event of
    +197 //     * an exception.</p>
    +198 //     *
    +199 //     * <p>There may be cases where the algorithm described above doesn't work,
    +200 //     * in that case the method tries to use the native "rm" command on
    +201 //     * the symlink instead.</p>
    +202 //     *
    +203 //     * @param link A <code>File</code> object of the symlink to delete.
    +204 //     * @param task An Ant Task required if "rm" needs to be invoked.
    +205 //     *
    +206 //     * @throws IOException If calls to <code>File.rename</code>,
    +207 //     * <code>File.delete</code> or <code>File.getCanonicalPath</code>
    +208 //     * fail.
    +209 //     * @throws BuildException if the execution of "rm" failed.
    +210 //     */
    +211 //    public void deleteSymbolicLink(File link, Task task)
    +212 //        throws IOException {
    +213 //        if (isDanglingSymbolicLink(link)) {
    +214 //            if (!link.delete()) {
    +215 //                throw new IOException("failed to remove dangling symbolic link "
    +216 //                                      + link);
    +217 //            }
    +218 //            return;
    +219 //        }
    +220 //
    +221 //        if (!isSymbolicLink(link)) {
    +222 //            // plain file, not a link
    +223 //            return;
    +224 //        }
    +225 //
    +226 //        if (!link.exists()) {
    +227 //            throw new FileNotFoundException("No such symbolic link: " + link);
    +228 //        }
    +229 //
    +230 //        // find the resource of the existing link:
    +231 //        File target = link.getCanonicalFile();
    +232 //
    +233 //        // no reason to try the renaming algorithm if we aren't allowed to
    +234 //        // write to the target's parent directory.  Let's hope that
    +235 //        // File.canWrite works on all platforms.
    +236 //
    +237 //        if (task == null || target.getParentFile().canWrite()) {
    +238 //
    +239 //            // rename the resource, thus breaking the link:
    +240 //            File temp = FILE_UTILS.createTempFile("symlink", ".tmp",
    +241 //                                                  target.getParentFile(), false,
    +242 //                                                  false);
    +243 //
    +244 //            if (FILE_UTILS.isLeadingPath(target, link)) {
    +245 //                // link points to a parent directory, renaming the parent
    +246 //                // will rename the file
    +247 //                link = new File(temp,
    +248 //                                FILE_UTILS.removeLeadingPath(target, link));
    +249 //            }
    +250 //
    +251 //            boolean renamedTarget = false;
    +252 //            try {
    +253 //                try {
    +254 //                    FILE_UTILS.rename(target, temp);
    +255 //                    renamedTarget = true;
    +256 //                } catch (IOException e) {
    +257 //                    throw new IOException("Couldn't rename resource when "
    +258 //                                          + "attempting to delete '" + link
    +259 //                                          + "'.  Reason: " + e.getMessage());
    +260 //                }
    +261 //                // delete the (now) broken link:
    +262 //                if (!link.delete()) {
    +263 //                    throw new IOException("Couldn't delete symlink: "
    +264 //                                          + link
    +265 //                                          + " (was it a real file? is this "
    +266 //                                          + "not a UNIX system?)");
    +267 //                }
    +268 //            } finally {
    +269 //                if (renamedTarget) {
    +270 //                    // return the resource to its original name:
    +271 //                    try {
    +272 //                        FILE_UTILS.rename(temp, target);
    +273 //                    } catch (IOException e) {
    +274 //                        throw new IOException("Couldn't return resource "
    +275 //                                              + temp
    +276 //                                              + " to its original name: "
    +277 //                                              + target.getAbsolutePath()
    +278 //                                              + ". Reason: " + e.getMessage()
    +279 //                                              + "\n THE RESOURCE'S NAME ON DISK"
    +280 //                                              + " HAS BEEN CHANGED BY THIS"
    +281 //                                              + " ERROR!\n");
    +282 //                    }
    +283 //                }
    +284 //            }
    +285 //        } else {
    +286 //            Execute.runCommand(task,
    +287 //                               new String[] {"rm", link.getAbsolutePath()});
    +288 //        }
    +289 //    }
    +290 
    +291 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/VectorSet.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/VectorSet.html new file mode 100644 index 000000000..501d23a0a --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/VectorSet.html @@ -0,0 +1,255 @@ + + + +VectorSet xref + + + +
    +1   /*
    +2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    +3    *  contributor license agreements.  See the NOTICE file distributed with
    +4    *  this work for additional information regarding copyright ownership.
    +5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    +6    *  (the "License"); you may not use this file except in compliance with
    +7    *  the License.  You may obtain a copy of the License at
    +8    *
    +9    *      http://www.apache.org/licenses/LICENSE-2.0
    +10   *
    +11   *  Unless required by applicable law or agreed to in writing, software
    +12   *  distributed under the License is distributed on an "AS IS" BASIS,
    +13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +14   *  See the License for the specific language governing permissions and
    +15   *  limitations under the License.
    +16   *
    +17   */
    +18  package org.owasp.dependencycheck.org.apache.tools.ant.util;
    +19  
    +20  import java.util.Collection;
    +21  import java.util.HashSet;
    +22  import java.util.LinkedList;
    +23  import java.util.Set;
    +24  import java.util.Vector;
    +25  
    +26  /**
    +27   * Subclass of Vector that won't store duplicate entries and shows
    +28   * HashSet's constant time performance characteristics for the
    +29   * contains method.
    +30   *
    +31   * <p>This is not a general purpose class but has been written because
    +32   * the protected members of {@link
    +33   * org.apache.tools.ant.DirectoryScanner DirectoryScanner} prohibited
    +34   * later revisions from using a more efficient collection.</p>
    +35   *
    +36   * <p>Methods are synchronized to keep Vector's contract.</p>
    +37   *
    +38   * @since Ant 1.8.0
    +39   */
    +40  public final class VectorSet<E> extends Vector<E> {
    +41      private static final long serialVersionUID = 1L;
    +42  
    +43      private final HashSet<E> set = new HashSet<E>();
    +44  
    +45      public VectorSet() { super(); }
    +46  
    +47      public VectorSet(int initialCapacity) { super(initialCapacity); }
    +48  
    +49      public VectorSet(int initialCapacity, int capacityIncrement) {
    +50          super(initialCapacity, capacityIncrement);
    +51      }
    +52  
    +53      public VectorSet(Collection<? extends E> c) {
    +54          if (c != null) {
    +55              for (E e : c) {
    +56                  add(e);
    +57              }
    +58          }
    +59      }
    +60  
    +61      public synchronized boolean add(E o) {
    +62          if (!set.contains(o)) {
    +63              doAdd(size(), o);
    +64              return true;
    +65          }
    +66          return false;
    +67      }
    +68  
    +69      /**
    +70       * This implementation may not add the element at the given index
    +71       * if it is already contained in the collection.
    +72       */
    +73      public void add(int index, E o) {
    +74          doAdd(index, o);
    +75      }
    +76  
    +77      private synchronized void doAdd(int index, E o) {
    +78          // Vector.add seems to delegate to insertElementAt, but this
    +79          // is not documented so we may better implement it ourselves
    +80          if (set.add(o)) {
    +81              int count = size();
    +82              ensureCapacity(count + 1);
    +83              if (index != count) {
    +84                  System.arraycopy(elementData, index, elementData, index + 1,
    +85                                   count - index);
    +86              }
    +87              elementData[index] = o;
    +88              elementCount++;
    +89          }
    +90      }
    +91  
    +92      public synchronized void addElement(E o) {
    +93          doAdd(size(), o);
    +94      }
    +95  
    +96      public synchronized boolean addAll(Collection<? extends E> c) {
    +97          boolean changed = false;
    +98          for (E e : c) {
    +99              changed |= add(e);
    +100         }
    +101         return changed;
    +102     }
    +103 
    +104     /**
    +105      * This implementation may not add all elements at the given index
    +106      * if any of them are already contained in the collection.
    +107      */
    +108     public synchronized boolean addAll(int index, Collection<? extends E> c) {
    +109         LinkedList toAdd = new LinkedList();
    +110         for (E e : c) {
    +111             if (set.add(e)) {
    +112                 toAdd.add(e);
    +113             }
    +114         }
    +115         if (toAdd.isEmpty()) {
    +116             return false;
    +117         }
    +118         int count = size();
    +119         ensureCapacity(count + toAdd.size());
    +120         if (index != count) {
    +121             System.arraycopy(elementData, index, elementData, index + toAdd.size(),
    +122                              count - index);
    +123         }
    +124         for (Object o : toAdd) {
    +125             elementData[index++] = o;
    +126         }
    +127         elementCount += toAdd.size();
    +128         return true;
    +129     }
    +130 
    +131     public synchronized void clear() {
    +132         super.clear();
    +133         set.clear();
    +134     }
    +135 
    +136     public Object clone() {
    +137         @SuppressWarnings("unchecked")
    +138         final VectorSet<E> vs = (VectorSet<E>) super.clone();
    +139         vs.set.addAll(set);
    +140         return vs;
    +141     }
    +142 
    +143     public synchronized boolean contains(Object o) {
    +144         return set.contains(o);
    +145     }
    +146 
    +147     public synchronized boolean containsAll(Collection<?> c) {
    +148         return set.containsAll(c);
    +149     }
    +150 
    +151     public void insertElementAt(E o, int index) {
    +152         doAdd(index, o);
    +153     }
    +154 
    +155     public synchronized E remove(int index) {
    +156         E o = get(index);
    +157         remove(o);
    +158         return o;
    +159     }
    +160 
    +161     public boolean remove(Object o) {
    +162         return doRemove(o);
    +163     }
    +164 
    +165     private synchronized boolean doRemove(Object o) {
    +166         // again, remove seems to delegate to removeElement, but we
    +167         // shouldn't trust it
    +168         if (set.remove(o)) {
    +169             int index = indexOf(o);
    +170             if (index < elementData.length - 1) {
    +171                 System.arraycopy(elementData, index + 1, elementData, index,
    +172                                  elementData.length - index - 1);
    +173             }
    +174             elementCount--;
    +175             return true;
    +176         }
    +177         return false;
    +178     }
    +179 
    +180     public synchronized boolean removeAll(Collection<?> c) {
    +181         boolean changed = false;
    +182         for (Object o : c) {
    +183             changed |= remove(o);
    +184         }
    +185         return changed;
    +186     }
    +187 
    +188     public synchronized void removeAllElements() {
    +189         set.clear();
    +190         super.removeAllElements();
    +191     }
    +192 
    +193     public boolean removeElement(Object o) {
    +194         return doRemove(o);
    +195     }
    +196 
    +197     public synchronized void removeElementAt(int index) {
    +198         remove(get(index));
    +199     }
    +200 
    +201     public synchronized void removeRange(final int fromIndex, int toIndex) {
    +202         while (toIndex > fromIndex) {
    +203             remove(--toIndex);
    +204         }
    +205     }
    +206 
    +207     public synchronized boolean retainAll(Collection<?> c) {
    +208         if (!(c instanceof Set)) {
    +209             c = new HashSet<Object>(c);
    +210         }
    +211         LinkedList<E> l = new LinkedList<E>();
    +212         for (E o : this) {
    +213             if (!c.contains(o)) {
    +214                 l.addLast(o);
    +215             }
    +216         }
    +217         if (!l.isEmpty()) {
    +218             removeAll(l);
    +219             return true;
    +220         }
    +221         return false;
    +222     }
    +223 
    +224     public synchronized E set(int index, E o) {
    +225         E orig = get(index);
    +226         if (set.add(o)) {
    +227             elementData[index] = o;
    +228             set.remove(orig);
    +229         } else {
    +230             int oldIndexOfO = indexOf(o);
    +231             remove(o);
    +232             remove(orig);
    +233             add(oldIndexOfO > index ? index : index - 1, o);
    +234         }
    +235         return orig;
    +236     }
    +237 
    +238     public void setElementAt(E o, int index) {
    +239         set(index, o);
    +240     }
    +241 
    +242 }
    +
    +
    + + + diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/package-frame.html new file mode 100644 index 000000000..ffbfa63f9 --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/package-frame.html @@ -0,0 +1,39 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.util + + + + +

    + org.owasp.dependencycheck.org.apache.tools.ant.util +

    + +

    Classes

    + + + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/package-summary.html new file mode 100644 index 000000000..3cc0f398c --- /dev/null +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/org/apache/tools/ant/util/package-summary.html @@ -0,0 +1,94 @@ + + + + + + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.org.apache.tools.ant.util + + + +
    + +
    +
    + +
    + +

    Package org.owasp.dependencycheck.org.apache.tools.ant.util

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary
    + CollectionUtils +
    + CompoundEnumeration +
    + EmptyEnumeration +
    + FileUtils +
    + SymbolicLinkUtils +
    + VectorSet +
    + +
    + +
    +
    + +
    +
    + + + \ No newline at end of file diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/FileUtils.html b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/FileUtils.html index 1b06f62aa..a6c491774 100644 --- a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/FileUtils.html +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/FileUtils.html @@ -86,7 +86,7 @@ 78 if (!org.apache.commons.io.FileUtils.deleteQuietly(file)) { 79 success = false; 80 final String msg = String.format("Failed to delete file: %s; attempting to delete on exit.", file.getPath()); -81 LOGGER.log(Level.FINE, msg); +81 LOGGER.log(Level.INFO, msg); 82 file.deleteOnExit(); 83 } 84 return success; diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/Settings.html b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/Settings.html index 598f7718c..45171a101 100644 --- a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/Settings.html +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/Settings.html @@ -197,581 +197,589 @@ 189 */ 190 public static final String ANALYZER_NEXUS_PROXY = "analyzer.nexus.proxy"; 191 /** -192 * The path to mono, if available. +192 * The properties key for whether the Central analyzer is enabled. 193 */ -194 public static final String ANALYZER_ASSEMBLY_MONO_PATH = "analyzer.assembly.mono.path"; +194 public static final String ANALYZER_CENTRAL_ENABLED = "analyzer.central.enabled"; 195 /** -196 * The additional configured zip file extensions, if available. +196 * The properties key for the Central search URL. 197 */ -198 public static final String ADDITIONAL_ZIP_EXTENSIONS = "extensions.zip"; +198 public static final String ANALYZER_CENTRAL_URL = "analyzer.central.url"; 199 /** -200 * The properties key for whether Test Scope dependencies should be skipped. +200 * The path to mono, if available. 201 */ -202 public static final String SKIP_TEST_SCOPE = "skip.test.scope"; +202 public static final String ANALYZER_ASSEMBLY_MONO_PATH = "analyzer.assembly.mono.path"; 203 /** -204 * The properties key for whether Runtime Scope dependencies should be skipped. +204 * The additional configured zip file extensions, if available. 205 */ -206 public static final String SKIP_RUNTIME_SCOPE = "skip.runtime.scope"; +206 public static final String ADDITIONAL_ZIP_EXTENSIONS = "extensions.zip"; 207 /** -208 * The properties key for whether Provided Scope dependencies should be skipped. +208 * The properties key for whether Test Scope dependencies should be skipped. 209 */ -210 public static final String SKIP_PROVIDED_SCOPE = "skip.provided.scope"; -211 -212 /** -213 * The key to obtain the path to the VFEED data file. -214 */ -215 public static final String VFEED_DATA_FILE = "vfeed.data_file"; -216 /** -217 * The key to obtain the VFEED connection string. -218 */ -219 public static final String VFEED_CONNECTION_STRING = "vfeed.connection_string"; -220 -221 /** -222 * The key to obtain the base download URL for the VFeed data file. -223 */ -224 public static final String VFEED_DOWNLOAD_URL = "vfeed.download_url"; -225 /** -226 * The key to obtain the download file name for the VFeed data. -227 */ -228 public static final String VFEED_DOWNLOAD_FILE = "vfeed.download_file"; +210 public static final String SKIP_TEST_SCOPE = "skip.test.scope"; +211 /** +212 * The properties key for whether Runtime Scope dependencies should be skipped. +213 */ +214 public static final String SKIP_RUNTIME_SCOPE = "skip.runtime.scope"; +215 /** +216 * The properties key for whether Provided Scope dependencies should be skipped. +217 */ +218 public static final String SKIP_PROVIDED_SCOPE = "skip.provided.scope"; +219 +220 /** +221 * The key to obtain the path to the VFEED data file. +222 */ +223 public static final String VFEED_DATA_FILE = "vfeed.data_file"; +224 /** +225 * The key to obtain the VFEED connection string. +226 */ +227 public static final String VFEED_CONNECTION_STRING = "vfeed.connection_string"; +228 229 /** -230 * The key to obtain the VFeed update status. +230 * The key to obtain the base download URL for the VFeed data file. 231 */ -232 public static final String VFEED_UPDATE_STATUS = "vfeed.update_status"; -233 } -234 //</editor-fold> -235 -236 /** -237 * The logger. -238 */ -239 private static final Logger LOGGER = Logger.getLogger(Settings.class.getName()); -240 /** -241 * The properties file location. -242 */ -243 private static final String PROPERTIES_FILE = "dependencycheck.properties"; +232 public static final String VFEED_DOWNLOAD_URL = "vfeed.download_url"; +233 /** +234 * The key to obtain the download file name for the VFeed data. +235 */ +236 public static final String VFEED_DOWNLOAD_FILE = "vfeed.download_file"; +237 /** +238 * The key to obtain the VFeed update status. +239 */ +240 public static final String VFEED_UPDATE_STATUS = "vfeed.update_status"; +241 } +242 //</editor-fold> +243 244 /** -245 * Thread local settings. +245 * The logger. 246 */ -247 private static ThreadLocal<Settings> localSettings = new ThreadLocal(); +247 private static final Logger LOGGER = Logger.getLogger(Settings.class.getName()); 248 /** -249 * The properties. +249 * The properties file location. 250 */ -251 private Properties props = null; -252 -253 /** -254 * Private constructor for the Settings class. This class loads the properties files. -255 * -256 * @param propertiesFilePath the path to the base properties file to load -257 */ -258 private Settings(String propertiesFilePath) { -259 InputStream in = null; -260 props = new Properties(); -261 try { -262 in = this.getClass().getClassLoader().getResourceAsStream(propertiesFilePath); -263 props.load(in); -264 } catch (IOException ex) { -265 LOGGER.log(Level.SEVERE, "Unable to load default settings."); -266 LOGGER.log(Level.FINE, null, ex); -267 } finally { -268 if (in != null) { -269 try { -270 in.close(); -271 } catch (IOException ex) { -272 LOGGER.log(Level.FINEST, null, ex); -273 } -274 } -275 } -276 logProperties("Properties loaded", props); -277 } -278 -279 /** -280 * Initializes the thread local settings object. Note, to use the settings object you must call this method. -281 * However, you must also call Settings.cleanup() to properly release resources. -282 */ -283 public static void initialize() { -284 localSettings.set(new Settings(PROPERTIES_FILE)); +251 private static final String PROPERTIES_FILE = "dependencycheck.properties"; +252 /** +253 * Thread local settings. +254 */ +255 private static ThreadLocal<Settings> localSettings = new ThreadLocal(); +256 /** +257 * The properties. +258 */ +259 private Properties props = null; +260 +261 /** +262 * Private constructor for the Settings class. This class loads the properties files. +263 * +264 * @param propertiesFilePath the path to the base properties file to load +265 */ +266 private Settings(String propertiesFilePath) { +267 InputStream in = null; +268 props = new Properties(); +269 try { +270 in = this.getClass().getClassLoader().getResourceAsStream(propertiesFilePath); +271 props.load(in); +272 } catch (IOException ex) { +273 LOGGER.log(Level.SEVERE, "Unable to load default settings."); +274 LOGGER.log(Level.FINE, null, ex); +275 } finally { +276 if (in != null) { +277 try { +278 in.close(); +279 } catch (IOException ex) { +280 LOGGER.log(Level.FINEST, null, ex); +281 } +282 } +283 } +284 logProperties("Properties loaded", props); 285 } 286 287 /** 288 * Initializes the thread local settings object. Note, to use the settings object you must call this method. 289 * However, you must also call Settings.cleanup() to properly release resources. -290 * -291 * @param propertiesFilePath the path to the base properties file to load -292 */ -293 public static void initialize(String propertiesFilePath) { -294 localSettings.set(new Settings(propertiesFilePath)); -295 } -296 -297 /** -298 * Cleans up resources to prevent memory leaks. -299 * +290 */ +291 public static void initialize() { +292 localSettings.set(new Settings(PROPERTIES_FILE)); +293 } +294 +295 /** +296 * Initializes the thread local settings object. Note, to use the settings object you must call this method. +297 * However, you must also call Settings.cleanup() to properly release resources. +298 * +299 * @param propertiesFilePath the path to the base properties file to load 300 */ -301 public static void cleanup() { -302 cleanup(true); +301 public static void initialize(String propertiesFilePath) { +302 localSettings.set(new Settings(propertiesFilePath)); 303 } 304 305 /** 306 * Cleans up resources to prevent memory leaks. 307 * -308 * @param deleteTemporary flag indicating whether any temporary directories generated should be removed -309 */ -310 public static void cleanup(boolean deleteTemporary) { -311 if (deleteTemporary && tempDirectory != null && tempDirectory.exists()) { -312 FileUtils.delete(tempDirectory); -313 } -314 try { -315 localSettings.remove(); -316 } catch (Throwable ex) { -317 LOGGER.log(Level.FINE, "Error cleaning up Settings", ex); -318 } -319 } -320 -321 /** -322 * Gets the underlying instance of the Settings object. -323 * -324 * @return the Settings object -325 */ -326 public static Settings getInstance() { -327 return localSettings.get(); -328 } -329 -330 /** -331 * Sets the instance of the Settings object to use in this thread. -332 * -333 * @param instance the instance of the settings object to use in this thread -334 */ -335 public static void setInstance(Settings instance) { -336 localSettings.set(instance); -337 } -338 -339 /** -340 * Logs the properties. This will not log any properties that contain 'password' in the key. -341 * -342 * @param header the header to print with the log message -343 * @param properties the properties to log -344 */ -345 private static void logProperties(String header, Properties properties) { -346 if (LOGGER.isLoggable(Level.FINE)) { -347 final StringWriter sw = new StringWriter(); -348 PrintWriter pw = null; -349 try { -350 pw = new PrintWriter(sw); -351 pw.format("%s:%n%n", header); -352 final Enumeration e = properties.propertyNames(); -353 while (e.hasMoreElements()) { -354 final String key = (String) e.nextElement(); -355 if (key.contains("password")) { -356 pw.format("%s='*****'%n", key); -357 } else { -358 final String value = properties.getProperty(key); -359 if (value != null) { -360 pw.format("%s='%s'%n", key, value); -361 } -362 } -363 } -364 pw.flush(); -365 LOGGER.fine(sw.toString()); -366 } finally { -367 if (pw != null) { -368 pw.close(); -369 } -370 } -371 -372 } -373 } -374 -375 /** -376 * Sets a property value. -377 * -378 * @param key the key for the property -379 * @param value the value for the property -380 */ -381 public static void setString(String key, String value) { -382 localSettings.get().props.setProperty(key, value); -383 if (LOGGER.isLoggable(Level.FINE)) { -384 LOGGER.fine(String.format("Setting: %s='%s'", key, value)); -385 } -386 } -387 -388 /** -389 * Sets a property value. -390 * -391 * @param key the key for the property -392 * @param value the value for the property -393 */ -394 public static void setBoolean(String key, boolean value) { -395 if (value) { -396 localSettings.get().props.setProperty(key, Boolean.TRUE.toString()); -397 } else { -398 localSettings.get().props.setProperty(key, Boolean.FALSE.toString()); -399 } -400 if (LOGGER.isLoggable(Level.FINE)) { -401 LOGGER.fine(String.format("Setting: %s='%b'", key, value)); -402 } -403 } -404 -405 /** -406 * Merges a new properties file into the current properties. This method allows for the loading of a user provided -407 * properties file.<br/><br/> -408 * Note: even if using this method - system properties will be loaded before properties loaded from files. -409 * -410 * @param filePath the path to the properties file to merge. -411 * @throws FileNotFoundException is thrown when the filePath points to a non-existent file -412 * @throws IOException is thrown when there is an exception loading/merging the properties -413 */ -414 public static void mergeProperties(File filePath) throws FileNotFoundException, IOException { -415 FileInputStream fis = null; -416 try { -417 fis = new FileInputStream(filePath); -418 mergeProperties(fis); -419 } finally { -420 if (fis != null) { -421 try { -422 fis.close(); -423 } catch (IOException ex) { -424 LOGGER.log(Level.FINEST, "close error", ex); -425 } -426 } -427 } -428 } -429 -430 /** -431 * Merges a new properties file into the current properties. This method allows for the loading of a user provided -432 * properties file.<br/><br/> -433 * Note: even if using this method - system properties will be loaded before properties loaded from files. -434 * -435 * @param filePath the path to the properties file to merge. -436 * @throws FileNotFoundException is thrown when the filePath points to a non-existent file -437 * @throws IOException is thrown when there is an exception loading/merging the properties -438 */ -439 public static void mergeProperties(String filePath) throws FileNotFoundException, IOException { -440 FileInputStream fis = null; -441 try { -442 fis = new FileInputStream(filePath); -443 mergeProperties(fis); -444 } finally { -445 if (fis != null) { -446 try { -447 fis.close(); -448 } catch (IOException ex) { -449 LOGGER.log(Level.FINEST, "close error", ex); -450 } -451 } -452 } -453 } -454 -455 /** -456 * Merges a new properties file into the current properties. This method allows for the loading of a user provided -457 * properties file.<br/><br/> -458 * Note: even if using this method - system properties will be loaded before properties loaded from files. -459 * -460 * @param stream an Input Stream pointing at a properties file to merge -461 * @throws IOException is thrown when there is an exception loading/merging the properties -462 */ -463 public static void mergeProperties(InputStream stream) throws IOException { -464 localSettings.get().props.load(stream); -465 logProperties("Properties updated via merge", localSettings.get().props); -466 } -467 -468 /** -469 * Returns a value from the properties file as a File object. If the value was specified as a system property or -470 * passed in via the -Dprop=value argument - this method will return the value from the system properties before the -471 * values in the contained configuration file. -472 * -473 * @param key the key to lookup within the properties file -474 * @return the property from the properties file converted to a File object -475 */ -476 public static File getFile(String key) { -477 final String file = getString(key); -478 if (file == null) { -479 return null; -480 } -481 return new File(file); -482 } -483 -484 /** -485 * Returns a value from the properties file as a File object. If the value was specified as a system property or -486 * passed in via the -Dprop=value argument - this method will return the value from the system properties before the -487 * values in the contained configuration file. -488 * -489 * This method will check the configured base directory and will use this as the base of the file path. -490 * Additionally, if the base directory begins with a leading "[JAR]\" sequence with the path to the folder -491 * containing the JAR file containing this class. -492 * -493 * @param key the key to lookup within the properties file -494 * @return the property from the properties file converted to a File object -495 */ -496 protected static File getDataFile(String key) { -497 final String file = getString(key); -498 LOGGER.log(Level.FINE, String.format("Settings.getDataFile() - file: '%s'", file)); -499 if (file == null) { -500 return null; -501 } -502 if (file.startsWith("[JAR]")) { -503 LOGGER.log(Level.FINE, "Settings.getDataFile() - transforming filename"); -504 final File jarPath = getJarPath(); -505 LOGGER.log(Level.FINE, String.format("Settings.getDataFile() - jar file: '%s'", jarPath.toString())); -506 final File retVal = new File(jarPath, file.substring(6)); -507 LOGGER.log(Level.FINE, String.format("Settings.getDataFile() - returning: '%s'", retVal.toString())); -508 return retVal; +308 */ +309 public static void cleanup() { +310 cleanup(true); +311 } +312 +313 /** +314 * Cleans up resources to prevent memory leaks. +315 * +316 * @param deleteTemporary flag indicating whether any temporary directories generated should be removed +317 */ +318 public static void cleanup(boolean deleteTemporary) { +319 if (deleteTemporary && tempDirectory != null && tempDirectory.exists()) { +320 FileUtils.delete(tempDirectory); +321 } +322 try { +323 localSettings.remove(); +324 } catch (Throwable ex) { +325 LOGGER.log(Level.FINE, "Error cleaning up Settings", ex); +326 } +327 } +328 +329 /** +330 * Gets the underlying instance of the Settings object. +331 * +332 * @return the Settings object +333 */ +334 public static Settings getInstance() { +335 return localSettings.get(); +336 } +337 +338 /** +339 * Sets the instance of the Settings object to use in this thread. +340 * +341 * @param instance the instance of the settings object to use in this thread +342 */ +343 public static void setInstance(Settings instance) { +344 localSettings.set(instance); +345 } +346 +347 /** +348 * Logs the properties. This will not log any properties that contain 'password' in the key. +349 * +350 * @param header the header to print with the log message +351 * @param properties the properties to log +352 */ +353 private static void logProperties(String header, Properties properties) { +354 if (LOGGER.isLoggable(Level.FINE)) { +355 final StringWriter sw = new StringWriter(); +356 PrintWriter pw = null; +357 try { +358 pw = new PrintWriter(sw); +359 pw.format("%s:%n%n", header); +360 final Enumeration e = properties.propertyNames(); +361 while (e.hasMoreElements()) { +362 final String key = (String) e.nextElement(); +363 if (key.contains("password")) { +364 pw.format("%s='*****'%n", key); +365 } else { +366 final String value = properties.getProperty(key); +367 if (value != null) { +368 pw.format("%s='%s'%n", key, value); +369 } +370 } +371 } +372 pw.flush(); +373 LOGGER.fine(sw.toString()); +374 } finally { +375 if (pw != null) { +376 pw.close(); +377 } +378 } +379 +380 } +381 } +382 +383 /** +384 * Sets a property value. +385 * +386 * @param key the key for the property +387 * @param value the value for the property +388 */ +389 public static void setString(String key, String value) { +390 localSettings.get().props.setProperty(key, value); +391 if (LOGGER.isLoggable(Level.FINE)) { +392 LOGGER.fine(String.format("Setting: %s='%s'", key, value)); +393 } +394 } +395 +396 /** +397 * Sets a property value. +398 * +399 * @param key the key for the property +400 * @param value the value for the property +401 */ +402 public static void setBoolean(String key, boolean value) { +403 if (value) { +404 localSettings.get().props.setProperty(key, Boolean.TRUE.toString()); +405 } else { +406 localSettings.get().props.setProperty(key, Boolean.FALSE.toString()); +407 } +408 if (LOGGER.isLoggable(Level.FINE)) { +409 LOGGER.fine(String.format("Setting: %s='%b'", key, value)); +410 } +411 } +412 +413 /** +414 * Merges a new properties file into the current properties. This method allows for the loading of a user provided +415 * properties file.<br/><br/> +416 * Note: even if using this method - system properties will be loaded before properties loaded from files. +417 * +418 * @param filePath the path to the properties file to merge. +419 * @throws FileNotFoundException is thrown when the filePath points to a non-existent file +420 * @throws IOException is thrown when there is an exception loading/merging the properties +421 */ +422 public static void mergeProperties(File filePath) throws FileNotFoundException, IOException { +423 FileInputStream fis = null; +424 try { +425 fis = new FileInputStream(filePath); +426 mergeProperties(fis); +427 } finally { +428 if (fis != null) { +429 try { +430 fis.close(); +431 } catch (IOException ex) { +432 LOGGER.log(Level.FINEST, "close error", ex); +433 } +434 } +435 } +436 } +437 +438 /** +439 * Merges a new properties file into the current properties. This method allows for the loading of a user provided +440 * properties file.<br/><br/> +441 * Note: even if using this method - system properties will be loaded before properties loaded from files. +442 * +443 * @param filePath the path to the properties file to merge. +444 * @throws FileNotFoundException is thrown when the filePath points to a non-existent file +445 * @throws IOException is thrown when there is an exception loading/merging the properties +446 */ +447 public static void mergeProperties(String filePath) throws FileNotFoundException, IOException { +448 FileInputStream fis = null; +449 try { +450 fis = new FileInputStream(filePath); +451 mergeProperties(fis); +452 } finally { +453 if (fis != null) { +454 try { +455 fis.close(); +456 } catch (IOException ex) { +457 LOGGER.log(Level.FINEST, "close error", ex); +458 } +459 } +460 } +461 } +462 +463 /** +464 * Merges a new properties file into the current properties. This method allows for the loading of a user provided +465 * properties file.<br/><br/> +466 * Note: even if using this method - system properties will be loaded before properties loaded from files. +467 * +468 * @param stream an Input Stream pointing at a properties file to merge +469 * @throws IOException is thrown when there is an exception loading/merging the properties +470 */ +471 public static void mergeProperties(InputStream stream) throws IOException { +472 localSettings.get().props.load(stream); +473 logProperties("Properties updated via merge", localSettings.get().props); +474 } +475 +476 /** +477 * Returns a value from the properties file as a File object. If the value was specified as a system property or +478 * passed in via the -Dprop=value argument - this method will return the value from the system properties before the +479 * values in the contained configuration file. +480 * +481 * @param key the key to lookup within the properties file +482 * @return the property from the properties file converted to a File object +483 */ +484 public static File getFile(String key) { +485 final String file = getString(key); +486 if (file == null) { +487 return null; +488 } +489 return new File(file); +490 } +491 +492 /** +493 * Returns a value from the properties file as a File object. If the value was specified as a system property or +494 * passed in via the -Dprop=value argument - this method will return the value from the system properties before the +495 * values in the contained configuration file. +496 * +497 * This method will check the configured base directory and will use this as the base of the file path. +498 * Additionally, if the base directory begins with a leading "[JAR]\" sequence with the path to the folder +499 * containing the JAR file containing this class. +500 * +501 * @param key the key to lookup within the properties file +502 * @return the property from the properties file converted to a File object +503 */ +504 protected static File getDataFile(String key) { +505 final String file = getString(key); +506 LOGGER.log(Level.FINE, String.format("Settings.getDataFile() - file: '%s'", file)); +507 if (file == null) { +508 return null; 509 } -510 return new File(file); -511 } -512 -513 /** -514 * Attempts to retrieve the folder containing the Jar file containing the Settings class. -515 * -516 * @return a File object -517 */ -518 private static File getJarPath() { -519 final String jarPath = Settings.class.getProtectionDomain().getCodeSource().getLocation().getPath(); -520 String decodedPath = "."; -521 try { -522 decodedPath = URLDecoder.decode(jarPath, "UTF-8"); -523 } catch (UnsupportedEncodingException ex) { -524 LOGGER.log(Level.FINEST, null, ex); -525 } -526 -527 final File path = new File(decodedPath); -528 if (path.getName().toLowerCase().endsWith(".jar")) { -529 return path.getParentFile(); -530 } else { -531 return new File("."); -532 } -533 } +510 if (file.startsWith("[JAR]")) { +511 LOGGER.log(Level.FINE, "Settings.getDataFile() - transforming filename"); +512 final File jarPath = getJarPath(); +513 LOGGER.log(Level.FINE, String.format("Settings.getDataFile() - jar file: '%s'", jarPath.toString())); +514 final File retVal = new File(jarPath, file.substring(6)); +515 LOGGER.log(Level.FINE, String.format("Settings.getDataFile() - returning: '%s'", retVal.toString())); +516 return retVal; +517 } +518 return new File(file); +519 } +520 +521 /** +522 * Attempts to retrieve the folder containing the Jar file containing the Settings class. +523 * +524 * @return a File object +525 */ +526 private static File getJarPath() { +527 final String jarPath = Settings.class.getProtectionDomain().getCodeSource().getLocation().getPath(); +528 String decodedPath = "."; +529 try { +530 decodedPath = URLDecoder.decode(jarPath, "UTF-8"); +531 } catch (UnsupportedEncodingException ex) { +532 LOGGER.log(Level.FINEST, null, ex); +533 } 534 -535 /** -536 * Returns a value from the properties file. If the value was specified as a system property or passed in via the -537 * -Dprop=value argument - this method will return the value from the system properties before the values in the -538 * contained configuration file. -539 * -540 * @param key the key to lookup within the properties file -541 * @param defaultValue the default value for the requested property -542 * @return the property from the properties file -543 */ -544 public static String getString(String key, String defaultValue) { -545 final String str = System.getProperty(key, localSettings.get().props.getProperty(key, defaultValue)); -546 return str; -547 } -548 -549 /** -550 * A reference to the temporary directory; used incase it needs to be deleted during cleanup. +535 final File path = new File(decodedPath); +536 if (path.getName().toLowerCase().endsWith(".jar")) { +537 return path.getParentFile(); +538 } else { +539 return new File("."); +540 } +541 } +542 +543 /** +544 * Returns a value from the properties file. If the value was specified as a system property or passed in via the +545 * -Dprop=value argument - this method will return the value from the system properties before the values in the +546 * contained configuration file. +547 * +548 * @param key the key to lookup within the properties file +549 * @param defaultValue the default value for the requested property +550 * @return the property from the properties file 551 */ -552 private static File tempDirectory = null; -553 -554 /** -555 * Returns the temporary directory. -556 * -557 * @return the temporary directory -558 * @throws java.io.IOException thrown if the temporary directory does not exist and cannot be created +552 public static String getString(String key, String defaultValue) { +553 final String str = System.getProperty(key, localSettings.get().props.getProperty(key, defaultValue)); +554 return str; +555 } +556 +557 /** +558 * A reference to the temporary directory; used incase it needs to be deleted during cleanup. 559 */ -560 public static File getTempDirectory() throws IOException { -561 final File tmpDir = new File(Settings.getString(Settings.KEYS.TEMP_DIRECTORY, System.getProperty("java.io.tmpdir"))); -562 if (!tmpDir.exists()) { -563 if (!tmpDir.mkdirs()) { -564 final String msg = String.format("Unable to make a temporary folder '%s'", tmpDir.getPath()); -565 throw new IOException(msg); -566 } else { -567 tempDirectory = tmpDir; -568 } -569 } -570 return tmpDir; -571 } -572 -573 /** -574 * Returns a value from the properties file. If the value was specified as a system property or passed in via the -575 * -Dprop=value argument - this method will return the value from the system properties before the values in the -576 * contained configuration file. -577 * -578 * @param key the key to lookup within the properties file -579 * @return the property from the properties file -580 */ -581 public static String getString(String key) { -582 return System.getProperty(key, localSettings.get().props.getProperty(key)); -583 } -584 -585 /** -586 * Removes a property from the local properties collection. This is mainly used in test cases. -587 * -588 * @param key the property key to remove -589 */ -590 public static void removeProperty(String key) { -591 localSettings.get().props.remove(key); -592 } -593 -594 /** -595 * Returns an int value from the properties file. If the value was specified as a system property or passed in via -596 * the -Dprop=value argument - this method will return the value from the system properties before the values in the -597 * contained configuration file. -598 * -599 * @param key the key to lookup within the properties file -600 * @return the property from the properties file -601 * @throws InvalidSettingException is thrown if there is an error retrieving the setting -602 */ -603 public static int getInt(String key) throws InvalidSettingException { -604 int value; -605 try { -606 value = Integer.parseInt(Settings.getString(key)); -607 } catch (NumberFormatException ex) { -608 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); -609 } -610 return value; -611 } -612 -613 /** -614 * Returns an int value from the properties file. If the value was specified as a system property or passed in via -615 * the -Dprop=value argument - this method will return the value from the system properties before the values in the -616 * contained configuration file. -617 * -618 * @param key the key to lookup within the properties file -619 * @param defaultValue the default value to return -620 * @return the property from the properties file or the defaultValue if the property does not exist or cannot be -621 * converted to an integer -622 */ -623 public static int getInt(String key, int defaultValue) { -624 int value; -625 try { -626 value = Integer.parseInt(Settings.getString(key)); -627 } catch (NumberFormatException ex) { -628 final String msg = String.format("Could not convert property '%s' to an int.", key); -629 LOGGER.log(Level.FINEST, msg, ex); -630 value = defaultValue; -631 } -632 return value; -633 } -634 -635 /** -636 * Returns a long value from the properties file. If the value was specified as a system property or passed in via -637 * the -Dprop=value argument - this method will return the value from the system properties before the values in the -638 * contained configuration file. -639 * -640 * @param key the key to lookup within the properties file -641 * @return the property from the properties file -642 * @throws InvalidSettingException is thrown if there is an error retrieving the setting -643 */ -644 public static long getLong(String key) throws InvalidSettingException { -645 long value; -646 try { -647 value = Long.parseLong(Settings.getString(key)); -648 } catch (NumberFormatException ex) { -649 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); -650 } -651 return value; -652 } -653 -654 /** -655 * Returns a boolean value from the properties file. If the value was specified as a system property or passed in -656 * via the <code>-Dprop=value</code> argument this method will return the value from the system properties before -657 * the values in the contained configuration file. -658 * -659 * @param key the key to lookup within the properties file -660 * @return the property from the properties file -661 * @throws InvalidSettingException is thrown if there is an error retrieving the setting -662 */ -663 public static boolean getBoolean(String key) throws InvalidSettingException { -664 boolean value; -665 try { -666 value = Boolean.parseBoolean(Settings.getString(key)); -667 } catch (NumberFormatException ex) { -668 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); -669 } -670 return value; -671 } -672 -673 /** -674 * Returns a boolean value from the properties file. If the value was specified as a system property or passed in -675 * via the <code>-Dprop=value</code> argument this method will return the value from the system properties before -676 * the values in the contained configuration file. -677 * -678 * @param key the key to lookup within the properties file -679 * @param defaultValue the default value to return if the setting does not exist -680 * @return the property from the properties file -681 * @throws InvalidSettingException is thrown if there is an error retrieving the setting -682 */ -683 public static boolean getBoolean(String key, boolean defaultValue) throws InvalidSettingException { -684 boolean value; -685 try { -686 final String strValue = Settings.getString(key); -687 if (strValue == null) { -688 return defaultValue; -689 } -690 value = Boolean.parseBoolean(strValue); -691 } catch (NumberFormatException ex) { -692 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); -693 } -694 return value; -695 } -696 -697 /** -698 * Returns a connection string from the configured properties. If the connection string contains a %s, this method -699 * will determine the 'data' directory and replace the %s with the path to the data directory. If the data directory -700 * does not exists it will be created. -701 * -702 * @param connectionStringKey the property file key for the connection string -703 * @param dbFileNameKey the settings key for the db filename -704 * @param dbVersionKey the settings key for the dbVersion -705 * @return the connection string -706 * @throws IOException thrown the data directory cannot be created -707 * @throws InvalidSettingException thrown if there is an invalid setting -708 */ -709 public static String getConnectionString(String connectionStringKey, String dbFileNameKey, String dbVersionKey) -710 throws IOException, InvalidSettingException { -711 final String connStr = Settings.getString(connectionStringKey); -712 if (connStr == null) { -713 final String msg = String.format("Invalid properties file to get the connection string; '%s' must be defined.", -714 connectionStringKey); -715 throw new InvalidSettingException(msg); -716 } -717 if (connStr.contains("%s")) { -718 final File directory = getDataDirectory(); -719 String fileName = null; -720 if (dbFileNameKey != null) { -721 fileName = Settings.getString(dbFileNameKey); -722 } -723 if (fileName == null) { -724 final String msg = String.format("Invalid properties file to get a file based connection string; '%s' must be defined.", -725 dbFileNameKey); -726 throw new InvalidSettingException(msg); -727 } -728 if (fileName.contains("%s")) { -729 String version = null; -730 if (dbVersionKey != null) { -731 version = Settings.getString(dbVersionKey); -732 } -733 if (version == null) { -734 final String msg = String.format("Invalid properties file to get a file based connection string; '%s' must be defined.", -735 dbFileNameKey); -736 throw new InvalidSettingException(msg); -737 } -738 fileName = String.format(fileName, version); -739 } -740 if (connStr.startsWith("jdbc:h2:file:") && fileName.endsWith(".h2.db")) { -741 fileName = fileName.substring(0, fileName.length() - 6); -742 } -743 // yes, for H2 this path won't actually exists - but this is sufficient to get the value needed -744 final File dbFile = new File(directory, fileName); -745 final String cString = String.format(connStr, dbFile.getCanonicalPath()); -746 LOGGER.log(Level.FINE, String.format("Connection String: '%s'", cString)); -747 return cString; -748 } -749 return connStr; -750 } -751 -752 /** -753 * Retrieves the directory that the JAR file exists in so that we can ensure we always use a common data directory -754 * for the embedded H2 database. This is public solely for some unit tests; otherwise this should be private. -755 * -756 * @return the data directory to store data files -757 * @throws IOException is thrown if an IOException occurs of course... -758 */ -759 public static File getDataDirectory() throws IOException { -760 final File path = Settings.getDataFile(Settings.KEYS.DATA_DIRECTORY); -761 if (path.exists() || path.mkdirs()) { -762 return path; -763 } -764 throw new IOException(String.format("Unable to create the data directory '%s'", path.getAbsolutePath())); -765 } -766 } +560 private static File tempDirectory = null; +561 +562 /** +563 * Returns the temporary directory. +564 * +565 * @return the temporary directory +566 * @throws java.io.IOException thrown if the temporary directory does not exist and cannot be created +567 */ +568 public static File getTempDirectory() throws IOException { +569 final File tmpDir = new File(Settings.getString(Settings.KEYS.TEMP_DIRECTORY, System.getProperty("java.io.tmpdir"))); +570 if (!tmpDir.exists()) { +571 if (!tmpDir.mkdirs()) { +572 final String msg = String.format("Unable to make a temporary folder '%s'", tmpDir.getPath()); +573 throw new IOException(msg); +574 } else { +575 tempDirectory = tmpDir; +576 } +577 } +578 return tmpDir; +579 } +580 +581 /** +582 * Returns a value from the properties file. If the value was specified as a system property or passed in via the +583 * -Dprop=value argument - this method will return the value from the system properties before the values in the +584 * contained configuration file. +585 * +586 * @param key the key to lookup within the properties file +587 * @return the property from the properties file +588 */ +589 public static String getString(String key) { +590 return System.getProperty(key, localSettings.get().props.getProperty(key)); +591 } +592 +593 /** +594 * Removes a property from the local properties collection. This is mainly used in test cases. +595 * +596 * @param key the property key to remove +597 */ +598 public static void removeProperty(String key) { +599 localSettings.get().props.remove(key); +600 } +601 +602 /** +603 * Returns an int value from the properties file. If the value was specified as a system property or passed in via +604 * the -Dprop=value argument - this method will return the value from the system properties before the values in the +605 * contained configuration file. +606 * +607 * @param key the key to lookup within the properties file +608 * @return the property from the properties file +609 * @throws InvalidSettingException is thrown if there is an error retrieving the setting +610 */ +611 public static int getInt(String key) throws InvalidSettingException { +612 int value; +613 try { +614 value = Integer.parseInt(Settings.getString(key)); +615 } catch (NumberFormatException ex) { +616 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); +617 } +618 return value; +619 } +620 +621 /** +622 * Returns an int value from the properties file. If the value was specified as a system property or passed in via +623 * the -Dprop=value argument - this method will return the value from the system properties before the values in the +624 * contained configuration file. +625 * +626 * @param key the key to lookup within the properties file +627 * @param defaultValue the default value to return +628 * @return the property from the properties file or the defaultValue if the property does not exist or cannot be +629 * converted to an integer +630 */ +631 public static int getInt(String key, int defaultValue) { +632 int value; +633 try { +634 value = Integer.parseInt(Settings.getString(key)); +635 } catch (NumberFormatException ex) { +636 final String msg = String.format("Could not convert property '%s' to an int.", key); +637 LOGGER.log(Level.FINEST, msg, ex); +638 value = defaultValue; +639 } +640 return value; +641 } +642 +643 /** +644 * Returns a long value from the properties file. If the value was specified as a system property or passed in via +645 * the -Dprop=value argument - this method will return the value from the system properties before the values in the +646 * contained configuration file. +647 * +648 * @param key the key to lookup within the properties file +649 * @return the property from the properties file +650 * @throws InvalidSettingException is thrown if there is an error retrieving the setting +651 */ +652 public static long getLong(String key) throws InvalidSettingException { +653 long value; +654 try { +655 value = Long.parseLong(Settings.getString(key)); +656 } catch (NumberFormatException ex) { +657 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); +658 } +659 return value; +660 } +661 +662 /** +663 * Returns a boolean value from the properties file. If the value was specified as a system property or passed in +664 * via the <code>-Dprop=value</code> argument this method will return the value from the system properties before +665 * the values in the contained configuration file. +666 * +667 * @param key the key to lookup within the properties file +668 * @return the property from the properties file +669 * @throws InvalidSettingException is thrown if there is an error retrieving the setting +670 */ +671 public static boolean getBoolean(String key) throws InvalidSettingException { +672 boolean value; +673 try { +674 value = Boolean.parseBoolean(Settings.getString(key)); +675 } catch (NumberFormatException ex) { +676 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); +677 } +678 return value; +679 } +680 +681 /** +682 * Returns a boolean value from the properties file. If the value was specified as a system property or passed in +683 * via the <code>-Dprop=value</code> argument this method will return the value from the system properties before +684 * the values in the contained configuration file. +685 * +686 * @param key the key to lookup within the properties file +687 * @param defaultValue the default value to return if the setting does not exist +688 * @return the property from the properties file +689 * @throws InvalidSettingException is thrown if there is an error retrieving the setting +690 */ +691 public static boolean getBoolean(String key, boolean defaultValue) throws InvalidSettingException { +692 boolean value; +693 try { +694 final String strValue = Settings.getString(key); +695 if (strValue == null) { +696 return defaultValue; +697 } +698 value = Boolean.parseBoolean(strValue); +699 } catch (NumberFormatException ex) { +700 throw new InvalidSettingException("Could not convert property '" + key + "' to an int.", ex); +701 } +702 return value; +703 } +704 +705 /** +706 * Returns a connection string from the configured properties. If the connection string contains a %s, this method +707 * will determine the 'data' directory and replace the %s with the path to the data directory. If the data directory +708 * does not exists it will be created. +709 * +710 * @param connectionStringKey the property file key for the connection string +711 * @param dbFileNameKey the settings key for the db filename +712 * @param dbVersionKey the settings key for the dbVersion +713 * @return the connection string +714 * @throws IOException thrown the data directory cannot be created +715 * @throws InvalidSettingException thrown if there is an invalid setting +716 */ +717 public static String getConnectionString(String connectionStringKey, String dbFileNameKey, String dbVersionKey) +718 throws IOException, InvalidSettingException { +719 final String connStr = Settings.getString(connectionStringKey); +720 if (connStr == null) { +721 final String msg = String.format("Invalid properties file to get the connection string; '%s' must be defined.", +722 connectionStringKey); +723 throw new InvalidSettingException(msg); +724 } +725 if (connStr.contains("%s")) { +726 final File directory = getDataDirectory(); +727 String fileName = null; +728 if (dbFileNameKey != null) { +729 fileName = Settings.getString(dbFileNameKey); +730 } +731 if (fileName == null) { +732 final String msg = String.format("Invalid properties file to get a file based connection string; '%s' must be defined.", +733 dbFileNameKey); +734 throw new InvalidSettingException(msg); +735 } +736 if (fileName.contains("%s")) { +737 String version = null; +738 if (dbVersionKey != null) { +739 version = Settings.getString(dbVersionKey); +740 } +741 if (version == null) { +742 final String msg = String.format("Invalid properties file to get a file based connection string; '%s' must be defined.", +743 dbFileNameKey); +744 throw new InvalidSettingException(msg); +745 } +746 fileName = String.format(fileName, version); +747 } +748 if (connStr.startsWith("jdbc:h2:file:") && fileName.endsWith(".h2.db")) { +749 fileName = fileName.substring(0, fileName.length() - 6); +750 } +751 // yes, for H2 this path won't actually exists - but this is sufficient to get the value needed +752 final File dbFile = new File(directory, fileName); +753 final String cString = String.format(connStr, dbFile.getCanonicalPath()); +754 LOGGER.log(Level.FINE, String.format("Connection String: '%s'", cString)); +755 return cString; +756 } +757 return connStr; +758 } +759 +760 /** +761 * Retrieves the directory that the JAR file exists in so that we can ensure we always use a common data directory +762 * for the embedded H2 database. This is public solely for some unit tests; otherwise this should be private. +763 * +764 * @return the data directory to store data files +765 * @throws IOException is thrown if an IOException occurs of course... +766 */ +767 public static File getDataDirectory() throws IOException { +768 final File path = Settings.getDataFile(Settings.KEYS.DATA_DIRECTORY); +769 if (path.exists() || path.mkdirs()) { +770 return path; +771 } +772 throw new IOException(String.format("Unable to create the data directory '%s'", path.getAbsolutePath())); +773 } +774 }
    diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-frame.html b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-frame.html index 5add21560..2132bf6d6 100644 --- a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-frame.html +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-summary.html b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-summary.html index 35d5dd1b0..5ffd2cdf6 100644 --- a/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-summary.html +++ b/dependency-check-utils/xref/org/owasp/dependencycheck/utils/package-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference Package org.owasp.dependencycheck.utils + Dependency-Check Utils 1.2.6 Reference Package org.owasp.dependencycheck.utils diff --git a/dependency-check-utils/xref/overview-frame.html b/dependency-check-utils/xref/overview-frame.html index 879cf6ab8..18e83d47d 100644 --- a/dependency-check-utils/xref/overview-frame.html +++ b/dependency-check-utils/xref/overview-frame.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference + Dependency-Check Utils 1.2.6 Reference @@ -16,6 +16,27 @@ diff --git a/dependency-check-utils/xref/overview-summary.html b/dependency-check-utils/xref/overview-summary.html index 2cb4f6f35..8728b53ef 100644 --- a/dependency-check-utils/xref/overview-summary.html +++ b/dependency-check-utils/xref/overview-summary.html @@ -3,7 +3,7 @@ - Dependency-Check Utils 1.2.5 Reference + Dependency-Check Utils 1.2.6 Reference @@ -24,7 +24,7 @@
    -

    Dependency-Check Utils 1.2.5 Reference

    +

    Dependency-Check Utils 1.2.6 Reference

    @@ -34,6 +34,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/index.html b/index.html index 3c84fbdd6..4541583c5 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,13 @@ - + dependency-check - About @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -307,7 +307,7 @@

    About

    Dependency-check is an open source solution the OWASP Top 10 2013 entry: A9 - Using Components with Known Vulnerabilities. Dependency-check can currently be used to scan Java applications (and their dependent libraries) to identify known vulnerable components.

    -

    The problem with using known vulnerable components was covered in a paper by Jeff Williams and Arshan Dabirsiaghi titled, "The Unfortunate Reality of Insecure Libraries" (registration required). The gist of the paper is that we as a development community include third party libraries in our applications that contain well known published vulnerabilities (such as those at the National Vulnerability Database).

    +

    The problem with using known vulnerable components was covered in a paper by Jeff Williams and Arshan Dabirsiaghi titled, “The Unfortunate Reality of Insecure Libraries” (registration required). The gist of the paper is that we as a development community include third party libraries in our applications that contain well known published vulnerabilities (such as those at the National Vulnerability Database).

    More information about dependency-check can be found here:

      diff --git a/internals.html b/internals.html index 2cda21663..a80938ded 100644 --- a/internals.html +++ b/internals.html @@ -1,13 +1,13 @@ - + dependency-check - How does dependency-check work? @@ -62,9 +62,9 @@ -
    • | Last Published: 2014-09-16
    • +
    • | Last Published: 2014-11-16
    • - Version: 1.2.5 + Version: 1.2.6
    diff --git a/issue-tracking.html b/issue-tracking.html index 805977357..98c4f9ab8 100644 --- a/issue-tracking.html +++ b/issue-tracking.html @@ -1,13 +1,13 @@ - + dependency-check - Issue Tracking @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/jar-analyzer.html b/jar-analyzer.html index e83d2ed33..542527344 100644 --- a/jar-analyzer.html +++ b/jar-analyzer.html @@ -1,13 +1,13 @@ - + dependency-check - Jar Analyzer @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/license.html b/license.html index 028760503..8c75ced36 100644 --- a/license.html +++ b/license.html @@ -1,13 +1,13 @@ - + dependency-check - Project License @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/mail-lists.html b/mail-lists.html index d2084aa5d..9eaa27f87 100644 --- a/mail-lists.html +++ b/mail-lists.html @@ -1,13 +1,13 @@ - + dependency-check - Project Mailing Lists @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/modules.html b/modules.html index 7ecc2e4be..d7388dbd5 100644 --- a/modules.html +++ b/modules.html @@ -1,13 +1,13 @@ - + dependency-check - Project Modules @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/nexus-analyzer.html b/nexus-analyzer.html index e250d5d48..4a9649330 100644 --- a/nexus-analyzer.html +++ b/nexus-analyzer.html @@ -1,13 +1,13 @@ - + dependency-check - Nexus Analyzer @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/nuspec-analyzer.html b/nuspec-analyzer.html index 40138b4d3..4e3817cb2 100644 --- a/nuspec-analyzer.html +++ b/nuspec-analyzer.html @@ -1,13 +1,13 @@ - + dependency-check - Nuspec Analyzer @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/project-info.html b/project-info.html index 1e2276eb0..bf1086bf4 100644 --- a/project-info.html +++ b/project-info.html @@ -1,13 +1,13 @@ - + dependency-check - Project Information @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/project-summary.html b/project-summary.html index 7e69eb3a9..c68b73623 100644 --- a/project-summary.html +++ b/project-summary.html @@ -1,13 +1,13 @@ - + dependency-check - Project Summary @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • @@ -348,7 +348,7 @@ - +
    + org.owasp.dependencycheck.org.apache.tools.ant +
    + org.owasp.dependencycheck.org.apache.tools.ant.launch +
    + org.owasp.dependencycheck.org.apache.tools.ant.taskdefs.condition +
    + org.owasp.dependencycheck.org.apache.tools.ant.types +
    + org.owasp.dependencycheck.org.apache.tools.ant.types.resources +
    + org.owasp.dependencycheck.org.apache.tools.ant.types.selectors +
    + org.owasp.dependencycheck.org.apache.tools.ant.util +
    org.owasp.dependencycheck.utils dependency-check-parent
    Version1.2.5
    1.2.6
    Type pom
    diff --git a/source-repository.html b/source-repository.html index 51f7ffb7e..82f9b5168 100644 --- a/source-repository.html +++ b/source-repository.html @@ -1,13 +1,13 @@ - + dependency-check - Source Repository @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/suppression.html b/suppression.html index ed4f60074..d509299d6 100644 --- a/suppression.html +++ b/suppression.html @@ -1,13 +1,13 @@ - + dependency-check - Suppressing False Positives @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/team-list.html b/team-list.html index 2c23758b5..bd3fe5a6c 100644 --- a/team-list.html +++ b/team-list.html @@ -1,13 +1,13 @@ - + dependency-check - Team list @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6
  • diff --git a/thereport.html b/thereport.html index b010c1723..987b3857f 100644 --- a/thereport.html +++ b/thereport.html @@ -1,13 +1,13 @@ - + dependency-check - How To Read The Report @@ -62,9 +62,9 @@ -
  • | Last Published: 2014-09-16
  • +
  • | Last Published: 2014-11-16
  • - Version: 1.2.5 + Version: 1.2.6