Prepare configured secrets before loading
This commit is contained in:
@@ -137,7 +137,8 @@ func LoadSecretsDir(directory string) (*SecretsReport, error) {
|
||||
|
||||
// SecretsDirOptions controls how directory values are applied.
|
||||
type SecretsDirOptions struct {
|
||||
Overwrite bool
|
||||
Overwrite bool
|
||||
containmentRoot string
|
||||
}
|
||||
|
||||
// LoadSecretsDirWithOptions loads directory values with the selected policy.
|
||||
@@ -159,6 +160,9 @@ func loadSecretsDir(directory string, options SecretsDirOptions, environment sec
|
||||
if err != nil {
|
||||
return report, secretsFailure(classifySecretsFilesystemError(err), "secrets directory could not be canonicalized: "+strconv.Quote(cleanAbsolutePath(directory)))
|
||||
}
|
||||
if options.containmentRoot != "" && !containedPath(options.containmentRoot, canonical) {
|
||||
return report, secretsFailure(CodeSecretsInvalidPath, "secrets directory is outside the configuration root")
|
||||
}
|
||||
info, err := os.Stat(canonical)
|
||||
if err != nil {
|
||||
return report, secretsFailure(classifySecretsFilesystemError(err), "secrets directory could not be inspected: "+strconv.Quote(canonical))
|
||||
|
||||
Reference in New Issue
Block a user