preflyt 1.0.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/bin/cli.js +86 -0
- package/package.json +12 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
|
|
6
|
+
// Simple patterns for common API keys
|
|
7
|
+
const API_KEY_PATTERNS = [
|
|
8
|
+
{ name: 'OpenAI', pattern: /sk-[a-zA-Z0-9-_]{20,}/ },
|
|
9
|
+
{ name: 'Stripe Secret', pattern: /sk_live_[a-zA-Z0-9]{20,}/ },
|
|
10
|
+
{ name: 'Stripe Test', pattern: /sk_test_[a-zA-Z0-9]{20,}/ },
|
|
11
|
+
{ name: 'AWS Access Key', pattern: /AKIA[0-9A-Z]{16}/ },
|
|
12
|
+
{ name: 'GitHub Token', pattern: /ghp_[a-zA-Z0-9]{36}/ },
|
|
13
|
+
{ name: 'Hugging Face', pattern: /hf_[a-zA-Z0-9]{20,}/ },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
// File extensions to scan
|
|
17
|
+
const SCAN_EXTENSIONS = ['.js', '.ts', '.jsx', '.tsx', '.py', '.env', '.json']
|
|
18
|
+
|
|
19
|
+
// Folders to skip
|
|
20
|
+
const SKIP_FOLDERS = ['node_modules', '.git', '.next', 'dist', 'build']
|
|
21
|
+
|
|
22
|
+
// Store found issues
|
|
23
|
+
const issues = []
|
|
24
|
+
|
|
25
|
+
// Scan a single file
|
|
26
|
+
function scanFile(filePath) {
|
|
27
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
28
|
+
const lines = content.split('\n')
|
|
29
|
+
|
|
30
|
+
lines.forEach((line, index) => {
|
|
31
|
+
API_KEY_PATTERNS.forEach(({ name, pattern }) => {
|
|
32
|
+
if (pattern.test(line)) {
|
|
33
|
+
issues.push({
|
|
34
|
+
file: filePath,
|
|
35
|
+
line: index + 1,
|
|
36
|
+
type: name,
|
|
37
|
+
content: line.trim().substring(0, 80) + (line.length > 80 ? '...' : '')
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Recursively scan directory
|
|
45
|
+
function scanDirectory(dir) {
|
|
46
|
+
const items = fs.readdirSync(dir)
|
|
47
|
+
|
|
48
|
+
items.forEach(item => {
|
|
49
|
+
const fullPath = path.join(dir, item)
|
|
50
|
+
const stat = fs.statSync(fullPath)
|
|
51
|
+
|
|
52
|
+
if (stat.isDirectory()) {
|
|
53
|
+
if (!SKIP_FOLDERS.includes(item)) {
|
|
54
|
+
scanDirectory(fullPath)
|
|
55
|
+
}
|
|
56
|
+
} else if (stat.isFile()) {
|
|
57
|
+
const ext = path.extname(item)
|
|
58
|
+
if (SCAN_EXTENSIONS.includes(ext)) {
|
|
59
|
+
scanFile(fullPath)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Main
|
|
66
|
+
console.log('\n✈️ Preflyt - Preflight security check...\n')
|
|
67
|
+
|
|
68
|
+
const targetDir = process.argv[2] || '.'
|
|
69
|
+
scanDirectory(targetDir)
|
|
70
|
+
|
|
71
|
+
if (issues.length === 0) {
|
|
72
|
+
console.log('✅ All clear! Ready for takeoff.\n')
|
|
73
|
+
} else {
|
|
74
|
+
console.log(`⚠️ Found ${issues.length} issue(s) to fix before shipping:\n`)
|
|
75
|
+
|
|
76
|
+
issues.forEach(issue => {
|
|
77
|
+
console.log(` 📁 ${issue.file}:${issue.line}`)
|
|
78
|
+
console.log(` Type: ${issue.type}`)
|
|
79
|
+
console.log(` Code: ${issue.content}`)
|
|
80
|
+
console.log()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
console.log('💡 Tip: Move secrets to environment variables!\n')
|
|
84
|
+
process.exit(1) // Exit with error code
|
|
85
|
+
}
|
|
86
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "preflyt",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Preflight security checks for flow coders",
|
|
5
|
+
"bin": {
|
|
6
|
+
"preflyt": "./bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"keywords": ["security", "api-keys", "scanner", "flow-coding", "preflight"],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "MIT"
|
|
11
|
+
}
|
|
12
|
+
|