@agenticcli/shipguard 0.8.1 → 0.9.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 +12 -0
- package/dist/checksum-manifest.json +5 -5
- package/dist/{chunk-BGWAAJ5S.js → chunk-6XMYOF3N.js} +3 -38
- package/dist/chunk-E4Z2MZ5J.js +904 -0
- package/dist/chunk-NC5RELTG.js +40 -0
- package/dist/cli-facts.json +8 -5
- package/dist/cli.js +468 -456
- package/dist/{config-generator-4MK6PGY5.js → config-generator-S5KFHKGQ.js} +2 -1
- package/dist/{pro-scanner-ZKL6L5L6.js → pro-scanner-TPNDJ6L6.js} +2 -1
- package/docs/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/chunk-MVYY4QWT.js +0 -176
package/docs/llms.txt
CHANGED
|
@@ -12,7 +12,7 @@ shipguard scan — scan project for risks
|
|
|
12
12
|
shipguard scan --changed — scan only changed files
|
|
13
13
|
shipguard scan --strict — exit code 1 on high-risk findings
|
|
14
14
|
shipguard scan --report — generate Markdown report
|
|
15
|
-
shipguard scan --json — machine-readable output
|
|
15
|
+
shipguard scan --json — machine-readable output (schemaVersion 6; the `coverage` object says how many files were discovered, scanned and skipped, and why)
|
|
16
16
|
shipguard scan --check-regressions — exit code 1 if a previously-passing rule now fails
|
|
17
17
|
shipguard history — show recent local scan history for this repo (read-only)
|
|
18
18
|
|
package/package.json
CHANGED
package/dist/chunk-MVYY4QWT.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeUtf8Strict,
|
|
3
|
-
detectBinary,
|
|
4
|
-
normalizeNewlines,
|
|
5
|
-
stripBom
|
|
6
|
-
} from "./chunk-KGIK7XNK.js";
|
|
7
|
-
|
|
8
|
-
// src/utils/fs.ts
|
|
9
|
-
import fg from "fast-glob";
|
|
10
|
-
import { readFile, stat } from "fs/promises";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
var DEFAULT_MAX_FILE_SIZE_BYTES = 512 * 1024;
|
|
13
|
-
var DEFAULT_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
|
|
14
|
-
var DEFAULT_MAX_FILES = 5e3;
|
|
15
|
-
var DEFAULT_IGNORE = [
|
|
16
|
-
"node_modules/**",
|
|
17
|
-
"dist/**",
|
|
18
|
-
"build/**",
|
|
19
|
-
".next/**",
|
|
20
|
-
"coverage/**",
|
|
21
|
-
".git/**",
|
|
22
|
-
"*.lock",
|
|
23
|
-
"pnpm-lock.yaml",
|
|
24
|
-
"package-lock.json",
|
|
25
|
-
// Extended — large artifact directories
|
|
26
|
-
".cache/**",
|
|
27
|
-
".turbo/**",
|
|
28
|
-
".venv/**",
|
|
29
|
-
"venv/**",
|
|
30
|
-
"vendor/**",
|
|
31
|
-
"tmp/**",
|
|
32
|
-
"out/**",
|
|
33
|
-
// Large file extensions — binary and generated
|
|
34
|
-
"*.log",
|
|
35
|
-
"*.min.js",
|
|
36
|
-
"*.map",
|
|
37
|
-
"*.png",
|
|
38
|
-
"*.jpg",
|
|
39
|
-
"*.jpeg",
|
|
40
|
-
"*.gif",
|
|
41
|
-
"*.webp",
|
|
42
|
-
"*.ico",
|
|
43
|
-
"*.pdf",
|
|
44
|
-
"*.zip",
|
|
45
|
-
"*.gz",
|
|
46
|
-
"*.tar",
|
|
47
|
-
"*.mp4",
|
|
48
|
-
"*.mov",
|
|
49
|
-
"*.wasm",
|
|
50
|
-
"*.node",
|
|
51
|
-
".DS_Store",
|
|
52
|
-
// ShipGuard's own report output — never scan the tool's own artifacts
|
|
53
|
-
".shipguard/**"
|
|
54
|
-
];
|
|
55
|
-
var MAX_SKIPPED_NAMES = 50;
|
|
56
|
-
function compareScanPaths(a, b) {
|
|
57
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
58
|
-
}
|
|
59
|
-
async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], options = {}) {
|
|
60
|
-
const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
|
|
61
|
-
const maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
|
|
62
|
-
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
63
|
-
const { onProgress } = options;
|
|
64
|
-
const allIgnore = [...DEFAULT_IGNORE, ...ignorePatterns];
|
|
65
|
-
const filePaths = await fg(patterns, {
|
|
66
|
-
cwd: rootDir,
|
|
67
|
-
ignore: allIgnore,
|
|
68
|
-
dot: true,
|
|
69
|
-
absolute: false,
|
|
70
|
-
onlyFiles: true,
|
|
71
|
-
// Privacy moat: NEVER follow symlinks. A symlink inside
|
|
72
|
-
// the project pointing out of the root (e.g. `ln -s /home escape`) would
|
|
73
|
-
// otherwise cause the scan to descend out-of-tree, reading and reporting
|
|
74
|
-
// files the user never intended to scan (and risking a hang on huge external
|
|
75
|
-
// trees). The user's code must never leave their machine; out-of-tree files
|
|
76
|
-
// must never enter the scan. fast-glob defaults this to true, so it is
|
|
77
|
-
// load-bearing that we set it false explicitly.
|
|
78
|
-
followSymbolicLinks: false
|
|
79
|
-
});
|
|
80
|
-
filePaths.sort(compareScanPaths);
|
|
81
|
-
const symlinkProbeEntries = await fg(patterns, {
|
|
82
|
-
cwd: rootDir,
|
|
83
|
-
ignore: allIgnore,
|
|
84
|
-
dot: true,
|
|
85
|
-
absolute: false,
|
|
86
|
-
onlyFiles: false,
|
|
87
|
-
followSymbolicLinks: false,
|
|
88
|
-
objectMode: true
|
|
89
|
-
});
|
|
90
|
-
const allSkippedSymlinkPaths = symlinkProbeEntries.filter((entry) => entry.dirent.isSymbolicLink()).map((entry) => entry.path).sort(compareScanPaths);
|
|
91
|
-
const skippedSymlinks = allSkippedSymlinkPaths.length;
|
|
92
|
-
const skippedSymlinkFiles = allSkippedSymlinkPaths.slice(0, MAX_SKIPPED_NAMES);
|
|
93
|
-
if (skippedSymlinks > 0) {
|
|
94
|
-
const named = skippedSymlinkFiles.join(", ");
|
|
95
|
-
const more = skippedSymlinks > skippedSymlinkFiles.length ? " (and others)" : "";
|
|
96
|
-
console.warn(
|
|
97
|
-
`[shipguard] Scan INCOMPLETE: ${skippedSymlinks} symlink(s) not followed (privacy protection) and NOT scanned: ${named}${more}`
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
const total = filePaths.length;
|
|
101
|
-
const files = [];
|
|
102
|
-
let skippedTooLarge = 0;
|
|
103
|
-
const skippedTooLargeFiles = [];
|
|
104
|
-
let skippedBinary = 0;
|
|
105
|
-
const skippedBinaryFiles = [];
|
|
106
|
-
let truncated = false;
|
|
107
|
-
let totalBytes = 0;
|
|
108
|
-
let processed = 0;
|
|
109
|
-
const invalidUtf8Files = [];
|
|
110
|
-
const unreadableFiles = [];
|
|
111
|
-
for (const fp of filePaths) {
|
|
112
|
-
if (files.length >= maxFiles || totalBytes >= maxTotalBytes) {
|
|
113
|
-
truncated = true;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
const fullPath = join(rootDir, fp);
|
|
117
|
-
try {
|
|
118
|
-
const fileStat = await stat(fullPath);
|
|
119
|
-
if (fileStat.size > maxFileSizeBytes) {
|
|
120
|
-
skippedTooLarge++;
|
|
121
|
-
if (skippedTooLargeFiles.length < MAX_SKIPPED_NAMES) {
|
|
122
|
-
skippedTooLargeFiles.push(fp);
|
|
123
|
-
}
|
|
124
|
-
onProgress?.(++processed, total, fp);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const buffer = await readFile(fullPath);
|
|
128
|
-
if (detectBinary(new Uint8Array(buffer))) {
|
|
129
|
-
skippedBinary++;
|
|
130
|
-
if (skippedBinaryFiles.length < MAX_SKIPPED_NAMES) {
|
|
131
|
-
skippedBinaryFiles.push(fp);
|
|
132
|
-
}
|
|
133
|
-
onProgress?.(++processed, total, fp);
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
const decoded = decodeUtf8Strict(new Uint8Array(buffer));
|
|
137
|
-
if (!decoded.ok) {
|
|
138
|
-
invalidUtf8Files.push({ relativePath: fp, reason: decoded.reason });
|
|
139
|
-
onProgress?.(++processed, total, fp);
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
const content = normalizeNewlines(stripBom(decoded.text));
|
|
143
|
-
totalBytes += buffer.length;
|
|
144
|
-
files.push({
|
|
145
|
-
path: fullPath,
|
|
146
|
-
content,
|
|
147
|
-
relativePath: fp
|
|
148
|
-
});
|
|
149
|
-
} catch (err) {
|
|
150
|
-
const detail = err instanceof Error ? err.message : String(err);
|
|
151
|
-
console.warn(`[shipguard] Could not read file ${fp}: ${detail}`);
|
|
152
|
-
unreadableFiles.push(fp);
|
|
153
|
-
}
|
|
154
|
-
onProgress?.(++processed, total, fp);
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
files,
|
|
158
|
-
skippedTooLarge,
|
|
159
|
-
skippedTooLargeFiles,
|
|
160
|
-
skippedBinary,
|
|
161
|
-
skippedBinaryFiles,
|
|
162
|
-
skippedSymlinks,
|
|
163
|
-
skippedSymlinkFiles,
|
|
164
|
-
truncated,
|
|
165
|
-
invalidUtf8Files,
|
|
166
|
-
unreadableFiles
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export {
|
|
171
|
-
DEFAULT_MAX_FILE_SIZE_BYTES,
|
|
172
|
-
DEFAULT_MAX_TOTAL_BYTES,
|
|
173
|
-
DEFAULT_MAX_FILES,
|
|
174
|
-
compareScanPaths,
|
|
175
|
-
readFiles
|
|
176
|
-
};
|