@agenticcli/shipguard 0.2.0 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,91 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor's trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms or the URL for them above, along with the above
47
+ copyright notice.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not imply any licenses other than those expressly granted in
52
+ these terms.
53
+
54
+ ## Termination
55
+
56
+ If you use the software in violation of these terms, such use is not licensed,
57
+ and your licenses will automatically terminate. If the licensor provides you
58
+ with a notice of your violation, and you cease all violation of this license no
59
+ later than 30 days after you receive that notice, your licenses will be
60
+ reinstated retroactively. However, if you violate these terms after such
61
+ reinstatement, any additional violation of these terms will cause your licenses
62
+ to terminate automatically and permanently.
63
+
64
+ ## No Liability
65
+
66
+ *As far as the law allows, the software comes as is, without any warranty or
67
+ condition, and the licensor will not be liable to you for any damages arising
68
+ out of these terms or the use or nature of the software, under any kind of
69
+ legal claim.*
70
+
71
+ ## Definitions
72
+
73
+ The **licensor** is the entity offering these terms, and the **software** is the
74
+ software the licensor makes available under these terms, including any portion
75
+ of it.
76
+
77
+ **you** refers to the individual or entity agreeing to these terms.
78
+
79
+ **your company** is any legal entity, sole proprietorship, or other kind of
80
+ organization that you work for, plus all organizations that have control over,
81
+ are under the control of, or are under common control with that organization.
82
+ **control** means ownership of substantially all the assets of an entity, or the
83
+ power to direct its management and policies by vote, contract, or otherwise.
84
+ Control can be direct or indirect.
85
+
86
+ **your licenses** are all the licenses granted to you for the software under
87
+ these terms.
88
+
89
+ **use** means anything you do with the software requiring one of your licenses.
90
+
91
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -51,6 +51,10 @@ Details: [agenticcli.dev/docs#telemetry](https://agenticcli.dev/docs#telemetry)
51
51
 
52
52
  See [full docs](https://agenticcli.dev/docs) for policy configuration, CI setup, and agent integration.
53
53
 
54
+ ## Testing notes
55
+
56
+ Cross-impl crypto-compatibility test (CLI↔backend) lives in the private backend repo post-split; CLI repo verifies against signed-bundle fixtures. Drift risk low (stable Ed25519 scheme).
57
+
54
58
  ## License
55
59
 
56
60
  MIT
@@ -0,0 +1,7 @@
1
+ {
2
+ "secrets": "f7b1c7492d365c3bfa580a19ba721e8ef87eac0385b45284af2764a6d679df7e",
3
+ "auth": "f7b1c7492d365c3bfa580a19ba721e8ef87eac0385b45284af2764a6d679df7e",
4
+ "database": "f7b1c7492d365c3bfa580a19ba721e8ef87eac0385b45284af2764a6d679df7e",
5
+ "deployment": "f7b1c7492d365c3bfa580a19ba721e8ef87eac0385b45284af2764a6d679df7e",
6
+ "payments": "f7b1c7492d365c3bfa580a19ba721e8ef87eac0385b45284af2764a6d679df7e"
7
+ }
@@ -1,3 +1,10 @@
1
+ import {
2
+ decodeUtf8Strict,
3
+ detectBinary,
4
+ normalizeNewlines,
5
+ stripBom
6
+ } from "./chunk-ANTCYKRO.js";
7
+
1
8
  // src/utils/fs.ts
2
9
  import fg from "fast-glob";
3
10
  import { readFile, stat } from "fs/promises";
@@ -5,7 +12,6 @@ import { join } from "path";
5
12
  var DEFAULT_MAX_FILE_SIZE_BYTES = 512 * 1024;
6
13
  var DEFAULT_MAX_TOTAL_BYTES = 256 * 1024 * 1024;
7
14
  var DEFAULT_MAX_FILES = 5e3;
8
- var BINARY_CHECK_BYTES = 8192;
9
15
  var DEFAULT_IGNORE = [
10
16
  "node_modules/**",
11
17
  "dist/**",
@@ -46,6 +52,7 @@ var DEFAULT_IGNORE = [
46
52
  // ShipGuard's own report output — never scan the tool's own artifacts
47
53
  ".shipguard/**"
48
54
  ];
55
+ var MAX_SKIPPED_NAMES = 50;
49
56
  async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], options = {}) {
50
57
  const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
51
58
  const maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
@@ -57,15 +64,26 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
57
64
  ignore: allIgnore,
58
65
  dot: true,
59
66
  absolute: false,
60
- onlyFiles: true
67
+ onlyFiles: true,
68
+ // Privacy moat (incident 3063d8a9): NEVER follow symlinks. A symlink inside
69
+ // the project pointing out of the root (e.g. `ln -s /home escape`) would
70
+ // otherwise cause the scan to descend out-of-tree, reading and reporting
71
+ // files the user never intended to scan (and risking a hang on huge external
72
+ // trees). The user's code must never leave their machine; out-of-tree files
73
+ // must never enter the scan. fast-glob defaults this to true, so it is
74
+ // load-bearing that we set it false explicitly.
75
+ followSymbolicLinks: false
61
76
  });
