diff --git a/.env.wtfis.example b/.env.wtfis.example index 9b22a66..1f0119c 100644 --- a/.env.wtfis.example +++ b/.env.wtfis.example @@ -1,8 +1,8 @@ # Example ~/.env.wtfis file # Don't forget to chmod 400! -VT_API_KEY = foo -PT_API_KEY = bar -PT_API_USER = baz@example.com -IP2WHOIS_API_KEY = alice -SHODAN_API_KEY = hunter2 -# WTFIS_DEFAULTS = "-s -1 -n" +VT_API_KEY=foo +PT_API_KEY=bar +PT_API_USER=baz@example.com +IP2WHOIS_API_KEY=alice +SHODAN_API_KEY=hunter2 +# WTFIS_DEFAULTS=-s -1 -n diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df1ff46 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +#################################### +# Builder image +#################################### + +FROM python:3.10-slim as builder + +WORKDIR /workspace +COPY . . + +# Install git +RUN apt-get update && \ + apt-get install -y --no-install-recommends git + +# Checkout latest tagged commit +RUN git checkout \ + tags/$(git describe --tags $(git rev-list --tags --max-count=1)) \ + -b latest_tag + +# Ensure latest pip +RUN python -m pip install --upgrade pip + +# Install hatch +RUN pip install hatch + +# Clean build wheel and src tarball +RUN hatch build --clean + + +#################################### +# Final image +#################################### + +FROM python:3.10-slim + +# Create user and cd to work dir +RUN useradd --create-home --shell /bin/bash wtfis +WORKDIR /home/wtfis + +# Copy wheel file from builder image +COPY --from=builder /workspace/dist/*.whl . + +# Upgrade pip, install wheel and delete wheel file +RUN python -m pip install --upgrade pip && \ + pip install *.whl && \ + rm -f *.whl + +# Run as user +USER wtfis + +# Command +CMD ["bash"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..68ed96d --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +PROJECT_NAME := wtfis +WTFIS_ENV_FILE := ${HOME}/.env.wtfis + +# Build Docker image of the latest tagged commit +.PHONY: docker-image +docker-image: + docker build -t $(PROJECT_NAME) --rm . + +# Run and exec into the Docker image +.PHONY: docker-run +docker-run: + docker run --env-file=$(WTFIS_ENV_FILE) -it wtfis diff --git a/README.md b/README.md index 380fae2..d97910d 100644 --- a/README.md +++ b/README.md @@ -150,13 +150,13 @@ Panels can be displayed with no color with `-n` or `--no-color`. Default arguments can be defined by setting the `WTFIS_DEFAULTS` environment variable. For example, to use shodan and display results in one column by default: ``` -WTFIS_DEFAULTS="-s -1" +WTFIS_DEFAULTS=-s -1 ``` If an argument is in `WTFIS_DEFAULTS`, then specifying the same argument during command invocation **negates** that argument. So in the example above, if you then run: ``` -wtfis example.com -s +$ wtfis example.com -s ``` then Shodan will NOT be used. @@ -164,6 +164,38 @@ then Shodan will NOT be used. Note that maximum resolutions (`-m N, --max-resolutions N`) cannot be defined in defaults at the moment. +## Docker + +wtfis can be run from a Docker image. First, build the image (using the included [Dockerfile](./Dockerfile)) by running: + +``` +$ make docker-image +``` + +The image will have the latest _tagged_ version (not necessarily from the latest commit) wtfis. This ensures that you are getting a stable release. + +Two ways you can run the image: + +Ensure `.env.wtfis` is in your home directory and set with the necessary envvars. Then simply run: + +``` +$ make docker-run +``` + +This is an alias to + +``` +$ docker run --env-file=${HOME}/.env.wtfis -it wtfis +``` + +Note that each definition must NOT have any spaces before and after the equal sign (`FOO=bar`, not `FOO = bar`). + +Altenatively, you can set the environment variables yourself, then run, e.g.: + +``` +$ docker run -e VT_API_KEY -e SHODAN_API_KEY -it wtfis +``` + ## TODOs * Consider adding Greynoise enrichment (RIOT, etc.)