Azure Compliance Mod for Flowpipe
Pipelines to detect and remediate misconfigurations in Azure resources.
Documentation
Getting Started
Requirements
Docker daemon must be installed and running. Please see Install Docker Engine for more information.
Installation
Download and install Flowpipe (https://flowpipe.io/downloads) and Steampipe (https://steampipe.io/downloads). Or use Brew:
brew install turbot/tap/flowpipebrew install turbot/tap/steampipeInstall the Azure plugin with Steampipe:
steampipe plugin install azureSteampipe will automatically use your default Azure credentials. Optionally, you can setup multiple subscriptions or customize Azure credentials.
Create a connection_import resource to import your Steampipe Azure connections:
vi ~/.flowpipe/config/azure.fpcconnection_import "azure" {  source      = "~/.steampipe/config/azure.spc"  connections = ["*"]}For more information on importing connections, please see Connection Import.
For more information on connections in Flowpipe, please see Managing Connections.
Install the mod:
mkdir azure-compliancecd azure-complianceflowpipe mod install github.com/turbot/flowpipe-mod-azure-complianceRunning Detect and Correct Pipelines
To run your first detection, you'll need to ensure your Steampipe server is up and running:
steampipe service startTo find your desired detection, you can filter the pipeline list output:
flowpipe pipeline list | grep "detect_and_correct"Then run your chosen pipeline:
flowpipe pipeline run detect_and_correct_sql_databases_with_public_access_enabledThis will then run the pipeline and depending on your configured running mode; perform the relevant action(s), there are 3 running modes:
- Wizard
 - Notify
 - Automatic
 
Wizard
This is the default running mode, allowing for a hands-on approach to approving changes to resources by prompting for input for each detected resource.
Whilst the out of the box default is to run the workflow directly in the terminal. You can use Flowpipe server and external integrations to prompt in http, slack, teams, etc.
Notify
This mode as the name implies is used purely to report detections via notifications either directly to your terminal when running in client mode or via another configured notifier when running in server mode for each detected resource.
To run in notify mode, you will need to set the approvers variable to an empty list [] and ensure the resource-specific default_action variable is set to notify, either in your flowpipe.fpvars file:
approvers = []sql_databases_with_public_access_enabled_default_action = "notify"or pass the approvers and default_action arguments on the command-line.
flowpipe pipeline run detect_and_correct_sql_databases_with_public_access_enabled --arg='default_action=notify' --arg='approvers=[]'Automatic
This behavior allows for a hands-off approach to remediating resources.
To run in automatic mode, you will need to set the approvers variable to an empty list [] and the the resource-specific default_action variable to one of the available options in your flowpipe.fpvars file:
approvers = []sql_databases_with_public_access_enabled_default_action = "revoke_firewall_rule"or pass the approvers and default_action argument on the command-line.
flowpipe pipeline run detect_and_correct_sql_databases_with_public_access_enabled --arg='approvers=[] --arg='default_action=revoke_firewall_rule'To further enhance this approach, you can enable the pipelines corresponding query trigger to run completely hands-off.
Running Query Triggers
Note: Query triggers require Flowpipe running in server mode.
Each detect_and_correct pipeline comes with a corresponding Query Trigger, these are disabled by default allowing for you to enable and schedule them as desired.
Let's begin by looking at how to set-up a Query Trigger to automatically resolve our SQL databases that do not block public access.
Firsty, we need to update our flowpipe.fpvars file to add or update the following variables - if we want to run our remediation hourly and automatically apply the corrections:
sql_databases_with_public_access_enabled_trigger_enabled  = truesql_databases_with_public_access_enabled_trigger_schedule = "1h"sql_databases_with_public_access_enabled_default_action   = "revoke_firewall_rule"Now we'll need to start up our Flowpipe server:
flowpipe serverThis will run every hour and detect SQL databases that do not block public access and apply the corrections without further interaction!
Configure Variables
Several pipelines have input variables that can be configured to better match your environment and requirements.
Each variable has a default defined in its source file, e.g, sql/sql_databases_with_public_access_enabled.fp (or variables.fp for more generic variables), but these can be overwritten in several ways:
The easiest approach is to setup your flowpipe.fpvars file, starting with the sample:
cp flowpipe.fpvars.example flowpipe.fpvarsvi flowpipe.fpvars
flowpipe pipeline run detect_and_correct_sql_databases_with_public_access_enabledAlternatively, you can pass variables on the command line:
flowpipe pipeline run detect_and_correct_sql_databases_with_public_access_enabled --var notifier=notifier.defaultOr through environment variables:
export FP_VAR_notifier="notifier.default"flowpipe pipeline run detect_and_correct_sql_databases_with_public_access_enabledFor more information, please see Passing Input Variables
Finally, each detection pipeline has a corresponding Query Trigger, these are disabled by default allowing for you to configure only those which are required, see the docs for more information.
Open Source & Contributing
This repository is published under the Apache 2.0 license. Please see our code of conduct. We look forward to collaborating with you!
Flowpipe and Steampipe are products produced from this open source software, exclusively by Turbot HQ, Inc. They are distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.
Get Involved
Want to help but don't know where to start? Pick up one of the help wanted issues: