SlideShare a Scribd company logo
What did you InSpec?
https://github.com/gdha/inspec-
cfgmgmtcamp-ghent-2019
Gratien D'haese
IT3 Consultants
2019 - Gratien D'haese What did you InSpec? 2
Who am I?
●
Gratien D'haese
●
IT3 Consultants (company)
●
> 30 years Unix experience
●
Unix/Linux Engineer (incl. DevOps)
●
Web: it3.be
●
Relax-and-Recover (ReaR)
●
Linux disaster recovery framework
●
Open Source pages:
https://github.com/gdha
2019 - Gratien D'haese What did you InSpec? 3
Bit of history
pre-historic times
2019 - Gratien D'haese What did you InSpec? 4
Bit of history
power to the Ops
●
system administrators = Ops
●
powerful shell scripts used for:
●
Update
●
Control
●
Security
●
Monitor
●
Battle between Ops and Devs
●
No CI/CD
●
Lots of Change Controls
2019 - Gratien D'haese What did you InSpec? 5
Ops -> DevOps
●
it’s everyone’s job now
●
Ops tools for devs
●
Software engineers (devs) learn ops
●
Admins transition to devs
2019 - Gratien D'haese What did you InSpec? 6
DevOps and the rest
●
Developers want tests
●
Operations want peace
●
Compliance Officers want √
●
Security Officers do not want holes
2019 - Gratien D'haese What did you InSpec? 7
What is InSpec
●
InSpec is an open-source testing frameworktesting framework
provided by Chef
●
Human-readable language for specifying
compliance, security and policy requirements
●
Extensible language
●
Re-usable
●
Command-line
●
Integrates with Test Kitchen
2019 - Gratien D'haese What did you InSpec? 8
What InSpec is not
●
Is not a capacity planning tool
●
Is not a monitoring tool
●
Is not a logging tool
●
Is not a configuration management tool
●
Is not a firewall tool
●
Is not a intrusion detection tool
2019 - Gratien D'haese What did you InSpec? 9
Why using InSpec?
●
Less scripts for verification required
●
One Language for many platforms
●
Easy to read
●
Easy to hand-over
●
Easy to share
●
Big collection of ready to use profiles
●
Excellent documentation
●
No need to be a nerd
2019 - Gratien D'haese What did you InSpec? 10
Features of InSpec
●
Supports many Operating Systems
●
Linux
●
Mac/OS
●
BSD, Solaris, AIX, HP-UX
●
Windows
●
Supports many Hypervisors, VMs, bare-metal
●
Support different Cloud Providers
●
Supports docker
●
Supports DBs
2019 - Gratien D'haese What did you InSpec? 11
Why should you care?
●
Do you want to be the next?
New Data Breach exposes 57 million records
https://blog.hackenproof.com/industry-news/new-data-
breach-exposes-57-million-records/
●
Protection of your assets – data (security)
●
IQ/OQ Compliance
●
System validation after major changes
●
CI/CD integration checks
2019 - Gratien D'haese What did you InSpec? 12
Idiot proof
# inspec exec https://github.com/lnxchk/inspec-
profile-wannacry-exploit/archive/master.tar.gz -i
./insecure_keys/vagrant.private -t
ssh://root@server
Profile: WannaCry Exploit Mitigation Status
(wannacry-exploit)
Version: 0.2.0
Target: ssh://root@server:22
× WannaCry Vulnerability Check: Hot-fix mitigation
check for WannaCry Ransomware vulnerability (23
failed)
Can you guess what is wrong with above
test?
2019 - Gratien D'haese What did you InSpec? 13
Wannacry on Windows
# inspec exec https://github.com/lnxchk/inspec-
profile-wannacry-exploit/archive/master.tar.gz -t
winrm://administrator@10.180.4.12 --password xxxx
Profile: WannaCry Exploit Mitigation Status (wannacry-exploit)
Version: 0.2.0
Target:
winrm://administrator@http://10.180.4.12:5985/wsman:3389
✔ WannaCry Vulnerability Check: Hot-fix mitigation check for
WannaCry Ransomware vulnerability
✔ WMI with {:class=>"win32_quickfixengineering",
:filter=>"HotFixID = 'KB4012213'"} InstalledOn should not eq
nil
Profile Summary: 1 successful control, 0 control failures, 0
controls skipped
Test Summary: 1 successful, 0 failures, 0 skipped
2019 - Gratien D'haese What did you InSpec? 14
InSpec Basics
●
Start with a demo – mychefdk container
●
Launch the container and use inspec to check
for my account
●
Check inside the container
●
Check from outside the container
●
Run cookbook myaccount inside the container
●
Re-run the checks again
2019 - Gratien D'haese What did you InSpec? 15
InSpec Basics (continued)
●
Download from https://www.inspec.io/
●
Open Source at GitHub:
https://github.com/inspec/inspec
●
Resources
●
InSpec uses built-in resources for common
services, system files and configurations
https://www.inspec.io/docs/reference/resources/
●
Resources work on many Linux platforms, and also
on Windows
2019 - Gratien D'haese What did you InSpec? 16
InSpec resources
●
OS resources
●
apache
●
bond
●
command
●
directory
●
docker
●
etc_fstab
●
group
●
mssql_session
●
and so on
●
Cloud resources
●
AWS
●
Azure
●
Google
2019 - Gratien D'haese What did you InSpec? 17
unless os.windows?
# This is an example test, replace with your own test.
describe user('root') do
it { should exist }
end
describe user('gdha') do
it { should exist }
its('uid') { should eq 501 }
its('group') { should eq 'users'}
its('home') { should eq '/home/gdha' }
its('shell') { should eq '/bin/bash' }
end
end
describe port(80) do
it { should_not be_listening }
end
Resource
Matcher
2019 - Gratien D'haese What did you InSpec? 18
Matchers
●
should exist
●
should be_in
●
should_not match /blabla/
●
should eq
●
should_not eq
●
should cmp
●
https://www.inspec.io/docs/reference/matchers/
2019 - Gratien D'haese What did you InSpec? 19
Profiles
●
Profiles is about sharing and caring
●
Built around “controls” that can be reviewed
●
Each profile can have multiple tests
●
Include profiles from outside this test
●
Profiles can be published to be re-used
●
More at
https://www.inspec.io/docs/reference/profiles/
2019 - Gratien D'haese What did you InSpec? 20
Profiles (continued)
$ inspec init profile dockerprofile
Create new profile at
/Users/gdha/data/projects/inspec/dockerprofile
• Create directory libraries
• Create file README.md
• Create directory controls
• Create file controls/example.rb
• Create file inspec.yml
• Create file libraries/.gitkeep
Add more tests
under this directory
2019 - Gratien D'haese What did you InSpec? 21
Inspec shell
root@c26e2f2d7904:/# inspec shell
Welcome to the interactive InSpec Shell
To find out how to use it, type: help
You are currently running on:
Name: ubuntu
Families: debian, linux, unix, os
Release: 18.04
Arch: x86_64
inspec> help
inspec> command('uname -s').stdout
=> "Linuxn"
2019 - Gratien D'haese What did you InSpec? 22
Inspec shell (continued)
inspec> describe file('/etc/gshadow') do
inspec> it { should be_owned_by 'root' }
inspec> end
Profile: inspec-shell
Version: (not specified)
File /etc/gshadow
✔ should be owned by "root"
Test Summary: 1 successful, 0 failures, 0 skipped
2019 - Gratien D'haese What did you InSpec? 23
Example: source control file
$ cat inspec-path-check/controls/path.rb
title 'DOT in PATH variable'
control 'path-1.0' do # A unique ID for this control
impact 1.0 # The criticality, if this control fails.
title 'DOT in PATH variable'
desc 'An optional description...'
describe os_env('PATH') do # The actual test
its('split') { should_not include('') }
its('split') { should_not include('.') }
end
end
2019 - Gratien D'haese What did you InSpec? 24
Profiles
●
InSpec profiles allow you to share and pack
sets of tests
●
Built around controls (see previous example)
●
Profiles can have multiple tests
●
May depend on external profiles
●
Publishing of your profiles is possible
●
inspec init profile <profile-name>
●
inspec check <profile-name>
2019 - Gratien D'haese What did you InSpec? 25
Running inspec
●
Inspec on command line
●
Can run locally on this machine
●
inspec exec profile-name
●
Run remotely via target option
●
inspec exec profile-name -i pub.key -t
ssh://user@system
●
inspec exec profile-name -t
winrm://administrator@system --password secret
●
Run via test kitchen
2019 - Gratien D'haese What did you InSpec? 26
Excute a local path
$ inspec exec inspec-path-check
$ inspec exec /full/path/to/inspec-path-check
Profile: PATH check InSpec Profile (path-check)
Version: 0.1.0
Target: local://
✔ path-1.0: DOT in PATH variable
✔ Environment variable PATH split should not include ""
✔ Environment variable PATH split should not include "."
Profile Summary: 1 successful control, 0 control failures, 0
controls skipped
Test Summary: 2 successful, 0 failures, 0 skipped
2019 - Gratien D'haese What did you InSpec? 27
Execute a GIT repo
$ inspec exec https://github.com/gdha/inspec-path-check
[2019-01-16T18:10:26+01:00] WARN: URL target
https://github.com/gdha/inspec-path-check transformed to
https://github.com/gdha/inspec-path-
check/archive/master.tar.gz. Consider using the git fetcher
Profile: PATH check InSpec Profile (path-check)
Version: 0.1.0
Target: local://
✔ path-1.0: DOT in PATH variable
✔ Environment variable PATH split should not include ""
✔ Environment variable PATH split should not include "."
Profile Summary: 1 successful control, 0 control failures, 0
controls skipped
Test Summary: 2 successful, 0 failures, 0 skipped
2019 - Gratien D'haese What did you InSpec? 28
Execute in a docker container
$ inspec exec -t docker://c26e2f2d7904 inspec-path-check
Profile: PATH check InSpec Profile (path-check)
Version: 0.1.0
Target:
docker://c26e2f2d79041252b2646baea3d64f18f52eea9b45a2443f3325a9
4221e10a4e
✔ path-1.0: DOT in PATH variable
✔ Environment variable PATH split should not include ""
✔ Environment variable PATH split should not include "."
Profile Summary: 1 successful control, 0 control failures, 0
controls skipped
Test Summary: 2 successful, 0 failures, 0 skipped
2019 - Gratien D'haese What did you InSpec? 29
Execute inspec remotely
$ inspec exec -t ssh://client --password vagrant
../path-check/
Profile: PATH check InSpec Profile (path-check)
Version: 0.1.0
Target: ssh://root@client:22
✔ path-1.0: DOT in PATH variable
✔ Environment variable PATH split should not include ""
✔ Environment variable PATH split should not include "."
Profile Summary: 1 successful control, 0 control failures, 0
controls skipped
Test Summary: 2 successful, 0 failures, 0 skipped
$ inspec exec -t winrm://admin@windows --password
xx ../patch-check
2019 - Gratien D'haese What did you InSpec? 30
Using InSpec with Test Kitchen
driver:
name: vagrant
provisioner:
name: chef_zero
verifier:
name: inspec
platforms:
- name: centos-7.6
suites:
- name: default
run_list:
- recipe[nginx_test::default]
verifier:
inspec_tests:
- test/integration/default
2019 - Gratien D'haese What did you InSpec? 31
Kitchen verify
$ kitchen verify
-----> Starting Kitchen (v1.24.0)
-----> Verifying <default-centos-76>...
Loaded tests from
{:path=>".Users.gdha.data.projects.inspec.inspec-cfgmgmtcamp-
ghent-2019.cookbooks.nginx_test.test.integration.default"}
User root
✔ should exist
Port 80
✔ should be listening
System Package nginx
✔ should be installed
File /etc/nginx/sites-available/default
✔ should exist
Command: `curl localhost`
✔ stdout should match "Welcome"
Test Summary: 5 successful, 0 failures, 0 skipped
Finished verifying <default-centos-76> (0m0.81s).
-----> Kitchen is finished. (0m7.83s)
2019 - Gratien D'haese What did you InSpec? 32
DevSec Linux Security
Baseline (linux-baseline)
# docker ps
CONTAINER ID IMAGE COMMAND
1e2ef5665f9f openshift/base-centos7 ...
# inspec exec https://github.com/dev-sec/linux-baseline -t
docker://1e2ef5665f9f
✔ os-01: Trusted hosts login
✔ File /etc/hosts.equiv should not exist
✔ os-02: Check owner and permissions for /etc/shadow
✔ File /etc/shadow should exist
✔ File /etc/shadow should be file
Profile Summary: 14 successful controls, 3 control
failures, 37 controls skipped
Test Summary: 53 successful, 8 failures, 37 skipped
More details at https://dev-sec.io/
2019 - Gratien D'haese What did you InSpec? 33
ReaR Automated Testing
client server
recover
2019 - Gratien D'haese What did you InSpec? 34
2019 - Gratien D'haese What did you InSpec? 35
Links
●
https://github.com/gdha/inspec-cfgmgmtcamp-
ghent-2019
●
https://github.com/inspec/inspec
●
https://www.inspec.io/
●
https://www.inspec.io/docs/reference/resources/
●
http://www.it3.be/
●
https://gdha.github.io/rear-automated-testing/
●
mailto:gratien.dhaese@it3.be

More Related Content

PDF
JenkinsPy workshop
PPTX
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
PDF
Assign, commit, and review - A developer’s guide to OpenStack contribution-20...
PDF
Assign, Commit, and Review
ODP
Nagios Conference 2012 - Mike Weber - NRPE
PDF
Nebula: Netflix's OSS Gradle Plugins
PDF
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017
JenkinsPy workshop
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Assign, commit, and review - A developer’s guide to OpenStack contribution-20...
Assign, Commit, and Review
Nagios Conference 2012 - Mike Weber - NRPE
Nebula: Netflix's OSS Gradle Plugins
Continuous Delivery w projekcie Open Source - Marcin Stachniuk - DevCrowd 2017

What's hot (20)

PDF
Prepare to defend thyself with Blue/Green
PPTX
Skaffold - faster development on K8S
PDF
Introducción a git y GitHub
PDF
Git and Github
PDF
Git and github fundamental
PPTX
GitFlow, SourceTree and GitLab
PDF
An Introduction to Rancher
KEY
The everyday developer's guide to version control with Git
PDF
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
PDF
Secure Programming Practices in C++ (NDC Oslo 2018)
PPTX
Nagios distributed monitoring for web applications
PDF
Writing Commits for You, Your Friends, and Your Future Self
PPTX
PDF
Git Introduction Tutorial
PPTX
Android presentation - Gradle ++
PPTX
PPTX
More developers on DevOps with Docker orchestration
PPT
Open Source Collaboration With Git And Git Hub
PDF
Мониторинг облачной CI-системы на примере Jenkins / Александр Акбашев (HERE T...
Prepare to defend thyself with Blue/Green
Skaffold - faster development on K8S
Introducción a git y GitHub
Git and Github
Git and github fundamental
GitFlow, SourceTree and GitLab
An Introduction to Rancher
The everyday developer's guide to version control with Git
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
Secure Programming Practices in C++ (NDC Oslo 2018)
Nagios distributed monitoring for web applications
Writing Commits for You, Your Friends, and Your Future Self
Git Introduction Tutorial
Android presentation - Gradle ++
More developers on DevOps with Docker orchestration
Open Source Collaboration With Git And Git Hub
Мониторинг облачной CI-системы на примере Jenkins / Александр Акбашев (HERE T...
Ad

Similar to What did you inspec? (20)

PDF
Inspec: Turn your compliance, security, and other policy requirements into au...
PPTX
InSpec - June 2018 at Open28.be
PPTX
Adding Security and Compliance to Your Workflow with InSpec
PPTX
InSpec Workflow for DevOpsDays Riga 2017
PPTX
Using Chef InSpec for Infrastructure Security
PPTX
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
PPTX
InSpec For DevOpsDays Amsterdam 2017
PPTX
Adding Security to Your Workflow with InSpec (MAY 2017)
PPTX
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
PDF
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
PPTX
Adding Security to Your Workflow With InSpec - SCaLE17x
PPTX
Building Security into Your Workflow with InSpec
PPTX
InSpec at DevOps ATL Meetup January 22, 2020
PDF
Prescriptive System Security with InSpec
PPTX
Prescriptive Security with InSpec - All Things Open 2019
PPTX
DevOpsDays InSpec Workshop
PPTX
DevSecCon London 2017: Inspec workshop by Mandi Walls
PPTX
InSpec Workshop DevSecCon 2017
PPTX
BuildStuff.LT 2018 InSpec Workshop
PPTX
InSpec Workshop at Velocity London 2018
Inspec: Turn your compliance, security, and other policy requirements into au...
InSpec - June 2018 at Open28.be
Adding Security and Compliance to Your Workflow with InSpec
InSpec Workflow for DevOpsDays Riga 2017
Using Chef InSpec for Infrastructure Security
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
InSpec For DevOpsDays Amsterdam 2017
Adding Security to Your Workflow with InSpec (MAY 2017)
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
Adding Security to Your Workflow With InSpec - SCaLE17x
Building Security into Your Workflow with InSpec
InSpec at DevOps ATL Meetup January 22, 2020
Prescriptive System Security with InSpec
Prescriptive Security with InSpec - All Things Open 2019
DevOpsDays InSpec Workshop
DevSecCon London 2017: Inspec workshop by Mandi Walls
InSpec Workshop DevSecCon 2017
BuildStuff.LT 2018 InSpec Workshop
InSpec Workshop at Velocity London 2018
Ad

More from Gratien D'haese (11)

PDF
Open Technology Assemby Open Source Support Program
PDF
Rear automated testing with Bareos
PDF
Relax-and-Recover Automated Testing
PDF
Business Continuity Planning with Bareos and rear (Loadays 2015)
PDF
Upgrade ux-fosdem-2015-gdhaese
PDF
Cfg2html fosdem2014
PDF
Adhocr T-dose 2012
PDF
LinuxTag2012 Rear
PDF
Linux Disaster Recovery Best Practices with rear
PDF
Exploring I Pv6
PPT
Linux Disaster Recovery Solutions
Open Technology Assemby Open Source Support Program
Rear automated testing with Bareos
Relax-and-Recover Automated Testing
Business Continuity Planning with Bareos and rear (Loadays 2015)
Upgrade ux-fosdem-2015-gdhaese
Cfg2html fosdem2014
Adhocr T-dose 2012
LinuxTag2012 Rear
Linux Disaster Recovery Best Practices with rear
Exploring I Pv6
Linux Disaster Recovery Solutions

Recently uploaded (20)

PPTX
Top Website Bugs That Hurt User Experience – And How Expert Web Design Fixes
PPTX
curriculumandpedagogyinearlychildhoodcurriculum-171021103104 - Copy.pptx
PDF
Lean-Manufacturing-Tools-Techniques-and-How-To-Use-Them.pdf
PPT
12 Things That Make People Trust a Website Instantly
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PDF
Uptota Investor Deck - Where Africa Meets Blockchain
PPTX
artificialintelligenceai1-copy-210604123353.pptx
PPTX
t_and_OpenAI_Combined_two_pressentations
PDF
Understand the Gitlab_presentation_task.pdf
PPTX
TITLE DEFENSE entitle the impact of social media on education
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PPT
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
PPTX
Reading as a good Form of Recreation
PPTX
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
PPTX
newyork.pptxirantrafgshenepalchinachinane
PPTX
The-Importance-of-School-Sanitation.pptx
PDF
Containerization lab dddddddddddddddmanual.pdf
PPTX
KSS ON CYBERSECURITY INCIDENT RESPONSE AND PLANNING MANAGEMENT.pptx
PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PPTX
Layers_of_the_Earth_Grade7.pptx class by
Top Website Bugs That Hurt User Experience – And How Expert Web Design Fixes
curriculumandpedagogyinearlychildhoodcurriculum-171021103104 - Copy.pptx
Lean-Manufacturing-Tools-Techniques-and-How-To-Use-Them.pdf
12 Things That Make People Trust a Website Instantly
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
Uptota Investor Deck - Where Africa Meets Blockchain
artificialintelligenceai1-copy-210604123353.pptx
t_and_OpenAI_Combined_two_pressentations
Understand the Gitlab_presentation_task.pdf
TITLE DEFENSE entitle the impact of social media on education
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
Reading as a good Form of Recreation
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
newyork.pptxirantrafgshenepalchinachinane
The-Importance-of-School-Sanitation.pptx
Containerization lab dddddddddddddddmanual.pdf
KSS ON CYBERSECURITY INCIDENT RESPONSE AND PLANNING MANAGEMENT.pptx
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
Layers_of_the_Earth_Grade7.pptx class by

What did you inspec?

  • 1. What did you InSpec? https://github.com/gdha/inspec- cfgmgmtcamp-ghent-2019 Gratien D'haese IT3 Consultants
  • 2. 2019 - Gratien D'haese What did you InSpec? 2 Who am I? ● Gratien D'haese ● IT3 Consultants (company) ● > 30 years Unix experience ● Unix/Linux Engineer (incl. DevOps) ● Web: it3.be ● Relax-and-Recover (ReaR) ● Linux disaster recovery framework ● Open Source pages: https://github.com/gdha
  • 3. 2019 - Gratien D'haese What did you InSpec? 3 Bit of history pre-historic times
  • 4. 2019 - Gratien D'haese What did you InSpec? 4 Bit of history power to the Ops ● system administrators = Ops ● powerful shell scripts used for: ● Update ● Control ● Security ● Monitor ● Battle between Ops and Devs ● No CI/CD ● Lots of Change Controls
  • 5. 2019 - Gratien D'haese What did you InSpec? 5 Ops -> DevOps ● it’s everyone’s job now ● Ops tools for devs ● Software engineers (devs) learn ops ● Admins transition to devs
  • 6. 2019 - Gratien D'haese What did you InSpec? 6 DevOps and the rest ● Developers want tests ● Operations want peace ● Compliance Officers want √ ● Security Officers do not want holes
  • 7. 2019 - Gratien D'haese What did you InSpec? 7 What is InSpec ● InSpec is an open-source testing frameworktesting framework provided by Chef ● Human-readable language for specifying compliance, security and policy requirements ● Extensible language ● Re-usable ● Command-line ● Integrates with Test Kitchen
  • 8. 2019 - Gratien D'haese What did you InSpec? 8 What InSpec is not ● Is not a capacity planning tool ● Is not a monitoring tool ● Is not a logging tool ● Is not a configuration management tool ● Is not a firewall tool ● Is not a intrusion detection tool
  • 9. 2019 - Gratien D'haese What did you InSpec? 9 Why using InSpec? ● Less scripts for verification required ● One Language for many platforms ● Easy to read ● Easy to hand-over ● Easy to share ● Big collection of ready to use profiles ● Excellent documentation ● No need to be a nerd
  • 10. 2019 - Gratien D'haese What did you InSpec? 10 Features of InSpec ● Supports many Operating Systems ● Linux ● Mac/OS ● BSD, Solaris, AIX, HP-UX ● Windows ● Supports many Hypervisors, VMs, bare-metal ● Support different Cloud Providers ● Supports docker ● Supports DBs
  • 11. 2019 - Gratien D'haese What did you InSpec? 11 Why should you care? ● Do you want to be the next? New Data Breach exposes 57 million records https://blog.hackenproof.com/industry-news/new-data- breach-exposes-57-million-records/ ● Protection of your assets – data (security) ● IQ/OQ Compliance ● System validation after major changes ● CI/CD integration checks
  • 12. 2019 - Gratien D'haese What did you InSpec? 12 Idiot proof # inspec exec https://github.com/lnxchk/inspec- profile-wannacry-exploit/archive/master.tar.gz -i ./insecure_keys/vagrant.private -t ssh://root@server Profile: WannaCry Exploit Mitigation Status (wannacry-exploit) Version: 0.2.0 Target: ssh://root@server:22 × WannaCry Vulnerability Check: Hot-fix mitigation check for WannaCry Ransomware vulnerability (23 failed) Can you guess what is wrong with above test?
  • 13. 2019 - Gratien D'haese What did you InSpec? 13 Wannacry on Windows # inspec exec https://github.com/lnxchk/inspec- profile-wannacry-exploit/archive/master.tar.gz -t winrm://administrator@10.180.4.12 --password xxxx Profile: WannaCry Exploit Mitigation Status (wannacry-exploit) Version: 0.2.0 Target: winrm://administrator@http://10.180.4.12:5985/wsman:3389 ✔ WannaCry Vulnerability Check: Hot-fix mitigation check for WannaCry Ransomware vulnerability ✔ WMI with {:class=>"win32_quickfixengineering", :filter=>"HotFixID = 'KB4012213'"} InstalledOn should not eq nil Profile Summary: 1 successful control, 0 control failures, 0 controls skipped Test Summary: 1 successful, 0 failures, 0 skipped
  • 14. 2019 - Gratien D'haese What did you InSpec? 14 InSpec Basics ● Start with a demo – mychefdk container ● Launch the container and use inspec to check for my account ● Check inside the container ● Check from outside the container ● Run cookbook myaccount inside the container ● Re-run the checks again
  • 15. 2019 - Gratien D'haese What did you InSpec? 15 InSpec Basics (continued) ● Download from https://www.inspec.io/ ● Open Source at GitHub: https://github.com/inspec/inspec ● Resources ● InSpec uses built-in resources for common services, system files and configurations https://www.inspec.io/docs/reference/resources/ ● Resources work on many Linux platforms, and also on Windows
  • 16. 2019 - Gratien D'haese What did you InSpec? 16 InSpec resources ● OS resources ● apache ● bond ● command ● directory ● docker ● etc_fstab ● group ● mssql_session ● and so on ● Cloud resources ● AWS ● Azure ● Google
  • 17. 2019 - Gratien D'haese What did you InSpec? 17 unless os.windows? # This is an example test, replace with your own test. describe user('root') do it { should exist } end describe user('gdha') do it { should exist } its('uid') { should eq 501 } its('group') { should eq 'users'} its('home') { should eq '/home/gdha' } its('shell') { should eq '/bin/bash' } end end describe port(80) do it { should_not be_listening } end Resource Matcher
  • 18. 2019 - Gratien D'haese What did you InSpec? 18 Matchers ● should exist ● should be_in ● should_not match /blabla/ ● should eq ● should_not eq ● should cmp ● https://www.inspec.io/docs/reference/matchers/
  • 19. 2019 - Gratien D'haese What did you InSpec? 19 Profiles ● Profiles is about sharing and caring ● Built around “controls” that can be reviewed ● Each profile can have multiple tests ● Include profiles from outside this test ● Profiles can be published to be re-used ● More at https://www.inspec.io/docs/reference/profiles/
  • 20. 2019 - Gratien D'haese What did you InSpec? 20 Profiles (continued) $ inspec init profile dockerprofile Create new profile at /Users/gdha/data/projects/inspec/dockerprofile • Create directory libraries • Create file README.md • Create directory controls • Create file controls/example.rb • Create file inspec.yml • Create file libraries/.gitkeep Add more tests under this directory
  • 21. 2019 - Gratien D'haese What did you InSpec? 21 Inspec shell root@c26e2f2d7904:/# inspec shell Welcome to the interactive InSpec Shell To find out how to use it, type: help You are currently running on: Name: ubuntu Families: debian, linux, unix, os Release: 18.04 Arch: x86_64 inspec> help inspec> command('uname -s').stdout => "Linuxn"
  • 22. 2019 - Gratien D'haese What did you InSpec? 22 Inspec shell (continued) inspec> describe file('/etc/gshadow') do inspec> it { should be_owned_by 'root' } inspec> end Profile: inspec-shell Version: (not specified) File /etc/gshadow ✔ should be owned by "root" Test Summary: 1 successful, 0 failures, 0 skipped
  • 23. 2019 - Gratien D'haese What did you InSpec? 23 Example: source control file $ cat inspec-path-check/controls/path.rb title 'DOT in PATH variable' control 'path-1.0' do # A unique ID for this control impact 1.0 # The criticality, if this control fails. title 'DOT in PATH variable' desc 'An optional description...' describe os_env('PATH') do # The actual test its('split') { should_not include('') } its('split') { should_not include('.') } end end
  • 24. 2019 - Gratien D'haese What did you InSpec? 24 Profiles ● InSpec profiles allow you to share and pack sets of tests ● Built around controls (see previous example) ● Profiles can have multiple tests ● May depend on external profiles ● Publishing of your profiles is possible ● inspec init profile <profile-name> ● inspec check <profile-name>
  • 25. 2019 - Gratien D'haese What did you InSpec? 25 Running inspec ● Inspec on command line ● Can run locally on this machine ● inspec exec profile-name ● Run remotely via target option ● inspec exec profile-name -i pub.key -t ssh://user@system ● inspec exec profile-name -t winrm://administrator@system --password secret ● Run via test kitchen
  • 26. 2019 - Gratien D'haese What did you InSpec? 26 Excute a local path $ inspec exec inspec-path-check $ inspec exec /full/path/to/inspec-path-check Profile: PATH check InSpec Profile (path-check) Version: 0.1.0 Target: local:// ✔ path-1.0: DOT in PATH variable ✔ Environment variable PATH split should not include "" ✔ Environment variable PATH split should not include "." Profile Summary: 1 successful control, 0 control failures, 0 controls skipped Test Summary: 2 successful, 0 failures, 0 skipped
  • 27. 2019 - Gratien D'haese What did you InSpec? 27 Execute a GIT repo $ inspec exec https://github.com/gdha/inspec-path-check [2019-01-16T18:10:26+01:00] WARN: URL target https://github.com/gdha/inspec-path-check transformed to https://github.com/gdha/inspec-path- check/archive/master.tar.gz. Consider using the git fetcher Profile: PATH check InSpec Profile (path-check) Version: 0.1.0 Target: local:// ✔ path-1.0: DOT in PATH variable ✔ Environment variable PATH split should not include "" ✔ Environment variable PATH split should not include "." Profile Summary: 1 successful control, 0 control failures, 0 controls skipped Test Summary: 2 successful, 0 failures, 0 skipped
  • 28. 2019 - Gratien D'haese What did you InSpec? 28 Execute in a docker container $ inspec exec -t docker://c26e2f2d7904 inspec-path-check Profile: PATH check InSpec Profile (path-check) Version: 0.1.0 Target: docker://c26e2f2d79041252b2646baea3d64f18f52eea9b45a2443f3325a9 4221e10a4e ✔ path-1.0: DOT in PATH variable ✔ Environment variable PATH split should not include "" ✔ Environment variable PATH split should not include "." Profile Summary: 1 successful control, 0 control failures, 0 controls skipped Test Summary: 2 successful, 0 failures, 0 skipped
  • 29. 2019 - Gratien D'haese What did you InSpec? 29 Execute inspec remotely $ inspec exec -t ssh://client --password vagrant ../path-check/ Profile: PATH check InSpec Profile (path-check) Version: 0.1.0 Target: ssh://root@client:22 ✔ path-1.0: DOT in PATH variable ✔ Environment variable PATH split should not include "" ✔ Environment variable PATH split should not include "." Profile Summary: 1 successful control, 0 control failures, 0 controls skipped Test Summary: 2 successful, 0 failures, 0 skipped $ inspec exec -t winrm://admin@windows --password xx ../patch-check
  • 30. 2019 - Gratien D'haese What did you InSpec? 30 Using InSpec with Test Kitchen driver: name: vagrant provisioner: name: chef_zero verifier: name: inspec platforms: - name: centos-7.6 suites: - name: default run_list: - recipe[nginx_test::default] verifier: inspec_tests: - test/integration/default
  • 31. 2019 - Gratien D'haese What did you InSpec? 31 Kitchen verify $ kitchen verify -----> Starting Kitchen (v1.24.0) -----> Verifying <default-centos-76>... Loaded tests from {:path=>".Users.gdha.data.projects.inspec.inspec-cfgmgmtcamp- ghent-2019.cookbooks.nginx_test.test.integration.default"} User root ✔ should exist Port 80 ✔ should be listening System Package nginx ✔ should be installed File /etc/nginx/sites-available/default ✔ should exist Command: `curl localhost` ✔ stdout should match "Welcome" Test Summary: 5 successful, 0 failures, 0 skipped Finished verifying <default-centos-76> (0m0.81s). -----> Kitchen is finished. (0m7.83s)
  • 32. 2019 - Gratien D'haese What did you InSpec? 32 DevSec Linux Security Baseline (linux-baseline) # docker ps CONTAINER ID IMAGE COMMAND 1e2ef5665f9f openshift/base-centos7 ... # inspec exec https://github.com/dev-sec/linux-baseline -t docker://1e2ef5665f9f ✔ os-01: Trusted hosts login ✔ File /etc/hosts.equiv should not exist ✔ os-02: Check owner and permissions for /etc/shadow ✔ File /etc/shadow should exist ✔ File /etc/shadow should be file Profile Summary: 14 successful controls, 3 control failures, 37 controls skipped Test Summary: 53 successful, 8 failures, 37 skipped More details at https://dev-sec.io/
  • 33. 2019 - Gratien D'haese What did you InSpec? 33 ReaR Automated Testing client server recover
  • 34. 2019 - Gratien D'haese What did you InSpec? 34
  • 35. 2019 - Gratien D'haese What did you InSpec? 35 Links ● https://github.com/gdha/inspec-cfgmgmtcamp- ghent-2019 ● https://github.com/inspec/inspec ● https://www.inspec.io/ ● https://www.inspec.io/docs/reference/resources/ ● http://www.it3.be/ ● https://gdha.github.io/rear-automated-testing/ ● mailto:gratien.dhaese@it3.be