MongoDB Dumper #168
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
name: MongoDB Dumper | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
repository_dispatch: | |
concurrency: | |
group: run-dev | |
cancel-in-progress: true | |
jobs: | |
import_export: | |
name: Initial Import Export | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout CVEdumper | |
uses: actions/checkout@v3 | |
- name: Start MongoDB | |
uses: supercharge/[email protected] | |
with: | |
mongodb-version: "4.4" | |
- name: Install mongo tools command | |
run: | | |
echo "RELEASE_VERSION=$(date +"%Y%m%d")" >> "$GITHUB_ENV" | |
sudo apt-get update | |
sudo apt-get install -y wget gnupg | |
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add - | |
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list | |
sudo apt-get update | |
sudo apt-get install -y mongodb-database-tools mariadb-client | |
- name: Download the advisories zip file | |
run: | | |
wget -q https://github.com/CVEProject/cvelist/archive/refs/heads/master.zip | |
unzip -q master.zip | |
rm master.zip | |
- name: start docker services | |
run: | | |
docker-compose -f maxscale-compose.yml up -d | |
sleep 15 | |
- name: Import the advisories to mongodb/mysql | |
run: find cvelist-master -type f -name "CVE*.json" -exec mongoimport --host localhost:17017 -d CVE -c advisories {} \; | |
- name: dump the .advisories | |
run: mongodump --host localhost:17017 --db=CVE --collection=advisories | |
- name: Export the full CVE.advisories | |
run: mongoexport --host localhost:17017 --collection=advisories --db=CVE --out=CVE-full-$(date +"%Y%m%d").json | |
- name: Export the full CVE.advisories as Array | |
run: mongoexport --jsonArray --host localhost:17017 --collection=advisories --db=CVE --out=CVE-full-ARR-$(date +"%Y%m%d").json | |
- name: Dump the database | |
run: | | |
MYSQL_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cvedumper_master_1) | |
mysqldump -unosql -pnosql -h ${MYSQL_HOST} CVE > CVE-full-$(date +"%Y%m%d").sql | |
- name: zip files | |
run: | | |
zip -9 CVE-full-$(date +"%Y%m%d")-mongoexport.zip CVE-full-$(date +"%Y%m%d").json | |
zip -9 CVE-full-ARR-$(date +"%Y%m%d")-mongoexport.zip CVE-full-ARR-$(date +"%Y%m%d").json | |
- name: Release Latest dump | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: false | |
name: CVEdumper-${{ env.RELEASE_VERSION }} | |
files: | | |
*.zip | |
CVE-full*.sql | |
CVE-full*.json | |
tag_name: CVEdump-${{ env.RELEASE_VERSION }} |