##### Coverage Report - org.owasp.dependencycheck.analyzer.JavaScriptAnalyzer

Classes in this File | Line Coverage | Branch Coverage | Complexity
JavaScriptAnalyzer |
0% | 0/11
N/A | N/A
| 1.0;1

1 |  |
     /*
2 |  |
      * This file is part of dependency-check-core.
3 |  |
      *
4 |  |
      * Dependency-check-core is free software: you can redistribute it and/or modify it
5 |  |
      * under the terms of the GNU General Public License as published by the Free
6 |  |
      * Software Foundation, either version 3 of the License, or (at your option) any
7 |  |
      * later version.
8 |  |
      *
9 |  |
      * Dependency-check-core is distributed in the hope that it will be useful, but
10 |  |
      * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 |  |
      * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 |  |
      * details.
13 |  |
      *
14 |  |
      * You should have received a copy of the GNU General Public License along with
15 |  |
      * dependency-check-core. If not, see http://www.gnu.org/licenses/.
16 |  |
      *
17 |  |
      * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
18 |  |
      */
19 |  |
     package org.owasp.dependencycheck.analyzer;
20 |  |
21 |  |
     import org.owasp.dependencycheck.Engine;
22 |  |
     import org.owasp.dependencycheck.dependency.Dependency;
23 |  |
     import java.util.Set;
24 |  |
     import java.util.regex.Pattern;
25 |  |
26 |  |
     /**
27 |  |
      *
28 |  |
      * Used to load a JAR file and collect information that can be used to determine
29 |  |
      * the associated CPE.
30 |  |
      *
31 |  |
      * @author Jeremy Long (jeremy.long@owasp.org)
32 |  |
      */
33 | 0 |
     public class JavaScriptAnalyzer extends AbstractAnalyzer implements Analyzer {
34 |  |
35 |  |
         //<editor-fold defaultstate="collapsed" desc="All standard implmentation details of Analyzer">
36 |  |
         /**
37 |  |
          * The name of the analyzer.
38 |  |
          */
39 |  |
         private static final String ANALYZER_NAME = "JavaScript Analyzer";
40 |  |
         /**
41 |  |
          * The phase that this analyzer is intended to run in.
42 |  |
          */
43 | 0 |
         private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.INFORMATION_COLLECTION;
44 |  |
         /**
45 |  |
          * The set of file extensions supported by this analyzer.
46 |  |
          */
47 | 0 |
         private static final Set<String> EXTENSIONS = newHashSet("js");
48 |  |
49 |  |
         /**
50 |  |
          * Returns a list of file EXTENSIONS supported by this analyzer.
51 |  |
          *
52 |  |
          * @return a list of file EXTENSIONS supported by this analyzer.
53 |  |
          */
54 |  |
         public Set<String> getSupportedExtensions() {
55 | 0 |
             return EXTENSIONS;
56 |  |
         }
57 |  |
58 |  |
         /**
59 |  |
          * Returns the name of the analyzer.
60 |  |
          *
61 |  |
          * @return the name of the analyzer.
62 |  |
          */
63 |  |
         public String getName() {
64 | 0 |
             return ANALYZER_NAME;
65 |  |
         }
66 |  |
67 |  |
         /**
68 |  |
          * Returns whether or not this analyzer can process the given extension.
69 |  |
          *
70 |  |
          * @param extension the file extension to test for support.
71 |  |
          * @return whether or not the specified file extension is supported by this
72 |  |
          * analyzer.
73 |  |
          */
74 |  |
         public boolean supportsExtension(String extension) {
75 | 0 |
             return EXTENSIONS.contains(extension);
76 |  |
         }
77 |  |
78 |  |
         /**
79 |  |
          * Returns the phase that the analyzer is intended to run in.
80 |  |
          *
81 |  |
          * @return the phase that the analyzer is intended to run in.
82 |  |
          */
83 |  |
         public AnalysisPhase getAnalysisPhase() {
84 | 0 |
             return ANALYSIS_PHASE;
85 |  |
         }
86 |  |
         //</editor-fold>
87 |  |
88 |  |
         /**
89 |  |
          * Loads a specified JAR file and collects information from the manifest and
90 |  |
          * checksums to identify the correct CPE information.
91 |  |
          *
92 |  |
          * @param dependency the dependency to analyze.
93 |  |
          * @param engine the engine that is scanning the dependencies
94 |  |
          * @throws AnalysisException is thrown if there is an error reading the JAR
95 |  |
          * file.
96 |  |
          */
97 |  |
         @Override
98 |  |
         public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
99 | 0 |
             final Pattern extractComments = Pattern.compile("(/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|(//.*)");
100 |  |
101 | 0 |
         }
102 |  |
103 |  |
         /**
104 |  |
          * The initialize method does nothing for this Analyzer.
105 |  |
          *
106 |  |
          * @throws Exception thrown if there is an exception
107 |  |
          */
108 |  |
         @Override
109 |  |
         public void initialize() throws Exception {
110 |  |
             //do nothing
111 | 0 |
         }
112 |  |
113 |  |
         /**
114 |  |
          * The close method does nothing for this Analyzer.
115 |  |
          *
116 |  |
          * @throws Exception thrown if there is an exception
117 |  |
          */
118 |  |
         @Override
119 |  |
         public void close() throws Exception {
120 |  |
             //do nothing
121 | 0 |
         }
122 |  |
     }