forked from cisagov/Malcolm
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'cisa/main'
- Loading branch information
Showing
57 changed files
with
12,144 additions
and
8,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: api-build-and-push-ghcr | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- development | ||
paths: | ||
- 'api/**' | ||
- 'Dockerfiles/api.Dockerfile' | ||
- 'shared/bin/*' | ||
- '.trigger_workflow_build' | ||
workflow_dispatch: | ||
repository_dispatch: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write | ||
packages: write | ||
contents: read | ||
steps: | ||
- | ||
name: Cancel previous run in progress | ||
uses: styfle/[email protected] | ||
with: | ||
ignore_sha: true | ||
all_but_latest: true | ||
access_token: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Extract branch name | ||
shell: bash | ||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | ||
id: extract_branch | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Log in to registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfiles/api.Dockerfile | ||
push: true | ||
tags: ghcr.io/${{ github.repository_owner }}/malcolmnetsec/api:${{ steps.extract_branch.outputs.branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# this file exists solely for the purpose of being updated and seen by github to trigger a commit build action | ||
7 | ||
8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
FROM python:3-slim-bullseye as builder | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV TERM xterm | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
RUN apt-get update -q \ | ||
&& apt-get install -y --no-install-recommends gcc \ | ||
&& python3 -m pip install --upgrade pip \ | ||
&& python3 -m pip install flake8 | ||
|
||
COPY ./api /usr/src/app/ | ||
WORKDIR /usr/src/app | ||
|
||
RUN python3 -m pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt \ | ||
&& flake8 --ignore=E501,F401 | ||
|
||
FROM python:3-slim-bullseye | ||
|
||
# Copyright (c) 2022 Battelle Energy Alliance, LLC. All rights reserved. | ||
LABEL maintainer="[email protected]" | ||
LABEL org.opencontainers.image.authors='[email protected]' | ||
LABEL org.opencontainers.image.url='https://github.com/idaholab/Malcolm' | ||
LABEL org.opencontainers.image.documentation='https://github.com/idaholab/Malcolm/blob/main/README.md' | ||
LABEL org.opencontainers.image.source='https://github.com/idaholab/Malcolm' | ||
LABEL org.opencontainers.image.vendor='Idaho National Laboratory' | ||
LABEL org.opencontainers.image.title='malcolmnetsec/api' | ||
LABEL org.opencontainers.image.description='Malcolm container providing a REST API for some information about network traffic' | ||
|
||
ARG DEFAULT_UID=1000 | ||
ARG DEFAULT_GID=1000 | ||
ENV DEFAULT_UID $DEFAULT_UID | ||
ENV DEFAULT_GID $DEFAULT_GID | ||
ENV PUSER "yeflask" | ||
ENV PGROUP "yeflask" | ||
ENV PUSER_PRIV_DROP true | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV TERM xterm | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
ARG FLASK_ENV=production | ||
ARG OPENSEARCH_URL="http://opensearch:9200" | ||
ARG ARKIME_INDEX_PATTERN="arkime_sessions3-*" | ||
ARG ARKIME_INDEX_TIME_FIELD="firstPacket" | ||
ARG RESULT_SET_LIMIT="500" | ||
|
||
ENV HOME=/malcolm | ||
ENV APP_HOME="${HOME}"/api | ||
ENV APP_FOLDER="${APP_HOME}" | ||
ENV FLASK_APP=project/__init__.py | ||
ENV FLASK_ENV $FLASK_ENV | ||
ENV OPENSEARCH_URL $OPENSEARCH_URL | ||
ENV ARKIME_INDEX_PATTERN $ARKIME_INDEX_PATTERN | ||
ENV ARKIME_INDEX_TIME_FIELD $ARKIME_INDEX_TIME_FIELD | ||
ENV RESULT_SET_LIMIT $RESULT_SET_LIMIT | ||
|
||
WORKDIR "${APP_HOME}" | ||
|
||
COPY --from=builder /usr/src/app/wheels /wheels | ||
COPY --from=builder /usr/src/app/requirements.txt . | ||
COPY ./api "${APP_HOME}" | ||
COPY shared/bin/opensearch_status.sh "${APP_HOME}"/ | ||
|
||
ADD shared/bin/docker-uid-gid-setup.sh /usr/local/bin/ | ||
RUN apt-get -q update \ | ||
&& apt-get -y -q --no-install-recommends install curl netcat \ | ||
&& python3 -m pip install --upgrade pip \ | ||
&& python3 -m pip install --no-cache /wheels/* \ | ||
&& chmod 755 /usr/local/bin/docker-uid-gid-setup.sh \ | ||
&& groupadd --gid ${DEFAULT_GID} ${PGROUP} \ | ||
&& useradd -M --uid ${DEFAULT_UID} --gid ${DEFAULT_GID} --home "${HOME}" ${PUSER} \ | ||
&& chown -R ${PUSER}:${PGROUP} "${HOME}" \ | ||
&& usermod -a -G tty ${PUSER} \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
EXPOSE 5000 | ||
|
||
ENTRYPOINT ["/usr/local/bin/docker-uid-gid-setup.sh", "${APP_HOME}/entrypoint.sh"] | ||
|
||
# to be populated at build-time: | ||
ARG BUILD_DATE | ||
ARG MALCOLM_VERSION | ||
ARG VCS_REVISION | ||
|
||
ENV BUILD_DATE $BUILD_DATE | ||
ENV MALCOLM_VERSION $MALCOLM_VERSION | ||
ENV VCS_REVISION $VCS_REVISION | ||
|
||
LABEL org.opencontainers.image.created=$BUILD_DATE | ||
LABEL org.opencontainers.image.version=$MALCOLM_VERSION | ||
LABEL org.opencontainers.image.revision=$VCS_REVISION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM opensearchproject/opensearch:1.2.2 | ||
FROM opensearchproject/opensearch:1.2.3 | ||
|
||
# Copyright (c) 2022 Battelle Energy Alliance, LLC. All rights reserved. | ||
LABEL maintainer="[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
echo "Giving OpenSearch time to start..." | ||
"${APP_HOME}"/opensearch_status.sh 2>&1 && echo "OpenSearch is running!" | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from flask.cli import FlaskGroup | ||
|
||
from project import app | ||
|
||
cli = FlaskGroup(app) | ||
|
||
if __name__ == "__main__": | ||
cli() |
Oops, something went wrong.