当前位置:网站首页>Introduction to Clair, a container static security vulnerability scanning tool
Introduction to Clair, a container static security vulnerability scanning tool
2022-06-21 11:18:00 【0xtuhao】
According to the Green Alliance 2018 year 3 A study in June showed that , at present Docker Hub Image on 76% There are loopholes , The researchers pulled Docker Hub Open the top ten images in the popular images on , Use it Docker Image security scan tool Clair the CVE Scan statistics . The results are displayed in more than a hundred images , Those without loopholes only occupy 24%, Those with high-risk vulnerabilities account for 67%. Many of the images we often use are included in it , Such as :Httpd,Nginx,Mysql wait .
This article will introduce the CoreOS The official container static security vulnerability scanning tool Clair, The tool is also used by many docker registry Integrate , such as VMware Open source in China Harbor(CNCF Member project )、Quary as well as Dockyard etc. .
The following will start from the system architecture 、 Processing flow 、 The landing method and usage suggestions are introduced to you clair, It is hoped to provide an option for the safe landing of containers .
System architecture
Clair It mainly includes the following modules :
- Catcher (Fetcher)- Collect vulnerability data from public sources
- detector (Detector)- Point out the... Contained in the container image Feature
- Container formatter (Image Format)- Clair Known container image formats , Include Docker,ACI
- Notification hook (Notification Hook)- Notify the user when a new vulnerability is discovered or an existing vulnerability is changed / machine
- database (Databases)- Layers and vulnerabilities in the storage container
- Worker - Every Post Layer Will start a worker Conduct Layer Detect
Workflow
The overall process flow is as follows :
- Clair Periodically obtain vulnerability metadata from the configured source and store it in the database .
- Client side usage Clair API Dealing with images , Get the characteristics of the image and put them into the database .
- Client side usage Clair API Query the vulnerability of a specific image from the database , Associate vulnerabilities and characteristics for each request , Avoid the need to rescan the image .
- When updating vulnerability metadata , There will be a system notification . in addition , also webhook It is used to configure to record the affected images or intercept their deployment .
Landing mode
Clair It can be directly integrated into the container warehouse , So that the warehouse is responsible for representing the user and Clair Interact . This type of setup avoids manual scanning , And create a reasonable receiver to Clair Vulnerability notification in place . The warehouse can also be used to authorize , To avoid revealing the image vulnerability information that users should not access .Clair Can be integrated into CI/CD In the pipeline , So when the mirror is generated , Triggered after the image is pushed to the warehouse Clair Request to scan the image . The integration idea is as follows :
- Users push images to the container warehouse , The warehouse selects whether to call... According to the set black-and-white list Clair scan
- Once triggered Clair scanning , Wait for the scanning result to return , Then notify the user
- If a vulnerability is found , be CI It also prevents CD Process start , otherwise CD Process start
There are mainly kubernetes And local deployment .
Server side
- k8s cluster
git clone https://github.com/coreos/clair
cd clair/contrib/helm
cp clair/values.yaml ~/my_custom_values.yaml
vi ~/my_custom_values.yaml
helm dependency update clair
helm install clair -f ~/my_custom_values.yaml- local
$ mkdir $PWD/clair_config
$ curl -L https://raw.githubusercontent.com/coreos/clair/master/config.yaml.sample -o $PWD/clair_config/config.yaml
$ docker run -d -e POSTGRES_PASSWORD="" -p 5432:5432 postgres:9.6
$ docker run --net=host -d -p 6060-6061:6060-6061 -v $PWD/clair_config:/config quay.io/coreos/clair-git:latest -config=/config/config.yamlclient
It's just Clair The service side , Additional clients are required for application . Currently listed from the official Derivative development tools in , There are already many options .
- Official client clairctl The test results are as follows :
clairctl analyze -l cve-2017-11610_web
Image: /cve-2017-11610_web:latest
Unknown: 80
Negligible: 235
Low: 195
Medium: 418
High: 161
Critical: 0
Defcon1: 0- clair api 3.0 Not very clear , At present, it can still be in coreos Found on the official website api v1 Version of the document , But it doesn't make sense to use the new version , Because the change is too big .
- klar, Only support the following registry Integrate .
- yair, Only support the following registry Integrate ,yair Yes, it is python Written , You can modify it yourself .
- analyze-local-images: Command line , But was abandoned , Only support clair v1/v2.
Taken together ,clairctl It has rich functions , And the community is more active , Can keep up with clair Timely update of , Therefore, it is recommended to choose clairctl, Because of its own use golang Development , Therefore, you can also according to your own CI/CD Secondary development of scenarios .
Such as below :
Here is a brief introduction to clairctl Installation method of , For specific usage, please refer to the official wiki.
- Main branch version
curl -L https://raw.githubusercontent.com/jgsqware/clairctl/master/install.sh | sh
- Docker-compose
$ git clone [email protected]:jgsqware/clairctl.git $GOPATH/src/github.com/jgsqware/clairctl
$ cd $GOPATH/src/github.com/jgsqware/clairctl
$ docker-compose up -d postgresUse advice
- master Less stable , Not suitable for production environment , It is recommended to use release edition , The latest version is https://github.com/coreos/clair/tree/release-2.0
- because Clair Will be based on CVE Kusu yes Docker The kernel used by the image , But the container actually uses the host's kernel , This may lead to a large number of useless vulnerabilities or false positives , But according to Clair What the development team means , They leave the decision to the user , By default, no white list mechanism is provided , There is no distinction between them .
- The first time you start, you need to download data to the database , The download time depends on the quality of the network . It can be used https://github.com/arminc/clair-local-scan Replace clair official db Mirror image .
- Many kernel vulnerabilities have been detected , But in fact, it can not be handled . however clair Decide not to filter anything , It is up to the user to decide , thus , User secondary development , It is inevitable to add a black-and-white list mechanism .
Reference material
边栏推荐
- 高性能并行编程与优化 | 第01讲回家作业
- Break down tasks
- The advanced process resistance of Intel and TSMC is increasing, and Chinese chips are expected to shorten the gap
- When gdpr knocks
- WPF DataContext usage
- 导航栏切换,留言板,文本框失去焦点
- Runaway player
- 03. Redis actual battle: meeting goddess nearby by geo type
- 开源FTP 服务器 FileZilla Server
- fix libpng warning: iCCP: Not recognizing known sRGB profile ......
猜你喜欢

