|
| 1 | +# NIST |
| 2 | + |
| 3 | +The NIST utility is used for functionality based around NIST DB Queries, and is primarily used to create URLs for the API based queries. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +In order to use the URLs generated by `netutils.nist.get_nist_urls*`, you will need an api key provided by NIST [here]('https://nvd.nist.gov/developers/request-an-api-key'). This key will need to be passed in as an additional header in your request in the form of `{"apiKey": "<key_value>"}` as stated by NIST in their [Getting Started]('https://nvd.nist.gov/developers/start-here') section. |
| 8 | + |
| 9 | + |
| 10 | +## Custom URLs |
| 11 | + |
| 12 | +The largest caveat in this functionality is the consistency of the URL values needed to obtain the CVE information. NIST NVD has specific parameters that can be used for standardization, however this does not mean that entries are standardized. Manually combing through a large amount of CPE Vendor submissions has shown that there are variations in how CPE Vendor data is presented. |
| 13 | + |
| 14 | +For this reason, for certain Vendor/OS combinations, a custom URL needs to be built. |
| 15 | +- **Cisco IOS CPE String** - `cpe:2.3:o:cisco:ios:15.5\\(2\\)s1c:*` |
| 16 | + - `15.5\\(2\\)s1c:*` - As seen here, Cisco uses CPE strings that do not include the `:` delimiter, which can be queried using escape characters in the search string. **This is the format of ALL "generic" OS/Other platforms that do not have their own custom NIST URL builder when querying NIST.** |
| 17 | + - Default URL Output - `'https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:o:cisco:ios:15.5\\(2\\)s1c:*'` |
| 18 | + |
| 19 | +- **Juniper JunOS CPE String** - `cpe:2.3:o:juniper:junos:10.2:r2:*:*:*:*:*:*` |
| 20 | + - `10.2:r2:*:*:*:*:*:*` - As noted here, one of the provided URLs to query for this Juniper JunOS OS platform includes additional values that follow NIST delimiter structures. In the case where the parser provides multiple URLs, they will both be evaluated and the CVE from both will be added and associated. |
| 21 | + - Custom URL Output - `['https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:o:juniper:junos:10.2r2:*:*:*:*:*:*:*', 'https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:o:juniper:junos:10.2:r2:*:*:*:*:*:*']` |
| 22 | + |
| 23 | + |
| 24 | +## Examples |
| 25 | +Here are a few examples showing how to use this in your python code. |
| 26 | + |
| 27 | +```python |
| 28 | + |
| 29 | +from netutils.nist import get_nist_urls |
| 30 | + |
| 31 | +# Get NIST URL for the Cisco IOS object |
| 32 | +get_nist_urls("cisco_ios", "15.5(2)S1c") |
| 33 | +# ['https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:o:cisco:ios:15.5\\(2\\)s1c:*'] |
| 34 | + |
| 35 | +# Get NIST URL(s) for the Juniper JunOS object |
| 36 | +get_nist_urls("juniper_junos", "10.2R2.11") |
| 37 | +# ['https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:o:juniper:junos:10.2r2:*:*:*:*:*:*:*', 'https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:o:juniper:junos:10.2:r2:*:*:*:*:*:*'] |
| 38 | +``` |
| 39 | + |
| 40 | +Currently known OS/Other Platform types that require a custom NIST URL: |
| 41 | + |
| 42 | +- Juniper JunOS |
0 commit comments