Coverage Report - org.owasp.dependencycheck.analyzer.Analyzer
 
Classes in this File Line Coverage Branch Coverage Complexity
Analyzer
N/A
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 org.owasp.dependencycheck.analyzer.exception.AnalysisException;
 21  
 import java.util.Set;
 22  
 import org.owasp.dependencycheck.Engine;
 23  
 import org.owasp.dependencycheck.dependency.Dependency;
 24  
 
 25  
 /**
 26  
  * An interface that defines an Analyzer that is used to identify Dependencies. An analyzer will collect information
 27  
  * about the dependency in the form of Evidence.
 28  
  *
 29  
  * @author Jeremy Long <jeremy.long@owasp.org>
 30  
  */
 31  
 public interface Analyzer {
 32  
 
 33  
     /**
 34  
      * Analyzes the given dependency. The analysis could be anything from identifying an Identifier for the dependency,
 35  
      * to finding vulnerabilities, etc. Additionally, if the analyzer collects enough information to add a description
 36  
      * or license information for the dependency it should be added.
 37  
      *
 38  
      * @param dependency a dependency to analyze.
 39  
      * @param engine the engine that is scanning the dependencies - this is useful if we need to check other
 40  
      * dependencies
 41  
      * @throws AnalysisException is thrown if there is an error analyzing the dependency file
 42  
      */
 43  
     void analyze(Dependency dependency, Engine engine) throws AnalysisException;
 44  
 
 45  
     /**
 46  
      * <p>
 47  
      * Returns a list of supported file extensions. An example would be an analyzer that inspected java jar files. The
 48  
      * getSupportedExtensions function would return a set with a single element "jar".</p>
 49  
      *
 50  
      * <p>
 51  
      * <b>Note:</b> when implementing this the extensions returned MUST be lowercase.</p>
 52  
      *
 53  
      * @return The file extensions supported by this analyzer.
 54  
      *
 55  
      * <p>
 56  
      * If the analyzer returns null it will not cause additional files to be analyzed but will be executed against every
 57  
      * file loaded</p>
 58  
      */
 59  
     Set<String> getSupportedExtensions();
 60  
 
 61  
     /**
 62  
      * Returns the name of the analyzer.
 63  
      *
 64  
      * @return the name of the analyzer.
 65  
      */
 66  
     String getName();
 67  
 
 68  
     /**
 69  
      * Returns whether or not this analyzer can process the given extension.
 70  
      *
 71  
      * @param extension the file extension to test for support.
 72  
      * @return whether or not the specified file extension is supported by this analyzer.
 73  
      */
 74  
     boolean supportsExtension(String extension);
 75  
 
 76  
     /**
 77  
      * Returns the phase that the analyzer is intended to run in.
 78  
      *
 79  
      * @return the phase that the analyzer is intended to run in.
 80  
      */
 81  
     AnalysisPhase getAnalysisPhase();
 82  
 
 83  
     /**
 84  
      * The initialize method is called (once) prior to the analyze method being called on all of the dependencies.
 85  
      *
 86  
      * @throws Exception is thrown if an exception occurs initializing the analyzer.
 87  
      */
 88  
     void initialize() throws Exception;
 89  
 
 90  
     /**
 91  
      * The close method is called after all of the dependencies have been analyzed.
 92  
      *
 93  
      * @throws Exception is thrown if an exception occurs closing the analyzer.
 94  
      */
 95  
     void close() throws Exception;
 96  
 }