Skip to content

Commit

Permalink
Fix log anonymizer
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherp committed Nov 13, 2024
1 parent 9719d17 commit 6234535
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/nzbhydra/logging/LogAnonymizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String getAnonymizedLog(String log) {

private String removeIpsFromLog(String log) {
logger.debug("Removing IPs and hostnames from log");
log = log.replaceAll("Host: .*\\..*\\]", "Host: <hidden>]");
log = log.replaceAll("Host: [^\\]]*", "Host: <hidden>");
log = log.replace("127.0.0.1", "<localhost>");
log = replaceWithHashedValues(log, IPV4_PATTERN, "IP4");
// log = replaceWithHashedValues(log, IPV6_PATTERN, "IP6");
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/resources/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
- type: "fix"
text: "Do not use IMDB IDs for indexers that don't support them. This would happen when using the TV search function in the ID and selecting a result from the autocomplete."
- type: "fix"
text: "When images were proxied the second time autocomplete images they could not be loaded a second time"
text: "When images were proxied the second time autocomplete images they could not be loaded a second time."
- type: "fix"
text: "The log anonymizer used when you create debug infos removed too much, sometimes resulting in missing information."
final: true
- version: "v7.10.0"
date: "2024-11-12"
Expand Down
10 changes: 10 additions & 0 deletions core/src/test/java/org/nzbhydra/logging/LogAnonymizerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ void shouldAnonymizeCookiesFromConfig() throws Exception {
assertThat(anonymized).isEqualTo("Cookies: Parsing b[]: remember-me=0:<HIDDEN> Auth-Type=http; Auth-Token=b:<HIDDEN> HYDRA-XSRF-TOKEN=2:<HIDDEN>");
}

@Test
void shouldNotCropLine() throws Exception {
String anonymized = testee.getAnonymizedLog("2024-11-13 08:13:43.656 INFO --- [http-nio-0.0.0.0-5] org.nzbhydra.searching.SearchWeb : [ID: 35674, Host: hello-1.hello.com] New search request: SearchRequest{source=INTERNAL, indexers=[NZBGeek], searchType=SEARCH, category=All, offset=0, limit=100, query=high potential, identifiers={}}");

anonymized = anonymized.replaceAll("IP4:[a-z0-9]*>-5", "IP4:abc>-5");

assertThat(anonymized).isEqualTo("2024-11-13 08:13:43.656 INFO --- [http-nio-<IP4:abc>-5] org.nzbhydra.searching.SearchWeb : [ID: 35674, Host: <hidden>] New search request: SearchRequest{source=INTERNAL, indexers=[NZBGeek], searchType=SEARCH, category=All, offset=0, limit=100, query=high potential, identifiers={}}");
}




}

0 comments on commit 6234535

Please sign in to comment.