View Javadoc

    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.nvdcve;
    20
    21  import org.owasp.dependencycheck.data.nvdcve.NvdCve12Handler;
    22  import java.io.File;
    23  import java.util.List;
    24  import java.util.Map;
    25  import javax.xml.parsers.SAXParser;
    26  import javax.xml.parsers.SAXParserFactory;
    27  import org.owasp.dependencycheck.dependency.VulnerableSoftware;
    28  import org.junit.After;
    29  import org.junit.AfterClass;
    30  import org.junit.Before;
    31  import org.junit.BeforeClass;
    32  import org.junit.Test;
    33  import static org.junit.Assert.*;
    34
    35  /**
    36   *
    37   * @author Jeremy Long (jeremy.long@owasp.org)
    38   */
    39  public class NvdCve_1_2_HandlerTest {
    40
    41      public NvdCve_1_2_HandlerTest() {
    42      }
    43
    44      @BeforeClass
    45      public static void setUpClass() throws Exception {
    46      }
    47
    48      @AfterClass
    49      public static void tearDownClass() throws Exception {
    50      }
    51
    52      @Before
    53      public void setUp() {
    54      }
    55
    56      @After
    57      public void tearDown() {
    58      }
    59
    60      @Test
    61      public void testParse() throws Exception {
    62          SAXParserFactory factory = SAXParserFactory.newInstance();
    63          SAXParser saxParser = factory.newSAXParser();
    64
    65          File file = new File(this.getClass().getClassLoader().getResource("nvdcve-2012.xml").getPath());
    66
    67          NvdCve12Handler instance = new NvdCve12Handler();
    68          saxParser.parse(file, instance);
    69          Map<String, List<VulnerableSoftware>> results = instance.getVulnerabilities();
    70          assertTrue("No vulnerable software identified with a previous version in 2012 CVE 1.2?", !results.isEmpty());
    71      }
    72  }