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