diff --git a/config/patches/inspec-gem/fix-uninitialized-constant-parser-mixin.patch b/config/patches/inspec-gem/fix-uninitialized-constant-parser-mixin.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a63d2c752a34c51b1ea2ff1fdbe90cb84e1fa7c_Y29uZmlnL3BhdGNoZXMvaW5zcGVjLWdlbS9maXgtdW5pbml0aWFsaXplZC1jb25zdGFudC1wYXJzZXItbWl4aW4ucGF0Y2g= --- /dev/null +++ b/config/patches/inspec-gem/fix-uninitialized-constant-parser-mixin.patch @@ -0,0 +1,45 @@ +From c9bb58e9087b2fe5f211ce042bbce767397ca548 Mon Sep 17 00:00:00 2001 +Message-ID: <c9bb58e9087b2fe5f211ce042bbce767397ca548.1715881810.git.stanhu@gmail.com> +From: Stan Hu <stanhu@gmail.com> +Date: Thu, 2 May 2024 01:46:33 -0700 +Subject: [PATCH] Fix uninitialized constant Parser::AST::Processor::Mixin + (#7030) + +parser 3.3.1.0 introduced +https://github.com/whitequark/parser/pull/1000, which causes this +failure: + +``` +% bundle exec ruby -Itest test/unit/profiles/profile_test.rb +inspec/lib/inspec/utils/profile_ast_helpers.rb:7:in `<class:CollectorBase>': uninitialized constant Parser::AST::Processor::Mixin (NameError) + + include Parser::AST::Processor::Mixin + ^^^^^^^ +``` + +Fix this by inherting from `Parser::AST::Processor` instead. + +Closes #7029 + +Signed-off-by: Stan Hu <stanhu@gmail.com> +--- + lib/inspec/utils/profile_ast_helpers.rb | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/lib/inspec/utils/profile_ast_helpers.rb b/lib/inspec/utils/profile_ast_helpers.rb +index 8e00206f8..299e85bd5 100644 +--- a/lib/inspec/utils/profile_ast_helpers.rb ++++ b/lib/inspec/utils/profile_ast_helpers.rb +@@ -3,8 +3,7 @@ require "rubocop-ast" + module Inspec + class Profile + class AstHelper +- class CollectorBase +- include Parser::AST::Processor::Mixin ++ class CollectorBase < Parser::AST::Processor + include RuboCop::AST::Traversal + + attr_reader :memo +-- +2.45.0 + diff --git a/config/projects/gitlab.rb b/config/projects/gitlab.rb index c4e9692e520c552b126c222a0e29703d616b3718_Y29uZmlnL3Byb2plY3RzL2dpdGxhYi5yYg==..4a63d2c752a34c51b1ea2ff1fdbe90cb84e1fa7c_Y29uZmlnL3Byb2plY3RzL2dpdGxhYi5yYg== 100644 --- a/config/projects/gitlab.rb +++ b/config/projects/gitlab.rb @@ -112,6 +112,7 @@ dependency 'redis' dependency 'nginx' dependency 'chef-gem' +dependency 'inspec-gem' dependency 'logrotate' dependency 'runit' dependency 'go-crond' diff --git a/config/software/inspec-gem.rb b/config/software/inspec-gem.rb new file mode 100644 index 0000000000000000000000000000000000000000..4a63d2c752a34c51b1ea2ff1fdbe90cb84e1fa7c_Y29uZmlnL3NvZnR3YXJlL2luc3BlYy1nZW0ucmI= --- /dev/null +++ b/config/software/inspec-gem.rb @@ -0,0 +1,43 @@ +# +# Copyright 2012-2014 Chef Software, Inc. +# Copyright 2017-2022 GitLab Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +require 'mixlib/shellout' + +name 'inspec-gem' +# The version here should be in agreement with the chef-bin/cinc version and +# /Gemfile.lock so that our rspec testing stays consistent with the package +# contents. +default_version '6.6.0' + +license 'MIT' +license_file 'LICENSE' + +skip_transitive_dependency_licensing true + +dependency 'omnibus-gitlab-gems' + +build do + env = with_standard_compiler_flags(with_embedded_path) + + block 'patch inspec files' do + prefix_path = "#{install_dir}/embedded" + gem_path = shellout!("#{embedded_bin('ruby')} -e \"puts Gem.path.find { |path| path.start_with?(\'#{prefix_path}\') }\"", env: env).stdout.chomp + + # This can be dropped when inspec is updated with https://github.com/inspec/inspec/issues/7030 + patch source: "fix-uninitialized-constant-parser-mixin.patch", + target: "#{gem_path}/gems/inspec-core-#{version}/lib/inspec/utils/profile_ast_helpers.rb" + end +end