darold / squidanalyzer

Squid Analyzer parses Squid proxy access log and reports general statistics about hits, bytes, users, networks, top URLs, and top second level domains. Statistic reports are oriented toward user and bandwidth control.
http://squidanalyzer.darold.net/
125 stars 36 forks source link

Error parsing squidguard logs #196

Closed silvaguilherme closed 5 years ago

silvaguilherme commented 5 years ago

I am having errors when logging squidguard logs. TOP Denied is always with REDIRECT. I tried the issue # 164 solution, but then make the change, I get this error when I try to generate the report. squidanalyzer

darold commented 5 years ago

I can not reproduce this issue. Please use latest development code and report the error reported. If you can post a sample log file it will help too.

szaszg commented 5 years ago

I have a similar problem with the current git code. Some times ago the code changed, e.g. in the 'check_exlusions()' sub: from: foreach my $e (@{$self->{Exclude}{uris}}) { if ($url =~ m#^$e$#i) { return 1;} to: return 1 if (grep(/^$url$/i, @{ $self->{UrlExcludeCache} }));

With the 'new' code, if the logged url contains some regex special character, the grep may fail like above: I have a malformed url in access.log: 1551045792.016 201 10.1.60.11 TCP_MISS/301 447 GET http://toprumbudapest.com/wp-content/themes/to prum/img/logo.svg') - HIER_DIRECT/67.207.72.37 text/html

Please note the ') at the end of the url.

So, the new code just fail with: Unmatched ) in regex; marked by <-- HERE in m/^http://toprumbudapest.com/wp-content/themes/toprum/img/logo.svg') <-- HERE $/ at /usr/local/share/perl/5.20.2/SquidAnalyzer.pm line 1098, line 142976.

darold commented 5 years ago

Hi,

Thanks for the detailed report. Commit 842ade0 might solve this issue, give a try to latest development code and let me know if there is any other issues.

Regards,