in reply to Perl readable Weblogs
Cool idea. Very dangerous though. Your choice of delimiter is not safe (and I don't think there is a safe one). Apache passes anything you type on the URL through. So sending the URL:
http://www.victim.com/trick'); system('rm -rf /etc/passwd'); ('
Would become:
(bytes=>'0',...,url=>'trick'); system('rm -rf /etc/passwd'); ('', ...)
Which I don't want someone to be able to run on my server.
From my brief reading of the BNF for valid URLs there are some invalid characters in URLs, such as ~, but Apache still writes out whatever it was given to the access log.
Also I doubt it is faster to eval each line of the log rather than making the log format something that can be split. I bet a regular expression match is faster than the eval, and it is certainly safer.
If you do decide to go with the split idea the following might work. Again you have to choose a good delimiter, but tacking the URL on the end means you can ignore it when choosing the delimiter by providing the number of fields to split. (Although I am not sure what request can contain so my choice of | as a delimiter may be invalid).
LogFormat "%b|%f|%h|%a|%l|%p|%P|%r|%s|%t|%T|%u|%v|%U log_perl
Then to read:
while (<LOGFILE>) { my %hash; %hash{bytes, filename, remotehost, remoteip, remoteuser, serverport, pid, request, status, time, timeserve, authuser, virtual, url) = split /\|/, $_, 13; # Use hash
-ben
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl readable Weblogs
by tadman (Prior) on Apr 19, 2001 at 01:22 UTC | |
|
Re: Re: Perl readable Weblogs
by mr.nick (Chaplain) on Apr 19, 2001 at 21:24 UTC | |
by knobunc (Pilgrim) on Apr 20, 2001 at 00:18 UTC |