@bytebase/dbhub 0.11.1 → 0.11.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.
- package/dist/index.js +18 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2031,6 +2031,7 @@ import dotenv from "dotenv";
|
|
|
2031
2031
|
import path from "path";
|
|
2032
2032
|
import fs from "fs";
|
|
2033
2033
|
import { fileURLToPath } from "url";
|
|
2034
|
+
import { homedir as homedir2 } from "os";
|
|
2034
2035
|
|
|
2035
2036
|
// src/utils/ssh-config-parser.ts
|
|
2036
2037
|
import { readFileSync as readFileSync2, existsSync } from "fs";
|
|
@@ -2065,7 +2066,7 @@ function findDefaultSSHKey() {
|
|
|
2065
2066
|
return void 0;
|
|
2066
2067
|
}
|
|
2067
2068
|
function parseSSHConfig(hostAlias, configPath) {
|
|
2068
|
-
const sshConfigPath = configPath
|
|
2069
|
+
const sshConfigPath = configPath;
|
|
2069
2070
|
if (!existsSync(sshConfigPath)) {
|
|
2070
2071
|
return null;
|
|
2071
2072
|
}
|
|
@@ -2260,7 +2261,9 @@ function resolveSSHConfig() {
|
|
|
2260
2261
|
sources.push("SSH_HOST from environment");
|
|
2261
2262
|
}
|
|
2262
2263
|
if (sshConfigHost && looksLikeSSHAlias(sshConfigHost)) {
|
|
2263
|
-
const
|
|
2264
|
+
const sshConfigPath = path.join(homedir2(), ".ssh", "config");
|
|
2265
|
+
console.error(`Attempting to parse SSH config for host '${sshConfigHost}' from: ${sshConfigPath}`);
|
|
2266
|
+
const sshConfigData = parseSSHConfig(sshConfigHost, sshConfigPath);
|
|
2264
2267
|
if (sshConfigData) {
|
|
2265
2268
|
config = { ...sshConfigData };
|
|
2266
2269
|
sources.push(`SSH config for host '${sshConfigHost}'`);
|
|
@@ -2844,9 +2847,20 @@ var executeSqlSchema = {
|
|
|
2844
2847
|
function splitSQLStatements(sql2) {
|
|
2845
2848
|
return sql2.split(";").map((statement) => statement.trim()).filter((statement) => statement.length > 0);
|
|
2846
2849
|
}
|
|
2850
|
+
function stripSQLComments(sql2) {
|
|
2851
|
+
let cleaned = sql2.split("\n").map((line) => {
|
|
2852
|
+
const commentIndex = line.indexOf("--");
|
|
2853
|
+
return commentIndex >= 0 ? line.substring(0, commentIndex) : line;
|
|
2854
|
+
}).join("\n");
|
|
2855
|
+
cleaned = cleaned.replace(/\/\*[\s\S]*?\*\//g, " ");
|
|
2856
|
+
return cleaned.trim();
|
|
2857
|
+
}
|
|
2847
2858
|
function isReadOnlySQL(sql2, connectorType) {
|
|
2848
|
-
const
|
|
2849
|
-
|
|
2859
|
+
const cleanedSQL = stripSQLComments(sql2).toLowerCase();
|
|
2860
|
+
if (!cleanedSQL) {
|
|
2861
|
+
return true;
|
|
2862
|
+
}
|
|
2863
|
+
const firstWord = cleanedSQL.split(/\s+/)[0];
|
|
2850
2864
|
const keywordList = allowedKeywords[connectorType] || allowedKeywords.default || [];
|
|
2851
2865
|
return keywordList.includes(firstWord);
|
|
2852
2866
|
}
|