15+城市道路要素分割应用,用这一个分割模型就够了!

Secret magic weapon

【哈尔滨工业大学】考研初试复试资料分享

机器学习2-线性回归

国宝上新计划-四大博物馆独家数字珍藏强势来袭!
The first question of leetcode -- sum of two numbers

高性能并行编程与优化 | 第01讲回家作业

New experience of cultural tourism! 3dcat helps Guangzhou intangible cultural heritage "yuancosmos" block make a cool appearance

Citus 11 for Postgres 完全开源,可从任何节点查询(Citus 官方博客)

High concurrency - personal notes
随机推荐
Mqtt of NLog custom target
CAS central certification service
Runaway player
秘密法宝
Simple implementation of Snake game in C language
领导:谁再用redis过期监听实现关闭订单,立马滚蛋!
Kotlin - Sequence 序列
MySQL - library operation
2022年最强八股文《码出八股文-斩出offer线》
Hezhili: microbial driven carbon nitrogen sulfur phosphorus cycle in mangrove wetland sediments and its coupling mechanism
Nature子刊 | 周集中团队揭示长期气候变暖导致草地土壤微生物多样性降低
[ZZ] OWT server: audio and video forwarding diagram
numpy | 插入不定长字符数组测试OK
Implementation of qcustomplot based on qtquick
The out of the box caching function of angular server-side rendering applications
永不落幕的数据库注入攻防
开源FTP 服务器 FileZilla Server
求你了,别在高并发场景中使用悲观锁了!
DevSecOps:初入江湖
MySQL - Database Foundation