inibase 1.6.5 → 1.6.6
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/cli.js +1 -1
- package/dist/utils.d.ts +10 -6
- package/dist/utils.js +18 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -180,7 +180,7 @@ rl.on("line", async (input) => {
|
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
if (!isSafeName(splitedInput[1]))
|
|
183
|
-
console.log(`${textRed(" Err:")} Invalid table name
|
|
183
|
+
console.log(`${textRed(" Err:")} Invalid table name`);
|
|
184
184
|
else if (!(await isExists(join(path, splitedInput[1]))))
|
|
185
185
|
console.log(`${textRed(" Err:")} Table doesn't exist`);
|
|
186
186
|
else {
|
package/dist/utils.d.ts
CHANGED
|
@@ -236,13 +236,17 @@ export declare const createError: (language: ErrorLang, name: ErrorCode, variabl
|
|
|
236
236
|
/**
|
|
237
237
|
* Validates that a string is a safe name for a table, database or column.
|
|
238
238
|
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
239
|
+
* Instead of whitelisting allowed characters, this uses a blacklist that blocks
|
|
240
|
+
* only characters known to cause problems with shell commands, filesystem
|
|
241
|
+
* paths, or injection attacks. All Unicode letters (Latin, Arabic, Chinese,
|
|
242
|
+
* etc.), digits, underscores, hyphens, spaces and forward slashes are allowed.
|
|
242
243
|
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
244
|
+
* Blocked characters: null bytes, control characters, `\`, `;`, `|`, `&`,
|
|
245
|
+
* `<`, `>`, `$`, backtick, `!`, `'`, `"`, `{`, `}`, `(`, `)`, `~`, and `.`
|
|
246
|
+
* (reserved as column-path separator). Forward slash (`/`) is intentionally
|
|
247
|
+
* allowed so that nested table names like `"user/logs"` work.
|
|
248
|
+
*
|
|
249
|
+
* Leading or trailing spaces are not allowed.
|
|
246
250
|
*
|
|
247
251
|
* @param input - The value to be checked.
|
|
248
252
|
* @returns boolean - True if the name is safe to use, false otherwise.
|
package/dist/utils.js
CHANGED
|
@@ -726,13 +726,17 @@ export const createError = (language, name, variable) => {
|
|
|
726
726
|
/**
|
|
727
727
|
* Validates that a string is a safe name for a table, database or column.
|
|
728
728
|
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
729
|
+
* Instead of whitelisting allowed characters, this uses a blacklist that blocks
|
|
730
|
+
* only characters known to cause problems with shell commands, filesystem
|
|
731
|
+
* paths, or injection attacks. All Unicode letters (Latin, Arabic, Chinese,
|
|
732
|
+
* etc.), digits, underscores, hyphens, spaces and forward slashes are allowed.
|
|
732
733
|
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
734
|
+
* Blocked characters: null bytes, control characters, `\`, `;`, `|`, `&`,
|
|
735
|
+
* `<`, `>`, `$`, backtick, `!`, `'`, `"`, `{`, `}`, `(`, `)`, `~`, and `.`
|
|
736
|
+
* (reserved as column-path separator). Forward slash (`/`) is intentionally
|
|
737
|
+
* allowed so that nested table names like `"user/logs"` work.
|
|
738
|
+
*
|
|
739
|
+
* Leading or trailing spaces are not allowed.
|
|
736
740
|
*
|
|
737
741
|
* @param input - The value to be checked.
|
|
738
742
|
* @returns boolean - True if the name is safe to use, false otherwise.
|
|
@@ -741,12 +745,14 @@ export const isValidName = (input) => typeof input === "string" &&
|
|
|
741
745
|
input.length > 0 &&
|
|
742
746
|
input.length <= 255 &&
|
|
743
747
|
validNamePattern.test(input);
|
|
744
|
-
//
|
|
745
|
-
|
|
746
|
-
//
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
748
|
+
// Forbidden characters: control chars, path separators, shell metacharacters,
|
|
749
|
+
// quoting, grouping, history expansion, home-dir expansion and dot (reserved
|
|
750
|
+
// as column-path separator). The forward slash (/) is intentionally allowed
|
|
751
|
+
// so that nested table names like "user/logs" work.
|
|
752
|
+
const nameForbiddenChars = "\\x00-\\x1F\\x7F.\\\\;|&<>$`!'\\" + "{}()~";
|
|
753
|
+
// Names must be 1-255 chars, start/end with a non-forbidden non-whitespace
|
|
754
|
+
// character, and contain no forbidden characters in between.
|
|
755
|
+
const validNamePattern = new RegExp(`^[^${nameForbiddenChars}\\s\\p{Z}\\p{Cf}][^${nameForbiddenChars}\\p{Cf}]*[^${nameForbiddenChars}\\s\\p{Z}\\p{Cf}]$|^[^${nameForbiddenChars}\\s\\p{Z}\\p{Cf}]$`, "u");
|
|
750
756
|
/**
|
|
751
757
|
* Validates that a string is a safe name for a table, database or column and
|
|
752
758
|
* throws a translated `INVALID_NAME` error if it is not.
|