File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import requests
2+ from requests .auth import HTTPBasicAuth
3+ # For in house hosted API
4+ # Replace these values with your SecurityCenter information
5+ Tenable_SERVER = 'https://your-securitycenter-server'
6+ ACCESS_KEY = 'your-access-key'
7+ SECRET_KEY = 'your-secret-key'
8+ SCAN_ID = 1 # Replace with the ID of the scan you want to initiate
9+
10+ # API endpoint for initiating a scan
11+ SCAN_ENDPOINT = f'{ Tenable_SERVER } /rest/scan/{ SCAN_ID } /launch'
12+
13+ # Set up the headers and authentication
14+ headers = {
15+ 'Content-Type' : 'application/json' ,
16+ 'Accept' : 'application/json' ,
17+ }
18+ auth = HTTPBasicAuth (ACCESS_KEY , SECRET_KEY )
19+
20+ # Initiate the scan
21+ try :
22+ response = requests .post (SCAN_ENDPOINT , headers = headers , auth = auth , verify = False )
23+ response .raise_for_status ()
24+ print (f'Scan initiation successful. Response: { response .text } ' )
25+ except requests .exceptions .HTTPError as err :
26+ print (f'Error initiating scan: { err } ' )
27+ except Exception as e :
28+ print (f'An error occurred: { e } ' )
You can’t perform that action at this time.
0 commit comments