Parsers for usage of VirtualDirContext option in Tomcat config files

This module provides the following parsers:

TomcatVirtualDirContextFallback

This is a parser for a command for finding config files in default location:

/usr/bin/find /usr/share -maxdepth 1 -name 'tomcat*' -exec grep -R -s 'VirtualDirContext' --include '*.xml' '{}' +

It is especially useful if the Tomcat server is not running.

TomcatVirtualDirContextTargeted

This is a parser for a command for finding config files in the custom location defined in a command line:

/bin/grep -R -s 'VirtualDirContext' --include '*.xml' {catalina}

Where catalina variable is computed as following:

/bin/ps auxww | awk '/java/ { match($0, "\-Dcatalina\.home=([^[:space:]]+)", a); match($0, "\-Dcatalina\.base=([^[:space:]]+)", b); if (a[1] != "" || b[1] != "") print a[1] " " b[1] }'

Both parsers detect whether there are any config files which contain VirtualDirContext.

Sample input:

/usr/share/tomcat/conf/server.xml:    <Resources className="org.apache.naming.resources.VirtualDirContext"

Examples:

>>> shared[TomcatVirtualDirContextFallback].data
{'/usr/share/tomcat/conf/server.xml':
 ['    <Resources className="org.apache.naming.resources.VirtualDirContext"'],
 }
class insights.parsers.tomcat_virtual_dir_context.TomcatVirtualDirContextBase(*args, **kwargs)[source]

Bases: CommandParser

Generic parser which finds whether there is a VirtualDirContext option used in TomCat configuration file.

parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.tomcat_virtual_dir_context.TomcatVirtualDirContextFallback(*args, **kwargs)[source]

Bases: TomcatVirtualDirContextBase

Reports whether there is a VirtualDirContext option used in TomCat configuration file. Looks for the configuration files in default location.

class insights.parsers.tomcat_virtual_dir_context.TomcatVirtualDirContextTargeted(*args, **kwargs)[source]

Bases: TomcatVirtualDirContextBase

Reports whether there is a VirtualDirContext option used in TomCat configuration file. Looks for the configuration files in location derived from running Tomcat command.