Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Baseline in a secure way #4499

Merged
merged 1 commit into from Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,6 +3,7 @@ package io.gitlab.arturbosch.detekt.core.baseline
import org.xml.sax.SAXParseException
import java.nio.file.Files
import java.nio.file.Path
import javax.xml.XMLConstants
import javax.xml.parsers.SAXParserFactory
import javax.xml.stream.XMLStreamException
import javax.xml.stream.XMLStreamWriter
Expand All @@ -17,7 +18,11 @@ internal class BaselineFormat {
fun read(path: Path): Baseline {
try {
Files.newInputStream(path).use {
val reader = SAXParserFactory.newInstance().newSAXParser()
val reader = SAXParserFactory.newInstance()
.apply {
setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true)
}
.newSAXParser()
val handler = BaselineHandler()
reader.parse(it, handler)
return handler.createBaseline()
Expand Down