Coverage Report - org.owasp.dependencycheck.analyzer.JavaScriptAnalyzer
 
Classes in this File Line Coverage Branch Coverage Complexity
JavaScriptAnalyzer
0%
0/11
N/A
1
 
 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) 2012 Jeremy Long. All Rights Reserved.
 17  
  */
 18  
 package org.owasp.dependencycheck.analyzer;
 19  
 
 20  
 import java.util.Set;
 21  
 import java.util.regex.Pattern;
 22  
 import org.owasp.dependencycheck.Engine;
 23  
 import org.owasp.dependencycheck.dependency.Dependency;
 24  
 
 25  
 /**
 26  
  *
 27  
  * Used to load a JAR file and collect information that can be used to determine the associated CPE.
 28  
  *
 29  
  * @author Jeremy Long <jeremy.long@owasp.org>
 30  
  */
 31  0
 public class JavaScriptAnalyzer extends AbstractAnalyzer implements Analyzer {
 32  
 
 33  
     //<editor-fold defaultstate="collapsed" desc="All standard implmentation details of Analyzer">
 34  
     /**
 35  
      * The name of the analyzer.
 36  
      */
 37  
     private static final String ANALYZER_NAME = "JavaScript Analyzer";
 38  
     /**
 39  
      * The phase that this analyzer is intended to run in.
 40  
      */
 41  0
     private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.INFORMATION_COLLECTION;
 42  
     /**
 43  
      * The set of file extensions supported by this analyzer.
 44  
      */
 45  0
     private static final Set<String> EXTENSIONS = newHashSet("js");
 46  
 
 47  
     /**
 48  
      * Returns a list of file EXTENSIONS supported by this analyzer.
 49  
      *
 50  
      * @return a list of file EXTENSIONS supported by this analyzer.
 51  
      */
 52  
     public Set<String> getSupportedExtensions() {
 53  0
         return EXTENSIONS;
 54  
     }
 55  
 
 56  
     /**
 57  
      * Returns the name of the analyzer.
 58  
      *
 59  
      * @return the name of the analyzer.
 60  
      */
 61  
     public String getName() {
 62  0
         return ANALYZER_NAME;
 63  
     }
 64  
 
 65  
     /**
 66  
      * Returns whether or not this analyzer can process the given extension.
 67  
      *
 68  
      * @param extension the file extension to test for support.
 69  
      * @return whether or not the specified file extension is supported by this analyzer.
 70  
      */
 71  
     public boolean supportsExtension(String extension) {
 72  0
         return EXTENSIONS.contains(extension);
 73  
     }
 74  
 
 75  
     /**
 76  
      * Returns the phase that the analyzer is intended to run in.
 77  
      *
 78  
      * @return the phase that the analyzer is intended to run in.
 79  
      */
 80  
     public AnalysisPhase getAnalysisPhase() {
 81  0
         return ANALYSIS_PHASE;
 82  
     }
 83  
     //</editor-fold>
 84  
 
 85  
     /**
 86  
      * Loads a specified JAR file and collects information from the manifest and checksums to identify the correct CPE
 87  
      * information.
 88  
      *
 89  
      * @param dependency the dependency to analyze.
 90  
      * @param engine the engine that is scanning the dependencies
 91  
      * @throws AnalysisException is thrown if there is an error reading the JAR file.
 92  
      */
 93  
     @Override
 94  
     public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
 95  0
         final Pattern extractComments = Pattern.compile("(/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|(//.*)");
 96  
 
 97  0
     }
 98  
 
 99  
     /**
 100  
      * The initialize method does nothing for this Analyzer.
 101  
      *
 102  
      * @throws Exception thrown if there is an exception
 103  
      */
 104  
     @Override
 105  
     public void initialize() throws Exception {
 106  
         //do nothing
 107  0
     }
 108  
 
 109  
     /**
 110  
      * The close method does nothing for this Analyzer.
 111  
      *
 112  
      * @throws Exception thrown if there is an exception
 113  
      */
 114  
     @Override
 115  
     public void close() throws Exception {
 116  
         //do nothing
 117  0
     }
 118  
 }