@vibgrate/cli 1.0.65 → 1.0.66
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.
|
@@ -1169,6 +1169,260 @@ import * as crypto3 from "crypto";
|
|
|
1169
1169
|
import * as path2 from "path";
|
|
1170
1170
|
import { Command as Command2 } from "commander";
|
|
1171
1171
|
import chalk3 from "chalk";
|
|
1172
|
+
|
|
1173
|
+
// src/utils/compact-artifact.ts
|
|
1174
|
+
import * as zlib from "zlib";
|
|
1175
|
+
import { promisify } from "util";
|
|
1176
|
+
|
|
1177
|
+
// src/utils/compact-evidence.ts
|
|
1178
|
+
var CATEGORY_PATTERNS = [
|
|
1179
|
+
{ category: "pricing", pattern: /price|pricing|billing|subscri|trial|credit|plan|tier|upgrade|premium|pro|enterprise/i },
|
|
1180
|
+
{ category: "auth", pattern: /sign[- ]?in|sign[- ]?up|log[- ]?in|log[- ]?out|auth|sso|oauth|password|register|invite|onboard/i },
|
|
1181
|
+
{ category: "dashboard", pattern: /dashboard|overview|home|main|summary|stats/i },
|
|
1182
|
+
{ category: "settings", pattern: /setting|config|preference|option|profile|account/i },
|
|
1183
|
+
{ category: "users", pattern: /user|member|team|role|permission|access|admin|owner/i },
|
|
1184
|
+
{ category: "integrations", pattern: /integrat|connect|webhook|api[- ]?key|sync|import|export/i },
|
|
1185
|
+
{ category: "reports", pattern: /report|analy|metric|chart|graph|insight|track/i },
|
|
1186
|
+
{ category: "workflows", pattern: /workflow|automat|schedule|trigger|action|job|task|pipeline/i },
|
|
1187
|
+
{ category: "projects", pattern: /project|workspace|organization|folder|repo/i },
|
|
1188
|
+
{ category: "navigation", pattern: /menu|nav|sidebar|header|footer|breadcrumb/i }
|
|
1189
|
+
];
|
|
1190
|
+
function compactUiPurpose(result, maxSamplesPerCategory = 3) {
|
|
1191
|
+
const evidence = result.topEvidence;
|
|
1192
|
+
const dependencies = evidence.filter((e) => e.kind === "dependency").map((e) => e.value).slice(0, 10);
|
|
1193
|
+
const routes = dedupeRoutes(
|
|
1194
|
+
evidence.filter((e) => e.kind === "route").map((e) => e.value)
|
|
1195
|
+
).slice(0, 15);
|
|
1196
|
+
const textEvidence = evidence.filter(
|
|
1197
|
+
(e) => e.kind !== "dependency" && e.kind !== "route" && e.kind !== "feature_flag"
|
|
1198
|
+
);
|
|
1199
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
1200
|
+
const categoryCounts = {};
|
|
1201
|
+
for (const item of textEvidence) {
|
|
1202
|
+
const category = categorize(item.value);
|
|
1203
|
+
if (!byCategory.has(category)) {
|
|
1204
|
+
byCategory.set(category, /* @__PURE__ */ new Set());
|
|
1205
|
+
}
|
|
1206
|
+
const normalized = normalizeValue(item.value);
|
|
1207
|
+
if (normalized.length >= 3) {
|
|
1208
|
+
byCategory.get(category).add(normalized);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
const samples = [];
|
|
1212
|
+
for (const [category, values] of byCategory) {
|
|
1213
|
+
const deduped = dedupeStrings([...values]);
|
|
1214
|
+
categoryCounts[category] = deduped.length;
|
|
1215
|
+
for (const value of deduped.slice(0, maxSamplesPerCategory)) {
|
|
1216
|
+
samples.push({ kind: "text", value, category });
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
const featureFlags = evidence.filter((e) => e.kind === "feature_flag");
|
|
1220
|
+
if (featureFlags.length > 0) {
|
|
1221
|
+
categoryCounts["feature_flags"] = featureFlags.length;
|
|
1222
|
+
samples.push({ kind: "feature_flag", value: "feature flags detected", category: "feature_flags" });
|
|
1223
|
+
}
|
|
1224
|
+
return {
|
|
1225
|
+
samples,
|
|
1226
|
+
categoryCounts,
|
|
1227
|
+
originalCount: evidence.length,
|
|
1228
|
+
dependencies,
|
|
1229
|
+
routes,
|
|
1230
|
+
detectedFrameworks: result.detectedFrameworks
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
function categorize(value) {
|
|
1234
|
+
for (const { category, pattern } of CATEGORY_PATTERNS) {
|
|
1235
|
+
if (pattern.test(value)) return category;
|
|
1236
|
+
}
|
|
1237
|
+
return "general";
|
|
1238
|
+
}
|
|
1239
|
+
function normalizeValue(value) {
|
|
1240
|
+
return value.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
1241
|
+
}
|
|
1242
|
+
function dedupeStrings(values) {
|
|
1243
|
+
const sorted = values.sort((a, b) => b.length - a.length);
|
|
1244
|
+
const kept = [];
|
|
1245
|
+
for (const value of sorted) {
|
|
1246
|
+
const isDupe = kept.some((k) => {
|
|
1247
|
+
const stem = value.slice(0, 6);
|
|
1248
|
+
return k.startsWith(stem) || k.includes(value) || value.includes(k);
|
|
1249
|
+
});
|
|
1250
|
+
if (!isDupe) {
|
|
1251
|
+
kept.push(value);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return kept;
|
|
1255
|
+
}
|
|
1256
|
+
function dedupeRoutes(routes) {
|
|
1257
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1258
|
+
const result = [];
|
|
1259
|
+
for (const route of routes) {
|
|
1260
|
+
const normalized = route.replace(/:[a-z_]+/gi, ":param").replace(/\[\[*\.*\.*[a-z_]+\]*\]/gi, ":param").replace(/\/+$/, "").toLowerCase();
|
|
1261
|
+
if (!seen.has(normalized)) {
|
|
1262
|
+
seen.add(normalized);
|
|
1263
|
+
result.push(route);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return result;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// src/utils/compact-artifact.ts
|
|
1270
|
+
var gzip2 = promisify(zlib.gzip);
|
|
1271
|
+
var MAX_ITEMS = 50;
|
|
1272
|
+
function extractName(entry) {
|
|
1273
|
+
const match = entry.match(/^(.+?)\s*\(/);
|
|
1274
|
+
return match ? match[1].trim() : entry.trim();
|
|
1275
|
+
}
|
|
1276
|
+
function compactDataStores(result) {
|
|
1277
|
+
return {
|
|
1278
|
+
databaseTechnologies: result.databaseTechnologies.slice(0, 10),
|
|
1279
|
+
connectionStrings: [],
|
|
1280
|
+
// Don't include connection strings in upload
|
|
1281
|
+
connectionPoolSettings: result.connectionPoolSettings.slice(0, MAX_ITEMS),
|
|
1282
|
+
replicationSettings: result.replicationSettings.slice(0, 20),
|
|
1283
|
+
readReplicaSettings: result.readReplicaSettings.slice(0, 20),
|
|
1284
|
+
failoverSettings: result.failoverSettings.slice(0, 20),
|
|
1285
|
+
collationAndEncoding: result.collationAndEncoding.slice(0, 20),
|
|
1286
|
+
queryTimeoutDefaults: result.queryTimeoutDefaults.slice(0, 20),
|
|
1287
|
+
manualIndexes: result.manualIndexes.map(extractName).slice(0, MAX_ITEMS),
|
|
1288
|
+
tables: result.tables.map(extractName).slice(0, MAX_ITEMS),
|
|
1289
|
+
views: result.views.map(extractName).slice(0, MAX_ITEMS),
|
|
1290
|
+
storedProcedures: result.storedProcedures.map(extractName).slice(0, MAX_ITEMS),
|
|
1291
|
+
triggers: result.triggers.map(extractName).slice(0, MAX_ITEMS),
|
|
1292
|
+
rowLevelSecurityPolicies: result.rowLevelSecurityPolicies.slice(0, 20),
|
|
1293
|
+
otherServices: result.otherServices.slice(0, 20)
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function compactApiSurface(result) {
|
|
1297
|
+
const seenProviders = /* @__PURE__ */ new Set();
|
|
1298
|
+
const uniqueIntegrations = result.integrations.filter((i) => {
|
|
1299
|
+
const domain = i.provider.split(":")[0];
|
|
1300
|
+
if (seenProviders.has(domain)) return false;
|
|
1301
|
+
seenProviders.add(domain);
|
|
1302
|
+
return true;
|
|
1303
|
+
}).slice(0, MAX_ITEMS).map((i) => ({
|
|
1304
|
+
provider: i.provider,
|
|
1305
|
+
endpoint: "",
|
|
1306
|
+
// Don't include full endpoints
|
|
1307
|
+
version: i.version,
|
|
1308
|
+
parameters: [],
|
|
1309
|
+
// Don't include params
|
|
1310
|
+
configOptions: [],
|
|
1311
|
+
authHints: []
|
|
1312
|
+
}));
|
|
1313
|
+
return {
|
|
1314
|
+
integrations: uniqueIntegrations,
|
|
1315
|
+
openApiSpecifications: result.openApiSpecifications.slice(0, 10),
|
|
1316
|
+
webhookUrls: result.webhookUrls.slice(0, 20),
|
|
1317
|
+
callbackEndpoints: result.callbackEndpoints.slice(0, 20),
|
|
1318
|
+
apiVersionPins: result.apiVersionPins.slice(0, 20),
|
|
1319
|
+
tokenExpirationPolicies: result.tokenExpirationPolicies.slice(0, 20),
|
|
1320
|
+
rateLimitOverrides: result.rateLimitOverrides.slice(0, 20),
|
|
1321
|
+
customHeaders: result.customHeaders.slice(0, 20),
|
|
1322
|
+
corsPolicies: result.corsPolicies.slice(0, 20),
|
|
1323
|
+
oauthScopes: result.oauthScopes.slice(0, 20),
|
|
1324
|
+
apiTokens: []
|
|
1325
|
+
// Don't include token references
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
function compactAssetBranding(result) {
|
|
1329
|
+
return {
|
|
1330
|
+
faviconFiles: result.faviconFiles.slice(0, 1),
|
|
1331
|
+
productLogos: []
|
|
1332
|
+
// Don't include logos
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
function prepareArtifactForUpload(artifact) {
|
|
1336
|
+
const compacted = { ...artifact };
|
|
1337
|
+
if (compacted.extended) {
|
|
1338
|
+
const ext = { ...compacted.extended };
|
|
1339
|
+
if (ext.dataStores) {
|
|
1340
|
+
ext.dataStores = compactDataStores(ext.dataStores);
|
|
1341
|
+
}
|
|
1342
|
+
if (ext.apiSurface) {
|
|
1343
|
+
ext.apiSurface = compactApiSurface(ext.apiSurface);
|
|
1344
|
+
}
|
|
1345
|
+
if (ext.assetBranding) {
|
|
1346
|
+
ext.assetBranding = compactAssetBranding(ext.assetBranding);
|
|
1347
|
+
}
|
|
1348
|
+
if (ext.uiPurpose) {
|
|
1349
|
+
const compactedUi = compactUiPurpose(ext.uiPurpose);
|
|
1350
|
+
ext.uiPurpose = {
|
|
1351
|
+
enabled: ext.uiPurpose.enabled,
|
|
1352
|
+
detectedFrameworks: compactedUi.detectedFrameworks,
|
|
1353
|
+
evidenceCount: compactedUi.originalCount,
|
|
1354
|
+
capped: ext.uiPurpose.capped,
|
|
1355
|
+
topEvidence: [],
|
|
1356
|
+
// Clear full evidence
|
|
1357
|
+
unknownSignals: [],
|
|
1358
|
+
// Add compacted data under extended properties
|
|
1359
|
+
...{ compacted: compactedUi }
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
if (ext.runtimeConfiguration) {
|
|
1363
|
+
ext.runtimeConfiguration = {
|
|
1364
|
+
...ext.runtimeConfiguration,
|
|
1365
|
+
environmentVariables: ext.runtimeConfiguration.environmentVariables.slice(0, 100),
|
|
1366
|
+
hiddenConfigFiles: ext.runtimeConfiguration.hiddenConfigFiles.slice(0, MAX_ITEMS),
|
|
1367
|
+
startupArguments: ext.runtimeConfiguration.startupArguments.slice(0, 100)
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
if (ext.operationalResilience) {
|
|
1371
|
+
const ops = ext.operationalResilience;
|
|
1372
|
+
ext.operationalResilience = {
|
|
1373
|
+
implicitTimeouts: ops.implicitTimeouts.slice(0, 30),
|
|
1374
|
+
defaultPaginationSize: ops.defaultPaginationSize.slice(0, 30),
|
|
1375
|
+
implicitRetryLogic: ops.implicitRetryLogic.slice(0, 30),
|
|
1376
|
+
defaultLocale: ops.defaultLocale.slice(0, 20),
|
|
1377
|
+
defaultCurrency: ops.defaultCurrency.slice(0, 20),
|
|
1378
|
+
implicitTimezone: ops.implicitTimezone.slice(0, 20),
|
|
1379
|
+
defaultCharacterEncoding: ops.defaultCharacterEncoding.slice(0, 20),
|
|
1380
|
+
sessionStores: ops.sessionStores.slice(0, 20),
|
|
1381
|
+
distributedLocks: ops.distributedLocks.slice(0, 20),
|
|
1382
|
+
jobSchedulers: ops.jobSchedulers.slice(0, 30),
|
|
1383
|
+
idempotencyKeys: ops.idempotencyKeys.slice(0, 20),
|
|
1384
|
+
rateLimitingCounters: ops.rateLimitingCounters.slice(0, 20),
|
|
1385
|
+
circuitBreakerState: ops.circuitBreakerState.slice(0, 20),
|
|
1386
|
+
abTestToggles: ops.abTestToggles.slice(0, 20),
|
|
1387
|
+
regionalEnablementRules: ops.regionalEnablementRules.slice(0, 20),
|
|
1388
|
+
betaAccessGroups: ops.betaAccessGroups.slice(0, 20),
|
|
1389
|
+
licensingEnforcementLogic: ops.licensingEnforcementLogic.slice(0, 20),
|
|
1390
|
+
killSwitches: ops.killSwitches.slice(0, 20),
|
|
1391
|
+
connectorRetryLogic: ops.connectorRetryLogic.slice(0, 20),
|
|
1392
|
+
apiPollingIntervals: ops.apiPollingIntervals.slice(0, 20),
|
|
1393
|
+
fieldMappings: ops.fieldMappings.slice(0, 20),
|
|
1394
|
+
schemaRegistryRules: ops.schemaRegistryRules.slice(0, 20),
|
|
1395
|
+
deadLetterQueueBehavior: ops.deadLetterQueueBehavior.slice(0, 20),
|
|
1396
|
+
dataMaskingRules: ops.dataMaskingRules.slice(0, 20),
|
|
1397
|
+
transformationLogic: ops.transformationLogic.slice(0, 20),
|
|
1398
|
+
timezoneHandling: ops.timezoneHandling.slice(0, 20),
|
|
1399
|
+
encryptionSettings: ops.encryptionSettings.slice(0, 30),
|
|
1400
|
+
hardcodedSecretSignals: ops.hardcodedSecretSignals.slice(0, 20)
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
if (ext.dependencyGraph) {
|
|
1404
|
+
ext.dependencyGraph = {
|
|
1405
|
+
...ext.dependencyGraph,
|
|
1406
|
+
phantomDependencies: ext.dependencyGraph.phantomDependencies.slice(0, MAX_ITEMS),
|
|
1407
|
+
phantomDependencyDetails: ext.dependencyGraph.phantomDependencyDetails?.slice(0, MAX_ITEMS),
|
|
1408
|
+
duplicatedPackages: ext.dependencyGraph.duplicatedPackages.slice(0, MAX_ITEMS)
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
compacted.extended = ext;
|
|
1412
|
+
}
|
|
1413
|
+
return compacted;
|
|
1414
|
+
}
|
|
1415
|
+
async function compressArtifact(artifact) {
|
|
1416
|
+
const json = JSON.stringify(artifact);
|
|
1417
|
+
return gzip2(json, { level: 9 });
|
|
1418
|
+
}
|
|
1419
|
+
async function prepareCompressedUpload(artifact) {
|
|
1420
|
+
const compacted = prepareArtifactForUpload(artifact);
|
|
1421
|
+
const compressed = await compressArtifact(compacted);
|
|
1422
|
+
return { body: compressed, contentEncoding: "gzip" };
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// src/commands/push.ts
|
|
1172
1426
|
function parseDsn(dsn) {
|
|
1173
1427
|
const cleaned = dsn.replace(/[\x00-\x1F\x7F\uFEFF\u200B-\u200D\u2060]/g, "").trim();
|
|
1174
1428
|
const match = cleaned.match(/^vibgrate\+(https?):?\/\/([^:]+):([^@]+)@([^/]+)\/(.+)$/);
|
|
@@ -1203,7 +1457,8 @@ var pushCommand = new Command2("push").description("Push scan results to Vibgrat
|
|
|
1203
1457
|
if (opts.strict) process.exit(1);
|
|
1204
1458
|
return;
|
|
1205
1459
|
}
|
|
1206
|
-
const
|
|
1460
|
+
const artifact = await readJsonFile(filePath);
|
|
1461
|
+
const { body, contentEncoding } = await prepareCompressedUpload(artifact);
|
|
1207
1462
|
const timestamp = String(Date.now());
|
|
1208
1463
|
let host = parsed.host;
|
|
1209
1464
|
if (opts.region) {
|
|
@@ -1216,12 +1471,16 @@ var pushCommand = new Command2("push").description("Push scan results to Vibgrat
|
|
|
1216
1471
|
}
|
|
1217
1472
|
}
|
|
1218
1473
|
const url = `${parsed.scheme}://${host}/v1/ingest/scan`;
|
|
1219
|
-
|
|
1474
|
+
const originalSize = JSON.stringify(artifact).length;
|
|
1475
|
+
const compressedSize = body.length;
|
|
1476
|
+
const ratio = ((1 - compressedSize / originalSize) * 100).toFixed(0);
|
|
1477
|
+
console.log(chalk3.dim(`Uploading to ${host}... (${(compressedSize / 1024).toFixed(0)} KB, ${ratio}% smaller)`));
|
|
1220
1478
|
try {
|
|
1221
1479
|
const response = await fetch(url, {
|
|
1222
1480
|
method: "POST",
|
|
1223
1481
|
headers: {
|
|
1224
1482
|
"Content-Type": "application/json",
|
|
1483
|
+
"Content-Encoding": contentEncoding,
|
|
1225
1484
|
"X-Vibgrate-Timestamp": timestamp,
|
|
1226
1485
|
"Authorization": `VibgrateDSN ${parsed.keyId}:${parsed.secret}`,
|
|
1227
1486
|
"Connection": "close"
|
|
@@ -7795,98 +8054,6 @@ async function scanOssGovernance(rootDir, fileCache) {
|
|
|
7795
8054
|
};
|
|
7796
8055
|
}
|
|
7797
8056
|
|
|
7798
|
-
// src/utils/compact-evidence.ts
|
|
7799
|
-
var CATEGORY_PATTERNS = [
|
|
7800
|
-
{ category: "pricing", pattern: /price|pricing|billing|subscri|trial|credit|plan|tier|upgrade|premium|pro|enterprise/i },
|
|
7801
|
-
{ category: "auth", pattern: /sign[- ]?in|sign[- ]?up|log[- ]?in|log[- ]?out|auth|sso|oauth|password|register|invite|onboard/i },
|
|
7802
|
-
{ category: "dashboard", pattern: /dashboard|overview|home|main|summary|stats/i },
|
|
7803
|
-
{ category: "settings", pattern: /setting|config|preference|option|profile|account/i },
|
|
7804
|
-
{ category: "users", pattern: /user|member|team|role|permission|access|admin|owner/i },
|
|
7805
|
-
{ category: "integrations", pattern: /integrat|connect|webhook|api[- ]?key|sync|import|export/i },
|
|
7806
|
-
{ category: "reports", pattern: /report|analy|metric|chart|graph|insight|track/i },
|
|
7807
|
-
{ category: "workflows", pattern: /workflow|automat|schedule|trigger|action|job|task|pipeline/i },
|
|
7808
|
-
{ category: "projects", pattern: /project|workspace|organization|folder|repo/i },
|
|
7809
|
-
{ category: "navigation", pattern: /menu|nav|sidebar|header|footer|breadcrumb/i }
|
|
7810
|
-
];
|
|
7811
|
-
function compactUiPurpose(result, maxSamplesPerCategory = 3) {
|
|
7812
|
-
const evidence = result.topEvidence;
|
|
7813
|
-
const dependencies = evidence.filter((e) => e.kind === "dependency").map((e) => e.value).slice(0, 10);
|
|
7814
|
-
const routes = dedupeRoutes(
|
|
7815
|
-
evidence.filter((e) => e.kind === "route").map((e) => e.value)
|
|
7816
|
-
).slice(0, 15);
|
|
7817
|
-
const textEvidence = evidence.filter(
|
|
7818
|
-
(e) => e.kind !== "dependency" && e.kind !== "route" && e.kind !== "feature_flag"
|
|
7819
|
-
);
|
|
7820
|
-
const byCategory = /* @__PURE__ */ new Map();
|
|
7821
|
-
const categoryCounts = {};
|
|
7822
|
-
for (const item of textEvidence) {
|
|
7823
|
-
const category = categorize(item.value);
|
|
7824
|
-
if (!byCategory.has(category)) {
|
|
7825
|
-
byCategory.set(category, /* @__PURE__ */ new Set());
|
|
7826
|
-
}
|
|
7827
|
-
const normalized = normalizeValue(item.value);
|
|
7828
|
-
if (normalized.length >= 3) {
|
|
7829
|
-
byCategory.get(category).add(normalized);
|
|
7830
|
-
}
|
|
7831
|
-
}
|
|
7832
|
-
const samples = [];
|
|
7833
|
-
for (const [category, values] of byCategory) {
|
|
7834
|
-
const deduped = dedupeStrings([...values]);
|
|
7835
|
-
categoryCounts[category] = deduped.length;
|
|
7836
|
-
for (const value of deduped.slice(0, maxSamplesPerCategory)) {
|
|
7837
|
-
samples.push({ kind: "text", value, category });
|
|
7838
|
-
}
|
|
7839
|
-
}
|
|
7840
|
-
const featureFlags = evidence.filter((e) => e.kind === "feature_flag");
|
|
7841
|
-
if (featureFlags.length > 0) {
|
|
7842
|
-
categoryCounts["feature_flags"] = featureFlags.length;
|
|
7843
|
-
samples.push({ kind: "feature_flag", value: "feature flags detected", category: "feature_flags" });
|
|
7844
|
-
}
|
|
7845
|
-
return {
|
|
7846
|
-
samples,
|
|
7847
|
-
categoryCounts,
|
|
7848
|
-
originalCount: evidence.length,
|
|
7849
|
-
dependencies,
|
|
7850
|
-
routes,
|
|
7851
|
-
detectedFrameworks: result.detectedFrameworks
|
|
7852
|
-
};
|
|
7853
|
-
}
|
|
7854
|
-
function categorize(value) {
|
|
7855
|
-
for (const { category, pattern } of CATEGORY_PATTERNS) {
|
|
7856
|
-
if (pattern.test(value)) return category;
|
|
7857
|
-
}
|
|
7858
|
-
return "general";
|
|
7859
|
-
}
|
|
7860
|
-
function normalizeValue(value) {
|
|
7861
|
-
return value.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").replace(/\s+/g, " ").trim().slice(0, 60);
|
|
7862
|
-
}
|
|
7863
|
-
function dedupeStrings(values) {
|
|
7864
|
-
const sorted = values.sort((a, b) => b.length - a.length);
|
|
7865
|
-
const kept = [];
|
|
7866
|
-
for (const value of sorted) {
|
|
7867
|
-
const isDupe = kept.some((k) => {
|
|
7868
|
-
const stem = value.slice(0, 6);
|
|
7869
|
-
return k.startsWith(stem) || k.includes(value) || value.includes(k);
|
|
7870
|
-
});
|
|
7871
|
-
if (!isDupe) {
|
|
7872
|
-
kept.push(value);
|
|
7873
|
-
}
|
|
7874
|
-
}
|
|
7875
|
-
return kept;
|
|
7876
|
-
}
|
|
7877
|
-
function dedupeRoutes(routes) {
|
|
7878
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7879
|
-
const result = [];
|
|
7880
|
-
for (const route of routes) {
|
|
7881
|
-
const normalized = route.replace(/:[a-z_]+/gi, ":param").replace(/\[\[*\.*\.*[a-z_]+\]*\]/gi, ":param").replace(/\/+$/, "").toLowerCase();
|
|
7882
|
-
if (!seen.has(normalized)) {
|
|
7883
|
-
seen.add(normalized);
|
|
7884
|
-
result.push(route);
|
|
7885
|
-
}
|
|
7886
|
-
}
|
|
7887
|
-
return result;
|
|
7888
|
-
}
|
|
7889
|
-
|
|
7890
8057
|
// src/utils/tool-installer.ts
|
|
7891
8058
|
import { spawn as spawn5 } from "child_process";
|
|
7892
8059
|
import chalk5 from "chalk";
|
|
@@ -8836,7 +9003,7 @@ async function autoPush(artifact, rootDir, opts) {
|
|
|
8836
9003
|
if (opts.strict) process.exit(1);
|
|
8837
9004
|
return;
|
|
8838
9005
|
}
|
|
8839
|
-
const body =
|
|
9006
|
+
const { body, contentEncoding } = await prepareCompressedUpload(artifact);
|
|
8840
9007
|
const timestamp = String(Date.now());
|
|
8841
9008
|
let host = parsed.host;
|
|
8842
9009
|
if (opts.region) {
|
|
@@ -8849,12 +9016,16 @@ async function autoPush(artifact, rootDir, opts) {
|
|
|
8849
9016
|
}
|
|
8850
9017
|
}
|
|
8851
9018
|
const url = `${parsed.scheme}://${host}/v1/ingest/scan`;
|
|
8852
|
-
|
|
9019
|
+
const originalSize = JSON.stringify(artifact).length;
|
|
9020
|
+
const compressedSize = body.length;
|
|
9021
|
+
const ratio = ((1 - compressedSize / originalSize) * 100).toFixed(0);
|
|
9022
|
+
console.log(chalk6.dim(`Uploading to ${host}... (${(compressedSize / 1024).toFixed(0)} KB, ${ratio}% smaller)`));
|
|
8853
9023
|
try {
|
|
8854
9024
|
const response = await fetch(url, {
|
|
8855
9025
|
method: "POST",
|
|
8856
9026
|
headers: {
|
|
8857
9027
|
"Content-Type": "application/json",
|
|
9028
|
+
"Content-Encoding": contentEncoding,
|
|
8858
9029
|
"X-Vibgrate-Timestamp": timestamp,
|
|
8859
9030
|
"Authorization": `VibgrateDSN ${parsed.keyId}:${parsed.secret}`,
|
|
8860
9031
|
"Connection": "close"
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
baselineCommand
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IHDUX5MC.js";
|
|
5
5
|
import {
|
|
6
6
|
VERSION,
|
|
7
7
|
dsnCommand,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
pushCommand,
|
|
11
11
|
scanCommand,
|
|
12
12
|
writeDefaultConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DMYMJUQP.js";
|
|
14
14
|
import {
|
|
15
15
|
ensureDir,
|
|
16
16
|
pathExists,
|
|
@@ -39,7 +39,7 @@ var initCommand = new Command("init").description("Initialize vibgrate in a proj
|
|
|
39
39
|
console.log(chalk.green("\u2714") + ` Created ${chalk.bold("vibgrate.config.ts")}`);
|
|
40
40
|
}
|
|
41
41
|
if (opts.baseline) {
|
|
42
|
-
const { runBaseline } = await import("./baseline-
|
|
42
|
+
const { runBaseline } = await import("./baseline-IEG2JITU.js");
|
|
43
43
|
await runBaseline(rootDir);
|
|
44
44
|
}
|
|
45
45
|
console.log("");
|
package/dist/index.js
CHANGED