-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
371 additions
and
37 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
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,22 +1,46 @@ | ||
name: integration-tests | ||
on: | ||
workflow_call: | ||
secrets: | ||
DOCKER_TOKEN: | ||
required: true | ||
jobs: | ||
integration-tests: | ||
name: Run integration tests | ||
test-alert-endpoints: | ||
name: Test alert endpoints | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
python-version: 3.12 | ||
- name: Install dependencies | ||
run: pip install --no-cache-dir -U pip .['test'] | ||
- name: Docker login | ||
run: docker login -u kamforka -p ${{ secrets.DOCKER_TOKEN }} | ||
- name: Run integration tests | ||
run: scripts/ci.py --test | ||
run: pytest -v tests/test_alert_endpoint.py | ||
|
||
test-case-endpoints: | ||
name: Test case endpoints | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
- name: Install dependencies | ||
run: pip install --no-cache-dir -U pip .['test'] | ||
- name: Run integration tests | ||
run: pytest -v tests/test_case_endpoint.py | ||
|
||
test-other-endpoints: | ||
name: Test other endpoints | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
- name: Install dependencies | ||
run: pip install --no-cache-dir -U pip .['test'] | ||
- name: Run integration tests | ||
run: | | ||
pytest -v --ignore=tests/test_alert_endpoint.py --ignore=tests/test_case_endpoint.py |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: integrator-image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
changes: | ||
name: Change detection | ||
runs-on: ubuntu-latest | ||
outputs: | ||
integrator: ${{ steps.filter.outputs.integrator }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
integrator: | ||
- 'docker/thehive4py-integrator/**' | ||
build: | ||
name: Build and push | ||
needs: changes | ||
if: ${{ needs.changes.outputs.integrator == 'true' }} | ||
runs-on: ubuntu-latest | ||
env: | ||
INTEGRATOR_BUILD_CTX: docker/thehive4py-integrator | ||
INTEGRATOR_IMAGE_NAME: kamforka/thehive4py-integrator | ||
THEHIVE_VERSION: 5.3.0 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set variables | ||
id: variables | ||
run: | | ||
echo "integrator_image_fullname=$INTEGRATOR_IMAGE_NAME:thehive-$THEHIVE_VERSION" >> "$GITHUB_OUTPUT" | ||
echo "integrator_image_fullname_with_hash=$INTEGRATOR_IMAGE_NAME:thehive-$THEHIVE_VERSION-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: kamforka | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ env.INTEGRATOR_BUILD_CTX }} | ||
platforms: linux/amd64,linux/arm64 | ||
# push: ${{ github.ref == 'refs/heads/main' }} | ||
push: true | ||
tags: ${{ steps.variables.outputs.integrator_image_fullname }},${{ steps.variables.outputs.integrator_image_fullname_with_hash}} | ||
build-args: | | ||
THEHIVE_VERSION=${{ env.THEHIVE_VERSION }} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
FROM alpine:3.17 as base | ||
|
||
# BUILDER STAGE | ||
FROM base as builder | ||
|
||
ARG ES_VERSION=7.17.19 | ||
ARG THEHIVE_VERSION=5.3.0 | ||
|
||
RUN apk update && apk upgrade && apk add curl | ||
|
||
## ES DOWNLOAD | ||
ARG ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz | ||
|
||
RUN curl -Lo /tmp/elasticsearch.tgz ${ES_DOWNLOAD_URL} \ | ||
&& tar -xzf /tmp/elasticsearch.tgz -C /tmp \ | ||
&& mv /tmp/elasticsearch-${ES_VERSION} /tmp/elasticsearch | ||
|
||
## THEHIVE DOWNLOAD | ||
ARG THEHIVE_DOWNLOAD_URL=https://archives.strangebee.com/zip/thehive-${THEHIVE_VERSION}-1.zip | ||
|
||
RUN curl -Lo /tmp/thehive.zip ${THEHIVE_DOWNLOAD_URL} | ||
RUN unzip -qo /tmp/thehive.zip -d /tmp \ | ||
&& mv /tmp/thehive-${THEHIVE_VERSION}-1 /tmp/thehive | ||
|
||
# FINAL STAGE | ||
FROM base | ||
RUN apk update && apk upgrade && apk add --no-cache openjdk11-jre-headless bash su-exec curl jq | ||
|
||
## ES SETUP | ||
COPY --from=builder /tmp/elasticsearch /usr/share/elasticsearch | ||
COPY configs/elasticsearch.yml /usr/share/elasticsearch/config/elasticsearch.yml | ||
|
||
RUN adduser -u 1000 -g 1000 -Dh /usr/share/elasticsearch elasticsearch \ | ||
&& mkdir -p /usr/share/elasticsearch/data \ | ||
&& chown -R elasticsearch:elasticsearch /usr/share/elasticsearch \ | ||
&& rm -rf /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64 | ||
|
||
## THEHIVE SETUP | ||
COPY --from=builder /tmp/thehive /opt/thehive/ | ||
COPY configs/thehive.conf /opt/thehive/conf/application.conf | ||
|
||
RUN adduser -u 1001 -g 1001 -Dh /opt/thehive thehive \ | ||
&& mkdir /var/log/thehive \ | ||
&& chown -R thehive:thehive /opt/thehive /var/log/thehive | ||
|
||
|
||
## ENTRYPOINT | ||
COPY entrypoint.sh / | ||
RUN chmod +x entrypoint.sh | ||
|
||
RUN /entrypoint.sh warmup | ||
|
||
EXPOSE 9000 | ||
ENTRYPOINT /entrypoint.sh startup | ||
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:9000/api/status |
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,7 @@ | ||
http.host: 0.0.0.0 | ||
transport.host: 0.0.0.0 | ||
discovery.type: single-node | ||
cluster.name: thehive4py | ||
xpack.security.enabled: false | ||
xpack.ml.enabled: false | ||
script.allowed_types: "inline,stored" |
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,22 @@ | ||
play.http.secret.key="supersecret" | ||
play.http.parser.maxDiskBuffer: 20MB | ||
|
||
db { | ||
provider: janusgraph | ||
janusgraph { | ||
storage { | ||
backend: berkeleyje | ||
directory: /opt/thehive/db | ||
} | ||
|
||
index.search { | ||
backend: elasticsearch | ||
hostname: ["127.0.0.1"] | ||
} | ||
} | ||
} | ||
|
||
storage { | ||
provider: localfs | ||
localfs.location: /opt/thehive/data | ||
} |
Oops, something went wrong.