Skip to content

Commit

Permalink
Update the Puppet module (#537)
Browse files Browse the repository at this point in the history
* Update the Puppet module:
* Apply puppet-lint recommendations
* Update the README since the project moved from draios to falcosecurity in GitHub
* Move parameters in their own file
+ Add the DEB repository automatically
+ Add the EPEL repository automatically
+ Add a logrotate configuration
* Update the configuration file with all the latest updates

falco-CLA-1.0-contributing-entity: Coveo Solutions Inc.
falco-CLA-1.0-signed-off-by: Jean-Philippe Lachance <jplachance@coveo.com>

* * Set required modules versions properly
* Set dependencies between classes
* Set the class order
* Apply mstemm's code review

* * Drop the Puppet 3 support
* Use a working version of puppetlabs-apt
* Use dependencies to be compatible with Puppet 4.7 and above
  • Loading branch information
JPLachance authored and mstemm committed Feb 21, 2019
1 parent 0b29b12 commit 9c57473
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 76 deletions.
2 changes: 1 addition & 1 deletion integrations/puppet-module/sysdig-falco/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 4.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
Expand Down
50 changes: 25 additions & 25 deletions integrations/puppet-module/sysdig-falco/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# falco
# 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)
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.
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:
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.
Expand All @@ -29,37 +29,37 @@ Falco can detect and alert on any behavior that involves making Linux system cal

## Module Description

This module configures falco as a systemd service. You configure falco
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
### What Falco affects

This module affects the following:

* The main falco configuration file `/etc/falco/falco.yaml`, including
* 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
### Beginning with Falco

To have Puppet install falco with the default parameters, declare the falco class:
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.
* 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.
* Starts the Falco service.

## Usage

Expand Down Expand Up @@ -101,12 +101,12 @@ class { 'falco':

#### Class: `falco`

Guides the basic setup and installation of falco on your system.
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.
* 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:
Expand All @@ -117,7 +117,7 @@ class { 'falco': }

###### `rules_file`

An array of files for falco to load. Order matters--the first file listed will be loaded first.
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']`

Expand All @@ -129,23 +129,23 @@ Default: `false`

##### `log_stderr`

Send falco's logs to stderr. Note: this is not notifications, this is
logs from the falco daemon itself.
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.
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",
log level of Falco's internal logging. Can be one of "emergency",
"alert", "critical", "error", "warning", "notice", "info", "debug".

Default: `info`
Expand All @@ -169,7 +169,7 @@ 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
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)
Expand Down Expand Up @@ -234,8 +234,8 @@ class { 'falco':

## Limitations

The module works where falco works as a daemonized service (generally, Linux only).
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/).
For more information on Sysdig Falco, visit our [github](https://github.com/falcosecurity/falco) or [web site](https://sysdig.com/opensource/falco/).
7 changes: 3 additions & 4 deletions integrations/puppet-module/sysdig-falco/manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# == Class: falco::config
class falco::config inherits falco {

file { '/etc/falco/falco.yaml':
notify => Service['falco'],
ensure => file,
require => Class['falco::install'],
notify => Service['falco'],
owner => 'root',
group => 'root',
mode => '0644',
content => template('falco/falco.yaml.erb'),
}

}
}
66 changes: 37 additions & 29 deletions integrations/puppet-module/sysdig-falco/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# == Class: falco
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
# Configuration parameters
$rules_file = $falco::params::rules_file,
$json_output = $falco::params::json_output,
$json_include_output_property = $falco::params::json_include_output_property,

$log_stderr = $falco::params::log_stderr,
$log_syslog = $falco::params::log_syslog,
$log_level = $falco::params::log_level,
$priority = $falco::params::priority,

$buffered_outputs = $falco::params::buffered_outputs,
$outputs_rate = $falco::params::outputs_rate,
$outputs_max_burst = $falco::params::outputs_max_burst,

$syslog_output = $falco::params::syslog_output,
$file_output = $falco::params::file_output,
$stdout_output = $falco::params::stdout_output,
$webserver = $falco::params::webserver,
$program_output = $falco::params::program_output,
$http_output = $falco::params::http_output,

# Installation parameters
$package_ensure = $falco::params::package_ensure,

# Service parameters
$service_ensure = $falco::params::service_ensure,
$service_enable = $falco::params::service_enable,
$service_restart = $falco::params::service_restart,
) inherits falco::params {
contain falco::install
contain falco::config
contain falco::service

Class['::falco::install']
-> Class['::falco::config']
~> Class['::falco::service']
}
59 changes: 57 additions & 2 deletions integrations/puppet-module/sysdig-falco/manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@
# == Class: falco::install
class falco::install inherits falco {
case $::osfamily {
'Debian': {
apt::source { 'sysdig':
location => 'http://download.draios.com/stable/deb',
release => 'stable-$(ARCH)/',
repos => '',
key => {
source => 'https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public',
id => 'D27A72F32D867DF9300A241574490FD6EC51E8C4'
},
}

ensure_packages(["linux-headers-${::kernelrelease}"])

$dependencies = [
Apt::Source['sysdig'],
Package["linux-headers-${::kernelrelease}"],
]
}
'RedHat': {
include 'epel'

yumrepo { 'sysdig':
baseurl => 'http://download.draios.com/stable/rpm/$basearch',
descr => 'Sysdig repository by Draios',
enabled => 1,
gpgcheck => 0,
}

ensure_packages(["kernel-devel-${::kernelrelease}"])

$dependencies = [
Yumrepo['sysdig'],
Class['epel']
]
}
default: {
$dependencies = []
}
}

package { 'falco':
ensure => installed,
ensure => $::falco::package_ensure,
require => $dependencies,
}

if ($::falco::file_output != undef) {
logrotate::rule { 'falco_output':
path => $::falco::file_output[filename],
rotate => 5,
rotate_every => 'day',
size => '1M',
missingok => true,
compress => true,
sharedscripts => true,
postrotate => '/usr/bin/killall -USR1 falco'
}
}
}
}
59 changes: 59 additions & 0 deletions integrations/puppet-module/sysdig-falco/manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# == Class falco::params
#
class falco::params {
# Configuration parameters
$rules_file = [
'/etc/falco/falco_rules.yaml',
'/etc/falco/falco_rules.local.yaml',
'/etc/falco/k8s_audit_rules.yaml',
'/etc/falco/rules.d',
]

$json_output = false
$json_include_output_property = true

$log_stderr = true
$log_syslog = true
$log_level = 'info'
$priority = 'debug'

$buffered_outputs = false
$outputs_rate = 1
$outputs_max_burst = 1000

$syslog_output = {
'enabled' => true
}
$file_output = {
'enabled' => false,
'keep_alive' => false,
'filename' => '/var/log/falco-events.log'
}
$stdout_output = {
'enabled' => true
}
$webserver = {
'enabled' => false,
'listen_port' => 8765,
'k8s_audit_endpoint' => '/k8s_audit',
'ssl_enabled' => false,
'ssl_certificate' => '/etc/falco/falco.pem'
}
$program_output = {
'enabled' => false,
'keep_alive' => false,
'program' => 'curl http://some-webhook.com'
}
$http_output = {
'enabled' => false,
'url' => 'http://some.url'
}

# Installation parameters
$package_ensure = 'installed'

# Service parameters
$service_ensure = 'running'
$service_enable = true
$service_restart = true
}
21 changes: 17 additions & 4 deletions integrations/puppet-module/sysdig-falco/manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# == Class: falco::service
class falco::service inherits falco {
validate_bool($falco::service_enable)

case $falco::service_ensure {
true, false, 'running', 'stopped': {
$_service_ensure = $falco::service_ensure
}
default: {
$_service_ensure = undef
}
}

service { 'falco':
ensure => running,
enable => true,
ensure => $_service_ensure,
enable => $falco::service_enable,
hasstatus => true,
hasrestart => true,
require => Package['falco'],
hasrestart => $falco::service_restart,
require => [
Class['falco::install'],
Class['falco::config'],
]
}
}
Loading

0 comments on commit 9c57473

Please sign in to comment.