@opscompass/opscompass-cli 1.3.3 → 1.3.4
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/lib/maskValues.js +19 -4
- package/package.json +2 -2
package/lib/maskValues.js
CHANGED
|
@@ -33,6 +33,7 @@ const MASK_PROPERTY_REGEX = /^[A-Za-z0-9._-]+$/;
|
|
|
33
33
|
const SQL_IDENTIFIER_REGEX = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
34
34
|
const SQL_COLUMN_TYPE_REGEX = /^[A-Z0-9_(),\s]+$/;
|
|
35
35
|
const INVALID_MASK_COMPONENT_REGEX = /[\n\r/\\]/;
|
|
36
|
+
const INVALID_MASK_ITEM_COMPONENT_REGEX = /[\n\r\\]/;
|
|
36
37
|
const DEFAULT_KEY_LOOKUP_TIMEOUT_MS = 5000;
|
|
37
38
|
const MASK_DB_COLUMNS = Object.freeze([
|
|
38
39
|
Object.freeze({
|
|
@@ -84,7 +85,11 @@ function validateMaskTokenComponent(componentName, value) {
|
|
|
84
85
|
if (typeof value !== "string" || value.length === 0) {
|
|
85
86
|
throw new Error(`Invalid mask token ${componentName}`);
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
const invalidComponentRegex =
|
|
89
|
+
componentName === "item"
|
|
90
|
+
? INVALID_MASK_ITEM_COMPONENT_REGEX
|
|
91
|
+
: INVALID_MASK_COMPONENT_REGEX;
|
|
92
|
+
if (invalidComponentRegex.test(value)) {
|
|
88
93
|
throw new Error(`Invalid mask token ${componentName}`);
|
|
89
94
|
}
|
|
90
95
|
if (componentName === "type" && !MASK_TYPE_REGEX.test(value)) {
|
|
@@ -156,7 +161,11 @@ function buildMaskDumpQuery(tableName, includeMaskFilter = false) {
|
|
|
156
161
|
return `${sql} ORDER BY name DESC`;
|
|
157
162
|
}
|
|
158
163
|
|
|
159
|
-
function executeKeyLookupScript(
|
|
164
|
+
function executeKeyLookupScript(
|
|
165
|
+
keyCommand,
|
|
166
|
+
item,
|
|
167
|
+
timeoutMs = DEFAULT_KEY_LOOKUP_TIMEOUT_MS,
|
|
168
|
+
) {
|
|
160
169
|
validateMaskTokenComponent("item", item);
|
|
161
170
|
|
|
162
171
|
return new Promise((resolve, reject) => {
|
|
@@ -323,7 +332,10 @@ class MaskDb {
|
|
|
323
332
|
|
|
324
333
|
const columnsDefinition = columns
|
|
325
334
|
.map((column) => {
|
|
326
|
-
const columnName = assertSafeSqlIdentifier(
|
|
335
|
+
const columnName = assertSafeSqlIdentifier(
|
|
336
|
+
column.name,
|
|
337
|
+
"column name",
|
|
338
|
+
);
|
|
327
339
|
const columnType = assertSafeColumnType(column.type);
|
|
328
340
|
let definition = `${columnName} ${columnType}`;
|
|
329
341
|
return definition;
|
|
@@ -671,7 +683,10 @@ async function getMask(maskType, args) {
|
|
|
671
683
|
const keyCommand = getKeyCommand(maskType);
|
|
672
684
|
if (keyCommand) {
|
|
673
685
|
try {
|
|
674
|
-
keystoreResponse = await executeKeyLookupScript(
|
|
686
|
+
keystoreResponse = await executeKeyLookupScript(
|
|
687
|
+
keyCommand,
|
|
688
|
+
maskToken.item,
|
|
689
|
+
);
|
|
675
690
|
keystoreObject = JSON.parse(keystoreResponse);
|
|
676
691
|
|
|
677
692
|
// If a username is returned by the keystore, the user is the username
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opscompass/opscompass-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Calls OpsCompass's APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"node": ">=22 <23 || >=24 <25"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opscompass/opscompass-api": "^1.3.
|
|
28
|
+
"@opscompass/opscompass-api": "^1.3.3",
|
|
29
29
|
"adm-zip": "^0.5.16",
|
|
30
30
|
"axios": "^0.28.1",
|
|
31
31
|
"better-sqlite3": "12.6.2",
|