Skip to content

Commit

Permalink
SNOW-1454054 - add check of user permission for token file
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Jul 19, 2024
1 parent 5f8ef63 commit 785f216
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ private static Map<String, Map> readParametersMap(Path configFilePath)
throws SnowflakeSQLException {
try {
File file = new File(configFilePath.toUri());
varifyFilePermissionSecure(configFilePath);
verifyFilePermissionSecure(configFilePath);
return mapper.readValue(file, Map.class);
} catch (IOException ex) {
throw new SnowflakeSQLException(ex, "Problem during reading a configuration file.");
}
}

private static void varifyFilePermissionSecure(Path configFilePath)
private static void verifyFilePermissionSecure(Path configFilePath)
throws IOException, SnowflakeSQLException {
if (Constants.getOS() != Constants.OS.WINDOWS) {
PosixFileAttributeView posixFileAttributeView =
Expand Down Expand Up @@ -108,7 +108,7 @@ public static ConnectionParameters buildConnectionParameters() throws SnowflakeS
.orElse(SNOWFLAKE_TOKEN_FILE_PATH));
logger.debug("Token used in connect is read from file: {}", path);
try {
varifyFilePermissionSecure(path);
verifyFilePermissionSecure(path);
String token = new String(Files.readAllBytes(path), Charset.defaultCharset());
if (!token.isEmpty()) {
putPropertyIfNotNull(conectionProperties, "token", token.trim());
Expand Down

0 comments on commit 785f216

Please sign in to comment.