Skip to content

Commit

Permalink
Add access_token to log mask + throw error if non boolean string is p…
Browse files Browse the repository at this point in the history
…assed for sonarr v4 config (#115)
  • Loading branch information
shayaantx authored Dec 20, 2023
1 parent cd31512 commit b1d66bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ botdarr:
| SONARR_DEFAULT_PROFILE | The sonarr quality profile (should be already configured in sonarr) | yes - if you use sonarr |
| SONARR_PATH | Where your sonarr shows should go (if you add/update them) | yes - if you use sonarr |
| SONARR_URL_BASE | Only populate this if you use a custom sonarr url base (which is configurable in Sonarr->Settings->General->URL Base) don't include prefix/suffix slashes | no |
| SONARR_V4 | Whether you are using sonarr v4 or not | no | no |
| SONARR_V4 | Whether you are using sonarr v4 or not (true/false) | no | false |

#### Lidarr
| Environment Variable | Description | Required | Default |
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/botdarr/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public static boolean isSonarrEnabled() {

public static boolean isSonarrV4Enabled() {
String isSonarrV4 = Config.getProperty(Config.Constants.SONARR_V4);
if (!Strings.isEmpty(isSonarrV4) &&
!(isSonarrV4.equalsIgnoreCase("true") ||
isSonarrV4.equalsIgnoreCase("false"))) {
throw new RuntimeException("Sonarr V4 flag is not set to true/false");
}
return !Strings.isEmpty(isSonarrV4) && Boolean.parseBoolean(isSonarrV4);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Plugin(name="LogMaskingConverter", category = "Converter")
@ConverterKeys({"scrubbedMsg"})
public class Log4jSensitiveDataPattern extends LogEventPatternConverter {
private static final Pattern API_KEY_PATTERN = Pattern.compile("apiKey=([0-9a-zA-z]+)");
private static final Pattern SECRET_PATTERN = Pattern.compile("(apiKey|access_token)=([0-9a-zA-z]+)");

protected Log4jSensitiveDataPattern(String name, String style) {
super(name, style);
Expand All @@ -26,9 +26,9 @@ public void format(LogEvent event, StringBuilder toAppendTo) {
String maskedMessage = message;
try {
StringBuffer modifiedBuffer = new StringBuffer();
Matcher matcher = API_KEY_PATTERN.matcher(message);
Matcher matcher = SECRET_PATTERN.matcher(message);
while(matcher.find()) {
matcher.appendReplacement(modifiedBuffer, "apiKey=****");
matcher.appendReplacement(modifiedBuffer, "****");
}
if (modifiedBuffer.length() > 0) {
maskedMessage = modifiedBuffer.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.6.11
5.6.12

0 comments on commit b1d66bc

Please sign in to comment.