react-doctor 0.5.2 → 0.5.3-dev.0b30023

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.
Files changed (4) hide show
  1. package/dist/cli.js +137 -49
  2. package/dist/index.js +131 -43
  3. package/dist/lsp.js +132 -44
  4. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="da49f5ad-b650-5a5f-b3dc-f9d554af8704")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7cac4c8f-fabe-50fb-942b-a3388562ae09")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -42571,42 +42571,74 @@ var Score = class Score extends Service()("react-doctor/Score") {
42571
42571
  }) }));
42572
42572
  static layerOf = (result) => succeed$3(Score, Score.of({ compute: () => succeed$2(result) }));
42573
42573
  };
42574
- const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
42574
+ const isControlCharacter = (codePoint) => codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
42575
+ const sanitizeTerminalText = (value) => {
42576
+ let sanitized = "";
42577
+ for (const character of value) {
42578
+ if (isControlCharacter(character.codePointAt(0) ?? 0)) continue;
42579
+ sanitized += character === "`" ? "'" : character;
42580
+ }
42581
+ return sanitized;
42582
+ };
42583
+ const SocketScoreSchema = Struct({
42575
42584
  overall: Number$1,
42576
42585
  license: Number$1,
42577
42586
  maintenance: Number$1,
42578
42587
  quality: Number$1,
42579
42588
  supplyChain: Number$1,
42580
42589
  vulnerability: Number$1
42581
- })) }));
42582
- const SCORE_AXES = [
42583
- {
42584
- key: "supplyChain",
42585
- label: "supply chain",
42586
- gates: true
42587
- },
42588
- {
42589
- key: "vulnerability",
42590
- label: "vulnerability",
42591
- gates: true
42592
- },
42590
+ });
42591
+ const SocketAlertSchema = Struct({
42592
+ type: String$1,
42593
+ severity: String$1,
42594
+ file: optional(NullOr(String$1)),
42595
+ props: optional(NullOr(Struct({ note: optional(NullOr(String$1)) })))
42596
+ });
42597
+ const SocketArtifactSchema = Struct({ score: optional(SocketScoreSchema) });
42598
+ const RawAlertsSchema = Struct({ alerts: optional(NullOr(ArraySchema(Unknown))) });
42599
+ const decodeArtifact = decodeUnknownOption(SocketArtifactSchema);
42600
+ const decodeRawAlerts = decodeUnknownOption(RawAlertsSchema);
42601
+ const decodeAlert = decodeUnknownOption(SocketAlertSchema);
42602
+ const extractAlerts = (parsed) => {
42603
+ const rawAlerts = getOrNull(decodeRawAlerts(parsed))?.alerts;
42604
+ if (!rawAlerts) return [];
42605
+ const alerts = [];
42606
+ for (const candidate of rawAlerts) {
42607
+ const alert = getOrNull(decodeAlert(candidate));
42608
+ if (alert !== null) alerts.push(alert);
42609
+ }
42610
+ return alerts;
42611
+ };
42612
+ const GATED_AXES = [{
42613
+ key: "supplyChain",
42614
+ label: "supply chain",
42615
+ guidance: {
42616
+ meaning: "risky install-time behavior — install scripts, obfuscated or native code, network/filesystem/shell access, or typosquatting",
42617
+ remediation: "Confirm this is the package you meant to install, and prefer a more established, audited alternative"
42618
+ }
42619
+ }, {
42620
+ key: "vulnerability",
42621
+ label: "vulnerability",
42622
+ guidance: {
42623
+ meaning: "known security vulnerabilities (CVEs) affecting this version",
42624
+ remediation: "Upgrade to a version with no known advisories (run `npm audit` to find one), or replace it"
42625
+ }
42626
+ }];
42627
+ const CONTEXT_AXES = [
42593
42628
  {
42594
42629
  key: "maintenance",
42595
- label: "maintenance",
42596
- gates: false
42630
+ label: "maintenance"
42597
42631
  },
42598
42632
  {
42599
42633
  key: "quality",
42600
- label: "quality",
42601
- gates: false
42634
+ label: "quality"
42602
42635
  },
42603
42636
  {
42604
42637
  key: "license",
42605
- label: "license",
42606
- gates: false
42638
+ label: "license"
42607
42639
  }
42608
42640
  ];
