You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
201
201
202
+
> [!NOTE]
203
+
> pre-commit hook is only available to Secrets and SCA scans.
204
+
202
205
Perform the following steps to install the pre-commit hook:
203
206
204
-
1. Install the pre-commit framework:
207
+
1. Install the pre-commit framework (Python 3.8 or higher must be installed):
205
208
206
209
`pip3 install pre-commit`
207
210
208
-
2. Navigate to the top directory of the local repository you wish to scan.
211
+
2. Navigate to the top directory of the localGit repository you wish to configure.
209
212
210
213
3. Create a new YAML file named `.pre-commit-config.yaml` (include the beginning `.`) in the repository’s top directory that contains the following:
211
214
212
215
```yaml
213
216
repos:
214
217
- 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
216
231
hooks:
217
232
- id: cycode
218
233
stages:
219
234
- commit
235
+
- id: cycode-sca
236
+
stages:
237
+
- commit
220
238
```
221
239
222
-
4. Install Cycode’s hook:
240
+
5. Install Cycode’s hook:
223
241
224
242
`pre-commit install`
225
243
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
+
226
252
> [!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 forcommit.
0 commit comments