owasp-dependency-track-cli 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- owasp_dependency_track_cli-0.0.1/LICENSE +21 -0
- owasp_dependency_track_cli-0.0.1/PKG-INFO +90 -0
- owasp_dependency_track_cli-0.0.1/README.md +70 -0
- owasp_dependency_track_cli-0.0.1/owasp_dependency_track_cli.egg-info/PKG-INFO +90 -0
- owasp_dependency_track_cli-0.0.1/owasp_dependency_track_cli.egg-info/SOURCES.txt +12 -0
- owasp_dependency_track_cli-0.0.1/owasp_dependency_track_cli.egg-info/dependency_links.txt +1 -0
- owasp_dependency_track_cli-0.0.1/owasp_dependency_track_cli.egg-info/entry_points.txt +2 -0
- owasp_dependency_track_cli-0.0.1/owasp_dependency_track_cli.egg-info/requires.txt +4 -0
- owasp_dependency_track_cli-0.0.1/owasp_dependency_track_cli.egg-info/top_level.txt +1 -0
- owasp_dependency_track_cli-0.0.1/setup.cfg +4 -0
- owasp_dependency_track_cli-0.0.1/setup.py +34 -0
- owasp_dependency_track_cli-0.0.1/test/test_api.py +66 -0
- owasp_dependency_track_cli-0.0.1/test/test_convert.py +21 -0
- owasp_dependency_track_cli-0.0.1/test/test_test.py +30 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mike Reiche
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: owasp-dependency-track-cli
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Inofficial OWASP Dependency Track CLI
|
|
5
|
+
Home-page: https://github.com/mreiche/owasp-dependency-track-cli
|
|
6
|
+
Author: Mike Reiche
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: owasp-dependency-track-client==0.0.3
|
|
10
|
+
Requires-Dist: is_empty==1.0.1
|
|
11
|
+
Requires-Dist: tabulate==0.9.0
|
|
12
|
+
Requires-Dist: colorama==0.4.6
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: description
|
|
15
|
+
Dynamic: description-content-type
|
|
16
|
+
Dynamic: home-page
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: summary
|
|
20
|
+
|
|
21
|
+
# OWASP Dependency Tracker CLI
|
|
22
|
+
|
|
23
|
+
A CLI client for usage in CI/CD pipelines.
|
|
24
|
+
|
|
25
|
+
## Test for findings
|
|
26
|
+
|
|
27
|
+
```shell
|
|
28
|
+
OWASP_DT_URL="http://localhost:8081/api"
|
|
29
|
+
OWASP_DT_VERIFY_SSL="False"
|
|
30
|
+
OWASP_DT_API_KEY="xyz"
|
|
31
|
+
SEVERITY_THRESHOLD_HIGH="3"
|
|
32
|
+
|
|
33
|
+
python main.py test --project-name webapp --auto-create test/test.sbom.xml
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
As Container runtime:
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
podman|docker \
|
|
40
|
+
run --rm -v"$(pwd):$(pwd)" \
|
|
41
|
+
-eOWASP_DT_URL="http://192.168.1.100:8081/api" \
|
|
42
|
+
-eOWASP_DT_VERIFY_SSL="false" \
|
|
43
|
+
-eOWASP_DT_API_KEY="xyz" \
|
|
44
|
+
ghcr.io/mreiche/owasp-dependency-track-cli:main test --project-name webapp2 --auto-create "$(pwd)/test/test.sbom.xml"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Environment variables
|
|
48
|
+
```shell
|
|
49
|
+
OWASP_DT_URL="http://localhost:8081/api" # Base-URL to OWASP Dependency Track API (mind '/api' as base path)
|
|
50
|
+
OWASP_DT_VERIFY_SSL="False" # Do not verify SSL
|
|
51
|
+
OWASP_DT_API_KEY="xyz" # You OWASP DT API Key
|
|
52
|
+
SEVERITY_THRESHOLD_HIGH="-1" # Threshold for HIGH severity findings
|
|
53
|
+
SEVERITY_THRESHOLD_MEDIUM="-1" # Threshold for MEDIUM severity findings
|
|
54
|
+
SEVERITY_THRESHOLD_LOW="-1" # Threshold for LOW severity findings
|
|
55
|
+
SEVERITY_THRESHOLD_UNASSIGNED="-1" # Threshold for UNASSIGNED severity findings
|
|
56
|
+
TEST_TIMEOUT_SEC="300" # Timeout in seconds for waiting OWASP DT finished scanning
|
|
57
|
+
HTTPS_PROXY="" # URL for for HTTP(S) proxy
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API-Key
|
|
61
|
+
|
|
62
|
+
Setup a user with API key and the following permissions:
|
|
63
|
+
|
|
64
|
+
1. Goto *Teams* -> *Automation*
|
|
65
|
+
1. Add *API-Key*
|
|
66
|
+
1. Add *Permissions*
|
|
67
|
+
- VIEW_VULNERABILITY
|
|
68
|
+
- SBOM_UPLOAD
|
|
69
|
+
- PROJECT_CREATION_UPLOAD (for the auto-create feature)
|
|
70
|
+
|
|
71
|
+
## Testing
|
|
72
|
+
|
|
73
|
+
### Start the test environment
|
|
74
|
+
```shell
|
|
75
|
+
cd test
|
|
76
|
+
podman|docker compose up
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Preconfigured user: `admin:admin2`
|
|
80
|
+
- Preconfigured API key: see `test/test.env`
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Update the test database
|
|
84
|
+
```shell
|
|
85
|
+
podman run -it --rm --network=test_default -v "$(pwd)/test:/test" postgres:latest pg_dump -h postgres -d dtrack -U "dtrack" -p "5432" -f "/test/postgres-init/init.sql"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## References
|
|
89
|
+
|
|
90
|
+
- This CLI is using the Python API client: https://github.com/mreiche/owasp-dependency-track-python-client
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# OWASP Dependency Tracker CLI
|
|
2
|
+
|
|
3
|
+
A CLI client for usage in CI/CD pipelines.
|
|
4
|
+
|
|
5
|
+
## Test for findings
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
OWASP_DT_URL="http://localhost:8081/api"
|
|
9
|
+
OWASP_DT_VERIFY_SSL="False"
|
|
10
|
+
OWASP_DT_API_KEY="xyz"
|
|
11
|
+
SEVERITY_THRESHOLD_HIGH="3"
|
|
12
|
+
|
|
13
|
+
python main.py test --project-name webapp --auto-create test/test.sbom.xml
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
As Container runtime:
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
podman|docker \
|
|
20
|
+
run --rm -v"$(pwd):$(pwd)" \
|
|
21
|
+
-eOWASP_DT_URL="http://192.168.1.100:8081/api" \
|
|
22
|
+
-eOWASP_DT_VERIFY_SSL="false" \
|
|
23
|
+
-eOWASP_DT_API_KEY="xyz" \
|
|
24
|
+
ghcr.io/mreiche/owasp-dependency-track-cli:main test --project-name webapp2 --auto-create "$(pwd)/test/test.sbom.xml"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Environment variables
|
|
28
|
+
```shell
|
|
29
|
+
OWASP_DT_URL="http://localhost:8081/api" # Base-URL to OWASP Dependency Track API (mind '/api' as base path)
|
|
30
|
+
OWASP_DT_VERIFY_SSL="False" # Do not verify SSL
|
|
31
|
+
OWASP_DT_API_KEY="xyz" # You OWASP DT API Key
|
|
32
|
+
SEVERITY_THRESHOLD_HIGH="-1" # Threshold for HIGH severity findings
|
|
33
|
+
SEVERITY_THRESHOLD_MEDIUM="-1" # Threshold for MEDIUM severity findings
|
|
34
|
+
SEVERITY_THRESHOLD_LOW="-1" # Threshold for LOW severity findings
|
|
35
|
+
SEVERITY_THRESHOLD_UNASSIGNED="-1" # Threshold for UNASSIGNED severity findings
|
|
36
|
+
TEST_TIMEOUT_SEC="300" # Timeout in seconds for waiting OWASP DT finished scanning
|
|
37
|
+
HTTPS_PROXY="" # URL for for HTTP(S) proxy
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API-Key
|
|
41
|
+
|
|
42
|
+
Setup a user with API key and the following permissions:
|
|
43
|
+
|
|
44
|
+
1. Goto *Teams* -> *Automation*
|
|
45
|
+
1. Add *API-Key*
|
|
46
|
+
1. Add *Permissions*
|
|
47
|
+
- VIEW_VULNERABILITY
|
|
48
|
+
- SBOM_UPLOAD
|
|
49
|
+
- PROJECT_CREATION_UPLOAD (for the auto-create feature)
|
|
50
|
+
|
|
51
|
+
## Testing
|
|
52
|
+
|
|
53
|
+
### Start the test environment
|
|
54
|
+
```shell
|
|
55
|
+
cd test
|
|
56
|
+
podman|docker compose up
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- Preconfigured user: `admin:admin2`
|
|
60
|
+
- Preconfigured API key: see `test/test.env`
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Update the test database
|
|
64
|
+
```shell
|
|
65
|
+
podman run -it --rm --network=test_default -v "$(pwd)/test:/test" postgres:latest pg_dump -h postgres -d dtrack -U "dtrack" -p "5432" -f "/test/postgres-init/init.sql"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## References
|
|
69
|
+
|
|
70
|
+
- This CLI is using the Python API client: https://github.com/mreiche/owasp-dependency-track-python-client
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: owasp-dependency-track-cli
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Inofficial OWASP Dependency Track CLI
|
|
5
|
+
Home-page: https://github.com/mreiche/owasp-dependency-track-cli
|
|
6
|
+
Author: Mike Reiche
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: owasp-dependency-track-client==0.0.3
|
|
10
|
+
Requires-Dist: is_empty==1.0.1
|
|
11
|
+
Requires-Dist: tabulate==0.9.0
|
|
12
|
+
Requires-Dist: colorama==0.4.6
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: description
|
|
15
|
+
Dynamic: description-content-type
|
|
16
|
+
Dynamic: home-page
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: summary
|
|
20
|
+
|
|
21
|
+
# OWASP Dependency Tracker CLI
|
|
22
|
+
|
|
23
|
+
A CLI client for usage in CI/CD pipelines.
|
|
24
|
+
|
|
25
|
+
## Test for findings
|
|
26
|
+
|
|
27
|
+
```shell
|
|
28
|
+
OWASP_DT_URL="http://localhost:8081/api"
|
|
29
|
+
OWASP_DT_VERIFY_SSL="False"
|
|
30
|
+
OWASP_DT_API_KEY="xyz"
|
|
31
|
+
SEVERITY_THRESHOLD_HIGH="3"
|
|
32
|
+
|
|
33
|
+
python main.py test --project-name webapp --auto-create test/test.sbom.xml
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
As Container runtime:
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
podman|docker \
|
|
40
|
+
run --rm -v"$(pwd):$(pwd)" \
|
|
41
|
+
-eOWASP_DT_URL="http://192.168.1.100:8081/api" \
|
|
42
|
+
-eOWASP_DT_VERIFY_SSL="false" \
|
|
43
|
+
-eOWASP_DT_API_KEY="xyz" \
|
|
44
|
+
ghcr.io/mreiche/owasp-dependency-track-cli:main test --project-name webapp2 --auto-create "$(pwd)/test/test.sbom.xml"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Environment variables
|
|
48
|
+
```shell
|
|
49
|
+
OWASP_DT_URL="http://localhost:8081/api" # Base-URL to OWASP Dependency Track API (mind '/api' as base path)
|
|
50
|
+
OWASP_DT_VERIFY_SSL="False" # Do not verify SSL
|
|
51
|
+
OWASP_DT_API_KEY="xyz" # You OWASP DT API Key
|
|
52
|
+
SEVERITY_THRESHOLD_HIGH="-1" # Threshold for HIGH severity findings
|
|
53
|
+
SEVERITY_THRESHOLD_MEDIUM="-1" # Threshold for MEDIUM severity findings
|
|
54
|
+
SEVERITY_THRESHOLD_LOW="-1" # Threshold for LOW severity findings
|
|
55
|
+
SEVERITY_THRESHOLD_UNASSIGNED="-1" # Threshold for UNASSIGNED severity findings
|
|
56
|
+
TEST_TIMEOUT_SEC="300" # Timeout in seconds for waiting OWASP DT finished scanning
|
|
57
|
+
HTTPS_PROXY="" # URL for for HTTP(S) proxy
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API-Key
|
|
61
|
+
|
|
62
|
+
Setup a user with API key and the following permissions:
|
|
63
|
+
|
|
64
|
+
1. Goto *Teams* -> *Automation*
|
|
65
|
+
1. Add *API-Key*
|
|
66
|
+
1. Add *Permissions*
|
|
67
|
+
- VIEW_VULNERABILITY
|
|
68
|
+
- SBOM_UPLOAD
|
|
69
|
+
- PROJECT_CREATION_UPLOAD (for the auto-create feature)
|
|
70
|
+
|
|
71
|
+
## Testing
|
|
72
|
+
|
|
73
|
+
### Start the test environment
|
|
74
|
+
```shell
|
|
75
|
+
cd test
|
|
76
|
+
podman|docker compose up
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Preconfigured user: `admin:admin2`
|
|
80
|
+
- Preconfigured API key: see `test/test.env`
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Update the test database
|
|
84
|
+
```shell
|
|
85
|
+
podman run -it --rm --network=test_default -v "$(pwd)/test:/test" postgres:latest pg_dump -h postgres -d dtrack -U "dtrack" -p "5432" -f "/test/postgres-init/init.sql"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## References
|
|
89
|
+
|
|
90
|
+
- This CLI is using the Python API client: https://github.com/mreiche/owasp-dependency-track-python-client
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
owasp_dependency_track_cli.egg-info/PKG-INFO
|
|
5
|
+
owasp_dependency_track_cli.egg-info/SOURCES.txt
|
|
6
|
+
owasp_dependency_track_cli.egg-info/dependency_links.txt
|
|
7
|
+
owasp_dependency_track_cli.egg-info/entry_points.txt
|
|
8
|
+
owasp_dependency_track_cli.egg-info/requires.txt
|
|
9
|
+
owasp_dependency_track_cli.egg-info/top_level.txt
|
|
10
|
+
test/test_api.py
|
|
11
|
+
test/test_convert.py
|
|
12
|
+
test/test_test.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from setuptools import setup, find_packages
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
this_directory = Path(__file__).parent
|
|
7
|
+
long_description = (this_directory / "README.md").read_text()
|
|
8
|
+
|
|
9
|
+
VERSION = os.environ.get("PACKAGE_VERSION", "0.0.1")
|
|
10
|
+
|
|
11
|
+
def read_requirements(filename):
|
|
12
|
+
with open(filename) as f:
|
|
13
|
+
return [
|
|
14
|
+
line.strip() for line in f
|
|
15
|
+
if line.strip() and not line.startswith('#')
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
setup(
|
|
20
|
+
name="owasp-dependency-track-cli",
|
|
21
|
+
description="Inofficial OWASP Dependency Track CLI",
|
|
22
|
+
long_description=long_description,
|
|
23
|
+
long_description_content_type="text/markdown",
|
|
24
|
+
version=VERSION,
|
|
25
|
+
url="https://github.com/mreiche/owasp-dependency-track-cli",
|
|
26
|
+
author="Mike Reiche",
|
|
27
|
+
packages=find_packages(),
|
|
28
|
+
install_requires=read_requirements('requirements.txt'),
|
|
29
|
+
entry_points={
|
|
30
|
+
'console_scripts': [
|
|
31
|
+
'owasp-dt = main',
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from time import sleep
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
import owasp_dt
|
|
7
|
+
from common import load_env
|
|
8
|
+
from lib.api import create_client_from_env, get_findings_by_project_uuid
|
|
9
|
+
from owasp_dt.api.bom import upload_bom
|
|
10
|
+
from owasp_dt.api.project import get_projects
|
|
11
|
+
from owasp_dt.models import UploadBomBody, IsTokenBeingProcessedResponse
|
|
12
|
+
from owasp_dt.api.event import is_token_being_processed_1
|
|
13
|
+
|
|
14
|
+
__base_dir = Path(__file__).parent
|
|
15
|
+
|
|
16
|
+
def setup_module():
|
|
17
|
+
load_env()
|
|
18
|
+
|
|
19
|
+
__upload_token = None
|
|
20
|
+
__project_id = None
|
|
21
|
+
|
|
22
|
+
@pytest.fixture
|
|
23
|
+
def client():
|
|
24
|
+
yield create_client_from_env()
|
|
25
|
+
|
|
26
|
+
def test_upload_sbom(client: owasp_dt.Client):
|
|
27
|
+
global __upload_token
|
|
28
|
+
with open(__base_dir / "test.sbom.xml") as sbom_file:
|
|
29
|
+
resp = upload_bom.sync_detailed(client=client, body=UploadBomBody(
|
|
30
|
+
project_name="test-project",
|
|
31
|
+
auto_create=True,
|
|
32
|
+
bom=sbom_file.read()
|
|
33
|
+
))
|
|
34
|
+
upload = resp.parsed
|
|
35
|
+
assert upload is not None, "API call failed. Check client permissions."
|
|
36
|
+
assert upload.token is not None
|
|
37
|
+
__upload_token = upload.token
|
|
38
|
+
|
|
39
|
+
@pytest.mark.depends(on=['test_upload_sbom'])
|
|
40
|
+
def test_get_scan_status(client: owasp_dt.Client):
|
|
41
|
+
max_tries = 10
|
|
42
|
+
i = 0
|
|
43
|
+
for i in range(max_tries):
|
|
44
|
+
resp = is_token_being_processed_1.sync_detailed(client=client, uuid=__upload_token)
|
|
45
|
+
status = resp.parsed
|
|
46
|
+
assert isinstance(status, IsTokenBeingProcessedResponse)
|
|
47
|
+
if not status.processing:
|
|
48
|
+
break
|
|
49
|
+
sleep(1)
|
|
50
|
+
|
|
51
|
+
assert i < max_tries, f"Scan not finished within {max_tries} seconds"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@pytest.mark.depends(on=['test_upload_sbom'])
|
|
55
|
+
def test_search_project_by_name(client: owasp_dt.Client):
|
|
56
|
+
global __project_id
|
|
57
|
+
resp = get_projects.sync_detailed(client=client, name="test-project")
|
|
58
|
+
projects = resp.parsed
|
|
59
|
+
assert len(projects) > 0
|
|
60
|
+
assert projects[0].uuid is not None
|
|
61
|
+
__project_id = projects[0].uuid
|
|
62
|
+
|
|
63
|
+
@pytest.mark.depends(on=['test_search_project_by_name','test_get_scan_status'])
|
|
64
|
+
def test_get_project_findings(client: owasp_dt.Client):
|
|
65
|
+
findings = get_findings_by_project_uuid(client=client, uuid=__project_id)
|
|
66
|
+
assert len(findings) > 0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
__base_dir = Path(__file__).parent
|
|
8
|
+
|
|
9
|
+
@pytest.mark.xfail(reason="Feature not implemented")
|
|
10
|
+
def test_convert():
|
|
11
|
+
test_env = os.environ.copy()
|
|
12
|
+
file = __base_dir / "test.sbom.json"
|
|
13
|
+
ret = subprocess.run(
|
|
14
|
+
["python", __base_dir / "../main.py", "convert", file],
|
|
15
|
+
capture_output=True,
|
|
16
|
+
text=True,
|
|
17
|
+
env=test_env
|
|
18
|
+
)
|
|
19
|
+
assert ret.returncode == 0
|
|
20
|
+
xml_file = file.parent / f"{file.stem}.xml"
|
|
21
|
+
assert xml_file.exists()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from common import load_env
|
|
7
|
+
from lib.args import create_parser
|
|
8
|
+
|
|
9
|
+
__base_dir = Path(__file__).parent
|
|
10
|
+
|
|
11
|
+
def setup_module():
|
|
12
|
+
load_env()
|
|
13
|
+
|
|
14
|
+
def test_test():
|
|
15
|
+
parser = create_parser()
|
|
16
|
+
args = parser.parse_args([
|
|
17
|
+
"test",
|
|
18
|
+
"--project-name",
|
|
19
|
+
"test-project",
|
|
20
|
+
"--auto-create",
|
|
21
|
+
"--latest",
|
|
22
|
+
str(__base_dir / "test.sbom.xml"),
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
args.func(args)
|
|
26
|
+
|
|
27
|
+
def test_proxy_fails(monkeypatch):
|
|
28
|
+
monkeypatch.setenv("HTTP_PROXY", "http://localhost:3128")
|
|
29
|
+
with pytest.raises(expected_exception=httpx.ConnectError):
|
|
30
|
+
test_test()
|