git-cli-scanner 1.5.0 โ 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +10 -10
- package/package.json +1 -1
- package/readme.md +80 -45
package/dist/cli.js
CHANGED
|
@@ -233,7 +233,7 @@ var init_cloudProviders = __esm({
|
|
|
233
233
|
{
|
|
234
234
|
id: "firebase-secret",
|
|
235
235
|
description: "Firebase API Key or Secret",
|
|
236
|
-
pattern: /firebase[_-]?(?:api[_-]?key|secret)[\s:=]+["'][a-zA-Z0-9\-_]{30,}["']
|
|
236
|
+
pattern: /firebase[_-]?(?:api[_-]?key|secret)[\s:=]+["']?[a-zA-Z0-9\-_]{30,}["']?/i,
|
|
237
237
|
risk: "Attackers can bypass security rules, read/write to your Firebase database, or exhaust quotas.",
|
|
238
238
|
solution: "Revoke the key in the Firebase console and restrict new keys to specific domains or IP addresses."
|
|
239
239
|
},
|
|
@@ -476,14 +476,14 @@ var init_infrastructure = __esm({
|
|
|
476
476
|
{
|
|
477
477
|
id: "smtp-credentials",
|
|
478
478
|
description: "SMTP Email Credentials",
|
|
479
|
-
pattern: /(?:smtp|mail|sendgrid|mailgun)[\w\-]*(?:password|secret|key)[\s:=]+["'][^"'\s]+["']
|
|
479
|
+
pattern: /(?:smtp|mail|sendgrid|mailgun)[\w\-]*(?:password|secret|key)[\s:=]+["']?[^"'\s]+["']?/i,
|
|
480
480
|
risk: "Attackers can use your SMTP server to send spam or phishing emails, ruining your domain reputation and incurring massive costs.",
|
|
481
481
|
solution: "Change the SMTP password via your email provider and inject it securely using a secrets manager."
|
|
482
482
|
},
|
|
483
483
|
{
|
|
484
484
|
id: "terraform-helm-secret",
|
|
485
485
|
description: "Terraform / Helm Variable Secret",
|
|
486
|
-
pattern: /(?:tf_var|helm_var)_[a-zA-Z0-9_]+[\s:=]+["'][^"'\s]+["']
|
|
486
|
+
pattern: /(?:tf_var|helm_var)_[a-zA-Z0-9_]+[\s:=]+["']?[^"'\s]+["']?/i,
|
|
487
487
|
risk: "Hardcoded infrastructure secrets can grant access to the underlying platform resources and services.",
|
|
488
488
|
solution: "Use a proper secrets management backend for Terraform (e.g. Vault) or pass secrets via CI/CD runners."
|
|
489
489
|
}
|
|
@@ -528,21 +528,21 @@ var init_authentication = __esm({
|
|
|
528
528
|
{
|
|
529
529
|
id: "jwt-secret",
|
|
530
530
|
description: "JWT Secret Key",
|
|
531
|
-
pattern: /(?:jwt[_-]?(?:secret|key)|secret[_-]?key)[\s:=]+[
|
|
531
|
+
pattern: /(?:jwt[_-]?(?:secret|key)|secret[_-]?key)[\s:=]+["']?[a-zA-Z0-9\-_!@#$%^&*()=+]{16,}["']?/i,
|
|
532
532
|
risk: "An attacker can forge JWT tokens to impersonate any user, including admins, bypassing all authentication.",
|
|
533
533
|
solution: "Rotate the secret, ensure all existing JWT sessions are invalidated, and inject it via environment variables."
|
|
534
534
|
},
|
|
535
535
|
{
|
|
536
536
|
id: "oauth-client-secret",
|
|
537
537
|
description: "OAuth Client Secret",
|
|
538
|
-
pattern: /(?:oauth|client)[_-]?(?:secret|key)[\s:=]+[
|
|
538
|
+
pattern: /(?:oauth|client)[_-]?(?:secret|key)[\s:=]+["']?[a-zA-Z0-9\-_]{16,}["']?/i,
|
|
539
539
|
risk: "Attackers can hijack the OAuth flow, authenticate on behalf of your users, or exhaust API quotas.",
|
|
540
540
|
solution: "Revoke the OAuth client secret in the identity provider console and generate a new one."
|
|
541
541
|
},
|
|
542
542
|
{
|
|
543
543
|
id: "session-secret",
|
|
544
544
|
description: "Session Cookie Secret",
|
|
545
|
-
pattern: /(?:session)[_-]?(?:secret|key)[\s:=]+[
|
|
545
|
+
pattern: /(?:session)[_-]?(?:secret|key)[\s:=]+["']?[a-zA-Z0-9\-_!@#$%^&*()=+]{16,}["']?/i,
|
|
546
546
|
risk: "Attackers can forge signed session cookies, allowing them to hijack active user sessions.",
|
|
547
547
|
solution: "Change the session secret to immediately invalidate all current user sessions."
|
|
548
548
|
}
|
|
@@ -587,7 +587,7 @@ var init_packageRegistries = __esm({
|
|
|
587
587
|
{
|
|
588
588
|
id: "npm-token",
|
|
589
589
|
description: "NPM Access Token",
|
|
590
|
-
pattern: /(?:npm|NPM)[_-]?(?:token|TOKEN)[\s:=]+["'](?:npm_[a-zA-Z0-9]{36})["']
|
|
590
|
+
pattern: /(?:npm|NPM)[_-]?(?:token|TOKEN)[\s:=]+["']?(?:npm_[a-zA-Z0-9]{36})["']?/i,
|
|
591
591
|
risk: "Attackers can publish malicious versions of your packages (Supply Chain Attack) to compromise all users downloading your code.",
|
|
592
592
|
solution: "Revoke the token immediately on npmjs.com and check your package versions for unauthorized releases."
|
|
593
593
|
},
|
|
@@ -601,7 +601,7 @@ var init_packageRegistries = __esm({
|
|
|
601
601
|
{
|
|
602
602
|
id: "maven-gradle-password",
|
|
603
603
|
description: "Maven/Gradle Repository Password",
|
|
604
|
-
pattern: /(?:maven|gradle|nexus|artifactory)[\w\-]*password[\s:=]+["'][a-zA-Z0-9\-_!@#$%^&*()=+]{8,}["']
|
|
604
|
+
pattern: /(?:maven|gradle|nexus|artifactory)[\w\-]*password[\s:=]+["']?[a-zA-Z0-9\-_!@#$%^&*()=+]{8,}["']?/i,
|
|
605
605
|
risk: "Attackers can access your private artifact repository, steal proprietary code, or inject backdoors into your Java packages.",
|
|
606
606
|
solution: "Change your repository password and remove it from the hardcoded configuration file (e.g. settings.xml)."
|
|
607
607
|
}
|
|
@@ -660,7 +660,7 @@ var init_cicd = __esm({
|
|
|
660
660
|
{
|
|
661
661
|
id: "jenkins-token",
|
|
662
662
|
description: "Jenkins Token or API Secret",
|
|
663
|
-
pattern: /(?:jenkins)[\w\-]*(?:token|secret|password)[\s:=]+["'][a-zA-Z0-9]{
|
|
663
|
+
pattern: /(?:jenkins)[\w\-]*(?:token|secret|password)[\s:=]+["']?[a-zA-Z0-9]{20,}["']?/i,
|
|
664
664
|
risk: "Attackers can trigger or modify your Jenkins build pipelines, leading to malicious deployments or lateral movement.",
|
|
665
665
|
solution: "Revoke the API token in the Jenkins User Configuration page and inject secrets using the Jenkins Credentials Manager."
|
|
666
666
|
}
|
|
@@ -712,7 +712,7 @@ var init_webhooks = __esm({
|
|
|
712
712
|
{
|
|
713
713
|
id: "paypal-secret",
|
|
714
714
|
description: "PayPal Client Secret",
|
|
715
|
-
pattern: /paypal[_-]?(?:client[_-]?secret|secret)[\s:=]+["'][a-zA-Z0-9\-_]{30,}["']
|
|
715
|
+
pattern: /paypal[_-]?(?:client[_-]?secret|secret)[\s:=]+["']?[a-zA-Z0-9\-_]{30,}["']?/i,
|
|
716
716
|
risk: "Attackers can process fraudulent payments, manipulate subscriptions, or steal transaction history.",
|
|
717
717
|
solution: "Revoke the secret in the PayPal Developer Dashboard and generate a new one."
|
|
718
718
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-cli-scanner",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "A powerful interactive CLI tool that scans your codebase for hardcoded secrets, API keys, passwords, and private keys before they reach your Git history.",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"scripts": {
|
package/readme.md
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
# Git CLI Scanner
|
|
2
2
|
|
|
3
|
-
A powerful CLI tool that scans your codebase for hardcoded secrets, API keys, passwords, private keys, database credentials, and
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## What Does It Scan For?
|
|
8
|
-
|
|
9
|
-
Git CLI Scanner uses regex heuristics and pattern matching to detect:
|
|
10
|
-
|
|
11
|
-
- **Cloud Provider Keys**: AWS Access/Secret Keys, Google Cloud API Keys.
|
|
12
|
-
- **Infrastructure & Databases**: Database Connection Strings (MongoDB, PostgreSQL, MySQL, Redis), Docker Hub Personal Access Tokens.
|
|
13
|
-
- **Collaboration Tools**: Slack Tokens, Slack Webhooks, GitHub PATs, OAuth Tokens, Discord Webhooks.
|
|
14
|
-
- **Private Keys**: RSA, DSA, EC, OpenSSH, PGP Private Keys.
|
|
15
|
-
- **Banned Files**: Accidental commits of `.env`, `.pem`, `.sqlite`, `.log` files (unless they are explicitly added to `.gitignore`).
|
|
16
|
-
|
|
17
|
-
It features an intelligent **Ignore System** (Dummy Detection) that automatically downgrades the severity of fake, dummy, or test secrets commonly used in unit tests (e.g., `1234567890abcdef`, `dummy_token`).
|
|
3
|
+
A powerful CLI tool that scans your codebase for hardcoded secrets, API keys, passwords, private keys, database credentials, Docker tokens, CI/CD secrets, and infrastructure configs before they reach your Git history.
|
|
18
4
|
|
|
19
5
|
---
|
|
20
6
|
|
|
@@ -30,26 +16,18 @@ npx git-cli-scanner <command>
|
|
|
30
16
|
|
|
31
17
|
---
|
|
32
18
|
|
|
33
|
-
## ๐
|
|
34
|
-
|
|
35
|
-
### Commands Overview
|
|
19
|
+
## ๐ Commands
|
|
36
20
|
|
|
37
21
|
| Command | Description | Arguments & Flags | Example Usage |
|
|
38
22
|
|---------|-------------|-------------------|---------------|
|
|
39
23
|
| `init` | Installs the pre-commit hook to automatically scan files on `git commit`. | None | `npx git-cli-scanner init` |
|
|
40
24
|
| `disable` | Removes the pre-commit hook to stop automatic scanning. | None | `npx git-cli-scanner disable` |
|
|
41
|
-
| `scan` | Manually scans the currently staged files (files added via `git add`). | `--show-sol`
|
|
42
|
-
| `scan-all` | Recursively scans an entire directory for secrets. | `<dir>`
|
|
43
|
-
| `scan-history
|
|
44
|
-
| `explore` | Launches an interactive Terminal User Interface (TUI) to
|
|
45
|
-
|
|
46
|
-
### 6. Interactive File Explorer (TUI)
|
|
47
|
-
|
|
48
|
-
Launch an interactive Terminal User Interface (TUI) to navigate your project directory and manually select files to scan.
|
|
25
|
+
| `scan` | Manually scans the currently staged files (files added via `git add`). | `--show-sol` โ Show suggested fixes for each finding | `npx git-cli-scanner scan`<br>`npx git-cli-scanner scan --show-sol` |
|
|
26
|
+
| `scan-all` | Recursively scans an entire directory for secrets. | `<dir>` โ The directory to scan<br>`--show-sol` โ Show suggested fixes | `npx git-cli-scanner scan-all .`<br>`npx git-cli-scanner scan-all ./src --show-sol` |
|
|
27
|
+
| `scan-history` | Scans Git commit history for leaked secrets (Time Travel). Defaults to the last commit. | `--id <hash>` โ Scan a specific commit<br>`--since="<time>"` โ Scan commits from a time range<br>`--all` โ Scan entire history across all branches<br>`--show-sol` โ Show fixes | `npx git-cli-scanner scan-history`<br>`npx git-cli-scanner scan-history --id 3a4b5c6`<br>`npx git-cli-scanner scan-history --since="30 days ago"`<br>`npx git-cli-scanner scan-history --all --show-sol` |
|
|
28
|
+
| `explore` | Launches an interactive Terminal User Interface (TUI) to browse and scan files. | None | `npx git-cli-scanner explore` |
|
|
49
29
|
|
|
50
|
-
|
|
51
|
-
git-cli-scanner explore
|
|
52
|
-
```
|
|
30
|
+
### Interactive Explorer Keys
|
|
53
31
|
|
|
54
32
|
| Key | Action |
|
|
55
33
|
|-----|--------|
|
|
@@ -60,41 +38,98 @@ git-cli-scanner explore
|
|
|
60
38
|
|
|
61
39
|
---
|
|
62
40
|
|
|
63
|
-
##
|
|
41
|
+
## ๐ What Does It Scan For?
|
|
42
|
+
|
|
43
|
+
### Scanners & Detection Rules
|
|
44
|
+
|
|
45
|
+
| Category | Rule ID | What It Detects | Severity |
|
|
46
|
+
|----------|---------|-----------------|----------|
|
|
47
|
+
| โ๏ธ Cloud Providers | `aws-access-key` | AWS Access Key IDs (`AKIA...`) | High |
|
|
48
|
+
| โ๏ธ Cloud Providers | `aws-secret-key` | AWS Secret Access Keys (heuristics) | High |
|
|
49
|
+
| โ๏ธ Cloud Providers | `gcp-api-key` | Google Cloud API Keys (`AIza...`) | High |
|
|
50
|
+
| ๐ฅ Firebase | `firebase-secret` | Firebase API Keys / Secrets | High |
|
|
51
|
+
| ๐ฅ Firebase | `firebase-service-account` | Firebase Service Account JSON (`"type": "service_account"`) | Critical |
|
|
52
|
+
| ๐ชช Authentication | `jwt-secret` | JWT Secret Keys (quoted or unquoted) | High |
|
|
53
|
+
| ๐ชช Authentication | `oauth-client-secret` | OAuth Client Secrets | High |
|
|
54
|
+
| ๐ชช Authentication | `session-secret` | Session Cookie Secrets | High |
|
|
55
|
+
| ๐ API Keys & Tokens | `generic-api-key` | Generic `api_key`, `api-key`, `API_KEY` patterns | High |
|
|
56
|
+
| ๐ API Keys & Tokens | `stripe-key` | Stripe API Keys (`sk_live_...`, `rk_live_...`) | High |
|
|
57
|
+
| ๐ API Keys & Tokens | `github-pat` | GitHub Personal Access Tokens | High |
|
|
58
|
+
| ๐ API Keys & Tokens | `slack-token` | Slack Bot/User Tokens (`xoxb-...`, `xoxp-...`) | High |
|
|
59
|
+
| ๐ API Keys & Tokens | `slack-webhook` | Slack Incoming Webhook URLs | High |
|
|
60
|
+
| ๐ API Keys & Tokens | `discord-webhook` | Discord Webhook URLs | High |
|
|
61
|
+
| ๐ฆ Package Registries | `npm-token` | NPM Access Tokens (`npm_...`) | High |
|
|
62
|
+
| ๐ฆ Package Registries | `pypi-token` | PyPI Access Tokens (`pypi-...`) | High |
|
|
63
|
+
| ๐ฆ Package Registries | `maven-gradle-password` | Maven/Gradle/Nexus/Artifactory Repository Passwords | High |
|
|
64
|
+
| ๐งฐ CI/CD | `gitlab-ci-token` | GitLab Personal Access Tokens (`glpat-...`) | Critical |
|
|
65
|
+
| ๐งฐ CI/CD | `github-actions-token` | GitHub Actions Runner Tokens (`ghp_...`, `ghs_...`) | Critical |
|
|
66
|
+
| ๐งฐ CI/CD | `jenkins-token` | Jenkins API Tokens / Secrets | High |
|
|
67
|
+
| ๐ Infrastructure | `docker-hub-token` | Docker Hub Personal Access Tokens (`dckr_pat_...`) | High |
|
|
68
|
+
| ๐ Infrastructure | `database-connection-string` | Database Connection Strings (MongoDB, PostgreSQL, MySQL, Redis with credentials) | High |
|
|
69
|
+
| ๐ Infrastructure | `smtp-credentials` | SMTP / SendGrid / Mailgun email passwords | High |
|
|
70
|
+
| ๐ Infrastructure | `terraform-helm-secret` | Terraform (`tf_var_...`) and Helm (`helm_var_...`) variable secrets | High |
|
|
71
|
+
| ๐ Webhooks | `stripe-secret` | Stripe Secret Keys and Webhook Secrets (`sk_live_`, `whsec_`) | High |
|
|
72
|
+
| ๐ Webhooks | `paypal-secret` | PayPal Client Secrets | High |
|
|
73
|
+
| ๐ Webhooks | `generic-webhook` | Generic Webhook URLs (Slack, Discord, IFTTT) | High |
|
|
74
|
+
| ๐ Private Keys | `rsa-private-key` | RSA Private Key blocks (`-----BEGIN RSA PRIVATE KEY-----`) | High |
|
|
75
|
+
| ๐ Private Keys | `dsa-private-key` | DSA Private Key blocks | High |
|
|
76
|
+
| ๐ Private Keys | `ec-private-key` | EC Private Key blocks | High |
|
|
77
|
+
| ๐ Private Keys | `openssh-private-key` | OpenSSH Private Key blocks | High |
|
|
78
|
+
| ๐ Private Keys | `pgp-private-key` | PGP Private Key blocks | High |
|
|
79
|
+
| ๐ Certificates | `banned-file-type` | Banned file extensions: `.pem`, `.key`, `.p12`, `.pfx`, `.crt`, `.cer`, `.keystore`, `.sqlite`, `.db`, `.log`, `.env` | Medium |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## ๐ก๏ธ Intelligent Dummy Detection
|
|
84
|
+
|
|
85
|
+
The scanner features an **Intelligent Ignore System** that automatically downgrades the severity of fake, dummy, or test secrets commonly used in unit tests and example files. This avoids blocking your commits with false positives.
|
|
86
|
+
|
|
87
|
+
**Patterns recognized as dummy:**
|
|
88
|
+
- Sequential characters: `1234567890abcdef`, `abcdefghijklmnop`
|
|
89
|
+
- Common placeholders: `EXAMPLE`, `dummy`, `test`, `fake`, `placeholder`
|
|
90
|
+
- Repetitive patterns: `aaaa`, `0000`
|
|
64
91
|
|
|
65
|
-
|
|
92
|
+
When a dummy value is detected, the finding is downgraded from `โ HIGH` to `โ IGNORED (DUMMY)` and **will not block** your commit.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Severity Levels
|
|
66
97
|
|
|
67
98
|
| Indicator | Level | Color | Meaning |
|
|
68
99
|
|-----------|-------|-------|---------|
|
|
69
|
-
| `โ` |
|
|
70
|
-
| `โ` |
|
|
71
|
-
|
|
|
100
|
+
| `โ` | CRITICAL | Red | CI/CD and service account secrets that grant admin-level access |
|
|
101
|
+
| `โ` | HIGH | Red | Hardcoded secrets that pose a critical risk and must be removed |
|
|
102
|
+
| `โ` | MEDIUM | Yellow | Risky files or configurations not safely ignored in `.gitignore` |
|
|
103
|
+
| `โ` | IGNORED | Dim | Test/example values (auto-detected dummy values that pose no risk) |
|
|
72
104
|
|
|
73
105
|
---
|
|
74
106
|
|
|
75
107
|
## Example Output
|
|
76
108
|
|
|
77
109
|
```
|
|
78
|
-
โ Found
|
|
110
|
+
โ Found 3 potential vulnerabilities! (3 blockers)
|
|
79
111
|
|
|
80
112
|
Scan Results:
|
|
81
113
|
|
|
82
|
-
โ HIGH ยท
|
|
83
|
-
File: src/config/
|
|
84
|
-
Match:
|
|
85
|
-
Risk:
|
|
114
|
+
โ HIGH ยท jwt-secret
|
|
115
|
+
File: src/config/auth.ts:5
|
|
116
|
+
Match: JWT_SECRET=xJk9Lp2Rm5Qw8Yz1Xv4Bn7Cm...
|
|
117
|
+
Risk: An attacker can forge JWT tokens to impersonate any user, including admins.
|
|
86
118
|
|
|
87
119
|
โ HIGH ยท database-connection-string
|
|
88
|
-
File: src/db/connection.ts:
|
|
89
|
-
Match: mongodb+srv://admin:
|
|
90
|
-
Risk: An attacker can directly connect to your database instance
|
|
120
|
+
File: src/db/connection.ts:3
|
|
121
|
+
Match: mongodb+srv://admin:supersecret@cluster0.mongo...
|
|
122
|
+
Risk: An attacker can directly connect to your database instance.
|
|
123
|
+
|
|
124
|
+
โ IGNORED (DUMMY) ยท aws-access-key
|
|
125
|
+
File: tests/mock.ts:10
|
|
126
|
+
Match: AKIAIOSFODNN7EXAMPLE...
|
|
127
|
+
Risk: (auto-downgraded โ recognized as a test/example value)
|
|
91
128
|
```
|
|
92
129
|
|
|
93
130
|
---
|
|
94
131
|
|
|
95
|
-
## Running Tests
|
|
96
|
-
|
|
97
|
-
If you are contributing to the project, you can run the test suite using Vitest:
|
|
132
|
+
## Running Tests
|
|
98
133
|
|
|
99
134
|
```bash
|
|
100
135
|
npm test
|