mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-21 16:49:43 +01:00
Merge branch 'colezlaw-suppression-fix'
Former-commit-id: 1e7d9df774347ea043fef8ef3f5d6ca4aebaa15a
This commit is contained in:
@@ -100,9 +100,8 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
|
|||||||
private void loadSuppressionData() throws SuppressionParseException {
|
private void loadSuppressionData() throws SuppressionParseException {
|
||||||
final SuppressionParser parser = new SuppressionParser();
|
final SuppressionParser parser = new SuppressionParser();
|
||||||
File file = null;
|
File file = null;
|
||||||
file = new File(this.getClass().getClassLoader().getResource("dependencycheck-base-suppression.xml").getPath());
|
|
||||||
try {
|
try {
|
||||||
rules = parser.parseSuppressionRules(file);
|
rules = parser.parseSuppressionRules(this.getClass().getClassLoader().getResourceAsStream("dependencycheck-base-suppression.xml"));
|
||||||
} catch (SuppressionParseException ex) {
|
} catch (SuppressionParseException ex) {
|
||||||
LOGGER.log(Level.FINE, "Unable to parse the base suppression data file", ex);
|
LOGGER.log(Level.FINE, "Unable to parse the base suppression data file", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,11 @@ import java.io.Reader;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.parsers.SAXParser;
|
import javax.xml.parsers.SAXParser;
|
||||||
import javax.xml.parsers.SAXParserFactory;
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
@@ -66,10 +68,25 @@ public class SuppressionParser {
|
|||||||
* @throws SuppressionParseException thrown if the xml file cannot be parsed
|
* @throws SuppressionParseException thrown if the xml file cannot be parsed
|
||||||
*/
|
*/
|
||||||
public List<SuppressionRule> parseSuppressionRules(File file) throws SuppressionParseException {
|
public List<SuppressionRule> parseSuppressionRules(File file) throws SuppressionParseException {
|
||||||
|
try {
|
||||||
|
return parseSuppressionRules(new FileInputStream(file));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.log(Level.FINE, null, ex);
|
||||||
|
throw new SuppressionParseException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the given xml stream and returns a list of the suppression rules contained.
|
||||||
|
*
|
||||||
|
* @param inputStream an InputStream containing suppression rues
|
||||||
|
* @return a list of suppression rules
|
||||||
|
* @throws SuppressionParseException if the xml cannot be parsed
|
||||||
|
*/
|
||||||
|
public List<SuppressionRule> parseSuppressionRules(InputStream inputStream) throws SuppressionParseException {
|
||||||
try {
|
try {
|
||||||
final InputStream schemaStream = this.getClass().getClassLoader().getResourceAsStream("schema/suppression.xsd");
|
final InputStream schemaStream = this.getClass().getClassLoader().getResourceAsStream("schema/suppression.xsd");
|
||||||
final SuppressionHandler handler = new SuppressionHandler();
|
final SuppressionHandler handler = new SuppressionHandler();
|
||||||
|
|
||||||
final SAXParserFactory factory = SAXParserFactory.newInstance();
|
final SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
factory.setNamespaceAware(true);
|
factory.setNamespaceAware(true);
|
||||||
factory.setValidating(true);
|
factory.setValidating(true);
|
||||||
@@ -80,7 +97,6 @@ public class SuppressionParser {
|
|||||||
xmlReader.setErrorHandler(new SuppressionErrorHandler());
|
xmlReader.setErrorHandler(new SuppressionErrorHandler());
|
||||||
xmlReader.setContentHandler(handler);
|
xmlReader.setContentHandler(handler);
|
||||||
|
|
||||||
final InputStream inputStream = new FileInputStream(file);
|
|
||||||
final Reader reader = new InputStreamReader(inputStream, "UTF-8");
|
final Reader reader = new InputStreamReader(inputStream, "UTF-8");
|
||||||
final InputSource in = new InputSource(reader);
|
final InputSource in = new InputSource(reader);
|
||||||
//in.setEncoding("UTF-8");
|
//in.setEncoding("UTF-8");
|
||||||
|
|||||||
Reference in New Issue
Block a user