Skip to content

Commit ba178f4

Browse files
SK-2040: resolve pr comments
1 parent 997768f commit ba178f4

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/utils/logs/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const logs = {
99
VALIDATING_VAULT_CONFIG: 'Validating vault config.',
1010
VALIDATING_CONNECTION_CONFIG: 'Validating connection config.',
1111
VAULT_CONTROLLER_INITIALIZED: 'Initialized vault controller with vault ID %s1.',
12+
DETECT_CONTROLLER_INITIALIZED: 'Initialized detect controller with vault ID %s1.',
1213
CONNECTION_CONTROLLER_INITIALIZED: 'Intitialized connection controller with connection ID %s1.',
1314
vaultId_CONFIG_EXISTS: 'Vault config with vault ID %s1 already exists.',
1415
vaultId_CONFIG_DOES_NOT_EXIST: `Vault config with vault ID %s1 doesn't exist.`,

src/utils/validations/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import TokenizeRequest from "../../vault/model/request/tokenize";
2121
import UpdateRequest from "../../vault/model/request/update";
2222
import { SkyflowConfig, StringKeyValueMapType } from "../../vault/types";
2323
import * as fs from 'fs';
24+
import * as path from 'path';
2425
import { isExpired } from "../jwt-utils";
2526
import logs from "../logs";
2627
import FileUploadOptions from "../../vault/model/options/fileUpload";
@@ -1000,12 +1001,17 @@ export const validateDeidentifyFileRequest = (deidentifyFileRequest: DeidentifyF
10001001
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_FILE_TYPE);
10011002
}
10021003

1003-
// Additional validation for File (browser)
1004+
// Additional validation for File
10041005
if (file instanceof File) {
1005-
if (!file.name || !file.size) {
1006+
if (!file.name || typeof file.name !== 'string' || file.name.trim().length === 0) {
10061007
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_FILE_TYPE);
10071008
}
1008-
}
1009+
// Validate fileBaseName
1010+
const fileBaseName = path.parse(file.name).name;
1011+
if (!fileBaseName || typeof fileBaseName !== 'string' || fileBaseName.trim().length === 0) {
1012+
throw new SkyflowError(SKYFLOW_ERROR_CODE.INVALID_FILE_TYPE);
1013+
}
1014+
}
10091015

10101016
// Validate options if provided
10111017
if (deidentifyFileOptions) {

src/vault/skyflow/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Skyflow {
5353
const vaultController = new VaultController(client);
5454
const detectController = new DetectController(client);
5555
printLog(parameterizedString(logs.infoLogs.VAULT_CONTROLLER_INITIALIZED, [config.vaultId]), MessageType.LOG, this.logLevel);
56-
// printLog for detect controller
56+
printLog(parameterizedString(logs.infoLogs.DETECT_CONTROLLER_INITIALIZED, [config.vaultId]), MessageType.LOG, this.logLevel);
5757
clients[config.vaultId] = { config, client, vaultController, detectController };
5858
}
5959

0 commit comments

Comments
 (0)