Skip to content

Commit

Permalink
Update aws secret pattern matcher (#1755)
Browse files Browse the repository at this point in the history
  • Loading branch information
aimethed authored Feb 14, 2024
1 parent e5ce527 commit 0fa4434
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class CachableSecretsManager
private static final long MAX_CACHE_AGE_MS = 60_000;
protected static final int MAX_CACHE_SIZE = 10;

private static final String SECRET_PATTERN = "(\\$\\{[a-zA-Z0-9-_\\-]+\\})";
private static final String SECRET_NAME_PATTERN = "\\$\\{([a-zA-Z0-9-_\\-]+)\\}";
private static final String SECRET_PATTERN = "(\\$\\{[a-zA-Z0-9-\\/_\\-\\.\\+=@]+\\})";
private static final String SECRET_NAME_PATTERN = "\\$\\{([a-zA-Z0-9-\\/_\\-\\.\\+=@]+)\\}";
private static final Pattern PATTERN = Pattern.compile(SECRET_PATTERN);
private static final Pattern NAME_PATTERN = Pattern.compile(SECRET_NAME_PATTERN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public void resolveSecrets()
String commonErrorsExpected = "ThisIsM}yStringWi${thTwoSecretS{uperSecretSecrets";
assertEquals(commonErrorsExpected, cachableSecretsManager.resolveSecrets(commonErrors));

String secretAllowedSpecialChars = "ThisIs${/My}StringW${ith_}All${Of+The}${@llowed=}${Special-Characters.}";
String secretAllowedSpecialCharsExpected = "ThisIs/MyStringWith_AllOf+The@llowed=Special-Characters.";
assertEquals(secretAllowedSpecialCharsExpected, cachableSecretsManager.resolveSecrets(secretAllowedSpecialChars));

String unknownSecret = "This${Unknown}";
try {
cachableSecretsManager.resolveSecrets(unknownSecret);
Expand Down

0 comments on commit 0fa4434

Please sign in to comment.