validate
Validate Cortex content files and packs against Demisto SDK standards and checks.
Ensures that YAML, JSON, and Markdown files in the content repository comply with Cortex standards so they can be processed by the platform, both locally and in GitLab.
Arguments
-g, --use-git
Validates changes using Git, checking the current branch's changes against origin/master. If the --post-commit flag is supplied, validation runs only on the current branch's changed files that have been committed. If the --post-commit flag is not supplied, validation runs on all changed files in the current branch, both committed and not committed.
-a, --validate-all
Whether to run all validations on all files.
-i, --input
The path of the content pack/file to validate specifically.
-pc, --post-commit
Whether the validation should run only on the current branch's committed changed files. This applies only when the -g flag is supplied.
-st, --staged
Whether the validation should run only on the current branch's staged files. This applies only when the -g flag is supplied.
--prev-ver
The previous branch or SHA1 commit to run checks against.
--no-multiprocessing
Runs validate on all files without multiprocessing for debugging purposes.
-j, --json-file
The JSON file path to which to output the command results.
--category-to-run
Runs specific validations by stating the category they're listed under in the configuration file.
-f, --fix
Whether to auto-fix failing validations with an available auto-fix.
--config-path
Path for a config file to run. If not given, the config file runs the default path at: demisto_sdk/commands/validate/default_config.toml.
--ignore-support-level
Whether to skip validations based on their support level.
--run-old-validate
Whether to run the old validate flow. Alternatively, configure the RUN_OLD_VALIDATE environment variable.
--skip-new-validate
Whether to skip the new validate flow. Alternatively, configure the SKIP_NEW_VALIDATE environment variable.
-sv, --run-specific-validations
A comma-separated list of validations to run for the stated error codes.
--ignore
Specifies an error code to not run. To ignore more than one error, repeat this option (for example --ignore AA123 --ignore BC321).
Examples
demisto-sdk validate --prev-ver SHA1-HASHValidates only changed files compared to the specified SHA-1 commit hash.
demisto-sdk validate --post-commitRuns a post-commit validation.
demisto-sdk validate -i Packs/HelloWorld/Integrations/HelloWorld/HelloWorld.ymlValidates only the
Packs/HelloWorld/Integrations/HelloWorld/HelloWorld.ymlfile.demisto-sdk validate -aValidates all files under the
Packsdirectory.demisto-sdk validate -i Packs/HelloWorldValidates all files under the
HelloWorldcontent pack.demisto-sdk validate --run-old-validate --skip-new-validate -aValidates all files in the repository using the old
validatemethod.demisto-sdk validate --config-path {config_file_path} -aValidates all files in the repository using the settings configured in the configuration file at the given path.
Validation error codes
Each error found by the validate command has an error code attached to it. The error code is in brackets preceding the error itself.
Example
path/to/file: [IN103] - The type field of the proxy parameter should be 8.
In addition, each pack has a .pack-ignore file. To ignore a certain validation for a given file, the error code needs to be listed in the ignorable_errors section in the validation configuration file, with the file name (only the name and extension, without the full path) and the error code to ignore.
Example
If the .pack-ignore file's ignorable_errors section contains [file:ipinfo_v2.yml] ignore=BA108,BA109, validation will not fail ipinfo_v2.yml for error codes BA108 and BA109.
Validation config file
You can define a validation config file to meet your specific requirements. If no file is defined, the default config file is used. The default configuration includes basic validation checks that ensure only valid content is uploaded to Cortex XSOAR.
Config file sections
Sections are defined in brackets [] in the validation config file. You can define the following sections:
ignorable_errors: A list of the error codes that can be ignored for individual content items in the.pack-ignorefile.path_based_validations: The configurations to run when running with the-a/-iflags.use_git: The configurations to run when running with the-gflag.support_level.<support_type>: The validations to ignore based on the content item support level.support_typeis eitherxsoar,partner, orcommunity. To ignore this feature in some of the calls, use the--ignore-support-levelflag.Custom sections can be configured to run with the
category-to-runflag. Two example custom categories are given with the default config file:xsoar_best_practices_use_git: The recommended set of validations to run when running with-g. It may occasionally be modified.xsoar_best_practices_path_based_validations: The recommended set of validations to run when running with-a/-i. It may be occasionally be modified.
Section options
Each section has the following options:
select- The validations to run.warning- Set a validation to only throw a warning and not fail the flow.
Example
To run only BA101 error validation:
[custom_category]
select = ["BA101"]Example
To run all the validations with error codes BA100, BA101, and BA102, except for BA102 for community supported files:
[custom_category]
select = ["BA100", "BA101", "BA102"]
[support_level.community]
ignore = ["BA102"]Last updated
Was this helpful?
