Just wanted to supply an update here. You can now do this all from the resilient client. Below is the updated code that should allow you to do this on 50.1 of the python module for Resilient.
Original Message:
Sent: Tue September 12, 2023 02:58 AM
From: Michael Herren
Subject: Export Playbook via API
Thank you very much for your response.
I will soon test your code but don't see a reason it will not work for me as well.
Once more thank you
------------------------------
Michael Herren
Security Analyst
PostFinance AG
Bern
Original Message:
Sent: Fri September 08, 2023 02:57 PM
From: Nick Mumaw
Subject: Export Playbook via API
Ok so I did some more testing and found that basically you can't just do this with the rest_client from the Resilient Python Module just yet. Hopefully with my findings this will be added in the future. I had to use requests as well. Here is my code to get this to work.
import resilient, requests
Using this code I am able to automate exporting every single playbook within my environment.
I might also point out that resilient-sdk has this capability too by using the Extract function, however it is limited on what all can be pulled like it doesn't also pull the integration and add the integration to your server when importing back in. This will actually pull the playbooks specified itself and allow you to import all playbooks at 1 time using the Admin -> Settings Import option. See the command below to understand how that command will work.
resilient-sdk extract -n "PREPENDED_NAME" -o "OUTPUT/PATH" -pb PLAYBOOK1 PLAYBOOK2 PLAYBOOK3
More on Extract can be found here as you can extract a lot more as well. https://ibmresilient.github.io/resilient-python-api/pages/resilient-sdk/resilient-sdk.html#extract
------------------------------
Nick Mumaw, GPEN, GPYC
Cyber Security Specialist - SOAR
IBM - Security
Original Message:
Sent: Fri September 08, 2023 02:10 AM
From: Michael Herren
Subject: Export Playbook via API
Thank you very much for your response. That is what I was expecting as well.
When I run the commands
__playbook_id = 77
__playbook_name = '<name>'
__payload = {
'id': __playbook_id,
'name': __playbook_name
}
__exportable = res_client.post('/playbooks/exports', payload=__payload)
__export_id = __exportable['export_id']
__export_id
The value of variable __export_id is 172 (for example). When I then execute
__payload = {
}
res_client.post('/playbooks/exports/172', __payload)
I get the error
RetryHTTPException: 'resilient' API Request Retry: Response Code: 500 Reason: Unknown Reason. {"success":false,"title":null,"message":"Internal Server Error","hints":[],"error_code":"generic"}
------------------------------
Michael Herren
Security Analyst
PostFinance AG
Bern
Original Message:
Sent: Wed September 06, 2023 06:03 PM
From: Nick Mumaw
Subject: Export Playbook via API
Hey Michael,
I have never done this before, but I think what you would be looking for is the post command for export extracting. This would allow you to grab the export that you just completed by supplying the export_id from the previously run command.
/orgs/{org_id}/playbooks/exports/{export_id}
I can do some further testing if you need it!
------------------------------
Nick Mumaw, GPEN, GPYC
Cyber Security Specialist - SOAR
IBM - Security
Original Message:
Sent: Fri September 01, 2023 07:38 AM
From: Michael Herren
Subject: Export Playbook via API
I am trying to write a script exporting playbooks created within IBM QRadar SOAR. So far I failed ot achieve my gloal.
I am using the following Python packages:
resilient 49.1.51
resilient-app-config-plugins 1.0.0
I am able to retrieve a list of all playbooks
__payload = {
'filters': [
]
}
__playbooks = res_client.post('/playbooks/query_paged?return_level=full', payload=__payload)['data']
Further I am able to initiate the export
__playbook_id = 77
__playbook_name = '<name>'
__playbook_display_name = '<name>'
__payload = {
'id': __playbook_id,
'name': __playbook_name
}
__exportable = res_client.post('/playbooks/exports', payload=__payload)
What is the next command to actually download the playbook? What ever I tried so far failed.
Thank you very much for your support.
------------------------------
Michael Herren
Security Analyst
PostFinance AG
Bern
------------------------------