1{ lib
2, appdirs
3, buildPythonPackage
4, cvss
5, fetchFromGitHub
6, httpx
7, msgpack
8, orjson
9, packageurl-python
10, pytestCheckHook
11, pythonOlder
12, pythonRelaxDepsHook
13, semver
14, tabulate
15}:
16
17buildPythonPackage rec {
18 pname = "appthreat-vulnerability-db";
19 version = "5.1.1";
20 format = "setuptools";
21
22 disabled = pythonOlder "3.7";
23
24 src = fetchFromGitHub {
25 owner = "AppThreat";
26 repo = "vulnerability-db";
27 rev = "refs/tags/v${version}";
28 hash = "sha256-lbaDoLEOMzMGwqBx6gBynVpXz/NM/uCJELwd4d1IEwk=";
29 };
30
31 postPatch = ''
32 substituteInPlace pytest.ini \
33 --replace " --cov-append --cov-report term --cov vdb" ""
34 # https://github.com/AppThreat/vulnerability-db/pull/48
35 substituteInPlace vdb/lib/utils.py \
36 --replace "isvalid(" "is_valid("
37 '';
38
39 pythonRelaxDeps = [
40 "semver"
41 ];
42
43 nativeBuildInputs = [
44 pythonRelaxDepsHook
45 ];
46
47 propagatedBuildInputs = [
48 appdirs
49 cvss
50 httpx
51 msgpack
52 orjson
53 packageurl-python
54 semver
55 tabulate
56 ] ++ httpx.optional-dependencies.http2;
57
58 nativeCheckInputs = [
59 pytestCheckHook
60 ];
61
62 preCheck = ''
63 export HOME=$(mktemp -d);
64 '';
65
66 disabledTests = [
67 # Tests require network access
68 "test_bulk_search"
69 "test_download_recent"
70 ];
71
72 pythonImportsCheck = [
73 "vdb"
74 ];
75
76 meta = with lib; {
77 description = "Vulnerability database and package search for sources such as OSV, NVD, GitHub and npm";
78 homepage = "https://github.com/appthreat/vulnerability-db";
79 changelog = "https://github.com/AppThreat/vulnerability-db/releases/tag/v${version}";
80 license = with licenses; [ mit ];
81 maintainers = with maintainers; [ fab ];
82 };
83}