Skip to content

Commit

Permalink
Encryption keys aren't passed in Linux agents (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Jan 13, 2024
1 parent e2bc38e commit b2b9ea2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
22 changes: 20 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<!--Skip integration tests unless explicitly requested with -DskipITs=false-->
<skipITs>true</skipITs>

<buildinfo.version>2.41.11</buildinfo.version>
<buildinfo.gradle.version>5.1.13</buildinfo.gradle.version>
<buildinfo.version>2.41.12</buildinfo.version>
<buildinfo.gradle.version>5.1.14</buildinfo.gradle.version>
</properties>

<repositories>
Expand Down Expand Up @@ -465,8 +465,26 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jenkins-multijob-plugin</artifactId>
Expand Down
23 changes: 7 additions & 16 deletions src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,14 @@
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.nio.file.Files;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;

import static org.jfrog.build.api.BuildInfoConfigProperties.*;

/**
* @author Tomer Cohen
Expand Down Expand Up @@ -586,7 +577,7 @@ private static FilePath createPropertiesFile(FilePath ws) throws IOException, In
private static void setPersistConfigurationEnv(ArtifactoryClientConfiguration configuration, FilePath propertiesFile,
Map<String, String> env) {
configuration.setPropertiesFile(propertiesFile.getRemote());
env.put("BUILDINFO_PROPFILE", propertiesFile.getRemote());
env.put(ENV_BUILDINFO_PROPFILE, propertiesFile.getRemote());
env.put(BuildInfoConfigProperties.PROP_PROPS_FILE, propertiesFile.getRemote());
// Jenkins prefixes env variables with 'env' but we need it clean.
System.setProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, propertiesFile.getRemote());
Expand All @@ -601,8 +592,8 @@ private static void savePropertiesToFile(ArtifactoryClientConfiguration configur
configuration.persistToPropertiesFile();
} else {
EncryptionKeyPair keyPair = configuration.persistToEncryptedPropertiesFile(outputStream);
env.put(BuildInfoConfigProperties.PROP_PROPS_FILE_KEY, keyPair.getStringSecretKey());
env.put(BuildInfoConfigProperties.PROP_PROPS_FILE_KEY_IV, keyPair.getStringIv());
env.put(ENV_PROPERTIES_FILE_KEY, keyPair.getStringSecretKey());
env.put(ENV_PROPERTIES_FILE_KEY_IV, keyPair.getStringIv());
}
} catch (IOException | InterruptedException | InvalidAlgorithmParameterException | NoSuchPaddingException |
IllegalBlockSizeException | NoSuchAlgorithmException | BadPaddingException | InvalidKeyException e) {
Expand Down

0 comments on commit b2b9ea2

Please sign in to comment.