fox-it/log4j-finder

Possibility to exclude directories

mhenninghaus77 opened this issue · 9 comments

Hi, is there a possibility to exclude certain directories from the search? Is it possible to start the tool via an exclude directive?

regards

Michael

I had the same needs and created a fork https://github.com/mjsalmi/log4j-finder

Could you check and verify if this meets your needs as well and I'll create a PR here if it does.

Hi mjsalmi, It would be nice to just have one --exclude=PATTERN parameter that would work for both directories and files. So just path in general. eg:

log4j-finder.py --exclude "/proc/*" --exclude "/dev/*" --exclude "/home/user/*.war"

Would that also cover the needs?

The matching with globbing wildcards could be done using the fnmatch module: https://docs.python.org/3/library/fnmatch.html

Hi yunzheng, This is definitely a good idea. I wasn't aware of fnmatch before and will look into it.

Switched the exclusion to use single argument and fnmatchmatching. I think it makes more sense now... Any more suggestions and/or ideas before I create a PR for this change?

@mjsalmi looks good to me!

Looks good but if I compile @mjsalmi's version (as described by documenation) I can not execute it on RHEL/CentOS 7 machines (without Python 3):

[42687] Error loading Python lib '/tmp/_MEIpgx09N/libpython3.6m.so.1.0': dlopen: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /tmp/_MEIpgx09N/libpython3.6m.so.1.0)

The latest executable provided by fox-it does work on these machines but can not exclude directories.

@yunzheng : can you provide us with a compiled version?

@trumbaut Linux and Windows executables are automatically built on every commit, but I will need to make an official release soon.

You could test with a recent build (non official release) that is build via GitHub Actions, grab it from here for example:
https://github.com/fox-it/log4j-finder/actions/runs/1591867705 (or any other commit)