-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example puppet module for falco (#341)
Add an example puppet module for falco. This module configures the main falco configuration file /etc/falco/falco.yaml, providing templates for all configuration options. It installs falco using debian/rpm packages and installs/manages it as a systemd service.
- Loading branch information
Showing
13 changed files
with
460 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Example Puppet Falco Module | ||
|
||
This contains an example [Puppet](https://puppet.com/) module for Falco. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3'] | ||
gem 'puppet', puppetversion | ||
gem 'puppetlabs_spec_helper', '>= 0.1.0' | ||
gem 'puppet-lint', '>= 0.3.2' | ||
gem 'facter', '>= 1.7.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
# falco | ||
|
||
#### Table of Contents | ||
|
||
1. [Overview](#overview) | ||
2. [Module Description - What the module does and why it is useful](#module-description) | ||
3. [Setup - The basics of getting started with falco](#setup) | ||
* [What falco affects](#what-falco-affects) | ||
* [Beginning with falco](#beginning-with-falco) | ||
4. [Usage - Configuration options and additional functionality](#usage) | ||
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) | ||
5. [Limitations - OS compatibility, etc.](#limitations) | ||
6. [Development - Guide for contributing to the module](#development) | ||
|
||
## Overview | ||
|
||
Sysdig Falco is a behavioral activity monitor designed to detect anomalous activity in your applications. Powered by sysdig’s system call capture infrastructure, falco lets you continuously monitor and detect container, application, host, and network activity... all in one place, from one source of data, with one set of rules. | ||
|
||
#### What kind of behaviors can Falco detect? | ||
|
||
Falco can detect and alert on any behavior that involves making Linux system calls. Thanks to Sysdig's core decoding and state tracking functionality, falco alerts can be triggered by the use of specific system calls, their arguments, and by properties of the calling process. For example, you can easily detect things like: | ||
|
||
- A shell is run inside a container | ||
- A container is running in privileged mode, or is mounting a sensitive path like `/proc` from the host. | ||
- A server process spawns a child process of an unexpected type | ||
- Unexpected read of a sensitive file (like `/etc/shadow`) | ||
- A non-device file is written to `/dev` | ||
- A standard system binary (like `ls`) makes an outbound network connection | ||
|
||
## Module Description | ||
|
||
This module configures falco as a systemd service. You configure falco | ||
to send its notifications to one or more output channels (syslog, | ||
files, programs). | ||
|
||
## Setup | ||
|
||
### What falco affects | ||
|
||
This module affects the following: | ||
|
||
* The main falco configuration file `/etc/falco/falco.yaml`, including | ||
** Output format (JSON vs plain text) | ||
** Log level | ||
** Rule priority level to run | ||
** Output buffering | ||
** Output throttling | ||
** Output channels (syslog, file, program) | ||
|
||
### Beginning with falco | ||
|
||
To have Puppet install falco with the default parameters, declare the falco class: | ||
|
||
``` puppet | ||
class { 'falco': } | ||
``` | ||
|
||
When you declare this class with the default options, the module: | ||
|
||
* Installs the appropriate falco software package and installs the falco-probe kernel module for your operating system. | ||
* Creates the required configuration file `/etc/falco/falco.yaml`. By default only syslog output is enabled. | ||
* Starts the falco service. | ||
|
||
## Usage | ||
|
||
### Enabling file output | ||
|
||
To enable file output, set the `file_output` hash, as follows: | ||
|
||
``` puppet | ||
class { 'falco': | ||
file_output => { | ||
'enabled' => 'true', | ||
'keep_alive' => 'false', | ||
'filename' => '/tmp/falco-events.txt' | ||
}, | ||
} | ||
``` | ||
|
||
### Enabling program output | ||
|
||
To enable program output, set the `program_output` hash and optionally the `json_output` parameters, as follows: | ||
|
||
``` puppet | ||
class { 'falco': | ||
json_output => 'true', | ||
program_output => { | ||
'enabled' => 'true', | ||
'keep_alive' => 'false', | ||
'program' => 'curl http://some-webhook.com' | ||
}, | ||
} | ||
``` | ||
|
||
## Reference | ||
|
||
* [**Public classes**](#public-classes) | ||
* [Class: falco](#class-falco) | ||
|
||
### Public Classes | ||
|
||
#### Class: `falco` | ||
|
||
Guides the basic setup and installation of falco on your system. | ||
|
||
When this class is declared with the default options, Puppet: | ||
|
||
* Installs the appropriate falco software package and installs the falco-probe kernel module for your operating system. | ||
* Creates the required configuration file `/etc/falco/falco.yaml`. By default only syslog output is enabled. | ||
* Starts the falco service. | ||
|
||
You can simply declare the default `falco` class: | ||
|
||
``` puppet | ||
class { 'falco': } | ||
``` | ||
|
||
###### `rules_file` | ||
|
||
An array of files for falco to load. Order matters--the first file listed will be loaded first. | ||
|
||
Default: `['/etc/falco/falco_rules.yaml', '/etc/falco/falco_rules.local.yaml']` | ||
|
||
##### `json_output` | ||
|
||
Whether to output events in json or text. | ||
|
||
Default: `false` | ||
|
||
##### `log_stderr` | ||
|
||
Send falco's logs to stderr. Note: this is not notifications, this is | ||
logs from the falco daemon itself. | ||
|
||
Default: `false` | ||
|
||
##### `log_syslog` | ||
|
||
Send falco's logs to syslog. Note: this is not notifications, this is | ||
logs from the falco daemon itself. | ||
|
||
Default: `true` | ||
|
||
##### `log_level` | ||
|
||
Minimum log level to include in logs. Note: these levels are | ||
separate from the priority field of rules. This refers only to the | ||
log level of falco's internal logging. Can be one of "emergency", | ||
"alert", "critical", "error", "warning", "notice", "info", "debug". | ||
|
||
Default: `info` | ||
|
||
##### `priority` | ||
|
||
Minimum rule priority level to load and run. All rules having a | ||
priority more severe than this level will be loaded/run. Can be one | ||
of "emergency", "alert", "critical", "error", "warning", "notice", | ||
"info", "debug". | ||
|
||
Default: `debug` | ||
|
||
##### `buffered_outputs` | ||
|
||
Whether or not output to any of the output channels below is | ||
buffered. | ||
|
||
Default: `true` | ||
|
||
##### `outputs_rate`/`outputs_max_burst` | ||
|
||
A throttling mechanism implemented as a token bucket limits the | ||
rate of falco notifications. This throttling is controlled by the following configuration | ||
options: | ||
|
||
* `outputs_rate`: the number of tokens (i.e. right to send a notification) | ||
gained per second. Defaults to 1. | ||
* `outputs_max_burst`: the maximum number of tokens outstanding. Defaults to 1000. | ||
|
||
##### `syslog_output | ||
|
||
Controls syslog output for notifications. Value: a hash, containing the following: | ||
|
||
* `enabled`: `true` or `false`. Default: `true`. | ||
|
||
Example: | ||
|
||
``` puppet | ||
class { 'falco': | ||
syslog_output => { | ||
'enabled' => 'true', | ||
}, | ||
} | ||
``` | ||
|
||
##### `file_output` | ||
|
||
Controls file output for notifications. Value: a hash, containing the following: | ||
|
||
* `enabled`: `true` or `false`. Default: `false`. | ||
* `keep_alive`: If keep_alive is set to true, the file will be opened once and continuously written to, with each output message on its own line. If keep_alive is set to false, the file will be re-opened for each output message. Default: `false`. | ||
* `filename`: Notifications will be written to this file. | ||
|
||
Example: | ||
|
||
``` puppet | ||
class { 'falco': | ||
file_output => { | ||
'enabled' => 'true', | ||
'keep_alive' => 'false', | ||
'filename' => '/tmp/falco-events.txt' | ||
}, | ||
} | ||
``` | ||
|
||
##### `program_output | ||
|
||
Controls program output for notifications. Value: a hash, containing the following: | ||
|
||
* `enabled`: `true` or `false`. Default: `false`. | ||
* `keep_alive`: If keep_alive is set to true, the file will be opened once and continuously written to, with each output message on its own line. If keep_alive is set to false, the file will be re-opened for each output message. Default: `false`. | ||
* `program`: Notifications will be written to this program. | ||
|
||
Example: | ||
|
||
``` puppet | ||
class { 'falco': | ||
program_output => { | ||
'enabled' => 'true', | ||
'keep_alive' => 'false', | ||
'program' => 'curl http://some-webhook.com' | ||
}, | ||
} | ||
``` | ||
|
||
## Limitations | ||
|
||
The module works where falco works as a daemonized service (generally, Linux only). | ||
|
||
## Development | ||
|
||
For more information on Sysdig Falco, visit our [github](https://github.com/draios/falco) or [web site](https://sysdig.com/opensource/falco/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'rubygems' | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
PuppetLint.configuration.send('disable_80chars') | ||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] | ||
|
||
desc "Validate manifests, templates, and ruby files" | ||
task :validate do | ||
Dir['manifests/**/*.pp'].each do |manifest| | ||
sh "puppet parser validate --noop #{manifest}" | ||
end | ||
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| | ||
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ | ||
end | ||
Dir['templates/**/*.erb'].each do |template| | ||
sh "erb -P -x -T '-' #{template} | ruby -c" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# == Class: falco::config | ||
class falco::config inherits falco { | ||
|
||
file { '/etc/falco/falco.yaml': | ||
notify => Service['falco'], | ||
ensure => file, | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0644', | ||
content => template('falco/falco.yaml.erb'), | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class falco ( | ||
$rules_file = [ | ||
'/etc/falco/falco_rules.yaml', | ||
'/etc/falco/falco_rules.local.yaml' | ||
], | ||
$json_output = 'false', | ||
$log_stderr = 'false', | ||
$log_syslog = 'true', | ||
$log_level = 'info', | ||
$priority = 'debug', | ||
$buffered_outputs = 'true', | ||
$outputs_rate = 1, | ||
$outputs_max_burst = 1000, | ||
$syslog_output = { | ||
'enabled' => 'true' | ||
}, | ||
$file_output = { | ||
'enabled' => 'false', | ||
'keep_alive' => 'false', | ||
'filename' => '/tmp/falco_events.txt' | ||
}, | ||
$program_output = { | ||
'enabled' => 'false', | ||
'keep_alive' => 'false', | ||
'program' => 'curl http://some-webhook.com' | ||
}, | ||
) { | ||
include falco::install | ||
include falco::config | ||
include falco::service | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# == Class: falco::install | ||
class falco::install inherits falco { | ||
package { 'falco': | ||
ensure => installed, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# == Class: falco::service | ||
class falco::service inherits falco { | ||
|
||
service { 'falco': | ||
ensure => running, | ||
enable => true, | ||
hasstatus => true, | ||
hasrestart => true, | ||
require => Package['falco'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "sysdig-falco", | ||
"version": "0.1.0", | ||
"author": "sysdig", | ||
"summary": "Sysdig Falco: Behavioral Activity Monitoring With Container Support", | ||
"license": "GPLv2", | ||
"source": "https://github.com/draios/falco", | ||
"project_page": "https://github.com/draios/falco", | ||
"issues_url": "https://github.com/draios/falco/issues", | ||
"dependencies": [ | ||
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"} | ||
] | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
examples/puppet-module/sysdig-falco/spec/classes/init_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
describe 'falco' do | ||
|
||
context 'with defaults for all parameters' do | ||
it { should contain_class('falco') } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'puppetlabs_spec_helper/module_spec_helper' |
Oops, something went wrong.