Skip to content

A library to locate, parse, and validate Cyber Hygiene configuration files

License

Notifications You must be signed in to change notification settings

cisagov/cyhy-config

Repository files navigation

cyhy-config 📝

GitHub Build Status CodeQL Coverage Status Known Vulnerabilities

This repository implements a Python module for reading TOML configuration files used by various Cyber Hygiene components. It will discover, read, and optionally validate a configuration file.

Search Procedure

The module will search for the configuration file in the following locations, in the specified order:

  1. The path in the filesystem specified by the optional CYHY_CONFIG_PATH environment variable.
  2. The path in AWS SSM specified by the optional CYHY_CONFIG_SSM_PATH environment variable.
  3. In the current working directory: cyhy.toml
  4. In the user's home directory: ~/.cyhy/cyhy.toml
  5. In the system's etc directory: /etc/cyhy.toml

If the configuration file is not found, the module will raise a FileNotFoundError.

Configuration File Validation

The module will optionally validate the configuration file against a Pydantic model. If the configuration file does not match the model a ValidationError will be raised.

Environment Variables

Variable Description
CYHY_CONFIG_PATH The path to the configuration file.
CYHY_CONFIG_SSM_PATH The path to the configuration file in AWS SSM.

Example Usage

from cyhy_config import get_config
from pydantic import ValidationError

try:
    config = get_config(file_path=config_file, model=MyModelClass)
except ValidationError:
    sys.exit(1)
except FileNotFoundError:
    sys.exit(1)

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

License

This project is in the worldwide public domain.

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

About

A library to locate, parse, and validate Cyber Hygiene configuration files

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published