Skip to content

Commit 4bd60c9

Browse files
authored
fix: Example code in README.md didn't work (#18)
The example code in the README was seemingly using old API (getter methods, rather than accessing properties directly) and querying a component version with no reported vulnerabilities. This patch fixs both issues so that the example code works. It also adds import statements so that the example can be copy/paste/run. Signed-off-by: Joshua Lock <[email protected]>
1 parent 552a93a commit 4bd60c9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,24 @@ OSS Index about. If you don't want to care about generating this list yourself,
5858

5959
As a quick test, you could run:
6060
```
61+
from ossindex.ossindex import OssIndex, PackageURL
62+
from ossindex.model import OssIndexComponent, Vulnerability
63+
6164
o = OssIndex()
6265
results: List[OssIndexComponent] = o.get_component_report(packages=[
63-
PackageURL.from_string(purl='pkg:pypi/pip@19.2.0')
66+
PackageURL.from_string(purl='pkg:pypi/pip@23.1.2')
6467
])
6568
for r in results:
66-
print("{}: {} known vulnerabilities".format(r.get_coordinates(), len(r.get_vulnerabilities())))
69+
print("{}: {} known vulnerabilities".format(r.coordinates, len(r.vulnerabilities)))
6770
v: Vulnerability
68-
for v in r.get_vulnerabilities():
71+
for v in r.vulnerabilities:
6972
print(' - {}'.format(str(v)))
7073
```
7174

7275
... which would output something like ...
7376
```
74-
pkg:pypi/pip@19.2.0: 1 known vulnerabilities
75-
- <Vulnerability id=e4c955a3-2004-472e-920b-783fea46c3cd, name=OSSINDEX-783f-ea46-c3cd, cvss_score=3.6>
77+
pkg:pypi/pip@23.1.2: 1 known vulnerabilities
78+
- <Vulnerability id=CVE-2018-20225, name=CVE-2018-20225, cvss_score=7.8>
7679
```
7780

7881
## Logging

0 commit comments

Comments
 (0)