Skip to content

Commit

Permalink
Merge pull request #47 from bloXroute-Labs/TCS-4727
Browse files Browse the repository at this point in the history
Add gitleaks
  • Loading branch information
jessenia authored Nov 4, 2024
2 parents 177e556 + e40c1e5 commit b83da46
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: gitleaks
on:
pull_request:
push:
branches:
- develop
workflow_dispatch:
schedule:
- cron: "0 4 * * *"
jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
environment: develop
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: "${{ secrets.GITLEAKS_LICENSE }}"
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.1
hooks:
- id: gitleaks
name: Detect hardcoded secrets
args: ["detect", "--source=."]
42 changes: 42 additions & 0 deletions PRECOMMIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Pre-commit Setup Guide

## Overview

This guide will help you set up `pre-commit` hooks for your project. Pre-commit hooks are useful for automatically running checks before committing code to ensure code quality, security, and consistency.
TechOps has enabled general golang linters and gitleaks which should be enabled on each commit.

## Prerequisites

- Python 3.6 or higher
- `pip` (Python package installer)
- `git` installed and configured

## Installation

To install `pre-commit`, follow these steps:

1. **Install pre-commit**
You can install `pre-commit` using `pip`:

```
pip install pre-commit
```

## Sample Usage
This is a sample run on a basic commit:
```
$ git commit -m "add precommit"
Check Yaml...........................................(no files to check)Skipped
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Check for added large files..............................................Passed
go fmt...............................................(no files to check)Skipped
go imports...........................................(no files to check)Skipped
golangci-lint........................................(no files to check)Skipped
Detect hardcoded secrets.................................................Passed
```

You can also run `pre-commit` test on all files:
```
pre-commit run --all-files
```

0 comments on commit b83da46

Please sign in to comment.