Skip to main content

A Python utility to ensure your files are securely encrypted with SOPS. Integrates seamlessly into your pre-commit workflow, providing automated validation for SOPS-encrypted files, enhancing security and compliance in your development process.

Project description

Validate-SOPS

Overview

validate-sops is a Python utility designed to validate that specified files are encrypted using Mozilla SOPS (Secrets OPerationS). It ensures that sensitive files committed to your repository are securely encrypted, preventing accidental exposure of secrets.

Supported Formats

The utility supports validation for files in the following formats:

  • JSON (.json)
  • YAML (.yaml and .yml)
  • Environment files (.env)

Features

  • Validates multiple files for SOPS encryption.
  • Easily integrated into pre-commit hooks for automated validation.
  • Provides clear error messages for non-compliant files.

Usage

To use validate-sops as a pre-commit hook in your projects, add the following configuration to your .pre-commit-config.yaml file:

repos:
-   repo: https://github.com/voldy/validate-sops
    rev: 'v0.1.1'  # Use the latest commit SHA or tag
    hooks:
    -   id: validate-sops
        # Adjust based on your file(s) location and type(s)
        files: '.*\/secrets\/encrypted\.(yaml|yml|json|env)$'

Ensure that the file paths and types specified in the files regex pattern match the location and formats of the files you intend to validate in your project.

Local Development Setup

The following instructions are intended for contributors and developers working on the validate-sops utility itself.

Installation

This project uses Poetry for dependency management and package handling. Ensure you have Poetry installed on your system.

To set up validate-sops for local development, follow these steps:

  1. Clone the repository:
git clone https://github.com/voldy/validate-sops.git
cd validate-sops
  1. Install dependencies using Poetry:
poetry install
  1. Set up the pre-commit hooks: After configuring .pre-commit-config.yaml in your project, run the following command to set up the git hook scripts:
pre-commit install
  1. To manually execute all configured pre-commit hooks on all files, run:
poetry run pre-commit run --all-files

This step is useful for testing the hooks before committing.

Running Tests

To run the unit tests for validate-sops, use the following command:

poetry run pytest

Testing Changes Locally in Another Project

If you're making changes to validate-sops and want to test these changes within the context of another project that uses validate-sops as a pre-commit hook, you can leverage the pre-commit try-repo command. This allows you to run your locally modified version of validate-sops directly in the consuming project without needing to commit or push your changes.

Here's how you can test your local changes to validate-sops in another project:

  1. Navigate to the root directory of the project where validate-sops is integrated as a pre-commit hook.
  2. Run the following command:
pre-commit try-repo /local/path/to/validate-sops validate-sops --verbose --all-files

Replace /local/path/to/validate-sops with the actual path to your local clone of the validate-sops repository.

Note: The try-repo command allows you to temporarily include your local version of validate-sops in the pre-commit configuration of the consuming project. This enables you to test uncommitted changes in validate-sops directly, making it easier to iterate on your development before finalizing your changes.

Contributing

Contributions to validate-sops are welcome! Please feel free to submit pull requests or open issues to suggest improvements or report bugs.

Author

Vladimir Zhukov

License

validate-sops is licensed under the MIT License. See the LICENSE file in the project root for the full license text.

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

validate_sops-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

validate_sops-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file validate_sops-0.1.2.tar.gz.

File metadata

  • Download URL: validate_sops-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.5 Darwin/24.4.0

File hashes

Hashes for validate_sops-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5c2f40e62b97b8a3656c64938afec6c12e4fa422aa139051806b3d16a7d261e8
MD5 30697ff2ecefdf6f0089258959671109
BLAKE2b-256 77b3c0d1cad4dc8ef791a99c9cc9871b71682506b46721323a2687134dafc6fa

See more details on using hashes here.

File details

Details for the file validate_sops-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: validate_sops-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.5 Darwin/24.4.0

File hashes

Hashes for validate_sops-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6275b4d259393576d06055447c822dcabb23fd0abae24d8d9b7e7afa26dbe9ca
MD5 f9d0a46bacc90e599cf8f29ee84bdcc4
BLAKE2b-256 01a5dc9c2b39d8a3b51feef5b4a4758b038d202b30201bd3836603e9ad3dfc53

See more details on using hashes here.

Supported by

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