cpe-search 0.1.4__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.
@@ -0,0 +1,47 @@
1
+ name: 'Publish Package to PyPI on New Release'
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ release:
6
+ types: [published]
7
+
8
+ jobs:
9
+ build:
10
+ name: Build package
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout repo
14
+ uses: actions/checkout@v4
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ cache: 'pip'
19
+ python-version: "3.10"
20
+ - name: Install Hatch
21
+ run: pip install hatch
22
+ - name: Build distributions
23
+ run: hatch build
24
+ - name: Upload dist as artifact
25
+ uses: actions/upload-artifact@v4
26
+ with:
27
+ name: dist
28
+ path: dist/
29
+
30
+ publish:
31
+ name: Publish to PyPI
32
+ needs: build
33
+ runs-on: ubuntu-latest
34
+ permissions:
35
+ id-token: write
36
+ steps:
37
+ - name: Checkout repo
38
+ uses: actions/checkout@v4
39
+ - name: Download built distributions
40
+ uses: actions/download-artifact@v5
41
+ with:
42
+ name: dist
43
+ path: dist/
44
+ - name: Publish to PyPI
45
+ uses: pypa/gh-action-pypi-publish@release/v1
46
+ with:
47
+ package-dir: dist/
@@ -0,0 +1,30 @@
1
+ name: 'Run Test Cases'
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+
7
+ jobs:
8
+ run-tests:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Checkout repo
12
+ uses: actions/checkout@v3
13
+ - name: Set up Python and Pip
14
+ uses: actions/setup-python@v4
15
+ with:
16
+ cache: 'pip'
17
+ python-version: '3.10'
18
+ - name: Upgrade Pip
19
+ run: python3 -m pip install --upgrade pip
20
+ - name: Install tool
21
+ run: pip install .
22
+ - name: Build CPE dictionary
23
+ env:
24
+ NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
25
+ run: NVD_API_KEY=$NVD_API_KEY cpe_search -u
26
+ - name: Test matching CPEs
27
+ run: python3 tests/test_cpes.py
28
+ # skip for now because of non-deterministic issues
29
+ # - name: Test CPE suggestions
30
+ # run: python3 tests/test_cpe_suggestions.py
@@ -0,0 +1,5 @@
1
+ cpe-search-dictionary.db3
2
+ deprecated-cpes.json
3
+ __pycache__/
4
+ .vscode
5
+ dist/
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+ This file keeps track of all notable changes between the different versions of cpe_search.
3
+
4
+ ## v0.1.4 - 2025-11-27
5
+ ### Fixed
6
+ - Fixed bug with `-` and `_` in queries preventing valid CPE matches
7
+
8
+ ## v0.1.3 - 2025-11-21
9
+ ### Fixed
10
+ - Skip retrieval of deprecatedBy CPEs if NVD's dictionary does not contain this data
11
+
12
+ ## v0.1.2 - 2025-11-18
13
+ ### Fixed
14
+ - GitHub workflow to publish PyPI package uses more recent action versions
15
+
16
+ ## v0.1.1 - 2025-11-18
17
+ ### Added
18
+ - GitHub workflow to automatically publish a package to PyPI on new release
19
+
20
+ ## v0.1.0 - 2025-11-17
21
+ ### Added
22
+ - Initial release
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2025 Dustin Born
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,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: cpe_search
3
+ Version: 0.1.4
4
+ Summary: Search for Common Platform Enumeration (CPE) strings using software names and titles.
5
+ Project-URL: Homepage, https://github.com/ra1nb0rn/cpe_search
6
+ Project-URL: Documentation, https://github.com/ra1nb0rn/cpe_search
7
+ Project-URL: Repository, https://github.com/ra1nb0rn/cpe_search
8
+ Project-URL: Issues, https://github.com/ra1nb0rn/cpe_search/issues
9
+ Author-email: Dustin Born <search.vulns1@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: cpe,enumeration,match,nvd,platform,search,software
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Information Technology
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: System :: Systems Administration
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: aiohttp
24
+ Requires-Dist: aiolimiter
25
+ Requires-Dist: requests
26
+ Requires-Dist: ujson
27
+ Provides-Extra: all
28
+ Requires-Dist: aiohttp; extra == 'all'
29
+ Requires-Dist: aiolimiter; extra == 'all'
30
+ Requires-Dist: mariadb==1.1.12; extra == 'all'
31
+ Requires-Dist: requests; extra == 'all'
32
+ Requires-Dist: ujson; extra == 'all'
33
+ Provides-Extra: dev
34
+ Requires-Dist: black; extra == 'dev'
35
+ Requires-Dist: isort; extra == 'dev'
36
+ Requires-Dist: pylint; extra == 'dev'
37
+ Requires-Dist: ruff; extra == 'dev'
38
+ Provides-Extra: mariadb
39
+ Requires-Dist: mariadb==1.1.12; extra == 'mariadb'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # cpe_search
43
+ Search for Common Platform Enumeration (CPE) strings using software names and titles.
44
+
45
+ ## About
46
+ *cpe_search* can be used to search for Common Platform Enumeration (CPE) strings using software names and titles. For example, if some tool discovered a web server running *Apache 2.4.39*, you can use this tool to easily and quickly retrieve the corresponding CPE 2.3 string *cpe:2.3:<zero-width space>a:apache:http_server:2.4.39:\*\:\*:\*:\*:\*:\*:\**. Thereafter, the retrieved CPE string can be used to accurately search for vulnerabilities, e.g. via the [Online NVD](https://nvd.nist.gov/) or the [search_vulns](https://github.com/ra1nb0rn/search_vulns) tool.
47
+
48
+ ## Installation
49
+ You can install cpe_search via pip directly:
50
+ ```
51
+ pip3 install cpe_search
52
+ ```
53
+ You can also clone this repository and run:
54
+ ```
55
+ pip3 install .
56
+ ```
57
+
58
+ Note that when *cpe_search* is used for the first time, it invokes a small setup routine that downloads all available CPEs from the [NVD's official API](https://nvd.nist.gov/developers/products) and precomputes the data utilized for searches in all subsequent runs. This may take a couple of minutes initially but is only done once. To speed this process up, you can provide an NVD API key if you have one (it's free). The API key can be provided with the ``-k`` argument or specified in an environment variable called ``NVD_API_KEY``. You can also set up and provide a configuration file, see `config.json`.
59
+
60
+ ## Usage
61
+ *cpe_search*'s usage information is shown in the following:
62
+ ```
63
+ usage: cpe_search [-h] [-u] [-k API_KEY] [-n NUMBER] [-q QUERY] [-v] [-c CONFIG]
64
+
65
+ Search for CPEs using software names and titles -- Created by Dustin Born (ra1nb0rn)
66
+
67
+ options:
68
+ -h, --help show this help message and exit
69
+ -u, --update Update the local CPE database
70
+ -k API_KEY, --api-key API_KEY
71
+ NVD API key to use for updating the local CPE dictionary
72
+ -n NUMBER, --number NUMBER
73
+ The number of CPEs to show in the similarity overview (default: 3)
74
+ -q QUERY, --query QUERY
75
+ A query, i.e. textual software name / title like 'Apache 2.4.39' or 'Wordpress 5.7.2'
76
+ -v, --verbose Be verbose and print status information
77
+ -c CONFIG, --config CONFIG
78
+ A config file to use (default: config.json)
79
+ ```
80
+ Note that when querying software with ``-q`` you have to put the software information in quotes if it contains any spaces. Also, you can use ``-q`` multiple times to make multiple queries at once. Moreover, the output can be piped to be directly useable with other tools. Here are some examples:
81
+ * Query *Sudo 1.8.2* to retrieve its CPE 2.3 string:
82
+ ```bash
83
+ $ cpe_search -q "Sudo 1.8.2"
84
+ cpe:2.3:a:sudo_project:sudo:1.8.2:*:*:*:*:*:*:*
85
+ [('cpe:2.3:a:sudo_project:sudo:1.8.2:*:*:*:*:*:*:*', 0.8660254037844385),
86
+ ('cpe:2.3:a:sudo_project:sudo:1.3.0:*:*:*:*:*:*:*', 0.5773502691896256),
87
+ ('cpe:2.3:a:cryptography.io:cryptography:1.8.2:*:*:*:*:*:*:*',
88
+ 0.4714045207910316)]
89
+ ```
90
+ * Make a query and pipe the retrieved CPE to another tool:
91
+ ```bash
92
+ $ cpe_search -q "Windows 10 1809" | xargs echo
93
+ cpe:2.3:o:microsoft:windows_10:1809:*:*:*:*:*:*:*
94
+ ```
95
+ * Make two queries at once:
96
+ ```bash
97
+ $ cpe_search -q "Apache 2.4.39" -q "Wordpress 5.7.2"
98
+ cpe:2.3:a:apache:http_server:2.4.39:*:*:*:*:*:*:*
99
+ [('cpe:2.3:a:apache:http_server:2.4.39:*:*:*:*:*:*:*', 0.6666664603674289),
100
+ ('cpe:2.3:a:apache:apache-airflow-providers-apache-spark:-:*:*:*:*:*:*:*',
101
+ 0.600000153741923),
102
+ ('cpe:2.3:a:apache:apache-airflow-providers-apache-hive:-:*:*:*:*:*:*:*',
103
+ 0.600000153741923)]
104
+
105
+ cpe:2.3:a:wordpress:wordpress:5.7.2:*:*:*:*:*:*:*
106
+ [('cpe:2.3:a:wordpress:wordpress:5.7.2:*:*:*:*:*:*:*', 0.9805804786431419),
107
+ ('cpe:2.3:a:wordpress:wordpress:-:*:*:*:*:*:*:*', 0.7071067811865475),
108
+ ('cpe:2.3:a:adenion:blog2social:5.7.2:*:*:*:*:wordpress:*:*',
109
+ 0.6859944446591075)]
110
+ ```
111
+
112
+ ## License
113
+ *cpe_search* is licensed under the MIT license, see [here](https://github.com/ra1nb0rn/cpe_search/blob/master/LICENSE).
@@ -0,0 +1,72 @@
1
+ # cpe_search
2
+ Search for Common Platform Enumeration (CPE) strings using software names and titles.
3
+
4
+ ## About
5
+ *cpe_search* can be used to search for Common Platform Enumeration (CPE) strings using software names and titles. For example, if some tool discovered a web server running *Apache 2.4.39*, you can use this tool to easily and quickly retrieve the corresponding CPE 2.3 string *cpe:2.3:<zero-width space>a:apache:http_server:2.4.39:\*\:\*:\*:\*:\*:\*:\**. Thereafter, the retrieved CPE string can be used to accurately search for vulnerabilities, e.g. via the [Online NVD](https://nvd.nist.gov/) or the [search_vulns](https://github.com/ra1nb0rn/search_vulns) tool.
6
+
7
+ ## Installation
8
+ You can install cpe_search via pip directly:
9
+ ```
10
+ pip3 install cpe_search
11
+ ```
12
+ You can also clone this repository and run:
13
+ ```
14
+ pip3 install .
15
+ ```
16
+
17
+ Note that when *cpe_search* is used for the first time, it invokes a small setup routine that downloads all available CPEs from the [NVD's official API](https://nvd.nist.gov/developers/products) and precomputes the data utilized for searches in all subsequent runs. This may take a couple of minutes initially but is only done once. To speed this process up, you can provide an NVD API key if you have one (it's free). The API key can be provided with the ``-k`` argument or specified in an environment variable called ``NVD_API_KEY``. You can also set up and provide a configuration file, see `config.json`.
18
+
19
+ ## Usage
20
+ *cpe_search*'s usage information is shown in the following:
21
+ ```
22
+ usage: cpe_search [-h] [-u] [-k API_KEY] [-n NUMBER] [-q QUERY] [-v] [-c CONFIG]
23
+
24
+ Search for CPEs using software names and titles -- Created by Dustin Born (ra1nb0rn)
25
+
26
+ options:
27
+ -h, --help show this help message and exit
28
+ -u, --update Update the local CPE database
29
+ -k API_KEY, --api-key API_KEY
30
+ NVD API key to use for updating the local CPE dictionary
31
+ -n NUMBER, --number NUMBER
32
+ The number of CPEs to show in the similarity overview (default: 3)
33
+ -q QUERY, --query QUERY
34
+ A query, i.e. textual software name / title like 'Apache 2.4.39' or 'Wordpress 5.7.2'
35
+ -v, --verbose Be verbose and print status information
36
+ -c CONFIG, --config CONFIG
37
+ A config file to use (default: config.json)
38
+ ```
39
+ Note that when querying software with ``-q`` you have to put the software information in quotes if it contains any spaces. Also, you can use ``-q`` multiple times to make multiple queries at once. Moreover, the output can be piped to be directly useable with other tools. Here are some examples:
40
+ * Query *Sudo 1.8.2* to retrieve its CPE 2.3 string:
41
+ ```bash
42
+ $ cpe_search -q "Sudo 1.8.2"
43
+ cpe:2.3:a:sudo_project:sudo:1.8.2:*:*:*:*:*:*:*
44
+ [('cpe:2.3:a:sudo_project:sudo:1.8.2:*:*:*:*:*:*:*', 0.8660254037844385),
45
+ ('cpe:2.3:a:sudo_project:sudo:1.3.0:*:*:*:*:*:*:*', 0.5773502691896256),
46
+ ('cpe:2.3:a:cryptography.io:cryptography:1.8.2:*:*:*:*:*:*:*',
47
+ 0.4714045207910316)]
48
+ ```
49
+ * Make a query and pipe the retrieved CPE to another tool:
50
+ ```bash
51
+ $ cpe_search -q "Windows 10 1809" | xargs echo
52
+ cpe:2.3:o:microsoft:windows_10:1809:*:*:*:*:*:*:*
53
+ ```
54
+ * Make two queries at once:
55
+ ```bash
56
+ $ cpe_search -q "Apache 2.4.39" -q "Wordpress 5.7.2"
57
+ cpe:2.3:a:apache:http_server:2.4.39:*:*:*:*:*:*:*
58
+ [('cpe:2.3:a:apache:http_server:2.4.39:*:*:*:*:*:*:*', 0.6666664603674289),
59
+ ('cpe:2.3:a:apache:apache-airflow-providers-apache-spark:-:*:*:*:*:*:*:*',
60
+ 0.600000153741923),
61
+ ('cpe:2.3:a:apache:apache-airflow-providers-apache-hive:-:*:*:*:*:*:*:*',
62
+ 0.600000153741923)]
63
+
64
+ cpe:2.3:a:wordpress:wordpress:5.7.2:*:*:*:*:*:*:*
65
+ [('cpe:2.3:a:wordpress:wordpress:5.7.2:*:*:*:*:*:*:*', 0.9805804786431419),
66
+ ('cpe:2.3:a:wordpress:wordpress:-:*:*:*:*:*:*:*', 0.7071067811865475),
67
+ ('cpe:2.3:a:adenion:blog2social:5.7.2:*:*:*:*:wordpress:*:*',
68
+ 0.6859944446591075)]
69
+ ```
70
+
71
+ ## License
72
+ *cpe_search* is licensed under the MIT license, see [here](https://github.com/ra1nb0rn/cpe_search/blob/master/LICENSE).
@@ -0,0 +1,82 @@
1
+ [build-system]
2
+ requires = ['hatchling']
3
+ build-backend = 'hatchling.build'
4
+
5
+ [project]
6
+ name = "cpe_search"
7
+ version = "0.1.4"
8
+ description = "Search for Common Platform Enumeration (CPE) strings using software names and titles."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ {name = "Dustin Born", email = "search.vulns1@gmail.com"}
14
+ ]
15
+ keywords = ["software", "cpe", "platform", "search", "nvd", "match", "enumeration"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Information Technology",
19
+ "Intended Audience :: System Administrators",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Topic :: Security",
25
+ "Topic :: System :: Systems Administration",
26
+ ]
27
+
28
+ dependencies = [
29
+ "aiohttp",
30
+ "aiolimiter",
31
+ "requests",
32
+ "ujson",
33
+ ]
34
+
35
+ [tool.hatch.build]
36
+ exclude = [
37
+ "src/cpe_search/deprecated_cpes.json",
38
+ "src/cpe_search/cpe-search-dictionary.db3",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ mariadb = [
43
+ "mariadb==1.1.12",
44
+ ]
45
+ dev = [
46
+ "black",
47
+ "isort",
48
+ "ruff",
49
+ "pylint",
50
+ ]
51
+ all = [
52
+ "aiohttp",
53
+ "aiolimiter",
54
+ "mariadb==1.1.12",
55
+ "requests",
56
+ "ujson",
57
+ ]
58
+
59
+ [project.scripts]
60
+ cpe_search = "cpe_search.cpe_search:main"
61
+
62
+ [project.urls]
63
+ Homepage = "https://github.com/ra1nb0rn/cpe_search"
64
+ Documentation = "https://github.com/ra1nb0rn/cpe_search"
65
+ Repository = "https://github.com/ra1nb0rn/cpe_search"
66
+ Issues = "https://github.com/ra1nb0rn/cpe_search/issues"
67
+
68
+ [tool.black]
69
+ line-length = 96
70
+ target-version = ['py311']
71
+
72
+ [tool.isort]
73
+ profile = "black"
74
+
75
+ [tool.ruff]
76
+ line-length = 96
77
+ target-version = "py311"
78
+ select = ["ALL"]
79
+ ignore = ["S104", "S201", "T201", "TRY201", "COM812", "E501", "TRY003", "EM101"]
80
+
81
+ [tool.pylint."FORMAT"]
82
+ max-line-length = 96
File without changes
@@ -0,0 +1,10 @@
1
+ {
2
+ "DEPRECATED_CPES_FILE": "deprecated-cpes.json",
3
+ "NVD_API_KEY": "",
4
+ "CPE_SEARCH_COUNT": 6,
5
+ "CPE_SEARCH_THRESHOLD": -1,
6
+ "DATABASE": {
7
+ "NAME": "cpe-search-dictionary.db3",
8
+ "TYPE": "sqlite"
9
+ }
10
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "DEPRECATED_CPES_FILE": "deprecated-cpes.json",
3
+ "NVD_API_KEY": "",
4
+ "CPE_SEARCH_COUNT": 6,
5
+ "CPE_SEARCH_THRESHOLD": -1,
6
+ "DATABASE": {
7
+ "NAME": "cpe_search_dictionary",
8
+ "TYPE": "mariadb",
9
+ "HOST": "localhost",
10
+ "USER": "search_vulns",
11
+ "PASSWORD": "",
12
+ "PORT": 3306
13
+ }
14
+ }