From 63ba01504879b7cc4c42445f92a2ba7ec4949c15 Mon Sep 17 00:00:00 2001 From: Bastiaan van den Hoek Date: Tue, 25 Oct 2022 15:03:46 +0200 Subject: [PATCH 1/3] mysql::db sql parameter support filenames with multiple dots --- manifests/db.pp | 4 ++-- spec/defines/mysql_db_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manifests/db.pp b/manifests/db.pp index f40e4d648..38175aa1f 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -76,8 +76,8 @@ # Ensure that the sql files passed are valid file paths. if $sql { $sql.each | $sqlfile | { - if $sqlfile !~ /^\/(?:[A-Za-z0-9_-]+\/?+)+(?:.[A-Za-z0-9]+)$/ { - $message = "The file '${sqlfile}' is invalid. A a valid file path is expected." + if $sqlfile !~ /^\/(?:[A-Za-z0-9_-]+\/?+)+(?:\.[A-Za-z0-9]+)+$/ { + $message = "The file '${sqlfile}' is invalid. A valid file path is expected." fail($message) } } diff --git a/spec/defines/mysql_db_spec.rb b/spec/defines/mysql_db_spec.rb index edbd94151..273707122 100644 --- a/spec/defines/mysql_db_spec.rb +++ b/spec/defines/mysql_db_spec.rb @@ -94,7 +94,7 @@ ].each do |path| it "fails when provided '#{path}' as a value to the 'sql' parameter" do params['sql'] = [path] - is_expected.to raise_error(Puppet::PreformattedError, %r{The file '#{Regexp.escape(path)}' is invalid. A a valid file path is expected.}) + is_expected.to raise_error(Puppet::PreformattedError, %r{The file '#{Regexp.escape(path)}' is invalid. A valid file path is expected.}) end end @@ -103,6 +103,7 @@ '/tmp/test.txt', '/tmp/.test', '/foo.test', + '/foo.test.txt', ].each do |path| it "succeeds when provided '#{path}' as a value to the 'sql' parameter" do params['sql'] = [path] From fa4805184cf9c2030dbf19306609197a25e0260f Mon Sep 17 00:00:00 2001 From: Bastiaan van den Hoek Date: Thu, 27 Oct 2022 19:37:32 +0200 Subject: [PATCH 2/3] mysql::db sql parameter support directorynames with one or more dots --- manifests/db.pp | 2 +- spec/defines/mysql_db_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/db.pp b/manifests/db.pp index 38175aa1f..09a48f41d 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -76,7 +76,7 @@ # Ensure that the sql files passed are valid file paths. if $sql { $sql.each | $sqlfile | { - if $sqlfile !~ /^\/(?:[A-Za-z0-9_-]+\/?+)+(?:\.[A-Za-z0-9]+)+$/ { + if $sqlfile !~ /^\/(?:.[.A-Za-z0-9_-]+\/?+)+(?:\.[.A-Za-z0-9]+)+$/ { $message = "The file '${sqlfile}' is invalid. A valid file path is expected." fail($message) } diff --git a/spec/defines/mysql_db_spec.rb b/spec/defines/mysql_db_spec.rb index 273707122..b9148d2b4 100644 --- a/spec/defines/mysql_db_spec.rb +++ b/spec/defines/mysql_db_spec.rb @@ -104,6 +104,10 @@ '/tmp/.test', '/foo.test', '/foo.test.txt', + '/foo/test/test-1.2.3/schema/test.sql', + '/foo/test/test-1.2.3/schema/foo.test.sql', + '/foo/foo.t1.t2.t3/foo.test-1.2.3/test.test.schema/test..app.sql', + '/foo/foo.t1.t2...t3/foo.test-1.2.3/test.test.schema/test.app.sql', ].each do |path| it "succeeds when provided '#{path}' as a value to the 'sql' parameter" do params['sql'] = [path] From d102abc6d43e1f75a8d265d6730c2b525600dac3 Mon Sep 17 00:00:00 2001 From: Bastiaan van den Hoek Date: Mon, 31 Oct 2022 13:02:06 +0100 Subject: [PATCH 3/3] Fix identation on mysql::db spec test --- spec/defines/mysql_db_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/mysql_db_spec.rb b/spec/defines/mysql_db_spec.rb index b9148d2b4..cd96dcdd0 100644 --- a/spec/defines/mysql_db_spec.rb +++ b/spec/defines/mysql_db_spec.rb @@ -107,7 +107,7 @@ '/foo/test/test-1.2.3/schema/test.sql', '/foo/test/test-1.2.3/schema/foo.test.sql', '/foo/foo.t1.t2.t3/foo.test-1.2.3/test.test.schema/test..app.sql', - '/foo/foo.t1.t2...t3/foo.test-1.2.3/test.test.schema/test.app.sql', + '/foo/foo.t1.t2...t3/foo.test-1.2.3/test.test.schema/test.app.sql', ].each do |path| it "succeeds when provided '#{path}' as a value to the 'sql' parameter" do params['sql'] = [path]