{"componentChunkName":"component---src-pages-author-author-yaml-id-js","path":"/author/rashmi-jain/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"86d7db20-4388-5613-859e-0da8464070b3","html":"<p>Audience:  Anyone who wishes to deliver secure code to the rest of the world.</p>\n<h2 id=\"answer-to-what-it-is\" style=\"position:relative;\"><a href=\"#answer-to-what-it-is\" aria-label=\"answer to what it is permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Answer to <strong>What it is?</strong></h2>\n<p>At the heart of any image scanning tool is static analysis against a “Common Vulnerabilities and Exposures” (CVE) database. Each layer within the container image is analyzed and queried to discover known vulnerabilities. </p>\n<p>In addition to vulnerability scanning, a comprehensive tool should compare the architecture of your application against best practices to identify potential vulnerabilities. </p>\n<h2 id=\"answer-to-why-it-is-important\" style=\"position:relative;\"><a href=\"#answer-to-why-it-is-important\" aria-label=\"answer to why it is important permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Answer to <strong>Why it is important?</strong></h2>\n<p>While tools like Kubernetes and Container Registries have become household names for developer community because these tools make their life much easier to develop and deploy applications, many are still catching up on the need to integrate container security tools to secure their containerized application throughout the container lifecycle.  As the world is already shifted to containerized applications, taking good care of you docker images is also equally important.</p>\n<p>One of the main unique features of containers is how layers are used to build a container image. A service is piled up with an application server layer, a Linux layer and so on. One of these layers is updated, we can rebuild the application with a new updated version.</p>\n<p>It would be an unthinking idea to get into a container-based strategy without integrating a well-grounded and inclusive container scanning security solution into the CI/CD setup.</p>\n<h2 id=\"what-are-the-factors-to-keep-in-mind-while-selecting-the-right-tool\" style=\"position:relative;\"><a href=\"#what-are-the-factors-to-keep-in-mind-while-selecting-the-right-tool\" aria-label=\"what are the factors to keep in mind while selecting the right tool permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What are the factors to keep in mind while selecting the right tool?</h2>\n<ul>\n<li>The CVE database should be up-to-date to any new vulnerability.</li>\n<li>The tool should give good coverage and should be easy to integrate.</li>\n<li>Few Image registries like Amazon ECR and Docker Hub, they have it as inbuild container security solution.</li>\n</ul>\n<h2 id=\"lets-get-implemented\" style=\"position:relative;\"><a href=\"#lets-get-implemented\" aria-label=\"lets get implemented permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Let's get Implemented.</h2>\n<p>I am here, implementing a Clair tool in gitlab-ci.yml to get secure docker images.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">image_scanning:</span>\n<span class=\"grvsc-line\">  stage: scan</span>\n<span class=\"grvsc-line\">  image: docker:stable</span>\n<span class=\"grvsc-line\">  tags:</span>\n<span class=\"grvsc-line\">    - gitlab-org-docker</span>\n<span class=\"grvsc-line\">  services:</span>\n<span class=\"grvsc-line\">    - docker:19.03.8-dind   </span>\n<span class=\"grvsc-line\">  variables:</span>\n<span class=\"grvsc-line\">    DOCKER_DRIVER: overlay2</span>\n<span class=\"grvsc-line\">  allow_failure: true</span>\n<span class=\"grvsc-line\">  before_script:</span>\n<span class=\"grvsc-line\">    - echo $CI_BUILD_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY</span>\n<span class=\"grvsc-line\">  script:</span>\n<span class=\"grvsc-line\">  - docker run -d --name db arminc/clair-db:latest</span>\n<span class=\"grvsc-line\">  - docker run -p 6060:6060 --link db:postgres -d --name clair --restart on-failure arminc/clair-local-scan:v2.0.1</span>\n<span class=\"grvsc-line\">  - apk add -U wget ca-certificates</span>\n<span class=\"grvsc-line\">  - docker pull $CI_REGISTRY_IMAGE:$PROJECT_NAME-latest || true</span>\n<span class=\"grvsc-line\">  - wget https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64</span>\n<span class=\"grvsc-line\">  - mv clair-scanner_linux_amd64 clair-scanner</span>\n<span class=\"grvsc-line\">  - chmod +x clair-scanner</span>\n<span class=\"grvsc-line\">  - touch clair-whitelist.yml</span>\n<span class=\"grvsc-line\">  - while( ! wget -q -O /dev/null http://docker:6060/v1/namespaces ) ; do sleep 1 ; done</span>\n<span class=\"grvsc-line\">  - retries=0</span>\n<span class=\"grvsc-line\">  - echo &quot;Waiting for clair daemon to start&quot;</span>\n<span class=\"grvsc-line\">  - while( ! wget -T 10 -q -O /dev/null http://docker:6060/v1/namespaces ) ; do sleep 1 ; echo -n &quot;.&quot; ; if [ $retries -eq 10 ] ; then echo &quot; Timeout, aborting.&quot; ; exit 1 ; fi ; retries=$(($retries+1)) ; done</span>\n<span class=\"grvsc-line\">  - ./clair-scanner -c http://docker:6060 --ip $(hostname -i) -r gl-container-scanning-report.json -l clair.log -w clair-whitelist.yml $CI_REGISTRY_IMAGE:$PROJECT_NAME-latest || true</span>\n<span class=\"grvsc-line\">  - cat gl-container-scanning-report.json</span>\n<span class=\"grvsc-line\">  artifacts:</span>\n<span class=\"grvsc-line\">    paths: [gl-container-scanning-report.json]</span>\n<span class=\"grvsc-line\">  rules:</span>\n<span class=\"grvsc-line\">    - if: &#39;$CI_COMMIT_BRANCH == &quot;staging&quot;&#39;</span>\n<span class=\"grvsc-line\">      when: always</span></code></pre>\n<p><code>gitlab-org-docker</code> is a GitLab shared-runner to run this analysis (an agent on which the above-described job will run), it will fetch the latest ms image and will run it against the CVE database, at last record the report in the JSON file which we can store as artifacts. These artifacts can be further used by the developer to see and resolve the vulnerabilities.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"title":"Deep Dive into Container Security Scanning","author":{"id":"Rashmi Jain","github":null,"avatar":null},"date":"August 04, 2020","updated_date":null,"tags":["Docker","Container","Security"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5625,"src":"/static/860e2776d69822d2fd8a8d8185ad6411/ee604/cover_container_security.png","srcSet":"/static/860e2776d69822d2fd8a8d8185ad6411/69585/cover_container_security.png 200w,\n/static/860e2776d69822d2fd8a8d8185ad6411/497c6/cover_container_security.png 400w,\n/static/860e2776d69822d2fd8a8d8185ad6411/ee604/cover_container_security.png 800w,\n/static/860e2776d69822d2fd8a8d8185ad6411/f3583/cover_container_security.png 1200w,\n/static/860e2776d69822d2fd8a8d8185ad6411/5707d/cover_container_security.png 1600w,\n/static/860e2776d69822d2fd8a8d8185ad6411/eeb1b/cover_container_security.png 1920w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"fields":{"authorId":"Rashmi Jain","slug":"/engineering/container-security-scanning/"}}}]},"authorYaml":{"id":"Rashmi Jain","bio":"Very curious about this world and blogging whenever learning something new","github":null,"stackoverflow":"4693458","linkedin":"jain-rashmi","medium":null,"twitter":null,"avatar":null}},"pageContext":{"id":"Rashmi Jain","__params":{"id":"rashmi-jain"}}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}