Coverage Report - org.owasp.dependencycheck.analyzer.CpeSuppressionAnalyzer
 
Classes in this File Line Coverage Branch Coverage Complexity
CpeSuppressionAnalyzer
60%
6/10
16%
1/6
2.333
 
 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) 2013 Jeremy Long. All Rights Reserved.
 17  
  */
 18  
 package org.owasp.dependencycheck.analyzer;
 19  
 
 20  
 import org.owasp.dependencycheck.Engine;
 21  
 import org.owasp.dependencycheck.dependency.Dependency;
 22  
 import org.owasp.dependencycheck.suppression.SuppressionRule;
 23  
 
 24  
 /**
 25  
  * The suppression analyzer processes an externally defined XML document that complies with the suppressions.xsd schema.
 26  
  * Any identified CPE entries within the dependencies that match will be removed.
 27  
  *
 28  
  * @author Jeremy Long <jeremy.long@owasp.org>
 29  
  */
 30  1
 public class CpeSuppressionAnalyzer extends AbstractSuppressionAnalyzer {
 31  
 
 32  
     //<editor-fold defaultstate="collapsed" desc="All standard implmentation details of Analyzer">
 33  
     /**
 34  
      * The name of the analyzer.
 35  
      */
 36  
     private static final String ANALYZER_NAME = "Cpe Suppression Analyzer";
 37  
     /**
 38  
      * The phase that this analyzer is intended to run in.
 39  
      */
 40  1
     private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.POST_IDENTIFIER_ANALYSIS;
 41  
 
 42  
     /**
 43  
      * Returns the name of the analyzer.
 44  
      *
 45  
      * @return the name of the analyzer.
 46  
      */
 47  
     @Override
 48  
     public String getName() {
 49  9
         return ANALYZER_NAME;
 50  
     }
 51  
 
 52  
     /**
 53  
      * Returns the phase that the analyzer is intended to run in.
 54  
      *
 55  
      * @return the phase that the analyzer is intended to run in.
 56  
      */
 57  
     @Override
 58  
     public AnalysisPhase getAnalysisPhase() {
 59  6
         return ANALYSIS_PHASE;
 60  
     }
 61  
     //</editor-fold>
 62  
 
 63  
     @Override
 64  
     public void analyze(final Dependency dependency, final Engine engine) throws AnalysisException {
 65  
 
 66  9
         if (getRules() == null || getRules().size() <= 0) {
 67  9
             return;
 68  
         }
 69  
 
 70  0
         for (final SuppressionRule rule : getRules()) {
 71  0
             rule.process(dependency);
 72  0
         }
 73  0
     }
 74  
 }