envspect 0.1.0
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/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/cli.js +721 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +692 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rakib
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# envspect
|
|
4
|
+
|
|
5
|
+
🔍 Zero-config `.env` validation, secret leak detection, and team sync CLI
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/envspect)
|
|
8
|
+
[](https://github.com/Rakib-Coder00/envspect/actions/workflows/ci.yml)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why?
|
|
16
|
+
|
|
17
|
+
Every team has these problems:
|
|
18
|
+
|
|
19
|
+
- 🔴 `.env.example` is outdated — new devs waste hours figuring out missing vars
|
|
20
|
+
- 🔴 Secrets get hardcoded in source files and committed to git
|
|
21
|
+
- 🔴 No one knows if `.env` matches `.env.example` until something breaks in production
|
|
22
|
+
|
|
23
|
+
**envspect** fixes all of this with a single command.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Use directly with npx (no install needed)
|
|
29
|
+
npx envspect scan
|
|
30
|
+
|
|
31
|
+
# Or install globally
|
|
32
|
+
npm install -g envspect
|
|
33
|
+
|
|
34
|
+
# Or as a dev dependency
|
|
35
|
+
npm install -D envspect
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### `envspect scan` — Env Diff Detection
|
|
41
|
+
|
|
42
|
+
Compares your `.env` against `.env.example` and reports missing, extra, and empty variables.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Basic scan
|
|
46
|
+
envspect scan
|
|
47
|
+
|
|
48
|
+
# Custom files
|
|
49
|
+
envspect scan --env .env.local --example .env.template
|
|
50
|
+
|
|
51
|
+
# Strict mode (also flags empty values as errors)
|
|
52
|
+
envspect scan --strict
|
|
53
|
+
|
|
54
|
+
# JSON output (for CI/CD pipelines)
|
|
55
|
+
envspect scan --format json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `envspect audit` — Secret Leak Detection
|
|
59
|
+
|
|
60
|
+
Scans your codebase for hardcoded secrets, API keys, tokens, and credentials.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Scan current directory
|
|
64
|
+
envspect audit
|
|
65
|
+
|
|
66
|
+
# Only show critical severity
|
|
67
|
+
envspect audit --severity critical
|
|
68
|
+
|
|
69
|
+
# Custom include/exclude patterns
|
|
70
|
+
envspect audit --include "src/**" --exclude "**/*.test.ts"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Detects 15+ secret patterns:**
|
|
74
|
+
- AWS Access Keys & Secret Keys
|
|
75
|
+
- GitHub Personal Access Tokens
|
|
76
|
+
- Stripe API Keys
|
|
77
|
+
- JWT Tokens
|
|
78
|
+
- Database Connection Strings (PostgreSQL, MongoDB, MySQL, Redis)
|
|
79
|
+
- Google API Keys
|
|
80
|
+
- Slack, SendGrid, Twilio, Discord tokens
|
|
81
|
+
- PEM Private Keys
|
|
82
|
+
- Generic API key/password assignments
|
|
83
|
+
- npm tokens
|
|
84
|
+
|
|
85
|
+
### `envspect sync` — Team Sync (Coming in v1.0)
|
|
86
|
+
|
|
87
|
+
Encrypted `.env` sharing for teams. No more Slack DMs with secrets.
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
Create a `.envspectrc` or `.envspectrc.json` in your project root:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"envFile": ".env",
|
|
96
|
+
"exampleFile": ".env.example",
|
|
97
|
+
"format": "table",
|
|
98
|
+
"scan": {
|
|
99
|
+
"strict": false
|
|
100
|
+
},
|
|
101
|
+
"audit": {
|
|
102
|
+
"include": ["src/**"],
|
|
103
|
+
"exclude": ["**/node_modules/**", "**/dist/**"],
|
|
104
|
+
"severity": "low"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## CI/CD Integration
|
|
110
|
+
|
|
111
|
+
Add to your GitHub Actions workflow:
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
- name: Validate environment
|
|
115
|
+
run: npx envspect scan --format json --strict
|
|
116
|
+
|
|
117
|
+
- name: Audit for secrets
|
|
118
|
+
run: npx envspect audit --severity high
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Programmatic API
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { parseEnvFile, diffEnvFiles, scanDirectory, defaultRules } from 'envspect';
|
|
125
|
+
|
|
126
|
+
// Parse and diff env files
|
|
127
|
+
const example = await parseEnvFile('.env.example');
|
|
128
|
+
const env = await parseEnvFile('.env');
|
|
129
|
+
const diff = diffEnvFiles(example.entries, env.entries);
|
|
130
|
+
|
|
131
|
+
console.log(`Missing: ${diff.missing.length}`);
|
|
132
|
+
console.log(`Extra: ${diff.extra.length}`);
|
|
133
|
+
|
|
134
|
+
// Scan for secrets
|
|
135
|
+
const report = await scanDirectory({
|
|
136
|
+
cwd: process.cwd(),
|
|
137
|
+
rules: defaultRules,
|
|
138
|
+
include: ['**/*.ts'],
|
|
139
|
+
exclude: ['**/node_modules/**'],
|
|
140
|
+
minSeverity: 'low',
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
console.log(`Found ${report.findings.length} potential secrets`);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT © [Rakib Hassan](https://github.com/Rakib-Coder00)
|