Skip to content

Database updater

Database updater #44

Workflow file for this run

name: Database updater
on:
workflow_dispatch:
schedule:
- cron: "30 6 1,15 * *"
jobs:
update-database:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo apt install -y sqlite3 jq
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: true
persist-credentials: false
- name: Change global git configurations
run: |
git config --global push.default current
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Collect latest database
uses: addnab/docker-run-action@v3
with:
image: registry.gast.it.uc3m.es/kubernetesdockerimages/netauditor:latest
options: --rm --entrypoint sh -v ${{ github.workspace }}:/tmp/CVEScannerV2
run: cp cve.db /tmp/CVEScannerV2
- name: Chown database
run: sudo chown runner:runner cve.db
- name: Download latest metasploit cache
run: curl https://gitlab.gast.it.uc3m.es/kubernetesdockerimages/metasploit/raw/master/modules_cache.json -o modules_cache_msf.json
- name: Install CVEScannerV2 dependencies
run: pip install -r requirements.txt
- name: Configure .api file
run: |
python -c "import os; file = open('.api', 'w'); file.write(os.environ['API_KEY']); file.close()"
shell: bash
env:
API_KEY : ${{secrets.API_KEY}}
- name: Update database
run: python3 database.py
- name: Generate new dump
run: |
sqlite3 cve.db .dump > dump.sql
grep -vx -f splitter/schema.sql -f splitter/pragma.sql dump.sql > data.sql
rm CVEScannerV2DB/data_*
splitter/splitter.py -i data.sql -o CVEScannerV2DB
- name: Update CVEScannerV2DB
run: |
cd CVEScannerV2DB
version=$(curl -s https://gitlab.gast.it.uc3m.es/api/v4/projects/314/repository/commits | jq -r '.[0].title' | grep -o "v.*-dev")
git checkout --orphan latest
git add -A
git commit -m "Update database (msf $version)"
git branch -D master
git branch -m master
git remote set-url origin https://updater:${{ secrets.TOKEN }}@github.com/scmanjarrez/CVEScannerV2DB.git
git push -f
- name: Update CVEScannerV2
run: |
cd ${{ github.workspace }}
version=$(curl -s https://gitlab.gast.it.uc3m.es/api/v4/projects/314/repository/commits | jq -r '.[0].title' | grep -o "v.*-dev")
git add --update
git commit -m "Update database (msf $version)"
git remote set-url origin --push https://updater:${{ secrets.TOKEN }}@github.com/scmanjarrez/CVEScannerV2.git
git remote set-url origin --add --push https://updater:${{ secrets.TOKENGL }}@gitlab.gast.it.uc3m.es/schica/CVEScannerV2.git
git push