Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit de1e264

Browse files
committed
Addressed Jenkins security issues
1 parent a0d2942 commit de1e264

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/main/java/com/mathworks/ci/MatlabBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public DescriptorExtensionList<TestRunTypeList, Descriptor<TestRunTypeList>> get
150150

151151

152152
public FormValidation doCheckMatlabRoot(@QueryParameter String matlabRoot) {
153+
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
153154
setMatlabRoot(matlabRoot);
154155
List<Function<String, FormValidation>> listOfCheckMethods =
155156
new ArrayList<Function<String, FormValidation>>();

src/main/java/com/mathworks/ci/MatlabReleaseInfo.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
import javax.xml.parsers.DocumentBuilder;
2020
import javax.xml.parsers.DocumentBuilderFactory;
21+
import javax.xml.parsers.ParserConfigurationException;
2122
import org.apache.commons.collections.MapUtils;
2223
import org.w3c.dom.Document;
2324
import org.w3c.dom.Element;
2425
import org.w3c.dom.Node;
2526
import org.w3c.dom.NodeList;
2627
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2728
import hudson.FilePath;
29+
import org.xml.sax.SAXException;
2830

2931
public class MatlabReleaseInfo {
3032
private FilePath matlabRoot;
@@ -82,6 +84,15 @@ private Map<String, String> getVersionInfoFromFile() throws MatlabVersionNotFoun
8284
FilePath versionFile = new FilePath(this.matlabRoot, VERSION_INFO_FILE);
8385
if(versionFile.exists()) {
8486
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
87+
String FEATURE = null;
88+
try{
89+
FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
90+
dbFactory.setFeature(FEATURE, true);
91+
dbFactory.setXIncludeAware(false);
92+
93+
} catch (ParserConfigurationException e) {
94+
throw new MatlabVersionNotFoundException("Error parsing verify if XML is valid", e);
95+
}
8596
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
8697
Document doc = dBuilder.parse(versionFile.read());
8798

src/main/java/com/mathworks/ci/UseMatlabVersionBuildWrapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import hudson.matrix.MatrixProject;
1919
import hudson.model.Computer;
20+
import jenkins.model.Jenkins;
2021
import org.kohsuke.stapler.DataBoundConstructor;
2122
import org.kohsuke.stapler.DataBoundSetter;
2223
import org.kohsuke.stapler.QueryParameter;
@@ -139,6 +140,7 @@ public String getMatlabAxisWarning() {
139140
*/
140141

141142
public FormValidation doCheckMatlabRootFolder(@QueryParameter String matlabRootFolder) {
143+
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
142144
List<Function<String, FormValidation>> listOfCheckMethods =
143145
new ArrayList<Function<String, FormValidation>>();
144146
listOfCheckMethods.add(chkMatlabEmpty);

0 commit comments

Comments
 (0)