70
Compliance as Code DevOpsDays Austin May 3, 2016

2016 - Compliance as Code - InSpec

Embed Size (px)

Citation preview

Page 1: 2016 - Compliance as Code - InSpec

Compliance as CodeDevOpsDays Austin

May 3, 2016

Page 2: 2016 - Compliance as Code - InSpec
Page 3: 2016 - Compliance as Code - InSpec
Page 4: 2016 - Compliance as Code - InSpec
Page 5: 2016 - Compliance as Code - InSpec

Chef Workflow

Page 6: 2016 - Compliance as Code - InSpec
Page 7: 2016 - Compliance as Code - InSpec
Page 8: 2016 - Compliance as Code - InSpec

SSH Control

"SSH supports two different protocol versions. The original version, SSHv1, was subject to a number of security issues. Please use SSHv2 instead to avoid these."

Page 9: 2016 - Compliance as Code - InSpec

How will I verify this?

Page 10: 2016 - Compliance as Code - InSpec

Whip up a one-liner!

grep "^Protocol" /etc/ssh/sshd_config | sed 's/Protocol //'

Page 11: 2016 - Compliance as Code - InSpec

Apache Server Information Leakage – Server Token Directive

•  Description

  This Directive Controls wheather Server response field is sent back to clients includes a description of Generic OS Type of the Server.

  This allows attackers to identify web servers details greatly and increases the efficiency of any attack,as security vulnerabilities are dependent upon specific software versions.

•  How to Test

  In order to test for ServerToken configuration, one should check the Apache configuration file.

•  Misconfiguration

  ServerTokensFull

•  Remediation

  Configure the ServerTokens directive in the Apache configuration to value of Prod or ProductOnly. This tells Apache to only return "Apache" in the Server header, returned on every page request.

  ServerTokensProd   or

  ServerTokensProductOnly

https://www.owasp.org/index.php/SCG_WS_Apache

Page 12: 2016 - Compliance as Code - InSpec

More grep and sed!

grep "^ServerTokens" /etc/httpd/conf/httpd.conf | sed 's/ServerTokens //'

Page 13: 2016 - Compliance as Code - InSpec
Page 14: 2016 - Compliance as Code - InSpec
Page 15: 2016 - Compliance as Code - InSpec
Page 16: 2016 - Compliance as Code - InSpec
Page 17: 2016 - Compliance as Code - InSpec
Page 18: 2016 - Compliance as Code - InSpec

C o mp l i a n c e

Page 19: 2016 - Compliance as Code - InSpec
Page 20: 2016 - Compliance as Code - InSpec

Two-thirds of organizations did not adequately test the security of all in-scope systems!

Page 21: 2016 - Compliance as Code - InSpec

Key Trends

•  While individual rule compliance is up, testing of security systems is down

•  Sustainability is low. Fewer than a third of companies were found to be still fully compliant less than a year after successful validation.

Page 22: 2016 - Compliance as Code - InSpec
Page 23: 2016 - Compliance as Code - InSpec

Shell Scripts

grep "^Protocol" /etc/ssh/sshd_config | sed 's/Protocol //' grep "^ServerTokens" /etc/httpd/conf/httpd.conf | sed 's/ServerTokens //'

Page 24: 2016 - Compliance as Code - InSpec

Infrastructure Code

package 'httpd' do action :installend

service 'httpd' do action [ :start, :enable ]end

Page 25: 2016 - Compliance as Code - InSpec

What We Have Here Is A Communications Problem

Page 26: 2016 - Compliance as Code - InSpec
Page 27: 2016 - Compliance as Code - InSpec

Security != Compliance

Page 28: 2016 - Compliance as Code - InSpec
Page 29: 2016 - Compliance as Code - InSpec
Page 30: 2016 - Compliance as Code - InSpec
Page 31: 2016 - Compliance as Code - InSpec
Page 32: 2016 - Compliance as Code - InSpec
Page 33: 2016 - Compliance as Code - InSpec
Page 34: 2016 - Compliance as Code - InSpec
Page 35: 2016 - Compliance as Code - InSpec

Compliance Language

Page 36: 2016 - Compliance as Code - InSpec

One Language !Linux

Page 37: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows

Page 38: 2016 - Compliance as Code - InSpec

Windows

Page 39: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Page 40: 2016 - Compliance as Code - InSpec

Available Resourcesapache_confapt

audit_policy

auditd_conf

auditd_rules

bond

bridge

csv

command

directory

etc_group

file

gemgroup

host

inetd_conf

interface

iptables

kernel_module

kernel_parameter

limits_conf

login_defs

mount

mysql_conf

mysql_sessionnpm

ntp_conf

oneget

os

os_env

package

parse_config

parse_config_file

passwd

pip

port

postgres_confpostgres_session

powershell

processes

registry_key

security_policy

service

ssh_config

sshd_config

user

windows_feature

yaml

yum

Page 41: 2016 - Compliance as Code - InSpec

What is it not?

