| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| NvdCveUpdater |
|
| 4.0;4 |
| 1 | /* | |
| 2 | * This file is part of dependency-check-core. | |
| 3 | * | |
| 4 | * Dependency-check-core is free software: you can redistribute it and/or modify it | |
| 5 | * under the terms of the GNU General Public License as published by the Free | |
| 6 | * Software Foundation, either version 3 of the License, or (at your option) any | |
| 7 | * later version. | |
| 8 | * | |
| 9 | * Dependency-check-core is distributed in the hope that it will be useful, but | |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 12 | * details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU General Public License along with | |
| 15 | * dependency-check-core. If not, see http://www.gnu.org/licenses/. | |
| 16 | * | |
| 17 | * Copyright (c) 2012 Jeremy Long. All Rights Reserved. | |
| 18 | */ | |
| 19 | package org.owasp.dependencycheck.data.update; | |
| 20 | ||
| 21 | import org.owasp.dependencycheck.data.update.exception.UpdateException; | |
| 22 | import java.net.MalformedURLException; | |
| 23 | import java.util.logging.Level; | |
| 24 | import java.util.logging.Logger; | |
| 25 | import org.owasp.dependencycheck.utils.DownloadFailedException; | |
| 26 | ||
| 27 | /** | |
| 28 | * Class responsible for updating the NVD CVE and CPE data stores. | |
| 29 | * | |
| 30 | * @author Jeremy Long <jeremy.long@owasp.org> | |
| 31 | */ | |
| 32 | 0 | public class NvdCveUpdater implements CachedWebDataSource { |
| 33 | ||
| 34 | /** | |
| 35 | * <p>Downloads the latest NVD CVE XML file from the web and imports it into | |
| 36 | * the current CVE Database.</p> | |
| 37 | * | |
| 38 | * @throws UpdateException is thrown if there is an error updating the | |
| 39 | * database | |
| 40 | */ | |
| 41 | @Override | |
| 42 | public void update() throws UpdateException { | |
| 43 | try { | |
| 44 | 0 | final StandardUpdate task = new StandardUpdate(); |
| 45 | 0 | if (task.isUpdateNeeded()) { |
| 46 | 0 | task.update(); |
| 47 | } | |
| 48 | 0 | } catch (MalformedURLException ex) { |
| 49 | 0 | Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.WARNING, |
| 50 | "NVD CVE properties files contain an invalid URL, unable to update the data to use the most current data."); | |
| 51 | 0 | Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.FINE, null, ex); |
| 52 | 0 | } catch (DownloadFailedException ex) { |
| 53 | 0 | Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.WARNING, |
| 54 | "Unable to download the NVD CVE data, unable to update the data to use the most current data."); | |
| 55 | 0 | Logger.getLogger(NvdCveUpdater.class.getName()).log(Level.FINE, null, ex); |
| 56 | 0 | } |
| 57 | 0 | } |
| 58 | } |