Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"github.com/spf13/pflag"
"golang.org/x/sync/semaphore"

"vitess.io/vitess/go/fileutil"
"vitess.io/vitess/go/ioutil"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/mysql/replication"
Expand Down Expand Up @@ -167,7 +168,9 @@
fs.StringVar(&builtinIncrementalRestorePath, "builtinbackup-incremental-restore-path", builtinIncrementalRestorePath, "the directory where incremental restore files, namely binlog files, are extracted to. In k8s environments, this should be set to a directory that is shared between the vttablet and mysqld pods. The path should exist. When empty, the default OS temp dir is assumed.")
}

// fullPath returns the full path of the entry, based on its type
// fullPath returns the full path of the entry, based on its type.
// It validates that the resolved path does not escape the base directory
// via path traversal (e.g. "../../" sequences in fe.Name).
func (fe *FileEntry) fullPath(cnf *Mycnf) (string, error) {
// find the root to use
var root string
Expand All @@ -184,7 +187,7 @@
return "", vterrors.Errorf(vtrpc.Code_UNKNOWN, "unknown base: %v", fe.Base)
}

return path.Join(fe.ParentPath, root, fe.Name), nil
return fileutil.SafePathJoin(path.Join(fe.ParentPath, root), fe.Name)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_throttler_topo)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (21)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (ers_prs_newfeatures_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (18)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtbackup)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_godriver)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vschema)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_tablet_healthcheck_cache)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_queries)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql80)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_consul)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_cellalias)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtctlbackup_sharded_clustertest_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_ghost)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (15)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_v2)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_gen4)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql_server_vault)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (topo_connection_cache)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - Manual

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_gen4)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_v2)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin) (typecheck)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin) (typecheck)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin) (typecheck)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Unit Test (Race)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_basic)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Region Sharding example using etcd on Ubuntu

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_across_db_versions)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtctlbackup_sharded_clustertest_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Unit Test (Race)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Local example using consul on Ubuntu

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_throttler_topo)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Local example using etcd on Ubuntu

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (22)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_partial_movetables_and_materialize)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_general_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql80)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_mysqlshell)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_migrate_vdiff2_convert_tz)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema_tracker)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_cellalias)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (18)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_foreign_key_stress)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - Manual

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Region Sharding example using etcd on Ubuntu

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_basic)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vstream)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_general_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (topo_connection_cache)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_mysqlshell)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_foreignkey_stress)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql_server_vault)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vschema)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtbackup)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin) (typecheck)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin) (typecheck)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin) (typecheck)

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (21)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (15)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (22)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_partial_keyspace)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_foreignkey_stress)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_tablet_healthcheck_cache)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_migrate_vdiff2_convert_tz)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_queries)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql80)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_foreign_key_stress)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Vitess Tester (vtgate)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (ers_prs_newfeatures_heavy)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_across_db_versions)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql80)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_ghost)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vstream)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_godriver)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema_tracker)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_partial_movetables_and_materialize)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_partial_keyspace)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite)

undefined: fileutil.SafePathJoin

Check failure on line 190 in go/vt/mysqlctl/builtinbackupengine.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_consul)

undefined: fileutil.SafePathJoin
}

// open attempts t oopen the file
Expand Down
89 changes: 89 additions & 0 deletions go/vt/mysqlctl/builtinbackupengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/fileutil"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
)

Expand Down Expand Up @@ -70,6 +72,93 @@ func TestGetIncrementalFromPosGTIDSet(t *testing.T) {
}
}

func TestFileEntryFullPath(t *testing.T) {
cnf := &Mycnf{
DataDir: "/vt/data",
InnodbDataHomeDir: "/vt/innodb-data",
InnodbLogGroupHomeDir: "/vt/innodb-log",
BinLogPath: "/vt/binlogs/mysql-bin",
}

tests := []struct {
name string
entry FileEntry
wantPath string
wantError error
}{
{
name: "valid relative path in DataDir",
entry: FileEntry{Base: backupData, Name: "mydb/table1.ibd"},
wantPath: "/vt/data/mydb/table1.ibd",
},
{
name: "valid relative path in InnodbDataHomeDir",
entry: FileEntry{Base: backupInnodbDataHomeDir, Name: "ibdata1"},
wantPath: "/vt/innodb-data/ibdata1",
},
{
name: "valid relative path in InnodbLogGroupHomeDir",
entry: FileEntry{Base: backupInnodbLogGroupHomeDir, Name: "ib_logfile0"},
wantPath: "/vt/innodb-log/ib_logfile0",
},
{
name: "valid relative path in BinlogDir",
entry: FileEntry{Base: backupBinlogDir, Name: "mysql-bin.000001"},
wantPath: "/vt/binlogs/mysql-bin.000001",
},
{
name: "valid path with ParentPath",
entry: FileEntry{Base: backupData, Name: "mydb/table1.ibd", ParentPath: "/tmp/restore"},
wantPath: "/tmp/restore/vt/data/mydb/table1.ibd",
},
{
name: "path traversal escapes base directory",
entry: FileEntry{Base: backupData, Name: "../../etc/passwd"},
wantError: fileutil.ErrInvalidJoinedPath,
},
{
name: "path traversal with deeper nesting",
entry: FileEntry{Base: backupData, Name: "mydb/../../../etc/shadow"},
wantError: fileutil.ErrInvalidJoinedPath,
},
{
name: "path traversal to root",
entry: FileEntry{Base: backupData, Name: "../../../../../etc/crontab"},
wantError: fileutil.ErrInvalidJoinedPath,
},
{
name: "path traversal escapes ParentPath",
entry: FileEntry{Base: backupData, Name: "../../../../etc/passwd", ParentPath: "/tmp/restore"},
wantError: fileutil.ErrInvalidJoinedPath,
},
{
name: "relative path with dot-dot that stays within base",
entry: FileEntry{Base: backupData, Name: "mydb/../mydb/table1.ibd"},
wantPath: "/vt/data/mydb/table1.ibd",
},
}

// Test unknown base separately since it returns a different error type.
t.Run("unknown base", func(t *testing.T) {
entry := FileEntry{Base: "unknown", Name: "file"}
_, err := entry.fullPath(cnf)
require.Error(t, err)
assert.Contains(t, err.Error(), "unknown base")
})

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.entry.fullPath(cnf)
if tt.wantError != nil {
require.ErrorIs(t, err, tt.wantError)
} else {
require.NoError(t, err)
assert.Equal(t, tt.wantPath, got)
}
})
}
}

func TestShouldDrainForBackupBuiltIn(t *testing.T) {
be := &BuiltinBackupEngine{}

Expand Down
Loading