•  IDS / IPS• Firewall• Antivirus• Pentesting tool

Page 42: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Bare-metal

Page 43: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Bare-metal, VMs

Page 44: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Bare-metal, VMs, Containers

Page 45: 2016 - Compliance as Code - InSpec

Test Locally

$ inspecexectest.rb. Finished in 0.00901 seconds (files took 0.98501 seconds to load) 1 example, 0 failures

Page 46: 2016 - Compliance as Code - InSpec

Test Remote via SSH

$ inspecexectest.rb-ivagrant.key-tssh://[email protected]:11022

No Ruby / agent on the node

Page 47: 2016 - Compliance as Code - InSpec

Test Remote via WinRM

$ inspecexectest.rb-twinrm://[email protected]

No Ruby / agent on the node

Page 48: 2016 - Compliance as Code - InSpec

Test Docker Containers

$ inspecexectest.rb-tdocker://3dda08e75838

No Ruby / agent on the container

Page 49: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Bare-metal, VMs, Containers

Nodes

Page 50: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Bare-metal, VMs, Containers

Nodes, GRUB, DBs

Page 51: 2016 - Compliance as Code - InSpec

DB Testing

Page 52: 2016 - Compliance as Code - InSpec

One Language !Linux, Windows, BSD, Solaris, AIX, ...

Bare-metal, VMs, Containers

Nodes, GRUB, DBs, Endpoints, APIs, ...

Page 53: 2016 - Compliance as Code - InSpec

Cloud Testing

Page 54: 2016 - Compliance as Code - InSpec

Operating System and Application Coverage

• Red Hat Enterprise Linux• Ubuntu•  SUSE• Oracle Linux• Microsoft Windows 7, 8• Microsoft Windows Server 2008,

2012• AIX

• HP-UX• VMware ESXi• Oracle • MySQL• Apache Tomcat•  SQL Server•  IIS

Page 55: 2016 - Compliance as Code - InSpec

InSpeckitchen-inspec

Page 56: 2016 - Compliance as Code - InSpec

56 1-

©2016 Chef Software Inc.

Test Kitchen

Page 57: 2016 - Compliance as Code - InSpec

Setup our test

$ chef generate cookbook ssh $ cd ssh $ vim .kitchen.yml $ kitchen converge $ rm -rf test/integration/default/* $ mkdir -p test/integration/default/inspec/ $ vim test/integration/default/inspec/default_spec.rb

Page 58: 2016 - Compliance as Code - InSpec

SSH Version Check

describe sshd_config do its('Protocol'){shouldcmp2}end

Page 59: 2016 - Compliance as Code - InSpec

Run the test

$kitchenverifyFailures: 1) SSH Configuration Protocol should cmp 2 Failure/Error: its('Protocol') { should cmp 2 } expected: 2 got: 1

Page 60: 2016 - Compliance as Code - InSpec

Fix the issue (manually)

$kitchenlogin$sudovi/etc/ssh/sshd_config$exit$kitchenverifyFinished in 0.0382 seconds (files took 0.7536 seconds to load) 1 example, 0 failures Finished verifying <default-centos-71> (0m0.47s).

Page 61: 2016 - Compliance as Code - InSpec

Open Source Community

• Test Kitchen

• https://kitchen.io

• https://github.com/test-kitchen

• Kitchen-InSpec

• https://github.com/chef/kitchen-inspec• Kitchen-Ansible

• https://github.com/neillturner/kitchen-ansible

• Kitchen-Puppet

• https://github.com/neillturner/kitchen-puppet

• Supermarket.chef.io

Page 62: 2016 - Compliance as Code - InSpec

InSpecUsed with Chef Compliance

Page 63: 2016 - Compliance as Code - InSpec
Page 64: 2016 - Compliance as Code - InSpec
Page 65: 2016 - Compliance as Code - InSpec

Compliance as Code. !

Page 66: 2016 - Compliance as Code - InSpec

New Workflow

Page 67: 2016 - Compliance as Code - InSpec

Chef Provides a Proven Approach to DevOps

Apps

Runtime environments

Infrastructure

..

.

Targets/Workloads

Collaborative Development

Chef Insights

Production

Chef Server

Chef Server

Chef Supermarket

Assessment

Chef Compliance

Search

Audit

Discover

Deploy

Chef Delivery

Local Development

Model

Build

Test

Chef DK

Chef Client & Cookbooks

Page 68: 2016 - Compliance as Code - InSpec
Page 69: 2016 - Compliance as Code - InSpec

Austin, TX | July 11-13

Early Bird Pricing Through April 17th

«  Workshops & Chef Training !

«  Community Summit !

«  Chef Partner Summit !

«  Welcome Reception!

«  Keynotes!

«  Technical Sessions!

«  Happy Hour!

«  Keynotes!

«  Technical Sessions!

«  Awesome Chef Awards!

«  Community Celebration!

ChefConf.com

Page 70: 2016 - Compliance as Code - InSpec