Skip to content

Commit

Permalink
Add data ingestion mechanism (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanory committed Dec 21, 2023
1 parent aa6dc43 commit f8666d4
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 7 deletions.
119 changes: 112 additions & 7 deletions .github/workflows/data_ingestion.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,118 @@
name: Data ingestion
on: ["push", "workflow_dispatch"]
on:
push:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
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: Prepare data ingestion
run: ./src/prepare_ingestion.sh

- name: Run data ingestion (ingest-debsec - debian)
run: >
docker run
--network host
--rm
--volume $PWD/tmp/:/opt/glvd-data-ingestion
--entrypoint=""
--env PGHOST
--env PGPORT
--env PGUSER
--env PGPASSWORD
--env PGDATABASE
ghcr.io/gardenlinux/glvd:edge
/bin/sh -c 'glvd-data ingest-debsec debian /opt/glvd-data-ingestion/ingest-debsec/debian'
- name: Run data ingestion (ingest-debsec - gardenlinux)
run: >
docker run
--network host
--rm
--volume $PWD/tmp/:/opt/glvd-data-ingestion
--entrypoint=""
--env PGHOST
--env PGPORT
--env PGUSER
--env PGPASSWORD
--env PGDATABASE
ghcr.io/gardenlinux/glvd:edge
/bin/sh -c 'glvd-data ingest-debsec gardenlinux /opt/glvd-data-ingestion/ingest-debsec/gardenlinux'
- name: Run data ingestion (ingest-debsrc - debian buster)
run: >
docker run
--network host
--rm
--volume $PWD/tmp/:/opt/glvd-data-ingestion
--entrypoint=""
--env PGHOST
--env PGPORT
--env PGUSER
--env PGPASSWORD
--env PGDATABASE
ghcr.io/gardenlinux/glvd:edge
/bin/sh -c 'glvd-data ingest-debsrc debian buster /opt/glvd-data-ingestion/ingest-debsrc/lists/deb.debian.org_debian_dists_buster_main_source_Sources'
- name: Run data ingestion (ingest-debsrc - debian bullseye)
run: >
docker run
--network host
--rm
--volume $PWD/tmp/:/opt/glvd-data-ingestion
--entrypoint=""
--env PGHOST
--env PGPORT
--env PGUSER
--env PGPASSWORD
--env PGDATABASE
ghcr.io/gardenlinux/glvd:edge
/bin/sh -c 'glvd-data ingest-debsrc debian bullseye /opt/glvd-data-ingestion/ingest-debsrc/lists/deb.debian.org_debian_dists_bullseye_main_source_Sources'
- name: Run data ingestion (ingest-debsrc - debian bookworm)
run: >
docker run
--network host
--rm
--volume $PWD/tmp/:/opt/glvd-data-ingestion
--entrypoint=""
--env PGHOST
--env PGPORT
--env PGUSER
--env PGPASSWORD
--env PGDATABASE
ghcr.io/gardenlinux/glvd:edge
/bin/sh -c 'glvd-data ingest-debsrc debian bookworm /opt/glvd-data-ingestion/ingest-debsrc/lists/deb.debian.org_debian_dists_bookworm_main_source_Sources'
- name: Run data ingestion (ingest-debsrc - debian trixie)
run: >
docker run
--network host
--rm
--volume $PWD/tmp/:/opt/glvd-data-ingestion
--entrypoint=""
--env PGHOST
--env PGPORT
--env PGUSER
--env PGPASSWORD
--env PGDATABASE
ghcr.io/gardenlinux/glvd:edge
/bin/sh -c 'glvd-data ingest-debsrc debian trixie /opt/glvd-data-ingestion/ingest-debsrc/lists/deb.debian.org_debian_dists_trixie_main_source_Sources'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/*
5 changes: 5 additions & 0 deletions conf/ingest-debsrc/apt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Acquire::Retries "3";
Dir::Etc::parts "/dev/null";
Dir::Etc::Preferences "/dev/null";
Dir::Etc::PreferencesParts "/dev/null";
Dir::Etc::sourceparts "/dev/null";
6 changes: 6 additions & 0 deletions conf/ingest-debsrc/debian.sources
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enabled: yes
Types: deb-src
URIs: https://deb.debian.org/debian
Suites: buster bullseye bookworm trixie
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
2 changes: 2 additions & 0 deletions data/CVE/list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CVE-2023-6977 (This vulnerability enables malicious users to read sensitive files on ...)
TODO: check
24 changes: 24 additions & 0 deletions src/prepare_ingestion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

# Install Debian Keyring
sudo apt update
sudo apt install -y debian-archive-keyring

# Prepare: mount directories
mkdir -p tmp/ingest-debsec/{debian,gardenlinux}/CVE
mkdir -p tmp/ingest-debsrc/debian
mkdir -p tmp/ingest-debsrc/var/lib/dpkg
touch tmp/ingest-debsrc/var/lib/dpkg/status

# Prepare: ingest-debsec
curl https://salsa.debian.org/security-tracker-team/security-tracker/-/raw/master/data/CVE/list?ref_type=heads \
--output tmp/ingest-debsec/debian/CVE/list
cp -p data/CVE/list tmp/ingest-debsec/gardenlinux/CVE/list

# Prepare: ingest-debsrc
APT_CONFIG=conf/ingest-debsrc/apt.conf apt update \
-o Dir="$PWD/tmp/ingest-debsrc/" \
-o Dir::Etc::sourcelist="$PWD/conf/ingest-debsrc/debian.sources" \
-o Dir::State="$PWD/tmp/ingest-debsrc/"

0 comments on commit f8666d4

Please sign in to comment.