# Chef InSpec with Puppeteer

**URL:** <https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956>\
**Category:** Chef Infra (archive)\
**Created:** [June 7, 2021, 7:01pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956 "2021-06-07T19:01:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 7, 2021, 7:01pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/1 "2021-06-07T19:01:39Z")

</div>

We are trying to test redirection of URLs to our federation page for MFA. The inspec HTTP resource can be used for verification with SAML protected URLs. However, it falls short when it comes to OAuth related redirection. Therefore, we were attempting to use a headless browser via Puppeteer. If we simply run the control we CAN make it work. However, if we try to run the profile, we get the following stack trace.

jo314774@C02FK46DMD6R tests % inspec exec ../profiles/core --controls=^/profile-control-/

**Traceback** (most recent call last):

23: from /usr/local/bin/inspec:255:in `'

22: from /usr/local/bin/inspec:255:in `load'

21: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-bin-4.37.20/bin/inspec:11:in `\<top (required)\>'

20: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/base\_cli.rb:35:in `start'

19: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'

18: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'

17: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke\_command'

16: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'

15: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/cli.rb:285:in `exec'

14: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/runner.rb:135:in `run'

13: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/runner.rb:101:in `load'

12: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/runner.rb:101:in `each'

11: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/runner.rb:107:in `block in load'

10: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile.rb:285:in `load\_libraries'

9: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile\_context.rb:143:in `load\_libraries'

8: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile\_context.rb:143:in `each'

7: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile\_context.rb:144:in `block in load\_libraries'

6: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile\_context.rb:159:in `load\_library\_file'

5: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile\_context.rb:170:in `load\_with\_context'

4: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/profile\_context.rb:170:in `instance\_eval'

3: from libraries/multifactor\_page\_redirect.rb:1:in `load\_with\_context'

2: from /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.20/lib/inspec/dsl\_shared.rb:33:in `require'

1: from /opt/inspec/embedded/lib/ruby/2.7.0/rubygems/core\_ext/kernel\_require.rb:83:in `require'

/opt/inspec/embedded/lib/ruby/2.7.0/rubygems/core\_ext/kernel\_require.rb:83:in `require': **cannot load such file -- puppeteer (**  **LoadError** **)**

Can you please provide guidance.

---

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 10, 2021, 9:42pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/2 "2021-06-10T21:42:14Z")

</div>

@bobchaos , @Tensibai ... are either of you able to help with this question? If not, can you guide me towards someone who can? Thank you!

---

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 10, 2021, 9:43pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/3 "2021-06-10T21:43:11Z")

</div>

@ramereth , @Dan_Webb ... are any of you able to help with this question? If not, can you guide me towards someone who can? Thank you!

---

<div class="post-metadata">

**Author:** ![ramereth](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ramereth/32/2453_2.png) [@ramereth](https://discourse.chef.io/u/ramereth)\
**Post date:** [June 10, 2021, 10:11pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/4 "2021-06-10T22:11:58Z")

</div>

Are you sure that gem is installed in the InSpec environment?

---

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 11, 2021, 3:29pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/5 "2021-06-11T15:29:14Z")

</div>

@ramereth thank you so much for responding. We've tried both "puppeteer" and or "puppeteer-ruby" in our Gemfile and if I do a gem list I see puppeteer-ruby (0.32.3, 0.32.2). Is there something different you mean by "installed in the InSpec environment"?

Forgive me if it's a silly question. I'm fairly new to InSpec.

---

<div class="post-metadata">

**Author:** ![ramereth](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ramereth/32/2453_2.png) [@ramereth](https://discourse.chef.io/u/ramereth)\
**Post date:** [June 11, 2021, 3:53pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/6 "2021-06-11T15:53:38Z")

</div>

InSpec has it's own ruby environment. You need to use `/opt/inspec/embedded/bin/gem` to install/check if the gem is in the correct environment.

---

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 11, 2021, 4:56pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/7 "2021-06-11T16:56:40Z")

</div>

Thank you! This is so helpful. However, I'll have to research errors I'm getting when I try to install...

jo314774@C02FK46DMD6R authentication\_policy % sudo /opt/inspec/embedded/bin/gem install puppeteer-ruby

Password:

Building native extensions. This could take a while...

ERROR: Error installing puppeteer-ruby:

ERROR: Failed to build gem native extension.

current directory: /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/websocket-driver-0.7.4/ext/websocket-driver

/opt/inspec/embedded/bin/ruby -I /opt/inspec/embedded/lib/ruby/2.7.0 -r ./siteconf20210611-8404-1tnjr2g.rb extconf.rb

creating Makefile

current directory: /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/websocket-driver-0.7.4/ext/websocket-driver

make "DESTDIR=" clean

current directory: /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/websocket-driver-0.7.4/ext/websocket-driver

make "DESTDIR="

compiling websocket\_mask.c

linking shared-object websocket\_mask.bundle

current directory: /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/websocket-driver-0.7.4/ext/websocket-driver

make "DESTDIR=" install

make: /usr/local/bin/gmkdir: No such file or directory

make: \*\*\* [.sitearchdir.time] Error 1

make install failed, exit code 2

Gem files will remain installed in /opt/inspec/embedded/lib/ruby/gems/2.7.0/gems/websocket-driver-0.7.4 for inspection.

Results logged to /opt/inspec/embedded/lib/ruby/gems/2.7.0/extensions/x86\_64-darwin-18/2.7.0/websocket-driver-0.7.4/gem\_make.out

---

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 11, 2021, 5:00pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/8 "2021-06-11T17:00:58Z")

</div>

@ramereth ... Fixed via ... brew install coreutils.

This sure looks like at least a partial solution as puppeteer is NOW able to be loaded. Thank you SOOO much!

---

<div class="post-metadata">

**Author:** ![ramereth](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ramereth/32/2453_2.png) [@ramereth](https://discourse.chef.io/u/ramereth)\
**Post date:** [June 11, 2021, 5:18pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/9 "2021-06-11T17:18:44Z")

</div>

Glad that helped!

---

<div class="post-metadata">

**Author:** ![themacoz](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@themacoz](https://discourse.chef.io/u/themacoz)\
**Post date:** [June 11, 2021, 5:33pm UTC](https://discourse.chef.io/t/chef-inspec-with-puppeteer/19956/10 "2021-06-11T17:33:38Z")

</div>

> [@ramereth](#):
>
> /opt/inspec/embedded/bin/gem

Is there some documentation I missed somewhere that would would have taught me about ... /opt/inspec/embedded/bin/gem
