diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Gopass.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Gopass.kt index 4f454d5..f06f056 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Gopass.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/workplace/infrastructure/Gopass.kt @@ -42,6 +42,9 @@ fun Prov.installGopass( fun Prov.configureGopass(gopassRootFolder: String? = null) = def { + if ((gopassRootFolder != null) && (gopassRootFolder.trim().length > 0) && ("~" == gopassRootFolder.trim().substring(0, 1))) { + return@def ProvResult(false, err = "Gopass cannot be initialized with folders starting with ~") + } val defaultRootFolder = userHome() + ".password-store" val rootFolder = gopassRootFolder ?: defaultRootFolder // use default diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/base/GopassKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/base/GopassKtTest.kt index 3a94164..362006f 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/base/GopassKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/extensions/workplace/base/GopassKtTest.kt @@ -16,10 +16,21 @@ import org.junit.jupiter.api.Test import org.domaindrivenarchitecture.provs.extensions.test_keys.privateGPGSnakeoilKey import org.domaindrivenarchitecture.provs.extensions.test_keys.publicGPGSnakeoilKey import org.domaindrivenarchitecture.provs.workplace.infrastructure.* +import org.junit.jupiter.api.Assertions.assertFalse internal class GopassKtTest { + @ContainerTest + @Test + fun test_configureGopass_fails_with_path_starting_with_tilde() { + // when + val res = defaultTestContainer().configureGopass("~/somedir") + + // then + assertFalse(res.success) + } + @ContainerTest @Test fun test_installAndConfigureGopassAndMountStore() {