Compare commits

...

2 Commits

Author SHA1 Message Date
Christian P. MOMON 192001bbd4 Fixed anonymize map call. 2021-04-26 01:59:31 +02:00
Christian P. MOMON d047d174c2 Fixed anonymize access log check. 2021-04-26 01:31:39 +02:00
1 changed files with 10 additions and 10 deletions

View File

@ -47,8 +47,8 @@ public final class Anonymizer
{ {
private static Logger logger = LoggerFactory.getLogger(Anonymizer.class); private static Logger logger = LoggerFactory.getLogger(Anonymizer.class);
public static final Pattern IPV4_PATTERN = Pattern.compile("\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}"); public static final Pattern IPV4_PATTERN = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
public static final Pattern IPV6_PATTERN = Pattern.compile("([0-9a-f]{1,4}:{1,2}){4,7}([0-9a-f]){1,4}", Pattern.CASE_INSENSITIVE); public static final Pattern IPV6_PATTERN = Pattern.compile("([0-9a-f]){1,4}(:{1,2}[0-9a-f]{0,4}){4,7}", Pattern.CASE_INSENSITIVE);
private AnonMap map; private AnonMap map;
@ -118,6 +118,12 @@ public final class Anonymizer
// logger.info("anon=[{}][{}][{}]", anon.getIp(), // logger.info("anon=[{}][{}][{}]", anon.getIp(),
// anon.getUser(), anon.getDatetime()); // anon.getUser(), anon.getDatetime());
// logger.info("anon={}", anon); // logger.info("anon={}", anon);
// Make a check.
if (StringUtils.equals(line, anon.getLine()))
{
System.err.println("Anonymize failed detected: " + line);
}
} }
else else
{ {
@ -126,12 +132,6 @@ public final class Anonymizer
anon = anonymizeError(log); anon = anonymizeError(log);
} }
// Make a check.
if (StringUtils.equals(line, anon.getLine()))
{
System.err.println("Anonymize failed detected: " + line);
}
out.println(anon); out.println(anon);
} }
catch (IllegalArgumentException exception) catch (IllegalArgumentException exception)
@ -206,7 +206,7 @@ public final class Anonymizer
String ipv4 = matcher.group(); String ipv4 = matcher.group();
String right = anonLine.substring(matcher.end()); String right = anonLine.substring(matcher.end());
String anonIpv4 = this.map.get(ipv4); String anonIpv4 = this.map.anonymizeIp(ipv4);
anonLine = left + anonIpv4 + right; anonLine = left + anonIpv4 + right;
} }
@ -218,7 +218,7 @@ public final class Anonymizer
String ipv6 = matcher.group(); String ipv6 = matcher.group();
String right = anonLine.substring(matcher.end()); String right = anonLine.substring(matcher.end());
String anonIpv6 = this.map.get(ipv6); String anonIpv6 = this.map.anonymizeIp(ipv6);
anonLine = left + anonIpv6 + right; anonLine = left + anonIpv6 + right;
} }