Skip to main content

A Python module to parse DISA STIG (XCCDF) Files

Project description


Logo

Explore the docs »

Report Bug · Request Feature

GitHub last commit PyPi GitHub Workflow Status GitHub Open Issues GitHub Open PRs Python Versions GitHub License LinkedIN Profile

About

A basic Python package to parse DISA STIG (XCCDF) Files into a readable JSON format.

Installation

To install stig-parser, simple run the following command:

pip install stig-parser

Version Updates

The table below briefly describes each update. For more information, view the releases page.

Version Description
1.0.0 Initial Creation of stig-parser
1.0.1 Updated to handle change to STIG schema (Issue #3)
1.0.2 Added Additional Fields to Output JSON. View Release Notes for Full Details (Issue #9)

Documentation

Documentation hasn't been created at this time. For the current development documentation, please visit the repository.

Testing (Unit Testing)

This project leverages GitHub Actions for its CI/CD workflow. During a Push to any branch, with the exception of Master and Dev, the workflow will perform Unit Testing and Linting.

For manual testing, run the following commands;

## START PYTHON DEV CONTAINER
docker run -it --rm -v $(PWD)/dev:/testing python /bin/bash

## INSTALL DEPENDENCIES
pip install pytest

## CHANGE WORKING DIRECTORY
cd testing

## RUN PYTEST
pytest

Testing (Functional Testing)

To perform a functional test, run the following commands. This script will generate a dump.json file within the dev directory that can be reviewed for accuracy.

## START PYTHON DEV CONTAINER
docker run -it --rm -v $(PWD)/dev:/testing python /bin/bash

## INSTALL DEPENDENCIES
pip install stig-parser

## CHANGE WORKING DIRECTORY
cd testing

## RUN PYTHON SCRIPT
python3 test.py

Usage

To use this package simply, import the module and run the convert-xccdf() function. This will result in the a JSON String object.

## LOAD PYTHON MODULE
from stig_parser import convert_xccdf

## LOAD XML FILE (OPTIONAL)
import os

with open("example.xml", "r") as fh:
    raw_file = fh.read()

## PARSE XCCDF(XML) to JSON
json_results = convert_xccdf(raw_file)

Output

Outlined below is the expected JSON output:

{
    "title": "xxxxxxx",
    "description": "xxxxxxx",
    "version": "x",
    "release": "x ",
    "benchmark_date": "xxxxxxx",
    "release_info": "xxxxxxx",
    "source": "xxxxxxx",
    "notice": "xxxxxxx",
    "rules": [
        {
            "id": "xxxxxxx",
            "stig_id": "xxxxxxx",
            "severity": "xxxxxxx",
            "title": "xxxxxxx",
            "description": "xxxxxxx",
            "fixtext": "xxxxxxx",
            "check": "xxxxxxx",
            "cci": "xxxxxxx",
            "rule_id": "xxxxxxx"
        },
        {
            "id": "xxxxxxx",
            "stig_id": "xxxxxxx",
            "severity": "xxxxxxx",
            "title": "xxxxxxx",
            "description": "xxxxxxx",
            "fixtext": "xxxxxxx",
            "check": "xxxxxxx",
            "cci": "xxxxxxx",
            "rule_id": "xxxxxxx"
        }
    ]
}

Dependencies

The following packages are required for this package:

Package Name Reason
xmltodict This converts the raw XML file to a python dictionary for ease of processing

Comments, Concerns and Gripes

If you have any comments, concerns and/or gripes, please feel free to submit an issue on the repository.

Project details


Download files

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

Source Distribution

stig_parser-1.0.2.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

stig_parser-1.0.2-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

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