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

Update to Java 11 and recent parent POM, cleanup dependencies #253

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM maven:alpine as maven
FROM maven:3.8.6-eclipse-temurin-11 as maven
WORKDIR /app
COPY ./ ./
RUN mvn package -DskipTests

FROM maven:alpine
FROM maven:3.8.6-eclipse-temurin-11
ENV VERSION=1.3-SNAPSHOT
RUN apk --no-cache add git
WORKDIR /app
Expand Down
5 changes: 3 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ for (int i = 0; i < platforms.size(); ++i) {

stage('Build') {
withEnv([
"JAVA_HOME=${tool 'jdk8'}",
"JAVA_HOME=${tool 'jdk11'}",
"PATH+MVN=${tool 'mvn'}/bin",
'PATH+JDK=$JAVA_HOME/bin',
]) {
timeout(60) {
String command = 'mvn --batch-mode clean install -Dmaven.test.failure.ignore=true -Denvironment=test -Prun-its'
//TODO: Re-enable integration tests after full upgrade to Java 11
String command = 'mvn --batch-mode clean install -Dmaven.test.failure.ignore=true -Denvironment=test'
if (isUnix()) {
sh command
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class Config {
@CheckForNull
public Collection<CasCConfig> casc;

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
private static Config load(@Nonnull InputStream istream, boolean isEssentialsYML) throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
final Config loaded;
Expand Down Expand Up @@ -110,10 +111,12 @@ public static Config loadConfig(@Nonnull File configPath) throws IOException {
}

// TODO: make the destination configurable
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
public File getOutputWar() {
return new File(buildSettings.getTmpDir(), "/output/target/" + bundle.artifactId + "-" + buildSettings.getVersion() + ".war");
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
public File getOutputBOM() {
return new File(buildSettings.getTmpDir(), "/output/target/" + bundle.artifactId + "-" + buildSettings.getVersion() + ".bom.yml");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.tools.warpackager.lib.impl;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.jenkins.tools.warpackager.lib.config.CasCConfig;
import io.jenkins.tools.warpackager.lib.config.Config;
import io.jenkins.tools.warpackager.lib.config.DockerBuildSettings;
Expand Down Expand Up @@ -69,6 +70,7 @@ public void verifyConfig() throws IOException {
}
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
public void build() throws IOException, InterruptedException {

// Cleanup the temporary directory
Expand Down Expand Up @@ -230,6 +232,7 @@ public void build() throws IOException, InterruptedException {
}

//TODO: Merge with buildIfNeeded
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
private File checkoutIfNeeded(@Nonnull String id, @Nonnull SourceInfo source) throws IOException, InterruptedException {
File componentBuildDir = new File(buildRoot, id);
Files.createDirectories(componentBuildDir.toPath());
Expand Down Expand Up @@ -261,6 +264,7 @@ private void buildIfNeeded(@Nonnull DependencyInfo dep, @Nonnull String packagin
buildIfNeeded(dep, packaging,null);
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
private void buildIfNeeded(@Nonnull DependencyInfo dep, @Nonnull String packaging,
@CheckForNull List<String> extraMavenArgs)
throws IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//TODO: This code should finally go to the Standard Maven HPI Plugin

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.jenkins.tools.warpackager.lib.config.Config;
import io.jenkins.tools.warpackager.lib.config.DependencyInfo;
import io.jenkins.tools.warpackager.lib.config.WARResourceInfo;
Expand Down Expand Up @@ -41,10 +42,11 @@
import java.util.zip.ZipFile;

/**
* Custom stub for patching WAR files
* Custom logic for patching WAR files
* @author Oleg Nenashev
* @since TODO
*/
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
public class JenkinsWarPatcher extends PackagerBase {

private static final Logger LOGGER = Logger.getLogger(JenkinsWarPatcher.class.getName());
Expand All @@ -64,6 +66,7 @@ public JenkinsWarPatcher(@Nonnull Config config, @Nonnull File src, @Nonnull Fil
}

@Nonnull
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
private void explode(@Nonnull Set<String> excludes) throws IOException {
try (ZipFile zip = new ZipFile(srcWar)) {
Enumeration<? extends ZipEntry> it = zip.entries();
Expand All @@ -87,6 +90,7 @@ public JenkinsWarPatcher removeMetaInf() throws IOException {
return this;
}

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
private void deleteMetaINFFiles(String ... filenames) throws IOException {
for (String filename : filenames) {
File p = new File(dstDir, "META-INF/" + filename);
Expand Down Expand Up @@ -216,6 +220,8 @@ public void addResource(@Nonnull WARResourceInfo resource, File path) throws IOE
}

@Nonnull
@SuppressFBWarnings(value = {"XXE_DOCUMENT", "XXE_DTD_TRANSFORM_FACTORY"},
justification = "By design, private method for the utility tool")
private Document readXMLResource(String path) throws IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try (ZipFile zip = new ZipFile(srcWar)) {
Expand Down Expand Up @@ -244,7 +250,8 @@ private void copyResource(String srcPath, String destPath) throws IOException {
}
}

@Nonnull
@SuppressFBWarnings(value = {"XXE_DTD_TRANSFORM_FACTORY", "XXE_XSLT_TRANSFORM_FACTORY"},
justification = "By design, private method for the utility tool")
private void writeXMLResource(String path, Document doc) throws IOException {
File out = new File(dstDir, path);
createParentDirIfNotExists(out);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.tools.warpackager.lib.impl.plugins;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.jenkins.tools.warpackager.lib.config.DependencyInfo;
import io.jenkins.tools.warpackager.lib.model.plugins.PluginInfoProvider;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -39,9 +40,11 @@ public boolean isPlugin(@Nonnull DependencyInfo dependency) throws IOException,
return isPlugin;
}

@SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD",
justification = "Utility tool. The user takes the risk when connecting to custom update centers")
private static Map<String, String> extractUpdateCenterData(URL url) throws IOException {
Map<String, String> groupIDs = new HashMap<>();
String jsonp = null;
final String jsonp;
try {
jsonp = IOUtils.toString(url.openStream());
} catch(IOException e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import static io.jenkins.tools.warpackager.lib.util.SystemCommandHelper.runFor;

/**
* Maven interop utility class
* @author Oleg Nenashev
*/
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "As designed, the method is driven by config")
public class MavenHelper {

private static final String USER_HOME_PROPERTY = System.getProperty("user.home");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.tools.warpackager.lib.util;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;

Expand All @@ -10,9 +11,11 @@
import java.util.stream.Stream;

/**
* Wraps system commands needed for the tool.
* @author Oleg Nenashev
* @since TODO
*/
@SuppressFBWarnings(value = "COMMAND_INJECTION", justification = "As designed, system command helper class")
public class SystemCommandHelper {

// https://stackoverflow.com/a/228499
Expand Down
12 changes: 8 additions & 4 deletions custom-war-packager-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<name>Jenkins Custom WAR Packager Maven Plugin</name>
<description>Generates a Custom WAR file from the specified YAML configuration file</description>

<properties>
<spotbugs.skip>true</spotbugs.skip>
</properties>

<dependencies>
<dependency>
<groupId>io.jenkins.tools.custom-war-packager</groupId>
Expand All @@ -30,7 +34,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.1</version>
<version>3.7.1</version>
<!-- annotations are not needed for plugin execution, so exclude using provided scope -->
<scope>provided</scope>
</dependency>
Expand All @@ -44,7 +48,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -68,7 +72,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.1</version>
<executions>
<execution>
<id>generated-helpmojo</id>
Expand All @@ -86,7 +90,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.1</version>
</plugin>
</plugins>
</reporting>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.tools.warpackager.mavenplugin;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.jenkins.tools.warpackager.lib.config.BuildSettings;
import io.jenkins.tools.warpackager.lib.config.Config;
import io.jenkins.tools.warpackager.lib.impl.Builder;
Expand All @@ -25,6 +26,7 @@
* @since TODO
*/
@Mojo(name="build", defaultPhase = PACKAGE, requiresProject = false)
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "Maven plugin with parameterization, as designed")
public class BuildMojo extends AbstractMojo {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.tools.warpackager.mavenplugin;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.jenkins.tools.warpackager.lib.config.Config;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -20,6 +21,7 @@
* @since TODO
*/
@Mojo(name="custom-war", defaultPhase = PACKAGE, requiresDependencyResolution = RUNTIME)
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "Maven plugin with parameterization, as designed")
public class PackageMojo extends BuildMojo {

@Component
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<parent>
<groupId>org.jenkins-ci</groupId>
<artifactId>jenkins</artifactId>
<version>1.54</version>
<version>1.94</version>
</parent>

<properties>
<java.level>8</java.level>
<java.level>11</java.level>
<!-- Version of Maven Components -->
<maven.version>3.8.1</maven.version>
<maven.version>3.8.6</maven.version>
</properties>

<groupId>io.jenkins.tools.custom-war-packager</groupId>
Expand Down Expand Up @@ -59,9 +59,9 @@

<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1u2</version>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.7.3</version>
</dependency>

<!-- Test deps -->
Expand Down