1

我用 docker compose 运行 falco 和 falcosidekick,没有 k8s

我需要将 aws 实例元数据检索到 falco 规则输出。我找到了 jevt 字段类,但在 falco 容器启动时遇到错误

Invalid output format 'command=%jevt.value[/awsRegion': 'invalid formatting token jevt.value[/awsRegion']

这是我的规则:

- rule: Terminal shell in container
  desc: A shell was used as the entrypoint/exec point into a container with an attached terminal.
  condition: >
    spawned_process and container
    and shell_procs and proc.tty != 0
    and container_entrypoint
    and not user_expected_terminal_shell_in_container_conditions
  output: >
    command=%jevt.value["/awsRegion"]
  priority: NOTICE
  tags: [ container, shell, mitre_execution ]

我能怎么做?谢谢

4

2 回答 2

0

有几件事要知道:

  • jevt.valueis的语法jevt.value[/awsRegion](无引号)
  • 这些类型的字段用于 json 格式的事件,它适用于 kubernetes 审计日志,但在您的规则基于系统调用的情况下
  • falco 也不会查询 aws 元数据,您不会像这样在输出中包含此信息

问候,

于 2021-11-25T22:59:47.820 回答
0

Falco 不查询 AWS 元数据,因此我使用 aws cli describe-instances 检索元数据并将元数据传递给 falcosidekick 容器。

#loading EC2 metadata
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
INSTANCE_IP=$(aws ec2 describe-instances --instance-id "$INSTANCE_ID" --region eu-west-1 --query 'Reservations[*].Instances[*].{InstanceIp:PublicIpAddress}' --output text)
CLUSTER_NAME=$(aws ec2 describe-instances --instance-id "$INSTANCE_ID" --region eu-west-1 --query 'Reservations[*].Instances[*].{ClusterName:Tags[?Key==`Name`]|[0].Value}' --output text)

docker run -d -p 2801:2801 -d \
  -e CUSTOMFIELDS=INSTANCE_ID:"$INSTANCE_ID",INSTANCE_IP:"$INSTANCE_IP",CLUSTER_NAME:"$CLUSTER_NAME" \
  --name falcosidekick \
  falcosecurity/falcosidekick
于 2021-11-29T14:05:23.033 回答