Skip to content

Commit

Permalink
Fix docker image and avoid implicit setuptools runtime dependency (#683)
Browse files Browse the repository at this point in the history
* Avoid implicit dependency on setuptools

* Install pip into the virtual environment
  • Loading branch information
P4sca1 authored Oct 7, 2024
1 parent d34805f commit f630a5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ ARG no_proxy

ADD . /logprep
WORKDIR /logprep

# Install the Rust toolchain
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN python -m venv --without-pip /opt/venv
# Make sure we use the virtualenv:

# Use a python virtual environment
RUN python -m venv --upgrade-deps /opt/venv
ENV PATH="/opt/venv/bin:$PATH"


RUN if [ "$LOGPREP_VERSION" = "dev" ]; then pip install .;\
elif [ "$LOGPREP_VERSION" = "latest" ]; then pip install git+https://github.com/fkie-cad/Logprep.git@latest; \
else pip install "logprep==$LOGPREP_VERSION"; fi; \
logprep --version
/opt/venv/bin/logprep --version

# geoip2 4.8.0 lists a vulnerable setuptools version as a dependency. setuptools is unneeded at runtime, so it is uninstalled.
# More recent (currently unreleased) versions of geoip2 removed setuptools from dependencies.
Expand Down
4 changes: 2 additions & 2 deletions logprep/util/grok/grok.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from re import error

import numpy as np
import pkg_resources
from importlib import resources
from attrs import define, field, validators

from logprep.util.decorators import timeout
Expand All @@ -42,8 +42,8 @@
# added to re module in python 3.11
import regex as re # pylint: disable=shadowed-import

DEFAULT_PATTERNS_DIRS = [pkg_resources.resource_filename(__name__, "patterns/ecs-v1")]

DEFAULT_PATTERNS_DIRS = [str(resources.files(__package__) / "patterns/ecs-v1")]
LOGSTASH_NOTATION = r"(([^\[\]\{\}\.:]*)?(\[[^\[\]\{\}\.:]*\])*)"
GROK = r"%\{" + rf"([A-Z0-9_]*)(:({LOGSTASH_NOTATION}))?(:(int|float))?" + r"\}"
ONIGURUMA = r"\(\?<([^()]*)>\(?(([^()]*|\(([^()]*|\([^()]*\))*\))*)\)?\)"
Expand Down

0 comments on commit f630a5e

Please sign in to comment.