Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
pull/8581/head
Tiger Kaovilai 2025-02-18 15:36:14 -06:00
parent c153651044
commit 3bb39d9331
No known key found for this signature in database
GPG Key ID: F05DADBB55627443
1 changed files with 16 additions and 7 deletions

View File

@ -506,6 +506,10 @@ func getStorageCredentials(backupLocation *velerov1api.BackupStorageLocation, cr
return result, nil
}
// Translates user specified options (backupRepoConfig) to internal parameters
// so we would accept only the options that are well defined in the internal system.
// Users' inputs should not be treated as safe any time.
// We remove the unnecessary parameters and keep the modules/logics below safe
func getStorageVariables(backupLocation *velerov1api.BackupStorageLocation, repoBackend string, repoName string, backupRepoConfig map[string]string) (map[string]string, error) {
result := make(map[string]string)
@ -576,14 +580,19 @@ func getStorageVariables(backupLocation *velerov1api.BackupStorageLocation, repo
result[udmrepo.StoreOptionOssRegion] = strings.Trim(region, "/")
result[udmrepo.StoreOptionFsPath] = config["fspath"]
// Write all backupRepoConfig to results if not exists, otherwise error on conflict
for k, v := range backupRepoConfig { // if nil, this would be skipped
if _, ok := result[k]; !ok {
// TODO: validation of allowed values for each key?
result[k] = v
} else {
return result, errors.Errorf("backupRepoConfig contains key %s that would override storage variables", k)
// We remove the unnecessary parameters and keep the modules/logics below safe
if backupRepoConfig != nil {
// range of valid params to keep, everything else will be discarded.
validParams := []string{
udmrepo.StoreOptionCacheLimit,
udmrepo.StoreOptionKeyFullMaintenanceInterval,
}
for _, param := range validParams {
if v, found := backupRepoConfig[param]; found {
result[param] = v
}
}
}
return result, nil