inspec / inspec-azure

InSpec Azure Resource Pack
https://www.inspec.io/
Other
97 stars 80 forks source link

uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState #592

Closed jnahelou closed 2 years ago

jnahelou commented 2 years ago

Inspec crash due to missing import in active support while using inspec-azure.

How to reproduce

$ bundle exec inspec version
4.52.9

$ bundle exec gem list | grep activesupport
activesupport (7.0.0)

$ cat inspec.yml
---
name: default-profile
title: InSpec Profile
maintainer: jnahelou
copyright: jnahelou
copyright_email: jnahelou
license: Apache-2.0
summary: InSpec Compliance Profile
version: 0.1.0
description: Default test configuration
inspec_version: ">= 2.3.5"
depends:
- name: inspec-azure
  url: https://github.com/inspec/inspec-azure/archive/main.tar.gz

$ bundle exec inspec check inspec.yml
<crash with stacktrace>
vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.0/lib/active_support/xml_mini.rb:185:in `current_thread_backend': uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState (NameError)

I found here that they moved to autoload but in inspec-azure, the autoload seems not triggered in requirements:

https://github.com/inspec/inspec-azure/blob/642b6ac749efd11a179f7793283c1d1bd457181b/libraries/backend/azure_require.rb#L8

jnahelou commented 2 years ago

As a workaround, I switched locally in libraries/backend/azure_require.rb

-require 'active_support/core_ext/hash'
+#require 'active_support/core_ext/hash'
+require 'active_support'

and inspec.yml

depends:
- name: inspec-azure
  path: /home/jnahelou/perso/inspec-azure
jnikles1 commented 2 years ago

I ran into this issue as well. Thanks for mentioning the workaround

YohanValette-DXC commented 2 years ago

I also ran into this problem.

I am running kitchen in a vscode devcontainer

# Dockerfile
ARG VARIANT=2-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}

ENV KITCHEN_TF_VERSION='6.0.0'
ENV KITCHEN_SSH_VERSION='1.0.3'

...

RUN gem install \
        kitchen-terraform:${KITCHEN_TF_VERSION} \
        kitchen-ssh:${KITCHEN_SSH_VERSION}

It is not a solution for me to locally clone the inspec-azure repo. Is there a fix planned ?

DesislavaNPetrova commented 2 years ago

I ran into this issue as well. Any updates on the fix?

sathish-progress commented 2 years ago

investigating the issue, a fix should be pushed by EOW.

sathish-progress commented 2 years ago

will be fixed as part of https://github.com/inspec/inspec-azure/pull/608