log-llm-config-staging 1.3.99 → 1.4.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, statSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { readJSONFile, readMCPConfig, readMarkdownFile, readInstalledExtensions } from '../readers/file_readers.js';
|
|
4
4
|
import { getExtensionsCachePath, getExtensionsCacheInstalledSuffix, getVscdbPath } from '../paths/path_constants_helpers.js';
|
|
@@ -125,6 +125,13 @@ function collectRegularFileEntry(t, enrichByFileType) {
|
|
|
125
125
|
function collectMetadataEntry(t) {
|
|
126
126
|
try {
|
|
127
127
|
const stats = statSync(t.path);
|
|
128
|
+
if (stats.isDirectory?.()) {
|
|
129
|
+
try {
|
|
130
|
+
if (readdirSync(t.path).length === 0)
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
catch { /* unreadable — assume non-empty, allow */ }
|
|
134
|
+
}
|
|
128
135
|
return { file_type: t.file_type, file_path: t.logicalFilePath ?? t.path, raw_content: { filename: t.path, last_modified: stats.mtime.toISOString(), source: 'file_metadata' }, collect_style: 'metadata' };
|
|
129
136
|
}
|
|
130
137
|
catch (err) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Path templates are fetched from the backend (GET api/file-path-registry/sensitive-paths-audit-candidates/).
|
|
7
7
|
* The audit is sent with the rest of the config files in log_config_files (same auth, same batch).
|
|
8
8
|
*/
|
|
9
|
-
import { existsSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
9
|
+
import { existsSync, writeFileSync, mkdirSync, statSync } from 'node:fs';
|
|
10
10
|
import { join } from 'node:path';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { getSensitivePathsAuditCandidates } from './endpoint_client/index.js';
|
|
@@ -22,16 +22,35 @@ function expandPath(template, cwd) {
|
|
|
22
22
|
}
|
|
23
23
|
return join(cwd, template);
|
|
24
24
|
}
|
|
25
|
+
/** True when path exists: directories always qualify; files must be non-empty (size > 0). */
|
|
26
|
+
function shouldIncludeSensitivePath(resolved) {
|
|
27
|
+
if (!existsSync(resolved)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const st = statSync(resolved);
|
|
32
|
+
if (st.isDirectory()) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (st.isFile()) {
|
|
36
|
+
return st.size > 0;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
25
44
|
/**
|
|
26
45
|
* Write sensitive_paths_audit.txt under outputDir. pathTemplates from backend (~ = home).
|
|
27
|
-
* Lists one path per line for paths that exist. No file contents are read.
|
|
46
|
+
* Lists one path per line for paths that exist (files must be non-empty). No file contents are read.
|
|
28
47
|
* Overwrites the file on each run (same as hook_log.txt); does not append.
|
|
29
48
|
*/
|
|
30
49
|
export function writeSensitivePathsAudit(outputDir, pathTemplates, cwd = process.cwd()) {
|
|
31
50
|
const existing = [];
|
|
32
51
|
for (const template of pathTemplates) {
|
|
33
52
|
const resolved = expandPath(template, cwd);
|
|
34
|
-
if (
|
|
53
|
+
if (shouldIncludeSensitivePath(resolved)) {
|
|
35
54
|
existing.push(resolved);
|
|
36
55
|
}
|
|
37
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "log-llm-config-staging",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^24.10.1",
|
|
52
|
-
"@vitest/coverage-v8": "^
|
|
53
|
-
"@vitest/ui": "^
|
|
52
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
53
|
+
"@vitest/ui": "^4.1.8",
|
|
54
54
|
"ts-node": "^10.9.2",
|
|
55
55
|
"typescript": "^5.4.5",
|
|
56
|
-
"vitest": "^
|
|
56
|
+
"vitest": "^4.1.8"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"axios": "^1.15.2",
|