42609
- const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
42641
+ const SCORE_AXES = [...GATED_AXES, ...CONTEXT_AXES];
42610
42642
  const worstGatedAxis = (score) => {
42611
42643
  let worst = GATED_AXES[0];
42612
42644
  for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
@@ -42629,8 +42661,7 @@ const resolveConcreteVersion = (spec) => {
42629
42661
  const trimmed = spec.trim();
42630
42662
  if (trimmed.length === 0) return null;
42631
42663
  if (trimmed.includes(":")) return null;
42632
- const match = trimmed.match(/\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/);
42633
- return match ? match[0] : null;
42664
+ return import_semver.minVersion(trimmed)?.version ?? null;
42634
42665
  };
42635
42666
  const locateDependencyKey = (packageJsonText, section, name) => {
42636
42667
  const needle = `"${name}"`;
@@ -42714,7 +42745,7 @@ const collectMonorepoDependencies = (startDirectory, includeDevDependencies) =>
42714
42745
  return [...dependenciesByKey.values()];
42715
42746
  };
42716
42747
  const toPurl = (dependency) => `pkg:npm/${dependency.name}@${dependency.version}`;
42717
- const parseScoreFromBody = (body) => {
42748
+ const parseArtifactFromBody = (body) => {
42718
42749
  for (const line of body.split("\n")) {
42719
42750
  if (line.trim().length === 0) continue;
42720
42751
  let parsed;
@@ -42724,26 +42755,30 @@ const parseScoreFromBody = (body) => {
42724
42755
  continue;
42725
42756
  }
42726
42757
  const artifact = getOrNull(decodeArtifact(parsed));
42727
- if (artifact?.score) return artifact.score;
42758
+ if (artifact?.score) return {
42759
+ score: artifact.score,
42760
+ alerts: extractAlerts(parsed)
42761
+ };
42728
42762
  }
42729
42763
  return null;
42730
42764
  };
42731
- const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
42765
+ const fetchSocketArtifact = (dependency) => tryPromise(async (signal) => {
42732
42766
  const requestUrl = `${SOCKET_FREE_PURL_API_BASE}/${encodeURIComponent(toPurl(dependency))}`;
42733
42767
  const response = await fetch(requestUrl, {
42734
42768
  headers: { "User-Agent": SOCKET_FREE_USER_AGENT },
42735
42769
  signal
42736
42770
  });
42737
42771
  if (!response.ok) return null;
42738
- return parseScoreFromBody(await response.text());
42739
- }).pipe(timeout(FETCH_TIMEOUT_MS), orElseSucceed(() => null), tap$1((score) => {
42772
+ return parseArtifactFromBody(await response.text());
42773
+ }).pipe(timeout(FETCH_TIMEOUT_MS), orElseSucceed(() => null), tap$1((artifact) => {
42740
42774
  const scoreAttributes = {};
42741
- if (score !== null) {
42742
- scoreAttributes["socket.score.overall"] = toHundred(score.overall);
42743
- for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(score[axis.key]);
42775
+ if (artifact !== null) {
42776
+ scoreAttributes["socket.score.overall"] = toHundred(artifact.score.overall);
42777
+ for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(artifact.score[axis.key]);
42778
+ scoreAttributes["socket.alert.count"] = artifact.alerts.length;
42744
42779
  }
42745
42780
  return annotateCurrentSpan({
42746
- "socket.scored": score !== null,
42781
+ "socket.scored": artifact !== null,
42747
42782
  ...scoreAttributes
42748
42783
  });
42749
42784
  }), withSpan("SupplyChain.fetchScore", { attributes: {
@@ -42751,16 +42786,69 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
42751
42786
  "socket.version": dependency.version,
42752
42787
  "socket.purl": toPurl(dependency)
42753
42788
  } }));
42754
- const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
42755
- const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
42789
+ const formatOtherAxisScores = (score, failingKey) => SCORE_AXES.filter((axis) => axis.key !== failingKey).map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
42790
+ const ALERT_SEVERITY_RANK = {
42791
+ critical: 4,
42792
+ high: 3,
42793
+ middle: 2,
42794
+ medium: 2,
42795
+ low: 1
42796
+ };
42797
+ const severityRank = (severity) => ALERT_SEVERITY_RANK[severity.toLowerCase()] ?? 0;
42798
+ const displaySeverity = (severity) => {
42799
+ const normalized = sanitizeTerminalText(severity.toLowerCase());
42800
+ return normalized === "middle" ? "medium" : normalized;
42801
+ };
42802
+ const ALERT_TYPE_LABELS = {
42803
+ malware: "known malware",
42804
+ gptMalware: "AI-detected malware",
42805
+ gptSecurity: "AI-detected security risk",
42806
+ gptAnomaly: "AI-detected code anomaly",
42807
+ envVars: "environment-variable access",
42808
+ usesEval: "use of eval",
42809
+ troll: "protestware",
42810
+ didYouMean: "possible typosquat",
42811
+ typosquat: "possible typosquat"
42812
+ };
42813
+ const humanizeAlertType = (type) => type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
42814
+ const friendlyAlertType = (type) => ALERT_TYPE_LABELS[type] ?? sanitizeTerminalText(humanizeAlertType(type));
42815
+ const summarizeAlertNote = (note) => {
42816
+ const collapsed = sanitizeTerminalText(note.replace(/\s+/g, " ").trim());
42817
+ const firstSentence = collapsed.split(/(?<=\.)\s/)[0] || collapsed;
42818
+ if (firstSentence.length <= 160) return firstSentence.replace(/\.$/, "");
42819
+ return `${firstSentence.slice(0, 160).trimEnd()}…`;
42820
+ };
42821
+ const selectTopAlerts = (alerts) => [...alerts].sort((left, right) => severityRank(right.severity) - severityRank(left.severity)).slice(0, 3);
42822
+ const formatAlertReason = (topAlerts, totalCount) => {
42823
+ if (topAlerts.length === 1) {
42824
+ const [alert] = topAlerts;
42825
+ const location = alert.file ? ` in \`${sanitizeTerminalText(alert.file)}\`` : "";
42826
+ const note = alert.props?.note ? summarizeAlertNote(alert.props.note) : null;
42827
+ const detail = note ? `: "${note}"` : "";
42828
+ return `Socket flagged a ${displaySeverity(alert.severity)} ${friendlyAlertType(alert.type)} alert${location}${detail}.`;
42829
+ }
42830
+ return `Socket flagged ${totalCount} alerts (${topAlerts.map((alert) => friendlyAlertType(alert.type)).join(", ")}${totalCount > topAlerts.length ? ` (+${totalCount - topAlerts.length} more)` : ""}); most severe: ${displaySeverity(topAlerts[0].severity)}.`;
42831
+ };
42832
+ const formatDependencyIdentity = (dependency) => import_semver.valid(dependency.spec) !== null ? `${dependency.name}@${dependency.version}` : `${dependency.name}@${dependency.version} (lowest version "${dependency.spec}" allows)`;
42833
+ const buildSupplyChainHelp = (dependency, failingAxis, topAlerts, packagePageUrl, options) => {
42834
+ const hasCriticalAlert = topAlerts.some((alert) => alert.severity.toLowerCase() === "critical");
42835
+ const entry = `\`"${dependency.name}": "${dependency.spec}"\``;
42836
+ return `${hasCriticalAlert ? `Treat ${dependency.name} as compromised — do not ship it. Remove ${entry} from package.json and your lockfile, then audit anything it ran.` : `${failingAxis.guidance.remediation}; update ${entry} in package.json.`} Full report: ${packagePageUrl}. ${hasCriticalAlert ? `Only if you've confirmed this is a false positive, set \`supplyChain.enabled: false\`.` : `If you've reviewed and accepted this package, raise \`supplyChain.minScore\` (currently ${options.minScore}) or set \`supplyChain.severity: "warning"\`.`}`;
42837
+ };
42838
+ const buildLowScoreDiagnostic = (dependency, artifact, failingAxis, options) => {
42756
42839
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
42840
+ const failingScore = toHundred(artifact.score[failingAxis.key]);
42841
+ const topAlerts = selectTopAlerts(artifact.alerts);
42842
+ const reason = topAlerts.length > 0 ? formatAlertReason(topAlerts, artifact.alerts.length) : `This points to ${failingAxis.guidance.meaning}.`;
42843
+ const headline = `\`${formatDependencyIdentity(dependency)}\` scored ${failingScore}/100 on Socket's ${failingAxis.label} axis (minimum ${options.minScore}).`;
42844
+ const otherAxes = `Other axes — ${formatOtherAxisScores(artifact.score, failingAxis.key)}.`;
42757
42845
  return {
42758
42846
  filePath: "package.json",
42759
42847
  plugin: SUPPLY_CHAIN_PLUGIN,
42760
42848
  rule: SUPPLY_CHAIN_RULE,
42761
42849
  severity: options.severity,
42762
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
42763
- help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
42850
+ message: `${headline} ${reason} ${otherAxes}`,
42851
+ help: buildSupplyChainHelp(dependency, failingAxis, topAlerts, packagePageUrl, options),
42764
42852
  url: packagePageUrl,
42765
42853
  line: dependency.line,
42766
42854
  column: dependency.column,
@@ -42780,13 +42868,13 @@ const collectSupplyChainScores = (input) => gen(function* () {
42780
42868
  const options = resolveOptions(input.userConfig);
42781
42869
  const dependencies = collectMonorepoDependencies(input.rootDirectory, options.includeDevDependencies);
42782
42870
  if (dependencies.length === 0) return [];
42783
- const scores = yield* forEach$1(dependencies, fetchSocketScore, { concurrency: 8 });
42871
+ const artifacts = yield* forEach$1(dependencies, fetchSocketArtifact, { concurrency: 8 });
42784
42872
  return dependencies.map((dependency, index) => {
42785
- const score = scores[index];
42873
+ const artifact = artifacts[index];
42786
42874
  return {
42787
42875
  name: dependency.name,
42788
42876
  version: dependency.version,
42789
- overall: score ? toHundred(score.overall) : null
42877
+ overall: artifact ? toHundred(artifact.score.overall) : null
42790
42878
  };
42791
42879
  });
42792
42880
  });
@@ -42809,14 +42897,14 @@ const checkSupplyChain = (input) => gen(function* () {
42809
42897
  const packageJsonPath = Path.join(input.rootDirectory, "package.json");
42810
42898
  const dependencies = collectDependenciesToScore(readPackageJson$1(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
42811
42899
  if (dependencies.length === 0) return [];
42812
- const scores = yield* forEach$1(dependencies, fetchSocketScore, { concurrency: 8 });
42900
+ const artifacts = yield* forEach$1(dependencies, fetchSocketArtifact, { concurrency: 8 });
42813
42901
  const diagnostics = [];
42814
42902
  for (let index = 0; index < dependencies.length; index += 1) {
42815
- const score = scores[index];
42816
- if (!score) continue;
42817
- const worstAxis = worstGatedAxis(score);
42818
- if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
42819
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
42903
+ const artifact = artifacts[index];
42904
+ if (!artifact) continue;
42905
+ const worstAxis = worstGatedAxis(artifact.score);
42906
+ if (toHundred(artifact.score[worstAxis.key]) >= options.minScore) continue;
42907
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], artifact, worstAxis, options));
42820
42908
  }
42821
42909
  return diagnostics;
42822
42910
  });
@@ -43801,7 +43889,7 @@ const makeNoopConsole = () => ({
43801
43889
  });
43802
43890
  //#endregion
43803
43891
  //#region src/cli/utils/version.ts
43804
- const VERSION = "0.5.2";
43892
+ const VERSION = "0.5.3-dev.0b30023";
43805
43893
  //#endregion
43806
43894
  //#region src/cli/utils/json-mode.ts
43807
43895
  let context = null;
@@ -44159,13 +44247,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
44159
44247
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
44160
44248
  * standard `SENTRY_RELEASE` override.
44161
44249
  */
44162
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.2`;
44250
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.3-dev.0b30023`;
44163
44251
  /**
44164
44252
  * Deployment environment shown in Sentry's environment filter. Defaults to
44165
44253
  * `production` for tagged releases and `development` for dev/unbuilt versions,
44166
44254
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
44167
44255
  */
44168
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.2") ? "development" : "production");
44256
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.3-dev.0b30023") ? "development" : "production");
44169
44257
  /**
44170
44258
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
44171
44259
  * (set to `0` to disable tracing) and falls back to
@@ -53841,4 +53929,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
53841
53929
  export {};
53842
53930
 
53843
53931
  //# sourceMappingURL=cli.js.map
53844
- //# debugId=da49f5ad-b650-5a5f-b3dc-f9d554af8704
53932
+ //# debugId=7cac4c8f-fabe-50fb-942b-a3388562ae09
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5c0d7930-333e-5d67-93cf-63eae9bd87f8")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3f550091-4631-5201-b95e-820dcdff2adb")}catch(e){}}();
3
3
  import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import * as NFS from "node:fs";
@@ -39335,42 +39335,74 @@ var Score = class Score extends Service()("react-doctor/Score") {
39335
39335
  }) }));
39336
39336
  static layerOf = (result) => succeed$3(Score, Score.of({ compute: () => succeed$2(result) }));
39337
39337
  };
39338
- const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
39338
+ const isControlCharacter = (codePoint) => codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
39339
+ const sanitizeTerminalText = (value) => {
39340
+ let sanitized = "";
39341
+ for (const character of value) {
39342
+ if (isControlCharacter(character.codePointAt(0) ?? 0)) continue;
39343
+ sanitized += character === "`" ? "'" : character;
39344
+ }
39345
+ return sanitized;
39346
+ };
39347
+ const SocketScoreSchema = Struct({
39339
39348
  overall: Number$1,
39340
39349
  license: Number$1,
39341
39350
  maintenance: Number$1,
39342
39351
  quality: Number$1,
39343
39352
  supplyChain: Number$1,
39344
39353
  vulnerability: Number$1
39345
- })) }));
39346
- const SCORE_AXES = [
39347
- {
39348
- key: "supplyChain",
39349
- label: "supply chain",
39350
- gates: true
39351
- },
39352
- {
39353
- key: "vulnerability",
39354
- label: "vulnerability",
39355
- gates: true
39356
- },
39354
+ });
39355
+ const SocketAlertSchema = Struct({
39356
+ type: String$1,
39357
+ severity: String$1,
39358
+ file: optional(NullOr(String$1)),
39359
+ props: optional(NullOr(Struct({ note: optional(NullOr(String$1)) })))
39360
+ });
39361
+ const SocketArtifactSchema = Struct({ score: optional(SocketScoreSchema) });
39362
+ const RawAlertsSchema = Struct({ alerts: optional(NullOr(ArraySchema(Unknown))) });
39363
+ const decodeArtifact = decodeUnknownOption(SocketArtifactSchema);
39364
+ const decodeRawAlerts = decodeUnknownOption(RawAlertsSchema);
39365
+ const decodeAlert = decodeUnknownOption(SocketAlertSchema);
39366
+ const extractAlerts = (parsed) => {
39367
+ const rawAlerts = getOrNull(decodeRawAlerts(parsed))?.alerts;
39368
+ if (!rawAlerts) return [];
39369
+ const alerts = [];
39370
+ for (const candidate of rawAlerts) {
39371
+ const alert = getOrNull(decodeAlert(candidate));
39372
+ if (alert !== null) alerts.push(alert);
39373
+ }
39374
+ return alerts;
39375
+ };
39376
+ const GATED_AXES = [{
39377
+ key: "supplyChain",
39378
+ label: "supply chain",
39379
+ guidance: {
39380
+ meaning: "risky install-time behavior — install scripts, obfuscated or native code, network/filesystem/shell access, or typosquatting",
39381
+ remediation: "Confirm this is the package you meant to install, and prefer a more established, audited alternative"
39382
+ }
39383
+ }, {
39384
+ key: "vulnerability",
39385
+ label: "vulnerability",
39386
+ guidance: {
39387
+ meaning: "known security vulnerabilities (CVEs) affecting this version",
39388
+ remediation: "Upgrade to a version with no known advisories (run `npm audit` to find one), or replace it"
39389
+ }
39390
+ }];
39391
+ const CONTEXT_AXES = [
39357
39392
  {
39358
39393
  key: "maintenance",
39359
- label: "maintenance",
39360
- gates: false
39394
+ label: "maintenance"
39361
39395
  },
39362
39396
  {
39363
39397
  key: "quality",
39364
- label: "quality",
39365
- gates: false
39398
+ label: "quality"
39366
39399
  },
39367
39400
  {
39368
39401
  key: "license",
39369
- label: "license",
39370
- gates: false
39402
+ label: "license"
39371
39403
  }
39372
39404
  ];
39373
- const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
39405
+ const SCORE_AXES = [...GATED_AXES, ...CONTEXT_AXES];
39374
39406
  const worstGatedAxis = (score) => {
39375
39407
  let worst = GATED_AXES[0];
39376
39408
  for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
@@ -39393,8 +39425,7 @@ const resolveConcreteVersion = (spec) => {
39393
39425
  const trimmed = spec.trim();
39394
39426
  if (trimmed.length === 0) return null;
39395
39427
  if (trimmed.includes(":")) return null;
39396
- const match = trimmed.match(/\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/);
39397
- return match ? match[0] : null;
39428
+ return import_semver.minVersion(trimmed)?.version ?? null;
39398
39429
  };
39399
39430
  const locateDependencyKey = (packageJsonText, section, name) => {
39400
39431
  const needle = `"${name}"`;
@@ -39453,7 +39484,7 @@ const readPackageJsonText = (packageJsonPath) => {
39453
39484
  }
39454
39485
  };
39455
39486
  const toPurl = (dependency) => `pkg:npm/${dependency.name}@${dependency.version}`;
39456
- const parseScoreFromBody = (body) => {
39487
+ const parseArtifactFromBody = (body) => {
39457
39488
  for (const line of body.split("\n")) {
39458
39489
  if (line.trim().length === 0) continue;
39459
39490
  let parsed;
@@ -39463,26 +39494,30 @@ const parseScoreFromBody = (body) => {
39463
39494
  continue;
39464
39495
  }
39465
39496
  const artifact = getOrNull(decodeArtifact(parsed));
39466
- if (artifact?.score) return artifact.score;
39497
+ if (artifact?.score) return {
39498
+ score: artifact.score,
39499
+ alerts: extractAlerts(parsed)
39500
+ };
39467
39501
  }
39468
39502
  return null;
39469
39503
  };
39470
- const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
39504
+ const fetchSocketArtifact = (dependency) => tryPromise(async (signal) => {
39471
39505
  const requestUrl = `${SOCKET_FREE_PURL_API_BASE}/${encodeURIComponent(toPurl(dependency))}`;
39472
39506
  const response = await fetch(requestUrl, {
39473
39507
  headers: { "User-Agent": SOCKET_FREE_USER_AGENT },
39474
39508
  signal
39475
39509
  });
39476
39510
  if (!response.ok) return null;
39477
- return parseScoreFromBody(await response.text());
39478
- }).pipe(timeout(FETCH_TIMEOUT_MS), orElseSucceed(() => null), tap$1((score) => {
39511
+ return parseArtifactFromBody(await response.text());
39512
+ }).pipe(timeout(FETCH_TIMEOUT_MS), orElseSucceed(() => null), tap$1((artifact) => {
39479
39513
  const scoreAttributes = {};
39480
- if (score !== null) {
39481
- scoreAttributes["socket.score.overall"] = toHundred(score.overall);
39482
- for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(score[axis.key]);
39514
+ if (artifact !== null) {
39515
+ scoreAttributes["socket.score.overall"] = toHundred(artifact.score.overall);
39516
+ for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(artifact.score[axis.key]);
39517
+ scoreAttributes["socket.alert.count"] = artifact.alerts.length;
39483
39518
  }
39484
39519
  return annotateCurrentSpan({
39485
- "socket.scored": score !== null,
39520
+ "socket.scored": artifact !== null,
39486
39521
  ...scoreAttributes
39487
39522
  });
39488
39523
  }), withSpan("SupplyChain.fetchScore", { attributes: {
@@ -39490,16 +39525,69 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
39490
39525
  "socket.version": dependency.version,
39491
39526
  "socket.purl": toPurl(dependency)
39492
39527
  } }));
39493
- const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
39494
- const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
39528
+ const formatOtherAxisScores = (score, failingKey) => SCORE_AXES.filter((axis) => axis.key !== failingKey).map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
39529
+ const ALERT_SEVERITY_RANK = {
39530
+ critical: 4,
39531
+ high: 3,
39532
+ middle: 2,
39533
+ medium: 2,
39534
+ low: 1
39535
+ };
39536
+ const severityRank = (severity) => ALERT_SEVERITY_RANK[severity.toLowerCase()] ?? 0;
39537
+ const displaySeverity = (severity) => {
39538
+ const normalized = sanitizeTerminalText(severity.toLowerCase());
39539
+ return normalized === "middle" ? "medium" : normalized;
39540
+ };
39541
+ const ALERT_TYPE_LABELS = {
39542
+ malware: "known malware",
39543
+ gptMalware: "AI-detected malware",
39544
+ gptSecurity: "AI-detected security risk",
39545
+ gptAnomaly: "AI-detected code anomaly",
39546
+ envVars: "environment-variable access",
39547
+ usesEval: "use of eval",
39548
+ troll: "protestware",
39549
+ didYouMean: "possible typosquat",
39550
+ typosquat: "possible typosquat"
39551
+ };
39552
+ const humanizeAlertType = (type) => type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
39553
+ const friendlyAlertType = (type) => ALERT_TYPE_LABELS[type] ?? sanitizeTerminalText(humanizeAlertType(type));
39554
+ const summarizeAlertNote = (note) => {
39555
+ const collapsed = sanitizeTerminalText(note.replace(/\s+/g, " ").trim());
39556
+ const firstSentence = collapsed.split(/(?<=\.)\s/)[0] || collapsed;
39557
+ if (firstSentence.length <= 160) return firstSentence.replace(/\.$/, "");
39558
+ return `${firstSentence.slice(0, 160).trimEnd()}…`;
39559
+ };
39560
+ const selectTopAlerts = (alerts) => [...alerts].sort((left, right) => severityRank(right.severity) - severityRank(left.severity)).slice(0, 3);
39561
+ const formatAlertReason = (topAlerts, totalCount) => {
39562
+ if (topAlerts.length === 1) {
39563
+ const [alert] = topAlerts;
39564
+ const location = alert.file ? ` in \`${sanitizeTerminalText(alert.file)}\`` : "";
39565
+ const note = alert.props?.note ? summarizeAlertNote(alert.props.note) : null;
39566
+ const detail = note ? `: "${note}"` : "";
39567
+ return `Socket flagged a ${displaySeverity(alert.severity)} ${friendlyAlertType(alert.type)} alert${location}${detail}.`;
39568
+ }
39569
+ return `Socket flagged ${totalCount} alerts (${topAlerts.map((alert) => friendlyAlertType(alert.type)).join(", ")}${totalCount > topAlerts.length ? ` (+${totalCount - topAlerts.length} more)` : ""}); most severe: ${displaySeverity(topAlerts[0].severity)}.`;
39570
+ };
39571
+ const formatDependencyIdentity = (dependency) => import_semver.valid(dependency.spec) !== null ? `${dependency.name}@${dependency.version}` : `${dependency.name}@${dependency.version} (lowest version "${dependency.spec}" allows)`;
39572
+ const buildSupplyChainHelp = (dependency, failingAxis, topAlerts, packagePageUrl, options) => {
39573
+ const hasCriticalAlert = topAlerts.some((alert) => alert.severity.toLowerCase() === "critical");
39574
+ const entry = `\`"${dependency.name}": "${dependency.spec}"\``;
39575
+ return `${hasCriticalAlert ? `Treat ${dependency.name} as compromised — do not ship it. Remove ${entry} from package.json and your lockfile, then audit anything it ran.` : `${failingAxis.guidance.remediation}; update ${entry} in package.json.`} Full report: ${packagePageUrl}. ${hasCriticalAlert ? `Only if you've confirmed this is a false positive, set \`supplyChain.enabled: false\`.` : `If you've reviewed and accepted this package, raise \`supplyChain.minScore\` (currently ${options.minScore}) or set \`supplyChain.severity: "warning"\`.`}`;
39576
+ };
39577
+ const buildLowScoreDiagnostic = (dependency, artifact, failingAxis, options) => {
39495
39578
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
39579
+ const failingScore = toHundred(artifact.score[failingAxis.key]);
39580
+ const topAlerts = selectTopAlerts(artifact.alerts);
39581
+ const reason = topAlerts.length > 0 ? formatAlertReason(topAlerts, artifact.alerts.length) : `This points to ${failingAxis.guidance.meaning}.`;
39582
+ const headline = `\`${formatDependencyIdentity(dependency)}\` scored ${failingScore}/100 on Socket's ${failingAxis.label} axis (minimum ${options.minScore}).`;
39583
+ const otherAxes = `Other axes — ${formatOtherAxisScores(artifact.score, failingAxis.key)}.`;
39496
39584
  return {
39497
39585
  filePath: "package.json",
39498
39586
  plugin: SUPPLY_CHAIN_PLUGIN,
39499
39587
  rule: SUPPLY_CHAIN_RULE,
39500
39588
  severity: options.severity,
39501
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
39502
- help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
39589
+ message: `${headline} ${reason} ${otherAxes}`,
39590
+ help: buildSupplyChainHelp(dependency, failingAxis, topAlerts, packagePageUrl, options),
39503
39591
  url: packagePageUrl,
39504
39592
  line: dependency.line,
39505
39593
  column: dependency.column,
@@ -39525,14 +39613,14 @@ const checkSupplyChain = (input) => gen(function* () {
39525
39613
  const packageJsonPath = Path.join(input.rootDirectory, "package.json");
39526
39614
  const dependencies = collectDependenciesToScore(readPackageJson(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
39527
39615
  if (dependencies.length === 0) return [];
39528
- const scores = yield* forEach$1(dependencies, fetchSocketScore, { concurrency: 8 });
39616
+ const artifacts = yield* forEach$1(dependencies, fetchSocketArtifact, { concurrency: 8 });
39529
39617
  const diagnostics = [];
39530
39618
  for (let index = 0; index < dependencies.length; index += 1) {
39531
- const score = scores[index];
39532
- if (!score) continue;
39533
- const worstAxis = worstGatedAxis(score);
39534
- if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
39535
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
39619
+ const artifact = artifacts[index];
39620
+ if (!artifact) continue;
39621
+ const worstAxis = worstGatedAxis(artifact.score);
39622
+ if (toHundred(artifact.score[worstAxis.key]) >= options.minScore) continue;
39623
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], artifact, worstAxis, options));
39536
39624
  }
39537
39625
  return diagnostics;
39538
39626
  });
@@ -40354,4 +40442,4 @@ const toJsonReport = (result, options) => buildJsonReport({
40354
40442
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
40355
40443
 
40356
40444
  //# sourceMappingURL=index.js.map
40357
- //# debugId=5c0d7930-333e-5d67-93cf-63eae9bd87f8
40445
+ //# debugId=3f550091-4631-5201-b95e-820dcdff2adb
package/dist/lsp.js CHANGED
@@ -39321,42 +39321,74 @@ var Score = class Score extends Service()("react-doctor/Score") {
39321
39321
  }) }));
39322
39322
  static layerOf = (result) => succeed$3(Score, Score.of({ compute: () => succeed$2(result) }));
39323
39323
  };
39324
- const decodeArtifact = decodeUnknownOption(Struct({ score: optional(Struct({
39324
+ const isControlCharacter = (codePoint) => codePoint <= 31 || codePoint >= 127 && codePoint <= 159;
39325
+ const sanitizeTerminalText = (value) => {
39326
+ let sanitized = "";
39327
+ for (const character of value) {
39328
+ if (isControlCharacter(character.codePointAt(0) ?? 0)) continue;
39329
+ sanitized += character === "`" ? "'" : character;
39330
+ }
39331
+ return sanitized;
39332
+ };
39333
+ const SocketScoreSchema = Struct({
39325
39334
  overall: Number$1,
39326
39335
  license: Number$1,
39327
39336
  maintenance: Number$1,
39328
39337
  quality: Number$1,
39329
39338
  supplyChain: Number$1,
39330
39339
  vulnerability: Number$1
39331
- })) }));
39332
- const SCORE_AXES = [
39333
- {
39334
- key: "supplyChain",
39335
- label: "supply chain",
39336
- gates: true
39337
- },
39338
- {
39339
- key: "vulnerability",
39340
- label: "vulnerability",
39341
- gates: true
39342
- },
39340
+ });
39341
+ const SocketAlertSchema = Struct({
39342
+ type: String$1,
39343
+ severity: String$1,
39344
+ file: optional(NullOr(String$1)),
39345
+ props: optional(NullOr(Struct({ note: optional(NullOr(String$1)) })))
39346
+ });
39347
+ const SocketArtifactSchema = Struct({ score: optional(SocketScoreSchema) });
39348
+ const RawAlertsSchema = Struct({ alerts: optional(NullOr(ArraySchema(Unknown))) });
39349
+ const decodeArtifact = decodeUnknownOption(SocketArtifactSchema);
39350
+ const decodeRawAlerts = decodeUnknownOption(RawAlertsSchema);
39351
+ const decodeAlert = decodeUnknownOption(SocketAlertSchema);
39352
+ const extractAlerts = (parsed) => {
39353
+ const rawAlerts = getOrNull(decodeRawAlerts(parsed))?.alerts;
39354
+ if (!rawAlerts) return [];
39355
+ const alerts = [];
39356
+ for (const candidate of rawAlerts) {
39357
+ const alert = getOrNull(decodeAlert(candidate));
39358
+ if (alert !== null) alerts.push(alert);
39359
+ }
39360
+ return alerts;
39361
+ };
39362
+ const GATED_AXES = [{
39363
+ key: "supplyChain",
39364
+ label: "supply chain",
39365
+ guidance: {
39366
+ meaning: "risky install-time behavior — install scripts, obfuscated or native code, network/filesystem/shell access, or typosquatting",
39367
+ remediation: "Confirm this is the package you meant to install, and prefer a more established, audited alternative"
39368
+ }
39369
+ }, {
39370
+ key: "vulnerability",
39371
+ label: "vulnerability",
39372
+ guidance: {
39373
+ meaning: "known security vulnerabilities (CVEs) affecting this version",
39374
+ remediation: "Upgrade to a version with no known advisories (run `npm audit` to find one), or replace it"
39375
+ }
39376
+ }];
39377
+ const CONTEXT_AXES = [
39343
39378
  {
39344
39379
  key: "maintenance",
39345
- label: "maintenance",
39346
- gates: false
39380
+ label: "maintenance"
39347
39381
  },
39348
39382
  {
39349
39383
  key: "quality",
39350
- label: "quality",
39351
- gates: false
39384
+ label: "quality"
39352
39385
  },
39353
39386
  {
39354
39387
  key: "license",
39355
- label: "license",
39356
- gates: false
39388
+ label: "license"
39357
39389
  }
39358
39390
  ];
39359
- const GATED_AXES = SCORE_AXES.filter((axis) => axis.gates);
39391
+ const SCORE_AXES = [...GATED_AXES, ...CONTEXT_AXES];
39360
39392
  const worstGatedAxis = (score) => {
39361
39393
  let worst = GATED_AXES[0];
39362
39394
  for (const axis of GATED_AXES) if (score[axis.key] < score[worst.key]) worst = axis;
@@ -39379,8 +39411,7 @@ const resolveConcreteVersion = (spec) => {
39379
39411
  const trimmed = spec.trim();
39380
39412
  if (trimmed.length === 0) return null;
39381
39413
  if (trimmed.includes(":")) return null;
39382
- const match = trimmed.match(/\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/);
39383
- return match ? match[0] : null;
39414
+ return import_semver.minVersion(trimmed)?.version ?? null;
39384
39415
  };
39385
39416
  const locateDependencyKey = (packageJsonText, section, name) => {
39386
39417
  const needle = `"${name}"`;
@@ -39439,7 +39470,7 @@ const readPackageJsonText = (packageJsonPath) => {
39439
39470
  }
39440
39471
  };
39441
39472
  const toPurl = (dependency) => `pkg:npm/${dependency.name}@${dependency.version}`;
39442
- const parseScoreFromBody = (body) => {
39473
+ const parseArtifactFromBody = (body) => {
39443
39474
  for (const line of body.split("\n")) {
39444
39475
  if (line.trim().length === 0) continue;
39445
39476
  let parsed;
@@ -39449,26 +39480,30 @@ const parseScoreFromBody = (body) => {
39449
39480
  continue;
39450
39481
  }
39451
39482
  const artifact = getOrNull(decodeArtifact(parsed));
39452
- if (artifact?.score) return artifact.score;
39483
+ if (artifact?.score) return {
39484
+ score: artifact.score,
39485
+ alerts: extractAlerts(parsed)
39486
+ };
39453
39487
  }
39454
39488
  return null;
39455
39489
  };
39456
- const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
39490
+ const fetchSocketArtifact = (dependency) => tryPromise(async (signal) => {
39457
39491
  const requestUrl = `${SOCKET_FREE_PURL_API_BASE}/${encodeURIComponent(toPurl(dependency))}`;
39458
39492
  const response = await fetch(requestUrl, {
39459
39493
  headers: { "User-Agent": SOCKET_FREE_USER_AGENT },
39460
39494
  signal
39461
39495
  });
39462
39496
  if (!response.ok) return null;
39463
- return parseScoreFromBody(await response.text());
39464
- }).pipe(timeout(FETCH_TIMEOUT_MS), orElseSucceed(() => null), tap$1((score) => {
39497
+ return parseArtifactFromBody(await response.text());
39498
+ }).pipe(timeout(FETCH_TIMEOUT_MS), orElseSucceed(() => null), tap$1((artifact) => {
39465
39499
  const scoreAttributes = {};
39466
- if (score !== null) {
39467
- scoreAttributes["socket.score.overall"] = toHundred(score.overall);
39468
- for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(score[axis.key]);
39500
+ if (artifact !== null) {
39501
+ scoreAttributes["socket.score.overall"] = toHundred(artifact.score.overall);
39502
+ for (const axis of SCORE_AXES) scoreAttributes[`socket.score.${axis.key}`] = toHundred(artifact.score[axis.key]);
39503
+ scoreAttributes["socket.alert.count"] = artifact.alerts.length;
39469
39504
  }
39470
39505
  return annotateCurrentSpan({
39471
- "socket.scored": score !== null,
39506
+ "socket.scored": artifact !== null,
39472
39507
  ...scoreAttributes
39473
39508
  });
39474
39509
  }), withSpan("SupplyChain.fetchScore", { attributes: {
@@ -39476,16 +39511,69 @@ const fetchSocketScore = (dependency) => tryPromise(async (signal) => {
39476
39511
  "socket.version": dependency.version,
39477
39512
  "socket.purl": toPurl(dependency)
39478
39513
  } }));
39479
- const formatAxisScores = (score) => SCORE_AXES.map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
39480
- const buildLowScoreDiagnostic = (dependency, score, failingAxis, options) => {
39514
+ const formatOtherAxisScores = (score, failingKey) => SCORE_AXES.filter((axis) => axis.key !== failingKey).map((axis) => `${axis.label} ${toHundred(score[axis.key])}`).join(", ");
39515
+ const ALERT_SEVERITY_RANK = {
39516
+ critical: 4,
39517
+ high: 3,
39518
+ middle: 2,
39519
+ medium: 2,
39520
+ low: 1
39521
+ };
39522
+ const severityRank = (severity) => ALERT_SEVERITY_RANK[severity.toLowerCase()] ?? 0;
39523
+ const displaySeverity = (severity) => {
39524
+ const normalized = sanitizeTerminalText(severity.toLowerCase());
39525
+ return normalized === "middle" ? "medium" : normalized;
39526
+ };
39527
+ const ALERT_TYPE_LABELS = {
39528
+ malware: "known malware",
39529
+ gptMalware: "AI-detected malware",
39530
+ gptSecurity: "AI-detected security risk",
39531
+ gptAnomaly: "AI-detected code anomaly",
39532
+ envVars: "environment-variable access",
39533
+ usesEval: "use of eval",
39534
+ troll: "protestware",
39535
+ didYouMean: "possible typosquat",
39536
+ typosquat: "possible typosquat"
39537
+ };
39538
+ const humanizeAlertType = (type) => type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
39539
+ const friendlyAlertType = (type) => ALERT_TYPE_LABELS[type] ?? sanitizeTerminalText(humanizeAlertType(type));
39540
+ const summarizeAlertNote = (note) => {
39541
+ const collapsed = sanitizeTerminalText(note.replace(/\s+/g, " ").trim());
39542
+ const firstSentence = collapsed.split(/(?<=\.)\s/)[0] || collapsed;
39543
+ if (firstSentence.length <= 160) return firstSentence.replace(/\.$/, "");
39544
+ return `${firstSentence.slice(0, 160).trimEnd()}…`;
39545
+ };
39546
+ const selectTopAlerts = (alerts) => [...alerts].sort((left, right) => severityRank(right.severity) - severityRank(left.severity)).slice(0, 3);
39547
+ const formatAlertReason = (topAlerts, totalCount) => {
39548
+ if (topAlerts.length === 1) {
39549
+ const [alert] = topAlerts;
39550
+ const location = alert.file ? ` in \`${sanitizeTerminalText(alert.file)}\`` : "";
39551
+ const note = alert.props?.note ? summarizeAlertNote(alert.props.note) : null;
39552
+ const detail = note ? `: "${note}"` : "";
39553
+ return `Socket flagged a ${displaySeverity(alert.severity)} ${friendlyAlertType(alert.type)} alert${location}${detail}.`;
39554
+ }
39555
+ return `Socket flagged ${totalCount} alerts (${topAlerts.map((alert) => friendlyAlertType(alert.type)).join(", ")}${totalCount > topAlerts.length ? ` (+${totalCount - topAlerts.length} more)` : ""}); most severe: ${displaySeverity(topAlerts[0].severity)}.`;
39556
+ };
39557
+ const formatDependencyIdentity = (dependency) => import_semver.valid(dependency.spec) !== null ? `${dependency.name}@${dependency.version}` : `${dependency.name}@${dependency.version} (lowest version "${dependency.spec}" allows)`;
39558
+ const buildSupplyChainHelp = (dependency, failingAxis, topAlerts, packagePageUrl, options) => {
39559
+ const hasCriticalAlert = topAlerts.some((alert) => alert.severity.toLowerCase() === "critical");
39560
+ const entry = `\`"${dependency.name}": "${dependency.spec}"\``;
39561
+ return `${hasCriticalAlert ? `Treat ${dependency.name} as compromised — do not ship it. Remove ${entry} from package.json and your lockfile, then audit anything it ran.` : `${failingAxis.guidance.remediation}; update ${entry} in package.json.`} Full report: ${packagePageUrl}. ${hasCriticalAlert ? `Only if you've confirmed this is a false positive, set \`supplyChain.enabled: false\`.` : `If you've reviewed and accepted this package, raise \`supplyChain.minScore\` (currently ${options.minScore}) or set \`supplyChain.severity: "warning"\`.`}`;
39562
+ };
39563
+ const buildLowScoreDiagnostic = (dependency, artifact, failingAxis, options) => {
39481
39564
  const packagePageUrl = `${SOCKET_PACKAGE_PAGE_BASE}/${dependency.name}/overview/${dependency.version}`;
39565
+ const failingScore = toHundred(artifact.score[failingAxis.key]);
39566
+ const topAlerts = selectTopAlerts(artifact.alerts);
39567
+ const reason = topAlerts.length > 0 ? formatAlertReason(topAlerts, artifact.alerts.length) : `This points to ${failingAxis.guidance.meaning}.`;
39568
+ const headline = `\`${formatDependencyIdentity(dependency)}\` scored ${failingScore}/100 on Socket's ${failingAxis.label} axis (minimum ${options.minScore}).`;
39569
+ const otherAxes = `Other axes — ${formatOtherAxisScores(artifact.score, failingAxis.key)}.`;
39482
39570
  return {
39483
39571
  filePath: "package.json",
39484
39572
  plugin: SUPPLY_CHAIN_PLUGIN,
39485
39573
  rule: SUPPLY_CHAIN_RULE,
39486
39574
  severity: options.severity,
39487
- message: `\`${dependency.name}\` (declared in package.json as "${dependency.spec}", scored at ${dependency.version}) has a Socket ${failingAxis.label} score of ${toHundred(score[failingAxis.key])}/100 (below the minimum of ${options.minScore}). Axis scores — ${formatAxisScores(score)}.`,
39488
- help: `Update or replace the \`"${dependency.name}": "${dependency.spec}"\` entry in package.json. Review ${dependency.name} on Socket: ${packagePageUrl}. Or raise \`supplyChain.minScore\` if you have vetted and accepted this package.`,
39575
+ message: `${headline} ${reason} ${otherAxes}`,
39576
+ help: buildSupplyChainHelp(dependency, failingAxis, topAlerts, packagePageUrl, options),
39489
39577
  url: packagePageUrl,
39490
39578
  line: dependency.line,
39491
39579
  column: dependency.column,
@@ -39511,14 +39599,14 @@ const checkSupplyChain = (input) => gen(function* () {
39511
39599
  const packageJsonPath = Path.join(input.rootDirectory, "package.json");
39512
39600
  const dependencies = collectDependenciesToScore(readPackageJson(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
39513
39601
  if (dependencies.length === 0) return [];
39514
- const scores = yield* forEach$1(dependencies, fetchSocketScore, { concurrency: 8 });
39602
+ const artifacts = yield* forEach$1(dependencies, fetchSocketArtifact, { concurrency: 8 });
39515
39603
  const diagnostics = [];
39516
39604
  for (let index = 0; index < dependencies.length; index += 1) {
39517
- const score = scores[index];
39518
- if (!score) continue;
39519
- const worstAxis = worstGatedAxis(score);
39520
- if (toHundred(score[worstAxis.key]) >= options.minScore) continue;
39521
- diagnostics.push(buildLowScoreDiagnostic(dependencies[index], score, worstAxis, options));
39605
+ const artifact = artifacts[index];
39606
+ if (!artifact) continue;
39607
+ const worstAxis = worstGatedAxis(artifact.score);
39608
+ if (toHundred(artifact.score[worstAxis.key]) >= options.minScore) continue;
39609
+ diagnostics.push(buildLowScoreDiagnostic(dependencies[index], artifact, worstAxis, options));
39522
39610
  }
39523
39611
  return diagnostics;
39524
39612
  });
@@ -40092,7 +40180,7 @@ const computeConfigFingerprint = (projectDirectory, version) => {
40092
40180
  /** Display name used in client-facing messages and progress titles. */
40093
40181
  const SERVER_DISPLAY_NAME = "React Doctor";
40094
40182
  /** Server version reported in `serverInfo`; injected at build, `dev` from source. */
40095
- const SERVER_VERSION = "0.5.2";
40183
+ const SERVER_VERSION = "0.5.3";
40096
40184
  /** `Diagnostic.source` shown next to every published diagnostic. */
40097
40185
  const DIAGNOSTIC_SOURCE = "react-doctor";
40098
40186
  /**
@@ -42139,5 +42227,5 @@ const startLanguageServer = () => {
42139
42227
  };
42140
42228
  //#endregion
42141
42229
  export { startLanguageServer };
42142
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f84d06b3-b31c-5442-9457-b108cbc3cbbe")}catch(e){}}();
42143
- //# debugId=f84d06b3-b31c-5442-9457-b108cbc3cbbe
42230
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a3210985-4696-51c7-ad17-523eb171ecce")}catch(e){}}();
42231
+ //# debugId=a3210985-4696-51c7-ad17-523eb171ecce
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-dev.0b30023",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -64,7 +64,7 @@
64
64
  "vscode-languageserver": "^9.0.1",
65
65
  "vscode-languageserver-textdocument": "^1.0.12",
66
66
  "vscode-uri": "^3.1.0",
67
- "oxlint-plugin-react-doctor": "0.5.2"
67
+ "oxlint-plugin-react-doctor": "0.5.3-dev.0b30023"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/babel__code-frame": "^7.27.0",
@@ -72,9 +72,9 @@
72
72
  "@xterm/headless": "^6.0.0",
73
73
  "commander": "^14.0.3",
74
74
  "ora": "^9.4.0",
75
- "@react-doctor/api": "0.5.2",
76
- "@react-doctor/core": "0.5.2",
77
- "@react-doctor/language-server": "0.5.2"
75
+ "@react-doctor/language-server": "0.5.3",
76
+ "@react-doctor/core": "0.5.3",
77
+ "@react-doctor/api": "0.5.3"
78
78
  },
79
79
  "engines": {
80
80
  "node": "^20.19.0 || >=22.13.0"