Skip to main content

"A Python library for the Demisto SDK"

Project description

Demisto SDK

PyPI version CircleCI Coverage Status Ruff Black

The Demisto SDK library can be used to manage your Cortex XSOAR content with ease and efficiency. The library supports Python 3.8-3.10. Python 3.8 support will be removed soon.

Usage

Installation

  1. Install - pip3 install demisto-sdk

  2. Upgrade - pip3 install --upgrade demisto-sdk

  3. Connect demisto-sdk with Cortex XSOAR server - In order that demisto-sdk and Cortex XSOAR server communicate, perfrom the following steps:

    1. Get an API key for Cortex XSOAR/XSIAM-server - Settings -> Integrations -> API keys -> Get your Key (copy it)

    2. Set the following environment variables, or place an .env file at the root of the content pack:

      export DEMISTO_BASE_URL=<http or https>://<demisto-server url or ip>:<port>
      export DEMISTO_API_KEY=<API key>
      

      To use on Cortex XSIAM or Cortex XSOAR 8.x the XSIAM_AUTH_ID environment variable should also be set.

      export XSIAM_AUTH_ID=<auth id>
      

      for example:

      export DEMISTO_BASE_URL=http://127.0.0.1:8080
      export DEMISTO_API_KEY=XXXXXXXXXXXXXXXXXXXXXX
      

      As long as XSIAM_AUTH_ID environment 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.

      unset XSIAM_AUTH_ID
      

      For more configurations, check the demisto-py repo (the SDK uses demisto-py to communicate with Cortex XSOAR).

    3. For the Validate and Format commands to work properly:

    • Install node.js, and make sure @mdx-js/mdx, fs-extra and commander are installed in node-modules folder (npm install ...).

    • Set the DEMISTO_README_VALIDATION environment variable to True.

      MDX is used to validate markdown files, and make sure they render properly on XSOAR and xsoar.pan.dev.

    1. Reload your terminal.

Content path

The demisto-sdk is made to work with Cortex content, structured similar to the official 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 the DEMISTO_SDK_CONTENT_PATH environment 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 the DEMISTO_SDK_IGNORE_CONTENT_WARNING environment variable.

CLI usage

You can use the SDK in the CLI as follows:

demisto-sdk <command> <args>

For more information, run demisto-sdk -h. For more information on a specific command execute demisto-sdk <command> -h.

Version Check

demisto-sdk will 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:

export DEMISTO_SDK_SKIP_VERSION_CHECK=yes

Commands

Supported commands:

  1. init
  2. Validate
  3. Lint
  4. Secrets
  5. Unify
  6. Prepare-Content
  7. Split
  8. Format
  9. Run
  10. Run-playbook
  11. Upload
  12. Download
  13. Generate-docs
  14. Generate-test-playbook
  15. Generate-outputs
  16. Update-release-notes
  17. Zip-packs
  18. openapi-codegen
  19. postman-codegen
  20. generate-integration
  21. generate-yml-from-python
  22. generate-unit-tests

Customizable command configuration

You can create your own configuration for the demisto-sdk commands by creating a file named .demisto-sdk-conf within 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_value

Note: Make sure to use the flag's full name and input _ instead of a - if it exists in the flag name (e.g. instead of no-docker-checks use no_docker_checks).

Here are a few examples:

  • As a user, I would like to not use the mypy linter in my environment when using the lint command. In the .demisto-sdk-conf file I'll enter:
[lint]
no_mypy=true
  • As a user, I would like to include untracked git files in my validation when running the validate command. In the .demisto-sdk-conf file I'll enter:
[validate]
include_untracked=true
  • As a user, I would like to automatically use minor version changes when running the update-release-notes command. In the .demisto-sdk-conf file I'll enter:
[update-release-notes]
update_type=minor

Autocomplete

Our CLI supports autocomplete for Linux/MacOS machines, you can turn this feature on by running one of the following: for zsh users run in the terminal

eval "$(_DEMISTO_SDK_COMPLETE=source_zsh demisto-sdk)"

for regular bashrc users run in the terminal

eval "$(_DEMISTO_SDK_COMPLETE=source demisto-sdk)"

License

MIT - See LICENSE for more information.


How to setup development environment?

Follow the guide found here to setup your demisto-sdk dev environment. The development environment is connected to the branch you are currently using in the SDK repository.


Contributions

Contributions are welcome and appreciated. For information regarding contributing, press here. For release guide, press here


Internet Connection

An internet connection is required for the following commands to work properly:

  1. Format
  2. Validate
  3. Update-release-notes

Note that the following commands may work partially without an internet connection:

  1. Download - will fail when using the '-fmt, --run-format' argument.
  2. Lint - will fail when creating the image.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

demisto_sdk-1.16.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

demisto_sdk-1.16.0-py3-none-any.whl (2.8 MB view details)

Uploaded Python 3

File details

Details for the file demisto_sdk-1.16.0.tar.gz.

File metadata

  • Download URL: demisto_sdk-1.16.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1030-aws

File hashes

Hashes for demisto_sdk-1.16.0.tar.gz
Algorithm Hash digest
SHA256 1c67a1ac94f1eb9b6a21b708017359831dfe3f908357cbbf67e1340d1e59eb11
MD5 f40247495fa2a4ce73c3917893f154ef
BLAKE2b-256 69c7a29582c1a91c0368234ce6a5e31ef163626d0606d540eaae6af51d2345a7

See more details on using hashes here.

File details

Details for the file demisto_sdk-1.16.0-py3-none-any.whl.

File metadata

  • Download URL: demisto_sdk-1.16.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-1030-aws

File hashes

Hashes for demisto_sdk-1.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b308e75db9bf7bd76938c6fd3ca272ffab92c8584bc127afa4e24bc049e0944
MD5 f22ec53234abce6e64ade404abb59feb
BLAKE2b-256 c8241db0996b0777cbdcff38763b3293848772d4f1ce5b504b28d0fdd39fc1f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page