Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/install-slips-dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Install Slips Dependencies

on:
# workflow_call make this workflow re-usable
workflow_call:
# these are like variables to make the workflow more clean
# we can pass these variable from another workflows if we want
inputs:
zeek-repo-url:
description: 'Zeek repository URL'
Expand All @@ -25,6 +22,8 @@ on:
jobs:
install-dependencies:
runs-on: ubuntu-22.04
outputs:
dependencies_installed: ${{ steps.mark_installed.outputs.installed }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -62,3 +61,7 @@ jobs:
curl -fsSL ${{ inputs.zeek-key-url }} | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/security_zeek.gpg
sudo apt update && sudo apt install -y --no-install-recommends zeek
sudo ln -s /opt/zeek/bin/zeek /usr/local/bin/bro

- name: Mark dependencies as installed
id: mark_installed
run: echo "installed=true" >> $GITHUB_OUTPUT
121 changes: 71 additions & 50 deletions .github/workflows/publish-slips-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,85 @@ name: CI-production-publishing-slips-images
on:
push:
branches:
- 'master'
- '!develop'
- 'master'
- '!develop'

jobs:
publish_slips_docker_image:
# runs the tests in a docker(built by this job) on stop of a GH VM
runs-on: ubuntu-20.04
setup:
runs-on: ubuntu-22.04
# 2 hours timeout
timeout-minutes: 7200
timeout-minutes: 120
outputs:
slips_version: ${{ steps.get_version.outputs.slips_version }}
builder_name: ${{ steps.create_builder.outputs.name }}

steps:
- name: Get slips version
run: |
VER=$(curl -s https://raw.githubusercontent.com/stratosphereips/StratosphereLinuxIPS/develop/VERSION)
echo "SLIPS_VERSION=$VER" >> $GITHUB_ENV
- name: Get slips version
id: get_version
run: |
ver=$(curl -s https://raw.githubusercontent.com/stratosphereips/StratosphereLinuxIPS/develop/VERSION)
echo "slips_version=$ver" >> $GITHUB_OUTPUT

# clone slips and checkout branch
# By default it checks out only one commit
- uses: actions/checkout@v4
with:
ref: 'master'
# Fetch all history for all tags and branches
fetch-depth: ''
# submodules are needed for local and global p2p
submodules: true
# should come before buildx action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Set up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context
- name: Create and use Buildx builder
id: create_builder
uses: docker/setup-buildx-action@v3
with:
driver: docker-container # allows multi-platform builds
# allows you to enable special permissions for the build environment that are normally considered insecure,
# such as:network.host
buildkitd-flags: --allow-insecure-entitlement network.host
name: slips_multi_arch_builder
use: true

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: stratosphereips
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
publish_images:
needs: setup
runs-on: ubuntu-22.04
strategy:
matrix:
image_type:
- name: slips
dockerfile: ./docker/Dockerfile
- name: slips_light
dockerfile: ./docker/light/Dockerfile

# Set up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
steps:
- name: Use existing Buildx builder
uses: docker/setup-buildx-action@v3
with:
name: slips_multi_arch_builder
install: true
use: true

# clone slips and checkout branch
# By default it checks out only one commit
- uses: actions/checkout@v4
with:
ref: 'master'
# Fetch all history for all tags and branches
fetch-depth: 0
# submodules are needed for local and global p2p
submodules: true

- name: Build and push the main Slips image
id: docker_build_slips
uses: docker/build-push-action@v6
with:
allow: network.host
context: ./
file: ./docker/Dockerfile
tags: |
stratosphereips/slips:latest
stratosphereips/slips:${{ env.SLIPS_VERSION }}
push: true
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: stratosphereips
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push the light Slips image
id: docker_build_light_slips
uses: docker/build-push-action@v6
with:
allow: network.host
context: ./
file: ./docker/light/Dockerfile
tags: |
stratosphereips/slips_light:latest
stratosphereips/slips_light:${{ env.SLIPS_VERSION }}
push: true
- name: Build and push ${{ matrix.image_type.name }} image
uses: docker/build-push-action@v6
with:
allow: network.host
context: ./
file: ${{ matrix.image_type.dockerfile }}
platforms: linux/amd64,linux/arm64
tags: |
stratosphereips/${{ matrix.image_type.name }}:latest
stratosphereips/${{ matrix.image_type.name }}:${{ needs.setup.outputs.slips_version }}
push: true
34 changes: 22 additions & 12 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ on:
- 'master'
- 'develop'


jobs:
# uses the common workflow that builds slips
install-dependencies-using-reusable-workflow:
uses: ./.github/workflows/install-slips-dependencies.yml

unit-tests:
runs-on: ubuntu-22.04
timeout-minutes: 1800
# make this job depend on the first job
timeout-minutes: 120
needs: install-dependencies-using-reusable-workflow

# suppress tensorflow warnings
env:
TF_CPP_MIN_LOG_LEVEL: 3
TF_ENABLE_ONEDNN_OPTS: 0
Expand Down Expand Up @@ -93,8 +90,12 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: ''
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.12

- name: Restore APT cache
id: apt-cache
Expand All @@ -106,20 +107,29 @@ jobs:
key: apt-cache

- if: ${{ steps.apt-cache.outputs.cache-hit == 'true' }}
name: Echo restored from cache
name: Echo restored APT cache
continue-on-error: true
run: echo "Restored APT dependencies from cache successfully"

- name: Install Python dependencies (from cache if possible)
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r install/requirements.txt

- name: Install apt dependencies (from cache if possible)
- name: Install apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y $(cat install/apt_dependencies.txt)

- name: Restore Python dependencies
id: python-cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('install/requirements.txt') }}

- if: ${{ steps.python-cache.outputs.cache-hit == 'true' }}
name: Echo restored Python cache
continue-on-error: true
run: echo "Restored Python dependencies from cache successfully"

- name: Install Python dependencies
run: python3 -m pip install -r install/requirements.txt

- name: Start redis server
run: redis-server --daemonize yes
Expand Down
19 changes: 13 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ RUN apt update && apt install -y --no-install-recommends \
python3-dev \
python3-tzlocal \
python3-pip \
nano \
tree \
tmux \
&& echo 'deb http://download.opensuse.org/repositories/security:/zeek/xUbuntu_22.04/ /' | tee /etc/apt/sources.list.d/security:zeek.list \
&& curl -fsSL https://download.opensuse.org/repositories/security:zeek/xUbuntu_22.04/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/security_zeek.gpg > /dev/null \
&& curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" > /etc/apt/sources.list.d/redis.list \
&& apt update \
&& apt install -y --no-install-recommends --fix-missing \
zeek \
redis \
npm \
&& ln -s /opt/zeek/bin/zeek /usr/local/bin/bro \
&& apt clean \
Expand All @@ -73,8 +73,16 @@ RUN apt update && apt install -y --no-install-recommends \
&& [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
&& nvm install 22

# why are we compiling redis instead od just using apt?
# to support running slips on the rpi (arm64). the rpi uses jemmalloc by default, which expects a different page size
# than the default on x86_64
RUN pip3 install --no-cache-dir --upgrade pip \
&& git clone https://github.com/redis/redis \
&& cd redis \
&& make distclean \
&& make MALLOC=libc \
&& ENV PATH="$PATH:/redis/src"

RUN pip3 install --no-cache-dir --upgrade pip

# Switch to Slips installation dir on login.
WORKDIR ${SLIPS_DIR}
Expand All @@ -96,8 +104,7 @@ RUN pip install --ignore-installed --no-cache-dir -r install/requirements.txt \
# build the pigeon and add pigeon to path
RUN cd p2p4slips \
&& go build \
&& export PATH="{$PATH}:/StratosphereLinuxIPS/p2p4slips/";

&& ENV PATH="$PATH:/StratosphereLinuxIPS/p2p4slips/"


WORKDIR ${SLIPS_DIR}
Expand Down
Loading