Skip to content

Commit

Permalink
Setup worker to run python version of searchSync and fix search endpo…
Browse files Browse the repository at this point in the history
…ints
  • Loading branch information
aloftus23 committed Dec 11, 2024
1 parent dbf4ae8 commit 420f0a9
Show file tree
Hide file tree
Showing 23 changed files with 739 additions and 349 deletions.
98 changes: 24 additions & 74 deletions backend/Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -1,84 +1,34 @@
FROM node:18-alpine3.17 as build
USER root

RUN apk update && apk upgrade

WORKDIR /app

COPY ./package* ./

RUN npm install -g npm@9

RUN npm ci

COPY tsconfig.json ./tsconfig.json
COPY webpack.worker.config.js ./webpack.worker.config.js
COPY mock.js ./mock.js
COPY src ./src

RUN npx webpack --config webpack.worker.config.js

FROM golang:1.19-alpine as deps

RUN apk update && apk upgrade
# Base image for Python environment
FROM python:3.10-bullseye

WORKDIR /app

RUN apk add --no-cache curl unzip musl-dev

RUN curl -4LO http://github.com/Findomain/Findomain/releases/latest/download/findomain-linux.zip
RUN unzip findomain-linux.zip && chmod +x findomain && cp findomain /usr/bin/findomain

RUN go mod init crossfeed-worker

RUN go install github.com/facebookincubator/nvdtools/...@latest
RUN go install -v github.com/owasp-amass/amass/v3/...@master

FROM ruby:alpine as rubyBuild
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
unzip \
build-essential \
netcat \
--no-install-recommends && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN apk add --update --no-cache build-base git ruby ruby-dev openssl-dev
# Install Python dependencies from worker and application
COPY worker/requirements.txt /app/worker/requirements.txt
COPY requirements.txt /app/requirements.txt

RUN gem install bundler:2.3.21
RUN export RUBY_VERSION=$(ruby -e "print RUBY_VERSION") && git clone https://github.com/intrigueio/intrigue-ident.git && cd intrigue-ident && git checkout ee119abeac20564e728a92ab786400126e7a97f0 && sed -i "s/2.7.2/$RUBY_VERSION/g" Gemfile && sed -i "s/2.7.2p114/$RUBY_VERSION/g" Gemfile.lock && bundle install --jobs=4
RUN echo 'cd /app/intrigue-ident && bundle exec ruby ./util/ident.rb $@' > /usr/bin/intrigue-ident && chmod +x /usr/bin/intrigue-ident

FROM node:18-bullseye

#RUN apt update && apt upgrade -y && apt install zip -y
RUN apt update && apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev zip git -y
WORKDIR /app

RUN npm install -g pm2@5 wait-port@1
RUN wget -c https://www.python.org/ftp/python/3.10.11/Python-3.10.11.tar.xz && tar -Jxvf Python-3.10.11.tar.xz

RUN cd Python-3.10.11 && ./configure && make -j4 && make altinstall
RUN update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1
RUN update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.10 1
RUN pip3.10 install --upgrade pip

RUN apt remove dav1d && apt autoclean && apt autoremove

# Python dependencies

COPY worker/requirements.txt worker/requirements.txt

RUN pip install -r worker/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
RUN pip install --no-cache-dir -r /app/worker/requirements.txt

# Copy worker scripts and Django project
COPY worker worker
COPY src/xfd_django .

RUN wget https://publicsuffix.org/list/public_suffix_list.dat --no-use-server-timestamps

COPY --from=build /app/dist/worker.bundle.js worker.bundle.js

COPY --from=deps /usr/bin/findomain /usr/bin/
COPY --from=deps /go/bin/amass /usr/bin/
COPY --from=deps /go/bin/csv2cpe /go/bin/nvdsync /go/bin/cpe2cve /usr/bin/

COPY --from=deps /etc/ssl/certs /etc/ssl/certs

COPY --from=rubyBuild /usr/bin/intrigue-ident /usr/bin/
# Set environment variables
ENV DJANGO_SETTINGS_MODULE=xfd_django.settings
ENV PYTHONPATH="/app:$PYTHONPATH"

ENV GLOBAL_AGENT_HTTP_PROXY=http://localhost:8080
ENV GLOBAL_AGENT_NO_PROXY=censys.io
# Make the entry script executable
RUN chmod +x worker/worker-entry.sh

CMD ["./worker/worker-entry.sh"]
# Default entrypoint
CMD ["worker/worker-entry.sh"]
6 changes: 3 additions & 3 deletions backend/src/xfd_django/xfd_api/api_methods/api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def post(current_user):
id=uuid.uuid4(),
hashedKey=hashed_key,
lastFour=key[-4:],
userId=current_user,
user=current_user,
createdAt=datetime.utcnow(),
updatedAt=datetime.utcnow(),
)

# Convert the Django model instance to the Pydantic model, excluding fields like hashedKey and userId
# Convert the Django model instance to the Pydantic model, excluding fields like hashedKey and user
validated_data = ApiKeySchema.model_validate(api_key_instance).model_dump(
exclude={"hashedKey", "userId"}
exclude={"hashedKey", "user"}
)

# Add the actual API key to the response for initial display to the user
Expand Down
2 changes: 1 addition & 1 deletion backend/src/xfd_django/xfd_api/api_methods/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ async def invoke_scheduler(current_user):
print(lambda_function_name)

# Run the Lambda command
response = await lambda_client.run_command(name=lambda_function_name)
response = lambda_client.run_command(name=lambda_function_name)

return response

Expand Down
Loading

0 comments on commit 420f0a9

Please sign in to comment.