Package: validate-sops
Validate-SOPSOverviewvalidate-sopsis a Python utility designed to validate that specified files are encrypted usingMozilla SOPS (Secrets OPerationS). It ensures that sensitive files committed to your repository are securely encrypted, preventing accidental exposure of secrets.Supported FormatsThe utility supports validation for files in the following formats:JSON (.json)YAML (.yaml and .yml)Environment files (.env)FeaturesValidates multiple files for SOPS encryption.Easily integrated into pre-commit hooks for automated validation.Provides clear error messages for non-compliant files.UsageTo usevalidate-sopsas apre-commithook in your projects, add the following configuration to your.pre-commit-config.yamlfile:repos:-repo:https://github.com/voldy/validate-sopsrev:'v0.1.1'# Use the latest commit SHA or taghooks:-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 SetupThe following instructions are intended for contributors and developers working on thevalidate-sopsutility itself.InstallationThis project usesPoetryfor dependency management and package handling. Ensure you have Poetry installed on your system.To set upvalidate-sopsfor local development, follow these steps:Clone the repository:gitclonehttps://github.com/voldy/validate-sops.gitcdvalidate-sopsInstall dependencies using Poetry:poetryinstallSet up the pre-commit hooks:
After configuring.pre-commit-config.yamlin your project, run the following command to set up the git hook scripts:pre-commitinstallTo manually execute all configured pre-commit hooks on all files, run:poetryrunpre-commitrun--all-filesThis step is useful for testing the hooks before committing.Running TestsTo run the unit tests forvalidate-sops, use the following command:poetryrunpytestTesting Changes Locally in Another ProjectIf you're making changes tovalidate-sopsand want to test these changes within the context of another project that usesvalidate-sopsas a pre-commit hook, you can leverage thepre-commit try-repocommand. This allows you to run your locally modified version ofvalidate-sopsdirectly in the consuming project without needing to commit or push your changes.Here's how you can test your local changes tovalidate-sopsin another project:Navigate to the root directory of the project wherevalidate-sopsis integrated as a pre-commit hook.Run the following command:pre-committry-repo/local/path/to/validate-sopsvalidate-sops--verbose--all-filesReplace/local/path/to/validate-sopswith the actual path to your local clone of the validate-sops repository.Note: Thetry-repocommand allows you to temporarily include your local version ofvalidate-sopsin the pre-commit configuration of the consuming project. This enables you to test uncommitted changes invalidate-sopsdirectly, making it easier to iterate on your development before finalizing your changes.ContributingContributions tovalidate-sopsare welcome! Please feel free to submit pull requests or open issues to suggest improvements or report bugs.AuthorVladimir ZhukovLicensevalidate-sopsis licensed under the MIT License. See theLICENSEfile in the project root for the full license text.