Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/user/lib_mapper/nist.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
| cisco:ios_xe | → | cisco_xe |
| cisco:ios_xr | → | cisco_xr |
| cisco:nx-os | → | cisco_nxos |
| hpe:arubaos-cx | → | aruba_aoscx |
| juniper:junos | → | juniper_junos |
| paloaltonetworks:pan-os | → | paloalto_panos |
| paloaltonetworks:pan-os | → | paloalto_panos |
3 changes: 2 additions & 1 deletion docs/user/lib_mapper/nist_reverse.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
| NORMALIZED | | NIST |
| ---------- | -- | ------ |
| arista_eos | → | arista:eos |
| aruba_aoscx | → | hpe:arubaos-cx |
| aruba_os | → | arubanetworks:arubaos |
| cisco_asa | → | cisco:adaptive_security_appliance_software |
| cisco_ios | → | cisco:ios |
| cisco_nxos | → | cisco:nx-os |
| cisco_xe | → | cisco:ios_xe |
| cisco_xr | → | cisco:ios_xr |
| juniper_junos | → | juniper:junos |
| paloalto_panos | → | paloaltonetworks:pan-os |
| paloalto_panos | → | paloaltonetworks:pan-os |
4 changes: 3 additions & 1 deletion netutils/lib_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,10 @@
"arubanetworks:arubaos": "aruba_os",
"cisco:adaptive_security_appliance_software": "cisco_asa",
"cisco:ios": "cisco_ios",
"cisco:nx-os": "cisco_nxos",
"cisco:ios_xe": "cisco_xe",
"cisco:ios_xr": "cisco_xr",
"cisco:nx-os": "cisco_nxos",
"hpe:arubaos-cx": "aruba_aoscx",
"juniper:junos": "juniper_junos",
"paloaltonetworks:pan-os": "paloalto_panos",
}
Expand Down Expand Up @@ -741,6 +742,7 @@
# Normalized | NIST
NIST_LIB_MAPPER_REVERSE: t.Dict[str, str] = {
"arista_eos": "arista:eos",
"aruba_aoscx": "hpe:arubaos-cx",
"aruba_os": "arubanetworks:arubaos",
"cisco_asa": "cisco:adaptive_security_appliance_software",
"cisco_ios": "cisco:ios",
Expand Down
25 changes: 23 additions & 2 deletions netutils/nist.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
("buildmetadata", str, dataclasses.field(default=None)), # pylint: disable=[E3701]
("vendor_metadata", bool, dataclasses.field(default=False)), # pylint: disable=[E3701]
],
"hpe": {
"arubaos-cx": [
("release", str, dataclasses.field(default=None)),
],
},
"juniper": {
"junos": [
("main", str, dataclasses.field(default=None)), # pylint: disable=[E3701]
Expand Down Expand Up @@ -63,6 +68,18 @@ def __getitem__(self, key: str) -> t.Any:
return getattr(self, key)


def _get_nist_urls_hpe_arubaos_cx(os_platform_data: t.Dict[str, t.Any]) -> t.List[str]:
"""Create NIST URLs for HPE Aruba AOS-CX."""
base_url = "https://services.nvd.nist.gov/rest/json/cves/2.0?cpeName=cpe:2.3:o:"
version = (
f"{os_platform_data['major']}."
f"{os_platform_data['minor']}."
f"{os_platform_data['patch']}"
)

return [f"{base_url}{os_platform_data['vendor']}:{os_platform_data['os_type']}:{version}:*"]


def _get_nist_urls_juniper_junos(os_platform_data: t.Dict[str, t.Any]) -> t.List[str]: # pylint: disable=R0911
"""Create a list of possible NIST Url strings for JuniperPlatform.

Expand Down Expand Up @@ -233,6 +250,9 @@ def _os_platform_object_builder(vendor: str, platform: str, version: str) -> obj

get_nist_url_funcs: t.Dict[str, t.Any] = {
"default": _get_nist_urls_default,
"hpe": {
"arubaos-cx": _get_nist_urls_hpe_arubaos_cx,
},
"juniper": {"junos": _get_nist_urls_juniper_junos},
}

Expand All @@ -255,9 +275,10 @@ def get_nist_vendor_platform_urls(vendor: str, platform: str, version: str) -> t
>>>
"""
platform_data = _os_platform_object_builder(vendor, platform, version).__dict__
get_nist_urls_func = get_nist_url_funcs.get(vendor.lower(), {}).get(platform.lower())

if vendor.lower() == "juniper" and platform.lower() == "junos":
return _get_nist_urls_juniper_junos(platform_data)
if get_nist_urls_func:
return get_nist_urls_func(platform_data)
return _get_nist_urls_default(platform_data)


Expand Down