Skip to content

Commit f4b04a6

Browse files
Add doc tests on CI and fix linter errors
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent f9dd3e2 commit f4b04a6

5 files changed

Lines changed: 61 additions & 24 deletions

File tree

.github/workflows/docs.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI Documentation
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-20.04
8+
9+
strategy:
10+
max-parallel: 4
11+
matrix:
12+
python-version: [3.7]
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Give permission to run scripts
24+
run: chmod +x ./docs/scripts/doc8_style_check.sh
25+
26+
- name: Install Dependencies
27+
working-directory: ./docs
28+
run: pip install -r requirements.txt
29+
30+
- name: Check Sphinx Documentation build minimally
31+
working-directory: ./docs
32+
run: sphinx-build -E source build
33+
34+
- name: Check for documentation style errors
35+
working-directory: ./docs
36+
run: ./scripts/doc8_style_check.sh

docs/scripts/doc8_style_check.sh

100644100755
File mode changed.

docs/source/getting-started/docker_installation.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ Run your image as a container
4343
4444
At this point, the VulnerableCode app should be running at port ``8000`` on your Docker host.
4545
Go to http://localhost:8000/ on a web browser to access the web UI.
46-
Optionally, you can set ``NGINX_PORT`` environment variable in your shell or in the `.env` file to run on a different port than 8000.
46+
Optionally, you can set ``NGINX_PORT`` environment variable in your shell or in the `.env` file
47+
to run on a different port than 8000.
4748

4849
.. note::
4950

@@ -58,17 +59,17 @@ Optionally, you can set ``NGINX_PORT`` environment variable in your shell or in
5859
.. warning::
5960

6061
Serving VulnerableCode on a network could lead to security issues and there
61-
are several steps that may be needed to secure such a deployment.
62+
are several steps that may be needed to secure such a deployment.
6263
Currently, this is not recommendend.
6364

6465

6566
Invoke the importers
6667
--------------------
6768

68-
Connect to the Docker container ``bash``.
69-
From here you can access ``manage.py`` and run management commands
70-
to import data as specified in the `Data import <../README.rst#data-import>`_ section and run commands
71-
for the importers from there
69+
Connect to the Docker container ``bash``.
70+
From here you can access ``manage.py`` and run management commands
71+
to import data as specified in the `Data import <../README.rst#data-import>`_ section and
72+
run commands for the importers from there
7273

7374
For example:
7475

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Vulneribility Sources
22
=====================
33

4-
.. include:: ../../../SOURCES.rst
4+
.. include:: ../../../SOURCES.rst

docs/source/how-to-guides/add_new_importer.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ The Building Blocks A.K.A Prerequisites
4343
reference_id: str = ""
4444
url: str = ""
4545
severities: List[VulnerabilitySeverity] = dataclasses.field(default_factory=list)
46-
46+
4747
4848
Steps to build an Importer
4949
--------------------------
5050

5151
* **Register an Importer:**
5252

5353
To do this go to ``vulnerabilites/importer_yielder.py``, in the ``IMPORTER_REGISTRY``
54-
list add a dictionary with following data
54+
list add a dictionary with following data
5555

5656
.. code:: python
5757
@@ -63,7 +63,7 @@ list add a dictionary with following data
6363
'data_source_cfg': {},
6464
}
6565
66-
66+
6767
**Don't forget to replace <your_importer_name> and <your_data_source_name> with
6868
appropriate strings**
6969

@@ -72,7 +72,7 @@ If you know the license of the data you are importing, assign the license field
7272
equal to the license of the data in the ``add_<your_importer_name>_importer``
7373
method of the migration script.
7474

75-
* **Create a data source** :
75+
* **Create a data source** :
7676

7777
- Go to ``vulnerabilities/importers`` , create a python script, let's call it ``my_importer.py``
7878

@@ -83,25 +83,25 @@ method of the migration script.
8383
.. code:: python
8484
8585
from typing import Set
86-
86+
8787
from packageurl import PackageURL
8888
import requests
89-
89+
9090
from vulnerabilities.data_source import Advisory
9191
from vulnerabilities.data_source import DataSource
92-
92+
9393
class ExampleDataSource(DataSource):
9494
#This method must be implemented
9595
def updated_advisories(self)-> Set[Advisory]:
9696
raw_data = self.fetch()
9797
advisories = self.to_advisories(raw_data)
9898
return self.batch_advisories(advisories)
99-
100-
#Optional Method, but it is recommended to have fetching separated
99+
100+
#Optional Method, but it is recommended to have fetching separated
101101
def fetch(self):
102102
return requests.get("http://examplesecurity.org/api/json").json()
103-
104-
#Optional Method
103+
104+
#Optional Method
105105
@staticmethod
106106
def to_advisories(json_response:dict) -> Set[Advisory]:
107107
advisories = []
@@ -113,18 +113,18 @@ method of the migration script.
113113
cve_id = entry['cve_id']
114114
safe_purls ={ PackageURL(name=pkg_name,
115115
type=pkg_type,
116-
version=version)
116+
version=version)
117117
for version in safe_pkg_versions}
118118
vuln_purls= {PackageURL(name=pkg_name,
119119
type=pkg_type,
120-
version=version)
120+
version=version)
121121
for version in vuln_pkg_versions}
122-
123-
122+
123+
124124
advisory = Advisory(vulnerability_id=cve_id,summary='',impacted_package_urls=vuln_purls,resolved_package_urls=safe_purls)
125125
advisories.append(advisory)
126126
return advisories
127-
127+
128128
129129
Finally register this ``ExampleDataSource`` in
130130
``vulnerabilities/importers/__init__.py`` by adding the following line
@@ -138,4 +138,4 @@ Done, congrats on writing your new importer.Test it via
138138
::
139139

140140
./manage.py migrate
141-
./manage.py import my_importer
141+
./manage.py import my_importer

0 commit comments

Comments
 (0)