Sophos Cloud Optix Automation with Python
Notes and code guidance for automating the use of the Sophos Cloud Optix REST API
- Infrastructure as Code (IaC) Integration endpoints
- Scan: POST api/v1/iac/scan
Getting Started With Cloud Optix REST API
Sophos Cloud Optix Documentation
Endpoint: api/v1/iac/scan
Method: POST
Produces: applicaiton/json
- Code/function example only handles manatory/default query parameters
- IaC templates will be procesed asynchronouly (Default)
- Synchronous communication avaliable with optional query parameter
- Optional query parameter: 'async'
- Authorization header requires '': 'ApiKey'
- example: 'Authorization: ApiKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
- As part of the mutipart file construction, key for earch file needs to be consistant: 'files'
- example: = [('files', (, open(, 'rb')), 'files', (, open(, 'rb')))]
- Option to specify policy, otherwise 'default' is leveraged
- Optional query parameter: 'policy_name'
my_files = [('files', (<file1>, open(<file1>, 'rb')), 'files', (<file2>, open(<file2>, 'rb')))]
my_key = <-- from a secure spot ;)
my_scan_id = iac_scan(my_files, my_key)Success
200
{"scan_id":"999999a9-9999-999a-9a9a-99999a99a9a9a9","summary":null}
AuthN Failure
401
Unauthorized access or ApiKey expired params = {'async': params_async,
'policy_name': params_policy,
'repo_url': params_repo,
'branch': params_branch,
'committer_name': params_cname,
'committer_email': params_cemail,
'save_results_to_account': params_save}
