Skip to content

Commit

Permalink
Add data ingestion mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
nanory committed Dec 20, 2023
1 parent cf07f7c commit 9a7d5df
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 6 deletions.
40 changes: 34 additions & 6 deletions .github/workflows/data_ingestion.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
name: Data ingestion
on: ["push", "workflow_dispatch"]
jobs:
test:
data_ingestion:
environment: glvd-data-ingestion
name: data ingestion
runs-on: ubuntu-latest

env:
PGHOST: "${{ vars.PGHOST }}"
PGPORT: ${{ vars.PGPORT }}
PGUSER: ${{ vars.PGUSER }}
PGPASSWORD: ${{ secrets.PGPASSWORD }}
PGDATABASE: ${{ vars.PGDATABASE }}

steps:
- run: |
echo "${{ vars.PGDATABASE }}"
echo "${{ vars.PGHOST }}"
echo "${{ vars.PGPORT }}"
echo "${{ vars.PGUSER }}"
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build image for data ingestion container
id: build
uses: docker/build-push-action@v5
with:
context: .
file: container/Containerfile
load: true

- name: Run modified glvd container for data ingestion
run: >
docker run
--network host
--rm
--env PGHOST="$PGHOST"
--env PGPORT="$PGPORT"
--env PGUSER="$PGUSER"
--env PGPASSWORD="$PGPASSWORD"
--env PGDATABASE="$PGDATABASE"
${{ steps.build.outputs.imageid }}
28 changes: 28 additions & 0 deletions container/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Base Image
FROM ghcr.io/gardenlinux/glvd:edge

# Create ingestion directories
RUN mkdir -p /opt/glvd-data-ingestion/ingest-debsrc && \
mkdir -p /opt/glvd-data-ingestion/ingest-debsec

# Copy temporary build files for container to the container
COPY container/conf /opt/glvd-data-ingestion

# Copy ingestion scripts into the container
Copy src/data_ingestion.sh /usr/local/bin/data_ingestion

# Run commands for ingest-debsrc
RUN APT_CONFIG=/opt/glvd-data-ingestion/ingest-debsrc/apt.conf apt-get update

# Run commands for ingest-debsec
RUN apt update && \
apt install -y wget && \
mkdir -p /opt/glvd-data-ingestion/ingest-debsec/debian/CVE/ && \
mkdir -p /opt/glvd-data-ingestion/ingest-debsec/gardenlinux/CVE/ && \
wget https://salsa.debian.org/security-tracker-team/security-tracker/-/raw/master/data/CVE/list?ref_type=heads -o /opt/glvd-data-ingestion/ingest-debsec/debian/CVE/list

COPY data/CVE /opt/glvd-data-ingestion/ingest-debsec/gardenlinux/CVE

# Adjust entrypoint and command
ENTRYPOINT /bin/bash
CMD /usr/local/bin/data_ingestion
9 changes: 9 additions & 0 deletions container/conf/ingest-debsrc/apt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Acquire::Retries "3";
Dir "/opt/glvd-data-ingestion/ingest-debsrc/";
Dir::Etc::parts "/dev/null";
Dir::Etc::Preferences "/dev/null";
Dir::Etc::PreferencesParts "/dev/null";
Dir::Etc::sourcelist "/opt/glvd-data-ingestion/ingest-debsrc/sources.list";
Dir::Etc::sourceparts "/dev/null";
Dir::Etc::trusted "/usr/share/keyrings/debian-archive-keyring.gpg";
Dir::State "/opt/glvd-data-ingestion/ingest-debsrc/";
7 changes: 7 additions & 0 deletions container/conf/ingest-debsrc/sources.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
deb-src https://deb.debian.org/debian bookworm main non-free-firmware
deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src https://deb.debian.org/debian bookworm-proposed-updates main non-free-firmware
deb-src https://deb.debian.org/debian bookworm-backports main non-free-firmware
deb-src https://deb.debian.org/debian-security bookworm-security main non-free-firmware
deb-src https://deb.debian.org/debian trixie main non-free-firmware
deb-src [trusted=yes] https://repo.gardenlinux.io/gardenlinux 1337.0 main
15 changes: 15 additions & 0 deletions src/data_ingestion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# ---------
# Ingest NVD data
#glvd-data ingest-nvd

# ---------
# Ingest CVE lists
glvd-data ingest-debsec debian /opt/glvd/ingest-debsec/debian
glvd-data ingest-debsec gardenlinux /opt/glvd/ingest-debsec/gardenlinux

# ---------
# Ingest Debian sources
glvd-data ingest-debsrc debian trixie /mnt/ingest-debsrc/lists/deb.debian.org_debian_dists_trixie_main_source_Sources
glvd-data ingest-debsrc gardenlinux 1336.0 /mnt/ingest-debsrc/lists/repo.gardenlinux.io_gardenlinux_dists_1337.0_main_source_Sources

0 comments on commit 9a7d5df

Please sign in to comment.