Package: demisto-sdk
Demisto SDKThe Demisto SDK library can be used to manage your Cortex XSOAR content with ease and efficiency.Requirements:Python 3.8, 3.9 or 3.10.git installed.A linux, mac or WSL2 machine.Windows machines are not supported - use WSL2 or run in a container instead.UsageInstallationInstall-pip3 install demisto-sdkUpgrade-pip3 install --upgrade demisto-sdkConnect demisto-sdk with Cortex XSOAR server- In order that demisto-sdk and Cortex XSOAR server communicate, perfrom the following steps:Get an API key for Cortex XSOAR/XSIAM-server -Settings->Integrations->API keys->Get your Key(copy it)Set the following environment variables, or place an.env fileat the root of the content pack:exportDEMISTO_BASE_URL=<httporhttps>://<demisto-serverurlorip>:<port>exportDEMISTO_API_KEY=<APIkey>To use on Cortex XSIAM or Cortex XSOAR 8.x theXSIAM_AUTH_IDenvironment variable should also be set.exportXSIAM_AUTH_ID=<authid>for example:exportDEMISTO_BASE_URL=http://127.0.0.1:8080exportDEMISTO_API_KEY=XXXXXXXXXXXXXXXXXXXXXXAs long asXSIAM_AUTH_IDenvironment variable is set, SDK commands will be configured to work with an XSIAM instance.
In order to set Demisto SDK to work with Cortex XSOAR instance, you need to delete the XSIAM_AUTH_ID parameter from your environment.unsetXSIAM_AUTH_IDIn case the primary git branch is notmaster, or the upstream is not namedorigin, set them with environment variables:exportDEMISTO_DEFAULT_BRANCH=<branchnamehere>exportDEMISTO_DEFAULT_REMOTE=<upstreamnamehere>For more configurations, check thedemisto-pyrepo (the SDK uses demisto-py to communicate with Cortex XSOAR).For theValidateandFormatcommands to work properly:Install node.js, and make sure@mdx-js/mdx,fs-extraandcommanderare installed in node-modules folder (npm install ...).Set theDEMISTO_README_VALIDATIONenvironment variable to True.MDX is used to validate markdown files, and make sure they render properly on XSOAR andxsoar.pan.dev.Reload your terminal.Content pathThedemisto-sdkis made to work with Cortex content, structured similar to theofficial Cortex content repo.Demisto-SDK commands work best when called from the content directory or any of its subfolders.
To run Demisto-SDK commands from other folders, you may set theDEMISTO_SDK_CONTENT_PATHenvironment variable.We recommend running all demisto-SDK commands from a folder with a git repo, or any of its subfolders. To suppress warnings about running commands outside of a content repo folder, set theDEMISTO_SDK_IGNORE_CONTENT_WARNINGenvironment variable.CLI usageYou can use the SDK in the CLI as follows:demisto-sdk<command><args>For more information, rundemisto-sdk -h.
For more information on a specific command executedemisto-sdk <command> -h.Version Checkdemisto-sdkwill check against the GitHub repository releases for a new version every time it runs and will issue a warning if you are not using the latest and greatest. If you wish to skip this check you can set the environment variable:DEMISTO_SDK_SKIP_VERSION_CHECK. For example:exportDEMISTO_SDK_SKIP_VERSION_CHECK=yesCommandsSupported commands:initValidateLintSecretsPrepare-ContentSplitFormatRunRun-playbookUploadDownloadGenerate-docsGenerate-test-playbookGenerate-outputsUpdate-release-notesZip-packsopenapi-codegenpostman-codegengenerate-integrationgenerate-yml-from-pythongenerate-unit-testspre-commit (experimental)setup-envLogsLog files are generated and stored automatically by default in the user's home directory:Linux / macOS:$HOME/.demisto-sdk/logsWindows:%USERPROFILE%\.demisto-sdk\logsThe default directory can be overriden using the--log-file-pathflag, or theDEMISTO_SDK_LOG_FILE_PATHenvironment variable.Customizable command configurationYou can create your own configuration for thedemisto-sdkcommands by creating a file named.demisto-sdk-confwithin the directory from which you run the commands.
This file will enable you to set a default value to the existing command flags that will take effect whenever the command is run.
This can be done by entering the following structure into the file:[command_name]flag_name=flag_default_valueNote: Make sure to use the flag's full name and input_instead of a-if it exists in the flag name (e.g. instead ofno-docker-checksuseno_docker_checks).Here are a few examples:As a user, I would like to not use themypylinter in my environment when using thelintcommand. In the.demisto-sdk-conffile I'll enter:[lint]no_mypy=trueAs a user, I would like to include untracked git files in my validation when running thevalidatecommand. In the.demisto-sdk-conffile I'll enter:[validate]include_untracked=trueAs a user, I would like to automatically use minor version changes when running theupdate-release-notescommand. In the.demisto-sdk-conffile I'll enter:[update-release-notes]update_type=minorLicenseMIT - SeeLICENSEfor more information.How to setup a development environment?Follow the guide foundhereto setup yourdemisto-sdkdev environment.
The development environment is connected to the branch you are currently using in the SDK repository.ContributionsContributions are welcome and appreciated.
For information regarding contributing, presshere.Internet ConnectionAn internet connection is required for the following commands to work properly:FormatValidateUpdate-release-notesNote that the following commands may work partially without an internet connection:Download- will fail when using the '-fmt, --run-format' argument.Lint- will fail when creating the image.When working offline (or in an airgapped environment), set theDEMISTO_SDK_OFFLINE_ENVenvironment variable totrue:exportDEMISTO_SDK_OFFLINE_ENV=TRUEWhen set, Demisto-SDK features requiring an internet connection will not be run, often saving some time and avoiding errors.XSOAR CI/CDFor information regarding XSOAR CI/CD, please seethis article