Skip to main content

validate_bes_xml

A python module for validating BigFix XML files and content.

Validates .bes and .ojo files against the official BigFix XML schemas (bundled with the module) and reports what is wrong and where when a file does not validate. Useful locally and as a CI check for repositories of BigFix content.

How it works

For each XML file, the validator:

  1. Parses the file and reports XML syntax errors, if any.
  2. Determines which schema to use, in this order:
    • .ojo in the file name -> BESOJO.xsd
    • an attribute on the root tag referencing an .xsd file (e.g. xsi:noNamespaceSchemaLocation="BES.xsd")
    • the name of the root tag itself (e.g. <BES> -> BES.xsd)
  3. Validates the file against that schema and prints the line number and reason for every schema violation found.

Bundled schemas:

  • BES.xsd - Fixlets, Tasks, Analyses, Baselines, Computer Groups, etc.
  • BESAPI.xsd - BigFix REST API XML
  • BESOJO.xsd - Wizards / Dashboards (.ojo files)
  • BESDomain.xsd - Domain content

Additional .xsd files placed in the current working directory (or a schemas subfolder of it) are picked up automatically.

Requirements

Installation

pip install validate-bes-xml

Or from a clone of this repository:

pip install .

Usage

Command line

Validate all .bes and .ojo files in the current directory and its subfolders (excluding .git):

python -m validate_bes_xml

The exit code is the number of files that failed validation, so 0 means everything validated. This makes it easy to use as a CI check:

# example GitHub Actions step
- name: Validate BES XML
  run: |
    pip install validate-bes-xml
    python -m validate_bes_xml

Example output for an invalid file:

Schema Validation Error in: ./example.bes
  validated against schema: .../validate_bes_xml/schemas/BES.xsd
  Line 2: Element 'BES': Missing child element(s). Expected is one of ( Fixlet, Task, Analysis, SingleAction, SourcedFixletAction, MultipleActionGroup, Baseline, ComputerGroup, CustomSite, ActionSite ).
2 errors found in 71 xml files

Python

import validate_bes_xml

# validate a single file, returns True or False:
validate_bes_xml.validate_xml("example.bes")

# validate all .bes and .ojo files in a folder tree,
# returns the number of files that failed validation:
validate_bes_xml.validate_all_files("path/to/content")

# customize which file extensions are scanned:
validate_bes_xml.validate_all_files(".", file_extensions=(".bes",))

Development

Clone the repository, then install the requirements:

pip install -r requirements.txt
pip install pytest

Run the tests from the root of the repository:

pytest -v

The test examples live in tests/examples: files in good must validate, files in bad must not.

Related

License

MIT

Download files

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

Source Distribution

validate_bes_xml-2.1.1.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

validate_bes_xml-2.1.1-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file validate_bes_xml-2.1.1.tar.gz.

File metadata

  • Download URL: validate_bes_xml-2.1.1.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for validate_bes_xml-2.1.1.tar.gz
Algorithm Hash digest
SHA256 10d00e99ce6621f0ebf74a22a1a918bfc917091570dde61a258b508f410e69fa
MD5 68a3b4f2f6ae76706c4c47c70a65f305
BLAKE2b-256 ecd8451add2b0b72a2a94052ac0b5f0d05c6a9c6690e0d22f4ff19c4f95258b8

See more details on using hashes here.

File details

Details for the file validate_bes_xml-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for validate_bes_xml-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5837ca0a0e085012895653e86bff10d73d98bd274828428861cab766c36ebe81
MD5 9202eb200b116583fe81a3e97c11567c
BLAKE2b-256 17c96afea02008b0bd2d8a40dbd47e5137ba4a38edfcc6790c006807849a6ddd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.1.1 This release

2 files

1.1.2

2 files

1.1.1

2 files

1.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page