Skip to content

Commit

Permalink
Jenkins plugin macro replacement fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhukovAN committed Jan 13, 2022
1 parent dbd171b commit 8c782e3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,6 @@
+ [Feature] SARIF and SonarQube GIIF reports are added to CLI
+ [Feature] SARIF and SonarQube GIIF reports are added to TeamCity (no filtering yet)
### 20211228
+ [Feature] Raw JSON, SARIF and SonarQube GIIF reports filtering support added to TeamCity plugin
+ [Feature] Raw JSON, SARIF and SonarQube GIIF reports filtering support added to TeamCity plugin
### 20220113
+ [Fix] Macro replacement in Jenkins plugin fixed
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public enum PatternLanguage {
public static Map<Language, Set<PatternLanguage>> LANGUAGE_GROUP = new HashMap<>();
static {
LANGUAGE_GROUP.put(Language.PHP, Collections.singleton(PatternLanguage.PHP));
LANGUAGE_GROUP.put(Language.JAVA, Collections.singleton(PatternLanguage.PHP));
LANGUAGE_GROUP.put(Language.JAVA, Collections.singleton(PatternLanguage.JAVA));
LANGUAGE_GROUP.put(Language.CSHARP, Collections.singleton(PatternLanguage.CSHARP));
LANGUAGE_GROUP.put(Language.VB, Collections.singleton(PatternLanguage.VB));
LANGUAGE_GROUP.put(Language.JS, Collections.singleton(PatternLanguage.JAVASCRIPT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void validate() throws GenericException {
* @param replacements Dictionary with name / value pairs
* @return String with macro substitutions complete
*/
public String replaceMacro(@NonNull final String value, final Map<String, String> replacements) {
public String replaceMacro(final String value, final Map<String, String> replacements) {
return value;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public abstract class BaseIssue {

/**
* Scan result this issue belongs to
* TODO: Chek if we may get rid of this
* TODO: Check if we may get rid of this
*/
@NonNull
@JsonProperty("scanResultId")
Expand All @@ -78,6 +78,7 @@ public enum Type {
/**
* Issue type: vulnerability, weakness, SCA, DAST etc.
*/
@JsonIgnore
public Type getClazz() {
return TYPES.get(getClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ public void parsePhpSmokeScanResults() {
Assertions.assertNotEquals(0, xssCount);
}

@SneakyThrows
@Test
@DisplayName("Check scan results JSON serialization")
public void serializeScanResults() {
ObjectMapper mapper = createFaultTolerantObjectMapper();
InputStream inputStream = getResourceStream("json/scan/result/php-smoke.json");
Assertions.assertNotNull(inputStream);
ScanResult scanResult = mapper.readValue(inputStream, ScanResult.class);
String json = mapper.writeValueAsString(scanResult);
Assertions.assertFalse(json.contains("\"clazz\":"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -119,11 +120,12 @@ public JobExecutionResult processException(@NonNull final GenericException e) {
return res;
}

public String replaceMacro(@NonNull String value) {
public String replaceMacro(final String value) {
return replaceMacro(value, getBuildInfo().getEnvVars());
}

public String replaceMacro(@NonNull String value, Map<String, String> replacements) {
public String replaceMacro(final String value, Map<String, String> replacements) {
if (StringUtils.isEmpty(value)) return "";
return Util.replaceMacro(value, replacements);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public abstract class BaseIT extends BaseTest {
public static final String TOKEN = (null != System.getenv("ptai.token"))
? System.getenv("ptai.token")
: "6M9Qsct5fg20/UEzN7/hvR2RlXkTWOI5";
: "3F4y+YC+ZSkwkAGvzVDLvzvH4QXO+E2m";

public static final String USER = (null != System.getenv("ptai.user"))
? System.getenv("ptai.user")
Expand Down

0 comments on commit 8c782e3

Please sign in to comment.