PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FIX (backups): Extend filtering lists to detect from-image DB access
Rostislav Dugind98baa065625
diff --git a/backend/internal/features/databases/databases/postgresql/model.go b/backend/internal/features/databases/databases/postgresql/model.goindex c39ead05..9b642c64 100644--- a/backend/internal/features/databases/databases/postgresql/model.go+++ b/backend/internal/features/databases/databases/postgresql/model.go@@ -90,8 +90,18 @@ func (p *PostgresqlDatabase) Validate() error {// because it would expose internal metadata to non-system administrators.// To properly backup Databasus, see: https://databasus.com/faq#backup-databasusif p.Database != nil && *p.Database != "" {- localhostHosts := []string{"localhost", "127.0.0.1", "172.17.0.1", "host.docker.internal"}+ localhostHosts := []string{+ "localhost",+ "127.0.0.1",+ "172.17.0.1",+ "host.docker.internal",+ "::1", // IPv6 loopback (equivalent to 127.0.0.1)+ "::", // IPv6 all interfaces (equivalent to 0.0.0.0)+ "0.0.0.0", // IPv4 all interfaces+ }+isLocalhost := false+for _, host := range localhostHosts {if strings.EqualFold(p.Host, host) {isLocalhost = true@@ -99,6 +109,11 @@ func (p *PostgresqlDatabase) Validate() error {}}+ // Also check if the host is in the entire 127.0.0.0/8 loopback range+ if strings.HasPrefix(p.Host, "127.") {+ isLocalhost = true+ }+if isLocalhost && strings.EqualFold(*p.Database, "databasus") {return errors.New("backing up Databasus internal database is not allowed. To backup Databasus itself, see https://databasus.com/faq#backup-databasus",diff --git a/backend/internal/features/databases/databases/postgresql/model_test.go b/backend/internal/features/databases/databases/postgresql/model_test.goindex 69c73699..f2101130 100644--- a/backend/internal/features/databases/databases/postgresql/model_test.go+++ b/backend/internal/features/databases/databases/postgresql/model_test.go@@ -754,6 +754,42 @@ func Test_Validate_WhenLocalhostAndDatabasus_ReturnsError(t *testing.T) {username: "myuser",database: "databasus",},+ {+ name: "::1 (IPv6 loopback) with databasus db",+ host: "::1",+ username: "postgres",+ database: "databasus",+ },+ {+ name: ":: (IPv6 all interfaces) with databasus db",+ host: "::",+ username: "postgres",+ database: "databasus",+ },+ {+ name: "::1 (uppercase) with DATABASUS db",+ host: "::1",+ username: "POSTGRES",+ database: "DATABASUS",+ },+ {+ name: "0.0.0.0 (all IPv4 interfaces) with databasus db",+ host: "0.0.0.0",+ username: "postgres",+ database: "databasus",+ },+ {+ name: "127.0.0.2 (loopback range) with databasus db",+ host: "127.0.0.2",+ username: "postgres",+ database: "databasus",+ },+ {+ name: "127.255.255.255 (end of loopback range) with databasus db",+ host: "127.255.255.255",+ username: "postgres",+ database: "databasus",+ },}for _, tc := range testCases {