api-key-guard 1.0.1 → 1.0.2

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 CHANGED
@@ -1,61 +1,84 @@
1
- # API Key Guard
2
-
3
- A comprehensive CLI tool for detecting, preventing, and managing API key leaks in your codebase with AI-powered README generation.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Install the package
9
- npm install -g api-key-guard
10
-
11
- # Scan for API key leaks
12
- api-key-guard scan
13
-
14
- # Setup git hooks
15
- api-key-guard setup-hooks
16
-
17
- # Generate AI-powered README (requires GEMINI_API_KEY)
18
- export GEMINI_API_KEY=your_gemini_api_key_here
19
- api-key-guard readme
20
- ```
21
-
22
- ## Features
23
-
24
- - 🔍 **API Key Detection**: Scan your codebase for potential API key leaks
25
- - 🔗 **Git Hooks Integration**: Automatically check for leaks before commits
26
- - 🤖 **AI-Powered README**: Generate professional README files using Google's Gemini API
27
- - ⚙️ **Configurable**: Customize scanning patterns and ignore rules
28
- - 🛡️ **Security First**: Built with security best practices in mind
29
-
30
- ## CLI Commands
31
-
32
- ### `api-key-guard scan`
33
- Scan files for potential API key leaks.
34
-
35
- Options:
36
- - `-p, --path <path>`: Path to scan (default: current directory)
37
- - `-v, --verbose`: Show detailed output
38
-
39
- ### `api-key-guard setup-hooks`
40
- Setup git hooks for automatic API key detection before commits.
41
-
42
- ### `api-key-guard readme`
43
- Generate an AI-powered README.md file using Gemini API.
44
-
45
- Options:
46
- - `-f, --force`: Overwrite existing README.md without confirmation
47
- - `-o, --output <file>`: Output file path (default: README.md)
48
-
49
- ## Environment Variables
50
-
51
- - `GEMINI_API_KEY`: Required for README generation. Get your API key from [Google AI Studio](https://makersuite.google.com/app/apikey)
52
-
53
- ## Installation
54
-
55
- ```bash
56
- npm install api-key-guard
57
- ```
58
-
59
- ## License
60
-
61
- MIT
1
+ # 🔐 api-key-guard
2
+
3
+ [![npm version](https://badge.fury.io/js/api-key-guard.svg)](https://www.npmjs.com/package/api-key-guard)
4
+ [![npm downloads](https://img.shields.io/npm/dm/api-key-guard.svg)](https://www.npmjs.com/package/api-key-guard)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-key-guard",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A comprehensive tool to detect, prevent, and manage API key leaks in your codebase with AI-powered README generation",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -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/v1beta/models/gemini-1.5-flash:generateContent?key=${apiKey}`,
100
+ `https://generativelanguage.googleapis.com/v1/models/gemini-2.5-flash:generateContent?key=${apiKey}`,
101
101
  {
102
102
  contents: [{
103
103
  parts: [{