mirror of
https://github.com/falcosecurity/falco.git
synced 2026-03-31 17:12:41 +00:00
Compare commits
44 Commits
0.10.0
...
agent/0.83
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e62b25a8fb | ||
|
|
c5523d89a7 | ||
|
|
b2412302e6 | ||
|
|
81dcee23a9 | ||
|
|
81a38fb909 | ||
|
|
e9e9bd85c3 | ||
|
|
70f768d9ea | ||
|
|
a0331c9602 | ||
|
|
c3b0f0d96d | ||
|
|
2a7851c77b | ||
|
|
cb5db7486b | ||
|
|
512a36dfe1 | ||
|
|
73e1ae616a | ||
|
|
c30c5a7a62 | ||
|
|
2b75439d08 | ||
|
|
b99a4e5ccf | ||
|
|
05c4ba1842 | ||
|
|
45d467656f | ||
|
|
3912e6e44b | ||
|
|
958c0461bb | ||
|
|
19db7890b3 | ||
|
|
1c9f86bdd8 | ||
|
|
e0458cba67 | ||
|
|
cd2b210fe3 | ||
|
|
5ac3e7d074 | ||
|
|
d321666ee5 | ||
|
|
09d570d985 | ||
|
|
5844030bcb | ||
|
|
31482c2a18 | ||
|
|
498d083980 | ||
|
|
6fd7f0d628 | ||
|
|
d6fe29b47d | ||
|
|
a71cbcd7ee | ||
|
|
99d6bccc81 | ||
|
|
f92f74eaa8 | ||
|
|
d42d0e2dd1 | ||
|
|
135b4d9975 | ||
|
|
a25166b7ac | ||
|
|
800a3f1ea1 | ||
|
|
31464de885 | ||
|
|
9b308d2793 | ||
|
|
a99f09da96 | ||
|
|
1e0ddba11a | ||
|
|
b6d1101cb6 |
@@ -10,7 +10,7 @@ before_install:
|
||||
- sudo apt-get update
|
||||
install:
|
||||
- sudo apt-get --force-yes install g++-4.8
|
||||
- sudo apt-get install rpm linux-headers-$(uname -r)
|
||||
- sudo apt-get install rpm linux-headers-$(uname -r) libelf-dev
|
||||
- git clone https://github.com/draios/sysdig.git ../sysdig
|
||||
- sudo apt-get install -y python-pip libvirt-dev jq dkms
|
||||
- cd ..
|
||||
|
||||
12
COPYING
12
COPYING
@@ -277,18 +277,6 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
* In addition, as a special exception, the copyright holders give
|
||||
* permission to link the code of portions of this program with the
|
||||
* OpenSSL library under certain conditions as described in each
|
||||
* individual source file, and distribute linked combinations
|
||||
* including the two.
|
||||
* You must obey the GNU General Public License in all respects
|
||||
* for all of the code used other than OpenSSL. If you modify
|
||||
* file(s) with this exception, you may extend this exception to your
|
||||
* version of the file(s), but you are not obligated to do so. If you
|
||||
* do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
@@ -41,6 +41,10 @@ License Terms
|
||||
---
|
||||
Falco is licensed to you under the [GPL 2.0](./COPYING) open source license.
|
||||
|
||||
In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two.
|
||||
|
||||
You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
|
||||
|
||||
Contributor License Agreements
|
||||
---
|
||||
### Background
|
||||
|
||||
@@ -17,18 +17,30 @@ ADD http://download.draios.com/apt-draios-priority /etc/apt/preferences.d/
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
bash-completion \
|
||||
curl \
|
||||
jq \
|
||||
gnupg2 \
|
||||
bc \
|
||||
clang-7 \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg2 \
|
||||
gcc \
|
||||
gcc-5 \
|
||||
gdb && rm -rf /var/lib/apt/lists/*
|
||||
gcc-6 \
|
||||
gdb \
|
||||
jq \
|
||||
libc6-dev \
|
||||
libelf-dev \
|
||||
llvm-7 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Since our base Debian image ships with GCC 7 which breaks older kernels, revert the
|
||||
# default to gcc-5.
|
||||
RUN rm -rf /usr/bin/gcc && ln -s /usr/bin/gcc-5 /usr/bin/gcc
|
||||
|
||||
RUN rm -rf /usr/bin/clang \
|
||||
&& rm -rf /usr/bin/llc \
|
||||
&& ln -s /usr/bin/clang-7 /usr/bin/clang \
|
||||
&& ln -s /usr/bin/llc-7 /usr/bin/llc
|
||||
|
||||
RUN curl -s https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public | apt-key add - \
|
||||
&& curl -s -o /etc/apt/sources.list.d/draios.list http://download.draios.com/$FALCO_REPOSITORY/deb/draios.list \
|
||||
&& apt-get update \
|
||||
|
||||
@@ -17,18 +17,30 @@ ADD http://download.draios.com/apt-draios-priority /etc/apt/preferences.d/
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
bash-completion \
|
||||
curl \
|
||||
jq \
|
||||
gnupg2 \
|
||||
bc \
|
||||
clang-7 \
|
||||
ca-certificates \
|
||||
curl \
|
||||
dkms \
|
||||
gnupg2 \
|
||||
gcc \
|
||||
gcc-5 \
|
||||
dkms && rm -rf /var/lib/apt/lists/*
|
||||
gcc-6 \
|
||||
jq \
|
||||
libc6-dev \
|
||||
libelf-dev \
|
||||
llvm-7 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Since our base Debian image ships with GCC 7 which breaks older kernels, revert the
|
||||
# default to gcc-5.
|
||||
RUN rm -rf /usr/bin/gcc && ln -s /usr/bin/gcc-5 /usr/bin/gcc
|
||||
|
||||
RUN rm -rf /usr/bin/clang \
|
||||
&& rm -rf /usr/bin/llc \
|
||||
&& ln -s /usr/bin/clang-7 /usr/bin/clang \
|
||||
&& ln -s /usr/bin/llc-7 /usr/bin/llc
|
||||
|
||||
RUN ln -s $SYSDIG_HOST_ROOT/lib/modules /lib/modules
|
||||
|
||||
ADD falco-${FALCO_VERSION}-x86_64.deb /
|
||||
|
||||
@@ -17,17 +17,29 @@ ADD http://download.draios.com/apt-draios-priority /etc/apt/preferences.d/
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
bash-completion \
|
||||
curl \
|
||||
jq \
|
||||
bc \
|
||||
clang-7 \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg2 \
|
||||
gcc \
|
||||
gcc-5 && rm -rf /var/lib/apt/lists/*
|
||||
gcc-5 \
|
||||
gcc-6 \
|
||||
jq \
|
||||
libc6-dev \
|
||||
libelf-dev \
|
||||
llvm-7 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Since our base Debian image ships with GCC 7 which breaks older kernels, revert the
|
||||
# default to gcc-5.
|
||||
RUN rm -rf /usr/bin/gcc && ln -s /usr/bin/gcc-5 /usr/bin/gcc
|
||||
|
||||
RUN rm -rf /usr/bin/clang \
|
||||
&& rm -rf /usr/bin/llc \
|
||||
&& ln -s /usr/bin/clang-7 /usr/bin/clang \
|
||||
&& ln -s /usr/bin/llc-7 /usr/bin/llc
|
||||
|
||||
RUN curl -s https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public | apt-key add - \
|
||||
&& curl -s -o /etc/apt/sources.list.d/draios.list http://download.draios.com/$FALCO_REPOSITORY/deb/draios.list \
|
||||
&& apt-get update \
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
# The truncated dpkg-preconfigu is intentional, process names are
|
||||
# truncated at the sysdig level.
|
||||
- list: package_mgmt_binaries
|
||||
items: [rpm_binaries, deb_binaries, update-alternat, gem, pip, sane-utils.post]
|
||||
items: [rpm_binaries, deb_binaries, update-alternat, gem, pip, sane-utils.post, alternatives, chef-client]
|
||||
|
||||
- macro: package_mgmt_procs
|
||||
condition: proc.name in (package_mgmt_binaries)
|
||||
@@ -375,6 +375,9 @@
|
||||
(proc.cmdline startswith "sed -ri" or proc.cmdline startswith "sed -i") and
|
||||
(fd.name startswith /etc/httpd/conf.d/ or fd.name startswith /etc/httpd/conf))
|
||||
|
||||
- macro: userhelper_writing_etc_security
|
||||
condition: (proc.name=userhelper and fd.name startswith /etc/security)
|
||||
|
||||
- macro: parent_Xvfb_running_xkbcomp
|
||||
condition: (proc.pname=Xvfb and proc.cmdline startswith 'sh -c "/usr/bin/xkbcomp"')
|
||||
|
||||
@@ -395,18 +398,13 @@
|
||||
- list: known_shell_spawn_binaries
|
||||
items: []
|
||||
|
||||
- macro: shell_spawning_containers
|
||||
condition: (container.image startswith jenkins or
|
||||
container.image startswith gitlab/gitlab-ce or
|
||||
container.image startswith gitlab/gitlab-ee)
|
||||
|
||||
## End Deprecated
|
||||
|
||||
- macro: ansible_running_python
|
||||
condition: (proc.name in (python, pypy) and proc.cmdline contains ansible)
|
||||
|
||||
- macro: chef_running_yum_dump
|
||||
condition: (proc.name=python and proc.cmdline contains yum-dump.py)
|
||||
- macro: python_running_chef
|
||||
condition: (proc.name=python and (proc.cmdline contains yum-dump.py or proc.cmdline="python /usr/bin/chef-monitor.py"))
|
||||
|
||||
- macro: python_running_denyhosts
|
||||
condition: >
|
||||
@@ -490,9 +488,13 @@
|
||||
- macro: htpasswd_writing_passwd
|
||||
condition: (proc.name=htpasswd and fd.name=/etc/nginx/.htpasswd)
|
||||
|
||||
- macro: lvprogs_writing_lvm_archive
|
||||
condition: (proc.name in (dmeventd,lvcreate) and (fd.name startswith /etc/lvm/archive or
|
||||
fd.name startswith /etc/lvm/backup))
|
||||
- macro: lvprogs_writing_conf
|
||||
condition: >
|
||||
(proc.name in (dmeventd,lvcreate,pvscan) and
|
||||
(fd.name startswith /etc/lvm/archive or
|
||||
fd.name startswith /etc/lvm/backup or
|
||||
fd.name startswith /etc/lvm/cache))
|
||||
|
||||
- macro: ovsdb_writing_openvswitch
|
||||
condition: (proc.name=ovsdb-server and fd.directory=/etc/openvswitch)
|
||||
|
||||
@@ -541,6 +543,9 @@
|
||||
- macro: slapadd_writing_conf
|
||||
condition: (proc.name=slapadd and fd.name startswith /etc/ldap)
|
||||
|
||||
- macro: openldap_writing_conf
|
||||
condition: (proc.pname=run-openldap.sh and fd.name startswith /etc/openldap)
|
||||
|
||||
- macro: symantec_writing_conf
|
||||
condition: >
|
||||
((proc.name=symcfgd and fd.name startswith /etc/symantec) or
|
||||
@@ -554,6 +559,14 @@
|
||||
(proc.name=urlgrabber-ext- and proc.aname[3]=sosreport and
|
||||
(fd.name startswith /etc/pkt/nssdb or fd.name startswith /etc/pki/nssdb))
|
||||
|
||||
- macro: pkgmgmt_progs_writing_pki
|
||||
condition: >
|
||||
(proc.name=urlgrabber-ext- and proc.pname in (yum, yum-cron, repoquery) and
|
||||
(fd.name startswith /etc/pkt/nssdb or fd.name startswith /etc/pki/nssdb))
|
||||
|
||||
- macro: brandbot_writing_os_release
|
||||
condition: proc.name=brandbot and fd.name=/etc/os-release
|
||||
|
||||
- macro: selinux_writing_conf
|
||||
condition: (proc.name in (semodule,genhomedircon,sefcontext_comp) and fd.name startswith /etc/selinux)
|
||||
|
||||
@@ -567,7 +580,7 @@
|
||||
condition: (proc.name in (veritas_binaries) or veritas_driver_script)
|
||||
|
||||
- macro: veritas_writing_config
|
||||
condition: (veritas_progs and fd.name startswith /etc/vx)
|
||||
condition: (veritas_progs and (fd.name startswith /etc/vx or fd.name startswith /etc/opt/VRTS or fd.name startswith /etc/vom))
|
||||
|
||||
- macro: nginx_writing_conf
|
||||
condition: (proc.name=nginx and fd.name startswith /etc/nginx)
|
||||
@@ -593,6 +606,11 @@
|
||||
- macro: exe_running_docker_save
|
||||
condition: (proc.cmdline startswith "exe /var/lib/docker" and proc.pname in (dockerd, docker))
|
||||
|
||||
# Ideally we'd have a length check here as well but sysdig
|
||||
# filterchecks don't have operators like len()
|
||||
- macro: sed_temporary_file
|
||||
condition: (proc.name=sed and fd.name startswith "/etc/sed")
|
||||
|
||||
- macro: python_running_get_pip
|
||||
condition: (proc.cmdline startswith "python get-pip.py")
|
||||
|
||||
@@ -602,6 +620,9 @@
|
||||
- macro: gugent_writing_guestagent_log
|
||||
condition: (proc.name=gugent and fd.name=GuestAgent.log)
|
||||
|
||||
- macro: dse_writing_tmp
|
||||
condition: (proc.name=dse-entrypoint and fd.name=/root/tmp__)
|
||||
|
||||
- rule: Write below binary dir
|
||||
desc: an attempt to write to any file below a set of binary directories
|
||||
condition: >
|
||||
@@ -616,6 +637,44 @@
|
||||
priority: ERROR
|
||||
tags: [filesystem]
|
||||
|
||||
# If you'd like to generally monitor a wider set of directories on top
|
||||
# of the ones covered by the rule Write below binary dir, you can use
|
||||
# the following rule and lists.
|
||||
|
||||
- list: monitored_directories
|
||||
items: [/boot, /lib, /lib64, /usr/lib, /usr/local/lib, /usr/local/sbin, /usr/local/bin, /root/.ssh, /etc/cardserver]
|
||||
|
||||
# Until https://github.com/draios/sysdig/pull/1153, which fixes
|
||||
# https://github.com/draios/sysdig/issues/1152, is widely available,
|
||||
# we can't use glob operators to match pathnames. Until then, we do a
|
||||
# looser check to match ssh directories.
|
||||
# When fixed, we will use "fd.name glob '/home/*/.ssh/*'"
|
||||
- macro: user_ssh_directory
|
||||
condition: (fd.name startswith '/home' and fd.name contains '.ssh')
|
||||
|
||||
- macro: mkinitramfs_writing_boot
|
||||
condition: (proc.pname in (mkinitramfs, update-initramf) and fd.directory=/boot)
|
||||
|
||||
- macro: monitored_dir
|
||||
condition: >
|
||||
(fd.directory in (monitored_directories)
|
||||
or user_ssh_directory)
|
||||
and not mkinitramfs_writing_boot
|
||||
|
||||
- rule: Write below monitored dir
|
||||
desc: an attempt to write to any file below a set of binary directories
|
||||
condition: >
|
||||
evt.dir = < and open_write and monitored_dir
|
||||
and not package_mgmt_procs
|
||||
and not exe_running_docker_save
|
||||
and not python_running_get_pip
|
||||
and not python_running_ms_oms
|
||||
output: >
|
||||
File below a monitored directory opened for writing (user=%user.name
|
||||
command=%proc.cmdline file=%fd.name parent=%proc.pname pcmdline=%proc.pcmdline gparent=%proc.aname[2])
|
||||
priority: ERROR
|
||||
tags: [filesystem]
|
||||
|
||||
- list: safe_etc_dirs
|
||||
items: [/etc/cassandra, /etc/ssl/certs/java, /etc/logstash, /etc/nginx/conf.d, /etc/container_environment, /etc/hrmconfig]
|
||||
|
||||
@@ -677,7 +736,13 @@
|
||||
condition: (proc.name=httpd and fd.name startswith /etc/httpd/)
|
||||
|
||||
- macro: mysql_writing_conf
|
||||
condition: ((proc.name=start-mysql.sh or proc.pname=start-mysql.sh) and fd.name startswith /etc/mysql)
|
||||
condition: >
|
||||
((proc.name in (start-mysql.sh, run-mysqld) or proc.pname=start-mysql.sh) and
|
||||
(fd.name startswith /etc/mysql or fd.directory=/etc/my.cnf.d))
|
||||
|
||||
- macro: redis_writing_conf
|
||||
condition: >
|
||||
(proc.name=run-redis and fd.name=/etc/redis.conf)
|
||||
|
||||
- macro: openvpn_writing_conf
|
||||
condition: (proc.name in (openvpn,openvpn-entrypo) and fd.name startswith /etc/openvpn)
|
||||
@@ -733,6 +798,7 @@
|
||||
and not proc.pname in (sysdigcloud_binaries, mail_config_binaries, hddtemp.postins, sshkit_script_binaries, locales.postins, deb_binaries, dhcp_binaries)
|
||||
and not fd.name pmatch (safe_etc_dirs)
|
||||
and not fd.name in (/etc/container_environment.sh, /etc/container_environment.json, /etc/motd, /etc/motd.svc)
|
||||
and not sed_temporary_file
|
||||
and not exe_running_docker_save
|
||||
and not ansible_running_python
|
||||
and not python_running_denyhosts
|
||||
@@ -754,7 +820,7 @@
|
||||
and not supervise_writing_status
|
||||
and not pki_realm_writing_realms
|
||||
and not htpasswd_writing_passwd
|
||||
and not lvprogs_writing_lvm_archive
|
||||
and not lvprogs_writing_conf
|
||||
and not ovsdb_writing_openvswitch
|
||||
and not datadog_writing_conf
|
||||
and not curl_writing_pki_db
|
||||
@@ -791,6 +857,11 @@
|
||||
and not cockpit_writing_conf
|
||||
and not ipsec_writing_conf
|
||||
and not httpd_writing_ssl_conf
|
||||
and not userhelper_writing_etc_security
|
||||
and not pkgmgmt_progs_writing_pki
|
||||
and not brandbot_writing_os_release
|
||||
and not redis_writing_conf
|
||||
and not openldap_writing_conf
|
||||
|
||||
- rule: Write below etc
|
||||
desc: an attempt to write to any file below /etc
|
||||
@@ -837,7 +908,8 @@
|
||||
or fd.name startswith /root/.dbus
|
||||
or fd.name startswith /root/.composer
|
||||
or fd.name startswith /root/.gconf
|
||||
or fd.name startswith /root/.nv)
|
||||
or fd.name startswith /root/.nv
|
||||
or fd.name startswith /root/.local/share/jupyter)
|
||||
|
||||
- rule: Write below root
|
||||
desc: an attempt to write to any file directly below / or /root
|
||||
@@ -847,6 +919,7 @@
|
||||
and not fd.directory in (known_root_directories)
|
||||
and not exe_running_docker_save
|
||||
and not gugent_writing_guestagent_log
|
||||
and not dse_writing_tmp
|
||||
and not known_root_conditions
|
||||
output: "File below / or /root opened for writing (user=%user.name command=%proc.cmdline parent=%proc.pname file=%fd.name program=%proc.name)"
|
||||
priority: ERROR
|
||||
@@ -872,7 +945,7 @@
|
||||
iptables, ps, lsb_release, check-new-relea, dumpe2fs, accounts-daemon, sshd,
|
||||
vsftpd, systemd, mysql_install_d, psql, screen, debconf-show, sa-update,
|
||||
pam-auth-update, /usr/sbin/spamd, polkit-agent-he, lsattr, file, sosreport,
|
||||
scxcimservera, adclient, rtvscand, cockpit-session
|
||||
scxcimservera, adclient, rtvscand, cockpit-session, userhelper, ossec-syscheckd
|
||||
]
|
||||
|
||||
# Add conditions to this macro (probably in a separate file,
|
||||
@@ -918,7 +991,7 @@
|
||||
# Only let rpm-related programs write to the rpm database
|
||||
- rule: Write below rpm database
|
||||
desc: an attempt to write to the rpm database by any non-rpm related program
|
||||
condition: fd.name startswith /var/lib/rpm and open_write and not rpm_procs and not ansible_running_python and not chef_running_yum_dump
|
||||
condition: fd.name startswith /var/lib/rpm and open_write and not rpm_procs and not ansible_running_python and not python_running_chef
|
||||
output: "Rpm database opened for writing by a non-rpm program (command=%proc.cmdline file=%fd.name)"
|
||||
priority: ERROR
|
||||
tags: [filesystem, software_mgmt]
|
||||
@@ -940,6 +1013,9 @@
|
||||
- macro: rabbitmqctl_running_scripts
|
||||
condition: (proc.aname[2]=rabbitmqctl and proc.cmdline startswith "sh -c ")
|
||||
|
||||
- macro: run_by_appdynamics
|
||||
condition: (proc.pname=java and proc.pcmdline startswith "java -jar -Dappdynamics")
|
||||
|
||||
- rule: DB program spawned process
|
||||
desc: >
|
||||
a database-server related program spawned a new process other than itself.
|
||||
@@ -1072,6 +1148,17 @@
|
||||
- macro: possibly_node_in_container
|
||||
condition: (never_true and (proc.pname=node and proc.aname[3]=docker-containe))
|
||||
|
||||
# Similarly, you may want to consider any shell spawned by apache
|
||||
# tomcat as suspect. The famous apache struts attack (CVE-2017-5638)
|
||||
# could be exploited to do things like spawn shells.
|
||||
#
|
||||
# However, many applications *do* use tomcat to run arbitrary shells,
|
||||
# as a part of build pipelines, etc.
|
||||
#
|
||||
# Like for node, we make this case opt-in.
|
||||
- macro: possibly_parent_java_running_tomcat
|
||||
condition: (never_true and proc.pname=java and proc.pcmdline contains org.apache.catalina.startup.Bootstrap)
|
||||
|
||||
- macro: protected_shell_spawner
|
||||
condition: >
|
||||
(proc.aname in (protected_shell_spawning_binaries)
|
||||
@@ -1084,6 +1171,7 @@
|
||||
or parent_java_running_glassfish
|
||||
or parent_java_running_hadoop
|
||||
or parent_java_running_datastax
|
||||
or possibly_parent_java_running_tomcat
|
||||
or possibly_node_in_container)
|
||||
|
||||
- list: mesos_shell_binaries
|
||||
@@ -1122,11 +1210,12 @@
|
||||
and not redis_running_prepost_scripts
|
||||
and not rabbitmq_running_scripts
|
||||
and not rabbitmqctl_running_scripts
|
||||
and not run_by_appdynamics
|
||||
and not user_shell_container_exclusions
|
||||
output: >
|
||||
Shell spawned by untrusted binary (user=%user.name shell=%proc.name parent=%proc.pname
|
||||
cmdline=%proc.cmdline pcmdline=%proc.pcmdline gparent=%proc.aname[2] ggparent=%proc.aname[3]
|
||||
gggparent=%proc.aname[4] ggggparent=%proc.aname[5])
|
||||
aname[4]=%proc.aname[4] aname[5]=%proc.aname[5] aname[6]=%proc.aname[6] aname[7]=%proc.aname[7])
|
||||
priority: DEBUG
|
||||
tags: [shell]
|
||||
|
||||
@@ -1330,7 +1419,7 @@
|
||||
condition: >
|
||||
(fd.sockfamily = ip and system_procs)
|
||||
and (inbound_outbound)
|
||||
and not proc.name in (systemd, hostid)
|
||||
and not proc.name in (systemd, hostid, id)
|
||||
and not login_doing_dns_lookup
|
||||
output: >
|
||||
Known system binary sent/received network traffic
|
||||
|
||||
@@ -713,3 +713,30 @@ trace_files: !mux
|
||||
- open_dev_null: 1
|
||||
dev_null: 0
|
||||
trace_file: trace_files/cat_write.scap
|
||||
|
||||
skip_unknown_noevt:
|
||||
detect: False
|
||||
stdout_contains: Skipping rule "Contains Unknown Event And Skipping" that contains unknown filter proc.nobody
|
||||
rules_file:
|
||||
- rules/skip_unknown_evt.yaml
|
||||
trace_file: trace_files/cat_write.scap
|
||||
|
||||
skip_unknown_prefix:
|
||||
detect: False
|
||||
rules_file:
|
||||
- rules/skip_unknown_prefix.yaml
|
||||
trace_file: trace_files/cat_write.scap
|
||||
|
||||
skip_unknown_error:
|
||||
exit_status: 1
|
||||
stderr_contains: Rule "Contains Unknown Event And Not Skipping" contains unknown filter proc.nobody. Exiting.
|
||||
rules_file:
|
||||
- rules/skip_unknown_error.yaml
|
||||
trace_file: trace_files/cat_write.scap
|
||||
|
||||
skip_unknown_unspec_error:
|
||||
exit_status: 1
|
||||
stderr_contains: Rule "Contains Unknown Event And Unspecified" contains unknown filter proc.nobody. Exiting.
|
||||
rules_file:
|
||||
- rules/skip_unknown_unspec.yaml
|
||||
trace_file: trace_files/cat_write.scap
|
||||
|
||||
6
test/rules/skip_unknown_error.yaml
Normal file
6
test/rules/skip_unknown_error.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
- rule: Contains Unknown Event And Not Skipping
|
||||
desc: Contains an unknown event
|
||||
condition: proc.nobody=cat
|
||||
output: Never
|
||||
skip-if-unknown-filter: false
|
||||
priority: INFO
|
||||
6
test/rules/skip_unknown_evt.yaml
Normal file
6
test/rules/skip_unknown_evt.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
- rule: Contains Unknown Event And Skipping
|
||||
desc: Contains an unknown event
|
||||
condition: evt.type=open and proc.nobody=cat
|
||||
output: Never
|
||||
skip-if-unknown-filter: true
|
||||
priority: INFO
|
||||
8
test/rules/skip_unknown_prefix.yaml
Normal file
8
test/rules/skip_unknown_prefix.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
- rule: Contains Prefix of Filter
|
||||
desc: Testing matching filter prefixes
|
||||
condition: >
|
||||
evt.type=open and evt.arg.path="foo" and evt.arg[0]="foo"
|
||||
and proc.aname="ls" and proc.aname[1]="ls"
|
||||
and proc.apid=10 and proc.apid[1]=10
|
||||
output: Never
|
||||
priority: INFO
|
||||
5
test/rules/skip_unknown_unspec.yaml
Normal file
5
test/rules/skip_unknown_unspec.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
- rule: Contains Unknown Event And Unspecified
|
||||
desc: Contains an unknown event
|
||||
condition: proc.nobody=cat
|
||||
output: Never
|
||||
priority: INFO
|
||||
@@ -3,6 +3,7 @@ include_directories("${PROJECT_SOURCE_DIR}/../sysdig/userspace/libscap")
|
||||
include_directories("${PROJECT_SOURCE_DIR}/../sysdig/userspace/libsinsp")
|
||||
include_directories("${PROJECT_BINARY_DIR}/userspace/engine")
|
||||
include_directories("${LUAJIT_INCLUDE}")
|
||||
include_directories("${CURL_INCLUDE_DIR}")
|
||||
|
||||
add_library(falco_engine STATIC rules.cpp falco_common.cpp falco_engine.cpp token_bucket.cpp formats.cpp)
|
||||
|
||||
|
||||
@@ -322,6 +322,21 @@ function get_evttypes_syscalls(name, ast, source, warn_evttypes)
|
||||
return evttypes, syscallnums
|
||||
end
|
||||
|
||||
function get_filters(ast)
|
||||
|
||||
local filters = {}
|
||||
|
||||
function cb(node)
|
||||
if node.type == "FieldName" then
|
||||
filters[node.value] = 1
|
||||
end
|
||||
end
|
||||
|
||||
parser.traverse_ast(ast.filter.value, {FieldName=1} , cb)
|
||||
|
||||
return filters
|
||||
end
|
||||
|
||||
function compiler.expand_lists_in(source, list_defs)
|
||||
|
||||
for name, def in pairs(list_defs) do
|
||||
@@ -408,7 +423,9 @@ function compiler.compile_filter(name, source, macro_defs, list_defs, warn_evtty
|
||||
|
||||
evttypes, syscallnums = get_evttypes_syscalls(name, ast, source, warn_evttypes)
|
||||
|
||||
return ast, evttypes, syscallnums
|
||||
filters = get_filters(ast)
|
||||
|
||||
return ast, evttypes, syscallnums, filters
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -275,6 +275,12 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac
|
||||
error ("Missing name in rule")
|
||||
end
|
||||
|
||||
-- By default, if a rule's condition refers to an unknown
|
||||
-- filter like evt.type, etc the loader throws an error.
|
||||
if v['skip-if-unknown-filter'] == nil then
|
||||
v['skip-if-unknown-filter'] = false
|
||||
end
|
||||
|
||||
-- Possibly append to the condition field of an existing rule
|
||||
append = false
|
||||
|
||||
@@ -378,9 +384,34 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac
|
||||
warn_evttypes = v['warn_evttypes']
|
||||
end
|
||||
|
||||
local filter_ast, evttypes, syscallnums = compiler.compile_filter(v['rule'], v['condition'],
|
||||
state.macros, state.lists,
|
||||
warn_evttypes)
|
||||
local filter_ast, evttypes, syscallnums, filters = compiler.compile_filter(v['rule'], v['condition'],
|
||||
state.macros, state.lists,
|
||||
warn_evttypes)
|
||||
|
||||
-- If a filter in the rule doesn't exist, either skip the rule
|
||||
-- or raise an error, depending on the value of
|
||||
-- skip-if-unknown-filter.
|
||||
for filter, _ in pairs(filters) do
|
||||
found = false
|
||||
|
||||
for pat, _ in pairs(defined_filters) do
|
||||
if string.match(filter, pat) ~= nil then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
if v['skip-if-unknown-filter'] then
|
||||
if verbose then
|
||||
print("Skipping rule \""..v['rule'].."\" that contains unknown filter "..filter)
|
||||
end
|
||||
goto next_rule
|
||||
else
|
||||
error("Rule \""..v['rule'].."\" contains unknown filter "..filter)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (filter_ast.type == "Rule") then
|
||||
state.n_rules = state.n_rules + 1
|
||||
@@ -418,6 +449,8 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac
|
||||
|
||||
if (v['enabled'] == false) then
|
||||
falco_rules.enable_rule(rules_mgr, v['rule'], 0)
|
||||
else
|
||||
falco_rules.enable_rule(rules_mgr, v['rule'], 1)
|
||||
end
|
||||
|
||||
-- If the format string contains %container.info, replace it
|
||||
@@ -452,6 +485,8 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac
|
||||
else
|
||||
error ("Unexpected type in load_rule: "..filter_ast.type)
|
||||
end
|
||||
|
||||
::next_rule::
|
||||
end
|
||||
|
||||
if verbose then
|
||||
|
||||
@@ -258,6 +258,63 @@ void falco_rules::load_rules(const string &rules_content,
|
||||
|
||||
lua_setglobal(m_ls, m_lua_ignored_syscalls.c_str());
|
||||
|
||||
// Create a table containing all filtercheck names.
|
||||
lua_newtable(m_ls);
|
||||
|
||||
vector<const filter_check_info*> fc_plugins;
|
||||
sinsp::get_filtercheck_fields_info(&fc_plugins);
|
||||
|
||||
for(uint32_t j = 0; j < fc_plugins.size(); j++)
|
||||
{
|
||||
const filter_check_info* fci = fc_plugins[j];
|
||||
|
||||
if(fci->m_flags & filter_check_info::FL_HIDDEN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int32_t k = 0; k < fci->m_nfields; k++)
|
||||
{
|
||||
const filtercheck_field_info* fld = &fci->m_fields[k];
|
||||
|
||||
if(fld->m_flags & EPF_TABLE_ONLY ||
|
||||
fld->m_flags & EPF_PRINT_ONLY)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some filters can work with or without an argument
|
||||
std::set<string> flexible_filters = {
|
||||
"^proc.aname",
|
||||
"^proc.apid"
|
||||
};
|
||||
|
||||
std::list<string> fields;
|
||||
std::string field_base = string("^") + fld->m_name;
|
||||
|
||||
if(fld->m_flags & EPF_REQUIRES_ARGUMENT ||
|
||||
flexible_filters.find(field_base) != flexible_filters.end())
|
||||
{
|
||||
fields.push_back(field_base + "[%[%.]");
|
||||
}
|
||||
|
||||
if(!(fld->m_flags & EPF_REQUIRES_ARGUMENT) ||
|
||||
flexible_filters.find(field_base) != flexible_filters.end())
|
||||
{
|
||||
fields.push_back(field_base + "$");
|
||||
}
|
||||
|
||||
for(auto &field : fields)
|
||||
{
|
||||
lua_pushstring(m_ls, field.c_str());
|
||||
lua_pushnumber(m_ls, 1);
|
||||
lua_settable(m_ls, -3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lua_setglobal(m_ls, m_lua_defined_filters.c_str());
|
||||
|
||||
lua_pushstring(m_ls, rules_content.c_str());
|
||||
lua_pushlightuserdata(m_ls, this);
|
||||
lua_pushboolean(m_ls, (verbose ? 1 : 0));
|
||||
|
||||
@@ -56,6 +56,7 @@ class falco_rules
|
||||
string m_lua_load_rules = "load_rules";
|
||||
string m_lua_ignored_syscalls = "ignored_syscalls";
|
||||
string m_lua_ignored_events = "ignored_events";
|
||||
string m_lua_defined_filters = "defined_filters";
|
||||
string m_lua_events = "events";
|
||||
string m_lua_syscalls = "syscalls";
|
||||
string m_lua_describe_rule = "describe_rule";
|
||||
|
||||
@@ -158,7 +158,7 @@ uint64_t do_inspect(falco_engine *engine,
|
||||
bool all_events)
|
||||
{
|
||||
uint64_t num_evts = 0;
|
||||
int32_t res;
|
||||
int32_t rc;
|
||||
sinsp_evt* ev;
|
||||
StatsFileWriter writer;
|
||||
uint64_t duration_start = 0;
|
||||
@@ -179,7 +179,7 @@ uint64_t do_inspect(falco_engine *engine,
|
||||
while(1)
|
||||
{
|
||||
|
||||
res = inspector->next(&ev);
|
||||
rc = inspector->next(&ev);
|
||||
|
||||
writer.handle();
|
||||
|
||||
@@ -193,21 +193,21 @@ uint64_t do_inspect(falco_engine *engine,
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(res == SCAP_TIMEOUT)
|
||||
else if(rc == SCAP_TIMEOUT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if(res == SCAP_EOF)
|
||||
else if(rc == SCAP_EOF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(res != SCAP_SUCCESS)
|
||||
else if(rc != SCAP_SUCCESS)
|
||||
{
|
||||
//
|
||||
// Event read error.
|
||||
// Notify the chisels that we're exiting, and then die with an error.
|
||||
//
|
||||
cerr << "res = " << res << endl;
|
||||
cerr << "rc = " << rc << endl;
|
||||
throw sinsp_exception(inspector->getlasterr().c_str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user