返回 Skill 列表
extension
分类: 开发与工程无需 API Key

stix2-validator

验证STIX 2.1 JSON文件和捆绑包是否符合STIX规范。在验证威胁情报数据、在摄取前检查STIX捆绑包的完整性、验证指示器/恶意软件/攻击模式对象是否具有所需字段,或批量验证STIX文件目录时使用。提供详细的错误报告,显示哪些对象失败及其原因。

person作者: jakexiaohubgithub

STIX 2.1 Validator

Validate STIX 2.1 JSON bundles using the official stix2-validator library.

Requirements

Install the validator library before use:

pip install stix2-validator --break-system-packages

Usage

Validate a Single File

python scripts/validate_stix.py /path/to/bundle.json

Validate a Directory

python scripts/validate_stix.py /path/to/stix_files/

Add -r for recursive subdirectory scanning.

Options

| Option | Description | |--------|-------------| | --strict | Enable all optional validation checks | | --enforce-refs | Warn when object references don't resolve within the bundle | | -r, --recursive | Recursively validate files in subdirectories | | --json | Output results as JSON for programmatic use | | -q, --quiet | Suppress success messages, show only errors |

JSON Output

For integration with other tools, use --json:

python scripts/validate_stix.py bundle.json --json

Returns structured output:

{
  "file": "bundle.json",
  "valid": false,
  "errors": [
    {"id": "indicator--abc123", "type": "", "message": "'pattern_type' is a required property"}
  ],
  "warnings": []
}

Error Categories

The validator checks for:

  • Schema errors: Missing required properties, invalid property types
  • Format errors: Malformed UUIDs, invalid timestamps, incorrect ID formats
  • Reference errors: Unresolved object references (with --enforce-refs)
  • Semantic errors: Invalid STIX patterns, constraint violations

Exit Codes

  • 0: All files valid
  • 1: Validation errors found or file not found