62
77
  const total = filePaths.length;
63
78
  const files = [];
64
79
  let skippedTooLarge = 0;
80
+ const skippedTooLargeFiles = [];
65
81
  let skippedBinary = 0;
66
82
  let truncated = false;
67
83
  let totalBytes = 0;
68
84
  let processed = 0;
85
+ const invalidUtf8Files = [];
86
+ const unreadableFiles = [];
69
87
  for (const fp of filePaths) {
70
88
  if (files.length >= maxFiles || totalBytes >= maxTotalBytes) {
71
89
  truncated = true;
@@ -76,35 +94,47 @@ async function readFiles(rootDir, patterns = ["**/*"], ignorePatterns = [], opti
76
94
  const fileStat = await stat(fullPath);
77
95
  if (fileStat.size > maxFileSizeBytes) {
78
96
  skippedTooLarge++;
97
+ if (skippedTooLargeFiles.length < MAX_SKIPPED_NAMES) {
98
+ skippedTooLargeFiles.push(fp);
99
+ }
79
100
  onProgress?.(++processed, total, fp);
80
101
  continue;
81
102
  }
82
103
  const buffer = await readFile(fullPath);
83
- const checkLen = Math.min(buffer.length, BINARY_CHECK_BYTES);
84
- let isBinary = false;
85
- for (let i = 0; i < checkLen; i++) {
86
- if (buffer[i] === 0) {
87
- isBinary = true;
88
- break;
89
- }
90
- }
91
- if (isBinary) {
104
+ if (detectBinary(new Uint8Array(buffer))) {
92
105
  skippedBinary++;
93
106
  onProgress?.(++processed, total, fp);
94
107
  continue;
95
108
  }
96
- const content = buffer.toString("utf-8");
109
+ const decoded = decodeUtf8Strict(new Uint8Array(buffer));
110
+ if (!decoded.ok) {
111
+ invalidUtf8Files.push({ relativePath: fp, reason: decoded.reason });
112
+ onProgress?.(++processed, total, fp);
113
+ continue;
114
+ }
115
+ const content = normalizeNewlines(stripBom(decoded.text));
97
116
  totalBytes += buffer.length;
98
117
  files.push({
99
118
  path: fullPath,
100
119
  content,
101
120
  relativePath: fp
102
121
  });
103
- } catch {
122
+ } catch (err) {
123
+ const detail = err instanceof Error ? err.message : String(err);
124
+ console.warn(`[shipguard] Could not read file ${fp}: ${detail}`);
125
+ unreadableFiles.push(fp);
104
126
  }
105
127
  onProgress?.(++processed, total, fp);
106
128
  }
107
- return { files, skippedTooLarge, skippedBinary, truncated };
129
+ return {
130
+ files,
131
+ skippedTooLarge,
132
+ skippedTooLargeFiles,
133
+ skippedBinary,
134
+ truncated,
135
+ invalidUtf8Files,
136
+ unreadableFiles
137
+ };
108
138
  }
109
139
 
110
140
  export {