dbgate-tools 7.2.3 → 7.2.5

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.
@@ -7,6 +7,20 @@ exports.jsonScriptToJavascript = exports.playJsonScriptWriter = exports.ScriptWr
7
7
  const uniq_1 = __importDefault(require("lodash/uniq"));
8
8
  const cloneDeepWith_1 = __importDefault(require("lodash/cloneDeepWith"));
9
9
  const packageTools_1 = require("./packageTools");
10
+ // Line terminators (LF, CR, U+2028, U+2029) end a `//` comment; keep every line commented so
11
+ // comment/schedule text from a JSON script cannot break out and run as code. GHSA-rfx7-cmmf-7ff7
12
+ const JS_LINE_TERMINATORS_RE = /\r\n|[\r\n\u2028\u2029]/g;
13
+ // runners.js/scheduler.js scan the whole generated script text for `// @require ...` /
14
+ // `// @schedule ...` with unanchored regexes, so a directive can be formed by an '@' appearing
15
+ // *anywhere* in user-controlled text next to a '//' - not just one re-commented at a line start
16
+ // (e.g. "sometext // @require dbgate-plugin-evil" on a single line). Escape every '@' so
17
+ // user-controlled comment/schedule text can never reconstruct a directive, regardless of position.
18
+ const AT_RE = /@/g;
19
+ function sanitizeCommentText(text) {
20
+ return String(text)
21
+ .replace(AT_RE, '\\@')
22
+ .replace(JS_LINE_TERMINATORS_RE, '\n// ');
23
+ }
10
24
  class ScriptWriterJavaScript {
11
25
  constructor(varCount = '0') {
12
26
  this.s = '';
@@ -60,7 +74,7 @@ class ScriptWriterJavaScript {
60
74
  this._put(`await dbgateApi.dataReplicator(${JSON.stringify(options, null, 2)});`);
61
75
  }
62
76
  comment(s) {
63
- this._put(`// ${s}`);
77
+ this._put(`// ${sanitizeCommentText(s)}`);
64
78
  }
65
79
  getScript(schedule = null) {
66
80
  const packageNames = this.packageNames;
@@ -68,7 +82,7 @@ class ScriptWriterJavaScript {
68
82
  .map(packageName => `// @require ${packageName}\n`)
69
83
  .join('');
70
84
  if (schedule)
71
- prefix += `// @schedule ${schedule}`;
85
+ prefix += `// @schedule ${sanitizeCommentText(schedule)}`;
72
86
  if (prefix)
73
87
  prefix += '\n';
74
88
  return prefix + this.s;
@@ -0,0 +1,27 @@
1
+ export type CodexModelInfo = {
2
+ id: string;
3
+ name: string;
4
+ };
5
+ export declare const CODEX_MODELS: readonly [{
6
+ readonly id: "gpt-5.6-sol";
7
+ readonly name: "GPT-5.6 Sol";
8
+ }, {
9
+ readonly id: "gpt-5.6-terra";
10
+ readonly name: "GPT-5.6 Terra";
11
+ }, {
12
+ readonly id: "gpt-5.6-luna";
13
+ readonly name: "GPT-5.6 Luna";
14
+ }, {
15
+ readonly id: "gpt-5.5";
16
+ readonly name: "GPT-5.5";
17
+ }, {
18
+ readonly id: "gpt-5.4";
19
+ readonly name: "GPT-5.4";
20
+ }, {
21
+ readonly id: "gpt-5.4-mini";
22
+ readonly name: "GPT-5.4 mini";
23
+ }, {
24
+ readonly id: "gpt-5.3-codex-spark";
25
+ readonly name: "GPT-5.3 Codex Spark";
26
+ }];
27
+ export declare const DEFAULT_CODEX_MODEL = "gpt-5.6-sol";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CODEX_MODEL = exports.CODEX_MODELS = void 0;
4
+ exports.CODEX_MODELS = [
5
+ { id: 'gpt-5.6-sol', name: 'GPT-5.6 Sol' },
6
+ { id: 'gpt-5.6-terra', name: 'GPT-5.6 Terra' },
7
+ { id: 'gpt-5.6-luna', name: 'GPT-5.6 Luna' },
8
+ { id: 'gpt-5.5', name: 'GPT-5.5' },
9
+ { id: 'gpt-5.4', name: 'GPT-5.4' },
10
+ { id: 'gpt-5.4-mini', name: 'GPT-5.4 mini' },
11
+ { id: 'gpt-5.3-codex-spark', name: 'GPT-5.3 Codex Spark' },
12
+ ];
13
+ exports.DEFAULT_CODEX_MODEL = 'gpt-5.6-sol';
@@ -42,6 +42,7 @@ exports.mongoFilterBehaviour = {
42
42
  allowNumberDualTesting: true,
43
43
  allowObjectIdTesting: true,
44
44
  allowHexString: true,
45
+ passBooleans: true,
45
46
  };
46
47
  exports.evalFilterBehaviour = {
47
48
  supportEquals: true,
package/lib/index.d.ts CHANGED
@@ -28,3 +28,4 @@ export * from './redisKeysLoader';
28
28
  export * from './rowProgressReporter';
29
29
  export * from './diagramTools';
30
30
  export * from './queryMetadataTools';
31
+ export * from './codexModels';
package/lib/index.js CHANGED
@@ -44,3 +44,4 @@ __exportStar(require("./redisKeysLoader"), exports);
44
44
  __exportStar(require("./rowProgressReporter"), exports);
45
45
  __exportStar(require("./diagramTools"), exports);
46
46
  __exportStar(require("./queryMetadataTools"), exports);
47
+ __exportStar(require("./codexModels"), exports);
@@ -1,6 +1,18 @@
1
1
  import type { EngineDriver, ExtensionsDirectory } from 'dbgate-types';
2
2
  export declare function isValidJsIdentifier(name: string): boolean;
3
3
  export declare function assertValidJsIdentifier(name: string, label: string): void;
4
+ /**
5
+ * Tests whether a value is a canonical DbGate plugin package name (dbgate-plugin-<name>).
6
+ * By construction this rejects absolute paths, path traversal (..), path separators
7
+ * and scoped/@-names, none of which may ever be passed to require()/require.resolve().
8
+ */
9
+ export declare function isValidPluginPackageName(packageName: any): boolean;
10
+ /**
11
+ * Asserts that packageName is a canonical DbGate plugin package name.
12
+ * Must be called before any code path that resolves or require()s a plugin by name,
13
+ * so that caller-supplied paths cannot be loaded as modules.
14
+ */
15
+ export declare function assertValidPluginPackageName(packageName: any): string;
4
16
  /**
5
17
  * Validates a shell API function name.
6
18
  * Allowed forms:
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.findEngineDriver = exports.evalShellApiFunctionName = exports.compileShellApiFunctionName = exports.extractPackageName = exports.extractShellApiPlugins = exports.assertValidShellApiFunctionName = exports.assertValidJsIdentifier = exports.isValidJsIdentifier = void 0;
6
+ exports.findEngineDriver = exports.evalShellApiFunctionName = exports.compileShellApiFunctionName = exports.extractPackageName = exports.extractShellApiPlugins = exports.assertValidShellApiFunctionName = exports.assertValidPluginPackageName = exports.isValidPluginPackageName = exports.assertValidJsIdentifier = exports.isValidJsIdentifier = void 0;
7
7
  const camelCase_1 = __importDefault(require("lodash/camelCase"));
8
8
  const isString_1 = __importDefault(require("lodash/isString"));
9
9
  const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
@@ -32,10 +32,32 @@ function isValidJsIdentifier(name) {
32
32
  exports.isValidJsIdentifier = isValidJsIdentifier;
33
33
  function assertValidJsIdentifier(name, label) {
34
34
  if (!isValidJsIdentifier(name)) {
35
- throw new Error(`DBGM-00000 Invalid ${label}: ${String(name).substring(0, 100)}`);
35
+ throw new Error(`DBGM-00431 Invalid ${label}: ${String(name).substring(0, 100)}`);
36
36
  }
37
37
  }
38
38
  exports.assertValidJsIdentifier = assertValidJsIdentifier;
39
+ const VALID_PLUGIN_NAME_RE = /^dbgate-plugin-[a-zA-Z0-9_-]+$/;
40
+ /**
41
+ * Tests whether a value is a canonical DbGate plugin package name (dbgate-plugin-<name>).
42
+ * By construction this rejects absolute paths, path traversal (..), path separators
43
+ * and scoped/@-names, none of which may ever be passed to require()/require.resolve().
44
+ */
45
+ function isValidPluginPackageName(packageName) {
46
+ return typeof packageName === 'string' && VALID_PLUGIN_NAME_RE.test(packageName);
47
+ }
48
+ exports.isValidPluginPackageName = isValidPluginPackageName;
49
+ /**
50
+ * Asserts that packageName is a canonical DbGate plugin package name.
51
+ * Must be called before any code path that resolves or require()s a plugin by name,
52
+ * so that caller-supplied paths cannot be loaded as modules.
53
+ */
54
+ function assertValidPluginPackageName(packageName) {
55
+ if (!isValidPluginPackageName(packageName)) {
56
+ throw new Error(`DBGM-00000 Invalid plugin package name: ${String(packageName).substring(0, 100)}`);
57
+ }
58
+ return packageName;
59
+ }
60
+ exports.assertValidPluginPackageName = assertValidPluginPackageName;
39
61
  /**
40
62
  * Validates a shell API function name.
41
63
  * Allowed forms:
@@ -44,25 +66,24 @@ exports.assertValidJsIdentifier = assertValidJsIdentifier;
44
66
  */
45
67
  function assertValidShellApiFunctionName(functionName) {
46
68
  if (typeof functionName !== 'string') {
47
- throw new Error('DBGM-00000 functionName must be a string');
69
+ throw new Error('DBGM-00432 functionName must be a string');
48
70
  }
49
71
  const nsMatch = functionName.match(/^([^@]+)@([^@]+)$/);
50
72
  if (nsMatch) {
51
73
  if (!isValidJsIdentifier(nsMatch[1])) {
52
- throw new Error(`DBGM-00000 Invalid function part in functionName: ${nsMatch[1].substring(0, 100)}`);
74
+ throw new Error(`DBGM-00433 Invalid function part in functionName: ${nsMatch[1].substring(0, 100)}`);
53
75
  }
54
- if (!/^dbgate-plugin-[a-zA-Z0-9_-]+$/.test(nsMatch[2])) {
76
+ if (!isValidPluginPackageName(nsMatch[2])) {
55
77
  throw new Error(`DBGM-00000 Invalid plugin package in functionName: ${nsMatch[2].substring(0, 100)}`);
56
78
  }
57
79
  }
58
80
  else {
59
81
  if (!isValidJsIdentifier(functionName)) {
60
- throw new Error(`DBGM-00000 Invalid functionName: ${functionName.substring(0, 100)}`);
82
+ throw new Error(`DBGM-00435 Invalid functionName: ${functionName.substring(0, 100)}`);
61
83
  }
62
84
  }
63
85
  }
64
86
  exports.assertValidShellApiFunctionName = assertValidShellApiFunctionName;
65
- const VALID_PLUGIN_NAME_RE = /^dbgate-plugin-[a-zA-Z0-9_-]+$/;
66
87
  function extractShellApiPlugins(functionName, props) {
67
88
  const res = [];
68
89
  const nsMatch = functionName.match(/^([^@]+)@([^@]+)/);
@@ -76,9 +97,7 @@ function extractShellApiPlugins(functionName, props) {
76
97
  }
77
98
  }
78
99
  for (const plugin of res) {
79
- if (!VALID_PLUGIN_NAME_RE.test(plugin)) {
80
- throw new Error(`DBGM-00000 Invalid plugin name: ${String(plugin).substring(0, 100)}`);
81
- }
100
+ assertValidPluginPackageName(plugin);
82
101
  }
83
102
  return res;
84
103
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.2.3",
2
+ "version": "7.2.5",
3
3
  "name": "dbgate-tools",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@types/node": "^13.7.0",
29
- "dbgate-types": "7.2.3",
29
+ "dbgate-types": "7.2.5",
30
30
  "jest": "^28.1.3",
31
31
  "ts-jest": "^28.0.7",
32
32
  "typescript": "^4.4.3"
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "blueimp-md5": "^2.19.0",
36
36
  "dbgate-query-splitter": "^4.12.0",
37
- "dbgate-sqltree": "7.2.3",
37
+ "dbgate-sqltree": "7.2.5",
38
38
  "debug": "^4.3.4",
39
39
  "json-stable-stringify": "^1.0.1",
40
40
  "lodash": "^4.17.21",