From 9c89df8cb46651c47afff91d97804a38d3b75a81 Mon Sep 17 00:00:00 2001 From: ERAMOTO Masaya Date: Thu, 22 Mar 2018 10:20:18 +0900 Subject: [PATCH 1/3] Mitigate warning on test by initializing --- lib/bundles/inspec-habitat/profile.rb | 1 + lib/inspec/profile.rb | 3 +++ lib/inspec/profile_context.rb | 1 + lib/resources/http.rb | 2 ++ lib/utils/filter.rb | 1 + test/unit/reporters/cli_test.rb | 2 +- 6 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/bundles/inspec-habitat/profile.rb b/lib/bundles/inspec-habitat/profile.rb index 9fe8fe88d1..424d089a80 100644 --- a/lib/bundles/inspec-habitat/profile.rb +++ b/lib/bundles/inspec-habitat/profile.rb @@ -31,6 +31,7 @@ def self.upload(path, options = {}) def initialize(path, options = {}) @path = path @options = options + @cli_config = nil log_level = options.fetch('log_level', 'info') Habitat::Log.level(log_level.to_sym) diff --git a/lib/inspec/profile.rb b/lib/inspec/profile.rb index 3b5ba8fcb6..ef569117f1 100644 --- a/lib/inspec/profile.rb +++ b/lib/inspec/profile.rb @@ -115,6 +115,9 @@ def initialize(source_reader, options = {}) @runner_context = options[:profile_context] || Inspec::ProfileContext.for_profile(self, @backend, @attr_values) + + @supports_platform = metadata.supports_platform?(@backend) + @supports_runtime = metadata.supports_runtime? end def name diff --git a/lib/inspec/profile_context.rb b/lib/inspec/profile_context.rb index cfc681a102..0a4c7a06d6 100644 --- a/lib/inspec/profile_context.rb +++ b/lib/inspec/profile_context.rb @@ -38,6 +38,7 @@ def initialize(profile_id, backend, conf) # in the transitive dependency tree of the loaded profile. @resource_registry = Inspec::Resource.new_registry @library_eval_context = Inspec::LibraryEvalContext.create(@resource_registry, @require_loader) + @current_load = nil end def dependencies diff --git a/lib/resources/http.rb b/lib/resources/http.rb index 8c8f2e21f0..d1ab89afbc 100644 --- a/lib/resources/http.rb +++ b/lib/resources/http.rb @@ -74,6 +74,7 @@ def initialize(http_method, url, opts) @http_method = http_method @url = url @opts = opts + @response = nil end private @@ -152,6 +153,7 @@ def initialize(inspec, http_method, url, opts) 'curl is not available on the target machine' end + @ran_curl = false @inspec = inspec super(http_method, url, opts) end diff --git a/lib/utils/filter.rb b/lib/utils/filter.rb index 04c18aeeb5..c5a307d343 100644 --- a/lib/utils/filter.rb +++ b/lib/utils/filter.rb @@ -180,6 +180,7 @@ class Factory def initialize @accessors = [] @connectors = {} + @resource = nil end def connect(resource, table_accessor) # rubocop:disable Metrics/AbcSize diff --git a/test/unit/reporters/cli_test.rb b/test/unit/reporters/cli_test.rb index b996c4d0ca..c9b9d207c6 100644 --- a/test/unit/reporters/cli_test.rb +++ b/test/unit/reporters/cli_test.rb @@ -230,7 +230,7 @@ def windowize(string) it 'confirm controls' do result = report.send(:anonymous_controls_from_profile, profile) result.count.must_equal 3 - result.first[:id].must_match /generated/ + result.first[:id].must_match(/generated/) end end From 969a94edd382f82168014877e62973a7467c1a0c Mon Sep 17 00:00:00 2001 From: ERAMOTO Masaya Date: Thu, 22 Mar 2018 10:21:10 +0900 Subject: [PATCH 2/3] Suppress notification --- .travis.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4739ebfed..3bca3585ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,13 +71,6 @@ matrix: - AFFECTED_DIRS="www" - secure: "jdzXUhP1o7RkfSikZLKgUcCIaKqLjqWa35dnxWnz7qAQ2draRKa7I7cXmUv76BZkW8HBUUH11dOi8YOVxPYPOzaqvcTCfqNqGVxsT9epgWa7rA8aXMXkECp548ry1rYJQpti9zpwsoe2GQyNPr9vNiWMiyj51CaABmZ6JzmFEEqlZc8vqpqWeqJvIqaibQGk7ByLKmi4R44fVwFKIG39RuxV+alc/G4nnQ2zmNTFuy8uFGs5EghQvRytzWY+s2AKtDiZ0YXYOII1Nl1unXNnNoQt9oI209ztlSm1+XOuTPelW6bEIx5i7OZFaSRPgJzWnkGN85C9nBE08L2az9Jz18/rYJF4fdVRttdGskueyYI21lh1FwlAg51ZG0RfLTYk2Pq+k4c+NO1cfmGcaXBwihfD5BWqrILU5HHkYszXCSmgl4hscC7/BS4Kgcq2z32JJwV8B+x4XngM0G4uzIn1Soia3lZXEKdnfVsxFDdMQ7FK60F3uQlq/44LRkZujRhqfAKOiz+0tsLexWzj7wK+DJY9Y00CUfh7xcxRxDxFNpOv1FWYFB9lUlaOt3HDHgUoksqbURiUzhOZZzTE/1MAtF2K6mbpME5CbN08J88L5JBlb+CX79XCzj30lNMeS0I/dCRQEmkygr2eJYxvRO2qsBNuphs4SWk8NZyS/llVZFI=" -notifications: - slack: - secure: zwOu1gWt8wBDzlhXrYJ39jBDYTYj4Zb8/Z5XH6PalFOyYBytOLYqmpPzxw5KTzFapmcxYt1/biViX25+zapSSmDBuDa94ZneaXuCZAPXX0UJb82ORALMDsdbV1TkkS4Q6N4soigLJ5UaJwIgkZze9VtXeUvo3g8L8+mDYX4J0Poi7Kf/f1KZycNhgaVs7N/i2AI3lBeiVJv+giQbA99OR5dxPzkbx1BeZCK+W+YEPFmg1xycAItiHq0unT+kBN4pm9gW8TT1s/ZucUsKVu6Q8inw5N0PjZwboOkqsQFi5BweVicZBcbOVsW3Xs/f8DX2G823y73Al3QQg+ENxnIpizsHfjE+YzXUVsZ7v/UdsOq01Khxz1GK/X/PYrvIdHQKBwZ86RPJP61BvGIaQ4Hy6f9z+o2Tl/EaAmiOMScpdFi7sMskm8xknI0G24ZG5hkd7XNQ1eVvu33dvs+u12DsBGIylnwrppMDGnh022I5Hg8pS9tJ9gAsJlSFoIBn/yOryoFYb4avB8ujvN6+8cbZgkQ41k6ydqCHk2DxWmhsM4dUVXqC36sOePDE8a/DK5uQ057DSai5M+go5LeEJyK5r4fT5nbTk3nW6CGH0k2bPGWH5aP22mSKB9r2alDzqVfVyArfgtBIX2OXS/cZLER26a1EcB4mf3PMPDB06Aekyj0= - on_success: change - on_failure: always - on_pull_requests: false - deploy: provider: rubygems on: From cfc75f64e96391c7382b34ff60952f9eb620e676 Mon Sep 17 00:00:00 2001 From: ERAMOTO Masaya Date: Thu, 22 Mar 2018 17:13:09 +0900 Subject: [PATCH 3/3] Mitigate warning by removing previous defined method --- lib/resources/azure/azure_virtual_machine_data_disk.rb | 2 -- lib/resources/nginx.rb | 2 +- lib/resources/os_env.rb | 1 - test/unit/resources/aws_s3_bucket_test.rb | 3 --- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/resources/azure/azure_virtual_machine_data_disk.rb b/lib/resources/azure/azure_virtual_machine_data_disk.rb index f879395d5e..ed0959ca09 100644 --- a/lib/resources/azure/azure_virtual_machine_data_disk.rb +++ b/lib/resources/azure/azure_virtual_machine_data_disk.rb @@ -17,8 +17,6 @@ class AzureVirtualMachineDataDisk < AzureResourceBase filter = FilterTable.create filter.add_accessor(:where) .add_accessor(:entries) - .add_accessor(:has_data_disks?) - .add_accessor(:count) .add(:exists?) { |x| !x.entries.empty? } .add(:disk, field: :disk) .add(:number, field: :number) diff --git a/lib/resources/nginx.rb b/lib/resources/nginx.rb index 1c9ce38181..96a3935639 100644 --- a/lib/resources/nginx.rb +++ b/lib/resources/nginx.rb @@ -34,7 +34,7 @@ def initialize(nginx_path = '/usr/sbin/nginx') read_content end - %w{compiler_info error_log_path http_client_body_temp_path http_fastcgi_temp_path http_log_path http_proxy_temp_path http_scgi_temp_path http_uwsgi_temp_path lock_path modules_path openssl_version prefix sbin_path service support_info version}.each do |property| + %w{error_log_path http_client_body_temp_path http_fastcgi_temp_path http_log_path http_proxy_temp_path http_scgi_temp_path http_uwsgi_temp_path lock_path modules_path prefix sbin_path service version}.each do |property| define_method(property.to_sym) do @params[property.to_sym] end diff --git a/lib/resources/os_env.rb b/lib/resources/os_env.rb index f3ddcb716b..df7cee4a80 100644 --- a/lib/resources/os_env.rb +++ b/lib/resources/os_env.rb @@ -22,7 +22,6 @@ class OsEnv < Inspec.resource(1) end " - attr_reader :content def initialize(env = nil) @osenv = env end diff --git a/test/unit/resources/aws_s3_bucket_test.rb b/test/unit/resources/aws_s3_bucket_test.rb index e3e3ea86c3..988bc70f4a 100644 --- a/test/unit/resources/aws_s3_bucket_test.rb +++ b/test/unit/resources/aws_s3_bucket_test.rb @@ -163,9 +163,6 @@ def test_be_public_auth_acl def test_be_public_private_acl refute(AwsS3Bucket.new('private').public?) end - def test_be_public_public_acl - assert(AwsS3Bucket.new('public').public?) - end def test_has_access_logging_enabled_positive assert(AwsS3Bucket.new('public').has_access_logging_enabled?)