diff --git a/Gemfile b/Gemfile index 0b007d6fa..6bf1174d9 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ group :omnibus do end group :test do - gem "chefstyle", "~> 1.7.1" + gem "chefstyle", "~> 2.0.3" gem "concurrent-ruby", "~> 1.0" gem "html-proofer", platforms: :ruby # do not attempt to run proofer on windows gem "json_schemer", ">= 0.2.1", "< 0.2.19" diff --git a/lib/inspec/fetcher/local.rb b/lib/inspec/fetcher/local.rb index febf05c1c..61fe4f5cb 100644 --- a/lib/inspec/fetcher/local.rb +++ b/lib/inspec/fetcher/local.rb @@ -31,7 +31,7 @@ module Inspec::Fetcher target = target.gsub(%r{^file://}, "") else # support for windows paths - target = target.tr('\\', "/") + target = target.tr("\\", "/") end target if File.exist?(File.expand_path(target)) diff --git a/lib/inspec/resources/mssql_session.rb b/lib/inspec/resources/mssql_session.rb index 15b8b9276..14abf4e86 100644 --- a/lib/inspec/resources/mssql_session.rb +++ b/lib/inspec/resources/mssql_session.rb @@ -58,7 +58,7 @@ module Inspec::Resources end def query(q) # rubocop:disable Metrics/PerceivedComplexity - escaped_query = q.gsub(/\\/, '\\\\').gsub(/"/, '""').gsub(/\$/, '\\$') + escaped_query = q.gsub(/\\/, "\\\\").gsub(/"/, '""').gsub(/\$/, '\\$') # surpress 'x rows affected' in SQLCMD with 'set nocount on;' cmd_string = "sqlcmd -Q \"set nocount on; #{escaped_query}\" -W -w 1024 -s ','" cmd_string += " -U '#{@user}' -P '#{@password}'" unless @user.nil? || @password.nil? diff --git a/lib/inspec/resources/mysql_session.rb b/lib/inspec/resources/mysql_session.rb index cdc284595..8f24b6510 100644 --- a/lib/inspec/resources/mysql_session.rb +++ b/lib/inspec/resources/mysql_session.rb @@ -75,7 +75,7 @@ module Inspec::Resources def create_mysql_cmd(q, db = "") # TODO: simple escape, must be handled by a library # that does this securely - escaped_query = q.gsub(/\\/, '\\\\').gsub(/"/, '\\"').gsub(/\$/, '\\$') + escaped_query = q.gsub(/\\/, "\\\\").gsub(/"/, '\\"').gsub(/\$/, '\\$') # construct the query command = "mysql" diff --git a/lib/inspec/resources/pip.rb b/lib/inspec/resources/pip.rb index 11da3bbc7..03501efba 100644 --- a/lib/inspec/resources/pip.rb +++ b/lib/inspec/resources/pip.rb @@ -117,7 +117,7 @@ module Inspec::Resources if defined?(windows_paths["Python"]) && pipcmd.nil? return nil if windows_paths["Pip"].nil? - pipdir = windows_paths["Python"].split('\\') + pipdir = windows_paths["Python"].split("\\") # remove python.exe pipdir.pop pipcmd = pipdir.push("Scripts").push("pip.exe").join("/") diff --git a/lib/inspec/resources/registry_key.rb b/lib/inspec/resources/registry_key.rb index c9104adbe..803009598 100644 --- a/lib/inspec/resources/registry_key.rb +++ b/lib/inspec/resources/registry_key.rb @@ -281,7 +281,7 @@ module Inspec::Resources key = @options[:key] return "" unless key - key.start_with?('\\') ? key : "\\#{key}" + key.start_with?("\\") ? key : "\\#{key}" end end diff --git a/lib/inspec/resources/users.rb b/lib/inspec/resources/users.rb index 538c1fe2f..e7ed67e82 100644 --- a/lib/inspec/resources/users.rb +++ b/lib/inspec/resources/users.rb @@ -611,7 +611,7 @@ module Inspec::Resources # @see https://msdn.microsoft.com/en-us/library/aa394153(v=vs.85).aspx class WindowsUser < UserInfo def parse_windows_account(username) - account = username.split('\\') + account = username.split("\\") name = account.pop domain = account.pop unless account.empty? [name, domain] diff --git a/lib/inspec/runner.rb b/lib/inspec/runner.rb index 14dda0290..7ba10bcc0 100644 --- a/lib/inspec/runner.rb +++ b/lib/inspec/runner.rb @@ -243,7 +243,7 @@ module Inspec # to provide access to local profiles that add resources. @depends.each do |dep| # support for windows paths - dep = dep.tr('\\', "/") + dep = dep.tr("\\", "/") Inspec::Profile.for_path(dep, { profile_context: ctx }).load_libraries end diff --git a/lib/inspec/utils/erlang_parser.rb b/lib/inspec/utils/erlang_parser.rb index 2762b0ce3..34132bba4 100644 --- a/lib/inspec/utils/erlang_parser.rb +++ b/lib/inspec/utils/erlang_parser.rb @@ -52,13 +52,13 @@ class ErlangParser < Parslet::Parser rule(:stringS) do str("'") >> ( - str('\\') >> any | str("'").absent? >> any + str("\\") >> any | str("'").absent? >> any ).repeat.as(:string) >> str("'") >> filler? end rule(:stringD) do str('"') >> ( - str('\\') >> any | str('"').absent? >> any + str("\\") >> any | str('"').absent? >> any ).repeat.as(:string) >> str('"') >> filler? end diff --git a/lib/inspec/utils/filter.rb b/lib/inspec/utils/filter.rb index ff4517e4e..e08550425 100644 --- a/lib/inspec/utils/filter.rb +++ b/lib/inspec/utils/filter.rb @@ -375,13 +375,13 @@ module FilterTable methods_to_install_on_resource_class = @filter_methods + @custom_properties.keys methods_to_install_on_resource_class.each do |method_name| resource_class.send(:define_method, method_name) do |*args, &block| - begin - # self here is the resource instance - filter_table_instance = table_class.new(self, send(raw_data_fetcher_method_name), " with") - filter_table_instance.send(method_name, *args, &block) - rescue Inspec::Exceptions::ResourceFailed, Inspec::Exceptions::ResourceSkipped => e - FilterTable::ExceptionCatcher.new(resource_class, e) - end + + # self here is the resource instance + filter_table_instance = table_class.new(self, send(raw_data_fetcher_method_name), " with") + filter_table_instance.send(method_name, *args, &block) + rescue Inspec::Exceptions::ResourceFailed, Inspec::Exceptions::ResourceSkipped => e + FilterTable::ExceptionCatcher.new(resource_class, e) + end end end diff --git a/lib/inspec/utils/nginx_parser.rb b/lib/inspec/utils/nginx_parser.rb index f032a2d41..59c6b8080 100644 --- a/lib/inspec/utils/nginx_parser.rb +++ b/lib/inspec/utils/nginx_parser.rb @@ -31,19 +31,19 @@ class NginxParser < Parslet::Parser rule(:standard_value) do ((match(/[#;{'"]/).absent? >> any) >> ( - str('\\') >> any | match('[#;{]|\s').absent? >> any + str("\\") >> any | match('[#;{]|\s').absent? >> any ).repeat).as(:value) >> space.repeat end rule(:single_quoted_value) do str("'") >> ( - str('\\') >> any | str("'").absent? >> any + str("\\") >> any | str("'").absent? >> any ).repeat.as(:value) >> str("'") >> space.repeat end rule(:double_quoted_value) do str('"') >> ( - str('\\') >> any | str('"').absent? >> any + str("\\") >> any | str('"').absent? >> any ).repeat.as(:value) >> str('"') >> space.repeat end diff --git a/lib/resources/aws/aws_cloudtrail_trail.rb b/lib/resources/aws/aws_cloudtrail_trail.rb index e48e3af2b..e337d8059 100644 --- a/lib/resources/aws/aws_cloudtrail_trail.rb +++ b/lib/resources/aws/aws_cloudtrail_trail.rb @@ -36,12 +36,12 @@ class AwsCloudTrailTrail < Inspec.resource(1) def delivered_logs_days_ago query = { name: @trail_name } catch_aws_errors do - begin - resp = BackendFactory.create(inspec_runner).get_trail_status(query).to_h - ((Time.now - resp[:latest_cloud_watch_logs_delivery_time]) / (24 * 60 * 60)).to_i unless resp[:latest_cloud_watch_logs_delivery_time].nil? - rescue Aws::CloudTrail::Errors::TrailNotFoundException - nil - end + + resp = BackendFactory.create(inspec_runner).get_trail_status(query).to_h + ((Time.now - resp[:latest_cloud_watch_logs_delivery_time]) / (24 * 60 * 60)).to_i unless resp[:latest_cloud_watch_logs_delivery_time].nil? + rescue Aws::CloudTrail::Errors::TrailNotFoundException + nil + end end diff --git a/lib/resources/aws/aws_iam_access_keys.rb b/lib/resources/aws/aws_iam_access_keys.rb index ee34f80bf..73743d0d5 100644 --- a/lib/resources/aws/aws_iam_access_keys.rb +++ b/lib/resources/aws/aws_iam_access_keys.rb @@ -101,27 +101,27 @@ class AwsIamAccessKeys < Inspec.resource(1) access_key_data = [] user_details.each_key do |username| - begin - user_keys = iam_client.list_access_keys(user_name: username) - .access_key_metadata - user_keys = user_keys.map do |metadata| - { - access_key_id: metadata.access_key_id, - username: username, - status: metadata.status, - create_date: metadata.create_date, # DateTime.parse(metadata.create_date), - } - end - # Copy in from user data - # Synthetics - user_keys.each do |key_info| - add_synthetic_fields(key_info, user_details[username]) - end - access_key_data.concat(user_keys) - rescue Aws::IAM::Errors::NoSuchEntity # rubocop:disable Lint/HandleExceptions - # Swallow - a miss on search results should return an empty table + user_keys = iam_client.list_access_keys(user_name: username) + .access_key_metadata + user_keys = user_keys.map do |metadata| + { + access_key_id: metadata.access_key_id, + username: username, + status: metadata.status, + create_date: metadata.create_date, # DateTime.parse(metadata.create_date), + } end + + # Copy in from user data + # Synthetics + user_keys.each do |key_info| + add_synthetic_fields(key_info, user_details[username]) + end + access_key_data.concat(user_keys) + rescue Aws::IAM::Errors::NoSuchEntity # rubocop:disable Lint/HandleExceptions + # Swallow - a miss on search results should return an empty table + end access_key_data end diff --git a/lib/resources/aws/aws_iam_password_policy.rb b/lib/resources/aws/aws_iam_password_policy.rb index 6e0999152..55a912996 100644 --- a/lib/resources/aws/aws_iam_password_policy.rb +++ b/lib/resources/aws/aws_iam_password_policy.rb @@ -20,19 +20,19 @@ class AwsIamPasswordPolicy < Inspec.resource(1) # TODO: rewrite to avoid direct injection, match other resources, use AwsSingularResourceMixin def initialize(conn = nil) catch_aws_errors do - begin - if conn - # We're in a mocked unit test. - @policy = conn.iam_resource.account_password_policy - else - # Don't use the resource approach. It's a CRUD operation - # - if the policy does not exist, you get back a blank object to populate and save. - # Using the Client will throw an exception if no policy exists. - @policy = inspec_runner.backend.aws_client(Aws::IAM::Client).get_account_password_policy.password_policy - end - rescue Aws::IAM::Errors::NoSuchEntity - @policy = nil + + if conn + # We're in a mocked unit test. + @policy = conn.iam_resource.account_password_policy + else + # Don't use the resource approach. It's a CRUD operation + # - if the policy does not exist, you get back a blank object to populate and save. + # Using the Client will throw an exception if no policy exists. + @policy = inspec_runner.backend.aws_client(Aws::IAM::Client).get_account_password_policy.password_policy end + rescue Aws::IAM::Errors::NoSuchEntity + @policy = nil + end end diff --git a/lib/resources/aws/aws_kms_key.rb b/lib/resources/aws/aws_kms_key.rb index 09b5d08ec..eabc0a1c6 100644 --- a/lib/resources/aws/aws_kms_key.rb +++ b/lib/resources/aws/aws_kms_key.rb @@ -56,30 +56,30 @@ class AwsKmsKey < Inspec.resource(1) query = { key_id: @key_id } catch_aws_errors do - begin - resp = backend.describe_key(query) - @exists = true - @key = resp.key_metadata.to_h - @key_id = @key[:key_id] - @arn = @key[:arn] - @creation_date = @key[:creation_date] - @enabled = @key[:enabled] - @description = @key[:description] - @key_usage = @key[:key_usage] - @key_state = @key[:key_state] - @deletion_date = @key[:deletion_date] - @valid_to = @key[:valid_to] - @external = @key[:origin] == "EXTERNAL" - @has_key_expiration = @key[:expiration_model] == "KEY_MATERIAL_EXPIRES" - @managed_by_aws = @key[:key_manager] == "AWS" + resp = backend.describe_key(query) + + @exists = true + @key = resp.key_metadata.to_h + @key_id = @key[:key_id] + @arn = @key[:arn] + @creation_date = @key[:creation_date] + @enabled = @key[:enabled] + @description = @key[:description] + @key_usage = @key[:key_usage] + @key_state = @key[:key_state] + @deletion_date = @key[:deletion_date] + @valid_to = @key[:valid_to] + @external = @key[:origin] == "EXTERNAL" + @has_key_expiration = @key[:expiration_model] == "KEY_MATERIAL_EXPIRES" + @managed_by_aws = @key[:key_manager] == "AWS" + + resp = backend.get_key_rotation_status(query) + @has_rotation_enabled = resp.key_rotation_enabled unless resp.empty? + rescue Aws::KMS::Errors::NotFoundException + @exists = false + return - resp = backend.get_key_rotation_status(query) - @has_rotation_enabled = resp.key_rotation_enabled unless resp.empty? - rescue Aws::KMS::Errors::NotFoundException - @exists = false - return - end end end diff --git a/lib/resources/aws/aws_rds_instance.rb b/lib/resources/aws/aws_rds_instance.rb index 2e0a9ec31..be167e1d2 100644 --- a/lib/resources/aws/aws_rds_instance.rb +++ b/lib/resources/aws/aws_rds_instance.rb @@ -43,13 +43,13 @@ class AwsRdsInstance < Inspec.resource(1) backend = BackendFactory.create(inspec_runner) dsg_response = nil catch_aws_errors do - begin - dsg_response = backend.describe_db_instances(db_instance_identifier: db_instance_identifier) - @exists = true - rescue Aws::RDS::Errors::DBInstanceNotFound - @exists = false - return - end + + dsg_response = backend.describe_db_instances(db_instance_identifier: db_instance_identifier) + @exists = true + rescue Aws::RDS::Errors::DBInstanceNotFound + @exists = false + return + end if dsg_response.db_instances.empty? diff --git a/lib/resources/aws/aws_s3_bucket.rb b/lib/resources/aws/aws_s3_bucket.rb index 89dea9aa8..4e8fce251 100644 --- a/lib/resources/aws/aws_s3_bucket.rb +++ b/lib/resources/aws/aws_s3_bucket.rb @@ -85,30 +85,29 @@ class AwsS3Bucket < Inspec.resource(1) def fetch_bucket_policy backend = BackendFactory.create(inspec_runner) catch_aws_errors do - begin - # AWS SDK returns a StringIO, we have to read() - raw_policy = backend.get_bucket_policy(bucket: bucket_name).policy - return JSON.parse(raw_policy.read)["Statement"].map do |statement| - lowercase_hash = {} - statement.each_key { |k| lowercase_hash[k.downcase] = statement[k] } - @bucket_policy = OpenStruct.new(lowercase_hash) - end - rescue Aws::S3::Errors::NoSuchBucketPolicy - @bucket_policy = [] + + # AWS SDK returns a StringIO, we have to read() + raw_policy = backend.get_bucket_policy(bucket: bucket_name).policy + return JSON.parse(raw_policy.read)["Statement"].map do |statement| + lowercase_hash = {} + statement.each_key { |k| lowercase_hash[k.downcase] = statement[k] } + @bucket_policy = OpenStruct.new(lowercase_hash) end + rescue Aws::S3::Errors::NoSuchBucketPolicy + @bucket_policy = [] + end end def fetch_bucket_encryption_configuration @has_default_encryption_enabled ||= catch_aws_errors do - begin - !BackendFactory.create(inspec_runner) - .get_bucket_encryption(bucket: bucket_name) - .server_side_encryption_configuration - .nil? - rescue Aws::S3::Errors::ServerSideEncryptionConfigurationNotFoundError - false - end + !BackendFactory.create(inspec_runner) + .get_bucket_encryption(bucket: bucket_name) + .server_side_encryption_configuration + .nil? + rescue Aws::S3::Errors::ServerSideEncryptionConfigurationNotFoundError + false + end end diff --git a/lib/resources/aws/aws_s3_bucket_object.rb b/lib/resources/aws/aws_s3_bucket_object.rb index 2f47f77d1..ef28195bf 100644 --- a/lib/resources/aws/aws_s3_bucket_object.rb +++ b/lib/resources/aws/aws_s3_bucket_object.rb @@ -55,16 +55,16 @@ class AwsS3BucketObject < Inspec.resource(1) def fetch_from_api backend = BackendFactory.create(inspec_runner) catch_aws_errors do - begin - # Just use get_object to detect if the bucket exists - backend.get_object(bucket: bucket_name, key: key) - rescue Aws::S3::Errors::NoSuchBucket - @exists = false - return - rescue Aws::S3::Errors::NoSuchKey - @exists = false - return - end + + # Just use get_object to detect if the bucket exists + backend.get_object(bucket: bucket_name, key: key) + rescue Aws::S3::Errors::NoSuchBucket + @exists = false + return + rescue Aws::S3::Errors::NoSuchKey + @exists = false + return + end @exists = true end diff --git a/lib/resources/aws/aws_sns_subscription.rb b/lib/resources/aws/aws_sns_subscription.rb index d3f0772e9..34b29f0bc 100644 --- a/lib/resources/aws/aws_sns_subscription.rb +++ b/lib/resources/aws/aws_sns_subscription.rb @@ -53,19 +53,19 @@ class AwsSnsSubscription < Inspec.resource(1) def fetch_from_api backend = BackendFactory.create(inspec_runner) catch_aws_errors do - begin - aws_response = backend.get_subscription_attributes(subscription_arn: @subscription_arn).attributes - @exists = true - @owner = aws_response["Owner"] - @raw_message_delivery = aws_response["RawMessageDelivery"].eql?("true") - @topic_arn = aws_response["TopicArn"] - @endpoint = aws_response["Endpoint"] - @protocol = aws_response["Protocol"] - @confirmation_was_authenticated = aws_response["ConfirmationWasAuthenticated"].eql?("true") - rescue Aws::SNS::Errors::NotFound - @exists = false - return - end + + aws_response = backend.get_subscription_attributes(subscription_arn: @subscription_arn).attributes + @exists = true + @owner = aws_response["Owner"] + @raw_message_delivery = aws_response["RawMessageDelivery"].eql?("true") + @topic_arn = aws_response["TopicArn"] + @endpoint = aws_response["Endpoint"] + @protocol = aws_response["Protocol"] + @confirmation_was_authenticated = aws_response["ConfirmationWasAuthenticated"].eql?("true") + rescue Aws::SNS::Errors::NotFound + @exists = false + return + end end diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index f13beeaf8..1541e9d36 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -61,16 +61,16 @@ describe "inspec exec with json formatter" do it "properly validates all (valid) unit tests against the schema" do schema = JSONSchemer.schema(JSON.parse(inspec("schema exec-json").stdout)) all_profile_folders.first(1).each do |folder| - begin - out = inspec("exec " + folder + " --reporter json --no-create-lockfile") - # Ensure it parses properly - out = JSON.parse(out.stdout) - failures = schema.validate(out).to_a - _(failures).must_equal [] - rescue JSON::ParserError - # We don't actually care about these; cannot validate if parsing fails! - nil - end + + out = inspec("exec " + folder + " --reporter json --no-create-lockfile") + # Ensure it parses properly + out = JSON.parse(out.stdout) + failures = schema.validate(out).to_a + _(failures).must_equal [] + rescue JSON::ParserError + # We don't actually care about these; cannot validate if parsing fails! + nil + end end diff --git a/test/functional/inspec_exec_jsonmin_test.rb b/test/functional/inspec_exec_jsonmin_test.rb index f5ec96377..58c6d6670 100644 --- a/test/functional/inspec_exec_jsonmin_test.rb +++ b/test/functional/inspec_exec_jsonmin_test.rb @@ -37,16 +37,16 @@ describe "inspec exec" do it "properly validates all (valid) unit tests against the schema" do schema = JSONSchemer.schema(JSON.parse(inspec("schema exec-jsonmin").stdout)) all_profile_folders.first(1).each do |folder| - begin - out = inspec("exec " + folder + " --reporter json-min --no-create-lockfile") - # Ensure it parses properly; discard the result - out = JSON.parse(out.stdout) - failures = schema.validate(out).to_a - _(failures).must_equal [] - rescue JSON::ParserError - # We don't actually care about these; cannot validate if parsing fails! - nil - end + + out = inspec("exec " + folder + " --reporter json-min --no-create-lockfile") + # Ensure it parses properly; discard the result + out = JSON.parse(out.stdout) + failures = schema.validate(out).to_a + _(failures).must_equal [] + rescue JSON::ParserError + # We don't actually care about these; cannot validate if parsing fails! + nil + end end diff --git a/test/functional/inspec_json_profile_test.rb b/test/functional/inspec_json_profile_test.rb index 6ce66b893..6e5cbbe70 100644 --- a/test/functional/inspec_json_profile_test.rb +++ b/test/functional/inspec_json_profile_test.rb @@ -196,16 +196,16 @@ describe "inspec json" do it "properly validates all (valid) unit tests against the schema" do schema = JSONSchemer.schema(JSON.parse(inspec("schema profile-json").stdout)) all_profile_folders.first(1).each do |folder| - begin - out = inspec("json " + folder) - # Ensure it parses properly; discard the result - out = JSON.parse(out.stdout) - failures = schema.validate(out).to_a - _(failures).must_equal [] - rescue JSON::ParserError - # We don't actually care about these; cannot validate if parsing fails! - nil - end + + out = inspec("json " + folder) + # Ensure it parses properly; discard the result + out = JSON.parse(out.stdout) + failures = schema.validate(out).to_a + _(failures).must_equal [] + rescue JSON::ParserError + # We don't actually care about these; cannot validate if parsing fails! + nil + end end end diff --git a/test/functional/inspec_shell_test.rb b/test/functional/inspec_shell_test.rb index 39678deec..324796d55 100644 --- a/test/functional/inspec_shell_test.rb +++ b/test/functional/inspec_shell_test.rb @@ -9,7 +9,7 @@ describe "inspec shell tests" do describe "cmd" do def assert_shell_c(code, exit_status, json = false, stderr = "") json_suffix = " --reporter 'json'" if json - command = "shell -c '#{code.tr("'", '\\\'')}'#{json_suffix}" + command = "shell -c '#{code.tr("'", "\\'")}'#{json_suffix}" # On darwin this value is: # shell -c 'describe file(\"/Users/nickschwaderer/Documents/inspec/inspec/test/functional/inspec_shell_test.rb\") do it { should exist } end' --reporter 'json'" # appears to break in windows. @@ -25,7 +25,7 @@ describe "inspec shell tests" do def assert_shell_c_with_inputs(code, input_cmd, input, exit_status, json = false, stderr = "") json_suffix = " --reporter 'json'" if json - command = "shell -c '#{code.tr("'", '\\\'')}'#{input_cmd} #{input}#{json_suffix}" + command = "shell -c '#{code.tr("'", "\\'")}'#{input_cmd} #{input}#{json_suffix}" # On darwin this value is: # shell -c 'describe file(\"/Users/nickschwaderer/Documents/inspec/inspec/test/functional/inspec_shell_test.rb\") do it { should exist } end' --reporter 'json'" # appears to break in windows. @@ -226,7 +226,7 @@ describe "inspec shell tests" do end def do_shell(code, exit_status = 0, stderr = "") - cmd = "echo '#{code.tr("'", '\\\'')}' | #{exec_inspec} shell" + cmd = "echo '#{code.tr("'", "\\'")}' | #{exec_inspec} shell" self.out = CMD.run_command(cmd) assert_exit_code exit_status, out diff --git a/test/functional/inspec_vendor_test.rb b/test/functional/inspec_vendor_test.rb index 9a30953e8..fb9c6cb57 100644 --- a/test/functional/inspec_vendor_test.rb +++ b/test/functional/inspec_vendor_test.rb @@ -40,7 +40,7 @@ describe "example inheritance profile" do return unless is_windows? prepare_examples("inheritance") do |dir| - dir_with_backslash = File.join(dir, '..\\', File.basename(dir)) + dir_with_backslash = File.join(dir, "..\\", File.basename(dir)) out = inspec("vendor " + dir_with_backslash + " --overwrite") _(File.exist?(File.join(dir, "vendor"))).must_equal true diff --git a/test/unit/fetchers/fetchers_test.rb b/test/unit/fetchers/fetchers_test.rb index ed95af364..8e22cb532 100644 --- a/test/unit/fetchers/fetchers_test.rb +++ b/test/unit/fetchers/fetchers_test.rb @@ -37,7 +37,7 @@ describe "Inspec::Fetcher" do it "is able to handle Windows paths" do # simulate a local windows path file = __FILE__ - file.tr!("/", '\\') + file.tr!("/", "\\") res = Inspec::Fetcher::Registry.resolve(file) _(res).must_be_kind_of Inspec::Fetcher::Local _(res.target).must_equal __FILE__ diff --git a/test/unit/utils/erlang_parser_test.rb b/test/unit/utils/erlang_parser_test.rb index 6d0243d65..310d860a6 100644 --- a/test/unit/utils/erlang_parser_test.rb +++ b/test/unit/utils/erlang_parser_test.rb @@ -39,7 +39,7 @@ describe ErlangParser do end it "parses a root array with a single quoted string" do - _(parsestr('[\'st\\\'r\'].')).must_equal '{:array=>[{:string=>"st\\\\\'r"@2}]}' + _(parsestr("['st\\'r'].")).must_equal '{:array=>[{:string=>"st\\\\\'r"@2}]}' end it "parses a root array with an empty binary" do diff --git a/test/unit/utils/find_files_test.rb b/test/unit/utils/find_files_test.rb index 88157ca38..687f514fc 100644 --- a/test/unit/utils/find_files_test.rb +++ b/test/unit/utils/find_files_test.rb @@ -47,7 +47,7 @@ describe FindFiles do it "builds the correct command when an escaped single quote is used" do inspec.expects(:command).with('sh -c "find /a/\\\'b/"').returns(result) - helper.find_files('/a/\\\'b/') + helper.find_files("/a/\\'b/") end it "builds the correct command when an escaped double quote is used" do