Coverage Report - org.owasp.dependencycheck.data.update.NvdCveUpdater
 
Classes in this File Line Coverage Branch Coverage Complexity
NvdCveUpdater
0%
0/12
0%
0/2
4
 
 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.data.update;
 19  
 
 20  
 import java.net.MalformedURLException;
 21  
 import java.util.logging.Level;
 22  
 import java.util.logging.Logger;
 23  
 import org.owasp.dependencycheck.data.update.exception.UpdateException;
 24  
 import org.owasp.dependencycheck.utils.DownloadFailedException;
 25  
 
 26  
 /**
 27  
  * Class responsible for updating the NVD CVE and CPE data stores.
 28  
  *
 29  
  * @author Jeremy Long <jeremy.long@owasp.org>
 30  
  */
 31  0
 public class NvdCveUpdater implements CachedWebDataSource {
 32  
 
 33  
     /**
 34  
      * <p>
 35  
      * Downloads the latest NVD CVE XML file from the web and imports it into the current CVE Database.</p>
 36  
      *
 37  
      * @throws UpdateException is thrown if there is an error updating the database
 38  
      */
 39  
     @Override
 40  
     public void update() throws UpdateException {
 41  
         try {
 42  0
             final StandardUpdate task = new StandardUpdate();
 43  0
             if (task.isUpdateNeeded()) {
 44  0
                 task.update();
 45  
             }
 46  0
         } catch (MalformedURLException ex) {
 47  0
             Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.WARNING,
 48  
                     "NVD CVE properties files contain an invalid URL, unable to update the data to use the most current data.");
 49  0
             Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.FINE, null, ex);
 50  0
         } catch (DownloadFailedException ex) {
 51  0
             Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.WARNING,
 52  
                     "Unable to download the NVD CVE data, unable to update the data to use the most current data.");
 53  0
             Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.FINE, null, ex);
 54  0
         }
 55  0
     }
 56  
 }