Skip to content

Commit 1745f43

Browse files
matteogreeksacca97copernico
authored
Refactoring prospector code structure (#359)
## Main changes - Reorganized code structure - Fixed docker backend and worker containers - Added first implementation to automate the process of running prospector - Updated makefile - Updated backend to use config.yaml - Updated rules - Prepared to use also MITRE API --------- Co-authored-by: sacca97 <tommaso.sacchetti@gmail.com> Co-authored-by: Antonino Sabetta <antonino.sabetta@sap.com>
1 parent c888520 commit 1745f43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1836
-457
lines changed

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
# Maps tcp port 5432 on service container to the host
4040
- 5432:5432
4141
volumes:
42-
- prospector/ddl:/docker-entrypoint-initdb.d
42+
- ${{ github.workspace }}/prospector/ddl:/docker-entrypoint-initdb.d
4343
steps:
4444
- uses: actions/checkout@v3
4545
- name: Set up Python 3.10

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ prospector/.env
3232
prospector/workspace.code-workspace
3333
prospector/disabled_tests/skip_test-commits.db
3434
prospector/disabled_tests/skip_test-vulnerabilities.db
35+
prospector/tracer_dataset_final_2
3536
prospector/results
3637
prospector/*.py
3738
prospector/.vscode/launch.json

prospector/.env-sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ POSTGRES_HOST=localhost
1717
POSTGRES_DBNAME=postgres
1818
POSTGRES_PASSWORD=example
1919
REDIS_URL=redis://localhost:6379/0
20-
NVD_API_KEY=yourNvdApiKey
20+
NVD_API_KEY=APIkey
2121
PYTHONPATH=.

prospector/.flake8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[flake8]
2-
ignore = E203,E501,W503 #E203, E501, W503,F401,F403,W605
2+
ignore = E203,E501,W503,E501 E203, E501, W503,F401,F403,W605
33
exclude =
44
# No need to traverse our git directory
55
.git,
6+
empirical_study,
67
# There's no value in checking cache directories
78
__pycache__,
89
# The conf file is mostly autogenerated, ignore it

prospector/.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ repos:
1111
hooks:
1212
- id: black
1313
- repo: https://github.com/pycqa/isort
14-
rev: 5.10.1
14+
rev: 5.12.0
1515
hooks:
1616
- id: isort
1717
args: ["--profile", "black", "--filter-files"]
18-
- repo: https://gitlab.com/pycqa/flake8
18+
- repo: https://github.com/pycqa/flake8
1919
rev: 5.0.4
2020
hooks:
2121
- id: flake8

prospector/api/static/index.html

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
File renamed without changes.

prospector/client/cli/main.py renamed to prospector/cli/main.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
sys.path.append(path_root)
1515

1616

17-
import client.cli.report as report # noqa: E402
18-
from client.cli.console import ConsoleWriter, MessageStatus # noqa: E402
19-
from client.cli.prospector_client import TIME_LIMIT_AFTER # noqa: E402
20-
from client.cli.prospector_client import TIME_LIMIT_BEFORE # noqa: E402
21-
from client.cli.prospector_client import prospector # noqa: E402; noqa: E402
17+
import core.report as report # noqa: E402
18+
from cli.console import ConsoleWriter, MessageStatus # noqa: E402
19+
from core.prospector import TIME_LIMIT_AFTER # noqa: E402
20+
from core.prospector import TIME_LIMIT_BEFORE # noqa: E402
21+
from core.prospector import prospector # noqa: E402; noqa: E402
2222

2323
# Load logger before doing anything else
2424
from log.logger import get_level, logger, pretty_log # noqa: E402
@@ -30,7 +30,9 @@
3030

3131
def main(argv): # noqa: C901
3232
with ConsoleWriter("Initialization") as console:
33+
print("before config: ", argv)
3334
config = get_configuration(argv)
35+
print("after config: ", config.cve_id)
3436

3537
if not config:
3638
logger.error("No configuration file found. Cannot proceed.")
@@ -69,16 +71,16 @@ def main(argv): # noqa: C901
6971
repository_url=config.repository,
7072
publication_date=config.pub_date,
7173
vuln_descr=config.description,
72-
# tag_interval=config.tag_interval,
7374
version_interval=config.version_interval,
7475
modified_files=config.modified_files,
7576
advisory_keywords=config.keywords,
7677
use_nvd=config.use_nvd,
77-
fetch_references=config.fetch_references,
78+
# fetch_references=config.fetch_references,
7879
backend_address=config.backend,
7980
use_backend=config.use_backend,
8081
git_cache=config.git_cache,
8182
limit_candidates=config.max_candidates,
83+
# ignore_adv_refs=config.ignore_refs,
8284
)
8385

8486
if config.preprocess_only:

prospector/client/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)