Commit Graph

737 Commits

Author SHA1 Message Date
Mark Stemm
646aed5b8b Explicitly spawn program via shell.
So example continues to work.
2017-06-14 15:26:17 -07:00
Brett
6bfff60fc3 Add *.pyc to .gitignore 2017-06-14 13:04:14 -07:00
Mark Stemm
6ebbbd47d8 Merge pull request #245 from draios/prepare-for-0-7-0
Update for 0.7.0.
2017-05-30 12:52:44 -07:00
Mark Stemm
69ebcdd8e9 Update for 0.7.0.
Update README/CHANGELOG for 0.7.0.
2017-05-30 09:35:24 -07:00
Mark Stemm
74c97489bd Merge pull request #244 from draios/better-priorities
Use a wider range of priorities in rules.
2017-05-25 13:51:12 -07:00
Mark Stemm
5bafa198c6 Update automated tests to handle new priority lvls
The default falco ruleset now has a wider variety of priorities, so
adjust the automated tests to match:

 - Instead of creating a generic test yaml entry for every trace file in
   traces-{positive,negative,info} with assumptions about detect levels,
   add a new falco_traces.yaml.in multiplex file that has specific
   information about the detect priorities and rule detect counts for each
   trace file.
 - If a given trace file doesn't have a corresponding entry in
   falco_traces.yaml.in, a generic entry is added with a simple
   detect: (True|False) value and level. That way you can get specific
   detect levels/counts for existing trace files, but if you forget to
   add a trace to falco_traces.yaml.in, you'll still get some coverage.
 - falco_tests.yaml.in isn't added to any longer, so rename it to
   falco_tests.yaml.
 - Avocado is now run twice--once on each yaml file. The final test
   passes if both avocado runs pass.
2017-05-25 12:15:35 -07:00
Mark Stemm
edce729bd9 Use a wider range of priorities in rules.
Review the priorities used by each rule and try to use a consistent set
that uses more of the possible priorities. The general guidelines I used
were:

 - If a rule is related to a write of state (i.e. filesystem, etc.),
   its priority is ERROR.
 - If a rule is related to an unauthorized read of state (i.e. reading
   sensitive filees, etc.), its priority is WARNING.
 - If a rule is related to unexpected behavior (spawning an unexpected
   shell in a container, opening an unexpected network connection, etc.), its priority
   is NOTICE.
 - If a rule is related to behaving against good practices (unexpected
   privileged containers, containers with sensitive mounts, running
   interactive commands as root), its priority is INFO.

One exception is that the most FP-prone rule (Run shell untrusted) has a
priority of DEBUG.
2017-05-24 18:54:14 -07:00
Mark Stemm
f426c4292d Merge pull request #243 from draios/falco-fps
Address some setns FPs.
2017-05-24 13:18:08 -07:00
Mark Stemm
277d8ab887 Merge pull request #242 from draios/container-shell-with-tty
Add rule for shell with terminal in container.
2017-05-24 10:49:03 -07:00
Mark Stemm
697d718739 Merge pull request #237 from dkerwin/add_gitlab_mon_command
Add gitlab-mon command
2017-05-24 10:29:28 -07:00
Mark Stemm
307a484425 Merge pull request #241 from sublimino/patch-1
fix: invalid spaces in README markdown
2017-05-24 10:28:22 -07:00
Mark Stemm
c5a964e651 Address some setns FPs.
Allow the sysdig cloud agent to call setns to collect java process
metrics.

We've also seen cases where some of the intermediate processes created
below runc appear to call setns. It appears that this only should happen
if some events (like the execve that spawns the intermediate processes)
are lost, but just to be safe allow processes starting with "runc:" to
call setns.
2017-05-24 10:17:57 -07:00
Andrew Martin
612fbb00d9
fix: invalid spaces in README markdown
Fix invalid spaces in markdown links

