Skip to content

Commit d17d653

Browse files
committed
added gitleaks security scan
1 parent 00d079e commit d17d653

File tree

8 files changed

+80
-14
lines changed

8 files changed

+80
-14
lines changed

.github/actions/install-aptos-cli/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
version:
66
description: "Aptos CLI version to install"
77
required: true
8-
default: "7.2.0"
8+
default: "7.7.0"
99

1010
runs:
1111
using: "composite"

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install Aptos CLI
3939
uses: ./.github/actions/install-aptos-cli
4040
with:
41-
version: "6.2.0"
41+
version: "7.7.0"
4242
- name: Run Aptos Create Local Testnet
4343
run: |
4444
make local-testnet &

.github/workflows/lint.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ jobs:
3939
sudo apt-get update -y
4040
4141
- name: Install Aptos CLI
42-
run: |
43-
curl -fsSL "https://aptos.dev/scripts/install_cli.py" | python3
44-
aptos --version
45-
aptos update movefmt
46-
echo 'Adding movefmt to PATH'
47-
echo "$HOME/.aptos/bin" >> $GITHUB_PATH
42+
uses: ./.github/actions/install-aptos-cli
43+
with:
44+
version: "7.7.0"
4845

4946
- name: Install Node.js
5047
uses: actions/setup-node@v4
@@ -65,6 +62,8 @@ jobs:
6562

6663
- name: Run Pre Commit
6764
uses: pre-commit/[email protected]
65+
env:
66+
SKIP: detect-secrets # skip only this hook in CI; still runs locally
6867

6968
fmt:
7069
name: fmt

.github/workflows/security-scan.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
security-scan:
1111
runs-on: ubuntu-latest
1212
name: Security Scanning
13+
env:
14+
GITLEAKS_VERSION: "8.28.0" # pin gitleaks version
15+
GITLEAKS_CONFIG: ".gitleaks.toml" # config picked up automatically by gitleaks
1316

1417
steps:
1518
- name: Checkout code
@@ -20,9 +23,9 @@ jobs:
2023
- name: TruffleHog OSS Secret Scanning
2124
uses: trufflesecurity/trufflehog@main
2225
with:
23-
# Scan the entire repository
26+
# Scan the entire repository
2427
path: ./
25-
# Only show verified secrets and unknown (high confidence)
28+
# Only show verified secrets and unknown (high confidence)
2629
extra_args: --results=verified,unknown
2730

2831
- name: Setup Python for detect-secrets
@@ -79,6 +82,50 @@ jobs:
7982
8083
echo "✅ Custom secret checks passed!"
8184
85+
# ---- Gitleaks CLI pinned to 8.28.0 (no SARIF) ----
86+
- name: Download Gitleaks v8.28.0 (linux_x64) + verify checksum
87+
run: |
88+
set -euo pipefail
89+
TAR="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
90+
BASE="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}"
91+
92+
echo "Downloading $TAR..."
93+
curl -sSL "${BASE}/${TAR}" -o gitleaks.tar.gz
94+
curl -sSL "${BASE}/gitleaks_${GITLEAKS_VERSION}_checksums.txt" -o checksums.txt
95+
96+
EXPECTED=$(grep "$TAR" checksums.txt | awk '{print $1}')
97+
ACTUAL=$(sha256sum gitleaks.tar.gz | awk '{print $1}')
98+
[ "$EXPECTED" = "$ACTUAL" ] || { echo "Checksum mismatch!"; exit 1; }
99+
100+
tar -xzf gitleaks.tar.gz gitleaks
101+
chmod +x gitleaks
102+
./gitleaks version
103+
104+
# PRs: stage only changed files and scan staged diff (blocks on new leaks)
105+
- name: Run Gitleaks on staged PR changes (blocking)
106+
if: ${{ github.event_name == 'pull_request' }}
107+
run: |
108+
set -euo pipefail
109+
# Ensure base is present and compute changed files
110+
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
111+
git diff --name-only origin/${{ github.base_ref }}..HEAD > /tmp/changed_files.txt
112+
if [ -s /tmp/changed_files.txt ]; then
113+
xargs -a /tmp/changed_files.txt git add
114+
./gitleaks protect --staged --no-banner --redact
115+
xargs -a /tmp/changed_files.txt git reset
116+
else
117+
echo "No changed files; skipping."
118+
fi
119+
120+
# Non-PR runs (e.g., merge_group/push): full scan, do not fail the job
121+
- name: Run Gitleaks full scan (non-blocking)
122+
if: ${{ github.event_name != 'pull_request' }}
123+
run: |
124+
./gitleaks detect \
125+
--source . \
126+
--no-banner \
127+
--redact || true
128+
82129
# Optional: Add Semgrep for additional security analysis
83130
semgrep:
84131
runs-on: ubuntu-latest
@@ -92,7 +139,7 @@ jobs:
92139
- name: Run Semgrep
93140
uses: returntocorp/semgrep-action@v1
94141
with:
95-
# Run security-focused rules
142+
# Run security-focused rules
96143
config: >-
97144
p/security-audit
98145
p/secrets

.github/workflows/testnet-deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Install Aptos CLI
6767
uses: ./.github/actions/install-aptos-cli
6868
with:
69-
version: "6.2.0"
69+
version: "7.7.0"
7070

7171
- name: Set Aptos Workspace Config
7272
run: make set-workspace-config

.github/workflows/typescript-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Install Aptos CLI
5555
uses: ./.github/actions/install-aptos-cli
5656
with:
57-
version: "6.2.0"
57+
version: "7.7.0"
5858

5959
- name: Install Node.js
6060
uses: actions/setup-node@v4

.github/workflows/unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Install Aptos CLI
4242
uses: ./.github/actions/install-aptos-cli
4343
with:
44-
version: "6.2.0"
44+
version: "7.7.0"
4545

4646
- name: Run Aptos Create Local Testnet
4747
run: |

.gitleaks.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
title = "Gitleaks Config (lean)"
2+
3+
[allowlist]
4+
description = "Common non-secret noise"
5+
paths = [
6+
'''(^|/)tests?(/|$)''',
7+
'''(^|/)fixtures?(/|$)''',
8+
'''(^|/)examples?(/|$)''',
9+
'''(^|/)docs?(/|$)''',
10+
'''(^|/)migrations?(/|$)''',
11+
'''\.md$''',
12+
'''package-lock\.json$''',
13+
'''yarn\.lock$''',
14+
'''pnpm-lock\.yaml$''',
15+
'''\.png$''',
16+
'''\.jpg$''',
17+
'''\.jpeg$''',
18+
'''\.gif$''',
19+
'''\.svg$''',
20+
]

0 commit comments

Comments
 (0)