api-key-guard 1.0.1 → 1.0.3
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/README.md +84 -61
- package/package.json +1 -1
- package/src/readmeGenerator.js +1 -1
package/README.md
CHANGED
|
@@ -1,61 +1,84 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Features
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
# 🔐 api-key-guard
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/api-key-guard)
|
|
4
|
+
[](https://www.npmjs.com/package/api-key-guard)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
## Project Title & Description
|
|
8
|
+
|
|
9
|
+
**api-key-guard** is a comprehensive Node.js CLI tool designed to help developers and teams detect, prevent, and manage API key leaks within their codebases. It provides powerful scanning capabilities, integrates seamlessly with Git hooks, and even offers AI-powered assistance for project documentation, ensuring your secrets stay secret.
|
|
10
|
+
|
|
11
|
+
## ⚠️ Problem Statement: The Silent Threat of API Key Leaks
|
|
12
|
+
|
|
13
|
+
Accidentally committing API keys, private tokens, or sensitive credentials to a public or even private repository is a widespread and critical security vulnerability. A single leaked key can lead to:
|
|
14
|
+
|
|
15
|
+
* **Data Breaches:** Unauthorized access to sensitive user data.
|
|
16
|
+
* **Financial Loss:** Misuse of cloud resources, payment gateways, or premium services.
|
|
17
|
+
* **Reputational Damage:** Erosion of trust from customers and partners.
|
|
18
|
+
* **Service Interruptions:** Malicious actors disabling or disrupting your services.
|
|
19
|
+
|
|
20
|
+
Traditional methods often rely on manual reviews or simplistic grep commands, which are prone to error and can't keep pace with rapid development cycles. **api-key-guard** provides an automated, intelligent solution to proactively safeguard your repositories against this silent, yet devastating, threat.
|
|
21
|
+
|
|
22
|
+
## ✨ Features List
|
|
23
|
+
|
|
24
|
+
**api-key-guard** comes packed with features to make API key management robust and effortless:
|
|
25
|
+
|
|
26
|
+
* 🔍 **Advanced API Key Detection:**
|
|
27
|
+
* Utilizes a combination of regex patterns and entropy analysis to identify a wide range of common API keys (AWS, Google Cloud, Stripe, GitHub, etc.) and high-entropy strings that might be custom secrets.
|
|
28
|
+
* Scans various file types including JavaScript, TypeScript, Python, Ruby, JSON, YAML, Markdown, and more.
|
|
29
|
+
* 🎣 **Seamless Git Hooks Integration:**
|
|
30
|
+
* Set up pre-commit hooks to automatically scan staged files before every commit, preventing secrets from ever reaching your repository.
|
|
31
|
+
* Provides clear feedback and blocks commits if a leak is detected.
|
|
32
|
+
* 🚀 **Powerful CLI Commands:**
|
|
33
|
+
* `scan`: On-demand scanning of entire directories or specific files.
|
|
34
|
+
* `setup-hooks`: Automates the installation of Git pre-commit hooks.
|
|
35
|
+
* `readme`: Leverages AI to generate comprehensive `README.md` files based on your project's structure and existing documentation.
|
|
36
|
+
* 🤖 **AI-Powered README Generation:**
|
|
37
|
+
* A unique feature that helps you quickly generate professional and informative `README.md` files, improving project documentation and onboarding.
|
|
38
|
+
* 📁 **Multiple File Format Support:**
|
|
39
|
+
* Intelligently parses and scans a broad spectrum of text-based file formats, ensuring no stone is left unturned.
|
|
40
|
+
* ⚙️ **Configurable Ignore Patterns:**
|
|
41
|
+
* Define custom ignore rules in configuration files or via CLI flags to exclude specific files, directories (e.g., `node_modules`, `dist`), or even patterns of "false positive" keys, reducing noise.
|
|
42
|
+
* 🌈 **Colorful and Clear Output:**
|
|
43
|
+
* Leverages `chalk` to provide easy-to-read, color-coded output in the terminal, highlighting detected keys and scan results.
|
|
44
|
+
|
|
45
|
+
## 🛠️ Installation
|
|
46
|
+
|
|
47
|
+
**Prerequisites:**
|
|
48
|
+
|
|
49
|
+
* Node.js (v14 or higher)
|
|
50
|
+
* npm (v6 or higher)
|
|
51
|
+
|
|
52
|
+
Install `api-key-guard` globally using npm:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g api-key-guard
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Verify the installation by checking the version:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
api-key-guard --version
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 🚀 CLI Usage Examples
|
|
65
|
+
|
|
66
|
+
`api-key-guard` provides a simple yet powerful command-line interface.
|
|
67
|
+
|
|
68
|
+
### 1. `api-key-guard scan` - Scan your codebase for API keys
|
|
69
|
+
|
|
70
|
+
Scan a directory or specific files for potential API key leaks.
|
|
71
|
+
|
|
72
|
+
#### Basic Scan of Current Directory:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
api-key-guard scan .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Scan a Specific File:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
api-key-guard scan src/utils/api.js
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Scan a Specific Directory with
|
package/package.json
CHANGED
package/src/readmeGenerator.js
CHANGED
|
@@ -97,7 +97,7 @@ async function generateWithGemini(apiKey, projectContext) {
|
|
|
97
97
|
|
|
98
98
|
try {
|
|
99
99
|
const response = await axios.post(
|
|
100
|
-
`https://generativelanguage.googleapis.com/
|
|
100
|
+
`https://generativelanguage.googleapis.com/v1/models/gemini-2.5-flash:generateContent?key=${apiKey}`,
|
|
101
101
|
{
|
|
102
102
|
contents: [{
|
|
103
103
|
parts: [{
|