最近准备花一周的时间准备CKS考试,在准备考试中发现有一个题目关于使用falco处理日志和安全监控的题目。
专栏其他文章:
- [CKS] K8S Admission Set Up
- [CKS] CIS基准测试,修复kubelet和etcd不安全项
- [CKS] K8S NetworkPolicy Set Up
- [CKS] 利用Trivy对image进行扫描
- [CKS] 利用falco进行容器日志捕捉和安全监控
- [CKS] Audit Log Policy
- [CKS] Create/Read/Mount a Secret in K8S
- [CKS] K8S Dockerfile和yaml文件安全检测
- [CKS] K8S RuntimeClass SetUp
- [CKS] TLS Secrets创建与挂载
- [CKS] falco扫描发现访问指定文件pod
- [CKS] 使用ingress公开https服务
- [CKS] bom工具生成SPDX文档
- [CKS] 执行Pod安全标准
- [CKS] Docker守护进程
- [CKS]启用apiserver身份验证
What’s th falco
Falco是一种开源的云原生安全工具,它是一个运行在Linux内核层的容器运行时安全监控系统。Falco可以实时监测容器和宿主机的活动,并根据预定义的规则进行安全警报和响应。它可以检测并报告容器内的异常行为、恶意活动和潜在的安全风险,帮助管理员及时发现和应对安全威胁。Falco能够提供对容器环境的实时可观察性,帮助用户更好地管理和保护容器化应用的安全。
Question 1
There is a Pod on the worker node called monitor in the default namespace. Its only container is also called monitor.
-
On the worker node, create a Falco rules file at /home/cloud_user/monitor_rules.yml.
-
Configure a rule to detect spawning processes within the container. The output should be in the format [timestamp],[container id],[container image name],[uid],[process name]. (The priority should be NOTICE; no [ ] are needed in the output).
本题是要求你创建一个falco的rule,并且配置这个role,能够输出[timestamp],[container id],[container image name],[uid],[process name]
Practice
- 创建一个yml文件
monitor_rules.yml
用于存储falco的规则, 具体文件内容如下
- rule: spawned_process_in_monitor_container
desc: "A rule for monitor container"
condition: container.name="monitor" and evt.type=execve
output: "%evt.time,%container.id,%container.image,%user.uid,%proc.name"
priority: NOTICE
Question 2
Run Falco for 45 seconds or so to check for activity in the container.
Save the output to a file located at /home/cloud_user/falco_output.log on the worker node.
本题要求你运行falco 45s,并输出日志到falco_output.log
Practice
运行falco命令:
sudo falco -M 45 -r monitor_rules.yml > /home/cloud_user/falco_output.log
怎么验证结果?
当任务完成后,你需要查看falco_output.log
文件,如果里面有内容,则代表本题已完成