-
Notifications
You must be signed in to change notification settings - Fork 192
SNOW-2161718-JDBC-fix-permission-check-for-toml-config #2270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sfc-gh-ext-simba-vb
merged 45 commits into
master
from
SNOW-2161718-JDBC-fix-permission-check-for-toml-config
Sep 26, 2025
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
93545b1
Initial commit.
sfc-gh-ext-simba-vb 2964494
code checkin.
sfc-gh-ext-simba-vb 2422cbb
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb e831e1e
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 5b250e1
check style issue.
sfc-gh-ext-simba-vb 30a5b40
fixed the test failure.
sfc-gh-ext-simba-vb af5abc0
error msg printing.
sfc-gh-ext-simba-vb a0f6eeb
test failure fix.
sfc-gh-ext-simba-vb 41c7c22
SOP added for testing
sfc-gh-ext-simba-vb 31e7254
toml file changes.
sfc-gh-ext-simba-vb 637c4b7
Updated tests.
sfc-gh-ext-simba-vb 5c3023c
test fix
sfc-gh-ext-simba-vb 9938021
converted to parameterized JUnit test.
sfc-gh-ext-simba-vb b478cdf
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 56805b0
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb af63bd8
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb c32a8f2
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb a362f4d
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 674c6f5
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb d48db6c
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb a34f1fb
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 1c53874
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb f8ae72a
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb ce50293
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 37e7ba1
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 0f67733
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb b0aeece
Review comments implemented.
sfc-gh-ext-simba-vb c51dcc6
Merge branch 'SNOW-2161718-JDBC-fix-permission-check-for-toml-config'…
sfc-gh-ext-simba-vb ef020a4
review comments implemented 2
sfc-gh-ext-simba-vb 5a36f6a
Changed the tonl file creation logic.
sfc-gh-ext-simba-vb f74f61c
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 248691f
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb acf6f4c
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 6261f93
Merge branch 'SNOW-2161718-JDBC-fix-permission-check-for-toml-config'…
sfc-gh-ext-simba-vb bc0c2f4
Review comments implemented
sfc-gh-ext-simba-vb a3d8638
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 5e6fdc0
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb cb0b81e
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 2b10d23
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 1aff90e
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 76fd52e
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb 37b11d0
Merge branch 'master' into SNOW-2161718-JDBC-fix-permission-check-for…
sfc-gh-ext-simba-vb b07bc4f
Description.md altered.
sfc-gh-ext-simba-vb 4a387da
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb ea56cf7
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
src/test/java/net/snowflake/client/config/SFConnectionConfigParserPermissionTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| package net.snowflake.client.config; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.attribute.PosixFilePermission; | ||
| import java.util.Arrays; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import net.snowflake.client.annotations.DontRunOnWindows; | ||
| import net.snowflake.client.jdbc.SnowflakeSQLException; | ||
| import net.snowflake.client.jdbc.SnowflakeUtil; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| class SFConnectionConfigParserPermissionTest { | ||
|
|
||
| private Path createTempFileWithPermissions(Set<PosixFilePermission> perms) throws Exception { | ||
| // Create a unique temporary directory | ||
| Path tempDir = Files.createTempDirectory("snowflake"); | ||
|
|
||
| // Inside it, create a file named "connections.toml" | ||
| Path tomlFile = tempDir.resolve("connections.toml"); | ||
| Files.createFile(tomlFile); | ||
|
|
||
| // Apply the given POSIX permissions | ||
| Files.setPosixFilePermissions(tomlFile, perms); | ||
|
|
||
| // Mark both the file and the directory for deletion on JVM exit | ||
| tomlFile.toFile().deleteOnExit(); | ||
| tempDir.toFile().deleteOnExit(); | ||
|
|
||
| return tomlFile; | ||
| } | ||
|
|
||
| static List<Object[]> permissionTestCases() { | ||
| return Arrays.asList( | ||
| new Object[][] { | ||
| { // Group write | ||
| new HashSet<>( | ||
| Arrays.asList( | ||
| PosixFilePermission.OWNER_READ, | ||
| PosixFilePermission.OWNER_WRITE, | ||
| PosixFilePermission.GROUP_WRITE)), | ||
| true, | ||
| "writable by group or others" | ||
| }, | ||
| { // Others write | ||
| new HashSet<>( | ||
| Arrays.asList( | ||
| PosixFilePermission.OWNER_READ, | ||
| PosixFilePermission.OWNER_WRITE, | ||
| PosixFilePermission.OTHERS_WRITE)), | ||
| true, | ||
| "writable by group or others" | ||
| }, | ||
| { // Owner execute | ||
| new HashSet<>( | ||
| Arrays.asList( | ||
| PosixFilePermission.OWNER_READ, | ||
| PosixFilePermission.OWNER_WRITE, | ||
| PosixFilePermission.OWNER_EXECUTE)), | ||
| true, | ||
| "executable" | ||
| }, | ||
| { // Group execute | ||
| new HashSet<>( | ||
| Arrays.asList( | ||
| PosixFilePermission.OWNER_READ, | ||
| PosixFilePermission.OWNER_WRITE, | ||
| PosixFilePermission.GROUP_EXECUTE)), | ||
| true, | ||
| "executable" | ||
| }, | ||
| { // Others execute | ||
| new HashSet<>( | ||
| Arrays.asList( | ||
| PosixFilePermission.OWNER_READ, | ||
| PosixFilePermission.OWNER_WRITE, | ||
| PosixFilePermission.OTHERS_EXECUTE)), | ||
| true, | ||
| "executable" | ||
| }, | ||
| { // Owner read/write only | ||
| new HashSet<>( | ||
| Arrays.asList(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)), | ||
| false, | ||
| null | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("permissionTestCases") | ||
| @DontRunOnWindows | ||
| void testFilePermissionScenarios( | ||
| Set<PosixFilePermission> perms, boolean shouldThrow, String expectedMsg) throws Exception { | ||
| Path tempFile = createTempFileWithPermissions(perms); | ||
| try { | ||
| if (shouldThrow) { | ||
| Exception ex = | ||
| assertThrows( | ||
| SnowflakeSQLException.class, | ||
| () -> SFConnectionConfigParser.verifyFilePermissionSecure(tempFile)); | ||
| assertTrue(ex.getMessage().contains(expectedMsg)); | ||
| } else { | ||
| assertDoesNotThrow(() -> SFConnectionConfigParser.verifyFilePermissionSecure(tempFile)); | ||
| } | ||
| } finally { | ||
| Files.deleteIfExists(tempFile); | ||
| } | ||
| } | ||
|
|
||
| static List<Object[]> skipReadWarningTestCases() { | ||
| return Arrays.asList( | ||
| new Object[][] { | ||
| { | ||
| new HashSet<>( | ||
| Arrays.asList( | ||
| PosixFilePermission.OWNER_READ, | ||
| PosixFilePermission.OWNER_WRITE, | ||
| PosixFilePermission.GROUP_READ, | ||
| PosixFilePermission.OTHERS_READ)) | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("skipReadWarningTestCases") | ||
| @DontRunOnWindows | ||
sfc-gh-dheyman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| void testSkipWarningForReadPermissionsEnvVar(Set<PosixFilePermission> perms) throws Exception { | ||
| Path tempFile = createTempFileWithPermissions(perms); | ||
| SnowflakeUtil.systemSetEnv("SF_SKIP_WARNING_FOR_READ_PERMISSIONS_ON_CONFIG_FILE", "true"); | ||
| try { | ||
| assertDoesNotThrow(() -> SFConnectionConfigParser.verifyFilePermissionSecure(tempFile)); | ||
| } finally { | ||
| Files.deleteIfExists(tempFile); | ||
| SnowflakeUtil.systemSetEnv("SF_SKIP_WARNING_FOR_READ_PERMISSIONS_ON_CONFIG_FILE", null); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.