sysdig-CLA-1.0-signed-off-by: Andrew Martin sublimino@gmail.com
2017-05-24 11:16:16 +10:00
Mark Stemm
e88612a1af Add rule for shell with terminal in container.
Add a new falco rule "Terminal shell in container" that looks for shells
spawned in a container with an attached terminal. This is similar to the
existing "Run shell in container" rule, but doesn't have as many
exceptions as we expect this to be even less rare.
2017-05-23 13:37:44 -07:00
Mark Stemm
a86e3fc748 Merge pull request #239 from draios/update-for-0.6.1
Update for 0.6.1.
2017-05-15 11:07:44 -07:00
Mark Stemm
e97056569f Update for 0.6.1.
Update README/CHANGELOG for 0.6.1.
2017-05-15 10:37:57 -07:00
Mark Stemm
0e163b892f Merge pull request #238 from draios/claim-multiple-tokens
Add ability to claim multiple tokens.
2017-05-02 14:04:23 -07:00
Mark Stemm
4d148ce28f Add ability to claim multiple tokens.
This way you can use it as a form of bandwidth throttling.
2017-05-02 11:46:20 -07:00
Daniel Kerwin
974d864b3b Add gitlab-mon command
sysdig-CLA-1.0-signed-off-by: Daniel Kerwin daniel@gini.net
2017-05-02 17:30:50 +02:00
Mark Stemm
a3c83e7f6e Merge pull request #236 from draios/expose-tokens
Add ability to get number of tokens.
2017-04-27 13:19:47 -07:00
Mark Stemm
dafc4c2b88 Expose last seen time.
Also expose last seen time for token bucket.
2017-04-27 12:03:02 -07:00
Mark Stemm
c066be3905 Allow the initial time to be externally provided.
Allow the initial start time to be externally provided. Saves a call to
getttimeofday and allows running from an external clock (i.e. trace files).
2017-04-27 12:02:21 -07:00
Mark Stemm
f5ce6752be Add ability to get number of tokens.
Add a method to fetch the current number of available tokens.
2017-04-27 11:22:19 -07:00
Mark Stemm
060db62644 Merge pull request #235 from draios/fix-token-bucket-rate
Fix token bucket rate
2017-04-27 08:12:25 -07:00
Mark Stemm
1ad91c05f5 Fix token bucket rate
We were dividing the tokens gained by the rate instead of multiplying.
2017-04-26 19:02:04 -07:00
Mark Stemm
76876bc3ae Merge pull request #234 from draios/token-bucket-external-time
Allow for an external clock in token bucket.
2017-04-25 17:40:50 -07:00
Mark Stemm
e183de3b89 Allow rate to be less than 1.
Change all the token-related variables to doubles so the rate can be
less than 1.
2017-04-25 13:02:34 -07:00
Mark Stemm
87a6c74290 Allow for an external clock in token bucket.
Allow now to be externally provided to avoid unnecessary gettimeofday()
calls.
2017-04-25 10:01:25 -07:00
Mark Stemm
718113f7bd Merge pull request #232 from draios/remove-apache-shell-spawner
Don't allow apache2 to spawn shells in containers
2017-04-07 13:05:30 -07:00
Mark Stemm
955e1d78b1 Don't allow apache2 to spawn shells in containers
This ensures that interpreted php,perl,etc code run by apache won't be
able to spawn shells, either.

This fixes https://github.com/draios/falco/issues/231.
2017-04-06 15:24:21 -07:00
Mark Stemm
0cabeddf49 Merge pull request #228 from draios/prepare-for-0.6.0
Update changelog/readme for 0.6.0.
2017-03-29 15:11:05 -07:00
Mark Stemm
6127ca6e41 Update k8s README
To reflect github's new slightly stricter markdown format.
2017-03-29 14:39:27 -07:00
Mark Stemm
a2a707f771 Update changelog/readme for 0.6.0.
Updating with 0.6.0 featues/bug fixes.

Also update the formatting of README to honor github's new slightly
stricter markdown format.
2017-03-29 12:05:37 -07:00
Mark Stemm
3c2051176e Merge pull request #224 from draios/own-driver
Own driver
2017-03-24 21:35:48 -07:00
Mark Stemm
73fbbdb577 Add automated tests for packages/driver installs
Add automated tests for running falco from a package and container. As a
result, this will also test building the kernel module as well as
runnning falco-probe-loader as a backup.

In travis.yml, switch to the docker-enabled vm and install dkms. This
changed the environment slightly, so change how avocado's python
dependencies are installed. After building falco, copy the .deb package
to docker/local and build a local docker image based on that package.

Add the following new tests:

 - docker_package: this uses "docker run" to run the image created in
   travis.yml. This includes using dkms to build the kernel module and
   load it. In addition, the conf directory is mounted to /host/conf, the
   rules directory is mounted to /host/rules, and the traces directory is
   mounted to /host/traces.
 - docker_package_local_driver: this disables dkms via a volume mount
   that maps /dev/null to /usr/sbin/dkms and copies the kernel module by
   hand into the container to /root/.sysdig/falco-probe-....ko. As a
   result, falco-probe-loader will use the local kernel module instead
   of building one itself.
 - debian_package: this installs the .deb package and runs the installed
   version of falco.

Ideally, there'd also be a test for downloading the driver, but since
the driver depends on the kernel as well as the falco version string,
you can't put a single driver on download.draios.com that will work
long-term.

