Skip to content

Commit 07e3ea4

Browse files
committed
v0.6.0 - Spring 2020 cleanup, added back more methods
1 parent 3d7c8af commit 07e3ea4

File tree

6 files changed

+226
-45
lines changed

6 files changed

+226
-45
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.DS_Store
22
*.pyc
3-
*.sqlite

README.md

+183-14
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,226 @@
33
[![PyPi Version](http://img.shields.io/pypi/v/ares.svg)](https://pypi.python.org/pypi/ares/)
44

55
**ares** is an APACHE licensed library written in Python providing an easy to use wrapper around https://cve.circl.lu.
6-
This library has been tested with Python 2.7.x and Python 3.6.x.
6+
This library has been tested with Python 2.7.x and Python 3.6+.
77

88
## Installation:
99

1010
From source use
1111

12-
$ python setup.py install
12+
```bash
13+
$ python setup.py install
14+
```
1315

1416
or install from PyPi
1517

16-
$ pip install ares
18+
```bash
19+
$ pip install ares
20+
```
1721

1822
## Documentation:
1923

20-
- **`GET /api/browse/`**
21-
- **`GET /api/browse/vendor`**
24+
#### **`GET /api/browse`**
25+
#### **`GET /api/browse/<vendor>`**
26+
27+
##### Description
28+
29+
Returns a list of vendors or products of a specific vendor.
30+
This API call can be used in two ways; With or without the vendor.
31+
When the link is called without a vendor, it will return a list of possible vendors.
32+
When the link is called with a vendor, it enumerates the products for said vendor.
33+
34+
| Argument | Description | Example |
35+
| :-------------------| :------------------ | :------------------- |
36+
| vendor | Vendor name | `microsoft` |
2237

2338
```python
2439
>>> from ares import CVESearch
2540
>>> cve = CVESearch()
26-
>>> cve.browse(<vendor>)
41+
>>> cve.browse('microsoft')
42+
```
43+
44+
<br/>
45+
46+
#### **`GET /api/capec/<cpe> `**
47+
48+
##### Description
49+
50+
Outputs a list of CAPEC related to a CWE.
51+
CAPEC (Common Attack Pattern Enumeration and Classification) are a list of attack types commonly used by attackers.
52+
53+
| Argument | Description | Example |
54+
| :-------------------| :------------------ | :------------------- |
55+
| cweid | CWE ID | `200` |
56+
57+
58+
```python
59+
>>> cve.capec('200')
2760
```
2861

29-
- **`GET /api/search/vendor/product`**
62+
<br/>
63+
64+
#### **`GET /api/cpe2.2/<cpe> `**
65+
66+
##### Description
67+
68+
**DISABLED ON cve.circl.lu**
69+
70+
Converts a CPE code to the CPE2.2 standard, stripped of appendices.
71+
CPE2.2 is the old standard, and is a lot less uniform than the CPE2.3 standard.
72+
73+
| Argument | Description | Example |
74+
| :-------------------| :---------------------------------- | :--------------------------------------------------------------------- |
75+
| cpe | CPE code in cpe2.2 or cpe2.3 format | `cpe:2.3:o:microsoft:windows_vista:6.0:sp1:-:-:home_premium:-:-:x64:-` |
3076

3177
```python
32-
>>> cve.search('microsoft/office')
78+
>>> cve.cpe22('cpe:2.3:a:microsoft:office:2011:-:mac')
3379
```
3480

35-
- **`GET /api/cveid/cveid`**
81+
<br/>
82+
83+
#### **`GET /api/cpe2.3/<cpe> `**
84+
85+
##### Description
86+
87+
**DISABLED ON cve.circl.lu**
88+
89+
Converts a CPE code to the CPE2.3 standard, stripped of appendices.
90+
CPE2.3 is the newer standard, and is a lot more uniform and easier to read than the CPE2.2 standard.
91+
92+
| Argument | Description | Example |
93+
| :-------------------| :---------------------------------- | :--------------------------------------------------------------- |
94+
| cpe | CPE code in cpe2.2 or cpe2.3 format | `cpe:/o:microsoft:windows_vista:6.0:sp1:~-~home_premium~-~x64~-` |
95+
96+
```python
97+
>>> cve.cpe23('cpe:/a:microsoft:office:2011::mac')
98+
```
99+
100+
<br/>
101+
102+
#### **`GET /api/cve/<cveid>`**
103+
104+
##### Description
105+
106+
Outputs all available information for the specified CVE (Common Vulnerability and Exposure), in JSON format.
107+
This information includes basic CVE information like CVSS (Common Vulnerability Scoring System), related CPE (Common Product Enumeration),
108+
CWE (Common Weakness Enumeration), ... as well as additional information (RedHat Advisories etc).
109+
110+
| Argument | Description | Example |
111+
| :-------------------| :-------------------- | :----------------------- |
112+
| cveid | CVE number | `CVE-2014-0160` |
113+
114+
```python
115+
>>> cve.cve('CVE-2014-0160')
116+
```
117+
118+
<br/>
119+
120+
#### **`GET /api/cvefor/<cpe> `**
121+
122+
##### Description
123+
124+
**DISABLED ON cve.circl.lu**
125+
126+
Outputs a list of CVEs related to the product.
127+
128+
| Argument | Description | Example |
129+
| :-------------------| :---------------------------------- | :--------------------------------------------------------------- |
130+
| cpe | CPE code in cpe2.2 or cpe2.3 format | `cpe:/o:microsoft:windows_vista:6.0:sp1:~-~home_premium~-~x64~-` |
131+
36132

37133
```python
38-
>>> cve.id('CVE-2014-0160')
134+
>>> cve.cvefor('cpe:/o:microsoft:windows_vista:6.0:sp1:~-~home_premium~-~x64~-')
39135
```
40136

41-
- **`GET /api/last`**
137+
<br/>
138+
139+
#### **`GET /api/cwe `**
140+
141+
##### Description
142+
143+
Outputs a list of all CWEs (Common Weakness Enumeration).
42144

43145
```python
44-
>>> cve.last()
146+
>>> cve.cwe()
45147
```
46148

47-
- **`GET /api/dbInfo`**
149+
<br/>
150+
151+
#### **`GET /api/dbInfo`**
152+
153+
##### Description
154+
155+
Returns the stats of the database. When the user authenticates, more information is returned. This information includes:
156+
157+
Amount of whitelist and blacklist records
158+
Some server settings like the database name
159+
Some database information like disk usage
160+
161+
Unauthenticated queries return only collection information.
162+
163+
**Note: as of April 2020, authentication is disabled on cve.circl.lu.**
48164

49165
```python
50166
>>> cve.dbinfo()
51167
```
52168

169+
<br/>
170+
171+
#### **`GET /api/last`**
172+
#### **`GET /api/last/<limit>`**
173+
174+
##### Description
175+
176+
Outputs the last `n` amount of vulnerabilities. If the limit is not specified, the default of 30 is used.
177+
178+
| Argument | Description | Example |
179+
| :-------------------| :---------------------------------- | :--------------------- |
180+
| limit | The amount of CVEs to display | `10` |
181+
182+
```python
183+
>>> cve.last('10')
184+
```
185+
186+
<br/>
187+
188+
#### **`GET /api/search/link/<key>/<value>`**
189+
190+
##### Description
191+
192+
Returns all CVEs that are linked by a given key/value pair.
193+
194+
| Argument | Description | Example |
195+
| :-------------------| :---------------------------------- | :-------------------------- |
196+
| key | The key to link CVEs on | `msbulletin.bulletin_id` |
197+
| value | The value for the given key | `MS16-098` |
198+
199+
```python
200+
>>> cve.link('msbulletin.bulletin_id/MS16-098')
201+
```
202+
203+
<br/>
204+
205+
#### **`GET /api/search/<vendor>/<product>`**
206+
207+
##### Description
208+
209+
**DISABLED ON cve.circl.lu**
210+
211+
When vendor and product are specified, this API call returns a list of CVEs related to the product. The output of the browse call can be used for this.
212+
213+
| Argument | Description | Example |
214+
| :-------------------| :---------------------------------- | :-------------------------- |
215+
| vendor | Vendor name | `microsoft` |
216+
| product | Product name | `office` |
217+
218+
```python
219+
>>> cve.search('microsoft/office')
220+
```
221+
53222
## License:
54223

55224
```
56-
Copyright 2014-2018 Martin Simon
225+
Copyright 2014-2020 Martin Simon
57226
58227
Licensed under the Apache License, Version 2.0 (the "License");
59228
you may not use this file except in compliance with the License.

ares/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
__title__ = 'ares'
5-
__version__ = '0.5'
5+
__version__ = '0.6.0'
66
__author__ = 'Martin Simon <[email protected]>'
77
__repo__ = 'https://github.com/barnumbirr/ares'
88
__license__ = 'Apache v2.0 License'

ares/core.py

+39-23
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
import json
55
import requests
6-
from requests.compat import urljoin
76

87
class CVESearch(object):
98

109
_session = None
11-
__DEFAULT_BASE_URL = 'https://cve.circl.lu/api/'
10+
__DEFAULT_BASE_URL = "https://cve.circl.lu/api/"
1211
__DEFAULT_TIMEOUT = 120
1312

1413
def __init__(self, base_url = __DEFAULT_BASE_URL, request_timeout = __DEFAULT_TIMEOUT):
@@ -21,11 +20,16 @@ def session(self):
2120
self._session = requests.Session()
2221
self._session.headers.update({'Content-Type': 'application/json'})
2322
self._session.headers.update({'User-agent': 'ares - python wrapper \
24-
around cve.circl.lu (github.com/mrsmn/ares)'})
23+
around cve.circl.lu (github.com/barnumbirr/ares)'})
2524
return self._session
2625

2726
def __request(self, endpoint, query):
28-
response_object = self.session.get(requests.compat.urljoin(self.base_url + endpoint, query),
27+
# There is probably a more elegant way to do this ¯\_(ツ)_/¯
28+
if query:
29+
response_object = self.session.get(requests.compat.urljoin(self.base_url, endpoint + query),
30+
timeout = self.request_timeout)
31+
else:
32+
response_object = self.session.get(requests.compat.urljoin(self.base_url, endpoint),
2933
timeout = self.request_timeout)
3034

3135
try:
@@ -36,35 +40,47 @@ def __request(self, endpoint, query):
3640
return response
3741

3842
def browse(self, param=None):
39-
""" browse() returns a dict containing all the vendors
40-
browse(vendor) returns a dict containing all the products
41-
associated to a vendor
42-
"""
4343
response = self.__request('browse/', query=param)
4444
return response
4545

46-
def search(self, param):
47-
""" search() returns a dict containing all the vulnerabilities per
48-
vendor and a specific product
49-
"""
50-
response = self.__request('search/', query=param)
46+
def capec(self, param):
47+
response = self.__request('capec/', query=param)
5148
return response
5249

53-
def id(self, param):
54-
""" id() returns a dict containing a specific CVE ID """
50+
# def cpe22(self, param):
51+
# response = self.__request('cpe2.2/', query=param)
52+
# return response
53+
54+
55+
# def cpe23(self, param):
56+
# response = self.__request('cpe2.3/', query=param)
57+
# return response
58+
59+
def cve(self, param):
5560
response = self.__request('cve/', query=param)
5661
return response
5762

58-
def last(self):
59-
""" last() returns a dict containing the last 30 CVEs including CAPEC,
60-
CWE and CPE expansions
61-
"""
62-
response = self.__request('last/', query=None)
63+
# def cvefor(self, param):
64+
# response = self.__request('cvefor/', query=param)
65+
# return response
66+
67+
def cwe(self):
68+
""" Outputs a list of all CWEs (Common Weakness Enumeration). """
69+
response = self.__request('cwe', query=None)
6370
return response
6471

6572
def dbinfo(self):
66-
""" dbinfo() returns a dict containing more information about
67-
the current databases in use and when it was updated
68-
"""
6973
response = self.__request('dbInfo', query=None)
7074
return response
75+
76+
def last(self, param):
77+
response = self.__request('last/', query=param)
78+
return response
79+
80+
def link(self, param):
81+
response = self.__request('link/', query=param)
82+
return response
83+
84+
# def search(self, param):
85+
# response = self.__request('search/', query=param)
86+
# return response

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
requests==2.20.0
1+
requests==2.23.0

setup.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
setup(
2020
name='ares',
2121
packages = ['ares'],
22-
version = '0.5',
22+
version = '0.6.0',
2323
description = 'Python wrapper around https://cve.circl.lu.',
2424
author = 'Martin Simon',
2525
author_email = '[email protected]',
@@ -29,17 +29,14 @@
2929
'Buy me a coffee': 'https://github.com/barnumbirr/ares#buy-me-a-coffee',
3030
},
3131
license = 'Apache v2.0 License',
32-
install_requires=[
33-
'requests>=2.18.4'
34-
],
3532
keywords=['CVE', 'cybersecurity', 'vulnerability', 'circl.lu'],
3633
classifiers=[
3734
'License :: OSI Approved :: Apache Software License',
3835
'Development Status :: 5 - Production/Stable',
3936
'Intended Audience :: Developers',
4037
'Programming Language :: Python',
4138
'Programming Language :: Python :: 2.7',
42-
'Programming Language :: Python :: 3.6',
39+
'Programming Language :: Python :: 3.7',
4340
'Topic :: Software Development :: Libraries :: Python Modules',
4441
],
4542
long_description = long_description,

0 commit comments

Comments
 (0)