{"id":1195,"date":"2022-07-04T16:20:08","date_gmt":"2022-07-04T08:20:08","guid":{"rendered":"https:\/\/www.yinyubo.com\/?p=1195"},"modified":"2022-08-29T17:00:38","modified_gmt":"2022-08-29T09:00:38","slug":"trivy%e4%b8%8edroneci%e7%bb%93%e5%90%88%ef%bc%8c%e6%89%ab%e6%8f%8f%e5%ae%b9%e5%99%a8%e5%ae%89%e5%85%a8","status":"publish","type":"post","link":"https:\/\/www.yinyubo.com\/?p=1195","title":{"rendered":"trivy\u4e0edroneCI\u7ed3\u5408\uff0c\u626b\u63cf\u5bb9\u5668\u5b89\u5168"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"trivy\u4e0edroneCI\u7ed3\u5408\uff0c\u626b\u63cf\u5bb9\u5668\u5b89\u5168-trivy\u662f\u4ec0\u4e48\uff1f\">trivy\u662f\u4ec0\u4e48\uff1f<\/h2>\n\n\n\n<p>\u4e00\u6b3e\u7b80\u5355\u7684\u5b89\u5168\u626b\u63cf\u5de5\u5177\uff0c\u626b\u63cf\u8303\u56f4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>OS packages and software dependencies in use (SBOM)<\/li><li>Known vulnerabilities (CVEs)<\/li><li>IaC misconfigurations<\/li><li>Sensitive information and secrets<\/li><\/ul>\n\n\n\n<p>\u6211\u4eec\u9009\u62e9\u5b83\u7684\u4e3b\u8981\u539f\u56e0\u662f\uff0c1.\u5b83\u80fd\u4ee5docker\u7684\u65b9\u5f0f\u8fd0\u884c\uff0c\u901a\u8fc7\u628a\u75c5\u6bd2\u5e93\u7f13\u5b58\u6302\u8f7d\u5728NFS\u4e2d\uff0c\u907f\u514d\u6bcf\u6b21CI\u90fd\u53bb\u62c9\u53d6\u75c5\u6bd2\u5e93\u30022.\u5b83\u7684\u626b\u63cf\u901f\u5ea6\u5feb\uff0c10\u79d2\u949f\u4e4b\u5185\u80fd\u7ed3\u675f\u6218\u6597\u30023.\u5b83\u7684\u626b\u63cf\u5bf9\u8c61\u53ef\u4ee5\u662f\u5bb9\u5668\u955c\u50cf\uff0c\u76f4\u63a5\u626b\u63cf\u6211\u4eec\u4e1a\u52a1\u4ee3\u7801\u751f\u6210\u7684\u955c\u50cf\u3002<\/p>\n\n\n\n<p>4.\u5f53\u626b\u63cf\u51fa\u5b89\u5168\u6f0f\u6d1e\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u65b0\u57fa\u7840\u955c\u50cf\uff0c\u4e00\u6b21\u6027\u89e3\u51b3\u5b89\u5168\u95ee\u9898\uff0c\u5e76\u4e14\u518d\u6b21\u8fd0\u884ctrivy\uff0c\u5feb\u901f\u68c0\u67e5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">droneCI\u91cc\u600e\u4e48\u4f7f\u7528trivy\u5462\uff1f<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"515\" height=\"436\" src=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image.png\" alt=\"\" class=\"wp-image-1196\" srcset=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image.png 515w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image-300x254.png 300w\" sizes=\"auto, (max-width: 515px) 100vw, 515px\" \/><\/figure>\n\n\n\n<p>1.\u6bcf\u665a\u5b9a\u65f6\u66f4\u65b0trivy\u6570\u636e\u5e93\uff0c\u907f\u5f00trivy\u6bcf\u6b21\u81ea\u52a8\u66f4\u65b0\uff0c\u56e0\u4e3a\u9ed8\u8ba4trivy\u4e0a\u6e38\u4ed3\u5e93\u662f6\u5c0f\u65f6\u66f4\u65b0\u4e00\u6b21\u3002\u5982\u679c\u6ca1\u6709\u81ea\u52a8\u66f4\u65b0\uff0c\u5f88\u6709\u53ef\u80fd\u5de7\u4e86\uff0c\u5c31\u521a\u597d\u767d\u5929\u6709\u6b21drone\u6d41\u6c34\u7ebf\u4e1a\u52a1\u4ee3\u7801\u63d0\u4ea4\u9047\u4e0a\u4e86trivy\uff0c\u90a3\u5c31\u82b1\u65f6\u95f4\u4e45\u4e86<\/p>\n\n\n\n<p>\u9644\u4e0adrone\u6d41\u6c34\u7ebf-trivy\u4ed3\u5e93\u7684\u53c2\u8003\u4ee3\u7801\u3002\u628a\u66f4\u65b0\u597d\u7684\u6570\u636e\u5e93\uff0c\u6302\u8f7d\u5230\u4e00\u4e2anfs\u7f13\u5b58\u91cc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>---\nkind: pipeline\ntype: kubernetes\nname: download trivy db\nsteps:\n  - name: trivy download db\n    image: aquasec\/trivy:0.29.2\n    commands:\n      - \"trivy image --download-db-only\"\n    volumes:\n      - name: trivy-cache\n        path: \/root\/.cache\/\ntrigger:\n  event:\n    - cron\nvolumes:\n  - name: trivy-cache\n    host:\n      path: \/home\/nfs\/cache\/trivy<\/code><\/pre>\n\n\n\n<p>2.\u4ee5python\u4ed3\u5e93\u4e3a\u4f8b\u5b50\uff0c\u6211\u4eec\u5728\u751f\u6210\u955c\u50cf\u540e\uff0c\u901a\u8fc7trivy images &#8211;exit-code 1 {\u955c\u50cf\u540d\u79f0} \u529f\u80fd\u68c0\u67e5\uff0c\u5982\u679c\u6709\u5b89\u5168\u6f0f\u6d1e\uff0c\u4f1a\u8fd4\u56deexit-code 1\u6d41\u6c34\u7ebf\u7ed3\u675f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>---\r\nkind: pipeline\r\ntype: kubernetes\r\nname: push\r\nsteps:\r\n  - name: buildimages\r\n    image: gcr.io\/kaniko-project\/executor:v1.8.1\r\n    command: &#91;\u6b64\u5904\u7701\u53bbbuild \u955c\u50cf\u547d\u4ee4]\r\n  - name: trivy\r\n    image: aquasec\/trivy:0.29.2\r\n    commands:\r\n      - \"trivy image --skip-db-update --security-checks vuln --exit-code 1 python:latest\"\r\n    volumes:\r\n      - name: trivy-cache\r\n        path: \/root\/.cache\/\r\ntrigger:\r\n  event:\r\n    - push\r\nvolumes:\r\n  - name: trivy-cache\r\n    host:\r\n      path: \/home\/nfs\/cache\/trivy<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u6d41\u6c34\u7ebf\u6548\u679c<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"577\" src=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image-1-1024x577.png\" alt=\"\" class=\"wp-image-1197\" srcset=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image-1-1024x577.png 1024w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image-1-300x169.png 300w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image-1-768x433.png 768w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2022\/07\/image-1.png 1360w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>trivy\u662f\u4ec0\u4e48\uff1f \u4e00\u6b3e\u7b80\u5355\u7684\u5b89\u5168\u626b\u63cf\u5de5\u5177\uff0c\u626b\u63cf\u8303\u56f4\u5982\u4e0b\uff1a OS packages and software  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,10],"tags":[],"class_list":["post-1195","post","type-post","status-publish","format-standard","hentry","category-k8s","category-10"],"_links":{"self":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/1195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1195"}],"version-history":[{"count":1,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/1195\/revisions"}],"predecessor-version":[{"id":1198,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/1195\/revisions\/1198"}],"wp:attachment":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}