[
  {
    "path": ".gitattributes",
    "content": "# Set the default behavior, in case people don't have core.autocrlf set.\n* text=auto\n\n# Force the bash scripts to be checked out with LF line endings.\ngit-secrets text eol=lf\ngit-secrets.1 text eol=lf\ntest/bats/bin/* text eol=lf\ntest/bats/libexec/* text eol=lf\n*.bats text eol=lf\n*.bash text eol=lf"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "*Issue #, if available:*\n\n*Description of changes:*\n\n\nBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "---\nname: \"test\"\n\non:\n  push:\n    branches:\n      - 'master'\n  pull_request: {}\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - run: make test\n"
  },
  {
    "path": ".pre-commit-hooks.yaml",
    "content": "-   id: git-secrets\n    name: Git Secrets\n    description: git-secrets scans commits, commit messages, and --no-ff merges to prevent adding secrets into your git repositories.\n    entry: 'git-secrets --pre_commit_hook'\n    language: script\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: bash\n\nbefore_install:\n- git config --global user.email \"you@example.com\"\n- git config --global user.name \"Your Name\"\n\nscript:\n- make test\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# CHANGELOG\n\n## 1.3.0 - 2019-02-10\n\n* Empty provider output is now excluded\n  (https://github.com/awslabs/git-secrets/issues/34)\n* Spaces are now supported in git exec path, making more Windows\n  paths execute properly.\n* Patterns with newlines and carriage returns are now loaded properly.\n* Patterns that contain only \"\\n\" are now ignored.\n* Various Bash 4 fixes (https://github.com/awslabs/git-secrets/issues/66).\n* Make IAM key scanning much more targeted.\n\n## 1.2.1 - 2016-06-27\n\n* Fixed an issue where secret provider commands were causing \"command not\n  found\" errors due to a previously set IFS variable.\n  https://github.com/awslabs/git-secrets/pull/30\n\n## 1.2.0 - 2016-05-23\n\n* Fixed an issue where spaces files with spaces in their names were not being\n  properly scanned in the pre-commit hook.\n* Now ignoring empty lines and comments (e.g., `#`) in the .gitallowed file.\n* Fixed an issue where numbers were being compared to strings causing failures\n  on some platforms.\n\n## 1.1.0 - 2016-04-06\n\n* Bug fix: the pre-commit hook previously only scanned the working directory\n  rather than staged files. This release updates the pre-commit hook to instead\n  scan staged files so that git-secrets will detect violations if the working\n  directory drifts from the staging directory.\n* Added the `--scan-history` subcommand so that you can scan your entire\n  git history for violations.\n* Added the ability to filter false positives by using a .gitallowed file.\n* Added support for `--cached`, `--no-index`, and `--untracked` to the `--scan`\n  subcommand.\n\n## 1.0.1 - 2016-01-11\n\n* Now works correctly with filenames in a repository that contain spaces when\n  executing `git secrets --scan` with no provided filename (via `git grep`).\n* Now works with git repositories with hundreds of thousands of files when\n  using `git secrets --scan` with no provided filename (via `git grep`).\n\n## 1.0.0 - 2015-12-10\n\n* Initial release of ``git-secrets``.\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "## Code of Conduct\nThis project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). \nFor more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact \nopensource-codeofconduct@amazon.com with any additional questions or comments.\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing Guidelines\n\nThank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional \ndocumentation, we greatly value feedback and contributions from our community.\n\nPlease read through this document before submitting any issues or pull requests to ensure we have all the necessary \ninformation to effectively respond to your bug report or contribution.\n\n\n## Reporting Bugs/Feature Requests\n\nWe welcome you to use the GitHub issue tracker to report bugs or suggest features.\n\nWhen filing an issue, please check [existing open](https://github.com/awslabs/git-secrets/issues), or [recently closed](https://github.com/awslabs/git-secrets/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already \nreported the issue. Please try to include as much information as you can. Details like these are incredibly useful:\n\n* A reproducible test case or series of steps\n* The version of our code being used\n* Any modifications you've made relevant to the bug\n* Anything unusual about your environment or deployment\n\n\n## Contributing via Pull Requests\nContributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:\n\n1. You are working against the latest source on the *master* branch.\n2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.\n3. You open an issue to discuss any significant work - we would hate for your time to be wasted.\n\nTo send us a pull request, please:\n\n1. Fork the repository.\n2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.\n3. Ensure local tests pass.\n4. Commit to your fork using clear commit messages.\n5. Send us a pull request, answering any default questions in the pull request interface.\n6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.\n\nGitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and \n[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).\n\n\n## Finding contributions to work on\nLooking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/git-secrets/labels/help%20wanted) issues is a great place to start. \n\n\n## Code of Conduct\nThis project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). \nFor more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact \nopensource-codeofconduct@amazon.com with any additional questions or comments.\n\n\n## Security issue notifications\nIf you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.\n\n\n## Licensing\n\nSee the [LICENSE](https://github.com/awslabs/git-secrets/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.\n\nWe may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\nNote: Other license terms may apply to certain, identified software files\ncontained within or distributed with the accompanying software if such terms\nare included in the directory containing the accompanying software. Such other\nlicense terms will then apply in lieu of the terms of the software license\nabove.\n"
  },
  {
    "path": "Makefile",
    "content": "PREFIX ?= /usr/local\nMANPREFIX ?= \"${PREFIX}/share/man/man1\"\n\nhelp:\n\t@echo \"Please use \\`make <target>' where <target> is one of\"\n\t@echo \"  test     to perform unit tests.\"\n\t@echo \"  man      to build the man file from README.rst\"\n\t@echo \"  install  to install. Use PREFIX and MANPREFIX to customize.\"\n\n# We use bats for testing: https://github.com/sstephenson/bats\ntest:\n\tLANG=C test/bats/bin/bats test/\n\n# The man page is completely derived from README.rst. Edits to\n# README.rst require a rebuild of the man page.\nman:\n\trst2man.py README.rst > git-secrets.1\n\ninstall:\n\t@mkdir -p ${DESTDIR}${MANPREFIX}\n\t@mkdir -p ${DESTDIR}${PREFIX}/bin\n\t@cp -f git-secrets ${DESTDIR}${PREFIX}/bin\n\t@cp -f git-secrets.1 ${DESTDIR}${MANPREFIX}\n\n.PHONY: help test man\n"
  },
  {
    "path": "NOTICE.txt",
    "content": "git-secrets\nCopyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\nbats\nThis product bundles bats, which is available under a \"MIT\" license.\nFor details, see test/bats.\n"
  },
  {
    "path": "README.rst",
    "content": "===========\ngit-secrets\n===========\n\n-------------------------------------------------------------------------------------------\nPrevents you from committing passwords and other sensitive information to a git repository.\n-------------------------------------------------------------------------------------------\n\n.. contents:: :depth: 2\n\nSynopsis\n--------\n\n::\n\n    git secrets --scan [-r|--recursive] [--cached] [--no-index] [--untracked] [<files>...]\n    git secrets --scan-history\n    git secrets --install [-f|--force] [<target-directory>]\n    git secrets --list [--global]\n    git secrets --add [-a|--allowed] [-l|--literal] [--global] <pattern>\n    git secrets --add-provider [--global] <command> [arguments...]\n    git secrets --register-aws [--global]\n    git secrets --aws-provider [<credentials-file>]\n\n\nDescription\n-----------\n\n``git-secrets`` scans commits, commit messages, and ``--no-ff`` merges to\nprevent adding secrets into your git repositories. If a commit,\ncommit message, or any commit in a ``--no-ff`` merge history matches one of\nyour configured prohibited regular expression patterns, then the commit is\nrejected.\n\n\nInstalling git-secrets\n----------------------\n\n``git-secrets`` must be placed somewhere in your PATH so that it is picked up\nby ``git`` when running ``git secrets``.\n\n\\*nix (Linux/macOS)\n~~~~~~~~~~~~~~~~~~~\n\nYou can use the ``install`` target of the provided Makefile to install ``git secrets`` and the man page.\nYou can customize the install path using the PREFIX and MANPREFIX variables.\n\n::\n\n    make install\n\nWindows\n~~~~~~~\n\nRun the provided ``install.ps1`` powershell script. This will copy the needed files\nto an installation directory (``%USERPROFILE%/.git-secrets`` by default) and add\nthe directory to the current user ``PATH``.\n\n::\n\n    PS > ./install.ps1\n\nHomebrew (for macOS users)\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n    brew install git-secrets\n\n.. warning::\n\n    **You're not done yet! You MUST install the git hooks for every repo that\n    you wish to use with** ``git secrets --install``.\n\nHere's a quick example of how to ensure a git repository is scanned for secrets\non each commit::\n\n    cd /path/to/my/repo\n    git secrets --install\n    git secrets --register-aws\n\n\nAdvanced configuration\n----------------------\n\nAdd a configuration template if you want to add hooks to all repositories you\ninitialize or clone in the future.\n\n::\n\n    git secrets --register-aws --global\n\n\nAdd hooks to all your local repositories.\n\n::\n\n    git secrets --install ~/.git-templates/git-secrets\n    git config --global init.templateDir ~/.git-templates/git-secrets\n\n\nAdd custom providers to scan for security credentials.\n\n::\n\n    git secrets --add-provider -- cat /path/to/secret/file/patterns\n\n\nBefore making public a repository\n---------------------------------\n\nWith git-secrets is also possible to scan a repository including all revisions:\n\n::\n\n    git secrets --scan-history\n\n\nOptions\n-------\n\nOperation Modes\n~~~~~~~~~~~~~~~\n\nEach of these options must appear first on the command line.\n\n``--install``\n    Installs git hooks for a repository. Once the hooks are installed for a git\n    repository, commits and non-fast-forward merges for that repository will be prevented\n    from committing secrets.\n\n``--scan``\n    Scans one or more files for secrets. When a file contains a secret, the\n    matched text from the file being scanned will be written to stdout and the\n    script will exit with a non-zero status. Each matched line will be written with\n    the name of the file that matched, a colon, the line number that matched,\n    a colon, and then the line of text that matched. If no files are provided,\n    all files returned by ``git ls-files`` are scanned.\n\n``--scan-history``\n    Scans repository including all revisions. When a file contains a secret, the\n    matched text from the file being scanned will be written to stdout and the\n    script will exit with a non-zero status. Each matched line will be written with\n    the name of the file that matched, a colon, the line number that matched,\n    a colon, and then the line of text that matched.\n\n``--list``\n    Lists the ``git-secrets`` configuration for the current repo or in the global\n    git config.\n\n``--add``\n    Adds a prohibited or allowed pattern.\n\n``--add-provider``\n    Registers a secret provider. Secret providers are executables that when\n    invoked output prohibited patterns that ``git-secrets`` should treat as\n    prohibited.\n\n``--register-aws``\n    Adds common AWS patterns to the git config and ensures that keys present\n    in ``~/.aws/credentials`` are not found in any commit. The following\n    checks are added:\n\n    - AWS Access Key IDs via ``(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}``\n    - Amazon Bedrock API keys. Long-lived via ``ABSK[A-Za-z0-9+/]{109,}=*`` and short-lived via ``bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t``\n    - AWS Secret Access Key assignments via \":\" or \"=\" surrounded by optional\n      quotes\n    - AWS account ID assignments via \":\" or \"=\" surrounded by optional quotes\n    - Allowed patterns for example AWS keys (``AKIAIOSFODNN7EXAMPLE`` and\n      ``wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY``)\n    - Known credentials from ``~/.aws/credentials``\n\n    .. note::\n\n        While the patterns registered by this command should catch most\n        instances of AWS credentials, these patterns are **not** guaranteed to\n        catch them **all**. ``git-secrets`` should be used as an extra means of\n        insurance -- you still need to do your due diligence to ensure that you\n        do not commit credentials to a repository.\n\n``--aws-provider``\n    Secret provider that outputs credentials found in an INI file. You can\n    optionally provide the path to an INI file.\n\n\nOptions for ``--install``\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``-f, --force``\n    Overwrites existing hooks if present.\n\n``<target-directory>``\n    When provided, installs git hooks to the given directory. The current\n    directory is assumed if ``<target-directory>`` is not provided.\n\n    If the provided ``<target-directory>`` is not in a git repository, the\n    directory will be created and hooks will be placed in\n    ``<target-directory>/hooks``. This can be useful for creating git template\n    directories using with ``git init --template <target-directory>``.\n\n    You can run ``git init`` on a repository that has already been initialized.\n    From the `git init documentation <https://git-scm.com/docs/git-init>`_:\n\n        From the git documentation: Running ``git init`` in an existing repository\n        is safe. It will not overwrite things that are already there. The\n        primary reason for rerunning ``git init`` is to pick up newly added\n        templates (or to move the repository to another place if\n        ``--separate-git-dir`` is given).\n\n    The following git hooks are installed:\n\n    1. ``pre-commit``: Used to check if any of the files changed in the commit\n       use prohibited patterns.\n    2. ``commit-msg``: Used to determine if a commit message contains a\n       prohibited patterns.\n    3. ``prepare-commit-msg``: Used to determine if a merge commit will\n       introduce a history that contains a prohibited pattern at any point.\n       Please note that this hook is only invoked for non fast-forward merges.\n\n    .. note::\n\n        Git only allows a single script to be executed per hook. If the\n        repository contains Debian-style subdirectories like ``pre-commit.d``\n        and ``commit-msg.d``, then the git hooks will be installed into these\n        directories, which assumes that you've configured the corresponding\n        hooks to execute all of the scripts found in these directories. If\n        these git subdirectories are not present, then the git hooks will be\n        installed to the git repo's ``.git/hooks`` directory.\n\n\nExamples\n^^^^^^^^\n\nInstall git hooks to the current directory::\n\n    cd /path/to/my/repository\n    git secrets --install\n\nInstall git hooks to a repository other than the current directory::\n\n    git secrets --install /path/to/my/repository\n\nCreate a git template that has ``git-secrets`` installed, and then copy that\ntemplate into a git repository::\n\n    git secrets --install ~/.git-templates/git-secrets\n    git init --template ~/.git-templates/git-secrets\n\nOverwrite existing hooks if present::\n\n    git secrets --install -f\n\n\nOptions for ``--scan``\n~~~~~~~~~~~~~~~~~~~~~~\n\n``-r, --recursive``\n    Scans the given files recursively. If a directory is encountered, the\n    directory will be scanned. If ``-r`` is not provided, directories will be\n    ignored.\n\n    ``-r`` cannot be used alongside ``--cached``, ``--no-index``, or\n    ``--untracked``.\n\n``--cached``\n    Searches blobs registered in the index file.\n\n``--no-index``\n    Searches files in the current directory that is not managed by git.\n\n``--untracked``\n    In addition to searching in the tracked files in the working tree,\n    ``--scan`` also in untracked files.\n\n``<files>...``\n    The path to one or more files on disk to scan for secrets.\n\n    If no files are provided, all files returned by ``git ls-files`` are\n    scanned.\n\n\nExamples\n^^^^^^^^\n\nScan all files in the repo::\n\n    git secrets --scan\n\nScans a single file for secrets::\n\n    git secrets --scan /path/to/file\n\nScans a directory recursively for secrets::\n\n    git secrets --scan -r /path/to/directory\n\nScans multiple files for secrets::\n\n    git secrets --scan /path/to/file /path/to/other/file\n\nYou can scan by globbing::\n\n    git secrets --scan /path/to/directory/*\n\nScan from stdin::\n\n    echo 'hello!' | git secrets --scan -\n\n\nOptions for ``--list``\n~~~~~~~~~~~~~~~~~~~~~~\n\n``--global``\n    Lists only git-secrets configuration in the global git config.\n\n\nOptions for ``--add``\n~~~~~~~~~~~~~~~~~~~~~\n\n``--global``\n    Adds patterns to the global git config\n\n``-l, --literal``\n    Escapes special regular expression characters in the provided pattern so\n    that the pattern is searched for literally.\n\n``-a, --allowed``\n    Mark the pattern as allowed instead of prohibited. Allowed patterns are\n    used to filter out false positives.\n\n``<pattern>``\n    The regex pattern to search.\n\n\nExamples\n^^^^^^^^\n\nAdds a prohibited pattern to the current repo::\n\n    git secrets --add '[A-Z0-9]{20}'\n\nAdds a prohibited pattern to the global git config::\n\n    git secrets --add --global '[A-Z0-9]{20}'\n\nAdds a string that is scanned for literally (``+`` is escaped)::\n\n    git secrets --add --literal 'foo+bar'\n\nAdd an allowed pattern::\n\n    git secrets --add -a 'allowed pattern'\n\n\nOptions for ``--register-aws``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``--global``\n    Adds AWS specific configuration variables to the global git config.\n\n\nOptions for ``--aws-provider``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``[<credentials-file>]``\n    If provided, specifies the custom path to an INI file to scan. If not\n    provided, ``~/.aws/credentials`` is assumed.\n\n\nOptions for ``--add-provider``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``--global``\n    Adds the provider to the global git config.\n\n``<command>``\n    Provider command to invoke. When invoked the command is expected to write\n    prohibited patterns separated by new lines to stdout. Any extra arguments\n    provided are passed on to the command.\n\n\nExamples\n^^^^^^^^\n\nRegisters a secret provider with arguments::\n\n    git secrets --add-provider -- git secrets --aws-provider\n\nCats secrets out of a file::\n\n    git secrets --add-provider -- cat /path/to/secret/file/patterns\n\n\nDefining prohibited patterns\n----------------------------\n\n``egrep``-compatible regular expressions are used to determine if a commit or\ncommit message contains any prohibited patterns. These regular expressions are\ndefined using the ``git config`` command. It is important to note that\ndifferent systems use different versions of egrep. For example, when running on\nmacOS, you will use a different version of ``egrep`` than when running on something\nlike Ubuntu (BSD vs GNU).\n\nYou can add prohibited regular expression patterns to your git config using\n``git secrets --add <pattern>``.\n\n\nIgnoring false positives\n------------------------\n\nSometimes a regular expression might match false positives. For example, git\ncommit SHAs look a lot like AWS access keys. You can specify many different\nregular expression patterns as false positives using the following command:\n\n::\n\n    git secrets --add --allowed 'my regex pattern'\n\nYou can also add regular expressions patterns to filter false positives to a\n``.gitallowed`` file located in the repository's root directory. Lines starting\nwith ``#`` are skipped (comment line) and empty lines are also skipped.\n\nFirst, git-secrets will extract all lines from a file that contain a prohibited\nmatch. Included in the matched results will be the full path to the name of\nthe file that was matched, followed by ':', followed by the line number that was\nmatched, followed by the entire line from the file that was matched by a secret\npattern. Then, if you've defined allowed regular expressions, git-secrets will\ncheck to see if all of the matched lines match at least one of your registered\nallowed regular expressions. If all of the lines that were flagged as secret\nare canceled out by an allowed match, then the subject text does not contain\nany secrets. If any of the matched lines are not matched by an allowed regular\nexpression, then git-secrets will fail the commit/merge/message.\n\n.. important::\n\n    Just as it is a bad practice to add prohibited patterns that are too\n    greedy, it is also a bad practice to add allowed patterns that are too\n    forgiving. Be sure to test out your patterns using ad-hoc calls to\n    ``git secrets --scan $filename`` to ensure they are working as intended.\n\n\nSecret providers\n----------------\n\nSometimes you want to check for an exact pattern match against a set of known\nsecrets. For example, you might want to ensure that no credentials present in\n``~/.aws/credentials`` ever show up in a commit. In these cases, it's better to\nleave these secrets in one location rather than spread them out across git\nrepositories in git configs. You can use \"secret providers\" to fetch these\ntypes of credentials. A secret provider is an executable that when invoked\noutputs prohibited patterns separated by new lines.\n\nYou can add secret providers using the ``--add-provider`` command::\n\n    git secrets --add-provider -- git secrets --aws-provider\n\nNotice the use of ``--``. This ensures that any arguments associated with the\nprovider are passed to the provider each time it is invoked when scanning\nfor secrets.\n\n\nExample walkthrough\n-------------------\n\nLet's take a look at an example. Given the following subject text (stored in\n``/tmp/example``)::\n\n    This is a test!\n    password=ex@mplepassword\n    password=******\n    More test...\n\nAnd the following registered patterns:\n\n::\n\n    git secrets --add 'password\\s*=\\s*.+'\n    git secrets --add --allowed --literal 'ex@mplepassword'\n\nRunning ``git secrets --scan /tmp/example``, the result will\nresult in the following error output::\n\n    /tmp/example:3:password=******\n\n    [ERROR] Matched prohibited pattern\n\n    Possible mitigations:\n    - Mark false positives as allowed using: git config --add secrets.allowed ...\n    - List your configured patterns: git config --get-all secrets.patterns\n    - List your configured allowed patterns: git config --get-all secrets.allowed\n    - Use --no-verify if this is a one-time false positive\n\nBreaking this down, the prohibited pattern value of ``password\\s*=\\s*.+`` will\nmatch the following lines::\n\n    /tmp/example:2:password=ex@mplepassword\n    /tmp/example:3:password=******\n\n...But the first match will be filtered out due to the fact that it matches the\nallowed regular expression of ``ex@mplepassword``. Because there is still a\nremaining line that did not match, it is considered a secret.\n\nBecause that matching lines are placed on lines that start with the filename\nand line number (e.g., ``/tmp/example:3:...``), you can create allowed\npatterns that take filenames and line numbers into account in the regular\nexpression. For example, you could whitelist an entire file using something\nlike::\n\n    git secrets --add --allowed '/tmp/example:.*'\n    git secrets --scan /tmp/example && echo $?\n    # Outputs: 0\n\nAlternatively, you could allow a specific line number of a file if that\nline is unlikely to change using something like the following:\n\n::\n\n    git secrets --add --allowed '/tmp/example:3:.*'\n    git secrets --scan /tmp/example && echo $?\n    # Outputs: 0\n\nKeep this in mind when creating allowed patterns to ensure that your allowed\npatterns are not inadvertently matched due to the fact that the filename is\nincluded in the subject text that allowed patterns are matched against.\n\n\nSkipping validation\n-------------------\n\nUse the ``--no-verify`` option in the event of a false positive match in a\ncommit, merge, or commit message. This will skip the execution of the\ngit hook and allow you to make the commit or merge.\n\n\nAbout\n------\n\n- Author: `Michael Dowling <https://github.com/mtdowling>`_\n- Issue tracker: This project's source code and issue tracker can be found at\n  `https://github.com/awslabs/git-secrets <https://github.com/awslabs/git-secrets>`_\n- Special thanks to Adrian Vatchinsky and Ari Juels of Cornell University for\n  providing suggestions and feedback.\n\nCopyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n"
  },
  {
    "path": "git-secrets",
    "content": "#!/usr/bin/env bash\n# Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\").\n# You may not use this file except in compliance with the License.\n# A copy of the License is located at\n#\n# http://aws.amazon.com/apache2.0\n#\n# or in the \"license\" file accompanying this file. This file is distributed\n# on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n# express or implied. See the License for the specific language governing\n# permissions and limitations under the License.\n\nNONGIT_OK=1 OPTIONS_SPEC=\"\\\ngit secrets --scan [-r|--recursive] [--cached] [--no-index] [--untracked] [<files>...]\ngit secrets --scan-history\ngit secrets --install [-f|--force] [<target-directory>]\ngit secrets --list [--global]\ngit secrets --add [-a|--allowed] [-l|--literal] [--global] <pattern>\ngit secrets --add-provider [--global] <command> [arguments...]\ngit secrets --register-aws [--global]\ngit secrets --aws-provider [<credentials-file>]\n--\nscan Scans <files> for prohibited patterns\nscan-history Scans repo for prohibited patterns\ninstall Installs git hooks for Git repository or Git template directory\nlist Lists secret patterns\nadd Adds a prohibited or allowed pattern, ensuring to de-dupe with existing patterns\nadd-provider Adds a secret provider that when called outputs secret patterns on new lines\naws-provider Secret provider that outputs credentials found in an ini file\nregister-aws Adds common AWS patterns to the git config and scans for ~/.aws/credentials\nr,recursive --scan scans directories recursively\ncached --scan scans searches blobs registered in the index file\nno-index --scan searches files in the current directory that is not managed by Git\nuntracked In addition to searching in the tracked files in the working tree, --scan also in untracked files\nf,force --install overwrites hooks if the hook already exists\nl,literal --add and --add-allowed patterns are escaped so that they are literal\na,allowed --add adds an allowed pattern instead of a prohibited pattern\nglobal Uses the --global git config\ncommit_msg_hook* commit-msg hook (internal only)\npre_commit_hook* pre-commit hook (internal only)\nprepare_commit_msg_hook* prepare-commit-msg hook (internal only)\"\n\n# Include the git setup script. This parses and normalized CLI arguments.\n. \"$(git --exec-path)\"/git-sh-setup\n\nload_patterns() {\n  git config --get-all secrets.patterns\n  # Execute each provider and use their output to build up patterns\n  git config --get-all secrets.providers | while read -r cmd; do\n    # Only split words on '\\n\\t ' and strip \"\\r\" from the output to account\n    # for carriage returns being added on Windows systems. Note that this\n    # trimming is done before the test to ensure that the string is not empty.\n    local result=\"$(export IFS=$'\\n\\t '; $cmd | tr -d $'\\r')\"\n    # Do not add empty lines from providers as that would match everything.\n    if [ -n \"${result}\" ]; then\n      echo \"${result}\"\n    fi\n  done\n}\n\nload_allowed() {\n  git config --get-all secrets.allowed\n  local gitallowed=\"$(git rev-parse --show-toplevel)/.gitallowed\"\n  if [ -e \"$gitallowed\" ]; then\n    cat $gitallowed | awk 'NF && $1!~/^#/'\n  fi\n}\n\n# load patterns and combine them with |\nload_combined_patterns() {\n  local patterns=$(load_patterns)\n  local combined_patterns=''\n  for pattern in $patterns; do\n    combined_patterns=${combined_patterns}${pattern}\"|\"\n  done\n  combined_patterns=${combined_patterns%?}\n  echo $combined_patterns\n}\n\n# Scans files or a repo using patterns.\nscan() {\n  local files=(\"${@}\") options=\"\"\n  [ \"${SCAN_CACHED}\" == 1 ] && options+=\"--cached\"\n  [ \"${SCAN_UNTRACKED}\" == 1 ] && options+=\" --untracked\"\n  [ \"${SCAN_NO_INDEX}\" == 1 ] && options+=\" --no-index\"\n  # Scan using git-grep if there are no files or if git options are applied.\n  if [ ${#files[@]} -eq 0 ] || [ ! -z \"${options}\" ]; then\n    output=$(git_grep $options \"${files[@]}\")\n  else\n    output=$(regular_grep \"${files[@]}\")\n  fi\n  process_output $? \"${output}\"\n}\n\n# Scans through history using patterns\nscan_history() {\n  # git log does not support multiple patterns, so we need to combine them\n  local combined_patterns=$(load_combined_patterns)\n  [ -z \"${combined_patterns}\" ] && return 0\n  # Looks for differences matching the patterns, reduces the number of revisions to scan\n  local to_scan=$(git log --all -G\"${combined_patterns}\" --pretty=%H)\n  # Scan through revisions with findings to normalize output\n  output=$(GREP_OPTIONS= LC_ALL=C git grep -nwHEI \"${combined_patterns}\" $to_scan)\n  process_output $? \"${output}\"\n}\n\n# Performs a git-grep, taking into account patterns and options.\n# Note: this function returns 1 on success, 0 on error.\ngit_grep() {\n  local options=\"$1\"; shift\n  local files=(\"${@}\") combined_patterns=$(load_combined_patterns)\n\n  [ -z \"${combined_patterns}\" ] && return 1\n  GREP_OPTIONS= LC_ALL=C git grep -nwHEI ${options} \"${combined_patterns}\" -- \"${files[@]}\"\n}\n\n# Performs a regular grep, taking into account patterns and recursion.\n# Note: this function returns 1 on success, 0 on error.\nregular_grep() {\n  local files=(\"${@}\") patterns=$(load_patterns) action='skip'\n  [ -z \"${patterns}\" ] && return 1\n  [ ${RECURSIVE} -eq 1 ] && action=\"recurse\"\n  GREP_OPTIONS= LC_ALL=C grep -d \"${action}\" -nwHEI \"${patterns}\" \"${files[@]}\"\n}\n\n# Process the given status ($1) and output variables ($2).\n# Takes into account allowed patterns, and if a bad match is found,\n# prints an error message and exits 1.\nprocess_output() {\n  local status=\"$1\" output=\"$2\"\n  local allowed=$(load_allowed)\n  case \"$status\" in\n    0)\n      [ -z \"${allowed}\" ] && echo \"${output}\" >&2 && return 1\n      # Determine with a negative grep if the found matches are allowed\n      echo \"${output}\" | GREP_OPTIONS= LC_ALL=C grep -Ev \"${allowed}\" >&2 \\\n        && return 1 || return 0\n      ;;\n    1) return 0 ;;\n    *) exit $status\n  esac\n}\n\n# Calls the given scanning function at $1, shifts, and passes to it $@.\n# Exit 0 if success, otherwise exit 1 with error message.\nscan_with_fn_or_die() {\n  local fn=\"$1\"; shift\n  $fn \"$@\" && exit 0\n  echo >&2\n  echo \"[ERROR] Matched one or more prohibited patterns\" >&2\n  echo >&2\n  echo \"Possible mitigations:\" >&2\n  echo \"- Mark false positives as allowed using: git config --add secrets.allowed ...\" >&2\n  echo \"- Mark false positives as allowed by adding regular expressions to .gitallowed at repository's root directory\" >&2\n  echo \"- List your configured patterns: git config --get-all secrets.patterns\" >&2\n  echo \"- List your configured allowed patterns: git config --get-all secrets.allowed\" >&2\n  echo \"- List your configured allowed patterns in .gitallowed at repository's root directory\" >&2\n  echo \"- Use --no-verify if this is a one-time false positive\" >&2\n  exit 1\n}\n\n# Scans a commit message, passed in the path to a file.\ncommit_msg_hook() {\n  scan_with_fn_or_die \"scan\" \"$1\"\n}\n\n# Scans all files that are about to be committed.\npre_commit_hook() {\n  SCAN_CACHED=1\n  local files=() file found_match=0 rev=\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"\n  # Diff against HEAD if this is not the first commit in the repo.\n  git rev-parse --verify HEAD >/dev/null 2>&1 && rev=\"HEAD\"\n  # Filter out deleted files using --diff-filter\n  while IFS= read -r file; do\n    [ -n \"$file\" ] && files+=(\"$file\")\n  done <<< \"$(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)\"\n  scan_with_fn_or_die \"scan\" \"${files[@]}\"\n}\n\n# Determines if merging in a commit will introduce tainted history.\nprepare_commit_msg_hook() {\n  case \"$2,$3\" in\n    merge,)\n      local git_head=$(env | grep GITHEAD)  # e.g. GITHEAD_<sha>=release/1.43\n      local sha=\"${git_head##*=}\"           # Get just the SHA\n      local branch=$(git symbolic-ref HEAD) # e.g. refs/heads/master\n      local dest=\"${branch#refs/heads/}\"    # cut out \"refs/heads\"\n      git log \"${dest}\"..\"${sha}\" -p | scan_with_fn_or_die \"scan\" -\n      ;;\n  esac\n}\n\ninstall_hook() {\n  local path=\"$1\" hook=\"$2\" cmd=\"$3\" dest\n  # Determines the appropriate path for a hook to be installed\n  if [ -d \"${path}/hooks/${hook}.d\" ]; then\n    dest=\"${path}/hooks/${hook}.d/git-secrets\"\n  else\n    dest=\"${path}/hooks/${hook}\"\n  fi\n  [ -f \"${dest}\" ] && [ \"${FORCE}\" -ne 1 ] \\\n    && die \"${dest} already exists. Use -f to force\"\n  echo \"#!/usr/bin/env bash\" > \"${dest}\"\n  echo \"git secrets --${cmd} -- \\\"\\$@\\\"\" >> \"${dest}\"\n  chmod +x \"${dest}\"\n  [ -t 1 ] && command -v tput &> /dev/null && echo -n \"$(tput setaf 2)✓$(tput sgr 0) \"\n  echo \"Installed ${hook} hook to ${dest}\"\n}\n\ninstall_all_hooks() {\n  install_hook \"$1\" \"commit-msg\" \"commit_msg_hook\"\n  install_hook \"$1\" \"pre-commit\" \"pre_commit_hook\"\n  install_hook \"$1\" \"prepare-commit-msg\" \"prepare_commit_msg_hook\"\n}\n\n# Adds a git config pattern, ensuring to de-dupe\nadd_config() {\n  local key=\"$1\"; shift\n  local value=\"$@\"\n  if [ ${LITERAL} -eq 1 ]; then\n    value=$(sed 's/[\\.|$(){}?+*^]/\\\\&/g' <<< \"${value}\")\n  fi\n  if [ ${GLOBAL} -eq 1 ]; then\n    git config --global --get-all $key | grep -Fq \"${value}\" && return 1\n    git config --global --add \"${key}\" \"${value}\"\n  else\n    git config --get-all $key | grep -Fq \"${value}\" && return 1\n    git config --add \"${key}\" \"${value}\"\n  fi\n}\n\nregister_aws() {\n  # Reusable regex patterns\n  local aws=\"(AWS|aws|Aws)?_?\" quote=\"(\\\"|')\" connect=\"\\s*(:|=>|=)\\s*\"\n  local opt_quote=\"${quote}?\"\n  add_config 'secrets.providers' 'git secrets --aws-provider'\n  add_config 'secrets.patterns' '(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'\n  add_config 'secrets.patterns' 'ABSK[A-Za-z0-9+/]{109,}=*' #Bedrock long-lived - https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-generate.html\n  add_config 'secrets.patterns' 'bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t' #Bedrock short-lived - https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-generate.html\n  add_config 'secrets.patterns' \"${opt_quote}${aws}(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)${opt_quote}${connect}${opt_quote}[A-Za-z0-9/\\+=]{40}${opt_quote}\"\n  add_config 'secrets.patterns' \"${opt_quote}${aws}(ACCOUNT|account|Account)_?(ID|id|Id)?${opt_quote}${connect}${opt_quote}[0-9]{4}\\-?[0-9]{4}\\-?[0-9]{4}${opt_quote}\"\n  add_config 'secrets.allowed' 'AKIAIOSFODNN7EXAMPLE'\n  add_config 'secrets.allowed' \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\n\n  if [[ $? == 0 ]]; then\n    echo 'OK'\n  fi\n\n  exit $?\n}\n\naws_provider() {\n  local fi=\"$1\"\n  [ -z \"$fi\" ] && fi=~/.aws/credentials\n  # Find keys and ensure that special characters are escaped.\n  if [ -f $fi ]; then\n    awk -F \"=\" '/aws_access_key_id|aws_secret_access_key/ {print $2}' $fi \\\n      | tr -d ' \"' \\\n      | sed 's/[]\\.|$(){}?+*^]/\\\\&/g'\n  fi\n}\n\n# Ensures that the command is what was expected for an option.\nassert_option_for_command() {\n  local expected_command=\"$1\"\n  local option_name=\"$2\"\n  if [ \"${COMMAND}\" != \"${expected_command}\" ]; then\n    die \"${option_name} can only be supplied with the ${expected_command} subcommand\"\n  fi\n}\n\ndeclare COMMAND=\"$1\" FORCE=0 RECURSIVE=0 LITERAL=0 GLOBAL=0 ALLOWED=0\ndeclare SCAN_CACHED=0 SCAN_NO_INDEX=0 SCAN_UNTRACKED=0\n\n# Shift off the command name\nshift 1\nwhile [ \"$#\" -ne 0 ]; do\n  case \"$1\" in\n    -f)\n      assert_option_for_command \"--install\" \"-f|--force\"\n      FORCE=1\n      ;;\n    -r)\n      assert_option_for_command \"--scan\" \"-r|--recursive\"\n      RECURSIVE=1\n      ;;\n    -a)\n      assert_option_for_command \"--add\" \"-a|--allowed\"\n      ALLOWED=1\n      ;;\n    -l)\n      assert_option_for_command \"--add\" \"-l|--literal\"\n      LITERAL=1\n      ;;\n    --cached)\n      assert_option_for_command \"--scan\" \"--cached\"\n      SCAN_CACHED=1\n      ;;\n    --no-index)\n      assert_option_for_command \"--scan\" \"--no-index\"\n      SCAN_NO_INDEX=1\n      ;;\n    --untracked)\n      assert_option_for_command \"--scan\" \"--untracked\"\n      SCAN_UNTRACKED=1\n      ;;\n    --global) GLOBAL=1 ;;\n    --) shift; break ;;\n  esac\n  shift\ndone\n\n# Ensure that recursive is not applied with mutually exclusive options.\nif [ ${RECURSIVE} -eq 1 ]; then\n  if [ ${SCAN_CACHED} -eq 1  ] \\\n      || [ ${SCAN_NO_INDEX} -eq 1 ] \\\n      || [ ${SCAN_UNTRACKED} -eq 1 ];\n  then\n    die \"-r|--recursive cannot be supplied with --cached, --no-index, or --untracked\"\n  fi\nfi\n\ncase \"${COMMAND}\" in\n  -h|--help|--) \"$0\" -h; exit 0 ;;\n  --add-provider) add_config \"secrets.providers\" \"$@\" ;;\n  --register-aws) register_aws ;;\n  --aws-provider) aws_provider \"$1\" ;;\n  --commit_msg_hook|--pre_commit_hook|--prepare_commit_msg_hook)\n    ${COMMAND:2} \"$@\"\n    ;;\n  --add)\n    if [ ${ALLOWED} -eq 1 ]; then\n      add_config \"secrets.allowed\" \"$1\"\n    else\n      add_config \"secrets.patterns\" \"$1\"\n    fi\n    ;;\n  --scan) scan_with_fn_or_die \"scan\" \"$@\" ;;\n  --scan-history) scan_with_fn_or_die \"scan_history\" \"$@\" ;;\n  --list)\n    if [ ${GLOBAL} -eq 1 ]; then\n      git config --global --get-regex secrets.*\n    else\n      git config --get-regex secrets.*\n    fi\n    ;;\n  --install)\n    DIRECTORY=\"$1\"\n    if [ -z \"${DIRECTORY}\" ]; then\n      DIRECTORY=$(git rev-parse --git-dir) || die \"Not in a Git repository\"\n    elif [ -d \"${DIRECTORY}\"/.git ]; then\n      DIRECTORY=\"${DIRECTORY}/.git\"\n    fi\n    mkdir -p \"${DIRECTORY}/hooks\" || die \"Could not create dir: ${DIRECTORY}\"\n    install_all_hooks \"${DIRECTORY}\"\n    ;;\n  *) echo \"Unknown option: ${COMMAND}\" && \"$0\" -h ;;\nesac\n"
  },
  {
    "path": "git-secrets.1",
    "content": ".\\\" Man page generated from reStructuredText.\n.\n.TH GIT-SECRETS  \"\" \"\" \"\"\n.SH NAME\ngit-secrets \\- Prevents you from committing passwords and other sensitive information to a git repository.\n.\n.nr rst2man-indent-level 0\n.\n.de1 rstReportMargin\n\\\\$1 \\\\n[an-margin]\nlevel \\\\n[rst2man-indent-level]\nlevel margin: \\\\n[rst2man-indent\\\\n[rst2man-indent-level]]\n-\n\\\\n[rst2man-indent0]\n\\\\n[rst2man-indent1]\n\\\\n[rst2man-indent2]\n..\n.de1 INDENT\n.\\\" .rstReportMargin pre:\n. RS \\\\$1\n. nr rst2man-indent\\\\n[rst2man-indent-level] \\\\n[an-margin]\n. nr rst2man-indent-level +1\n.\\\" .rstReportMargin post:\n..\n.de UNINDENT\n. RE\n.\\\" indent \\\\n[an-margin]\n.\\\" old: \\\\n[rst2man-indent\\\\n[rst2man-indent-level]]\n.nr rst2man-indent-level -1\n.\\\" new: \\\\n[rst2man-indent\\\\n[rst2man-indent-level]]\n.in \\\\n[rst2man-indent\\\\n[rst2man-indent-level]]u\n..\n.SS Contents\n.INDENT 0.0\n.IP \\(bu 2\n\\fI\\%Synopsis\\fP\n.IP \\(bu 2\n\\fI\\%Description\\fP\n.IP \\(bu 2\n\\fI\\%Installing git\\-secrets\\fP\n.INDENT 2.0\n.IP \\(bu 2\n\\fI\\%*nix (Linux/macOS)\\fP\n.IP \\(bu 2\n\\fI\\%Windows\\fP\n.IP \\(bu 2\n\\fI\\%Homebrew (for macOS users)\\fP\n.UNINDENT\n.IP \\(bu 2\n\\fI\\%Advanced configuration\\fP\n.IP \\(bu 2\n\\fI\\%Before making public a repository\\fP\n.IP \\(bu 2\n\\fI\\%Options\\fP\n.INDENT 2.0\n.IP \\(bu 2\n\\fI\\%Operation Modes\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-install\\fP\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-scan\\fP\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-list\\fP\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-add\\fP\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-register\\-aws\\fP\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-aws\\-provider\\fP\\fP\n.IP \\(bu 2\n\\fI\\%Options for \\fB\\-\\-add\\-provider\\fP\\fP\n.UNINDENT\n.IP \\(bu 2\n\\fI\\%Defining prohibited patterns\\fP\n.IP \\(bu 2\n\\fI\\%Ignoring false positives\\fP\n.IP \\(bu 2\n\\fI\\%Secret providers\\fP\n.IP \\(bu 2\n\\fI\\%Example walkthrough\\fP\n.IP \\(bu 2\n\\fI\\%Skipping validation\\fP\n.IP \\(bu 2\n\\fI\\%About\\fP\n.UNINDENT\n.SH SYNOPSIS\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan [\\-r|\\-\\-recursive] [\\-\\-cached] [\\-\\-no\\-index] [\\-\\-untracked] [<files>...]\ngit secrets \\-\\-scan\\-history\ngit secrets \\-\\-install [\\-f|\\-\\-force] [<target\\-directory>]\ngit secrets \\-\\-list [\\-\\-global]\ngit secrets \\-\\-add [\\-a|\\-\\-allowed] [\\-l|\\-\\-literal] [\\-\\-global] <pattern>\ngit secrets \\-\\-add\\-provider [\\-\\-global] <command> [arguments...]\ngit secrets \\-\\-register\\-aws [\\-\\-global]\ngit secrets \\-\\-aws\\-provider [<credentials\\-file>]\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SH DESCRIPTION\n.sp\n\\fBgit\\-secrets\\fP scans commits, commit messages, and \\fB\\-\\-no\\-ff\\fP merges to\nprevent adding secrets into your git repositories. If a commit,\ncommit message, or any commit in a \\fB\\-\\-no\\-ff\\fP merge history matches one of\nyour configured prohibited regular expression patterns, then the commit is\nrejected.\n.SH INSTALLING GIT-SECRETS\n.sp\n\\fBgit\\-secrets\\fP must be placed somewhere in your PATH so that it is picked up\nby \\fBgit\\fP when running \\fBgit secrets\\fP\\&.\n.SS *nix (Linux/macOS)\n.IP \"System Message: WARNING/2 (README.rst:, line 43)\"\nTitle underline too short.\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\n\\e*nix (Linux/macOS)\n~~~~~~~~~~~~~~~~~\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nYou can use the \\fBinstall\\fP target of the provided Makefile to install \\fBgit secrets\\fP and the man page.\nYou can customize the install path using the PREFIX and MANPREFIX variables.\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\nmake install\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SS Windows\n.sp\nRun the provided \\fBinstall.ps1\\fP powershell script. This will copy the needed files\nto an installation directory (\\fB%USERPROFILE%/.git\\-secrets\\fP by default) and add\nthe directory to the current user \\fBPATH\\fP\\&.\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\nPS > ./install.ps1\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SS Homebrew (for macOS users)\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\nbrew install git\\-secrets\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\n\\fBWARNING:\\fP\n.INDENT 0.0\n.INDENT 3.5\nYou\\(aqre not done yet! You MUST install the git hooks for every repo that\nyou wish to use with \\fBgit secrets \\-\\-install\\fP\\&.\n.UNINDENT\n.UNINDENT\n.sp\nHere\\(aqs a quick example of how to ensure a git repository is scanned for secrets\non each commit:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ncd /path/to/my/repo\ngit secrets \\-\\-install\ngit secrets \\-\\-register\\-aws\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SH ADVANCED CONFIGURATION\n.sp\nAdd a configuration template if you want to add hooks to all repositories you\ninitialize or clone in the future.\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-register\\-aws \\-\\-global\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAdd hooks to all your local repositories.\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-install ~/.git\\-templates/git\\-secrets\ngit config \\-\\-global init.templateDir ~/.git\\-templates/git\\-secrets\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAdd custom providers to scan for security credentials.\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add\\-provider \\-\\- cat /path/to/secret/file/patterns\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SH BEFORE MAKING PUBLIC A REPOSITORY\n.sp\nWith git\\-secrets is also possible to scan a repository including all revisions:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan\\-history\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SH OPTIONS\n.SS Operation Modes\n.sp\nEach of these options must appear first on the command line.\n.INDENT 0.0\n.TP\n.B \\fB\\-\\-install\\fP\nInstalls git hooks for a repository. Once the hooks are installed for a git\nrepository, commits and non\\-fast\\-forward merges for that repository will be prevented\nfrom committing secrets.\n.TP\n.B \\fB\\-\\-scan\\fP\nScans one or more files for secrets. When a file contains a secret, the\nmatched text from the file being scanned will be written to stdout and the\nscript will exit with a non\\-zero status. Each matched line will be written with\nthe name of the file that matched, a colon, the line number that matched,\na colon, and then the line of text that matched. If no files are provided,\nall files returned by \\fBgit ls\\-files\\fP are scanned.\n.TP\n.B \\fB\\-\\-scan\\-history\\fP\nScans repository including all revisions. When a file contains a secret, the\nmatched text from the file being scanned will be written to stdout and the\nscript will exit with a non\\-zero status. Each matched line will be written with\nthe name of the file that matched, a colon, the line number that matched,\na colon, and then the line of text that matched.\n.TP\n.B \\fB\\-\\-list\\fP\nLists the \\fBgit\\-secrets\\fP configuration for the current repo or in the global\ngit config.\n.TP\n.B \\fB\\-\\-add\\fP\nAdds a prohibited or allowed pattern.\n.TP\n.B \\fB\\-\\-add\\-provider\\fP\nRegisters a secret provider. Secret providers are executables that when\ninvoked output prohibited patterns that \\fBgit\\-secrets\\fP should treat as\nprohibited.\n.TP\n.B \\fB\\-\\-register\\-aws\\fP\nAdds common AWS patterns to the git config and ensures that keys present\nin \\fB~/.aws/credentials\\fP are not found in any commit. The following\nchecks are added:\n.INDENT 7.0\n.IP \\(bu 2\nAWS Access Key IDs via \\fB(A3T[A\\-Z0\\-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A\\-Z0\\-9]{16}\\fP\n.IP \\(bu 2\nAmazon Bedrock API keys. Long\\-lived via \\fBABSK[A-Za-z0-9+/]{109,}=*\\fP and short\\-lived via \\fBbedrock\\-api\\-key\\-YmVkcm9jay5hbWF6b25hd3MuY29t\\fP\n.IP \\(bu 2\nAWS Secret Access Key assignments via \":\" or \"=\" surrounded by optional\nquotes\n.IP \\(bu 2\nAWS account ID assignments via \":\" or \"=\" surrounded by optional quotes\n.IP \\(bu 2\nAllowed patterns for example AWS keys (\\fBAKIAIOSFODNN7EXAMPLE\\fP and\n\\fBwJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\\fP)\n.IP \\(bu 2\nKnown credentials from \\fB~/.aws/credentials\\fP\n.UNINDENT\n.sp\n\\fBNOTE:\\fP\n.INDENT 7.0\n.INDENT 3.5\nWhile the patterns registered by this command should catch most\ninstances of AWS credentials, these patterns are \\fBnot\\fP guaranteed to\ncatch them \\fBall\\fP\\&. \\fBgit\\-secrets\\fP should be used as an extra means of\ninsurance \\-\\- you still need to do your due diligence to ensure that you\ndo not commit credentials to a repository.\n.UNINDENT\n.UNINDENT\n.TP\n.B \\fB\\-\\-aws\\-provider\\fP\nSecret provider that outputs credentials found in an INI file. You can\noptionally provide the path to an INI file.\n.UNINDENT\n.SS Options for \\fB\\-\\-install\\fP\n.INDENT 0.0\n.TP\n.B \\fB\\-f, \\-\\-force\\fP\nOverwrites existing hooks if present.\n.TP\n.B \\fB<target\\-directory>\\fP\nWhen provided, installs git hooks to the given directory. The current\ndirectory is assumed if \\fB<target\\-directory>\\fP is not provided.\n.sp\nIf the provided \\fB<target\\-directory>\\fP is not in a git repository, the\ndirectory will be created and hooks will be placed in\n\\fB<target\\-directory>/hooks\\fP\\&. This can be useful for creating git template\ndirectories using with \\fBgit init \\-\\-template <target\\-directory>\\fP\\&.\n.sp\nYou can run \\fBgit init\\fP on a repository that has already been initialized.\nFrom the \\fI\\%git init documentation\\fP:\n.INDENT 7.0\n.INDENT 3.5\nFrom the git documentation: Running \\fBgit init\\fP in an existing repository\nis safe. It will not overwrite things that are already there. The\nprimary reason for rerunning \\fBgit init\\fP is to pick up newly added\ntemplates (or to move the repository to another place if\n\\fB\\-\\-separate\\-git\\-dir\\fP is given).\n.UNINDENT\n.UNINDENT\n.sp\nThe following git hooks are installed:\n.INDENT 7.0\n.IP 1. 3\n\\fBpre\\-commit\\fP: Used to check if any of the files changed in the commit\nuse prohibited patterns.\n.IP 2. 3\n\\fBcommit\\-msg\\fP: Used to determine if a commit message contains a\nprohibited patterns.\n.IP 3. 3\n\\fBprepare\\-commit\\-msg\\fP: Used to determine if a merge commit will\nintroduce a history that contains a prohibited pattern at any point.\nPlease note that this hook is only invoked for non fast\\-forward merges.\n.UNINDENT\n.sp\n\\fBNOTE:\\fP\n.INDENT 7.0\n.INDENT 3.5\nGit only allows a single script to be executed per hook. If the\nrepository contains Debian\\-style subdirectories like \\fBpre\\-commit.d\\fP\nand \\fBcommit\\-msg.d\\fP, then the git hooks will be installed into these\ndirectories, which assumes that you\\(aqve configured the corresponding\nhooks to execute all of the scripts found in these directories. If\nthese git subdirectories are not present, then the git hooks will be\ninstalled to the git repo\\(aqs \\fB\\&.git/hooks\\fP directory.\n.UNINDENT\n.UNINDENT\n.UNINDENT\n.SS Examples\n.sp\nInstall git hooks to the current directory:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ncd /path/to/my/repository\ngit secrets \\-\\-install\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nInstall git hooks to a repository other than the current directory:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-install /path/to/my/repository\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nCreate a git template that has \\fBgit\\-secrets\\fP installed, and then copy that\ntemplate into a git repository:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-install ~/.git\\-templates/git\\-secrets\ngit init \\-\\-template ~/.git\\-templates/git\\-secrets\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nOverwrite existing hooks if present:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-install \\-f\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SS Options for \\fB\\-\\-scan\\fP\n.INDENT 0.0\n.TP\n.B \\fB\\-r, \\-\\-recursive\\fP\nScans the given files recursively. If a directory is encountered, the\ndirectory will be scanned. If \\fB\\-r\\fP is not provided, directories will be\nignored.\n.sp\n\\fB\\-r\\fP cannot be used alongside \\fB\\-\\-cached\\fP, \\fB\\-\\-no\\-index\\fP, or\n\\fB\\-\\-untracked\\fP\\&.\n.TP\n.B \\fB\\-\\-cached\\fP\nSearches blobs registered in the index file.\n.TP\n.B \\fB\\-\\-no\\-index\\fP\nSearches files in the current directory that is not managed by git.\n.TP\n.B \\fB\\-\\-untracked\\fP\nIn addition to searching in the tracked files in the working tree,\n\\fB\\-\\-scan\\fP also in untracked files.\n.TP\n.B \\fB<files>...\\fP\nThe path to one or more files on disk to scan for secrets.\n.sp\nIf no files are provided, all files returned by \\fBgit ls\\-files\\fP are\nscanned.\n.UNINDENT\n.SS Examples\n.sp\nScan all files in the repo:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nScans a single file for secrets:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan /path/to/file\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nScans a directory recursively for secrets:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan \\-r /path/to/directory\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nScans multiple files for secrets:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan /path/to/file /path/to/other/file\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nYou can scan by globbing:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-scan /path/to/directory/*\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nScan from stdin:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\necho \\(aqhello!\\(aq | git secrets \\-\\-scan \\-\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SS Options for \\fB\\-\\-list\\fP\n.INDENT 0.0\n.TP\n.B \\fB\\-\\-global\\fP\nLists only git\\-secrets configuration in the global git config.\n.UNINDENT\n.SS Options for \\fB\\-\\-add\\fP\n.INDENT 0.0\n.TP\n.B \\fB\\-\\-global\\fP\nAdds patterns to the global git config\n.TP\n.B \\fB\\-l, \\-\\-literal\\fP\nEscapes special regular expression characters in the provided pattern so\nthat the pattern is searched for literally.\n.TP\n.B \\fB\\-a, \\-\\-allowed\\fP\nMark the pattern as allowed instead of prohibited. Allowed patterns are\nused to filter out false positives.\n.TP\n.B \\fB<pattern>\\fP\nThe regex pattern to search.\n.UNINDENT\n.SS Examples\n.sp\nAdds a prohibited pattern to the current repo:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\(aq[A\\-Z0\\-9]{20}\\(aq\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAdds a prohibited pattern to the global git config:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\-\\-global \\(aq[A\\-Z0\\-9]{20}\\(aq\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAdds a string that is scanned for literally (\\fB+\\fP is escaped):\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\-\\-literal \\(aqfoo+bar\\(aq\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAdd an allowed pattern:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\-a \\(aqallowed pattern\\(aq\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SS Options for \\fB\\-\\-register\\-aws\\fP\n.INDENT 0.0\n.TP\n.B \\fB\\-\\-global\\fP\nAdds AWS specific configuration variables to the global git config.\n.UNINDENT\n.SS Options for \\fB\\-\\-aws\\-provider\\fP\n.INDENT 0.0\n.TP\n.B \\fB[<credentials\\-file>]\\fP\nIf provided, specifies the custom path to an INI file to scan. If not\nprovided, \\fB~/.aws/credentials\\fP is assumed.\n.UNINDENT\n.SS Options for \\fB\\-\\-add\\-provider\\fP\n.INDENT 0.0\n.TP\n.B \\fB\\-\\-global\\fP\nAdds the provider to the global git config.\n.TP\n.B \\fB<command>\\fP\nProvider command to invoke. When invoked the command is expected to write\nprohibited patterns separated by new lines to stdout. Any extra arguments\nprovided are passed on to the command.\n.UNINDENT\n.SS Examples\n.sp\nRegisters a secret provider with arguments:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add\\-provider \\-\\- git secrets \\-\\-aws\\-provider\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nCats secrets out of a file:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add\\-provider \\-\\- cat /path/to/secret/file/patterns\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.SH DEFINING PROHIBITED PATTERNS\n.sp\n\\fBegrep\\fP\\-compatible regular expressions are used to determine if a commit or\ncommit message contains any prohibited patterns. These regular expressions are\ndefined using the \\fBgit config\\fP command. It is important to note that\ndifferent systems use different versions of egrep. For example, when running on\nmacOS, you will use a different version of \\fBegrep\\fP than when running on something\nlike Ubuntu (BSD vs GNU).\n.sp\nYou can add prohibited regular expression patterns to your git config using\n\\fBgit secrets \\-\\-add <pattern>\\fP\\&.\n.SH IGNORING FALSE POSITIVES\n.sp\nSometimes a regular expression might match false positives. For example, git\ncommit SHAs look a lot like AWS access keys. You can specify many different\nregular expression patterns as false positives using the following command:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\-\\-allowed \\(aqmy regex pattern\\(aq\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nYou can also add regular expressions patterns to filter false positives to a\n\\fB\\&.gitallowed\\fP file located in the repository\\(aqs root directory. Lines starting\nwith \\fB#\\fP are skipped (comment line) and empty lines are also skipped.\n.sp\nFirst, git\\-secrets will extract all lines from a file that contain a prohibited\nmatch. Included in the matched results will be the full path to the name of\nthe file that was matched, followed by \\(aq:\\(aq, followed by the line number that was\nmatched, followed by the entire line from the file that was matched by a secret\npattern. Then, if you\\(aqve defined allowed regular expressions, git\\-secrets will\ncheck to see if all of the matched lines match at least one of your registered\nallowed regular expressions. If all of the lines that were flagged as secret\nare canceled out by an allowed match, then the subject text does not contain\nany secrets. If any of the matched lines are not matched by an allowed regular\nexpression, then git\\-secrets will fail the commit/merge/message.\n.sp\n\\fBIMPORTANT:\\fP\n.INDENT 0.0\n.INDENT 3.5\nJust as it is a bad practice to add prohibited patterns that are too\ngreedy, it is also a bad practice to add allowed patterns that are too\nforgiving. Be sure to test out your patterns using ad\\-hoc calls to\n\\fBgit secrets \\-\\-scan $filename\\fP to ensure they are working as intended.\n.UNINDENT\n.UNINDENT\n.SH SECRET PROVIDERS\n.sp\nSometimes you want to check for an exact pattern match against a set of known\nsecrets. For example, you might want to ensure that no credentials present in\n\\fB~/.aws/credentials\\fP ever show up in a commit. In these cases, it\\(aqs better to\nleave these secrets in one location rather than spread them out across git\nrepositories in git configs. You can use \"secret providers\" to fetch these\ntypes of credentials. A secret provider is an executable that when invoked\noutputs prohibited patterns separated by new lines.\n.sp\nYou can add secret providers using the \\fB\\-\\-add\\-provider\\fP command:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add\\-provider \\-\\- git secrets \\-\\-aws\\-provider\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nNotice the use of \\fB\\-\\-\\fP\\&. This ensures that any arguments associated with the\nprovider are passed to the provider each time it is invoked when scanning\nfor secrets.\n.SH EXAMPLE WALKTHROUGH\n.sp\nLet\\(aqs take a look at an example. Given the following subject text (stored in\n\\fB/tmp/example\\fP):\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\nThis is a test!\npassword=ex@mplepassword\npassword=******\nMore test...\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAnd the following registered patterns:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\(aqpassword\\es*=\\es*.+\\(aq\ngit secrets \\-\\-add \\-\\-allowed \\-\\-literal \\(aqex@mplepassword\\(aq\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nRunning \\fBgit secrets \\-\\-scan /tmp/example\\fP, the result will\nresult in the following error output:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\n/tmp/example:3:password=******\n\n[ERROR] Matched prohibited pattern\n\nPossible mitigations:\n\\- Mark false positives as allowed using: git config \\-\\-add secrets.allowed ...\n\\- List your configured patterns: git config \\-\\-get\\-all secrets.patterns\n\\- List your configured allowed patterns: git config \\-\\-get\\-all secrets.allowed\n\\- Use \\-\\-no\\-verify if this is a one\\-time false positive\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nBreaking this down, the prohibited pattern value of \\fBpassword\\es*=\\es*.+\\fP will\nmatch the following lines:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\n/tmp/example:2:password=ex@mplepassword\n/tmp/example:3:password=******\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\n\\&...But the first match will be filtered out due to the fact that it matches the\nallowed regular expression of \\fBex@mplepassword\\fP\\&. Because there is still a\nremaining line that did not match, it is considered a secret.\n.sp\nBecause that matching lines are placed on lines that start with the filename\nand line number (e.g., \\fB/tmp/example:3:...\\fP), you can create allowed\npatterns that take filenames and line numbers into account in the regular\nexpression. For example, you could whitelist an entire file using something\nlike:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\-\\-allowed \\(aq/tmp/example:.*\\(aq\ngit secrets \\-\\-scan /tmp/example && echo $?\n# Outputs: 0\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nAlternatively, you could allow a specific line number of a file if that\nline is unlikely to change using something like the following:\n.INDENT 0.0\n.INDENT 3.5\n.sp\n.nf\n.ft C\ngit secrets \\-\\-add \\-\\-allowed \\(aq/tmp/example:3:.*\\(aq\ngit secrets \\-\\-scan /tmp/example && echo $?\n# Outputs: 0\n.ft P\n.fi\n.UNINDENT\n.UNINDENT\n.sp\nKeep this in mind when creating allowed patterns to ensure that your allowed\npatterns are not inadvertently matched due to the fact that the filename is\nincluded in the subject text that allowed patterns are matched against.\n.SH SKIPPING VALIDATION\n.sp\nUse the \\fB\\-\\-no\\-verify\\fP option in the event of a false positive match in a\ncommit, merge, or commit message. This will skip the execution of the\ngit hook and allow you to make the commit or merge.\n.SH ABOUT\n.INDENT 0.0\n.IP \\(bu 2\nAuthor: \\fI\\%Michael Dowling\\fP\n.IP \\(bu 2\nIssue tracker: This project\\(aqs source code and issue tracker can be found at\n\\fI\\%https://github.com/awslabs/git\\-secrets\\fP\n.IP \\(bu 2\nSpecial thanks to Adrian Vatchinsky and Ari Juels of Cornell University for\nproviding suggestions and feedback.\n.UNINDENT\n.sp\nCopyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n.\\\" Generated by docutils manpage writer.\n.\n"
  },
  {
    "path": "install.ps1",
    "content": "Param([string]$InstallationDirectory = $($Env:USERPROFILE + \"\\.git-secrets\"))\n\nWrite-Host \"Checking to see if installation directory already exists...\"\nif (-not (Test-Path $InstallationDirectory))\n{\n    Write-Host \"Creating installation directory.\"\n    New-Item -ItemType Directory -Path $InstallationDirectory | Out-Null\n}\nelse\n{\n    Write-Host \"Installation directory already exists.\"\n}\n\nWrite-Host \"Copying files.\"\nCopy-Item ./git-secrets -Destination $InstallationDirectory -Force\nCopy-Item ./git-secrets.1 -Destination $InstallationDirectory -Force\n\nWrite-Host \"Checking if directory already exists in Path...\"\n$currentPath = [Environment]::GetEnvironmentVariable(\"PATH\", \"User\")\nif ($currentPath -notlike \"*$InstallationDirectory*\")\n{\n    Write-Host \"Adding to path.\"\n    $newPath = $currentPath\n    if(-not ($newPath.EndsWith(\";\")))\n    {\n        $newPath = $newPath + \";\"\n    }\n    $newPath = $newPath + $InstallationDirectory\n    [Environment]::SetEnvironmentVariable(\"PATH\", $newPath, \"User\")\n}\nelse\n{\n    Write-Host \"Already in Path.\"\n}\n\n# Adding to Session\nWrite-Host \"Adding to user session.\"\n$currentSessionPath = $Env:Path\nif ($currentSessionPath -notlike \"*$InstallationDirectory*\")\n{\n    if(-not ($currentSessionPath.EndsWith(\";\")))\n    {\n        $currentSessionPath = $currentSessionPath + \";\"\n    }\n    $Env:Path = $currentSessionPath + $InstallationDirectory\n}\n\nWrite-Host \"Done.\""
  },
  {
    "path": "test/bats/LICENSE",
    "content": "Copyright (c) 2014 Sam Stephenson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "test/bats/libexec/bats",
    "content": "#!/usr/bin/env bash\nset -e\n\nversion() {\n  echo \"Bats 0.4.0\"\n}\n\nusage() {\n  version\n  echo \"Usage: bats [-c] [-p | -t] <test> [<test> ...]\"\n}\n\nhelp() {\n  usage\n  echo\n  echo \"  <test> is the path to a Bats test file, or the path to a directory\"\n  echo \"  containing Bats test files.\"\n  echo\n  echo \"  -c, --count    Count the number of test cases without running any tests\"\n  echo \"  -h, --help     Display this help message\"\n  echo \"  -p, --pretty   Show results in pretty format (default for terminals)\"\n  echo \"  -t, --tap      Show results in TAP format\"\n  echo \"  -v, --version  Display the version number\"\n  echo\n  echo \"  For more information, see https://github.com/sstephenson/bats\"\n  echo\n}\n\nresolve_link() {\n  $(type -p greadlink readlink | head -1) \"$1\"\n}\n\nabs_dirname() {\n  local cwd=\"$(pwd)\"\n  local path=\"$1\"\n\n  while [ -n \"$path\" ]; do\n    cd \"${path%/*}\"\n    local name=\"${path##*/}\"\n    path=\"$(resolve_link \"$name\" || true)\"\n  done\n\n  pwd\n  cd \"$cwd\"\n}\n\nexpand_path() {\n  { cd \"$(dirname \"$1\")\" 2>/dev/null\n    local dirname=\"$PWD\"\n    cd \"$OLDPWD\"\n    echo \"$dirname/$(basename \"$1\")\"\n  } || echo \"$1\"\n}\n\nBATS_LIBEXEC=\"$(abs_dirname \"$0\")\"\nexport BATS_PREFIX=\"$(abs_dirname \"$BATS_LIBEXEC\")\"\nexport BATS_CWD=\"$(abs_dirname .)\"\nexport PATH=\"$BATS_LIBEXEC:$PATH\"\n\noptions=()\narguments=()\nfor arg in \"$@\"; do\n  if [ \"${arg:0:1}\" = \"-\" ]; then\n    if [ \"${arg:1:1}\" = \"-\" ]; then\n      options[${#options[*]}]=\"${arg:2}\"\n    else\n      index=1\n      while option=\"${arg:$index:1}\"; do\n        [ -n \"$option\" ] || break\n        options[${#options[*]}]=\"$option\"\n        let index+=1\n      done\n    fi\n  else\n    arguments[${#arguments[*]}]=\"$arg\"\n  fi\ndone\n\nunset count_flag pretty\n[ -t 0 ] && [ -t 1 ] && pretty=\"1\"\n[ -n \"$CI\" ] && pretty=\"\"\n\nfor option in \"${options[@]}\"; do\n  case \"$option\" in\n  \"h\" | \"help\" )\n    help\n    exit 0\n    ;;\n  \"v\" | \"version\" )\n    version\n    exit 0\n    ;;\n  \"c\" | \"count\" )\n    count_flag=\"-c\"\n    ;;\n  \"t\" | \"tap\" )\n    pretty=\"\"\n    ;;\n  \"p\" | \"pretty\" )\n    pretty=\"1\"\n    ;;\n  * )\n    usage >&2\n    exit 1\n    ;;\n  esac\ndone\n\nif [ \"${#arguments[@]}\" -eq 0 ]; then\n  usage >&2\n  exit 1\nfi\n\nfilenames=()\nfor filename in \"${arguments[@]}\"; do\n  if [ -d \"$filename\" ]; then\n    shopt -s nullglob\n    for suite_filename in \"$(expand_path \"$filename\")\"/*.bats; do\n      filenames[\"${#filenames[@]}\"]=\"$suite_filename\"\n    done\n    shopt -u nullglob\n  else\n    filenames[\"${#filenames[@]}\"]=\"$(expand_path \"$filename\")\"\n  fi\ndone\n\nif [ \"${#filenames[@]}\" -eq 1 ]; then\n  command=\"bats-exec-test\"\nelse\n  command=\"bats-exec-suite\"\nfi\n\nif [ -n \"$pretty\" ]; then\n  extended_syntax_flag=\"-x\"\n  formatter=\"bats-format-tap-stream\"\nelse\n  extended_syntax_flag=\"\"\n  formatter=\"cat\"\nfi\n\nset -o pipefail execfail\nexec \"$command\" $count_flag $extended_syntax_flag \"${filenames[@]}\" | \"$formatter\"\n"
  },
  {
    "path": "test/bats/libexec/bats-exec-suite",
    "content": "#!/usr/bin/env bash\nset -e\n\ncount_only_flag=\"\"\nif [ \"$1\" = \"-c\" ]; then\n  count_only_flag=1\n  shift\nfi\n\nextended_syntax_flag=\"\"\nif [ \"$1\" = \"-x\" ]; then\n  extended_syntax_flag=\"-x\"\n  shift\nfi\n\ntrap \"kill 0; exit 1\" int\n\ncount=0\nfor filename in \"$@\"; do\n  let count+=\"$(bats-exec-test -c \"$filename\")\"\ndone\n\nif [ -n \"$count_only_flag\" ]; then\n  echo \"$count\"\n  exit\nfi\n\necho \"1..$count\"\nstatus=0\noffset=0\nfor filename in \"$@\"; do\n  index=0\n  {\n    IFS= read -r # 1..n\n    while IFS= read -r line; do\n      case \"$line\" in\n      \"begin \"* )\n        let index+=1\n        echo \"${line/ $index / $(($offset + $index)) }\"\n        ;;\n      \"ok \"* | \"not ok \"* )\n        [ -n \"$extended_syntax_flag\" ] || let index+=1\n        echo \"${line/ $index / $(($offset + $index)) }\"\n        [ \"${line:0:6}\" != \"not ok\" ] || status=1\n        ;;\n      * )\n        echo \"$line\"\n        ;;\n      esac\n    done\n  } < <( bats-exec-test $extended_syntax_flag \"$filename\" )\n  offset=$(($offset + $index))\ndone\n\nexit \"$status\"\n"
  },
  {
    "path": "test/bats/libexec/bats-exec-test",
    "content": "#!/usr/bin/env bash\nset -e\nset -E\nset -T\n\nBATS_COUNT_ONLY=\"\"\nif [ \"$1\" = \"-c\" ]; then\n  BATS_COUNT_ONLY=1\n  shift\nfi\n\nBATS_EXTENDED_SYNTAX=\"\"\nif [ \"$1\" = \"-x\" ]; then\n  BATS_EXTENDED_SYNTAX=\"$1\"\n  shift\nfi\n\nBATS_TEST_FILENAME=\"$1\"\nif [ -z \"$BATS_TEST_FILENAME\" ]; then\n  echo \"usage: bats-exec <filename>\" >&2\n  exit 1\nelif [ ! -f \"$BATS_TEST_FILENAME\" ]; then\n  echo \"bats: $BATS_TEST_FILENAME does not exist\" >&2\n  exit 1\nelse\n  shift\nfi\n\nBATS_TEST_DIRNAME=\"$(dirname \"$BATS_TEST_FILENAME\")\"\nBATS_TEST_NAMES=()\n\nload() {\n  local name=\"$1\"\n  local filename\n\n  if [ \"${name:0:1}\" = \"/\" ]; then\n    filename=\"${name}\"\n  else\n    filename=\"$BATS_TEST_DIRNAME/${name}.bash\"\n  fi\n\n  [ -f \"$filename\" ] || {\n    echo \"bats: $filename does not exist\" >&2\n    exit 1\n  }\n\n  source \"${filename}\"\n}\n\nrun() {\n  local e E T oldIFS\n  [[ ! \"$-\" =~ e ]] || e=1\n  [[ ! \"$-\" =~ E ]] || E=1\n  [[ ! \"$-\" =~ T ]] || T=1\n  set +e\n  set +E\n  set +T\n  output=\"$(\"$@\" 2>&1)\"\n  status=\"$?\"\n  oldIFS=$IFS\n  IFS=$'\\n' lines=($output)\n  [ -z \"$e\" ] || set -e\n  [ -z \"$E\" ] || set -E\n  [ -z \"$T\" ] || set -T\n  IFS=$oldIFS\n}\n\nsetup() {\n  true\n}\n\nteardown() {\n  true\n}\n\nskip() {\n  BATS_TEST_SKIPPED=${1:-1}\n  BATS_TEST_COMPLETED=1\n  exit 0\n}\n\nbats_test_begin() {\n  BATS_TEST_DESCRIPTION=\"$1\"\n  if [ -n \"$BATS_EXTENDED_SYNTAX\" ]; then\n    echo \"begin $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION\" >&3\n  fi\n  setup\n}\n\nbats_test_function() {\n  local test_name=\"$1\"\n  BATS_TEST_NAMES[\"${#BATS_TEST_NAMES[@]}\"]=\"$test_name\"\n}\n\nbats_capture_stack_trace() {\n  BATS_PREVIOUS_STACK_TRACE=( \"${BATS_CURRENT_STACK_TRACE[@]}\" )\n  BATS_CURRENT_STACK_TRACE=()\n\n  local test_pattern=\" $BATS_TEST_NAME $BATS_TEST_SOURCE\"\n  local setup_pattern=\" setup $BATS_TEST_SOURCE\"\n  local teardown_pattern=\" teardown $BATS_TEST_SOURCE\"\n\n  local frame\n  local index=1\n\n  while frame=\"$(caller \"$index\")\"; do\n    BATS_CURRENT_STACK_TRACE[\"${#BATS_CURRENT_STACK_TRACE[@]}\"]=\"$frame\"\n    if [[ \"$frame\" = *\"$test_pattern\"     || \\\n          \"$frame\" = *\"$setup_pattern\"    || \\\n          \"$frame\" = *\"$teardown_pattern\" ]]; then\n      break\n    else\n      let index+=1\n    fi\n  done\n\n  BATS_SOURCE=\"$(bats_frame_filename \"${BATS_CURRENT_STACK_TRACE[0]}\")\"\n  BATS_LINENO=\"$(bats_frame_lineno \"${BATS_CURRENT_STACK_TRACE[0]}\")\"\n}\n\nbats_print_stack_trace() {\n  local frame\n  local index=1\n  local count=\"${#@}\"\n\n  for frame in \"$@\"; do\n    local filename=\"$(bats_trim_filename \"$(bats_frame_filename \"$frame\")\")\"\n    local lineno=\"$(bats_frame_lineno \"$frame\")\"\n\n    if [ $index -eq 1 ]; then\n      echo -n \"# (\"\n    else\n      echo -n \"#  \"\n    fi\n\n    local fn=\"$(bats_frame_function \"$frame\")\"\n    if [ \"$fn\" != \"$BATS_TEST_NAME\" ]; then\n      echo -n \"from function \\`$fn' \"\n    fi\n\n    if [ $index -eq $count ]; then\n      echo \"in test file $filename, line $lineno)\"\n    else\n      echo \"in file $filename, line $lineno,\"\n    fi\n\n    let index+=1\n  done\n}\n\nbats_print_failed_command() {\n  local frame=\"$1\"\n  local status=\"$2\"\n  local filename=\"$(bats_frame_filename \"$frame\")\"\n  local lineno=\"$(bats_frame_lineno \"$frame\")\"\n\n  local failed_line=\"$(bats_extract_line \"$filename\" \"$lineno\")\"\n  local failed_command=\"$(bats_strip_string \"$failed_line\")\"\n  echo -n \"#   \\`${failed_command}' \"\n\n  if [ $status -eq 1 ]; then\n    echo \"failed\"\n  else\n    echo \"failed with status $status\"\n  fi\n}\n\nbats_frame_lineno() {\n  local frame=\"$1\"\n  local lineno=\"${frame%% *}\"\n  echo \"$lineno\"\n}\n\nbats_frame_function() {\n  local frame=\"$1\"\n  local rest=\"${frame#* }\"\n  local fn=\"${rest%% *}\"\n  echo \"$fn\"\n}\n\nbats_frame_filename() {\n  local frame=\"$1\"\n  local rest=\"${frame#* }\"\n  local filename=\"${rest#* }\"\n\n  if [ \"$filename\" = \"$BATS_TEST_SOURCE\" ]; then\n    echo \"$BATS_TEST_FILENAME\"\n  else\n    echo \"$filename\"\n  fi\n}\n\nbats_extract_line() {\n  local filename=\"$1\"\n  local lineno=\"$2\"\n  sed -n \"${lineno}p\" \"$filename\"\n}\n\nbats_strip_string() {\n  local string=\"$1\"\n  printf \"%s\" \"$string\" | sed -e \"s/^[ \"$'\\t'\"]*//\" -e \"s/[ \"$'\\t'\"]*$//\"\n}\n\nbats_trim_filename() {\n  local filename=\"$1\"\n  local length=\"${#BATS_CWD}\"\n\n  if [ \"${filename:0:length+1}\" = \"${BATS_CWD}/\" ]; then\n    echo \"${filename:length+1}\"\n  else\n    echo \"$filename\"\n  fi\n}\n\nbats_debug_trap() {\n  if [ \"$BASH_SOURCE\" != \"$1\" ]; then\n    bats_capture_stack_trace\n  fi\n}\n\nbats_error_trap() {\n  BATS_ERROR_STATUS=\"$?\"\n  BATS_ERROR_STACK_TRACE=( \"${BATS_PREVIOUS_STACK_TRACE[@]}\" )\n  trap - debug\n}\n\nbats_teardown_trap() {\n  trap \"bats_exit_trap\" exit\n  local status=0\n  teardown >>\"$BATS_OUT\" 2>&1 || status=\"$?\"\n\n  if [ $status -eq 0 ]; then\n    BATS_TEARDOWN_COMPLETED=1\n  elif [ -n \"$BATS_TEST_COMPLETED\" ]; then\n    BATS_ERROR_STATUS=\"$status\"\n    BATS_ERROR_STACK_TRACE=( \"${BATS_CURRENT_STACK_TRACE[@]}\" )\n  fi\n\n  bats_exit_trap\n}\n\nbats_exit_trap() {\n  local status\n  local skipped\n  trap - err exit\n\n  skipped=\"\"\n  if [ -n \"$BATS_TEST_SKIPPED\" ]; then\n    skipped=\" # skip\"\n    if [ \"1\" != \"$BATS_TEST_SKIPPED\" ]; then\n      skipped+=\" ($BATS_TEST_SKIPPED)\"\n    fi\n  fi\n\n  if [ -z \"$BATS_TEST_COMPLETED\" ] || [ -z \"$BATS_TEARDOWN_COMPLETED\" ]; then\n    echo \"not ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION\" >&3\n    bats_print_stack_trace \"${BATS_ERROR_STACK_TRACE[@]}\" >&3\n    bats_print_failed_command \"${BATS_ERROR_STACK_TRACE[${#BATS_ERROR_STACK_TRACE[@]}-1]}\" \"$BATS_ERROR_STATUS\" >&3\n    sed -e \"s/^/# /\" < \"$BATS_OUT\" >&3\n    status=1\n  else\n    echo \"ok ${BATS_TEST_NUMBER}${skipped} ${BATS_TEST_DESCRIPTION}\" >&3\n    status=0\n  fi\n\n  rm -f \"$BATS_OUT\"\n  exit \"$status\"\n}\n\nbats_perform_tests() {\n  echo \"1..$#\"\n  test_number=1\n  status=0\n  for test_name in \"$@\"; do\n    \"$0\" $BATS_EXTENDED_SYNTAX \"$BATS_TEST_FILENAME\" \"$test_name\" \"$test_number\" || status=1\n    let test_number+=1\n  done\n  exit \"$status\"\n}\n\nbats_perform_test() {\n  BATS_TEST_NAME=\"$1\"\n  if [ \"$(type -t \"$BATS_TEST_NAME\" || true)\" = \"function\" ]; then\n    BATS_TEST_NUMBER=\"$2\"\n    if [ -z \"$BATS_TEST_NUMBER\" ]; then\n      echo \"1..1\"\n      BATS_TEST_NUMBER=\"1\"\n    fi\n\n    BATS_TEST_COMPLETED=\"\"\n    BATS_TEARDOWN_COMPLETED=\"\"\n    trap \"bats_debug_trap \\\"\\$BASH_SOURCE\\\"\" debug\n    trap \"bats_error_trap\" err\n    trap \"bats_teardown_trap\" exit\n    \"$BATS_TEST_NAME\" >>\"$BATS_OUT\" 2>&1\n    BATS_TEST_COMPLETED=1\n\n  else\n    echo \"bats: unknown test name \\`$BATS_TEST_NAME'\" >&2\n    exit 1\n  fi\n}\n\nif [ -z \"$TMPDIR\" ]; then\n  BATS_TMPDIR=\"/tmp\"\nelse\n  BATS_TMPDIR=\"${TMPDIR%/}\"\nfi\n\nBATS_TMPNAME=\"$BATS_TMPDIR/bats.$$\"\nBATS_PARENT_TMPNAME=\"$BATS_TMPDIR/bats.$PPID\"\nBATS_OUT=\"${BATS_TMPNAME}.out\"\n\nbats_preprocess_source() {\n  BATS_TEST_SOURCE=\"${BATS_TMPNAME}.src\"\n  { tr -d '\\r' < \"$BATS_TEST_FILENAME\"; echo; } | bats-preprocess > \"$BATS_TEST_SOURCE\"\n  trap \"bats_cleanup_preprocessed_source\" err exit\n  trap \"bats_cleanup_preprocessed_source; exit 1\" int\n}\n\nbats_cleanup_preprocessed_source() {\n  rm -f \"$BATS_TEST_SOURCE\"\n}\n\nbats_evaluate_preprocessed_source() {\n  if [ -z \"$BATS_TEST_SOURCE\" ]; then\n    BATS_TEST_SOURCE=\"${BATS_PARENT_TMPNAME}.src\"\n  fi\n  source \"$BATS_TEST_SOURCE\"\n}\n\nexec 3<&1\n\nif [ \"$#\" -eq 0 ]; then\n  bats_preprocess_source\n  bats_evaluate_preprocessed_source\n\n  if [ -n \"$BATS_COUNT_ONLY\" ]; then\n    echo \"${#BATS_TEST_NAMES[@]}\"\n  else\n    bats_perform_tests \"${BATS_TEST_NAMES[@]}\"\n  fi\nelse\n  bats_evaluate_preprocessed_source\n  bats_perform_test \"$@\"\nfi\n"
  },
  {
    "path": "test/bats/libexec/bats-format-tap-stream",
    "content": "#!/usr/bin/env bash\nset -e\n\n# Just stream the TAP output (sans extended syntax) if tput is missing\ncommand -v tput >/dev/null || exec grep -v \"^begin \"\n\nheader_pattern='[0-9]+\\.\\.[0-9]+'\nIFS= read -r header\n\nif [[ \"$header\" =~ $header_pattern ]]; then\n  count=\"${header:3}\"\n  index=0\n  failures=0\n  skipped=0\n  name=\"\"\n  count_column_width=$(( ${#count} * 2 + 2 ))\nelse\n  # If the first line isn't a TAP plan, print it and pass the rest through\n  printf \"%s\\n\" \"$header\"\n  exec cat\nfi\n\nupdate_screen_width() {\n  screen_width=\"$(tput cols)\"\n  count_column_left=$(( $screen_width - $count_column_width ))\n}\n\ntrap update_screen_width WINCH\nupdate_screen_width\n\nbegin() {\n  go_to_column 0\n  printf_with_truncation $(( $count_column_left - 1 )) \"   %s\" \"$name\"\n  clear_to_end_of_line\n  go_to_column $count_column_left\n  printf \"%${#count}s/${count}\" \"$index\"\n  go_to_column 1\n}\n\npass() {\n  go_to_column 0\n  printf \" ✓ %s\" \"$name\"\n  advance\n}\n\nskip() {\n  local reason=\"$1\"\n  [ -z \"$reason\" ] || reason=\": $reason\"\n  go_to_column 0\n  printf \" - %s (skipped%s)\" \"$name\" \"$reason\"\n  advance\n}\n\nfail() {\n  go_to_column 0\n  set_color 1 bold\n  printf \" ✗ %s\" \"$name\"\n  advance\n}\n\nlog() {\n  set_color 1\n  printf \"   %s\\n\" \"$1\"\n  clear_color\n}\n\nsummary() {\n  printf \"\\n%d test%s\" \"$count\" \"$(plural \"$count\")\"\n\n  printf \", %d failure%s\" \"$failures\" \"$(plural \"$failures\")\"\n\n  if [ \"$skipped\" -gt 0 ]; then\n    printf \", %d skipped\" \"$skipped\"\n  fi\n\n  printf \"\\n\"\n}\n\nprintf_with_truncation() {\n  local width=\"$1\"\n  shift\n  local string=\"$(printf \"$@\")\"\n\n  if [ \"${#string}\" -gt \"$width\" ]; then\n    printf \"%s...\" \"${string:0:$(( $width - 4 ))}\"\n  else\n    printf \"%s\" \"$string\"\n  fi\n}\n\ngo_to_column() {\n  local column=\"$1\"\n  printf \"\\x1B[%dG\" $(( $column + 1 ))\n}\n\nclear_to_end_of_line() {\n  printf \"\\x1B[K\"\n}\n\nadvance() {\n  clear_to_end_of_line\n  echo\n  clear_color\n}\n\nset_color() {\n  local color=\"$1\"\n  local weight=\"$2\"\n  printf \"\\x1B[%d;%dm\" $(( 30 + $color )) \"$( [ \"$weight\" = \"bold\" ] && echo 1 || echo 22 )\"\n}\n\nclear_color() {\n  printf \"\\x1B[0m\"\n}\n\nplural() {\n  [ \"$1\" -eq 1 ] || echo \"s\"\n}\n\n_buffer=\"\"\n\nbuffer() {\n  _buffer=\"${_buffer}$(\"$@\")\"\n}\n\nflush() {\n  printf \"%s\" \"$_buffer\"\n  _buffer=\"\"\n}\n\nfinish() {\n  flush\n  printf \"\\n\"\n}\n\ntrap finish EXIT\n\nwhile IFS= read -r line; do\n  case \"$line\" in\n  \"begin \"* )\n    let index+=1\n    name=\"${line#* $index }\"\n    buffer begin\n    flush\n    ;;\n  \"ok \"* )\n    skip_expr=\"ok $index # skip (\\(([^)]*)\\))?\"\n    if [[ \"$line\" =~ $skip_expr ]]; then\n      let skipped+=1\n      buffer skip \"${BASH_REMATCH[2]}\"\n    else\n      buffer pass\n    fi\n    ;;\n  \"not ok \"* )\n    let failures+=1\n    buffer fail\n    ;;\n  \"# \"* )\n    buffer log \"${line:2}\"\n    ;;\n  esac\ndone\n\nbuffer summary\n"
  },
  {
    "path": "test/bats/libexec/bats-preprocess",
    "content": "#!/usr/bin/env bash\nset -e\n\nencode_name() {\n  local name=\"$1\"\n  local result=\"test_\"\n\n  if [[ ! \"$name\" =~ [^[:alnum:]\\ _-] ]]; then\n    name=\"${name//_/-5f}\"\n    name=\"${name//-/-2d}\"\n    name=\"${name// /_}\"\n    result+=\"$name\"\n  else\n    local length=\"${#name}\"\n    local char i\n\n    for ((i=0; i<length; i++)); do\n      char=\"${name:$i:1}\"\n      if [ \"$char\" = \" \" ]; then\n        result+=\"_\"\n      elif [[ \"$char\" =~ [[:alnum:]] ]]; then\n        result+=\"$char\"\n      else\n        result+=\"$(printf -- \"-%02x\" \\'\"$char\")\"\n      fi\n    done\n  fi\n\n  echo \"$result\"\n}\n\ntests=()\nindex=0\npattern='^ *@test  *([^ ].*)  *\\{ *(.*)$'\n\nwhile IFS= read -r line; do\n  let index+=1\n  if [[ \"$line\" =~ $pattern ]]; then\n    quoted_name=\"${BASH_REMATCH[1]}\"\n    body=\"${BASH_REMATCH[2]}\"\n    name=\"$(eval echo \"$quoted_name\")\"\n    encoded_name=\"$(encode_name \"$name\")\"\n    tests[\"${#tests[@]}\"]=\"$encoded_name\"\n    echo \"${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}\"\n  else\n    printf \"%s\\n\" \"$line\"\n  fi\ndone\n\nfor test_name in \"${tests[@]}\"; do\n  echo \"bats_test_function ${test_name}\"\ndone\n"
  },
  {
    "path": "test/commit-msg.bats",
    "content": "#!/usr/bin/env bats\nload test_helper\n\n@test \"Rejects commit messages with prohibited patterns\" {\n  setup_good_repo\n  repo_run git-secrets --install $TEST_REPO\n  run git commit -m '@todo in the message??'\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" == \".git/COMMIT_EDITMSG:1:@todo in the message??\" ]\n}\n\n@test \"Allows commit messages that do not match a prohibited pattern\" {\n  setup_good_repo\n  repo_run git-secrets --install $TEST_REPO\n  cd $TEST_REPO\n  run git commit -m 'This is OK'\n  [ $status -eq 0 ]\n}\n"
  },
  {
    "path": "test/git-secrets.bats",
    "content": "#!/usr/bin/env bats\nload test_helper\n\n@test \"no arguments prints usage instructions\" {\n  repo_run git-secrets\n  [ $status -eq 0 ]\n  [ $(expr \"${lines[0]}\" : \"usage: git secrets\") -ne 0 ]\n}\n\n@test \"-h prints help\" {\n  repo_run git-secrets -h\n  [ $(expr \"${lines[0]}\" : \"usage: git secrets\") -ne 0 ]\n}\n\n@test \"Invalid scan filename fails\" {\n  repo_run git-secrets --scan /path/to/not/there\n  [ $status -eq 2 ]\n  echo \"$output\" | grep \"No such file\"\n}\n\n@test \"Does not require secrets\" {\n  git config --unset-all secrets.patterns || true\n  repo_run git-secrets --scan $BATS_TEST_FILENAME\n  [ $status -eq 0 ]\n}\n\n@test \"No prohibited matches exits 0\" {\n  echo 'it is ok' > \"$BATS_TMPDIR/test.txt\"\n  repo_run git-secrets --scan \"$BATS_TMPDIR/test.txt\"\n  [ $status -eq 0 ]\n}\n\n@test \"Scans all files when no file provided\" {\n  setup_bad_repo\n  repo_run git-secrets --scan\n  [ $status -eq 1 ]\n}\n\n@test \"Scans all files including history\" {\n  setup_bad_repo\n  repo_run git-secrets --scan-history\n  [ $status -eq 1 ]\n}\n\n@test \"Scans all files when no file provided with secret in history\" {\n  setup_bad_repo_history\n  repo_run git-secrets --scan\n  [ $status -eq 0 ]\n}\n\n@test \"Scans all files including history with secret in history\" {\n  setup_bad_repo_history\n  repo_run git-secrets --scan-history\n  [ $status -eq 1 ]\n}\n\n@test \"Scans history with secrets distributed among branches in history\" {\n  cd $TEST_REPO\n  echo '@todo' > $TEST_REPO/history_failure.txt\n  git add -A\n  git commit -m \"Testing history\"\n  echo 'todo' > $TEST_REPO/history_failure.txt\n  git add -A\n  git commit -m \"Testing history\"\n  git checkout -b testbranch\n  echo '@todo' > $TEST_REPO/history_failure.txt\n  git add -A\n  git commit -m \"Testing history\"\n  git checkout master\n  cd -\n  repo_run git-secrets --scan-history\n  [ $status -eq 1 ]\n}\n\n@test \"Scans recursively\" {\n  setup_bad_repo\n  mkdir -p $TEST_REPO/foo/bar/baz\n  echo '@todo more stuff' > $TEST_REPO/foo/bar/baz/data.txt\n  repo_run git-secrets --scan -r $TEST_REPO/foo\n  [ $status -eq 1 ]\n}\n\n@test \"Scans recursively only if -r is given\" {\n  setup_bad_repo\n  mkdir -p $TEST_REPO/foo/bar/baz\n  echo '@todo more stuff' > $TEST_REPO/foo/bar/baz/data.txt\n  repo_run git-secrets --scan $TEST_REPO/foo\n  [ $status -eq 0 ]\n}\n\n@test \"Excludes allowed patterns from failures\" {\n  git config --add secrets.patterns 'foo=\"baz{1,5}\"'\n  git config --add secrets.allowed 'foo=\"bazzz\"'\n  echo 'foo=\"bazzz\" is ok because 3 \"z\"s' > \"$BATS_TMPDIR/test.txt\"\n  repo_run git-secrets --scan \"$BATS_TMPDIR/test.txt\"\n  [ $status -eq 0 ]\n  echo 'This is NOT: ok foo=\"bazzzz\"' > \"$BATS_TMPDIR/test.txt\"\n  repo_run git-secrets --scan \"$BATS_TMPDIR/test.txt\"\n  [ $status -eq 1 ]\n}\n\n@test \"Prohibited matches exits 1\" {\n  file=\"$TEST_REPO/test.txt\"\n  echo '@todo stuff' > $file\n  echo 'this is forbidden right?' >> $file\n  repo_run git-secrets --scan $file\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" == \"$file:1:@todo stuff\" ]\n  [ \"${lines[1]}\" == \"$file:2:this is forbidden right?\" ]\n}\n\n@test \"Only matches on word boundaries\" {\n  file=\"$TEST_REPO/test.txt\"\n  # Note that the following does not match as it is not a word.\n  echo 'mesa Jar Jar Binks' > $file\n  # The following do match because they are in word boundaries.\n  echo 'foo.me' >> $file\n  echo '\"me\"' >> $file\n  repo_run git-secrets --scan $file\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" == \"$file:2:foo.me\" ]\n  [ \"${lines[1]}\" == \"$file:3:\\\"me\\\"\" ]\n}\n\n@test \"Can scan from stdin using -\" {\n  echo \"foo\" | \"${BATS_TEST_DIRNAME}/../git-secrets\" --scan -\n  echo \"me\" | \"${BATS_TEST_DIRNAME}/../git-secrets\" --scan - && exit 1 || true\n}\n\n@test \"installs hooks for repo\" {\n  setup_bad_repo\n  repo_run git-secrets --install $TEST_REPO\n  [ -f $TEST_REPO/.git/hooks/pre-commit ]\n  [ -f $TEST_REPO/.git/hooks/prepare-commit-msg ]\n  [ -f $TEST_REPO/.git/hooks/commit-msg ]\n}\n\n@test \"fails if hook exists and no -f\" {\n  repo_run git-secrets --install $TEST_REPO\n  repo_run git-secrets --install $TEST_REPO\n  [ $status -eq 1 ]\n}\n\n@test \"Overwrites hooks if -f is given\" {\n  repo_run git-secrets --install $TEST_REPO\n  repo_run git-secrets --install -f $TEST_REPO\n  [ $status -eq 0 ]\n}\n\n@test \"installs hooks for repo with Debian style directories\" {\n  setup_bad_repo\n  mkdir $TEST_REPO/.git/hooks/pre-commit.d\n  mkdir $TEST_REPO/.git/hooks/prepare-commit-msg.d\n  mkdir $TEST_REPO/.git/hooks/commit-msg.d\n  run git-secrets --install $TEST_REPO\n  [ -f $TEST_REPO/.git/hooks/pre-commit.d/git-secrets ]\n  [ -f $TEST_REPO/.git/hooks/prepare-commit-msg.d/git-secrets ]\n  [ -f $TEST_REPO/.git/hooks/commit-msg.d/git-secrets ]\n}\n\n@test \"installs hooks to template directory\" {\n  setup_bad_repo\n  run git-secrets --install $TEMPLATE_DIR\n  [ $status -eq 0 ]\n  run git init --template $TEMPLATE_DIR\n  [ $status -eq 0 ]\n  [ -f \"${TEST_REPO}/.git/hooks/pre-commit\" ]\n  [ -f \"${TEST_REPO}/.git/hooks/prepare-commit-msg\" ]\n  [ -f \"${TEST_REPO}/.git/hooks/commit-msg\" ]\n}\n\n@test \"Scans using keys from credentials file\" {\n  echo 'aws_access_key_id = abc123' > $BATS_TMPDIR/test.ini\n  echo 'aws_secret_access_key=foobaz' >> $BATS_TMPDIR/test.ini\n  echo 'aws_access_key_id = \"Bernard\"' >> $BATS_TMPDIR/test.ini\n  echo 'aws_secret_access_key= \"Laverne\"' >> $BATS_TMPDIR/test.ini\n  echo 'aws_access_key_id= Hoagie+man' >> $BATS_TMPDIR/test.ini\n  cd $TEST_REPO\n  run git secrets --aws-provider $BATS_TMPDIR/test.ini\n  [ $status -eq 0 ]\n  echo \"$output\" | grep -F \"foobaz\"\n  echo \"$output\" | grep -F \"abc123\"\n  echo \"$output\" | grep -F \"Bernard\"\n  echo \"$output\" | grep -F \"Laverne\"\n  echo \"$output\" | grep -F 'Hoagie\\+man'\n  run git secrets --add-provider -- git secrets --aws-provider $BATS_TMPDIR/test.ini\n  [ $status -eq 0 ]\n  echo '(foobaz) test' > $TEST_REPO/bad_file\n  echo \"abc123 test\" >> $TEST_REPO/bad_file\n  echo 'Bernard test' >> $TEST_REPO/bad_file\n  echo 'Laverne test' >> $TEST_REPO/bad_file\n  echo 'Hoagie+man test' >> $TEST_REPO/bad_file\n  repo_run git-secrets --scan $TEST_REPO/bad_file\n  [ $status -eq 1 ]\n  echo \"$output\" | grep \"foobaz\"\n  echo \"$output\" | grep \"abc123\"\n  echo \"$output\" | grep \"Bernard\"\n  echo \"$output\" | grep \"Laverne\"\n  echo \"$output\" | grep -F 'Hoagie+man'\n}\n\n@test \"Lists secrets for a repo\" {\n  repo_run git-secrets --list\n  [ $status -eq 0 ]\n  echo \"$output\" | grep -F 'secrets.patterns @todo'\n  echo \"$output\" | grep -F 'secrets.patterns forbidden|me'\n}\n\n@test \"Adds secrets to a repo and de-dedupes\" {\n  repo_run git-secrets --add 'testing+123'\n  [ $status -eq 0 ]\n  repo_run git-secrets --add 'testing+123'\n  [ $status -eq 1 ]\n  repo_run git-secrets --add --literal 'testing+abc'\n  [ $status -eq 0 ]\n  repo_run git-secrets --add -l 'testing+abc'\n  [ $status -eq 1 ]\n  repo_run git-secrets --list\n  echo \"$output\" | grep -F 'secrets.patterns @todo'\n  echo \"$output\" | grep -F 'secrets.patterns forbidden|me'\n  echo \"$output\" | grep -F 'secrets.patterns testing+123'\n  echo \"$output\" | grep -F 'secrets.patterns testing\\+abc'\n}\n\n@test \"Adds allowed patterns to a repo and de-dedupes\" {\n  repo_run git-secrets --add -a 'testing+123'\n  [ $status -eq 0 ]\n  repo_run git-secrets --add --allowed 'testing+123'\n  [ $status -eq 1 ]\n  repo_run git-secrets --add -a -l 'testing+abc'\n  [ $status -eq 0 ]\n  repo_run git-secrets --add -a -l 'testing+abc'\n  [ $status -eq 1 ]\n  repo_run git-secrets --list\n  echo \"$output\" | grep -F 'secrets.patterns @todo'\n  echo \"$output\" | grep -F 'secrets.patterns forbidden|me'\n  echo \"$output\" | grep -F 'secrets.allowed testing+123'\n  echo \"$output\" | grep -F 'secrets.allowed testing\\+abc'\n}\n\n@test \"Empty lines must be ignored in .gitallowed files\" {\n  setup_bad_repo\n  echo '' >> $TEST_REPO/.gitallowed\n  repo_run git-secrets --scan\n  [ $status -eq 1 ]\n}\n\n@test \"Comment lines must be ignored in .gitallowed files\" {\n  setup_bad_repo_with_hash\n  repo_run git-secrets --scan\n  [ $status -eq 1 ]\n  echo '#hash' > $TEST_REPO/.gitallowed\n  repo_run git-secrets --scan\n  [ $status -eq 1 ]\n  echo 'hash' > $TEST_REPO/.gitallowed\n  repo_run git-secrets --scan\n  [ $status -eq 0 ]\n}\n\n@test \"Scans all files and allowing none of the bad patterns in .gitallowed\" {\n  setup_bad_repo\n  echo 'hello' > $TEST_REPO/.gitallowed\n  repo_run git-secrets --scan\n  [ $status -eq 1 ]\n}\n\n@test \"Scans all files and allowing all bad patterns in .gitallowed\" {\n  setup_bad_repo\n  echo '@todo' > $TEST_REPO/.gitallowed\n  echo 'forbidden' >> $TEST_REPO/.gitallowed\n  echo 'me' >> $TEST_REPO/.gitallowed\n  repo_run git-secrets --scan\n  [ $status -eq 0 ]\n}\n\n@test \"Adds common AWS patterns\" {\n  repo_run git config --unset-all secrets\n  repo_run git-secrets --register-aws\n  git config --local --get secrets.providers\n  repo_run git-secrets --list\n  echo \"$output\" | grep -F '(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'\n  echo \"$output\" | grep \"AKIAIOSFODNN7EXAMPLE\"\n  echo \"$output\" | grep \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\n  echo \"$output\" | grep -F 'ABSK[A-Za-z0-9+/]{109,}=*'\n  echo \"$output\" | grep -F 'bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t'\n}\n\n@test \"Adds providers\" {\n  repo_run git-secrets --add-provider -- echo foo baz bar\n  [ $status -eq 0 ]\n  repo_run git-secrets --add-provider -- echo bam\n  [ $status -eq 0 ]\n  repo_run git-secrets --list\n  echo \"$output\" | grep -F 'echo foo baz bar'\n  echo \"$output\" | grep -F 'echo bam'\n  echo 'foo baz bar' > $TEST_REPO/bad_file\n  echo 'bam' >> $TEST_REPO/bad_file\n  repo_run git-secrets --scan $TEST_REPO/bad_file\n  [ $status -eq 1 ]\n  echo \"$output\" | grep -F 'foo baz bar'\n  echo \"$output\" | grep -F 'bam'\n}\n\n@test \"Strips providers that return nothing\" {\n  repo_run git-secrets --add-provider -- 'echo'\n  [ $status -eq 0 ]\n  repo_run git-secrets --add-provider -- 'echo 123'\n  [ $status -eq 0 ]\n  repo_run git-secrets --list\n  echo \"$output\" | grep -F 'echo 123'\n  echo 'foo' > $TEST_REPO/bad_file\n  repo_run git-secrets --scan $TEST_REPO/bad_file\n  [ $status -eq 0 ]\n}\n\n@test \"--recursive cannot be used with SCAN_*\" {\n  repo_run git-secrets --scan -r --cached\n  [ $status -eq 1 ]\n  repo_run git-secrets --scan -r --no-index\n  [ $status -eq 1 ]\n  repo_run git-secrets --scan -r --untracked\n  [ $status -eq 1 ]\n}\n\n@test \"--recursive can be used with --scan\" {\n  repo_run git-secrets --scan -r\n  [ $status -eq 0 ]\n}\n\n@test \"--recursive can't be used with --list\" {\n  repo_run git-secrets --list -r\n  [ $status -eq 1 ]\n}\n\n@test \"-f can only be used with --install\" {\n  repo_run git-secrets --scan -f\n  [ $status -eq 1 ]\n}\n\n@test \"-a can only be used with --add\" {\n  repo_run git-secrets --scan -a\n  [ $status -eq 1 ]\n}\n\n@test \"-l can only be used with --add\" {\n  repo_run git-secrets --scan -l\n  [ $status -eq 1 ]\n}\n\n@test \"--cached can only be used with --scan\" {\n  repo_run git-secrets --list --cached\n  [ $status -eq 1 ]\n}\n\n@test \"--no-index can only be used with --scan\" {\n  repo_run git-secrets --list --no-index\n  [ $status -eq 1 ]\n}\n\n@test \"--untracked can only be used with --scan\" {\n  repo_run git-secrets --list --untracked\n  [ $status -eq 1 ]\n}\n"
  },
  {
    "path": "test/pre-commit.bats",
    "content": "#!/usr/bin/env bats\nload test_helper\n\n@test \"Rejects commits with prohibited patterns in changeset\" {\n  setup_bad_repo\n  repo_run git-secrets --install $TEST_REPO\n  cd $TEST_REPO\n  run git commit -m 'Contents are bad not the message'\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" == \"data.txt:1:@todo more stuff\" ]\n  [ \"${lines[1]}\" == \"failure1.txt:1:another line... forbidden\" ]\n  [ \"${lines[2]}\" == \"failure2.txt:1:me\" ]\n}\n\n@test \"Rejects commits with prohibited patterns in changeset with filename that contain spaces\" {\n  setup_bad_repo_with_spaces\n  repo_run git-secrets --install $TEST_REPO\n  cd $TEST_REPO\n  run git commit -m 'Contents are bad not the message'\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" == \"da ta.txt:1:@todo more stuff\" ]\n}\n\n@test \"Scans staged files\" {\n  cd $TEST_REPO\n  repo_run git-secrets --install $TEST_REPO\n  echo '@todo more stuff' > $TEST_REPO/data.txt\n  echo 'hi there' > $TEST_REPO/ok.txt\n  git add -A\n  echo 'fixed the working directory, but not staged' > $TEST_REPO/data.txt\n  run git commit -m 'Contents are bad not the message'\n  [ $status -eq 1 ]\n  [ \"${lines[0]}\" == \"data.txt:1:@todo more stuff\" ]\n}\n\n@test \"Allows commits that do not match prohibited patterns\" {\n  setup_good_repo\n  repo_run git-secrets --install $TEST_REPO\n  cd $TEST_REPO\n  run git commit -m 'This is fine'\n  [ $status -eq 0 ]\n  # Ensure deleted files are filtered out of the grep\n  rm $TEST_REPO/data.txt\n  echo 'aaa' > $TEST_REPO/data_2.txt\n  run git add -A\n  run git commit -m 'This is also fine'\n  [ $status -eq 0 ]\n}\n\n@test \"Rejects commits with prohibited patterns in changeset when AWS provider is enabled\" {\n  setup_bad_repo\n  repo_run git-secrets --install $TEST_REPO\n  repo_run git-secrets --register-aws $TEST_REPO\n  cd $TEST_REPO\n  run git commit -m 'Contents are bad not the message'\n  [ $status -eq 1 ]\n  echo \"${lines}\" | grep -vq 'git secrets --aws-provider: command not found'\n\n  [ \"${lines[0]}\" == \"data.txt:1:@todo more stuff\" ]\n  [ \"${lines[1]}\" == \"failure1.txt:1:another line... forbidden\" ]\n  [ \"${lines[2]}\" == \"failure2.txt:1:me\" ]\n}\n"
  },
  {
    "path": "test/prepare-commit-msg.bats",
    "content": "#!/usr/bin/env bats\nload test_helper\n\n@test \"Rejects merges with prohibited patterns in history\" {\n  setup_good_repo\n  repo_run git-secrets --install $TEST_REPO\n  cd $TEST_REPO\n  git commit -m 'OK'\n  git checkout -b feature\n  echo '@todo' > data.txt\n  git add -A\n  git commit -m 'Bad commit' --no-verify\n  echo 'Fixing!' > data.txt\n  git add -A\n  git commit -m 'Fixing commit'\n  git checkout master\n  run git merge --no-ff feature\n  [ $status -eq 1 ]\n}\n\n@test \"Allows merges that do not match prohibited patterns\" {\n  setup_good_repo\n  cd $TEST_REPO\n  repo_run git-secrets --install\n  git commit -m 'OK'\n  git checkout -b feature\n  echo 'Not bad' > data.txt\n  git add -A\n  git commit -m 'Good commit'\n  git checkout master\n  run git merge --no-ff feature\n  [ $status -eq 0 ]\n}\n"
  },
  {
    "path": "test/test_helper.bash",
    "content": "#!/bin/bash\nexport TEST_REPO=\"$BATS_TMPDIR/test-repo\"\nexport TEMP_HOME=\"$BATS_TMPDIR/home\"\nexport TEMPLATE_DIR=\"${BATS_TMPDIR}/template\"\nINITIAL_PATH=\"${PATH}\"\nINITIAL_HOME=${HOME}\n\nsetup() {\n  setup_repo\n  [ -d \"${TEMPLATE_DIR}\" ] && rm -rf \"${TEMPLATE_DIR}\"\n  [ -d \"${TEMP_HOME}\" ] && rm -rf \"${TEMP_HOME}\"\n  mkdir -p $TEMP_HOME\n  export HOME=$TEMP_HOME\n  export PATH=\"${BATS_TEST_DIRNAME}/..:${INITIAL_PATH}\"\n  cd $TEST_REPO\n}\n\nteardown() {\n  delete_repo\n  export PATH=\"${INITIAL_PATH}\"\n  export HOME=\"${INITIAL_HOME}\"\n  [ -d \"${TEMP_HOME}\" ] && rm -rf \"${TEMP_HOME}\"\n}\n\ndelete_repo() {\n  [ -d $TEST_REPO ] && rm -rf $TEST_REPO || true\n}\n\nsetup_repo() {\n  delete_repo\n  mkdir -p $TEST_REPO\n  cd $TEST_REPO\n  git init --initial-branch=master\n  git config --local --add secrets.patterns '@todo'\n  git config --local --add secrets.patterns 'forbidden|me'\n  git config --local --add secrets.patterns '#hash'\n  git config --local user.email \"you@example.com\"\n  git config --local user.name \"Your Name\"\n  cd -\n}\n\nrepo_run() {\n  cmd=\"$1\"\n  shift\n  cd \"${TEST_REPO}\"\n  run \"${BATS_TEST_DIRNAME}/../${cmd}\" $@\n  cd -\n}\n\n# Creates a repo that should fail\nsetup_bad_repo() {\n  cd $TEST_REPO\n  echo '@todo more stuff' > $TEST_REPO/data.txt\n  echo 'hi there' > $TEST_REPO/ok.txt\n  echo 'another line... forbidden' > $TEST_REPO/failure1.txt\n  echo 'me' > $TEST_REPO/failure2.txt\n  git add -A\n  cd -\n}\n\n# Creates a repo that should fail\nsetup_bad_repo_with_spaces() {\n  cd $TEST_REPO\n  echo '@todo more stuff' > \"$TEST_REPO/da ta.txt\"\n  git add -A\n  cd -\n}\n\n# Creates a repo that should fail\nsetup_bad_repo_with_hash() {\n  cd $TEST_REPO\n  echo '#hash' > \"$TEST_REPO/data.txt\"\n  git add -A\n  cd -\n}\n\n# Creates a repo that should fail\nsetup_bad_repo_history() {\n  cd $TEST_REPO\n  echo '@todo' > $TEST_REPO/history_failure.txt\n  git add -A\n  git commit -m \"Testing history\"\n  echo 'todo' > $TEST_REPO/history_failure.txt\n  git add -A\n  cd -\n}\n\n# Creates a repo that does not fail\nsetup_good_repo() {\n  cd $TEST_REPO\n  echo 'hello!' > $TEST_REPO/data.txt\n  git add -A\n  cd -\n}\n"
  }
]