Skip to content

Commit 042d738

Browse files
authored
CM-41798 - Update README about pre-commit hook (#260)
1 parent 5906425 commit 042d738

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

.pre-commit-hooks.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
- id: cycode
2-
name: Cycode pre commit defender
2+
name: Cycode Secrets pre-commit defender
33
language: python
44
language_version: python3
55
entry: cycode
6-
args: [ '--no-progress-meter', 'scan', 'pre_commit' ]
6+
args: [ '--no-progress-meter', 'scan', '--scan-type', 'secret', 'pre_commit' ]
77
- id: cycode-sca
8-
name: Cycode SCA pre commit defender
8+
name: Cycode SCA pre-commit defender
99
language: python
1010
language_version: python3
1111
entry: cycode

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,33 +199,59 @@ export CYCODE_CLIENT_SECRET={your Cycode Secret Key}
199199

200200
Cycode’s pre-commit hook can be set up within your local repository so that the Cycode CLI application will identify any issues with your code automatically before you commit it to your codebase.
201201

202+
> [!NOTE]
203+
> pre-commit hook is only available to Secrets and SCA scans.
204+
202205
Perform the following steps to install the pre-commit hook:
203206

204-
1. Install the pre-commit framework:
207+
1. Install the pre-commit framework (Python 3.8 or higher must be installed):
205208

206209
`pip3 install pre-commit`
207210

208-
2. Navigate to the top directory of the local repository you wish to scan.
211+
2. Navigate to the top directory of the local Git repository you wish to configure.
209212

210213
3. Create a new YAML file named `.pre-commit-config.yaml` (include the beginning `.`) in the repository’s top directory that contains the following:
211214

212215
```yaml
213216
repos:
214217
- repo: https://github.com/cycodehq/cycode-cli
215-
rev: v1.4.0
218+
rev: v1.11.0
219+
hooks:
220+
- id: cycode
221+
stages:
222+
- commit
223+
```
224+
225+
4. Modify the created file for your specific needs. Use hook ID `cycode` to enable scan for Secrets. Use hook ID `cycode-sca` to enable SCA scan. If you want to enable both, use this configuration:
226+
227+
```yaml
228+
repos:
229+
- repo: https://github.com/cycodehq/cycode-cli
230+
rev: v1.11.0
216231
hooks:
217232
- id: cycode
218233
stages:
219234
- commit
235+
- id: cycode-sca
236+
stages:
237+
- commit
220238
```
221239

222-
4. Install Cycode’s hook:
240+
5. Install Cycode’s hook:
223241

224242
`pre-commit install`
225243

244+
A successful hook installation will result in the message: `Pre-commit installed at .git/hooks/pre-commit`.
245+
246+
6. Keep the pre-commit hook up to date:
247+
248+
`pre-commit autoupdate`
249+
250+
It will automatically bump "rev" in ".pre-commit-config.yaml" to the latest available version of Cycode CLI.
251+
226252
> [!NOTE]
227-
> A successful hook installation will result in the message:<br/>
228-
`Pre-commit installed at .git/hooks/pre-commit`
253+
> Trigger happens on `git commit` command.
254+
> Hook triggers only on the files that are staged for commit.
229255

230256
# Cycode CLI Commands
231257

0 commit comments

Comments
 (0)