pytest
This is a simple API gateway built using Flask. It fetches vulnerability data from the Silobreaker API converts it into a more readable gateway and and provides it in either CSV or JSON format.
-
Clone the repository:
git clone https://github.com/ZacksBot/Gateway.git cd Gateway
-
Create and Activate a Virtual Environmenty
python3 -m venv myenv source myenv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Run the Script
python gateway.py
-
Build the Docker image:
docker build -t vulnerabilities-api-gateway .
-
Run the Docker container:
docker run -p 5000:5000 vulnerabilities-api-gateway
This will start the API gateway on
http://localhost:5000
.
You can access the following endpoints:
- CSV Format:
http://localhost:5000/vulnerabilities
- JSON Format:
http://localhost:5000/vulnerabilities?format=json
This task was quite simple. It required converting a lengthy URL, which was not optimal for developers, into a more accessible gateway endpoint called /vulnerabilities
. Fetching the data from the long URL string and setting up the new endpoint was straightforward. The conversion to CSV was also simple; all I had to do was map through the JSON objects, extract specific values, and use the csv library to convert them into a CSV
format.