Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ApachePlugin log file discovery #980

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JSCU-CNI
Copy link
Contributor

@JSCU-CNI JSCU-CNI commented Jan 8, 2025

This PR improves the log file discovery of the ApachePlugin on targets.

  • We now parse Include and IncludeOptional directives in all apache .conf files (mods, sites and confs) and extract ErrorLog and CustomLog from those configuration files.
  • We now substitute Apache envvars from those log file location directives (e.g. ${APACHE_LOG_DIR}).


directive = match.groupdict()

if "*" in directive["location"]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do not use glob directly?

As python glob rely on fnmatch and apache documentation explicitly mark the location as being fnmatch style (https://httpd.apache.org/docs/2.4/en/mod/core.html#include)

Shell-style (fnmatch()) wildcard characters can be used in the filename`

match = pattern_to_use.match(line)
if not match:
self.target.log.warning("Unexpected Apache log configuration: %s (%s)", line, path)
def _process_conf_file(self, path: Path) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's would be better to add either a max_recurse integer or to create a set of already processed file in order to prevent infinite recursion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants