Add localwebroot configuration option.

This commit is contained in:
Bastian Kleineidam 2012-06-10 14:47:27 +02:00
parent d323971c5f
commit 00aa631267
9 changed files with 486 additions and 390 deletions

View file

@ -159,6 +159,15 @@
# The memory dump only works if the python-meliae package is installed.
# Otherwise a warning is printed to install it.
#debugmemory=0
# When checking absolute URLs inside local files, the given root directory
# is used as base URL.
# Note that the given directory must have URL syntax, so it must use a slash
# to join directories instead of a backslash.
# And the given directory must end with a slash.
# Unix example:
#localwebroot=/var/www/
# Windows example:
#localwebroot=/C|/public_html/
##################### filtering options ##########################

View file

@ -10,6 +10,9 @@ Changes:
directives of the form "<? ?>".
Prevents false errors when checking local PHP files.
Closes: SF bug #3532763
- checking: Allow configuration of local webroot directory to
enable checking of local HTML files with absolute URLs.
Closes: SF bug #3533203
Features:
- installation: Support RPM building with cx_Freeze.

423
doc/de.po

File diff suppressed because it is too large Load diff

View file

@ -120,6 +120,17 @@ ist. Andernfalls wird eine Warnung angezeigt mit dem Hinweis dieses Paket zu
installieren.
.br
Kommandozeilenoption: keine
.TP
\fBlocalwebroot=\fP\fISTRING\fP
Beim Prüfen von absoluten URLs in lokalen Dateien wird das angegebene
Wurzelverzeichnis als Basis\-URL benutzt.
.br
Beachten Sie dass das angegebene Verzeichnis in URL\-Syntax sein muss,
d.h. es muss einen normalen statt einen umgekehrten Schrägstrich zum
Aneinanderfügen von Verzeichnissen benutzen. Und das angegebene Verzeichnis
muss mit einem Schrägstrich enden.
.br
Kommandozeilenoption: keine
.SS [filtering]
.TP
\fBignore=\fP\fIREGEX\fP (MULTILINE)

View file

@ -113,6 +113,16 @@ The memory dump only works if the python-meliae package is installed.
Otherwise a warning is printed to install it.
.br
Command line option: none
.TP
\fBlocalwebroot=\fP\fISTRING\fP
When checking absolute URLs inside local files, the given root directory
is used as base URL.
.br
Note that the given directory must have URL syntax, so it must use a slash
to join directories instead of a backslash.
And the given directory must end with a slash.
.br
Command line option: none
.SS \fB[filtering]\fP
.TP
\fBignore=\fP\fIREGEX\fP (MULTILINE)

File diff suppressed because it is too large Load diff

View file

@ -298,3 +298,13 @@ class FileUrl (urlbase.UrlBase):
# remove last filename to make directory internal
url = url[:i+1]
return re.escape(url)
def add_url (self, url, line=0, column=0, name=u"", base=None):
"""If a local webroot directory is configured, replace absolute URLs
with it. After that queue the URL data for checking."""
webroot = self.aggregate.config["localwebroot"]
if webroot and url and url.startswith(u"/"):
url = webroot + url[1:]
log.debug(LOG_CHECK, "Applied local webroot `%s' to `%s'.",
webroot, url)
super(FileUrl, self).add_url(url, line=line, column=column, name=name, base=base)

View file

@ -193,6 +193,7 @@ class Configuration (dict):
self["clamavconf"] = clamav.canonical_clamav_conf()
self["useragent"] = UserAgent
self["debugmemory"] = False
self["localwebroot"] = None
from ..logger import Loggers
self.loggers = dict(**Loggers)

View file

@ -153,6 +153,8 @@ class LCConfigParser (ConfigParser.RawConfigParser, object):
self.getboolean(section, "cookies")
if self.has_option(section, "cookiefile"):
self.config['cookiefile'] = self.get(section, 'cookiefile')
if self.has_option(section, "localwebroot"):
self.config['localwebroot'] = self.get(section, 'localwebroot')
def read_authentication_config (self):
"""Read configuration options in section "authentication"."""