From a337ca1d2378624bb1e5cef47191c3545b6cd5e9 Mon Sep 17 00:00:00 2001 From: Stuart Paterson Date: Mon, 4 Mar 2019 15:33:37 +0000 Subject: [PATCH] Add InSpec init profile folder for Azure. Signed-off-by: Stuart Paterson --- .../templates/profiles/azure/README.md | 56 +++++++++++++++++++ .../profiles/azure/controls/example.rb | 15 +++++ .../templates/profiles/azure/inspec.yml | 14 +++++ .../profiles/azure/libraries/.gitkeep | 0 4 files changed, 85 insertions(+) create mode 100644 lib/plugins/inspec-init/templates/profiles/azure/README.md create mode 100644 lib/plugins/inspec-init/templates/profiles/azure/controls/example.rb create mode 100644 lib/plugins/inspec-init/templates/profiles/azure/inspec.yml create mode 100644 lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep diff --git a/lib/plugins/inspec-init/templates/profiles/azure/README.md b/lib/plugins/inspec-init/templates/profiles/azure/README.md new file mode 100644 index 000000000..ebb6dedb1 --- /dev/null +++ b/lib/plugins/inspec-init/templates/profiles/azure/README.md @@ -0,0 +1,56 @@ +# Example InSpec Profile For Azure + +This example shows the implementation of an InSpec profile for Azure. See [https://github.com/inspec/inspec-azure](https://github.com/inspec/inspec-azure) for details on how to configure credentials for your subscription. + +## Create a profile + +``` +$ inspec init profile --platform azure my-profile + + ─────────────────────────── InSpec Code Generator ─────────────────────────── + +Creating new profile at /Users/spaterson/my-profile + • Creating directory libraries + • Creating file README.md + • Creating directory controls + • Creating file controls/example.rb + • Creating file inspec.yml + • Creating file libraries/.gitkeep + +``` + +## Run the tests + +``` +$ cd my-profile/ +$ inspec exec . -t azure:// + + +Profile: Azure InSpec Profile (my-profile) +Version: 0.1.0 +Target: azure://12345abc-987d-654e-fg21-abcdef23324r + + × azure-virtual-machines-exist-check: Check resource groups to see if any VMs exist. (4 failed) + × Azure Virtual Machines should exist + expected Azure Virtual Machines to exist + × Azure Virtual Machines should exist + expected Azure Virtual Machines to exist + × Azure Virtual Machines should exist + expected Azure Virtual Machines to exist + × Azure Virtual Machines should exist + expected Azure Virtual Machines to exist + ✔ Azure Virtual Machines should exist + ✔ Azure Virtual Machines should exist + ✔ Azure Virtual Machines should exist + + +Profile: Azure Resource Pack (inspec-azure) +Version: 1.2.0 +Target: azure://12345abc-987d-654e-fg21-abcdef23324r + + No tests executed. + +Profile Summary: 0 successful controls, 1 control failure, 0 controls skipped +Test Summary: 3 successful, 4 failures, 0 skipped + +``` \ No newline at end of file diff --git a/lib/plugins/inspec-init/templates/profiles/azure/controls/example.rb b/lib/plugins/inspec-init/templates/profiles/azure/controls/example.rb new file mode 100644 index 000000000..4e95675d4 --- /dev/null +++ b/lib/plugins/inspec-init/templates/profiles/azure/controls/example.rb @@ -0,0 +1,15 @@ +# encoding: utf-8 +# copyright: 2018, The Authors + +title 'Sample Section' + +# you add controls here +control 'azure-virtual-machines-exist-check' do # A unique ID for this control. + impact 1.0 # The criticality, if this control fails. + title 'Check resource groups to see if any VMs exist.' # A human-readable title + azurerm_resource_groups.names.each do |resource_group_name| # Plural resources can be leveraged to loop across many resources + describe azurerm_virtual_machines(resource_group: resource_group_name) do + it { should exist } # The test itself. + end + end +end diff --git a/lib/plugins/inspec-init/templates/profiles/azure/inspec.yml b/lib/plugins/inspec-init/templates/profiles/azure/inspec.yml new file mode 100644 index 000000000..8013ffa04 --- /dev/null +++ b/lib/plugins/inspec-init/templates/profiles/azure/inspec.yml @@ -0,0 +1,14 @@ +name: <%= name %> +title: Azure InSpec Profile +maintainer: The Authors +copyright: The Authors +copyright_email: you@example.com +license: Apache-2.0 +summary: An InSpec Compliance Profile For Azure +version: 0.1.0 +inspec_version: '>= 3.7' +depends: +- name: inspec-azure + url: https://github.com/inspec/inspec-azure/archive/master.tar.gz +supports: +- platform: azure diff --git a/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep b/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep new file mode 100644 index 000000000..e69de29bb