Skip to content

Commit 0caf64e

Browse files
Merge pull request #546 from networktocode/develop
Merge 1.9.0 into main
2 parents b1bdf00 + 43fabf0 commit 0caf64e

22 files changed

+845
-3
lines changed

development_scripts.py

100644100755
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@
7171
"_dict": lib_mapper.CAPIRCA_LIB_MAPPER_REVERSE,
7272
"_file": "docs/user/lib_mapper/capirca_reverse.md",
7373
},
74+
"dna_center": {
75+
"header_src": "DNA_CENTER",
76+
"header_dst": "NORMALIZED",
77+
"_dict": lib_mapper.DNA_CENTER_LIB_MAPPER,
78+
"_file": "docs/user/lib_mapper/dna_center.md",
79+
},
80+
"dna_center_reverse": {
81+
"header_src": "NORMALIZED",
82+
"header_dst": "DNA_CENTER",
83+
"_dict": lib_mapper.DNA_CENTER_LIB_MAPPER_REVERSE,
84+
"_file": "docs/user/lib_mapper/dna_center_reverse.md",
85+
},
7486
"forwardnetworks": {
7587
"header_src": "FORWARDNETWORKS",
7688
"header_dst": "NORMALIZED",
@@ -131,6 +143,18 @@
131143
"_dict": lib_mapper.NETUTILSPARSER_LIB_MAPPER_REVERSE,
132144
"_file": "docs/user/lib_mapper/netutilsparser_reverse.md",
133145
},
146+
"nist": {
147+
"header_src": "NIST",
148+
"header_dst": "NORMALIZED",
149+
"_dict": lib_mapper.NIST_LIB_MAPPER,
150+
"_file": "docs/user/lib_mapper/nist.md",
151+
},
152+
"nist_reverse": {
153+
"header_src": "NORMALIZED",
154+
"header_dst": "NIST",
155+
"_dict": lib_mapper.NIST_LIB_MAPPER_REVERSE,
156+
"_file": "docs/user/lib_mapper/nist_reverse.md",
157+
},
134158
"ntctemplates": {
135159
"header_src": "NTCTEMPLATES",
136160
"header_dst": "NORMALIZED",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# v1.9 Release Notes
2+
3+
## Release Overview
4+
5+
- Added NIST URL creation and platform mapper.
6+
- Added DNA Center platform mappings.
7+
- Improved error message when duplicate line is parsed.
8+
9+
## [v1.9.0] 2024-07
10+
11+
### Added
12+
13+
- [489](https://github.com/networktocode/netutils/pull/489) Added NIST URL creation and platform mapper.
14+
- [519](https://github.com/networktocode/netutils/pull/519) Added DNA Center forward and reverse platform mappings.
15+
16+
### Changed
17+
18+
- [539](https://github.com/networktocode/netutils/pull/539) Provide more descriptive error message when duplicate line is parsed.

docs/dev/code_reference/nist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# NIST URLs
2+
3+
::: netutils.nist
4+
options:
5+
show_submodules: True

docs/user/include_jinja_list.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@
6060
| mac_to_format | netutils.mac.mac_to_format |
6161
| mac_to_int | netutils.mac.mac_to_int |
6262
| mac_type | netutils.mac.mac_type |
63+
| get_nist_urls | netutils.nist.get_nist_urls |
64+
| get_nist_vendor_platform_urls | netutils.nist.get_nist_vendor_platform_urls |
6365
| compare_version_loose | netutils.os_version.compare_version_loose |
6466
| compare_version_strict | netutils.os_version.compare_version_strict |
6567
| get_upgrade_path | netutils.os_version.get_upgrade_path |
68+
| version_metadata | netutils.os_version.version_metadata |
6669
| compare_cisco_type5 | netutils.password.compare_cisco_type5 |
6770
| compare_cisco_type7 | netutils.password.compare_cisco_type7 |
6871
| compare_cisco_type9 | netutils.password.compare_cisco_type9 |

docs/user/lib_mapper/dna_center.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| DNA_CENTER | | NORMALIZED |
2+
| ---------- | -- | ------ |
3+
| IOS || cisco_ios |
4+
| IOS-XE || cisco_ios |
5+
| IOS-XR || cisco_xr |
6+
| NX-OS || cisco_nxos |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| NORMALIZED | | DNA_CENTER |
2+
| ---------- | -- | ------ |
3+
| cisco_ios || IOS |
4+
| cisco_nxos || NX-OS |
5+
| cisco_xr || IOS-XR |

docs/user/lib_mapper/nist.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| NIST | | NORMALIZED |
2+
| ---------- | -- | ------ |
3+
| adaptive_security_appliance_software || cisco_asa |
4+
| eos || arista_eos |
5+
| ios || cisco_ios |
6+
| ios_xe || cisco_xe |
7+
| ios_xr || cisco_xr |
8+
| junos || juniper_junos |
9+
| nx-os || cisco_nxos |

docs/user/lib_mapper/nist_reverse.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| NORMALIZED | | NIST |
2+
| ---------- | -- | ------ |
3+
| arista_eos || eos |
4+
| cisco_asa || adaptive_security_appliance_software |
5+
| cisco_ios || ios |
6+
| cisco_nxos || nx-os |
7+
| cisco_xe || ios_xe |
8+
| cisco_xr || ios_xr |
9+
| juniper_junos || junos |

docs/user/lib_use_cases.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Functions are grouped with like functions, such as IP or MAC address based funct
2121
- Library Helpers - Provides helpers to pull useful information, e.g. NAPALM getters.
2222
- Library Mapper - Provides mappings in expected vendor names between Netmiko, NAPALM, pyntc, ntc-templates, pyats, and scrapli.
2323
- MAC Address - Provides the ability to work with MAC addresses such as validating or converting to integer.
24+
- NIST - Provides the ability to obtain a URL formatted for NIST CPE Query.
2425
- OS Version - Provides the ability to work with OS version, such as defining an upgrade path.
2526
- Password - Provides the ability to compare and encrypt common password schemas such as type5 and type7 Cisco passwords.
2627
- Ping - Provides the ability to ping, currently only tcp ping.

docs/user/lib_use_cases_nist.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Comments
 (0)