An open API service indexing awesome lists of open source software.

https://github.com/redhatinsights/vulnerability-engine

Vulnerability Engine
https://github.com/redhatinsights/vulnerability-engine

Last synced: 6 months ago
JSON representation

Vulnerability Engine

Awesome Lists containing this project

README

        

[![Tests](https://github.com/RedHatInsights/vulnerability-engine/actions/workflows/tests.yml/badge.svg)](https://github.com/RedHatInsights/vulnerability-engine/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/RedHatInsights/vulnerability-engine/branch/master/graph/badge.svg)](https://codecov.io/gh/RedHatInsights/vulnerability-engine)
[![GitHub release](https://img.shields.io/github/release/RedHatInsights/vulnerability-engine.svg)](https://github.com/RedHatInsights/vulnerability-engine/releases/latest)

# vulnerability-engine
Vulnerability Engine

## Versioning
This project uses semantic versioning https://semver.org/. This process is automated by using [Python Semantic Release](https://github.com/relekang/python-semantic-release). Commits need to use this [format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).

## Requirements
- VMaaS (Vulnerability Metadata as a Service)
- Provides core functionality for evaluating vulnerabilities
- https://github.com/RedHatInsights/vmaas

- Insights Platform
- Upload service, Inventory, Kafka message queue
- Mocked Platform service is part of this repository (for development purposes)

## Local setup
Install a local python environment with pre-commit:
~~~bash
poetry install --sync --no-root
poetry shell
pre-commit install
~~~

## Local testing
Build images and start containers:
~~~bash
docker-compose up --build
~~~

Engine usage:
~~~bash
# Generate testing Insights archive
echo '{"package_list": ["kernel-3.10.0-862.el7.x86_64"], "repository_list": ["rhel-7-server-rpms"]}' | ./scripts/generate_insights_archive.py -o /tmp/insights-archive.tar.gz -

# Upload Insights archive to Platform mock
./scripts/3scale-mock -o 123456 curl -X POST -H "x-include-rules: false" -F "file=@/tmp/insights-archive.tar.gz" http://localhost:8100/api/v1/upload

# Check systems details
./scripts/3scale-mock -o 123456 curl -X GET http://localhost:8300/api/vulnerability/v1/systems

# Upload Insights archive to Platform mock and send message to Listener 10 times
./scripts/3scale-mock -a 123456 curl -X POST -F "file=@/tmp/insights-archive.tar.gz" -H "x-upload-multiplier: 10" http://localhost:8100/api/v1/upload

# Delete system
curl -X DELETE http://localhost:8100/api/v1/delete/be012439-26ae-456c-99a6-27b402331064
~~~

### Database
Switch into **database** container and run database terminal:
~~~bash
docker exec -it vulnerability-engine-database bash -c "psql -d vulnerability"
~~~

## Feature Flags

Feature flags are supported by Unleash. Connection to an Unleash server is done by a Clowder provided config.

Local development can be done by supplying bootstrapped feature flags via `UNLEASH_BOOTSTRAP_FILE` environment variable.
`UNLEASH_BOOTSTRAP_FILE` should point to a JSON file conforming to Unleash's [API /api/client/features](https://docs.getunleash.io/api/client/features).

## Run tests
You can run all tests from scratch just after cloning repo using command:
~~~bash
docker-compose -f docker-compose.test.yml up --build --exit-code-from test
~~~

Or locally:
~~~bash
# install postgresql-devel postgresql-server
poetry install --sync --no-root
poetry shell
pytest -vvv tests/
~~~

### Developing / Debugging
You can tune metrics using Prometheus and Grafana dev containers, see [doc/metrics.md](doc/metrics.md).

---
## Structure
![vulnerability-engine schema](doc/vulnerability_engine_diagram.svg)

### Detailed structure
![vulnerability-engine detailedschema](https://user-images.githubusercontent.com/6339153/120200721-eade9900-c224-11eb-85d7-0e4c4d765e43.jpg)