@runsec/mcp 1.0.78 → 1.0.79

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 (2) hide show
  1. package/dist/index.js +57 -8
  2. package/package.json +4 -2
package/dist/index.js CHANGED
@@ -3093,7 +3093,7 @@ async function runUnifiedScanPipeline(opts) {
3093
3093
  `[runsec] unified scan: engines=${concurrent_duration_ms}ms merge+cognitive=${merge_duration_ms}ms | raw=${allRaw.length} primary=${findings.length} suppressed_cognitive=${findings_suppressed.length}`
3094
3094
  );
3095
3095
  console.error(
3096
- `[runsec] X-RunSec-Verdict: ${cognitiveResult.verdict.http_headers["X-RunSec-Verdict"]} (blocking=${cognitiveResult.verdict.blocking_findings_count})`
3096
+ `[runsec] @runsec/mcp cognitive complete | X-RunSec-Verdict: ${cognitiveResult.verdict.http_headers["X-RunSec-Verdict"]} | primary=${findings.length} suppressed=${findings_suppressed.length} blocking=${cognitiveResult.verdict.blocking_findings_count}`
3097
3097
  );
3098
3098
  return {
3099
3099
  standard,
@@ -5823,8 +5823,10 @@ function isRemediationTool(name) {
5823
5823
  }
5824
5824
 
5825
5825
  // src/hubUploadUrl.ts
5826
+ var import_node_fs17 = __toESM(require("fs"));
5826
5827
  var HUB_UPLOAD_REPORT_PATH = "/api/mcp/upload-report";
5827
5828
  var DEFAULT_PRODUCTION_HUB_ORIGIN = "https://runsec.io";
5829
+ var DEFAULT_DOCKER_INTERNAL_HUB_ORIGIN = "http://frontend:3000";
5828
5830
  var LEGACY_TELEMETRY_INGEST_PATH = "/api/v1/telemetry/ingest";
5829
5831
  function stripTrailingSlash(url) {
5830
5832
  return url.replace(/\/$/, "");
@@ -5856,11 +5858,24 @@ function colocatedHubOrigin() {
5856
5858
  if (!port || !/^\d+$/.test(port)) return null;
5857
5859
  return `http://127.0.0.1:${port}`;
5858
5860
  }
5861
+ function isDockerRuntime() {
5862
+ try {
5863
+ return import_node_fs17.default.existsSync("/.dockerenv");
5864
+ } catch {
5865
+ return false;
5866
+ }
5867
+ }
5868
+ function resolveDockerInternalHubOrigin() {
5869
+ return stripTrailingSlash(
5870
+ process.env.RUNSEC_HUB_INTERNAL_URL?.trim() || process.env.FRONTEND_INTERNAL_URL?.trim() || DEFAULT_DOCKER_INTERNAL_HUB_ORIGIN
5871
+ );
5872
+ }
5859
5873
  function resolveHubBaseUrl() {
5860
5874
  const candidates = [
5861
5875
  process.env.RUNSEC_HUB_URL,
5862
5876
  process.env.RUNSEC_API_URL,
5863
5877
  process.env.RUNSEC_HUB_ORIGIN,
5878
+ process.env.RUNSEC_HUB_INTERNAL_URL,
5864
5879
  process.env.NEXT_PUBLIC_APP_URL,
5865
5880
  process.env.PUBLIC_APP_URL,
5866
5881
  process.env.NEXTAUTH_URL,
@@ -5871,6 +5886,13 @@ function resolveHubBaseUrl() {
5871
5886
  if (candidates.length > 0) {
5872
5887
  return stripTrailingSlash(migrateLegacyIngestUrl(candidates[0]));
5873
5888
  }
5889
+ if (isDockerRuntime()) {
5890
+ const internal = resolveDockerInternalHubOrigin();
5891
+ console.error(
5892
+ `[runsec] Docker runtime \u2014 Hub upload via internal origin ${internal} (set RUNSEC_HUB_URL to override)`
5893
+ );
5894
+ return internal;
5895
+ }
5874
5896
  if (isProductionRuntime()) {
5875
5897
  const colocated = colocatedHubOrigin();
5876
5898
  if (colocated) {
@@ -5910,6 +5932,20 @@ function localhostAlternateUploadUrl(url) {
5910
5932
  return null;
5911
5933
  }
5912
5934
  }
5935
+ function dockerInternalAlternateUploadUrl(url) {
5936
+ if (!isDockerRuntime()) return null;
5937
+ try {
5938
+ const parsed = new URL(url);
5939
+ const internal = new URL(resolveDockerInternalHubOrigin());
5940
+ if (parsed.origin === internal.origin) return null;
5941
+ internal.pathname = HUB_UPLOAD_REPORT_PATH;
5942
+ internal.search = "";
5943
+ internal.hash = "";
5944
+ return internal.toString();
5945
+ } catch {
5946
+ return appendUploadPath(resolveDockerInternalHubOrigin());
5947
+ }
5948
+ }
5913
5949
 
5914
5950
  // src/complianceScores.ts
5915
5951
  var SEVERITY_PENALTY = {
@@ -6085,14 +6121,27 @@ async function uploadScanResultsToHub(payload, apiKey) {
6085
6121
  const url = resolveHubUploadUrl();
6086
6122
  console.error(`[runsec] Hub telemetry upload \u2192 ${url}`);
6087
6123
  const attemptUpload = async (targetUrl) => {
6088
- try {
6089
- return await postHubUpload(targetUrl, trimmedKey, payload);
6090
- } catch (firstError) {
6091
- const alt = localhostAlternateUploadUrl(targetUrl);
6092
- if (!alt || alt === targetUrl) throw firstError;
6093
- console.error(`[runsec] Hub telemetry retry \u2192 ${alt}`);
6094
- return await postHubUpload(alt, trimmedKey, payload);
6124
+ const errors = [];
6125
+ const urls = [targetUrl];
6126
+ const localhostAlt = localhostAlternateUploadUrl(targetUrl);
6127
+ if (localhostAlt && localhostAlt !== targetUrl) urls.push(localhostAlt);
6128
+ const dockerAlt = dockerInternalAlternateUploadUrl(targetUrl);
6129
+ if (dockerAlt && !urls.includes(dockerAlt)) urls.push(dockerAlt);
6130
+ let lastError = new Error("No upload attempts made");
6131
+ for (let i = 0; i < urls.length; i++) {
6132
+ const tryUrl = urls[i];
6133
+ if (i > 0) {
6134
+ console.error(`[runsec] Hub telemetry retry \u2192 ${tryUrl}`);
6135
+ }
6136
+ try {
6137
+ return await postHubUpload(tryUrl, trimmedKey, payload);
6138
+ } catch (err) {
6139
+ lastError = err;
6140
+ errors.push(err);
6141
+ dumpHubNetworkError(err, tryUrl);
6142
+ }
6095
6143
  }
6144
+ throw lastError;
6096
6145
  };
6097
6146
  try {
6098
6147
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runsec/mcp",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -30,7 +30,9 @@
30
30
  "test": "vitest run",
31
31
  "test:gold": "tsx scripts/qaValidationReport.ts",
32
32
  "test:gold:parse": "tsx scripts/qaValidationReport.ts --parse-only",
33
- "simulate:output": "tsx scripts/simulate_output.ts"
33
+ "simulate:output": "tsx scripts/simulate_output.ts",
34
+ "debug:pipeline": "tsx scripts/debug-pipeline.ts",
35
+ "test:e2e": "npm run build && tsx scripts/debug-pipeline.ts"
34
36
  },
35
37
  "keywords": [
36
38
  "mcp",