@runsec/mcp 1.0.1 → 1.0.2

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 (40) hide show
  1. package/dist/index.js +20 -6
  2. package/package.json +3 -4
  3. /package/{src/rules → dist}/data/rule-compliance-map.json +0 -0
  4. /package/{src/rules → dist}/data/semgrep-rules/README-taint-overlays.md +0 -0
  5. /package/{src/rules → dist}/data/semgrep-rules/advanced-agent-cloud.yaml +0 -0
  6. /package/{src/rules → dist}/data/semgrep-rules/app-logic.yaml +0 -0
  7. /package/{src/rules → dist}/data/semgrep-rules/auth-keycloak.yaml +0 -0
  8. /package/{src/rules → dist}/data/semgrep-rules/browser-agent.yaml +0 -0
  9. /package/{src/rules → dist}/data/semgrep-rules/cloud-secrets.yaml +0 -0
  10. /package/{src/rules → dist}/data/semgrep-rules/csharp-dotnet.yaml +0 -0
  11. /package/{src/rules → dist}/data/semgrep-rules/desktop-electron-pro.yaml +0 -0
  12. /package/{src/rules → dist}/data/semgrep-rules/desktop-vsto-suite.yaml +0 -0
  13. /package/{src/rules → dist}/data/semgrep-rules/devops-security.yaml +0 -0
  14. /package/{src/rules → dist}/data/semgrep-rules/domain-access-management.yaml +0 -0
  15. /package/{src/rules → dist}/data/semgrep-rules/domain-data-privacy.yaml +0 -0
  16. /package/{src/rules → dist}/data/semgrep-rules/domain-input-validation.yaml +0 -0
  17. /package/{src/rules → dist}/data/semgrep-rules/domain-platform-hardening.yaml +0 -0
  18. /package/{src/rules → dist}/data/semgrep-rules/ds-ml-security.yaml +0 -0
  19. /package/{src/rules → dist}/data/semgrep-rules/fastapi-async.yaml +0 -0
  20. /package/{src/rules → dist}/data/semgrep-rules/frontend-react.yaml +0 -0
  21. /package/{src/rules → dist}/data/semgrep-rules/frontend-security.yaml +0 -0
  22. /package/{src/rules → dist}/data/semgrep-rules/go-core.yaml +0 -0
  23. /package/{src/rules → dist}/data/semgrep-rules/hft-cpp-security.yaml +0 -0
  24. /package/{src/rules → dist}/data/semgrep-rules/infra-k8s-helm.yaml +0 -0
  25. /package/{src/rules → dist}/data/semgrep-rules/integration-security.yaml +0 -0
  26. /package/{src/rules → dist}/data/semgrep-rules/java-enterprise.yaml +0 -0
  27. /package/{src/rules → dist}/data/semgrep-rules/java-spring.yaml +0 -0
  28. /package/{src/rules → dist}/data/semgrep-rules/license-compliance.yaml +0 -0
  29. /package/{src/rules → dist}/data/semgrep-rules/mobile-flutter.yaml +0 -0
  30. /package/{src/rules → dist}/data/semgrep-rules/mobile-security.yaml +0 -0
  31. /package/{src/rules → dist}/data/semgrep-rules/nodejs-nestjs.yaml +0 -0
  32. /package/{src/rules → dist}/data/semgrep-rules/nodejs-security.yaml +0 -0
  33. /package/{src/rules → dist}/data/semgrep-rules/observability.yaml +0 -0
  34. /package/{src/rules → dist}/data/semgrep-rules/php-security.yaml +0 -0
  35. /package/{src/rules → dist}/data/semgrep-rules/python-backend-pro.yaml +0 -0
  36. /package/{src/rules → dist}/data/semgrep-rules/python-django.yaml +0 -0
  37. /package/{src/rules → dist}/data/semgrep-rules/python-security.yaml +0 -0
  38. /package/{src/rules → dist}/data/semgrep-rules/ru-regulatory.yaml +0 -0
  39. /package/{src/rules → dist}/data/semgrep-rules/ruby-rails.yaml +0 -0
  40. /package/{src/rules → dist}/data/semgrep-rules/rust-security.yaml +0 -0
package/dist/index.js CHANGED
@@ -37,9 +37,21 @@ var import_ignore = __toESM(require("ignore"));
37
37
  var import_node_fs = __toESM(require("fs"));
38
38
  var import_node_path = __toESM(require("path"));
