Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
fix: use multiline for regex
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p committed Apr 24, 2021
1 parent 3fabfba commit 3d4a22f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- id: forbid-secrets
name: Check for unencrypted Kubernetes secrets in manifest files
name: Check for unencrypted Kubernetes secrets in manifests
description: "Forbid files containing unencrypted Kubernetes secrets to be commited"
entry: forbid_secrets
language: python
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ Add the following to your `.pre-commit-config.yaml`

```yaml
- repo: https://github.com/k8s-at-home/sops-pre-commit
rev: v2.0.2
rev: v2.0.3
hooks:
- id: forbid-secrets
```
## License
This software is licensed under the MIT license (see the LICENSE file).
## Credits
[angelnu](https://github.com/angelnu/k8s-gitops/)
4 changes: 2 additions & 2 deletions hooks/forbid_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
def contains_secret(filename):
with open(filename, mode="r") as file_checked:
lines = file_checked.read()
kubernetes_secret = re.findall(SECRET_REGEX, lines, re.IGNORECASE)
kubernetes_secret = re.findall(SECRET_REGEX, lines, flags=re.IGNORECASE | re.MULTILINE)
if kubernetes_secret:
sops_secret = re.findall(SOPS_REGEX, lines, re.IGNORECASE)
sops_secret = re.findall(SOPS_REGEX, lines, flags=re.IGNORECASE | re.MULTILINE)
if not sops_secret:
return True
return False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name='sops-pre-commit',
description='Check for unencrypted Kubernetes secrets in manifest files',
url='https://github.com/k8s-at-home/sops-pre-commit',
version='2.0.1',
version='2.0.3',

author='Devin Buhl',
author_email='devin.kray@gmail.com',
Expand Down

0 comments on commit 3d4a22f

Please sign in to comment.