Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite backend #107

Merged
merged 26 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
756ce39
Fixes for CVE 5 conversion
prabhu Mar 14, 2024
57aa5e7
Remove sync option
prabhu Mar 17, 2024
dbe2a41
Set user interaction
prabhu Mar 17, 2024
2e58175
Convert to abspath
prabhu Mar 17, 2024
96932e4
Convert to CVE model
prabhu Mar 17, 2024
2a09c69
lint fixes
prabhu Mar 17, 2024
1e897d6
Added search by cve and stats method
prabhu Mar 18, 2024
451f7dd
Added search by cve and stats method
prabhu Mar 18, 2024
79d27df
Improve insert performance
prabhu Mar 18, 2024
4f09d8c
Use apsw to force sqlite version and switch to jsonb for improved per…
prabhu Mar 18, 2024
5ddd450
nested transaction is not supported
prabhu Mar 18, 2024
8f5a7e6
Add new vdb.lib.cve_model package to pyproject.toml, remove tests fro…
cerrussell Mar 19, 2024
ffe8bc5
Review comments
prabhu Mar 19, 2024
c0a041d
Reduce duplicates
prabhu Mar 19, 2024
0ce408a
lint fixes
prabhu Mar 19, 2024
54a4234
test with auto vacuum
prabhu Mar 19, 2024
6dc099c
go back to json which is surprisingly more efficient than blob
prabhu Mar 19, 2024
ef3f49a
go back to blob
prabhu Mar 19, 2024
eef7ce0
Remove incorrect provider metadata
prabhu Mar 19, 2024
aeeb38c
Revert removal of provider metadata
prabhu Mar 19, 2024
3b040e7
Adds a new purl prefix column to the index to assist with purl based …
prabhu Mar 19, 2024
8d5c5f1
Added git osv source
prabhu Mar 19, 2024
bcc25da
Bug fix
prabhu Mar 19, 2024
f5090cb
Create more aliases based on git url in references
prabhu Mar 19, 2024
7eb8cb2
Improve ghsa parsing
prabhu Mar 19, 2024
1208355
Bug fixes
prabhu Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pip install appthreat-vulnerability-db

## Usage

