@gitguard/cli 1.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 +356 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +135 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +26 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/scan.d.ts +14 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +85 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +46 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-client.d.ts +21 -0
- package/dist/lib/api-client.d.ts.map +1 -0
- package/dist/lib/api-client.js +54 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/config.d.ts +19 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +93 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/file-scanner.d.ts +6 -0
- package/dist/lib/file-scanner.d.ts.map +1 -0
- package/dist/lib/file-scanner.js +131 -0
- package/dist/lib/file-scanner.js.map +1 -0
- package/dist/lib/repo-detector.d.ts +6 -0
- package/dist/lib/repo-detector.d.ts.map +1 -0
- package/dist/lib/repo-detector.js +116 -0
- package/dist/lib/repo-detector.js.map +1 -0
- package/dist/lib/reporter.d.ts +18 -0
- package/dist/lib/reporter.d.ts.map +1 -0
- package/dist/lib/reporter.js +178 -0
- package/dist/lib/reporter.js.map +1 -0
- package/dist/types/index.d.ts +70 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GitGuard
|
|
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,356 @@
|
|
|
1
|
+
# GitGuard CLI
|
|
2
|
+
|
|
3
|
+
🛡️ **Security scanning for developers** - Find vulnerabilities in your code before they reach production.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@gitguard/cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🔍 **Comprehensive Security Scanning** - Detect SQL injection, XSS, CSRF, and 50+ vulnerability patterns
|
|
11
|
+
- ⚡ **Fast & Easy** - Scan your code in seconds with a single command
|
|
12
|
+
- 🎯 **CI/CD Ready** - Perfect for pre-commit hooks and automated pipelines
|
|
13
|
+
- 🔐 **Privacy First** - Scans run securely through GitGuard's API with enterprise-grade security
|
|
14
|
+
- 📊 **Subscription Tiers** - Free tier for unlimited scans with unlimited AI analysis for Premier users
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install globally
|
|
20
|
+
npm install -g @gitguard/cli
|
|
21
|
+
|
|
22
|
+
# Login to GitGuard
|
|
23
|
+
gitguard login
|
|
24
|
+
|
|
25
|
+
# Scan your code
|
|
26
|
+
gitguard scan
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### NPM
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g @gitguard/cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Yarn
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
yarn global add @gitguard/cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Authentication
|
|
46
|
+
|
|
47
|
+
Before scanning, authenticate with your GitGuard account:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
gitguard login
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If you don't have an account, sign up at [gitguard.net](https://www.gitguard.net).
|
|
54
|
+
|
|
55
|
+
### Scanning Code
|
|
56
|
+
|
|
57
|
+
**The CLI automatically uses your web app preferences!** If you have AI scanning enabled in your GitGuard account, the CLI will use it by default.
|
|
58
|
+
|
|
59
|
+
Scan the current directory (uses your default settings):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
gitguard scan
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Scan a specific directory:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
gitguard scan --dir ./src
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Scan a single file:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
gitguard scan --file ./src/api/auth.ts
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Override your default settings:**
|
|
78
|
+
|
|
79
|
+
Force enable AI analysis (even if disabled in your account):
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
gitguard scan --ai
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Disable AI analysis (even if enabled in your account):
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
gitguard scan --no-ai
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Enable/disable specific features:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
gitguard scan --dependencies --no-ai # Dependencies: yes, AI: no
|
|
95
|
+
gitguard scan --secrets --no-dependencies # Secrets: yes, Dependencies: no
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Output JSON for CI/CD:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
gitguard scan --json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Check Your Account
|
|
105
|
+
|
|
106
|
+
View your subscription and usage limits:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
gitguard whoami
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Logout
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
gitguard logout
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Commands
|
|
119
|
+
|
|
120
|
+
| Command | Description |
|
|
121
|
+
|---------|-------------|
|
|
122
|
+
| `gitguard login` | Authenticate with GitGuard |
|
|
123
|
+
| `gitguard logout` | Log out of your account |
|
|
124
|
+
| `gitguard scan` | Scan code for vulnerabilities |
|
|
125
|
+
| `gitguard whoami` | Show current user and subscription info |
|
|
126
|
+
| `gitguard --help` | Show help |
|
|
127
|
+
|
|
128
|
+
## Scan Options
|
|
129
|
+
|
|
130
|
+
| Option | Description |
|
|
131
|
+
|--------|-------------|
|
|
132
|
+
| `-d, --dir <path>` | Directory to scan (default: current directory) |
|
|
133
|
+
| `-f, --file <path>` | Scan a specific file |
|
|
134
|
+
| `--ai` | Force enable AI-powered analysis |
|
|
135
|
+
| `--no-ai` | Disable AI-powered analysis |
|
|
136
|
+
| `--dependencies` | Force enable dependency scanning |
|
|
137
|
+
| `--no-dependencies` | Disable dependency scanning |
|
|
138
|
+
| `--secrets` | Force enable secret detection |
|
|
139
|
+
| `--no-secrets` | Disable secret detection |
|
|
140
|
+
| `--json` | Output results as JSON |
|
|
141
|
+
|
|
142
|
+
**Note:** By default, the CLI uses your web app preferences. Override flags (`--ai`, `--dependencies`, `--secrets`) force-enable features. Disable flags (`--no-ai`, `--no-dependencies`, `--no-secrets`) force-disable them.
|
|
143
|
+
|
|
144
|
+
## Subscription Tiers
|
|
145
|
+
|
|
146
|
+
### Free
|
|
147
|
+
- Unlimited scans per day
|
|
148
|
+
- Basic vulnerability detection (50+ patterns)
|
|
149
|
+
- JSON export for CI/CD
|
|
150
|
+
- Public repository scanning
|
|
151
|
+
|
|
152
|
+
### Pro
|
|
153
|
+
- Everything in Free
|
|
154
|
+
- **AI-powered vulnerability analysis** (enabled by default)
|
|
155
|
+
- Private repository scanning
|
|
156
|
+
- Priority support
|
|
157
|
+
|
|
158
|
+
### Premier
|
|
159
|
+
- Everything in Pro
|
|
160
|
+
- **All scan features enabled by default:**
|
|
161
|
+
- AI-powered vulnerability analysis ✓
|
|
162
|
+
- Dependency scanning ✓
|
|
163
|
+
- Secret detection ✓
|
|
164
|
+
- License compliance checking ✓
|
|
165
|
+
- Unlimited team members
|
|
166
|
+
- SLA guarantee
|
|
167
|
+
|
|
168
|
+
[View full pricing](https://www.gitguard.net/pricing)
|
|
169
|
+
|
|
170
|
+
## CI/CD Integration
|
|
171
|
+
|
|
172
|
+
### GitHub Actions
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
name: Security Scan
|
|
176
|
+
|
|
177
|
+
on: [push, pull_request]
|
|
178
|
+
|
|
179
|
+
jobs:
|
|
180
|
+
security:
|
|
181
|
+
runs-on: ubuntu-latest
|
|
182
|
+
steps:
|
|
183
|
+
- uses: actions/checkout@v3
|
|
184
|
+
- name: Install GitGuard CLI
|
|
185
|
+
run: npm install -g @gitguard/cli
|
|
186
|
+
- name: Run security scan
|
|
187
|
+
env:
|
|
188
|
+
GITGUARD_API_TOKEN: ${{ secrets.GITGUARD_API_TOKEN }}
|
|
189
|
+
run: |
|
|
190
|
+
echo "$GITGUARD_API_TOKEN" | gitguard login --token
|
|
191
|
+
gitguard scan --json > scan-results.json
|
|
192
|
+
- name: Upload scan results
|
|
193
|
+
uses: actions/upload-artifact@v3
|
|
194
|
+
with:
|
|
195
|
+
name: security-scan
|
|
196
|
+
path: scan-results.json
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Pre-commit Hook
|
|
200
|
+
|
|
201
|
+
Add to `.git/hooks/pre-commit`:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
#!/bin/sh
|
|
205
|
+
|
|
206
|
+
# Run GitGuard scan on staged files
|
|
207
|
+
gitguard scan --dir .
|
|
208
|
+
|
|
209
|
+
if [ $? -ne 0 ]; then
|
|
210
|
+
echo "Security issues found! Fix them or use --no-verify to bypass."
|
|
211
|
+
exit 1
|
|
212
|
+
fi
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Make it executable:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
chmod +x .git/hooks/pre-commit
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Exit Codes
|
|
222
|
+
|
|
223
|
+
- `0` - No critical or high severity vulnerabilities found
|
|
224
|
+
- `1` - Critical or high severity vulnerabilities found, or scan error
|
|
225
|
+
|
|
226
|
+
Perfect for failing CI/CD pipelines on security issues!
|
|
227
|
+
|
|
228
|
+
## What Gets Scanned?
|
|
229
|
+
|
|
230
|
+
The CLI automatically scans these file types:
|
|
231
|
+
|
|
232
|
+
- **Web**: TypeScript, JavaScript (`.ts`, `.tsx`, `.js`, `.jsx`)
|
|
233
|
+
- **Backend**: Python (`.py`), Ruby (`.rb`), PHP (`.php`), Go (`.go`)
|
|
234
|
+
- **Mobile**: Swift (`.swift`), Kotlin (`.kt`)
|
|
235
|
+
- **Systems**: Rust (`.rs`), C/C++ (`.c`, `.cpp`), C# (`.cs`)
|
|
236
|
+
- **JVM**: Java (`.java`), Scala (`.scala`)
|
|
237
|
+
|
|
238
|
+
**Smart Exclusions:**
|
|
239
|
+
- Automatically respects your `.gitignore` file (if present)
|
|
240
|
+
- Falls back to excluding: `node_modules`, `dist`, `build`, `.git`, `.next`, `coverage`, `__pycache__`, `vendor`
|
|
241
|
+
- Skips hidden directories (unless explicitly included in your project)
|
|
242
|
+
|
|
243
|
+
## Detected Vulnerabilities
|
|
244
|
+
|
|
245
|
+
GitGuard detects 50+ vulnerability patterns including:
|
|
246
|
+
|
|
247
|
+
- **Injection Attacks**: SQL injection, Command injection, LDAP injection
|
|
248
|
+
- **XSS**: Reflected, Stored, DOM-based
|
|
249
|
+
- **Authentication**: Weak passwords, Insecure session management
|
|
250
|
+
- **Cryptography**: Weak algorithms, Hardcoded secrets
|
|
251
|
+
- **SSRF**: Server-side request forgery
|
|
252
|
+
- **Path Traversal**: Directory traversal attacks
|
|
253
|
+
- **CSRF**: Cross-site request forgery
|
|
254
|
+
|
|
255
|
+
... and many more!
|
|
256
|
+
|
|
257
|
+
## Examples
|
|
258
|
+
|
|
259
|
+
### Simple Scan
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
$ gitguard scan
|
|
263
|
+
|
|
264
|
+
✓ Collecting files...
|
|
265
|
+
ℹ Found 47 file(s), sending to GitGuard...
|
|
266
|
+
|
|
267
|
+
Scan Results
|
|
268
|
+
Files scanned: 47
|
|
269
|
+
Duration: 2.3s
|
|
270
|
+
|
|
271
|
+
Found 3 issue(s):
|
|
272
|
+
HIGH: 2
|
|
273
|
+
MEDIUM: 1
|
|
274
|
+
|
|
275
|
+
HIGH SQL Injection
|
|
276
|
+
src/api/users.ts:45
|
|
277
|
+
Unsanitized user input in SQL query
|
|
278
|
+
|
|
279
|
+
HIGH XSS Vulnerability
|
|
280
|
+
components/Form.tsx:23
|
|
281
|
+
Unescaped user input in HTML
|
|
282
|
+
|
|
283
|
+
MEDIUM Weak Cryptography
|
|
284
|
+
lib/crypto.ts:12
|
|
285
|
+
Using MD5 for hashing (use bcrypt instead)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### CI/CD JSON Output
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
$ gitguard scan --json
|
|
292
|
+
|
|
293
|
+
{
|
|
294
|
+
"scanId": "scan_abc123",
|
|
295
|
+
"status": "completed",
|
|
296
|
+
"filesScanned": 47,
|
|
297
|
+
"duration": 2300,
|
|
298
|
+
"summary": {
|
|
299
|
+
"total": 3,
|
|
300
|
+
"critical": 0,
|
|
301
|
+
"high": 2,
|
|
302
|
+
"medium": 1,
|
|
303
|
+
"low": 0,
|
|
304
|
+
"info": 0
|
|
305
|
+
},
|
|
306
|
+
"vulnerabilities": [...]
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Troubleshooting
|
|
311
|
+
|
|
312
|
+
### Authentication Failed
|
|
313
|
+
|
|
314
|
+
If you see "Authentication expired", log in again:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
gitguard logout
|
|
318
|
+
gitguard login
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Rate Limit Exceeded
|
|
322
|
+
|
|
323
|
+
Free tier has generous limits. If you hit the limit:
|
|
324
|
+
|
|
325
|
+
1. Wait for the daily reset (shown in `gitguard whoami`)
|
|
326
|
+
2. Or upgrade to Pro/Premier for unlimited scans
|
|
327
|
+
|
|
328
|
+
### No Files Found
|
|
329
|
+
|
|
330
|
+
Make sure you're in a directory with code files. The CLI only scans supported file types (see "What Gets Scanned?" above).
|
|
331
|
+
|
|
332
|
+
## Privacy & Security
|
|
333
|
+
|
|
334
|
+
- Your code is transmitted securely over HTTPS
|
|
335
|
+
- Scans are processed server-side and deleted after completion
|
|
336
|
+
- No code is stored permanently
|
|
337
|
+
- API tokens are stored locally in `~/.gitguard/config.json` (chmod 600)
|
|
338
|
+
- View our [Privacy Policy](https://www.gitguard.net/privacy)
|
|
339
|
+
|
|
340
|
+
## Support
|
|
341
|
+
|
|
342
|
+
- 📖 [Documentation](https://github.com/git-guard)
|
|
343
|
+
- 🐛 [Report Issues](https://github.com/git-guard/gitguard-cli/issues)
|
|
344
|
+
- 📧 [Email Support](mailto:support@gitguard.net)
|
|
345
|
+
|
|
346
|
+
## Contributing
|
|
347
|
+
|
|
348
|
+
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
349
|
+
|
|
350
|
+
## License
|
|
351
|
+
|
|
352
|
+
MIT © GitGuard
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
Made with ❤️ by the [Creative Lid LLC](https://www.creativelid.com) - [GitGuard](https://www.gitguard.net) team
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AASA,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAuFlD"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loginCommand = loginCommand;
|
|
7
|
+
const open_1 = __importDefault(require("open"));
|
|
8
|
+
const readline_1 = __importDefault(require("readline"));
|
|
9
|
+
const config_1 = require("../lib/config");
|
|
10
|
+
const api_client_1 = require("../lib/api-client");
|
|
11
|
+
const reporter_1 = require("../lib/reporter");
|
|
12
|
+
const POLL_INTERVAL = 2000;
|
|
13
|
+
const MAX_POLL_TIME = 600000;
|
|
14
|
+
async function loginCommand() {
|
|
15
|
+
const config = new config_1.ConfigManager();
|
|
16
|
+
const reporter = new reporter_1.Reporter(config);
|
|
17
|
+
if (process.env.GITGUARD_API_URL) {
|
|
18
|
+
config.set({ apiUrl: process.env.GITGUARD_API_URL });
|
|
19
|
+
reporter.info(`Using API URL: ${process.env.GITGUARD_API_URL}`);
|
|
20
|
+
}
|
|
21
|
+
const apiClient = new api_client_1.APIClient(config);
|
|
22
|
+
try {
|
|
23
|
+
reporter.info('Initializing authentication...');
|
|
24
|
+
const { requestCode, authUrl } = await apiClient.requestAuth();
|
|
25
|
+
reporter.info('\nIMPORTANT: You must be logged into GitGuard in your browser first!');
|
|
26
|
+
reporter.info('If you don\'t have an account, visit the web app to sign up.\n');
|
|
27
|
+
reporter.info('Please authenticate in your browser.');
|
|
28
|
+
reporter.info(`Opening: ${authUrl}\n`);
|
|
29
|
+
reporter.info('If the browser does not open automatically, please visit the URL above.\n');
|
|
30
|
+
await (0, open_1.default)(authUrl);
|
|
31
|
+
reporter.info('Waiting for authentication...');
|
|
32
|
+
let token;
|
|
33
|
+
try {
|
|
34
|
+
token = await pollForToken(apiClient, requestCode, reporter);
|
|
35
|
+
}
|
|
36
|
+
catch (pollError) {
|
|
37
|
+
if (pollError.message === 'Authentication timeout' || pollError.message === 'Authentication expired') {
|
|
38
|
+
reporter.warning('\nAutomatic authentication failed.');
|
|
39
|
+
reporter.info('If you see your token in the browser, you can paste it below:\n');
|
|
40
|
+
const manualToken = await promptForToken();
|
|
41
|
+
if (manualToken && manualToken.startsWith('gg_')) {
|
|
42
|
+
token = manualToken;
|
|
43
|
+
reporter.info('Token received manually.');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw pollError;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw pollError;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
config.setApiToken(token, 'temp@email.com');
|
|
54
|
+
const profile = await apiClient.getProfile();
|
|
55
|
+
config.setApiToken(token, profile.email);
|
|
56
|
+
config.setUserProfile(profile.subscription, profile.preferences);
|
|
57
|
+
reporter.success(`\nSuccessfully logged in as ${profile.email}`);
|
|
58
|
+
reporter.info(`Subscription: ${profile.subscription}`);
|
|
59
|
+
reporter.info(`Daily scans remaining: ${profile.limits.scansRemaining}/${profile.limits.dailyScans}`);
|
|
60
|
+
if (profile.subscription !== 'free') {
|
|
61
|
+
reporter.info('\nDefault scan features:');
|
|
62
|
+
if (profile.preferences.aiScanEnabled && (profile.subscription === 'pro' || profile.subscription === 'premier')) {
|
|
63
|
+
reporter.info(' ✓ AI-powered analysis enabled');
|
|
64
|
+
}
|
|
65
|
+
if (profile.preferences.dependencyScanEnabled && profile.subscription === 'premier') {
|
|
66
|
+
reporter.info(' ✓ Dependency scanning enabled');
|
|
67
|
+
}
|
|
68
|
+
if (profile.preferences.secretScanEnabled && profile.subscription === 'premier') {
|
|
69
|
+
reporter.info(' ✓ Secret detection enabled');
|
|
70
|
+
}
|
|
71
|
+
reporter.info('\nUse --no-ai, --no-dependencies, or --no-secrets to disable specific features.');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.message === 'Authentication timeout') {
|
|
76
|
+
reporter.error('Authentication timed out. Please try again.');
|
|
77
|
+
}
|
|
78
|
+
else if (error.message === 'Authentication expired') {
|
|
79
|
+
reporter.error('Authentication request expired. Please try again.');
|
|
80
|
+
}
|
|
81
|
+
else if (error.response?.data?.message) {
|
|
82
|
+
reporter.error(error.response.data.message);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
reporter.error('Login failed. Please try again.');
|
|
86
|
+
if (error.message) {
|
|
87
|
+
reporter.error(`Error: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function pollForToken(apiClient, requestCode, reporter) {
|
|
94
|
+
const startTime = Date.now();
|
|
95
|
+
let attempts = 0;
|
|
96
|
+
while (Date.now() - startTime < MAX_POLL_TIME) {
|
|
97
|
+
try {
|
|
98
|
+
const result = await apiClient.pollAuth(requestCode);
|
|
99
|
+
if (result.status === 'completed' && result.token) {
|
|
100
|
+
return result.token;
|
|
101
|
+
}
|
|
102
|
+
if (result.status === 'expired') {
|
|
103
|
+
throw new Error('Authentication expired');
|
|
104
|
+
}
|
|
105
|
+
attempts++;
|
|
106
|
+
if (attempts % 5 === 0) {
|
|
107
|
+
reporter.info('Still waiting for authentication...');
|
|
108
|
+
}
|
|
109
|
+
await sleep(POLL_INTERVAL);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error.response?.status === 410) {
|
|
113
|
+
throw new Error('Authentication expired');
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
throw new Error('Authentication timeout');
|
|
119
|
+
}
|
|
120
|
+
function sleep(ms) {
|
|
121
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
122
|
+
}
|
|
123
|
+
function promptForToken() {
|
|
124
|
+
const rl = readline_1.default.createInterface({
|
|
125
|
+
input: process.stdin,
|
|
126
|
+
output: process.stdout,
|
|
127
|
+
});
|
|
128
|
+
return new Promise((resolve) => {
|
|
129
|
+
rl.question('Paste your token: ', (answer) => {
|
|
130
|
+
rl.close();
|
|
131
|
+
resolve(answer.trim());
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"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AAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,EAAE,GAAG,kBAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE;YAC3C,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAIA,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBnD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logoutCommand = logoutCommand;
|
|
4
|
+
const config_1 = require("../lib/config");
|
|
5
|
+
const api_client_1 = require("../lib/api-client");
|
|
6
|
+
const reporter_1 = require("../lib/reporter");
|
|
7
|
+
async function logoutCommand() {
|
|
8
|
+
const config = new config_1.ConfigManager();
|
|
9
|
+
const reporter = new reporter_1.Reporter(config);
|
|
10
|
+
const apiClient = new api_client_1.APIClient(config);
|
|
11
|
+
if (!config.isAuthenticated()) {
|
|
12
|
+
reporter.warning('Not logged in');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const email = config.get().email;
|
|
16
|
+
try {
|
|
17
|
+
await apiClient.revokeToken();
|
|
18
|
+
reporter.info('Token revoked on server');
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
reporter.warning('Could not revoke token on server (continuing with local logout)');
|
|
22
|
+
}
|
|
23
|
+
config.clearAuth();
|
|
24
|
+
reporter.success(`Logged out ${email || ''}`);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;AAIA,sCAsBC;AA1BD,0CAA8C;AAC9C,kDAA8C;AAC9C,8CAA2C;AAEpC,KAAK,UAAU,aAAa;IACjC,MAAM,MAAM,GAAG,IAAI,sBAAa,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,MAAM,CAAC,CAAC;IAExC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC;QAC9B,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAClC,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;IAEjC,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC;QAC9B,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,OAAO,CAAC,iEAAiE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,CAAC,SAAS,EAAE,CAAC;IAEnB,QAAQ,CAAC,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ScanOptions {
|
|
2
|
+
dir?: string;
|
|
3
|
+
file?: string;
|
|
4
|
+
ai?: boolean;
|
|
5
|
+
noAi?: boolean;
|
|
6
|
+
dependencies?: boolean;
|
|
7
|
+
noDependencies?: boolean;
|
|
8
|
+
secrets?: boolean;
|
|
9
|
+
noSecrets?: boolean;
|
|
10
|
+
json?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function scanCommand(options: ScanOptions): Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAMA,UAAU,WAAW;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmFrE"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanCommand = scanCommand;
|
|
4
|
+
const config_1 = require("../lib/config");
|
|
5
|
+
const api_client_1 = require("../lib/api-client");
|
|
6
|
+
const reporter_1 = require("../lib/reporter");
|
|
7
|
+
const file_scanner_1 = require("../lib/file-scanner");
|
|
8
|
+
const repo_detector_1 = require("../lib/repo-detector");
|
|
9
|
+
async function scanCommand(options) {
|
|
10
|
+
const config = new config_1.ConfigManager();
|
|
11
|
+
const reporter = new reporter_1.Reporter(config);
|
|
12
|
+
const apiClient = new api_client_1.APIClient(config);
|
|
13
|
+
if (!config.isAuthenticated()) {
|
|
14
|
+
reporter.error('Not authenticated');
|
|
15
|
+
reporter.info('Run "gitguard login" to authenticate');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
reporter.info('Collecting files...');
|
|
20
|
+
const fileScanner = new file_scanner_1.FileScanner();
|
|
21
|
+
const scanDir = options.file ? process.cwd() : (options.dir || process.cwd());
|
|
22
|
+
let files;
|
|
23
|
+
if (options.file) {
|
|
24
|
+
files = await fileScanner.scanSingleFile(options.file);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
files = await fileScanner.collectFiles(scanDir);
|
|
28
|
+
}
|
|
29
|
+
const fileCount = Object.keys(files).length;
|
|
30
|
+
if (fileCount === 0) {
|
|
31
|
+
reporter.warning('No code files found to scan');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// Detect repository name from .git/config or package.json
|
|
35
|
+
const repository = repo_detector_1.RepoDetector.detectRepositoryName(scanDir);
|
|
36
|
+
reporter.info(`Found ${fileCount} file(s), sending to GitGuard...`);
|
|
37
|
+
const preferences = config.getPreferences();
|
|
38
|
+
const subscription = config.getSubscription() || 'free';
|
|
39
|
+
const includeAI = options.noAi ? false : (options.ai || preferences.aiScanEnabled);
|
|
40
|
+
const includeDependencies = options.noDependencies ? false : (options.dependencies || preferences.dependencyScanEnabled);
|
|
41
|
+
const includeSecrets = options.noSecrets ? false : (options.secrets || preferences.secretScanEnabled);
|
|
42
|
+
const result = await apiClient.scan({
|
|
43
|
+
files,
|
|
44
|
+
repository,
|
|
45
|
+
options: {
|
|
46
|
+
includeAI,
|
|
47
|
+
includeDependencies,
|
|
48
|
+
includeSecrets,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
if (options.json) {
|
|
52
|
+
console.log(JSON.stringify(result, null, 2));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
reporter.reportScan(result);
|
|
56
|
+
}
|
|
57
|
+
const hasCriticalOrHigh = result.summary.critical > 0 || result.summary.high > 0;
|
|
58
|
+
if (hasCriticalOrHigh) {
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error.response?.status === 401) {
|
|
64
|
+
reporter.error('Authentication expired. Please login again.');
|
|
65
|
+
config.clearAuth();
|
|
66
|
+
}
|
|
67
|
+
else if (error.response?.status === 429) {
|
|
68
|
+
reporter.error('Rate limit exceeded');
|
|
69
|
+
if (error.response.data?.message) {
|
|
70
|
+
reporter.info(error.response.data.message);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (error.response?.data?.message) {
|
|
74
|
+
reporter.error(error.response.data.message);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
reporter.error('Scan failed. Please try again.');
|
|
78
|
+
if (error.message) {
|
|
79
|
+
console.error(error.message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":";;AAkBA,kCAmFC;AArGD,0CAA8C;AAC9C,kDAA8C;AAC9C,8CAA2C;AAC3C,sDAAkD;AAClD,wDAAoD;AAc7C,KAAK,UAAU,WAAW,CAAC,OAAoB;IACpD,MAAM,MAAM,GAAG,IAAI,sBAAa,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,MAAM,CAAC,CAAC;IAExC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC;QAC9B,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACpC,QAAQ,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACtD,OAAO,CAA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