Skip to content

Commit 3aa4898

Browse files
Merge pull request #25 from delinea-sagar/master
Fixed the masking issue with special characters
2 parents 2867767 + d7b8203 commit 3aa4898

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

.changes/1.0.8.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## 1.0.8 - 2024-05-22
2+
### 🐛 Bug Fix
3+
4+
- Fixed the masking issue with special characters.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
77
and is generated by [Changie](https://github.com/miniscruff/changie).
8+
## 1.0.8 - 2024-05-22
9+
### 🐛 Bug Fix
10+
11+
- Fixed the masking issue with special characters.
812
## 1.0.7 - 2024-04-10
913
### 🐛 Bug Fix
1014

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tasks:
1818
bump:
1919
desc: bump the version using changie
2020
cmds:
21-
- changie batch 1.0.7
21+
- changie batch 1.0.8
2222
- changie merge
2323
- git add .changes/*
2424
- git add CHANGELOG.md

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010
<groupId>io.jenkins.plugins</groupId>
1111
<artifactId>thycotic-secret-server</artifactId>
12-
<version>1.0.7</version>
12+
<version>1.0.8</version>
1313
<packaging>hpi</packaging>
1414
<properties>
1515
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
@@ -57,17 +57,17 @@
5757
<dependency>
5858
<groupId>org.springframework</groupId>
5959
<artifactId>spring-beans</artifactId>
60-
<version>${spring.version}</version>
60+
<version>5.3.24</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>org.springframework</groupId>
6464
<artifactId>spring-context</artifactId>
65-
<version>${spring.version}</version>
65+
<version>5.3.24</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>org.springframework</groupId>
6969
<artifactId>spring-core</artifactId>
70-
<version>${spring.version}</version>
70+
<version>5.3.24</version>
7171
</dependency>
7272
<dependency>
7373
<groupId>com.thycotic.secrets</groupId>

src/main/java/com/thycotic/secrets/jenkins/ServerConsoleLogFilter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.OutputStream;
77
import java.io.Serializable;
88
import java.io.IOException;
9+
import java.util.ArrayList;
910
import java.util.List;
1011
import java.util.Objects;
1112
import java.util.stream.Collectors;
@@ -38,12 +39,24 @@ public OutputStream decorateLogger(Run run, final OutputStream logger) throws IO
3839
}
3940

4041
public static Pattern getAggregateSecretPattern(List<String> patterns) {
41-
String aggregatedPattern = String.join("|", patterns);
42+
List<String> escapedPatterns = new ArrayList<>();
43+
for (String pattern : patterns) {
44+
escapedPatterns.add(ServerConsoleLogFilter.escapeSpecialCharacters(pattern));
45+
}
46+
String aggregatedPattern = String.join("|", escapedPatterns);
4247
try {
4348
return Pattern.compile(aggregatedPattern);
4449
} catch (PatternSyntaxException e) {
4550
System.err.println("Error compiling pattern: " + e.getMessage());
4651
return null;
4752
}
4853
}
54+
55+
private static String escapeSpecialCharacters(String input) {
56+
String[] specialChars = {"\\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "[", "]", "{", "}", "~", "@", "#", "%", "&", "_", "-", "=", "!", "/"};
57+
for (String specialChar : specialChars) {
58+
input = input.replace(specialChar, "\\" + specialChar);
59+
}
60+
return input;
61+
}
4962
}

0 commit comments

Comments
 (0)