39
39
  var import_js_yaml = __toESM(require("js-yaml"));
40
- var DATA_DIR = import_node_path.default.resolve(__dirname, "../rules/data");
41
- var SEMGREP_RULES_DIR = import_node_path.default.join(DATA_DIR, "semgrep-rules");
42
- var COMPLIANCE_MAP_PATH = import_node_path.default.join(DATA_DIR, "rule-compliance-map.json");
40
+ var cachedDataDirectory = null;
41
+ function getDataDirectory() {
42
+ if (cachedDataDirectory) return cachedDataDirectory;
43
+ const prodPath = import_node_path.default.join(__dirname, "data");
44
+ const fallbackPath = import_node_path.default.join(__dirname, "..", "src", "rules", "data");
45
+ if (import_node_fs.default.existsSync(prodPath) && import_node_fs.default.statSync(prodPath).isDirectory()) {
46
+ cachedDataDirectory = import_node_path.default.resolve(prodPath);
47
+ return cachedDataDirectory;
48
+ }
49
+ if (import_node_fs.default.existsSync(fallbackPath) && import_node_fs.default.statSync(fallbackPath).isDirectory()) {
50
+ cachedDataDirectory = import_node_path.default.resolve(fallbackPath);
51
+ return cachedDataDirectory;
52
+ }
53
+ throw new Error(`Cannot find rules data directory. Looked in: ${prodPath}, ${fallbackPath}`);
54
+ }
43
55
  var PCI_CWE = /* @__PURE__ */ new Set(["CWE-798", "CWE-327", "CWE-256", "CWE-89", "CWE-79", "CWE-22", "CWE-287", "CWE-285", "CWE-522"]);
44
56
  var SOC2_CWE = /* @__PURE__ */ new Set(["CWE-285", "CWE-306", "CWE-287", "CWE-863", "CWE-16", "CWE-200", "CWE-862"]);
45
57
  var HIPAA_CWE = /* @__PURE__ */ new Set(["CWE-532", "CWE-359", "CWE-353", "CWE-345", "CWE-200", "CWE-522"]);
@@ -70,7 +82,8 @@ function extractMetricId(id, message) {
70
82
  return id.toUpperCase();
71
83
  }
72
84
  function readComplianceMap() {
73
- const raw = import_node_fs.default.readFileSync(COMPLIANCE_MAP_PATH, "utf-8");
85
+ const complianceMapPath = import_node_path.default.join(getDataDirectory(), "rule-compliance-map.json");
86
+ const raw = import_node_fs.default.readFileSync(complianceMapPath, "utf-8");
74
87
  return JSON.parse(raw);
75
88
  }
76
89
  function collectRulePatterns(rule) {
@@ -95,11 +108,12 @@ function collectRulePatterns(rule) {
95
108
  return Array.from(new Set(patterns));
96
109
  }
97
110
  function parseSemgrepRuleFiles() {
98
- const files = import_node_fs.default.readdirSync(SEMGREP_RULES_DIR).filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"));
111
+ const semgrepRulesDir = import_node_path.default.join(getDataDirectory(), "semgrep-rules");
112
+ const files = import_node_fs.default.readdirSync(semgrepRulesDir).filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"));
99
113
  const compliance = readComplianceMap();
100
114
  const out = [];
101
115
  for (const fileName of files) {
102
- const full = import_node_path.default.join(SEMGREP_RULES_DIR, fileName);
116
+ const full = import_node_path.default.join(semgrepRulesDir, fileName);
103
117
  const parsed = import_js_yaml.default.load(import_node_fs.default.readFileSync(full, "utf-8"));
104
118
  const rows = Array.isArray(parsed?.rules) ? parsed.rules : [];
105
119
  for (const row of rows) {
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@runsec/mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",
7
- "README.md",
8
- "src/rules/data"
7
+ "README.md"
9
8
  ],
10
9
  "bin": {
11
10
  "runsec-mcp": "./dist/index.js"
@@ -14,7 +13,7 @@
14
13
  "access": "public"
15
14
  },
16
15
  "scripts": {
17
- "build": "tsup src/index.ts --format cjs --clean",
16
+ "build": "tsup src/index.ts --format cjs --clean && node -e \"require('fs').cpSync('src/rules/data', 'dist/data', {recursive: true})\"",
18
17
  "test": "vitest run",
19
18
  "simulate:output": "tsx scripts/simulate_output.ts"
20
19
  },