These tests depend on the following new test attributes:
  - package: if present, this points to the docker image/debian package
    to install.
  - addl_docker_run_args: if present, will be added to the docker run
    command.
  - copy_local_driver: if present, will copy the built kernel module to
    ~/.sysdig. ~/.sysdig/* is always cleared out before each test.
  - run_duration: maps to falco's -M <secs> flag
  - trace_file is now optional.

Also add some misc general test changes:
  - Clean up our use of process.run. By default it will fail a test if the
    run program returns non-zero, so we don't have to grab the exit
    status. In addition, get rid of sudo in the command lines and use the
    sudo attribute instead.

  - Fix some tests that were writing to files below /tmp/falco_outputs
    by creating the directory first. Useful when running avocado directly.
2017-03-24 16:54:42 -07:00
Mark Stemm
52b006e875 Add ability to run live for specific duration
Use -M <secs> (same as sysdig) to run falco for a specific duration and
exit.
2017-03-24 13:54:20 -07:00
Mark Stemm
f72182d9af Merge pull request #226 from draios/fix-k8s-daemonset
Make sure entrypoint runs for docker pod.
2017-03-21 14:44:57 -07:00
Mark Stemm
8d58589c39 Make sure entrypoint runs for docker pod.
If a daemonset specifies a command, this overrides the entrypoint. In
falco's case, the entrypoint handles the details of loading the kernel
driver, so specifying a command accidently prevents the driver from
being loaded.

This happens to work if you had a previously loaded sysdig_probe driver
lying around.

The fix is to specify args instead. In this case, the driver will be
loaded via the entrypoint.

This fixes https://github.com/draios/falco/issues/225.
2017-03-21 14:10:44 -07:00
Mark Stemm
ec5adfe892 Build and package standalone falco kernel module
Start packaging (and building when necessary) a falco-specific kernel
module in falco releases. Previously, falco would depend on sysdig and
use its kernel module instead.

The kernel module was already templated to some degree in various
places, so we just had to change the templated name from
sysdig/sysdig-probe to falco/falco-probe.

In containers, run falco-probe-loader instead of
sysdig-probe-loader. This is actually a script in the sysdig repository
which is modified in https://github.com/draios/sysdig/pull/789, and uses
the filename to indicate what kernel module to build and/or load.

For the falco package itself, don't depend on sysdig any longer but instead
depend on dkms and its dependencies, using sysdig as a guide on the set
of required packages.

Additionally, for the package pre-install/post-install scripts start
running falco-probe-loader.

Finally, add a --version argument to falco so it can pass the desired
version string to falco-probe-loader.
2017-03-20 15:56:37 -07:00
Mark Stemm
18900089f3 Merge pull request #221 from dkerwin/erl_child_setup_spawn_in_container
Add erl_child_setup to shell spawning binaries in a container.
2017-03-14 20:05:51 -07:00
Mark Stemm
490a3fef00 Merge pull request #222 from draios/add-k8s-example
Add falco,event generator files for k8s.
2017-03-07 14:36:33 -05:00
Mark Stemm
5e8dc8bce4 Add falco,event generator files for k8s.
Add example k8s yaml files that allow for running falco as a k8s
daemonset and the event generator as a deployment, running on 1 node.

Falco is configured to send its output to a slack webhook corresponding
to the #demo-falco-alerts channel on sysdig's public slack channel.

The output is is k8s friendly by using -pk, -k (k8s api server), and
-K (credentials to communicate with api server).
2017-03-07 10:46:32 -08:00
Daniel Kerwin
d29742a617 Add erl_child_setup to shell spawning binaries in a container.
sysdig-CLA-1.0-signed-off-by: Daniel Kerwin <daniel@linuxaddicted.de>
2017-03-06 21:33:44 +01:00
Mark Stemm
353defe362 Merge pull request #220 from dkerwin/add_gitlab_binaries
Add support for gitlab omnibus containers/pod
2017-03-06 11:13:28 -08:00
Mark Stemm
6b9620084f Merge pull request #218 from draios/add-erl-child-setup
Add erl_child_setup as a shell spawner.
2017-03-06 11:07:25 -08:00
Daniel Kerwin
537565d27a Add support for gitlab omnibus containers/pod
(https://docs.gitlab.com/omnibus/README.html).

sysdig-CLA-1.0-signed-off-by: Daniel Kerwin <daniel@linuxaddicted.de>
2017-03-06 17:22:24 +01:00
Mark Stemm
b2529f1108 Add erl_child_setup as a shell spawner. 2017-03-06 08:00:30 -08:00
Mark Stemm
561c388dab Merge pull request #212 from draios/use-formatter-cache
Use formatter cache
2017-02-27 21:10:44 -08:00
Mark Stemm
db469c6514 Use sysdig's formatter cache.
Use the sinsp_evt_formatter_cache added in
https://github.com/draios/sysdig/pull/771 instead of a local cache. This
simplifies the lua side quite a bit, as it only needs to call
format_output(), and clean up everything via free_formatters() in
output_cleanup().

On the C side, use a sinsp_evt_formatter object and use it in
format_event().
2017-02-27 12:15:49 -08:00
Mark Stemm
fb36af12cf Return lua errors not falco_exceptions
In C functions that implement lua functions, don't directly throw
falco_exceptions, which results in opaque error messages like:

Mon Feb 27 10:09:58 2017: Runtime error: Error invoking function output:
C++ exception. Exiting.

Instead, return lua errors via lua_error().
2017-02-27 11:57:36 -08:00