From c67a89822f86a7d10498ea2783b833052b719086 Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Tue, 3 Jan 2023 10:07:58 +0800 Subject: [PATCH] SECURITY-2973 --- pom.xml | 2 +- .../SemanticVersioning/parsing/PomParser.java | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 6998658..c092dca 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 1.625.3 - 7 + 8 semantic-versioning-plugin diff --git a/src/main/java/org/jenkinsci/plugins/SemanticVersioning/parsing/PomParser.java b/src/main/java/org/jenkinsci/plugins/SemanticVersioning/parsing/PomParser.java index 1cf8796..fdcea76 100644 --- a/src/main/java/org/jenkinsci/plugins/SemanticVersioning/parsing/PomParser.java +++ b/src/main/java/org/jenkinsci/plugins/SemanticVersioning/parsing/PomParser.java @@ -26,14 +26,13 @@ import hudson.Extension; import hudson.FilePath; -import hudson.FilePath.FileCallable; import hudson.model.Descriptor; import hudson.remoting.VirtualChannel; +import jenkins.MasterToSlaveFileCallable; import org.jenkinsci.plugins.SemanticVersioning.AppVersion; import org.jenkinsci.plugins.SemanticVersioning.InvalidBuildFileFormatException; import org.jenkinsci.plugins.SemanticVersioning.Messages; -import org.jenkinsci.remoting.RoleChecker; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -54,6 +53,7 @@ public class PomParser extends AbstractBuildDefinitionParser { public PomParser() { } + @Override public AppVersion extractAppVersion(FilePath workspace, PrintStream logger) throws IOException, InvalidBuildFileFormatException { String version = null; @@ -86,7 +86,7 @@ private Document getPom(FilePath workspace) Document pomDocument; try { - pomDocument = pom.act(new FileCallable() { + pomDocument = pom.act(new MasterToSlaveFileCallable() { private static final long serialVersionUID = 1L; public Document invoke(File pom, VirtualChannel channel) @@ -98,20 +98,13 @@ public Document invoke(File pom, VirtualChannel channel) .newDocumentBuilder(); return documentBuilder.parse(pom); - } catch (SAXException e) { - throw new InterruptedException(pom - .getAbsolutePath() - + " is not a valid POM file."); - } catch (ParserConfigurationException e) { + } catch (SAXException | ParserConfigurationException e) { throw new InterruptedException(pom .getAbsolutePath() + " is not a valid POM file."); } } - public void checkRoles(RoleChecker arg0) throws SecurityException { - } - }); } catch (InterruptedException e) { throw new InvalidBuildFileFormatException(e.getMessage());