Add a custom rule for shells in containers
Write a minimal custom rule with condition, output and priority to rules.d, where Falco picks it up.
cat > /etc/falco/rules.d/shell.yaml <<'EOF'
- rule: Shell in container
desc: A shell was spawned in a container
condition: container and proc.name in (bash, sh, zsh)
output: "Shell spawned (pod=%k8s.pod.name cmd=%proc.cmdline)"
priority: WARNING
EOF
- tool
- falco6 commands
More falco commands
-
falco -r /etc/falco/falco_rules.yaml --validateCheck rule syntax before you apply it; on error the exit code is non-zero, so it works as a CI check.
-
kubectl logs -l app.kubernetes.io/name=falco -n falco | jq 'select(.priority=="Critical")'Show only Critical Falco events from the JSON output; needs json_output: true in falco.yaml.
-
falcoctl artifact install falco-rules:latest && falcoctl artifact listInstall and manage versioned rules and plugins from OCI registries instead of copying rule files by hand.
-
falco -M 60 -o json_output=true 2>/dev/null | jq -c '{rule,output_fields}'Run Falco for 60 seconds and exit; useful for a quick check of a suspicious node.
-
falco --list | grep -E 'k8s\.|container\.|proc\.' | sortFind k8s, container and process fields to use in your own rule conditions and outputs.