@ship-safe/cli 1.1.0 → 1.1.3
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/dist/index.js +283 -230
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,8 @@ import { Command, InvalidArgumentError, Option } from "commander";
|
|
|
10
10
|
|
|
11
11
|
// src/commands/scan.ts
|
|
12
12
|
import { resolve as resolve2, join as join4 } from "path";
|
|
13
|
-
import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
|
|
13
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
14
|
+
import { homedir as homedir3 } from "os";
|
|
14
15
|
import chalk5 from "chalk";
|
|
15
16
|
import ora2 from "ora";
|
|
16
17
|
import { select } from "@inquirer/prompts";
|
|
@@ -675,41 +676,41 @@ var ZodType = class {
|
|
|
675
676
|
get description() {
|
|
676
677
|
return this._def.description;
|
|
677
678
|
}
|
|
678
|
-
_getType(
|
|
679
|
-
return getParsedType(
|
|
679
|
+
_getType(input2) {
|
|
680
|
+
return getParsedType(input2.data);
|
|
680
681
|
}
|
|
681
|
-
_getOrReturnCtx(
|
|
682
|
+
_getOrReturnCtx(input2, ctx) {
|
|
682
683
|
return ctx || {
|
|
683
|
-
common:
|
|
684
|
-
data:
|
|
685
|
-
parsedType: getParsedType(
|
|
684
|
+
common: input2.parent.common,
|
|
685
|
+
data: input2.data,
|
|
686
|
+
parsedType: getParsedType(input2.data),
|
|
686
687
|
schemaErrorMap: this._def.errorMap,
|
|
687
|
-
path:
|
|
688
|
-
parent:
|
|
688
|
+
path: input2.path,
|
|
689
|
+
parent: input2.parent
|
|
689
690
|
};
|
|
690
691
|
}
|
|
691
|
-
_processInputParams(
|
|
692
|
+
_processInputParams(input2) {
|
|
692
693
|
return {
|
|
693
694
|
status: new ParseStatus(),
|
|
694
695
|
ctx: {
|
|
695
|
-
common:
|
|
696
|
-
data:
|
|
697
|
-
parsedType: getParsedType(
|
|
696
|
+
common: input2.parent.common,
|
|
697
|
+
data: input2.data,
|
|
698
|
+
parsedType: getParsedType(input2.data),
|
|
698
699
|
schemaErrorMap: this._def.errorMap,
|
|
699
|
-
path:
|
|
700
|
-
parent:
|
|
700
|
+
path: input2.path,
|
|
701
|
+
parent: input2.parent
|
|
701
702
|
}
|
|
702
703
|
};
|
|
703
704
|
}
|
|
704
|
-
_parseSync(
|
|
705
|
-
const result = this._parse(
|
|
705
|
+
_parseSync(input2) {
|
|
706
|
+
const result = this._parse(input2);
|
|
706
707
|
if (isAsync(result)) {
|
|
707
708
|
throw new Error("Synchronous parse encountered promise.");
|
|
708
709
|
}
|
|
709
710
|
return result;
|
|
710
711
|
}
|
|
711
|
-
_parseAsync(
|
|
712
|
-
const result = this._parse(
|
|
712
|
+
_parseAsync(input2) {
|
|
713
|
+
const result = this._parse(input2);
|
|
713
714
|
return Promise.resolve(result);
|
|
714
715
|
}
|
|
715
716
|
parse(data, params) {
|
|
@@ -1035,13 +1036,13 @@ function isValidCidr(ip, version) {
|
|
|
1035
1036
|
return false;
|
|
1036
1037
|
}
|
|
1037
1038
|
var ZodString = class _ZodString extends ZodType {
|
|
1038
|
-
_parse(
|
|
1039
|
+
_parse(input2) {
|
|
1039
1040
|
if (this._def.coerce) {
|
|
1040
|
-
|
|
1041
|
+
input2.data = String(input2.data);
|
|
1041
1042
|
}
|
|
1042
|
-
const parsedType = this._getType(
|
|
1043
|
+
const parsedType = this._getType(input2);
|
|
1043
1044
|
if (parsedType !== ZodParsedType.string) {
|
|
1044
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1045
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1045
1046
|
addIssueToContext(ctx2, {
|
|
1046
1047
|
code: ZodIssueCode.invalid_type,
|
|
1047
1048
|
expected: ZodParsedType.string,
|
|
@@ -1053,8 +1054,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1053
1054
|
let ctx = void 0;
|
|
1054
1055
|
for (const check of this._def.checks) {
|
|
1055
1056
|
if (check.kind === "min") {
|
|
1056
|
-
if (
|
|
1057
|
-
ctx = this._getOrReturnCtx(
|
|
1057
|
+
if (input2.data.length < check.value) {
|
|
1058
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1058
1059
|
addIssueToContext(ctx, {
|
|
1059
1060
|
code: ZodIssueCode.too_small,
|
|
1060
1061
|
minimum: check.value,
|
|
@@ -1066,8 +1067,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1066
1067
|
status.dirty();
|
|
1067
1068
|
}
|
|
1068
1069
|
} else if (check.kind === "max") {
|
|
1069
|
-
if (
|
|
1070
|
-
ctx = this._getOrReturnCtx(
|
|
1070
|
+
if (input2.data.length > check.value) {
|
|
1071
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1071
1072
|
addIssueToContext(ctx, {
|
|
1072
1073
|
code: ZodIssueCode.too_big,
|
|
1073
1074
|
maximum: check.value,
|
|
@@ -1079,10 +1080,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1079
1080
|
status.dirty();
|
|
1080
1081
|
}
|
|
1081
1082
|
} else if (check.kind === "length") {
|
|
1082
|
-
const tooBig =
|
|
1083
|
-
const tooSmall =
|
|
1083
|
+
const tooBig = input2.data.length > check.value;
|
|
1084
|
+
const tooSmall = input2.data.length < check.value;
|
|
1084
1085
|
if (tooBig || tooSmall) {
|
|
1085
|
-
ctx = this._getOrReturnCtx(
|
|
1086
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1086
1087
|
if (tooBig) {
|
|
1087
1088
|
addIssueToContext(ctx, {
|
|
1088
1089
|
code: ZodIssueCode.too_big,
|
|
@@ -1105,8 +1106,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1105
1106
|
status.dirty();
|
|
1106
1107
|
}
|
|
1107
1108
|
} else if (check.kind === "email") {
|
|
1108
|
-
if (!emailRegex.test(
|
|
1109
|
-
ctx = this._getOrReturnCtx(
|
|
1109
|
+
if (!emailRegex.test(input2.data)) {
|
|
1110
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1110
1111
|
addIssueToContext(ctx, {
|
|
1111
1112
|
validation: "email",
|
|
1112
1113
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1118,8 +1119,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1118
1119
|
if (!emojiRegex) {
|
|
1119
1120
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1120
1121
|
}
|
|
1121
|
-
if (!emojiRegex.test(
|
|
1122
|
-
ctx = this._getOrReturnCtx(
|
|
1122
|
+
if (!emojiRegex.test(input2.data)) {
|
|
1123
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1123
1124
|
addIssueToContext(ctx, {
|
|
1124
1125
|
validation: "emoji",
|
|
1125
1126
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1128,8 +1129,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1128
1129
|
status.dirty();
|
|
1129
1130
|
}
|
|
1130
1131
|
} else if (check.kind === "uuid") {
|
|
1131
|
-
if (!uuidRegex.test(
|
|
1132
|
-
ctx = this._getOrReturnCtx(
|
|
1132
|
+
if (!uuidRegex.test(input2.data)) {
|
|
1133
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1133
1134
|
addIssueToContext(ctx, {
|
|
1134
1135
|
validation: "uuid",
|
|
1135
1136
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1138,8 +1139,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1138
1139
|
status.dirty();
|
|
1139
1140
|
}
|
|
1140
1141
|
} else if (check.kind === "nanoid") {
|
|
1141
|
-
if (!nanoidRegex.test(
|
|
1142
|
-
ctx = this._getOrReturnCtx(
|
|
1142
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
1143
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1143
1144
|
addIssueToContext(ctx, {
|
|
1144
1145
|
validation: "nanoid",
|
|
1145
1146
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1148,8 +1149,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1148
1149
|
status.dirty();
|
|
1149
1150
|
}
|
|
1150
1151
|
} else if (check.kind === "cuid") {
|
|
1151
|
-
if (!cuidRegex.test(
|
|
1152
|
-
ctx = this._getOrReturnCtx(
|
|
1152
|
+
if (!cuidRegex.test(input2.data)) {
|
|
1153
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1153
1154
|
addIssueToContext(ctx, {
|
|
1154
1155
|
validation: "cuid",
|
|
1155
1156
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1158,8 +1159,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1158
1159
|
status.dirty();
|
|
1159
1160
|
}
|
|
1160
1161
|
} else if (check.kind === "cuid2") {
|
|
1161
|
-
if (!cuid2Regex.test(
|
|
1162
|
-
ctx = this._getOrReturnCtx(
|
|
1162
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
1163
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1163
1164
|
addIssueToContext(ctx, {
|
|
1164
1165
|
validation: "cuid2",
|
|
1165
1166
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1168,8 +1169,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1168
1169
|
status.dirty();
|
|
1169
1170
|
}
|
|
1170
1171
|
} else if (check.kind === "ulid") {
|
|
1171
|
-
if (!ulidRegex.test(
|
|
1172
|
-
ctx = this._getOrReturnCtx(
|
|
1172
|
+
if (!ulidRegex.test(input2.data)) {
|
|
1173
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1173
1174
|
addIssueToContext(ctx, {
|
|
1174
1175
|
validation: "ulid",
|
|
1175
1176
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1179,9 +1180,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1179
1180
|
}
|
|
1180
1181
|
} else if (check.kind === "url") {
|
|
1181
1182
|
try {
|
|
1182
|
-
new URL(
|
|
1183
|
+
new URL(input2.data);
|
|
1183
1184
|
} catch {
|
|
1184
|
-
ctx = this._getOrReturnCtx(
|
|
1185
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1185
1186
|
addIssueToContext(ctx, {
|
|
1186
1187
|
validation: "url",
|
|
1187
1188
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1191,9 +1192,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1191
1192
|
}
|
|
1192
1193
|
} else if (check.kind === "regex") {
|
|
1193
1194
|
check.regex.lastIndex = 0;
|
|
1194
|
-
const testResult = check.regex.test(
|
|
1195
|
+
const testResult = check.regex.test(input2.data);
|
|
1195
1196
|
if (!testResult) {
|
|
1196
|
-
ctx = this._getOrReturnCtx(
|
|
1197
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1197
1198
|
addIssueToContext(ctx, {
|
|
1198
1199
|
validation: "regex",
|
|
1199
1200
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1202,10 +1203,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1202
1203
|
status.dirty();
|
|
1203
1204
|
}
|
|
1204
1205
|
} else if (check.kind === "trim") {
|
|
1205
|
-
|
|
1206
|
+
input2.data = input2.data.trim();
|
|
1206
1207
|
} else if (check.kind === "includes") {
|
|
1207
|
-
if (!
|
|
1208
|
-
ctx = this._getOrReturnCtx(
|
|
1208
|
+
if (!input2.data.includes(check.value, check.position)) {
|
|
1209
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1209
1210
|
addIssueToContext(ctx, {
|
|
1210
1211
|
code: ZodIssueCode.invalid_string,
|
|
1211
1212
|
validation: { includes: check.value, position: check.position },
|
|
@@ -1214,12 +1215,12 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1214
1215
|
status.dirty();
|
|
1215
1216
|
}
|
|
1216
1217
|
} else if (check.kind === "toLowerCase") {
|
|
1217
|
-
|
|
1218
|
+
input2.data = input2.data.toLowerCase();
|
|
1218
1219
|
} else if (check.kind === "toUpperCase") {
|
|
1219
|
-
|
|
1220
|
+
input2.data = input2.data.toUpperCase();
|
|
1220
1221
|
} else if (check.kind === "startsWith") {
|
|
1221
|
-
if (!
|
|
1222
|
-
ctx = this._getOrReturnCtx(
|
|
1222
|
+
if (!input2.data.startsWith(check.value)) {
|
|
1223
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1223
1224
|
addIssueToContext(ctx, {
|
|
1224
1225
|
code: ZodIssueCode.invalid_string,
|
|
1225
1226
|
validation: { startsWith: check.value },
|
|
@@ -1228,8 +1229,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1228
1229
|
status.dirty();
|
|
1229
1230
|
}
|
|
1230
1231
|
} else if (check.kind === "endsWith") {
|
|
1231
|
-
if (!
|
|
1232
|
-
ctx = this._getOrReturnCtx(
|
|
1232
|
+
if (!input2.data.endsWith(check.value)) {
|
|
1233
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1233
1234
|
addIssueToContext(ctx, {
|
|
1234
1235
|
code: ZodIssueCode.invalid_string,
|
|
1235
1236
|
validation: { endsWith: check.value },
|
|
@@ -1239,8 +1240,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1239
1240
|
}
|
|
1240
1241
|
} else if (check.kind === "datetime") {
|
|
1241
1242
|
const regex = datetimeRegex(check);
|
|
1242
|
-
if (!regex.test(
|
|
1243
|
-
ctx = this._getOrReturnCtx(
|
|
1243
|
+
if (!regex.test(input2.data)) {
|
|
1244
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1244
1245
|
addIssueToContext(ctx, {
|
|
1245
1246
|
code: ZodIssueCode.invalid_string,
|
|
1246
1247
|
validation: "datetime",
|
|
@@ -1250,8 +1251,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1250
1251
|
}
|
|
1251
1252
|
} else if (check.kind === "date") {
|
|
1252
1253
|
const regex = dateRegex;
|
|
1253
|
-
if (!regex.test(
|
|
1254
|
-
ctx = this._getOrReturnCtx(
|
|
1254
|
+
if (!regex.test(input2.data)) {
|
|
1255
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1255
1256
|
addIssueToContext(ctx, {
|
|
1256
1257
|
code: ZodIssueCode.invalid_string,
|
|
1257
1258
|
validation: "date",
|
|
@@ -1261,8 +1262,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1261
1262
|
}
|
|
1262
1263
|
} else if (check.kind === "time") {
|
|
1263
1264
|
const regex = timeRegex(check);
|
|
1264
|
-
if (!regex.test(
|
|
1265
|
-
ctx = this._getOrReturnCtx(
|
|
1265
|
+
if (!regex.test(input2.data)) {
|
|
1266
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1266
1267
|
addIssueToContext(ctx, {
|
|
1267
1268
|
code: ZodIssueCode.invalid_string,
|
|
1268
1269
|
validation: "time",
|
|
@@ -1271,8 +1272,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1271
1272
|
status.dirty();
|
|
1272
1273
|
}
|
|
1273
1274
|
} else if (check.kind === "duration") {
|
|
1274
|
-
if (!durationRegex.test(
|
|
1275
|
-
ctx = this._getOrReturnCtx(
|
|
1275
|
+
if (!durationRegex.test(input2.data)) {
|
|
1276
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1276
1277
|
addIssueToContext(ctx, {
|
|
1277
1278
|
validation: "duration",
|
|
1278
1279
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1281,8 +1282,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1281
1282
|
status.dirty();
|
|
1282
1283
|
}
|
|
1283
1284
|
} else if (check.kind === "ip") {
|
|
1284
|
-
if (!isValidIP(
|
|
1285
|
-
ctx = this._getOrReturnCtx(
|
|
1285
|
+
if (!isValidIP(input2.data, check.version)) {
|
|
1286
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1286
1287
|
addIssueToContext(ctx, {
|
|
1287
1288
|
validation: "ip",
|
|
1288
1289
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1291,8 +1292,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1291
1292
|
status.dirty();
|
|
1292
1293
|
}
|
|
1293
1294
|
} else if (check.kind === "jwt") {
|
|
1294
|
-
if (!isValidJWT(
|
|
1295
|
-
ctx = this._getOrReturnCtx(
|
|
1295
|
+
if (!isValidJWT(input2.data, check.alg)) {
|
|
1296
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1296
1297
|
addIssueToContext(ctx, {
|
|
1297
1298
|
validation: "jwt",
|
|
1298
1299
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1301,8 +1302,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1301
1302
|
status.dirty();
|
|
1302
1303
|
}
|
|
1303
1304
|
} else if (check.kind === "cidr") {
|
|
1304
|
-
if (!isValidCidr(
|
|
1305
|
-
ctx = this._getOrReturnCtx(
|
|
1305
|
+
if (!isValidCidr(input2.data, check.version)) {
|
|
1306
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1306
1307
|
addIssueToContext(ctx, {
|
|
1307
1308
|
validation: "cidr",
|
|
1308
1309
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1311,8 +1312,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1311
1312
|
status.dirty();
|
|
1312
1313
|
}
|
|
1313
1314
|
} else if (check.kind === "base64") {
|
|
1314
|
-
if (!base64Regex.test(
|
|
1315
|
-
ctx = this._getOrReturnCtx(
|
|
1315
|
+
if (!base64Regex.test(input2.data)) {
|
|
1316
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1316
1317
|
addIssueToContext(ctx, {
|
|
1317
1318
|
validation: "base64",
|
|
1318
1319
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1321,8 +1322,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1321
1322
|
status.dirty();
|
|
1322
1323
|
}
|
|
1323
1324
|
} else if (check.kind === "base64url") {
|
|
1324
|
-
if (!base64urlRegex.test(
|
|
1325
|
-
ctx = this._getOrReturnCtx(
|
|
1325
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
1326
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1326
1327
|
addIssueToContext(ctx, {
|
|
1327
1328
|
validation: "base64url",
|
|
1328
1329
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1334,7 +1335,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1334
1335
|
util.assertNever(check);
|
|
1335
1336
|
}
|
|
1336
1337
|
}
|
|
1337
|
-
return { status: status.value, value:
|
|
1338
|
+
return { status: status.value, value: input2.data };
|
|
1338
1339
|
}
|
|
1339
1340
|
_regex(regex, validation, message) {
|
|
1340
1341
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -1595,13 +1596,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1595
1596
|
this.max = this.lte;
|
|
1596
1597
|
this.step = this.multipleOf;
|
|
1597
1598
|
}
|
|
1598
|
-
_parse(
|
|
1599
|
+
_parse(input2) {
|
|
1599
1600
|
if (this._def.coerce) {
|
|
1600
|
-
|
|
1601
|
+
input2.data = Number(input2.data);
|
|
1601
1602
|
}
|
|
1602
|
-
const parsedType = this._getType(
|
|
1603
|
+
const parsedType = this._getType(input2);
|
|
1603
1604
|
if (parsedType !== ZodParsedType.number) {
|
|
1604
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1605
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1605
1606
|
addIssueToContext(ctx2, {
|
|
1606
1607
|
code: ZodIssueCode.invalid_type,
|
|
1607
1608
|
expected: ZodParsedType.number,
|
|
@@ -1613,8 +1614,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1613
1614
|
const status = new ParseStatus();
|
|
1614
1615
|
for (const check of this._def.checks) {
|
|
1615
1616
|
if (check.kind === "int") {
|
|
1616
|
-
if (!util.isInteger(
|
|
1617
|
-
ctx = this._getOrReturnCtx(
|
|
1617
|
+
if (!util.isInteger(input2.data)) {
|
|
1618
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1618
1619
|
addIssueToContext(ctx, {
|
|
1619
1620
|
code: ZodIssueCode.invalid_type,
|
|
1620
1621
|
expected: "integer",
|
|
@@ -1624,9 +1625,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1624
1625
|
status.dirty();
|
|
1625
1626
|
}
|
|
1626
1627
|
} else if (check.kind === "min") {
|
|
1627
|
-
const tooSmall = check.inclusive ?
|
|
1628
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1628
1629
|
if (tooSmall) {
|
|
1629
|
-
ctx = this._getOrReturnCtx(
|
|
1630
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1630
1631
|
addIssueToContext(ctx, {
|
|
1631
1632
|
code: ZodIssueCode.too_small,
|
|
1632
1633
|
minimum: check.value,
|
|
@@ -1638,9 +1639,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1638
1639
|
status.dirty();
|
|
1639
1640
|
}
|
|
1640
1641
|
} else if (check.kind === "max") {
|
|
1641
|
-
const tooBig = check.inclusive ?
|
|
1642
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1642
1643
|
if (tooBig) {
|
|
1643
|
-
ctx = this._getOrReturnCtx(
|
|
1644
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1644
1645
|
addIssueToContext(ctx, {
|
|
1645
1646
|
code: ZodIssueCode.too_big,
|
|
1646
1647
|
maximum: check.value,
|
|
@@ -1652,8 +1653,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1652
1653
|
status.dirty();
|
|
1653
1654
|
}
|
|
1654
1655
|
} else if (check.kind === "multipleOf") {
|
|
1655
|
-
if (floatSafeRemainder(
|
|
1656
|
-
ctx = this._getOrReturnCtx(
|
|
1656
|
+
if (floatSafeRemainder(input2.data, check.value) !== 0) {
|
|
1657
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1657
1658
|
addIssueToContext(ctx, {
|
|
1658
1659
|
code: ZodIssueCode.not_multiple_of,
|
|
1659
1660
|
multipleOf: check.value,
|
|
@@ -1662,8 +1663,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1662
1663
|
status.dirty();
|
|
1663
1664
|
}
|
|
1664
1665
|
} else if (check.kind === "finite") {
|
|
1665
|
-
if (!Number.isFinite(
|
|
1666
|
-
ctx = this._getOrReturnCtx(
|
|
1666
|
+
if (!Number.isFinite(input2.data)) {
|
|
1667
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1667
1668
|
addIssueToContext(ctx, {
|
|
1668
1669
|
code: ZodIssueCode.not_finite,
|
|
1669
1670
|
message: check.message
|
|
@@ -1674,7 +1675,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1674
1675
|
util.assertNever(check);
|
|
1675
1676
|
}
|
|
1676
1677
|
}
|
|
1677
|
-
return { status: status.value, value:
|
|
1678
|
+
return { status: status.value, value: input2.data };
|
|
1678
1679
|
}
|
|
1679
1680
|
gte(value, message) {
|
|
1680
1681
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -1826,25 +1827,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1826
1827
|
this.min = this.gte;
|
|
1827
1828
|
this.max = this.lte;
|
|
1828
1829
|
}
|
|
1829
|
-
_parse(
|
|
1830
|
+
_parse(input2) {
|
|
1830
1831
|
if (this._def.coerce) {
|
|
1831
1832
|
try {
|
|
1832
|
-
|
|
1833
|
+
input2.data = BigInt(input2.data);
|
|
1833
1834
|
} catch {
|
|
1834
|
-
return this._getInvalidInput(
|
|
1835
|
+
return this._getInvalidInput(input2);
|
|
1835
1836
|
}
|
|
1836
1837
|
}
|
|
1837
|
-
const parsedType = this._getType(
|
|
1838
|
+
const parsedType = this._getType(input2);
|
|
1838
1839
|
if (parsedType !== ZodParsedType.bigint) {
|
|
1839
|
-
return this._getInvalidInput(
|
|
1840
|
+
return this._getInvalidInput(input2);
|
|
1840
1841
|
}
|
|
1841
1842
|
let ctx = void 0;
|
|
1842
1843
|
const status = new ParseStatus();
|
|
1843
1844
|
for (const check of this._def.checks) {
|
|
1844
1845
|
if (check.kind === "min") {
|
|
1845
|
-
const tooSmall = check.inclusive ?
|
|
1846
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1846
1847
|
if (tooSmall) {
|
|
1847
|
-
ctx = this._getOrReturnCtx(
|
|
1848
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1848
1849
|
addIssueToContext(ctx, {
|
|
1849
1850
|
code: ZodIssueCode.too_small,
|
|
1850
1851
|
type: "bigint",
|
|
@@ -1855,9 +1856,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1855
1856
|
status.dirty();
|
|
1856
1857
|
}
|
|
1857
1858
|
} else if (check.kind === "max") {
|
|
1858
|
-
const tooBig = check.inclusive ?
|
|
1859
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1859
1860
|
if (tooBig) {
|
|
1860
|
-
ctx = this._getOrReturnCtx(
|
|
1861
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1861
1862
|
addIssueToContext(ctx, {
|
|
1862
1863
|
code: ZodIssueCode.too_big,
|
|
1863
1864
|
type: "bigint",
|
|
@@ -1868,8 +1869,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1868
1869
|
status.dirty();
|
|
1869
1870
|
}
|
|
1870
1871
|
} else if (check.kind === "multipleOf") {
|
|
1871
|
-
if (
|
|
1872
|
-
ctx = this._getOrReturnCtx(
|
|
1872
|
+
if (input2.data % check.value !== BigInt(0)) {
|
|
1873
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1873
1874
|
addIssueToContext(ctx, {
|
|
1874
1875
|
code: ZodIssueCode.not_multiple_of,
|
|
1875
1876
|
multipleOf: check.value,
|
|
@@ -1881,10 +1882,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1881
1882
|
util.assertNever(check);
|
|
1882
1883
|
}
|
|
1883
1884
|
}
|
|
1884
|
-
return { status: status.value, value:
|
|
1885
|
+
return { status: status.value, value: input2.data };
|
|
1885
1886
|
}
|
|
1886
|
-
_getInvalidInput(
|
|
1887
|
-
const ctx = this._getOrReturnCtx(
|
|
1887
|
+
_getInvalidInput(input2) {
|
|
1888
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
1888
1889
|
addIssueToContext(ctx, {
|
|
1889
1890
|
code: ZodIssueCode.invalid_type,
|
|
1890
1891
|
expected: ZodParsedType.bigint,
|
|
@@ -1993,13 +1994,13 @@ ZodBigInt.create = (params) => {
|
|
|
1993
1994
|
});
|
|
1994
1995
|
};
|
|
1995
1996
|
var ZodBoolean = class extends ZodType {
|
|
1996
|
-
_parse(
|
|
1997
|
+
_parse(input2) {
|
|
1997
1998
|
if (this._def.coerce) {
|
|
1998
|
-
|
|
1999
|
+
input2.data = Boolean(input2.data);
|
|
1999
2000
|
}
|
|
2000
|
-
const parsedType = this._getType(
|
|
2001
|
+
const parsedType = this._getType(input2);
|
|
2001
2002
|
if (parsedType !== ZodParsedType.boolean) {
|
|
2002
|
-
const ctx = this._getOrReturnCtx(
|
|
2003
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2003
2004
|
addIssueToContext(ctx, {
|
|
2004
2005
|
code: ZodIssueCode.invalid_type,
|
|
2005
2006
|
expected: ZodParsedType.boolean,
|
|
@@ -2007,7 +2008,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
2007
2008
|
});
|
|
2008
2009
|
return INVALID;
|
|
2009
2010
|
}
|
|
2010
|
-
return OK(
|
|
2011
|
+
return OK(input2.data);
|
|
2011
2012
|
}
|
|
2012
2013
|
};
|
|
2013
2014
|
ZodBoolean.create = (params) => {
|
|
@@ -2018,13 +2019,13 @@ ZodBoolean.create = (params) => {
|
|
|
2018
2019
|
});
|
|
2019
2020
|
};
|
|
2020
2021
|
var ZodDate = class _ZodDate extends ZodType {
|
|
2021
|
-
_parse(
|
|
2022
|
+
_parse(input2) {
|
|
2022
2023
|
if (this._def.coerce) {
|
|
2023
|
-
|
|
2024
|
+
input2.data = new Date(input2.data);
|
|
2024
2025
|
}
|
|
2025
|
-
const parsedType = this._getType(
|
|
2026
|
+
const parsedType = this._getType(input2);
|
|
2026
2027
|
if (parsedType !== ZodParsedType.date) {
|
|
2027
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2028
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2028
2029
|
addIssueToContext(ctx2, {
|
|
2029
2030
|
code: ZodIssueCode.invalid_type,
|
|
2030
2031
|
expected: ZodParsedType.date,
|
|
@@ -2032,8 +2033,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2032
2033
|
});
|
|
2033
2034
|
return INVALID;
|
|
2034
2035
|
}
|
|
2035
|
-
if (Number.isNaN(
|
|
2036
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2036
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
2037
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2037
2038
|
addIssueToContext(ctx2, {
|
|
2038
2039
|
code: ZodIssueCode.invalid_date
|
|
2039
2040
|
});
|
|
@@ -2043,8 +2044,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2043
2044
|
let ctx = void 0;
|
|
2044
2045
|
for (const check of this._def.checks) {
|
|
2045
2046
|
if (check.kind === "min") {
|
|
2046
|
-
if (
|
|
2047
|
-
ctx = this._getOrReturnCtx(
|
|
2047
|
+
if (input2.data.getTime() < check.value) {
|
|
2048
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2048
2049
|
addIssueToContext(ctx, {
|
|
2049
2050
|
code: ZodIssueCode.too_small,
|
|
2050
2051
|
message: check.message,
|
|
@@ -2056,8 +2057,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2056
2057
|
status.dirty();
|
|
2057
2058
|
}
|
|
2058
2059
|
} else if (check.kind === "max") {
|
|
2059
|
-
if (
|
|
2060
|
-
ctx = this._getOrReturnCtx(
|
|
2060
|
+
if (input2.data.getTime() > check.value) {
|
|
2061
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2061
2062
|
addIssueToContext(ctx, {
|
|
2062
2063
|
code: ZodIssueCode.too_big,
|
|
2063
2064
|
message: check.message,
|
|
@@ -2074,7 +2075,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2074
2075
|
}
|
|
2075
2076
|
return {
|
|
2076
2077
|
status: status.value,
|
|
2077
|
-
value: new Date(
|
|
2078
|
+
value: new Date(input2.data.getTime())
|
|
2078
2079
|
};
|
|
2079
2080
|
}
|
|
2080
2081
|
_addCheck(check) {
|
|
@@ -2127,10 +2128,10 @@ ZodDate.create = (params) => {
|
|
|
2127
2128
|
});
|
|
2128
2129
|
};
|
|
2129
2130
|
var ZodSymbol = class extends ZodType {
|
|
2130
|
-
_parse(
|
|
2131
|
-
const parsedType = this._getType(
|
|
2131
|
+
_parse(input2) {
|
|
2132
|
+
const parsedType = this._getType(input2);
|
|
2132
2133
|
if (parsedType !== ZodParsedType.symbol) {
|
|
2133
|
-
const ctx = this._getOrReturnCtx(
|
|
2134
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2134
2135
|
addIssueToContext(ctx, {
|
|
2135
2136
|
code: ZodIssueCode.invalid_type,
|
|
2136
2137
|
expected: ZodParsedType.symbol,
|
|
@@ -2138,7 +2139,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
2138
2139
|
});
|
|
2139
2140
|
return INVALID;
|
|
2140
2141
|
}
|
|
2141
|
-
return OK(
|
|
2142
|
+
return OK(input2.data);
|
|
2142
2143
|
}
|
|
2143
2144
|
};
|
|
2144
2145
|
ZodSymbol.create = (params) => {
|
|
@@ -2148,10 +2149,10 @@ ZodSymbol.create = (params) => {
|
|
|
2148
2149
|
});
|
|
2149
2150
|
};
|
|
2150
2151
|
var ZodUndefined = class extends ZodType {
|
|
2151
|
-
_parse(
|
|
2152
|
-
const parsedType = this._getType(
|
|
2152
|
+
_parse(input2) {
|
|
2153
|
+
const parsedType = this._getType(input2);
|
|
2153
2154
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2154
|
-
const ctx = this._getOrReturnCtx(
|
|
2155
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2155
2156
|
addIssueToContext(ctx, {
|
|
2156
2157
|
code: ZodIssueCode.invalid_type,
|
|
2157
2158
|
expected: ZodParsedType.undefined,
|
|
@@ -2159,7 +2160,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
2159
2160
|
});
|
|
2160
2161
|
return INVALID;
|
|
2161
2162
|
}
|
|
2162
|
-
return OK(
|
|
2163
|
+
return OK(input2.data);
|
|
2163
2164
|
}
|
|
2164
2165
|
};
|
|
2165
2166
|
ZodUndefined.create = (params) => {
|
|
@@ -2169,10 +2170,10 @@ ZodUndefined.create = (params) => {
|
|
|
2169
2170
|
});
|
|
2170
2171
|
};
|
|
2171
2172
|
var ZodNull = class extends ZodType {
|
|
2172
|
-
_parse(
|
|
2173
|
-
const parsedType = this._getType(
|
|
2173
|
+
_parse(input2) {
|
|
2174
|
+
const parsedType = this._getType(input2);
|
|
2174
2175
|
if (parsedType !== ZodParsedType.null) {
|
|
2175
|
-
const ctx = this._getOrReturnCtx(
|
|
2176
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2176
2177
|
addIssueToContext(ctx, {
|
|
2177
2178
|
code: ZodIssueCode.invalid_type,
|
|
2178
2179
|
expected: ZodParsedType.null,
|
|
@@ -2180,7 +2181,7 @@ var ZodNull = class extends ZodType {
|
|
|
2180
2181
|
});
|
|
2181
2182
|
return INVALID;
|
|
2182
2183
|
}
|
|
2183
|
-
return OK(
|
|
2184
|
+
return OK(input2.data);
|
|
2184
2185
|
}
|
|
2185
2186
|
};
|
|
2186
2187
|
ZodNull.create = (params) => {
|
|
@@ -2194,8 +2195,8 @@ var ZodAny = class extends ZodType {
|
|
|
2194
2195
|
super(...arguments);
|
|
2195
2196
|
this._any = true;
|
|
2196
2197
|
}
|
|
2197
|
-
_parse(
|
|
2198
|
-
return OK(
|
|
2198
|
+
_parse(input2) {
|
|
2199
|
+
return OK(input2.data);
|
|
2199
2200
|
}
|
|
2200
2201
|
};
|
|
2201
2202
|
ZodAny.create = (params) => {
|
|
@@ -2209,8 +2210,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
2209
2210
|
super(...arguments);
|
|
2210
2211
|
this._unknown = true;
|
|
2211
2212
|
}
|
|
2212
|
-
_parse(
|
|
2213
|
-
return OK(
|
|
2213
|
+
_parse(input2) {
|
|
2214
|
+
return OK(input2.data);
|
|
2214
2215
|
}
|
|
2215
2216
|
};
|
|
2216
2217
|
ZodUnknown.create = (params) => {
|
|
@@ -2220,8 +2221,8 @@ ZodUnknown.create = (params) => {
|
|
|
2220
2221
|
});
|
|
2221
2222
|
};
|
|
2222
2223
|
var ZodNever = class extends ZodType {
|
|
2223
|
-
_parse(
|
|
2224
|
-
const ctx = this._getOrReturnCtx(
|
|
2224
|
+
_parse(input2) {
|
|
2225
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2225
2226
|
addIssueToContext(ctx, {
|
|
2226
2227
|
code: ZodIssueCode.invalid_type,
|
|
2227
2228
|
expected: ZodParsedType.never,
|
|
@@ -2237,10 +2238,10 @@ ZodNever.create = (params) => {
|
|
|
2237
2238
|
});
|
|
2238
2239
|
};
|
|
2239
2240
|
var ZodVoid = class extends ZodType {
|
|
2240
|
-
_parse(
|
|
2241
|
-
const parsedType = this._getType(
|
|
2241
|
+
_parse(input2) {
|
|
2242
|
+
const parsedType = this._getType(input2);
|
|
2242
2243
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2243
|
-
const ctx = this._getOrReturnCtx(
|
|
2244
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2244
2245
|
addIssueToContext(ctx, {
|
|
2245
2246
|
code: ZodIssueCode.invalid_type,
|
|
2246
2247
|
expected: ZodParsedType.void,
|
|
@@ -2248,7 +2249,7 @@ var ZodVoid = class extends ZodType {
|
|
|
2248
2249
|
});
|
|
2249
2250
|
return INVALID;
|
|
2250
2251
|
}
|
|
2251
|
-
return OK(
|
|
2252
|
+
return OK(input2.data);
|
|
2252
2253
|
}
|
|
2253
2254
|
};
|
|
2254
2255
|
ZodVoid.create = (params) => {
|
|
@@ -2258,8 +2259,8 @@ ZodVoid.create = (params) => {
|
|
|
2258
2259
|
});
|
|
2259
2260
|
};
|
|
2260
2261
|
var ZodArray = class _ZodArray extends ZodType {
|
|
2261
|
-
_parse(
|
|
2262
|
-
const { ctx, status } = this._processInputParams(
|
|
2262
|
+
_parse(input2) {
|
|
2263
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
2263
2264
|
const def = this._def;
|
|
2264
2265
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
2265
2266
|
addIssueToContext(ctx, {
|
|
@@ -2399,10 +2400,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2399
2400
|
this._cached = { shape, keys };
|
|
2400
2401
|
return this._cached;
|
|
2401
2402
|
}
|
|
2402
|
-
_parse(
|
|
2403
|
-
const parsedType = this._getType(
|
|
2403
|
+
_parse(input2) {
|
|
2404
|
+
const parsedType = this._getType(input2);
|
|
2404
2405
|
if (parsedType !== ZodParsedType.object) {
|
|
2405
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2406
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2406
2407
|
addIssueToContext(ctx2, {
|
|
2407
2408
|
code: ZodIssueCode.invalid_type,
|
|
2408
2409
|
expected: ZodParsedType.object,
|
|
@@ -2410,7 +2411,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2410
2411
|
});
|
|
2411
2412
|
return INVALID;
|
|
2412
2413
|
}
|
|
2413
|
-
const { status, ctx } = this._processInputParams(
|
|
2414
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2414
2415
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2415
2416
|
const extraKeys = [];
|
|
2416
2417
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -2723,8 +2724,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
2723
2724
|
});
|
|
2724
2725
|
};
|
|
2725
2726
|
var ZodUnion = class extends ZodType {
|
|
2726
|
-
_parse(
|
|
2727
|
-
const { ctx } = this._processInputParams(
|
|
2727
|
+
_parse(input2) {
|
|
2728
|
+
const { ctx } = this._processInputParams(input2);
|
|
2728
2729
|
const options = this._def.options;
|
|
2729
2730
|
function handleResults(results) {
|
|
2730
2731
|
for (const result of results) {
|
|
@@ -2845,8 +2846,8 @@ var getDiscriminator = (type) => {
|
|
|
2845
2846
|
}
|
|
2846
2847
|
};
|
|
2847
2848
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
2848
|
-
_parse(
|
|
2849
|
-
const { ctx } = this._processInputParams(
|
|
2849
|
+
_parse(input2) {
|
|
2850
|
+
const { ctx } = this._processInputParams(input2);
|
|
2850
2851
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
2851
2852
|
addIssueToContext(ctx, {
|
|
2852
2853
|
code: ZodIssueCode.invalid_type,
|
|
@@ -2959,8 +2960,8 @@ function mergeValues(a, b) {
|
|
|
2959
2960
|
}
|
|
2960
2961
|
}
|
|
2961
2962
|
var ZodIntersection = class extends ZodType {
|
|
2962
|
-
_parse(
|
|
2963
|
-
const { status, ctx } = this._processInputParams(
|
|
2963
|
+
_parse(input2) {
|
|
2964
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2964
2965
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
2965
2966
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
2966
2967
|
return INVALID;
|
|
@@ -3012,8 +3013,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
3012
3013
|
});
|
|
3013
3014
|
};
|
|
3014
3015
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
3015
|
-
_parse(
|
|
3016
|
-
const { status, ctx } = this._processInputParams(
|
|
3016
|
+
_parse(input2) {
|
|
3017
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3017
3018
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
3018
3019
|
addIssueToContext(ctx, {
|
|
3019
3020
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3085,8 +3086,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3085
3086
|
get valueSchema() {
|
|
3086
3087
|
return this._def.valueType;
|
|
3087
3088
|
}
|
|
3088
|
-
_parse(
|
|
3089
|
-
const { status, ctx } = this._processInputParams(
|
|
3089
|
+
_parse(input2) {
|
|
3090
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3090
3091
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
3091
3092
|
addIssueToContext(ctx, {
|
|
3092
3093
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3138,8 +3139,8 @@ var ZodMap = class extends ZodType {
|
|
|
3138
3139
|
get valueSchema() {
|
|
3139
3140
|
return this._def.valueType;
|
|
3140
3141
|
}
|
|
3141
|
-
_parse(
|
|
3142
|
-
const { status, ctx } = this._processInputParams(
|
|
3142
|
+
_parse(input2) {
|
|
3143
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3143
3144
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
3144
3145
|
addIssueToContext(ctx, {
|
|
3145
3146
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3198,8 +3199,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
3198
3199
|
});
|
|
3199
3200
|
};
|
|
3200
3201
|
var ZodSet = class _ZodSet extends ZodType {
|
|
3201
|
-
_parse(
|
|
3202
|
-
const { status, ctx } = this._processInputParams(
|
|
3202
|
+
_parse(input2) {
|
|
3203
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3203
3204
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
3204
3205
|
addIssueToContext(ctx, {
|
|
3205
3206
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3287,8 +3288,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3287
3288
|
super(...arguments);
|
|
3288
3289
|
this.validate = this.implement;
|
|
3289
3290
|
}
|
|
3290
|
-
_parse(
|
|
3291
|
-
const { ctx } = this._processInputParams(
|
|
3291
|
+
_parse(input2) {
|
|
3292
|
+
const { ctx } = this._processInputParams(input2);
|
|
3292
3293
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
3293
3294
|
addIssueToContext(ctx, {
|
|
3294
3295
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3391,8 +3392,8 @@ var ZodLazy = class extends ZodType {
|
|
|
3391
3392
|
get schema() {
|
|
3392
3393
|
return this._def.getter();
|
|
3393
3394
|
}
|
|
3394
|
-
_parse(
|
|
3395
|
-
const { ctx } = this._processInputParams(
|
|
3395
|
+
_parse(input2) {
|
|
3396
|
+
const { ctx } = this._processInputParams(input2);
|
|
3396
3397
|
const lazySchema = this._def.getter();
|
|
3397
3398
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
3398
3399
|
}
|
|
@@ -3405,9 +3406,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
3405
3406
|
});
|
|
3406
3407
|
};
|
|
3407
3408
|
var ZodLiteral = class extends ZodType {
|
|
3408
|
-
_parse(
|
|
3409
|
-
if (
|
|
3410
|
-
const ctx = this._getOrReturnCtx(
|
|
3409
|
+
_parse(input2) {
|
|
3410
|
+
if (input2.data !== this._def.value) {
|
|
3411
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3411
3412
|
addIssueToContext(ctx, {
|
|
3412
3413
|
received: ctx.data,
|
|
3413
3414
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -3415,7 +3416,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
3415
3416
|
});
|
|
3416
3417
|
return INVALID;
|
|
3417
3418
|
}
|
|
3418
|
-
return { status: "valid", value:
|
|
3419
|
+
return { status: "valid", value: input2.data };
|
|
3419
3420
|
}
|
|
3420
3421
|
get value() {
|
|
3421
3422
|
return this._def.value;
|
|
@@ -3436,9 +3437,9 @@ function createZodEnum(values, params) {
|
|
|
3436
3437
|
});
|
|
3437
3438
|
}
|
|
3438
3439
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3439
|
-
_parse(
|
|
3440
|
-
if (typeof
|
|
3441
|
-
const ctx = this._getOrReturnCtx(
|
|
3440
|
+
_parse(input2) {
|
|
3441
|
+
if (typeof input2.data !== "string") {
|
|
3442
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3442
3443
|
const expectedValues = this._def.values;
|
|
3443
3444
|
addIssueToContext(ctx, {
|
|
3444
3445
|
expected: util.joinValues(expectedValues),
|
|
@@ -3450,8 +3451,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3450
3451
|
if (!this._cache) {
|
|
3451
3452
|
this._cache = new Set(this._def.values);
|
|
3452
3453
|
}
|
|
3453
|
-
if (!this._cache.has(
|
|
3454
|
-
const ctx = this._getOrReturnCtx(
|
|
3454
|
+
if (!this._cache.has(input2.data)) {
|
|
3455
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3455
3456
|
const expectedValues = this._def.values;
|
|
3456
3457
|
addIssueToContext(ctx, {
|
|
3457
3458
|
received: ctx.data,
|
|
@@ -3460,7 +3461,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3460
3461
|
});
|
|
3461
3462
|
return INVALID;
|
|
3462
3463
|
}
|
|
3463
|
-
return OK(
|
|
3464
|
+
return OK(input2.data);
|
|
3464
3465
|
}
|
|
3465
3466
|
get options() {
|
|
3466
3467
|
return this._def.values;
|
|
@@ -3501,9 +3502,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3501
3502
|
};
|
|
3502
3503
|
ZodEnum.create = createZodEnum;
|
|
3503
3504
|
var ZodNativeEnum = class extends ZodType {
|
|
3504
|
-
_parse(
|
|
3505
|
+
_parse(input2) {
|
|
3505
3506
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3506
|
-
const ctx = this._getOrReturnCtx(
|
|
3507
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3507
3508
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
3508
3509
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3509
3510
|
addIssueToContext(ctx, {
|
|
@@ -3516,7 +3517,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3516
3517
|
if (!this._cache) {
|
|
3517
3518
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
3518
3519
|
}
|
|
3519
|
-
if (!this._cache.has(
|
|
3520
|
+
if (!this._cache.has(input2.data)) {
|
|
3520
3521
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3521
3522
|
addIssueToContext(ctx, {
|
|
3522
3523
|
received: ctx.data,
|
|
@@ -3525,7 +3526,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3525
3526
|
});
|
|
3526
3527
|
return INVALID;
|
|
3527
3528
|
}
|
|
3528
|
-
return OK(
|
|
3529
|
+
return OK(input2.data);
|
|
3529
3530
|
}
|
|
3530
3531
|
get enum() {
|
|
3531
3532
|
return this._def.values;
|
|
@@ -3542,8 +3543,8 @@ var ZodPromise = class extends ZodType {
|
|
|
3542
3543
|
unwrap() {
|
|
3543
3544
|
return this._def.type;
|
|
3544
3545
|
}
|
|
3545
|
-
_parse(
|
|
3546
|
-
const { ctx } = this._processInputParams(
|
|
3546
|
+
_parse(input2) {
|
|
3547
|
+
const { ctx } = this._processInputParams(input2);
|
|
3547
3548
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
3548
3549
|
addIssueToContext(ctx, {
|
|
3549
3550
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3575,8 +3576,8 @@ var ZodEffects = class extends ZodType {
|
|
|
3575
3576
|
sourceType() {
|
|
3576
3577
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3577
3578
|
}
|
|
3578
|
-
_parse(
|
|
3579
|
-
const { status, ctx } = this._processInputParams(
|
|
3579
|
+
_parse(input2) {
|
|
3580
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3580
3581
|
const effect = this._def.effect || null;
|
|
3581
3582
|
const checkCtx = {
|
|
3582
3583
|
addIssue: (arg) => {
|
|
@@ -3708,12 +3709,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
|
3708
3709
|
});
|
|
3709
3710
|
};
|
|
3710
3711
|
var ZodOptional = class extends ZodType {
|
|
3711
|
-
_parse(
|
|
3712
|
-
const parsedType = this._getType(
|
|
3712
|
+
_parse(input2) {
|
|
3713
|
+
const parsedType = this._getType(input2);
|
|
3713
3714
|
if (parsedType === ZodParsedType.undefined) {
|
|
3714
3715
|
return OK(void 0);
|
|
3715
3716
|
}
|
|
3716
|
-
return this._def.innerType._parse(
|
|
3717
|
+
return this._def.innerType._parse(input2);
|
|
3717
3718
|
}
|
|
3718
3719
|
unwrap() {
|
|
3719
3720
|
return this._def.innerType;
|
|
@@ -3727,12 +3728,12 @@ ZodOptional.create = (type, params) => {
|
|
|
3727
3728
|
});
|
|
3728
3729
|
};
|
|
3729
3730
|
var ZodNullable = class extends ZodType {
|
|
3730
|
-
_parse(
|
|
3731
|
-
const parsedType = this._getType(
|
|
3731
|
+
_parse(input2) {
|
|
3732
|
+
const parsedType = this._getType(input2);
|
|
3732
3733
|
if (parsedType === ZodParsedType.null) {
|
|
3733
3734
|
return OK(null);
|
|
3734
3735
|
}
|
|
3735
|
-
return this._def.innerType._parse(
|
|
3736
|
+
return this._def.innerType._parse(input2);
|
|
3736
3737
|
}
|
|
3737
3738
|
unwrap() {
|
|
3738
3739
|
return this._def.innerType;
|
|
@@ -3746,8 +3747,8 @@ ZodNullable.create = (type, params) => {
|
|
|
3746
3747
|
});
|
|
3747
3748
|
};
|
|
3748
3749
|
var ZodDefault = class extends ZodType {
|
|
3749
|
-
_parse(
|
|
3750
|
-
const { ctx } = this._processInputParams(
|
|
3750
|
+
_parse(input2) {
|
|
3751
|
+
const { ctx } = this._processInputParams(input2);
|
|
3751
3752
|
let data = ctx.data;
|
|
3752
3753
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
3753
3754
|
data = this._def.defaultValue();
|
|
@@ -3771,8 +3772,8 @@ ZodDefault.create = (type, params) => {
|
|
|
3771
3772
|
});
|
|
3772
3773
|
};
|
|
3773
3774
|
var ZodCatch = class extends ZodType {
|
|
3774
|
-
_parse(
|
|
3775
|
-
const { ctx } = this._processInputParams(
|
|
3775
|
+
_parse(input2) {
|
|
3776
|
+
const { ctx } = this._processInputParams(input2);
|
|
3776
3777
|
const newCtx = {
|
|
3777
3778
|
...ctx,
|
|
3778
3779
|
common: {
|
|
@@ -3824,10 +3825,10 @@ ZodCatch.create = (type, params) => {
|
|
|
3824
3825
|
});
|
|
3825
3826
|
};
|
|
3826
3827
|
var ZodNaN = class extends ZodType {
|
|
3827
|
-
_parse(
|
|
3828
|
-
const parsedType = this._getType(
|
|
3828
|
+
_parse(input2) {
|
|
3829
|
+
const parsedType = this._getType(input2);
|
|
3829
3830
|
if (parsedType !== ZodParsedType.nan) {
|
|
3830
|
-
const ctx = this._getOrReturnCtx(
|
|
3831
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3831
3832
|
addIssueToContext(ctx, {
|
|
3832
3833
|
code: ZodIssueCode.invalid_type,
|
|
3833
3834
|
expected: ZodParsedType.nan,
|
|
@@ -3835,7 +3836,7 @@ var ZodNaN = class extends ZodType {
|
|
|
3835
3836
|
});
|
|
3836
3837
|
return INVALID;
|
|
3837
3838
|
}
|
|
3838
|
-
return { status: "valid", value:
|
|
3839
|
+
return { status: "valid", value: input2.data };
|
|
3839
3840
|
}
|
|
3840
3841
|
};
|
|
3841
3842
|
ZodNaN.create = (params) => {
|
|
@@ -3846,8 +3847,8 @@ ZodNaN.create = (params) => {
|
|
|
3846
3847
|
};
|
|
3847
3848
|
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3848
3849
|
var ZodBranded = class extends ZodType {
|
|
3849
|
-
_parse(
|
|
3850
|
-
const { ctx } = this._processInputParams(
|
|
3850
|
+
_parse(input2) {
|
|
3851
|
+
const { ctx } = this._processInputParams(input2);
|
|
3851
3852
|
const data = ctx.data;
|
|
3852
3853
|
return this._def.type._parse({
|
|
3853
3854
|
data,
|
|
@@ -3860,8 +3861,8 @@ var ZodBranded = class extends ZodType {
|
|
|
3860
3861
|
}
|
|
3861
3862
|
};
|
|
3862
3863
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
3863
|
-
_parse(
|
|
3864
|
-
const { status, ctx } = this._processInputParams(
|
|
3864
|
+
_parse(input2) {
|
|
3865
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3865
3866
|
if (ctx.common.async) {
|
|
3866
3867
|
const handleAsync = async () => {
|
|
3867
3868
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -3915,8 +3916,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3915
3916
|
}
|
|
3916
3917
|
};
|
|
3917
3918
|
var ZodReadonly = class extends ZodType {
|
|
3918
|
-
_parse(
|
|
3919
|
-
const result = this._def.innerType._parse(
|
|
3919
|
+
_parse(input2) {
|
|
3920
|
+
const result = this._def.innerType._parse(input2);
|
|
3920
3921
|
const freeze = (data) => {
|
|
3921
3922
|
if (isValid(data)) {
|
|
3922
3923
|
data.value = Object.freeze(data.value);
|
|
@@ -5805,8 +5806,8 @@ function loadAllRules(options) {
|
|
|
5805
5806
|
return getEmbeddedRules(options);
|
|
5806
5807
|
}
|
|
5807
5808
|
function generateFindingId(filePath, line, ruleId) {
|
|
5808
|
-
const
|
|
5809
|
-
return createHash("sha256").update(
|
|
5809
|
+
const input2 = `${filePath}:${line}:${ruleId}`;
|
|
5810
|
+
return createHash("sha256").update(input2).digest("hex").slice(0, 16);
|
|
5810
5811
|
}
|
|
5811
5812
|
function extractSnippet(content, line, contextLines = 5) {
|
|
5812
5813
|
const lines = content.split("\n");
|
|
@@ -6903,27 +6904,36 @@ function collectFiles(rootDir, options) {
|
|
|
6903
6904
|
return files;
|
|
6904
6905
|
}
|
|
6905
6906
|
|
|
6907
|
+
// src/commands/scan.ts
|
|
6908
|
+
import { input } from "@inquirer/prompts";
|
|
6909
|
+
|
|
6906
6910
|
// src/lib/output.ts
|
|
6907
6911
|
import chalk2 from "chalk";
|
|
6908
6912
|
|
|
6909
6913
|
// src/lib/banner.ts
|
|
6910
6914
|
import chalk from "chalk";
|
|
6911
|
-
var
|
|
6912
|
-
var
|
|
6913
|
-
var
|
|
6915
|
+
var PURPLE = chalk.hex("#A855F7");
|
|
6916
|
+
var PURPLE_BOLD = chalk.hex("#A855F7").bold;
|
|
6917
|
+
var DIM_PURPLE = chalk.hex("#C084FC");
|
|
6914
6918
|
function printBanner() {
|
|
6915
6919
|
console.log("");
|
|
6916
6920
|
console.log(
|
|
6917
|
-
|
|
6921
|
+
PURPLE(" \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513")
|
|
6922
|
+
);
|
|
6923
|
+
console.log(
|
|
6924
|
+
PURPLE(" \u2503") + chalk.bold.white(" ") + PURPLE("\u2503")
|
|
6925
|
+
);
|
|
6926
|
+
console.log(
|
|
6927
|
+
PURPLE(" \u2503") + chalk.bold.white(" ") + PURPLE_BOLD("S H I P S A F E") + chalk.bold.white(" ") + PURPLE("\u2503")
|
|
6918
6928
|
);
|
|
6919
6929
|
console.log(
|
|
6920
|
-
|
|
6930
|
+
PURPLE(" \u2503") + chalk.dim(" Security Scanner for AI-gen code ") + PURPLE("\u2503")
|
|
6921
6931
|
);
|
|
6922
6932
|
console.log(
|
|
6923
|
-
|
|
6933
|
+
PURPLE(" \u2503") + chalk.bold.white(" ") + PURPLE("\u2503")
|
|
6924
6934
|
);
|
|
6925
6935
|
console.log(
|
|
6926
|
-
|
|
6936
|
+
PURPLE(" \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B")
|
|
6927
6937
|
);
|
|
6928
6938
|
console.log("");
|
|
6929
6939
|
}
|
|
@@ -6963,31 +6973,31 @@ function printScanSummaryBox(stats) {
|
|
|
6963
6973
|
}
|
|
6964
6974
|
function printUpsellBox(criticalHigh) {
|
|
6965
6975
|
console.log("");
|
|
6966
|
-
console.log(
|
|
6976
|
+
console.log(DIM_PURPLE(" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E"));
|
|
6967
6977
|
console.log(
|
|
6968
|
-
|
|
6978
|
+
DIM_PURPLE(" \u2502") + PURPLE_BOLD(" \u{1F512} Unlock AI-Powered Deep Analysis ") + DIM_PURPLE("\u2502")
|
|
6969
6979
|
);
|
|
6970
|
-
console.log(
|
|
6980
|
+
console.log(DIM_PURPLE(" \u2502 \u2502"));
|
|
6971
6981
|
if (criticalHigh > 0) {
|
|
6972
6982
|
console.log(
|
|
6973
|
-
|
|
6983
|
+
DIM_PURPLE(" \u2502 ") + chalk.white(`Found ${criticalHigh} critical/high issues. AI finds`) + " ".repeat(Math.max(0, 46 - `Found ${criticalHigh} critical/high issues. AI finds`.length)) + DIM_PURPLE("\u2502")
|
|
6974
6984
|
);
|
|
6975
6985
|
console.log(
|
|
6976
|
-
|
|
6986
|
+
DIM_PURPLE(" \u2502 ") + chalk.dim("auth logic flaws, business logic bugs & more.") + " ".repeat(3) + DIM_PURPLE("\u2502")
|
|
6977
6987
|
);
|
|
6978
6988
|
} else {
|
|
6979
6989
|
console.log(
|
|
6980
|
-
|
|
6990
|
+
DIM_PURPLE(" \u2502 ") + chalk.dim("Surface scan clean. AI finds auth logic,") + " ".repeat(8) + DIM_PURPLE("\u2502")
|
|
6981
6991
|
);
|
|
6982
6992
|
console.log(
|
|
6983
|
-
|
|
6993
|
+
DIM_PURPLE(" \u2502 ") + chalk.dim("RLS policies & business logic bugs.") + " ".repeat(13) + DIM_PURPLE("\u2502")
|
|
6984
6994
|
);
|
|
6985
6995
|
}
|
|
6986
|
-
console.log(
|
|
6996
|
+
console.log(DIM_PURPLE(" \u2502 \u2502"));
|
|
6987
6997
|
console.log(
|
|
6988
|
-
|
|
6998
|
+
DIM_PURPLE(" \u2502 ") + chalk.white("\u2192 Run ") + PURPLE_BOLD("shipsafe login") + chalk.white(" to get started") + " ".repeat(13) + DIM_PURPLE("\u2502")
|
|
6989
6999
|
);
|
|
6990
|
-
console.log(
|
|
7000
|
+
console.log(DIM_PURPLE(" \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"));
|
|
6991
7001
|
}
|
|
6992
7002
|
|
|
6993
7003
|
// src/lib/output.ts
|
|
@@ -7225,7 +7235,7 @@ async function loginCommand(options) {
|
|
|
7225
7235
|
`);
|
|
7226
7236
|
const pollSpinner = ora("Waiting for authorization...").start();
|
|
7227
7237
|
const startTime = Date.now();
|
|
7228
|
-
const pollInterval =
|
|
7238
|
+
const pollInterval = 2e3;
|
|
7229
7239
|
let networkErrors = 0;
|
|
7230
7240
|
while (Date.now() - startTime < expiresIn * 1e3) {
|
|
7231
7241
|
await new Promise((r) => setTimeout(r, pollInterval));
|
|
@@ -7235,6 +7245,16 @@ async function loginCommand(options) {
|
|
|
7235
7245
|
headers: { "Content-Type": "application/json" },
|
|
7236
7246
|
body: JSON.stringify({ deviceCode })
|
|
7237
7247
|
});
|
|
7248
|
+
if (!pollRes.ok) {
|
|
7249
|
+
networkErrors++;
|
|
7250
|
+
if (networkErrors >= 5) {
|
|
7251
|
+
pollSpinner.fail(
|
|
7252
|
+
chalk3.red("Server error during login. Run `shipsafe login` again.")
|
|
7253
|
+
);
|
|
7254
|
+
return;
|
|
7255
|
+
}
|
|
7256
|
+
continue;
|
|
7257
|
+
}
|
|
7238
7258
|
const pollData = await pollRes.json();
|
|
7239
7259
|
networkErrors = 0;
|
|
7240
7260
|
if (pollData.status === "complete") {
|
|
@@ -7541,14 +7561,14 @@ async function scanCommand(targetPath, options) {
|
|
|
7541
7561
|
value: "free"
|
|
7542
7562
|
},
|
|
7543
7563
|
{
|
|
7544
|
-
name: `${chalk5.hex("#
|
|
7564
|
+
name: `${chalk5.hex("#A855F7")("\u25B8")} ${chalk5.bold("Login first")} ${chalk5.dim("\u2014 unlock AI-powered deep analysis")}`,
|
|
7545
7565
|
value: "login"
|
|
7546
7566
|
}
|
|
7547
7567
|
],
|
|
7548
7568
|
theme: {
|
|
7549
|
-
prefix: { idle: chalk5.hex("#
|
|
7569
|
+
prefix: { idle: chalk5.hex("#A855F7")(" \u{1F6E1}\uFE0F"), done: chalk5.green(" \u2713") },
|
|
7550
7570
|
style: {
|
|
7551
|
-
highlight: (text) => chalk5.hex("#
|
|
7571
|
+
highlight: (text) => chalk5.hex("#A855F7")(text)
|
|
7552
7572
|
}
|
|
7553
7573
|
}
|
|
7554
7574
|
});
|
|
@@ -7771,6 +7791,39 @@ async function scanCommand(targetPath, options) {
|
|
|
7771
7791
|
)
|
|
7772
7792
|
);
|
|
7773
7793
|
}
|
|
7794
|
+
if (!options.ci && token) {
|
|
7795
|
+
try {
|
|
7796
|
+
const feedbackFile = join4(homedir3(), ".shipsafe", "feedback.json");
|
|
7797
|
+
let lastFeedback = 0;
|
|
7798
|
+
try {
|
|
7799
|
+
const data = JSON.parse(readFileSync5(feedbackFile, "utf-8"));
|
|
7800
|
+
lastFeedback = data.lastFeedbackAt || 0;
|
|
7801
|
+
} catch {
|
|
7802
|
+
}
|
|
7803
|
+
const sevenDays = 7 * 24 * 60 * 60 * 1e3;
|
|
7804
|
+
if (Date.now() - lastFeedback > sevenDays) {
|
|
7805
|
+
const answer = await input({
|
|
7806
|
+
message: chalk5.dim("Rate this scan (1-5, or Enter to skip):")
|
|
7807
|
+
});
|
|
7808
|
+
const rating = parseInt(answer, 10);
|
|
7809
|
+
const now = Date.now();
|
|
7810
|
+
if (rating >= 1 && rating <= 5) {
|
|
7811
|
+
fetch(`${options.apiUrl}/api/cli/feedback`, {
|
|
7812
|
+
method: "POST",
|
|
7813
|
+
headers: {
|
|
7814
|
+
"Content-Type": "application/json",
|
|
7815
|
+
Authorization: `Bearer ${token.token}`
|
|
7816
|
+
},
|
|
7817
|
+
body: JSON.stringify({ rating })
|
|
7818
|
+
}).catch(() => {
|
|
7819
|
+
});
|
|
7820
|
+
console.log(chalk5.dim(" Thanks for the feedback!"));
|
|
7821
|
+
}
|
|
7822
|
+
writeFileSync4(feedbackFile, JSON.stringify({ lastFeedbackAt: now }), { mode: 384 });
|
|
7823
|
+
}
|
|
7824
|
+
} catch {
|
|
7825
|
+
}
|
|
7826
|
+
}
|
|
7774
7827
|
if (options.ci) {
|
|
7775
7828
|
const hasHighSeverity = result.findings.some(
|
|
7776
7829
|
(f) => f.severity === "critical" || severity !== "critical" && f.severity === "high"
|
|
@@ -7782,7 +7835,7 @@ async function scanCommand(targetPath, options) {
|
|
|
7782
7835
|
}
|
|
7783
7836
|
|
|
7784
7837
|
// src/commands/init.ts
|
|
7785
|
-
import { writeFileSync as
|
|
7838
|
+
import { writeFileSync as writeFileSync5, existsSync as existsSync6 } from "fs";
|
|
7786
7839
|
import { resolve as resolve3 } from "path";
|
|
7787
7840
|
import chalk6 from "chalk";
|
|
7788
7841
|
var DEFAULT_CONFIG = `# ShipSafe Configuration
|
|
@@ -7818,7 +7871,7 @@ function initCommand() {
|
|
|
7818
7871
|
console.log(chalk6.yellow("A .shipsafe.yml already exists in this directory."));
|
|
7819
7872
|
return;
|
|
7820
7873
|
}
|
|
7821
|
-
|
|
7874
|
+
writeFileSync5(configPath, DEFAULT_CONFIG, "utf-8");
|
|
7822
7875
|
console.log(chalk6.green("Created .shipsafe.yml configuration file."));
|
|
7823
7876
|
}
|
|
7824
7877
|
|