The Cortex XSOAR extension for Visual Studio Code enables you to design and author scripts and integrations for Cortex XSOAR directly from VSCode. The extension adds a set of commands, as a sidebar with Automation and Integration Settings, just like the Settings sidebar in the Cortex XSOAR script editor. When writing code, the plugin provides you with auto-completion of Cortex XSOAR and Python functions. The extension also provides an easy-to-use set of demisto-sdk commands to format your packs, lint, and validate.
- Python 3.7 and up.
- Python for VSCode.
- Setup the content repository
- Install demisto-sdk. Don't forget to setup the required environment variables. It is highly recommended to install it on a virtual environment such as pipenv.
Install the Visual Studio Code extension directly from the Visual Studio Code marketplace or use this link.
Cortex XSOAR recommends configuring the following:
A path to the python interpreter where demisto-sdk is installed. If not configured, will use the default python.pythonPath that redirects to python by default.
Will auto-run demisto-sdk lint and demisto-sdk validate when saving your file if this configuration is set to true. It is recommended to change this configuration to false and enable it only for your content repository.
All of the commands in the extension start the easy-to-find pattern XSOAR.
XSOAR: Load Script/Integration: Opens a side-panel to easily modify the integration configuration, inputs, and outputs.
XSOAR: Demisto-SDK Lint/Validate/Update Release Notes...: Will run the demisto-sdk commands.
Read the Debugging using your IDE section.
The launch (.vscode/launch.json) configuration for running an integration should be as follows:
You can use Run and Debug (⇧⌘D) in VSCode (or click F5 on the python file).
If you are developing an integration that relies on packages other than the base packages, Cortex XSOAR recommends that you create a separate environment for that.
In addition, you will need the CommonServerPython.py, CommonServerUserPython.py, demistomock.py files alongside your integration.
Let's say you are developing an integration in Packs/Pasta/Integrations/Pasta and your integration requires the pasta package. You would need to create a pipenv in that root:
The command will create a new environment along with Pipfile and Pipfile.lock.
If you need to deactivate your current pipenv, run exit.
Activate that pipenv in your VSCode (Command Pallete (⇧⌘P) -> Python: Select Interpreter).
You need the following three files in your directory:
Can be found in Packs/Base/Scripts/CommonServerPython.
- Create an empty file with the name CommonServerUserPython.py.
Can be found in Tests/demistomock.
The files will be auto-copied to your integration folder when running XSOAR: Demisto-SDK Lint. You can run the command by right-clicking on the file from the command pallet.
Alternately, you can link those files to keep them updated:
You need to modify the launch configuration to use your local Pasta's CommonServerPython and demistomock.
Now you can run your custom integration with your pipenv!