cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
408
Views
6
Helpful
1
Replies

Using PowerShell to obtain all PSIRTs for Cisco Nexus

Tim Glen
Cisco Employee
Cisco Employee

Summary

I had a need to obtain all the PSIRTs for Cisco Nexus in CSV format similar to how the Cisco IOS Software Checker performs.

Steps

1. Follow this document to authenticate.   Be sure to take note of your access_token,  you will need it.

NOTE: Remember the access_token is ONLY valid for one hour after you obtained it.

2. Run the code below to obtain all Nexus PSIRTs.

# Clear all Used Variables

# Clear all Used Variables

$token_type=''

$access_token=''

$auth_header=''

$url=''

$headers=''

$response=''

# Create the Headers and the WebRequest

$token_type=$auth_response.token_type.ToString()

$access_token=$auth_response.access_token.ToString()

$auth_header=$token_type + ' ' + $access_token

$headers=@{Accept='application/xml';Authorization=$auth_header}

$url='https://api.cisco.com/security/advisories/cvrf/product?product=nexus'

# Send the Query

$response=Invoke-RestMethod -URI $url -Method Get -Header $headers

#Write the Output

$response.advisories.advisory | Export-Csv -Path c:\temp\nexus-psirts.csv

3. Run the code below to obtain all NX-OS PSIRTs. There will be duplicates from Step 2 but there will be new entries too.

# Clear all Used Variables

$token_type=''

$access_token=''

$auth_header=''

$url=''

$headers=''

$response=''

# Create the Headers and the WebRequest

$token_type=$auth_response.token_type.ToString()

$access_token=$auth_response.access_token.ToString()

$auth_header=$token_type + ' ' + $access_token

$headers=@{Accept='application/xml';Authorization=$auth_header}

$url='https://api.cisco.com/security/advisories/cvrf/product?product=nx-os'

# Send the Query

$response=Invoke-RestMethod -URI $url -Method Get -Header $headers

#Write the Output

$response.advisories.advisory | Export-Csv -Path c:\temp\nxos-psirts.csv

4.  In the tool of your choice merge the two CSV files and delete the duplicate lines.

Output

One thing I noticed is that in the CSV there are several fields that have no usable value eg. bugIDs, ipsSignatures, cves, etc, I just hide \ delete these. I'll wrap text on the Summary column & vertically center all the columns.

Hope this helps.    Please rate and comment!

1 Reply 1

lbandlav
Cisco Employee
Cisco Employee

Thanks! This worked for NXOS, but is there a way, using which i can still filter based on NXOS and protocol SSH..etc?

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: