Commit Graph

2166 Commits

Author SHA1 Message Date
Mark Stemm
a787dc84d5 Add daemonization, fix any bugs found.
Add support for daemonizing via the --daemon flag. If daemonized, the
pid is written to the file provided via the --pidfile flag. When
daemonized, falco immediately returns an error if stderr output or
logging was chosen on the command line.

Clean up handling of outputs to match the expected use case (daemon):

 - syslog output is enabled by default
 - stdout output is disabled by default
 - If not configured at all, both outputs are enabled.

Also fix some bugs I found while running via packages:

 - There were still some references to the old rules filename
   falco_rules.conf.
 - The redhat package mistakenly defined some system directories like
   /etc, /etc/init.d. Add them to the exclusion list (See
   https://cmake.org/Bug/view.php?id=13609 for context).
 - Clean up some of the error messages to be more consistent.

After this I was able to build and install debian and rpm
packages. Starting the falco service ran falco as a daemon with syslog
output.
2016-05-06 17:25:54 -07:00
Mark Stemm
cfc89127e7 Add init.d files to debian/redhat packages.
Add init.d scripts to debian/redhat packages as well as
postinstall/remove scripts to enable the falco service on install and
disable it on uninstall.

I still need to add support for daemonization to falco, and change the
default output options to match the expected use of being daemonized.
2016-05-06 14:04:44 -07:00
Mark Stemm
b8cdb8e46c Modify existing rules to not use ignored syscalls.
The ignored syscalls in macros were:
 - write: renamed to open_write to make its weaker resolution more
 apparent. Checks for open with any flag that could change a file.
 - read: renamed to open_read. Checks for open with any read flag.
 - sendto: I couldn't think of any way to replace this, so I simply
 removed it with a comment.

I kept the original read/write macros commented out with a note that
they use ignored syscalls.

I have not tested these changes yet other than verifying that falco
starts properly.
2016-05-05 23:20:46 -07:00
Mark Stemm
4f63461b59 Return errors for ignored syscalls.
Create a table containing the filtered syscalls and set it as the lua
global m_lua_ignored_syscalls == ignored_syscalls.

In the parser, add a general purpose ast traversal function
traverse_ast that calls a callback for all nodes of a specific type.

In the compiler, add a new function check_for_ignored_syscalls that uses
the traversal function to be called back for all "BinaryRelOp"
nodes (i.e. X = Y, X in [a, b, c], etc). For those nodes, if the lhs is
a field 'evt.type' or 'syscall.type' and the rhs contains one of the
ignored syscalls, throw an error.

Call check_for_ignored_syscalls after parsing any macro or rule
filter. The thrown error will contain the macro or rule that had the
ignored syscall.

In the next commit I'll change the rules to skip the ignored syscalls.
2016-05-05 22:52:04 -07:00
Mark Stemm
d220ff6bdc Merge pull request #39 from draios/add-dockerfiles
Add docker files to create images using apt-get.
2016-05-05 21:16:50 -07:00
Henri DF
3d02acf3af Merge pull request #38 from draios/rules-yaml
Change rules file format to YAML
2016-05-05 20:39:34 -07:00
Henri DF
fc04ddfe40 Move output code into output.lua 2016-05-06 03:37:23 +00:00
Henri DF
f6c8c4cb84 Fix (and rename) parser smoke test 2016-05-06 03:37:16 +00:00
Henri DF
9dd4e799cb Split out parsing into parser.lua 2016-05-06 03:37:16 +00:00
Henri DF
e1b9b047d0 Support new yaml format for rules
Uses yaml parsing lib to parse a yaml file comprising of a list of
macros and rules, like:

- macro: bin_dir
  condition: fd.directory in (/bin, /sbin, /usr/bin, /usr/sbin)

- macro: core_binaries
  condition: proc.name in (ls, mkdir, cat, less, ps)

- condition: (fd.typechar = 4 or fd.typechar=6) and core_binaries
  output: "%evt.time: %proc.name network with %fd.l4proto"

- condition: evt.type = write and bin_dir
  output: "%evt.time: System binary modified (file '%fd.filename' written by process %proc.name)"

- condition: container.id != host and proc.name = bash
  output: "%evt.time: Shell running in container (%proc.name, %container.id)"
2016-05-06 03:37:16 +00:00
Henri DF
fdafc7da77 Remove dead macro-checking code
The `check_macros` function wasn't doing anything, and checking is done as
part of expansion.
2016-05-06 03:36:59 +00:00
Henri DF
0ec141385d Remove outputs and macros from grammar
These will no longer need to be parsed with the move to yaml
2016-05-06 03:36:59 +00:00
Henri DF
480c964075 Remove traces of in-expr expansion
In-expr expansion has moved to libsinsp (https://github.com/draios/sysdig/pull/565)
2016-05-06 03:36:59 +00:00
Henri DF
77a3e3b110 Load statically-linked lyaml lib and lua bindings 2016-05-06 03:36:59 +00:00
Henri DF
1703d048c3 Add libyaml (c lib) and lyaml (lua bindings) to build 2016-05-06 03:36:59 +00:00
Henri DF
a9f9454d26 Remove unneeded include dir 2016-05-06 03:36:59 +00:00
Henri DF
e3adaf2a5a Convert rules file to yaml format 2016-05-06 03:36:59 +00:00
Mark Stemm
0914651d1d Merge pull request #37 from draios/remaining-digwatch-falco-renames
Remove remaining digwatch references (really).
2016-05-04 18:34:10 -07:00
Mark Stemm
ba80367116 Remove remaining digwatch references (really).
Try harder looking for remaining digwatch references, replacing with
falco.
2016-05-04 15:44:11 -07:00
Mark Stemm
bd7b9880ee Merge pull request #36 from draios/readme-build-additions
Changes related to use of kernel module.
2016-05-04 13:07:32 -07:00
Mark Stemm
c2ee87976c Add docker files to create images using apt-get.
Based on the Dockerfiles from the sysdig repository. The only change
from the sysdig versions is to use environment variable FALCO_REPOSITORY
and to install falco instead of sysdig.

Note that the entrypoint still uses sysdig-probe-loader and
SYSDIG_HOST_ROOT, as it's building the kernel module for sysdig.

I verified I could create and run an image using the dev version using
"docker build ." from docker/dev, and run it using:

docker run -i -t --name falco --privileged -v /var/run/docker.sock:/host/var/run/docker.sock -v /dev:/host/dev -v /proc:/host/proc:ro -v /boot:/host/boot:ro -v /lib/modules:/host/lib/modules:ro -v /usr:/host/usr:r\o sysdig/falco falco -r /etc/falco_rules.conf

I still need to update jenkins to create a release build.
2016-05-03 17:10:55 -07:00
Mark Stemm
dfa6da47a3 Update README to always use local kernel module.
Instead of suggesting using a kernel module from an installed version of
sysdig, always recommend unloading any existing module and using the
locally built one.
2016-05-03 15:45:28 -07:00
Mark Stemm
345452836b Changes related to use of kernel module.
While building falco from source, I found a couple of problems related
to use of kernel modules:

1. The falco build needs driver_config.h from the sysdig repo, but it
isn't created by default.

[ 50%] Building C object userspace/libscap/CMakeFiles/scap.dir/scap.c.o
/mnt/sf_stemm/work/src/sysdig/userspace/libscap/scap.c:34:40: fatal error: ../../driver/driver_config.h: No such file or directory
compilation terminated.c

Fixed by adding ${SYSDIG_DIR}/driver to CMakeLists.txt. I did notice
that after doing this the object files were in the sysdig/driver
directory, but I don't think this is related to the Makefiles/CMakeFiles
in the sysdig/driver directory?

2. Falco needs the sysdig kernel module, but it may not be loaded if no
other sysdig is installed.

Added notes to the README that discuss loading the kernel module by hand
if no binary sysdig is installed.
2016-05-02 22:46:22 -07:00
Mark Stemm
7040d018c4 Merge pull request #35 from draios/remove-digiwatch-refs
Remove remaining Digwatch references.
2016-05-02 12:09:31 -07:00
Mark Stemm
738f555bae Remove remaining Digwatch references.
Remove remaining Digwatch references I noticed while getting up to
speed.
2016-05-02 11:32:33 -07:00
Henri DF
9729058b9b Update README.md 2016-05-02 10:59:31 -07:00
Henri DF
14c1e30c24 Simple script to list ignored syscalls 2016-05-01 23:35:30 +00:00
Henri DF
c7648e01ee Merge pull request #34 from draios/falco-digwatch-renaming
More falco->digwatch renaming
2016-05-01 16:19:30 -07:00
Henri DF
bde9631cd4 More falco->digwatch renaming 2016-05-01 23:13:28 +00:00
Henri DF
c702713107 Add discarded syscalls to README 2016-05-01 09:14:43 -07:00
Henri DF
244ebad1da Merge pull request #33 from draios/falco-digwatch-renaming
More falco->digwatch renaming
2016-05-01 09:10:08 -07:00
Henri DF
5052039ee1 More falco->digwatch renaming 2016-05-01 16:09:49 +00:00
Henri DF
81e51d13e7 Update README.md 2016-04-28 17:06:57 -07:00
Henri DF
657573d3a9 Merge pull request #31 from draios/discard-by-type
Drop high-volume events
2016-04-28 15:36:33 -07:00
Henri DF
e207bc5f3a Drop high-volume events 2016-04-28 20:58:28 +00:00
Henri DF
8252b9decb Update README.md 2016-04-27 22:10:35 -07:00
Henri DF
edb112f167 Merge pull request #32 from draios/rename-falco
Name change!
2016-04-27 20:28:52 -07:00
Henri DF
abe6220651 Renaming 2016-04-28 03:28:19 +00:00
Henri DF
8b5fcf866a Merge pull request #30 from draios/logging
Logging
2016-04-22 16:01:37 -07:00
Henri DF
6d72619968 rename digwatch_syslog -> digwatch_logger 2016-04-22 16:01:00 -07:00
Henri DF
4c64295adc Digwatch logging
Log digwatch messages to syslog and/or stderr
2016-04-22 15:56:18 -07:00
Henri DF
5413935f15 Small tweak to usage message 2016-04-22 15:33:43 -07:00
Henri DF
fad88ee4b7 Remove signal handling
Not currently serving any purpose
2016-04-22 14:59:58 -07:00
Henri DF
6b2ef3088c Merge pull request #29 from draios/install-digwat
Add install-digwatch script template
2016-04-21 16:36:15 -07:00
Henri DF
1baedc156f Add install-digwatch script template 2016-04-21 16:33:17 -07:00
Henri DF
d59e66da86 Merge pull request #28 from draios/json-output
Add support for json-formatted output
2016-04-21 16:31:53 -07:00
Henri DF
45f8096dd3 Add support for json-formatted output 2016-04-21 16:30:51 -07:00
Henri DF
f837dfc78c Change s3 URL https->http for Jenkins 2016-04-21 23:17:00 +00:00
Henri DF
fc5b51774a Update README.md 2016-04-12 21:57:10 -07:00
Henri DF
8ad7679f7f Remove priority_level from yaml file
It is not currently used for anything, will revert when that time comes.
2016-04-12 21:49:54 -07:00