deltarq-scan 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/README.md +210 -0
- package/bin/deltarq-scan.js +198 -0
- package/logo.png +0 -0
- package/package.json +50 -0
- package/src/engine/aggregator.js +96 -0
- package/src/engine/anonymizer.js +79 -0
- package/src/output/terminal.js +218 -0
- package/src/output/uploader.js +122 -0
- package/src/rules/data.js +24 -0
- package/src/rules/git.js +14 -0
- package/src/rules/identity.js +34 -0
- package/src/rules/index.js +53 -0
- package/src/rules/infrastructure.js +44 -0
- package/src/rules/logging.js +14 -0
- package/src/scanner/awsScanner.js +138 -0
- package/src/scanner/dbScanner.js +67 -0
- package/src/scanner/fileScanner.js +422 -0
- package/src/scanner/gitScanner.js +115 -0
- package/src/utils/detect.js +90 -0
- package/src/utils/fileUtils.js +88 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Safely read a file, returning null if it doesn't exist or errors
|
|
7
|
+
*/
|
|
8
|
+
export function readFileSafe(filePath) {
|
|
9
|
+
try {
|
|
10
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Check if a file exists
|
|
18
|
+
*/
|
|
19
|
+
export function fileExists(filePath) {
|
|
20
|
+
try {
|
|
21
|
+
return fs.existsSync(filePath);
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Find files matching glob patterns in a directory
|
|
29
|
+
* @param {string} baseDir - Directory to search in
|
|
30
|
+
* @param {string[]} patterns - Glob patterns to match
|
|
31
|
+
* @returns {Promise<string[]>} Array of matched file paths
|
|
32
|
+
*/
|
|
33
|
+
export async function findFiles(baseDir, patterns) {
|
|
34
|
+
const results = [];
|
|
35
|
+
for (const pattern of patterns) {
|
|
36
|
+
const matches = await glob(pattern, {
|
|
37
|
+
cwd: baseDir,
|
|
38
|
+
absolute: true,
|
|
39
|
+
nodir: true,
|
|
40
|
+
dot: true,
|
|
41
|
+
ignore: ['**/node_modules/**', '**/.git/**', '**/dist/**', '**/build/**', '**/.next/**', '**/.vercel/**', '**/coverage/**', '**/.out/**'],
|
|
42
|
+
});
|
|
43
|
+
results.push(...matches);
|
|
44
|
+
}
|
|
45
|
+
return [...new Set(results)];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse a .env file content into key-value pairs
|
|
50
|
+
* @param {string} content - Raw .env file content
|
|
51
|
+
* @returns {Object} Parsed key-value pairs
|
|
52
|
+
*/
|
|
53
|
+
export function parseEnvContent(content) {
|
|
54
|
+
const result = {};
|
|
55
|
+
if (!content) return result;
|
|
56
|
+
|
|
57
|
+
const lines = content.split('\n');
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
const trimmed = line.trim();
|
|
60
|
+
// Skip comments and empty lines
|
|
61
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
62
|
+
|
|
63
|
+
const eqIndex = trimmed.indexOf('=');
|
|
64
|
+
if (eqIndex === -1) continue;
|
|
65
|
+
|
|
66
|
+
const key = trimmed.substring(0, eqIndex).trim();
|
|
67
|
+
let value = trimmed.substring(eqIndex + 1).trim();
|
|
68
|
+
|
|
69
|
+
// Remove surrounding quotes
|
|
70
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
71
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
72
|
+
value = value.slice(1, -1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
result[key] = value;
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Resolve a target path, defaulting to CWD
|
|
82
|
+
*/
|
|
83
|
+
export function resolveTargetDir(targetArg) {
|
|
84
|
+
if (targetArg) {
|
|
85
|
+
return path.resolve(targetArg);
|
|
86
|
+
}
|
|
87
|
+
return process.cwd();
|
|
88
|
+
}
|