Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit ec995bd

Browse files
Added detect-secret pre-commit hook
1 parent b1c2a2f commit ec995bd

File tree

4 files changed

+134
-3
lines changed

4 files changed

+134
-3
lines changed

.github/workflows/validate_terraform.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
-
2626
name: Install pre-commit
2727
run: pip install pre-commit
28+
-
29+
name: Upgrade hooks
30+
run: pre-commit autoupdate
2831
-
2932
name: Run pre-commit command
3033
run: pre-commit run -a

.pre-commit-config.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,26 @@ default_stages: [commit]
66
# Terraform Validate : Validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc
77
repos:
88
- repo: git://github.com/antonbabenko/pre-commit-terraform
9-
rev: v1.45.0
9+
rev: v1.52.0
1010
hooks:
1111
- id: terraform_fmt
1212
- repo: git://github.com/pre-commit/pre-commit-hooks
13-
rev: v3.4.0
13+
rev: v4.0.1
1414
hooks:
1515
- id: check-merge-conflict
1616
- id: trailing-whitespace
1717
- id: detect-private-key
18+
- repo: https://github.com/ibm/detect-secrets
19+
# If you desire to use a specific version of detect-secrets, you can replace `master` with other git revisions such as branch, tag or commit sha.
20+
# You are encouraged to use static refs such as tags, instead of branch name
21+
#
22+
# Running "pre-commit autoupdate" would automatically updates rev to latest tag
23+
rev: 0.13.1+ibm.46.dss
24+
hooks:
25+
- id: detect-secrets # pragma: whitelist secret
26+
# Add options for detect-secrets-hook binary. You can run `detect-secrets-hook --help` to list out all possible options.
27+
# You may also run `pre-commit run detect-secrets` to preview the scan result.
28+
# when "--baseline" without "--use-all-plugins", pre-commit scan with just plugins in baseline file
29+
# when "--baseline" with "--use-all-plugins", pre-commit scan with all available plugins
30+
# add "--fail-on-non-audited" to fail pre-commit for unaudited potential secrets
31+
args: [--baseline, .secrets.baseline, --use-all-plugins ]

.secrets.baseline

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"exclude": {
3+
"files": "^.secrets.baseline$",
4+
"lines": null
5+
},
6+
"generated_at": "2021-10-12T12:36:29Z",
7+
"plugins_used": [
8+
{
9+
"name": "AWSKeyDetector"
10+
},
11+
{
12+
"name": "ArtifactoryDetector"
13+
},
14+
{
15+
"name": "AzureStorageKeyDetector"
16+
},
17+
{
18+
"base64_limit": 4.5,
19+
"name": "Base64HighEntropyString"
20+
},
21+
{
22+
"name": "BasicAuthDetector"
23+
},
24+
{
25+
"name": "BoxDetector"
26+
},
27+
{
28+
"name": "CloudantDetector"
29+
},
30+
{
31+
"ghe_instance": "github.ibm.com",
32+
"name": "GheDetector"
33+
},
34+
{
35+
"name": "GitHubTokenDetector"
36+
},
37+
{
38+
"hex_limit": 3,
39+
"name": "HexHighEntropyString"
40+
},
41+
{
42+
"name": "IbmCloudIamDetector"
43+
},
44+
{
45+
"name": "IbmCosHmacDetector"
46+
},
47+
{
48+
"name": "JwtTokenDetector"
49+
},
50+
{
51+
"keyword_exclude": null,
52+
"name": "KeywordDetector"
53+
},
54+
{
55+
"name": "MailchimpDetector"
56+
},
57+
{
58+
"name": "NpmDetector"
59+
},
60+
{
61+
"name": "PrivateKeyDetector"
62+
},
63+
{
64+
"name": "SlackDetector"
65+
},
66+
{
67+
"name": "SoftlayerDetector"
68+
},
69+
{
70+
"name": "SquareOAuthDetector"
71+
},
72+
{
73+
"name": "StripeDetector"
74+
},
75+
{
76+
"name": "TwilioKeyDetector"
77+
}
78+
],
79+
"results": {},
80+
"version": "0.13.1+ibm.46.dss",
81+
"word_list": {
82+
"file": null,
83+
"hash": null
84+
}
85+
}

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,45 @@ Be sure you have the compiled plugins on $HOME/.terraform.d/plugins/
119119
### Pre-commit Hooks
120120

121121
Run the following command to execute the pre-commit hooks defined in .pre-commit-config.yaml file
122-
122+
```
123123
pre-commit run -a
124+
```
124125

125126
We can install pre-coomit tool using
126127

128+
```
127129
pip install pre-commit
128130
129131
or
130132
131133
pip3 install pre-commit
134+
```
135+
136+
### Detect Secret Hook
137+
138+
Used to detect secrets within a code base.
139+
140+
To create a secret baseline file run following command
141+
142+
```
143+
detect-secrets scan --update .secrets.baseline
144+
```
145+
146+
While running the pre-commit hook, if you encounter an error like
147+
148+
```
149+
WARNING: You are running an outdated version of detect-secrets.
150+
Your version: 0.13.1+ibm.27.dss
151+
Latest version: 0.13.1+ibm.46.dss
152+
See upgrade guide at https://ibm.biz/detect-secrets-how-to-upgrade
153+
```
154+
155+
run below command
156+
157+
```
158+
pre-commit autoupdate
159+
```
160+
which upgrades all the pre-commit hooks present in .pre-commit.yaml file.
132161

133162
## How to input varaible values through a file
134163

0 commit comments

Comments
 (0)