Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter HTTP Basic Authorisation Credential in Update Audit Log #1622

Merged
merged 37 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
db9d8ad
API Key authenticate
maggarwal13 Dec 24, 2024
f7243bb
Fix tests
maggarwal13 Dec 24, 2024
a0d1b42
refactor
maggarwal13 Dec 24, 2024
c3cf5a9
add loggings
maggarwal13 Dec 27, 2024
4c5232f
fix exception
maggarwal13 Dec 27, 2024
abcd1fa
change logging
maggarwal13 Dec 27, 2024
6e52f60
refactor
maggarwal13 Dec 27, 2024
b21c4ee
Add more logging
maggarwal13 Dec 27, 2024
5063c18
add objectMapper
maggarwal13 Dec 27, 2024
88d7673
remove expiration
maggarwal13 Dec 27, 2024
117bd97
correct scope formatting
maggarwal13 Dec 27, 2024
74fd6d8
fix scope issue
maggarwal13 Dec 27, 2024
7a28d79
refactor
maggarwal13 Dec 27, 2024
632d27b
remove logging
maggarwal13 Dec 30, 2024
b945733
use Header for bearer token
maggarwal13 Dec 31, 2024
fe5a1e3
refactor
maggarwal13 Dec 31, 2024
bec395f
test for notification email
maggarwal13 Dec 31, 2024
8c5e29d
refactor
maggarwal13 Dec 31, 2024
eaded85
Add tests
maggarwal13 Dec 31, 2024
feb4715
Add JWT verification
maggarwal13 Jan 2, 2025
2104def
enable caching on public key
maggarwal13 Jan 2, 2025
db70263
change logging to error
maggarwal13 Jan 2, 2025
fe546c6
add tests
maggarwal13 Jan 2, 2025
2e73133
Add Tests for updates
maggarwal13 Jan 3, 2025
193fbca
add domain tests
maggarwal13 Jan 3, 2025
092d108
acl by apikey email
maggarwal13 Jan 6, 2025
f7f1fd1
add caching for ApiKey oAuth
maggarwal13 Jan 6, 2025
d747f70
Merge branch 'master' into apikey_autheniticate
maggarwal13 Jan 6, 2025
e492dbd
refcator
maggarwal13 Jan 7, 2025
fd63bbf
Merge branch 'apikey_autheniticate' into acl_accounting_api_key
maggarwal13 Jan 7, 2025
d1c8e9c
Filter basic auth from audit logs
maggarwal13 Jan 8, 2025
6ed0f25
Merge branch 'master' into filter_basic_auth_audit_logs
maggarwal13 Jan 9, 2025
74ab29a
remove one space
maggarwal13 Jan 10, 2025
19a5d01
Merge branch 'master' into filter_basic_auth_audit_logs
eshryane Jan 14, 2025
805448f
Simplified regex
eshryane Jan 14, 2025
4010b78
Merge branch 'master' into filter_basic_auth_audit_logs
eshryane Jan 15, 2025
f45a77e
Merge branch 'master' into filter_basic_auth_audit_logs
maggarwal13 Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.ripe.db.whois.common.conversion;

import com.google.common.base.Splitter;
import org.apache.commons.lang.StringUtils;

import java.util.Iterator;
import java.util.List;
Expand All @@ -20,15 +21,26 @@ public class PasswordFilter {

//from logsearch tweaked
private static final Pattern PASSWORD_PATTERN_FOR_CONTENT = Pattern.compile("(?im)^(override|password)(:|%3A)\\s*(.+)\\s*$");
private static final Pattern BASIC_AUTH_HEADER_PATTERN_FOR_CONTENT = Pattern.compile("(?im)^(Header: Authorization=Basic)\\s*(.*)\\s*$", Pattern.CASE_INSENSITIVE);

private static final Pattern URI_PASSWORD_PATTERN_PASSWORD_FOR_URL = Pattern.compile("(?<=)(password|override)(:|=|%3A)([^&^\\s]*)", Pattern.CASE_INSENSITIVE);

public static String filterPasswordsInContents(final String contents) {
String result = contents;
if (contents != null) {
final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents);
result = replacePassword(matcher);
if(StringUtils.isEmpty(contents)) {
return contents;
}
return result;

final String filteredContent = replaceBasicAuthHeader(BASIC_AUTH_HEADER_PATTERN_FOR_CONTENT.matcher(contents));
Dismissed Show dismissed Hide dismissed
return replacePassword(PASSWORD_PATTERN_FOR_CONTENT.matcher(filteredContent));
}

private static String replaceBasicAuthHeader(final Matcher matcher) {
final StringBuilder result = new StringBuilder();
while (matcher.find()) {
matcher.appendReplacement(result, String.format("%s FILTERED", matcher.group(1)));
}
matcher.appendTail(result);
return result.toString();
}

public static String filterPasswordsInUrl(final String url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,38 @@ public void testFilterPasswordsInMessage() {
"delete: adsf\n"));
}

@Test
public void testFilterBasicAuthHeadersInMessage() {
final String input = "" +
"Header: Authorization=Basic dDZsUlpndk9GSXBoamlHd3RDR3VMd3F3OjJDVEdQeDVhbFVFVzRwa1Rrd2FRdGRPNg==\n" +
"blue: asdfasdfasdf\n" +
"yellow%3A++asdfasdfasdf\n" +
"green: asdfasdfasdf # password: test\n" +
"purple: password\n" +
"password: test1 \n" +
"password:test2\n" +
"password: test3\n" +
"password%3A++test4\n" +
"password%3A++test5\n" +
"Header: Authorization=Basic dDZsUlpndk9GSXBoamlHd3RDR3VMd3F3OjJDVEdQeDVhbFVFVzRwa1Rrd2FRdGRPNg==\n" +
"delete: adsf\n";

assertThat(PasswordFilter.filterPasswordsInContents(input), containsString("" +
"Header: Authorization=Basic FILTERED\n" +
"blue: asdfasdfasdf\n" +
"yellow%3A++asdfasdfasdf\n" +
"green: asdfasdfasdf # password: test\n" +
"purple: password\n" +
"password:FILTERED\n" +
"password:FILTERED\n" +
"password:FILTERED\n" +
"password%3AFILTERED\n" +
"password%3AFILTERED\n" +
"Header: Authorization=Basic FILTERED\n" +
"delete: adsf\n"));
}


@Test
public void testFilterOverridePasswordsInMessage() {
final String input = "" +
Expand Down
Loading