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.
Files changed (3) hide show
  1. package/dist/cli.js +10 -10
  2. package/package.json +1 -1
  3. 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,}["']/i,
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]+["']/i,
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]+["']/i,
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:=]+[\"'][a-zA-Z0-9\-_!@#$%^&*()=+]{16,}[\"']/i,
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:=]+[\"'][a-zA-Z0-9\-_]{16,}[\"']/i,
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:=]+[\"'][a-zA-Z0-9\-_!@#$%^&*()=+]{16,}[\"']/i,
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})["']/i,
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,}["']/i,
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]{32}["']/i,
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,}["']/i,
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.0",
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 Docker infrastructure tokens before they reach your Git history.
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
- ## ๐Ÿš€ Usage & Commands
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` (Shows suggested solutions) | `npx git-cli-scanner scan`<br>`npx git-cli-scanner scan --show-sol` |
42
- | `scan-all` | Recursively scans an entire directory for secrets. | `<dir>` (The directory to scan)<br>`--show-sol` (Shows solutions) | `npx git-cli-scanner scan-all .`<br>`npx git-cli-scanner scan-all ./src --show-sol` |
43
- | `scan-history`| Scans Git commit history for leaked secrets (Time Travel). | `--id <hash>` (Scan a specific commit)<br>`--since="<time>"` (Scan from a time)<br>`--all` (Scan entire history)<br>`--show-sol` (Shows solutions) | `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` |
44
- | `explore` | Launches an interactive Terminal User Interface (TUI) to navigate and scan files. | None | `npx git-cli-scanner explore` |
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
- ```bash
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
- ## Severity Levels
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
- The scanner categorizes findings into different severity levels:
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
- | `โ—` | HIGH | Red | Hardcoded secrets that pose a critical risk and must be removed. |
70
- | `โ—` | MEDIUM | Yellow | Risky files or configurations not safely ignored in `.gitignore`. |
71
- | `โ—‹` | IGNORED | Dim | Test/example values (auto-detected dummy values that pose no risk). |
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 2 vulnerabilities! (2 blockers)
110
+ โœ– Found 3 potential vulnerabilities! (3 blockers)
79
111
 
80
112
  Scan Results:
81
113
 
82
- โ— HIGH ยท aws-secret-key
83
- File: src/config/aws.ts:12
84
- Match: aws_secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEX...
85
- Risk: Compromised AWS Secret Keys grant direct access to your entire cloud infrastructure.
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:5
89
- Match: mongodb+srv://admin:supersecret123@cluster0.mongo...
90
- Risk: An attacker can directly connect to your database instance, allowing them to steal user data.
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 Locally
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