This package is ideal as a library for managing vulnerabilities. This is used by [dep-scan](http://github.com/AppThreat/dep-scan), a free open-source dependency audit tool. However, there is a limited cli capability available with few features to test this tool directly.
This package is ideal as a library for managing vulnerabilities. This is used by [owasp-dep-scan](http://github.com/owasp-dep-scan/dep-scan), a free open-source dependency audit tool. However, there is a limited cli capability available with few features to test this tool directly.

### Download pre-built database

Expand All @@ -52,23 +52,23 @@ oras pull ghcr.io/appthreat/vdb:v5 -o $VDB_HOME

Cache application vulnerabilities

```bash
```shell
prabhu marked this conversation as resolved.
Show resolved Hide resolved
vdb --cache
```

Typical size of this database is over 1.1 GB.

Cache application and OS vulnerabilities

```bash
```shell
vdb --cache-os
```

Note the size of the database with OS vulnerabilities is over 3.1 GB.

Cache from just [OSV](https://osv.dev)

```bash
```shell
vdb --cache --only-osv
```

Expand All @@ -77,31 +77,24 @@ It is possible to customise the cache behaviour by increasing the historic data
- NVD_START_YEAR - Default: 2018. Supports upto 2002
- GITHUB_PAGE_COUNT - Default: 2. Supports upto 20

### Periodic sync

To periodically sync the latest vulnerabilities and update the database cache.

```bash
vdb --sync
```

### Basic search

It is possible to perform simple search using the cli.

```bash
vdb --search android:8.0

vdb --search google:android:8.0

vdb --search android:8.0,simplesamlphp:1.14.11

```shell
vdb --search pkg:pypi/[email protected]

# Full url and short form for swift
vdb --search "pkg:swift/github.com/vapor/[email protected]"

vdb --search "pkg:swift/vapor/[email protected]"
```

Syntax is package:version,package:version or vendor : package : version (Without space)
# Search by cpe
vdb --search "cpe:2.3:a:npm:gitblame:*:*:*:*:*:*:*:*"

# Search by colon separated values
vdb --search "npm:gitblame:0.0.1"

# Search by CVE id
vdb --search CVE-2024-25169
```
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[project]
name = "appthreat-vulnerability-db"
version = "6.0.0"
description = "AppThreat's vulnerability database and package search library with a built-in file based storage. OSV, CVE, GitHub, npm are the primary sources of vulnerabilities."
description = "AppThreat's vulnerability database and package search library with a built-in sqlite based storage. OSV, CVE, GitHub, npm are the primary sources of vulnerabilities."
authors = [
{name = "Team AppThreat", email = "[email protected]"},
]
dependencies = [
"httpx[http2]",
"appdirs",
"tabulate",
"msgpack==1.0.5",
"orjson",
"semver>=3.0.0",
"packageurl-python",
"cvss",
"pydantic[email]"
"pydantic[email]",
"rich",
"apsw>=3.45.2.0"
]
requires-python = ">=3.10"
readme = "README.md"
Expand Down Expand Up @@ -47,12 +47,13 @@ dev = [
"black",
"bandit",
"flake8",
"pylint",
"pytest",
"pytest-cov"
]

[tool.setuptools]
packages = ["test", "vdb", "vdb.lib"]
packages = ["vdb", "vdb.lib", "vdb.lib.cve_model"]
prabhu marked this conversation as resolved.
Show resolved Hide resolved

[tool.pytest.ini_options]
addopts="--showlocals -v --cov-report=term-missing --no-cov-on-fail --cov vdb"
Expand Down
95 changes: 95 additions & 0 deletions test/data/CVE-2023-52426.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"id": "CVE-2023-52426",
"sourceIdentifier": "[email protected]",
"published": "2024-02-04T20:15:46.120",
"lastModified": "2024-02-09T02:02:39.800",
"vulnStatus": "Analyzed",
"descriptions": [
{
"lang": "en",
"value": "libexpat through 2.5.0 allows recursive XML Entity Expansion if XML_DTD is undefined at compile time."
},
{
"lang": "es",
"value": "libexpat hasta 2.5.0 permite la expansión recursiva de entidades XML si XML_DTD no está definido en el momento de la compilación."
}
],
"metrics": {
"cvssMetricV31": [
{
"source": "[email protected]",
"type": "Primary",
"cvssData": {
"version": "3.1",
"vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
"attackVector": "LOCAL",
"attackComplexity": "LOW",
"privilegesRequired": "LOW",
"userInteraction": "NONE",
"scope": "UNCHANGED",
"confidentialityImpact": "NONE",
"integrityImpact": "NONE",
"availabilityImpact": "HIGH",
"baseScore": 5.5,
"baseSeverity": "MEDIUM"
},
"exploitabilityScore": 1.8,
"impactScore": 3.6
}
]
},
"weaknesses": [
{
"source": "[email protected]",
"type": "Primary",
"description": [
{
"lang": "en",
"value": "CWE-776"
}
]
}
],
"configurations": [
{
"nodes": [
{
"operator": "OR",
"negate": false,
"cpeMatch": [
{
"vulnerable": true,
"criteria": "cpe:2.3:a:libexpat_project:libexpat:*:*:*:*:*:*:*:*",
"matchCriteriaId": "1C50909D-8A18-484B-A7DB-7EF4CA67C2CB",
"versionEndIncluding": "2.5.0"
}
]
}
]
}
],
"references": [
{
"url": "https://cwe.mitre.org/data/definitions/776.html",
"source": "[email protected]",
"tags": [
"Technical Description"
]
},
{
"url": "https://github.com/libexpat/libexpat/commit/0f075ec8ecb5e43f8fdca5182f8cca4703da0404",
"source": "[email protected]",
"tags": [
"Patch",
"Vendor Advisory"
]
},
{
"url": "https://github.com/libexpat/libexpat/pull/777",
"source": "[email protected]",
"tags": [
"Vendor Advisory"
]
}
]
}
Loading
Loading