Skip to content
Snippets Groups Projects
Commit 4a63d2c7 authored by Stan Hu's avatar Stan Hu
Browse files

Patch inspec gem to work with future parser gems

Due to https://github.com/inspec/inspec/issues/7029, omnibus-gitlab
will not work if parser 3.3.1.0 and up are installed. Patch the gem
with https://github.com/inspec/inspec/pull/7030 until an update is
available. This will avoid failures if parser 3.3.1.0 is installed and
prevent incidents such as
https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17954.

Changelog: fixed
parent c4e9692e
No related branches found
No related tags found
1 merge request!143Merge upstream Omnibus GitLab up to the 17.1 branching point
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
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
dependency 'redis' dependency 'redis'
dependency 'nginx' dependency 'nginx'
dependency 'chef-gem' dependency 'chef-gem'
dependency 'inspec-gem'
dependency 'logrotate' dependency 'logrotate'
dependency 'runit' dependency 'runit'
dependency 'go-crond' dependency 'go-crond'
......
#
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment