<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Takashi Yoneuchi</title>
    <description>The latest articles on DEV Community by Takashi Yoneuchi (@y0n3uchy).</description>
    <link>https://dev.to/y0n3uchy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F691740%2F28d28468-ad1b-4e54-8fe7-76cc8ec99897.jpeg</url>
      <title>DEV Community: Takashi Yoneuchi</title>
      <link>https://dev.to/y0n3uchy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/y0n3uchy"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Takashi Yoneuchi</dc:creator>
      <pubDate>Tue, 17 Jun 2025 11:27:40 +0000</pubDate>
      <link>https://dev.to/y0n3uchy/-118d</link>
      <guid>https://dev.to/y0n3uchy/-118d</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/gmo-flatt-security-inc/llm-framework-vulns-exposed-learnings-from-cves-2j48" class="crayons-story__hidden-navigation-link"&gt;LLM Framework Vulns Exposed: Learnings from CVEs&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/gmo-flatt-security-inc"&gt;
            &lt;img alt="GMO Flatt Security Inc. logo" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F10953%2Ffdfa7b97-a1a7-4c62-8602-aaa2d87024c6.jpg" class="crayons-logo__image"&gt;
          &lt;/a&gt;

          &lt;a href="/gmo-flatt-security" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3238834%2F087fdc45-4dba-4280-8add-413436ed0779.jpg" alt="gmo-flatt-security profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/gmo-flatt-security" class="crayons-story__secondary fw-medium m:hidden"&gt;
              GMO Flatt Security
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                GMO Flatt Security
                
              
              &lt;div id="story-author-preview-content-2558956" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/gmo-flatt-security" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3238834%2F087fdc45-4dba-4280-8add-413436ed0779.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;GMO Flatt Security&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/gmo-flatt-security-inc" class="crayons-story__secondary fw-medium"&gt;GMO Flatt Security Inc.&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/gmo-flatt-security-inc/llm-framework-vulns-exposed-learnings-from-cves-2j48" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 9 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/gmo-flatt-security-inc/llm-framework-vulns-exposed-learnings-from-cves-2j48" id="article-link-2558956"&gt;
          LLM Framework Vulns Exposed: Learnings from CVEs
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/security"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;security&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/development"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;development&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/llm"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;llm&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/gmo-flatt-security-inc/llm-framework-vulns-exposed-learnings-from-cves-2j48" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;6&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/gmo-flatt-security-inc/llm-framework-vulns-exposed-learnings-from-cves-2j48#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            11 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>ai</category>
      <category>security</category>
      <category>development</category>
      <category>llm</category>
    </item>
    <item>
      <title>7 Easy-to-Follow Best Practices for Writing Dockerfile
</title>
      <dc:creator>Takashi Yoneuchi</dc:creator>
      <pubDate>Wed, 13 Oct 2021 15:59:46 +0000</pubDate>
      <link>https://dev.to/y0n3uchy/7-easy-to-follow-best-practices-for-writing-dockerfile-2npa</link>
      <guid>https://dev.to/y0n3uchy/7-easy-to-follow-best-practices-for-writing-dockerfile-2npa</guid>
      <description>&lt;p&gt;Dockerfile allows you to create container images in such a way as if you were writing shell scripts. This simplicity is excellent indeed, but &lt;strong&gt;it does NOT mean that you don't need to learn good practices for writing Dockerfile&lt;/strong&gt;. Just a few practices will make your container images more optimized and secure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This article shows a list of 7 best practices for writing Dockerfile along with some &lt;a href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;Shisho&lt;/a&gt; rules to detect the issues&lt;/strong&gt;. You may not know Shisho, but it's okay because Shisho is extremely easy to use; all you need to do for checking your Dockerfile is just by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://raw.githubusercontent.com/security-aware-repo-examples/dockerfile-best-practice/master/rules/docker.shisho.yaml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker.shisho.yaml &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    docker run &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/workspace ghcr.io/flatt-security/shisho-cli:latest check ./docker.shisho.yaml &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you're a user of GitHub Actions, you can copy &lt;a href="https://github.com/security-aware-repo-examples/dockerfile-best-practice/blob/master/.github/workflows/security.yaml" rel="noopener noreferrer"&gt;this example workflow&lt;/a&gt; and &lt;a href="https://github.com/security-aware-repo-examples/dockerfile-best-practice/blob/master/shisho.yaml" rel="noopener noreferrer"&gt;the rule file&lt;/a&gt; in &lt;a href="https://github.com/security-aware-repo-examples/dockerfile-best-practice" rel="noopener noreferrer"&gt;security-aware-repo-examples/dockerfile-best-practice&lt;/a&gt; to your repository. The workflow checks your repository with the rule, and it reports them to GitHub Code Scanning. The issues will appear at &lt;code&gt;https://github.com/&amp;lt;your org&amp;gt;/&amp;lt;your repository&amp;gt;/security/code-scanning&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv71m9uscc6b492bkfrke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv71m9uscc6b492bkfrke.png" alt="Image description"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;


&lt;h2&gt;
  
  
  ♻️ Three Practices for Maintainability
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Avoid to use &lt;code&gt;latest&lt;/code&gt; tag for immutability
&lt;/h3&gt;

&lt;p&gt;A &lt;code&gt;latest&lt;/code&gt; tag is used to create a docker image whose base is the latest version of another image. The use of &lt;code&gt;latest&lt;/code&gt; tag, however, might cause confusion and inconsistent behaviour among built images. &lt;strong&gt;It is better to pin the version of your base images if possible&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The following Shisho rule will detect the use of &lt;code&gt;latest&lt;/code&gt; tag:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'use-fixed-tag-sfor-immutablity'
    language: dockerfile
    message: |
      The use of `latest` tag might cause confusion and inconsistent behavior in automated builds. It is better to pin the version of your base images.
    patterns: 
      - pattern: FROM :[IMAGE]
      - pattern: FROM :[IMAGE] as :[ALIAS]
      - pattern: FROM :[IMAGE]:latest
      - pattern: FROM :[IMAGE]:latest as :[ALIAS]
      - pattern: FROM :[IMAGE]@:[HASH]
      - pattern: FROM :[IMAGE]@:[HASH] as :[ALIAS]
      - pattern: FROM :[IMAGE]:latest@:[HASH]
      - pattern: FROM :[IMAGE]:latest@:[HASH] as :[ALIAS]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/pCUKzhjNrCdI" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Use an idiomatic way to run &lt;code&gt;apt-get install&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;You may often run &lt;code&gt;apt-get&lt;/code&gt; inside your Dockerfile as follows:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get update
&lt;span class="k"&gt;RUN &lt;/span&gt;apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; nginx &amp;lt;... and some more packages&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;However, the example above has two issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When the cache image for the first &lt;code&gt;RUN&lt;/code&gt; is available, the second &lt;code&gt;apt-get&lt;/code&gt; might install old packages due to not running &lt;code&gt;apt-get update&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Some layers for this image have cache files for &lt;code&gt;apt-get&lt;/code&gt;, resulting in larger image size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simple way to address these issues is running &lt;code&gt;apt-get update&lt;/code&gt; and &lt;code&gt;apt-get install&lt;/code&gt; in a single &lt;code&gt;RUN&lt;/code&gt; instruction.  &lt;strong&gt;The following examples show an idiomatic way to run them once while removing &lt;code&gt;/var/lib/apt/lists/*&lt;/code&gt; (i.e. apt caches) to reduce the image size more&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RUN apt-get update &amp;amp;&amp;amp; \
    apt-get install -y nginx &amp;amp;&amp;amp; \
    rm -rf /var/lib/apt/lists/*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The following Shisho rule will enforce the use of this idiom:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'remove-cache-of-apt-get'
    language: dockerfile
    message: |
      It is better to remove cache files of `apt-get` to keep your image slim.
    pattern: |
      RUN apt-get install :[X]
    rewrite: |
        RUN apt-get update &amp;amp;&amp;amp; \
            apt-get install :[X] &amp;amp;&amp;amp; \
            rm -rf /var/lib/apt/lists/*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/MXSj8P0WnLff" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Use &lt;code&gt;--no-install-recommends&lt;/code&gt; flag of &lt;code&gt;apt-get&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;It is even better to avoid to install any unnecessary tools by &lt;code&gt;--no-install-recommends&lt;/code&gt; of &lt;code&gt;apt-get&lt;/code&gt; command. The following Shisho rule may help the use of this flag:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "1"
rules:
  - id: "use-no-install-recommends-flag-apt-get"
    language: dockerfile
    message: |
      You can avoid to install any unnecessary tools by `--no-install-recommends` on `apt-get`.
    patterns:
      - pattern: |
          RUN apt-get install :[...X]
      - pattern: |
          RUN :[...Y] apt-get install :[...X]
    constraints:
      - target: X
        should: not-match
        regex-pattern: ".*--no-install-recommends.*"
    rewrite_options:
      - |
        RUN :[Y] apt-get install --no-install-recommends :[X]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/61eWV60xJ6S9" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  🛡️ Four Practices for Security
&lt;/h2&gt;

&lt;p&gt;While container technology brings many advantages, such as portability or isolation, it also creates new threats from a security perspective. This section describes common docker security issues and explains how to avoid them.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Avoid to store secrets in environment variables
&lt;/h3&gt;

&lt;p&gt;Hardcoded secrets in your Dockerfile will be stored in resulting images. &lt;strong&gt;You should avoid to embed the secrets.&lt;/strong&gt; You can inject environment variables at run-time instead.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'avoid-to-store-secrets-in-env'
    language: dockerfile
    message: |
      Hardcoded secrets in your Dockerfile will be stored in resulting images. Please consider to stop embedding the secrets. 
    pattern: |
      ENV :[...] :[KEY]=:[VALUE] :[...]
    constraints:
      - target: KEY
        should: match-any-of
        regex-patterns:
          - "[sS][eE][cC][rR][eE][tT]"
          - "[tT][oO][kK][eE][nN]"
          # ... add as you like ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/0CzbZm6GsHjP" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Use trusted base images
&lt;/h3&gt;

&lt;p&gt;A docker image consists of multiple layers, and some of them are usually derived from the base image. Here exists a risk of supply chain attacks! &lt;strong&gt;It is better to use official images to reduce the risk as much as possible&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'use-docker-official-images'
    language: dockerfile
    message: |
      It is better to use official images to reduce the risk of supply chain attacks.
    patterns: 
      - pattern: FROM :[IMAGE]
      - pattern: FROM :[IMAGE] as :[ALIAS]
      - pattern: FROM :[IMAGE]::[TAG]
      - pattern: FROM :[IMAGE]::[TAG] as :[ALIAS]
      - pattern: FROM :[IMAGE]@:[HASH]
      - pattern: FROM :[IMAGE]@:[HASH] as :[ALIAS]
      - pattern: FROM :[IMAGE]::[TAG]@:[HASH]
      - pattern: FROM :[IMAGE]::[TAG]@:[HASH] as :[ALIAS]
    constraints:
      - target: IMAGE
        should: match
        regex-pattern: "/"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/4kK3OmX8WZ7E" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you already have a list of trusted base images, some slight changes will let you use them:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'use-trusted-base-images'
    language: dockerfile
    message: |
      It is better to use trusted base images to reduce the risk of supply chain attacks.
    patterns: 
      - pattern: FROM :[IMAGE]
      - pattern: FROM :[IMAGE] as :[ALIAS]
      - pattern: FROM :[IMAGE]::[TAG]
      - pattern: FROM :[IMAGE]::[TAG] as :[ALIAS]
      - pattern: FROM :[IMAGE]@:[HASH]
      - pattern: FROM :[IMAGE]@:[HASH] as :[ALIAS]
      - pattern: FROM :[IMAGE]::[TAG]@:[HASH]
      - pattern: FROM :[IMAGE]::[TAG]@:[HASH] as :[ALIAS]
    constraints:
      - target: IMAGE
        should: not-match-any-of
        regex-patterns:
            - "^[^/]+$"
            - "^image-name/you-trust$"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/VkWKIes7zyXa" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  6. Avoid to run &lt;code&gt;curl &amp;lt;...&amp;gt; | sh&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Many shell scripts and dockerfiles use &lt;code&gt;curl &amp;lt;...&amp;gt; | sh&lt;/code&gt; as an idiomatic way to run an external script inside computers/containers, but this idiom has a risk of remote code execution by attackers through MITM attacks or compromising the distributed script itself (see &lt;a href="https://about.codecov.io/security-update/" rel="noopener noreferrer"&gt;the report of recent codecov incident&lt;/a&gt;). &lt;strong&gt;It is better to check the integrity of what you download before running it as a shell script.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "1"
rules:
  - id: "check-integrity-of-downloaded-shell-script"
    title: Check the integrity of downloaded shell scripts
    language: dockerfile
    message: |
      It is better to check the integrity of what you download before running it as a shell script.
    pattern: |
      RUN :[CMD]
    constraints:
      - target: CMD
        should: match-any-of
        regex-patterns:
          - curl[^|^&amp;gt;]*[|&amp;gt;]
          - wget[^|^&amp;gt;]*[|&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/pBMNlxgalIOn" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  7. Use &lt;code&gt;COPY&lt;/code&gt; instead of &lt;code&gt;ADD&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ADD&lt;/code&gt; instruction allows us to fetch resources over the network and extract an archive, but it may cause security issues such as Meet-in-the-Middle (MITM) attacks or Zip Slip vulnerabilities. &lt;strong&gt;It is better to use &lt;code&gt;COPY&lt;/code&gt; instead of &lt;code&gt;ADD&lt;/code&gt; if possible.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following Shisho rule detects the use of &lt;code&gt;ADD&lt;/code&gt; instructions:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'use-copy-instead-of-add'
    language: dockerfile
    message: |
      ADD instruction allows us to fetch resources over network and extract an archive, but it may cause security issues such as Meet-in-the-Middle (MITM) attacks or Zip Slip vulnerabilities.
    pattern: ADD :[FROM] :[TO]
    rewrite: COPY :[FROM] :[TO]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://play.shisho.dev/p/9Y9EEnLVKiJr" rel="noopener noreferrer"&gt;(You can see the working example of this rule at Shisho Playground)&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In this article, I presented some best practices for writing Dockerfile and demonstrated how to check your Dockerfile is following the practices continuously by &lt;a href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;Shisho&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You can refer &lt;a href="https://github.com/security-aware-repo-examples/dockerfile-best-practice" rel="noopener noreferrer"&gt;security-aware-repo-examples/dockerfile-best-practice&lt;/a&gt; to see the working example.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/security-aware-repo-examples" rel="noopener noreferrer"&gt;
        security-aware-repo-examples
      &lt;/a&gt; / &lt;a href="https://github.com/security-aware-repo-examples/dockerfile-best-practice" rel="noopener noreferrer"&gt;
        dockerfile-best-practice
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Shisho rules that enforce Dockerfile best practices
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;dockerfile-best-practice&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;This repository shows an example of a GitHub Actions workflow to detect anti-patterns in your Dockerfile. See &lt;a href="https://dev.to/y0n3uchy/7-easy-to-follow-best-practices-for-writing-dockerfile-2npa" rel="nofollow"&gt;"7 Easy-to-Follow Best Practices for Writing Dockerfile"&lt;/a&gt; for further details.&lt;/p&gt;

&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/security-aware-repo-examples/dockerfile-best-practice" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;If you have an interest in Shisho, I would be appreciated if you starred the following repository and gave me feedback at &lt;a href="https://github.com/flatt-security/shisho/discussions" rel="noopener noreferrer"&gt;discussions&lt;/a&gt;!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/flatt-security" rel="noopener noreferrer"&gt;
        flatt-security
      &lt;/a&gt; / &lt;a href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;
        shisho
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Lightweight static analyzer for several programming languages
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;shisho&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/flatt-security/shisho./docs/public/images/header.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fflatt-security%2Fshisho.%2Fdocs%2Fpublic%2Fimages%2Fheader.png" alt="shisho"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/flatt-security/shisho/releases/latest" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/b7834e03a3dfa90476a10cceb0d9f76035dd0bb5e9853c809cbdeb0896944bb6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f666c6174742d73656375726974792f73686973686f2e7376673f6c6f676f3d676974687562" alt="GitHub Release"&gt;&lt;/a&gt;
&lt;a href="https://github.com/marketplace/actions/shisho-action" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/0baa5c4c44645afc59d09f799cbdc1332d0f9af3975e12b0dada7233fd0aa008/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61726b6574706c6163652d73686973686f2d2d616374696f6e2d626c75653f6c6f676f3d676974687562" alt="GitHub Marketplace"&gt;&lt;/a&gt;
&lt;a href="https://github.com/flatt-security/shisho/blob/main/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/2119f1e2cff29e293b56b080172b8dfc9ad38f566eba084b8452b15da6a41cca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f666c6174742d73656375726974792f73686973686f" alt="License"&gt;&lt;/a&gt;
&lt;a href="https://docs.shisho.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f00af82f081e2bd6e8bee1a00aa52d19de5dc9ab2137bdbb02e4089d787f7d11/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d646f63732e73686973686f2e6465762d707572706c65" alt="Documentation"&gt;&lt;/a&gt;
&lt;a href="https://github.com/flatt-security/shisho/actions/workflows/test.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/flatt-security/shisho/actions/workflows/test.yml/badge.svg?branch=main" alt="Test"&gt;&lt;/a&gt;
&lt;a href="https://play.shisho.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/8650bec9e3bc421d4ad70ba19feced3f8d003cc2e47aeab31b69c140caae1837/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c617967726f756e642d706c617967726f756e642e73686973686f2e6465762d707572706c65" alt="Playground"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Shisho is a lightweight static analyzer for developers.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Please see &lt;a href="https://docs.shisho.dev" rel="nofollow noopener noreferrer"&gt;the usage documentation&lt;/a&gt; for further information.&lt;/h3&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/flatt-security/shisho./docs/content/images/shisho-demo.gif"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fflatt-security%2Fshisho.%2Fdocs%2Fcontent%2Fimages%2Fshisho-demo.gif" alt="demo"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Try at Playground&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;You can try Shisho at &lt;a href="https://play.shisho.dev" rel="nofollow noopener noreferrer"&gt;our playground&lt;/a&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Try with Docker&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;You can try shisho in your machine as follows:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c1"&gt;echo&lt;/span&gt; &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;func test(v []string) int { return len(v) + 1; }&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;|&lt;/span&gt; docker run -i ghcr.io/flatt-security/shisho-cli:latest find &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;len(:[...])&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --lang=go&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c1"&gt;echo&lt;/span&gt; &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;func test(v []string) int { return len(v) + 1; }&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;&amp;gt;&lt;/span&gt; file.go
docker run -i -v &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;$(&lt;/span&gt;pwd&lt;span class="pl-pds"&gt;)&lt;/span&gt;&lt;/span&gt;:/workspace ghcr.io/flatt-security/shisho-cli:latest find &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;len(:[...])&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --lang=go /workspace/file.go&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Install with pre-built binaries&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;When you'd like to run shisho outside docker containers, please follow the instructions below:&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Linux / macOS&lt;/h3&gt;

&lt;/div&gt;
&lt;p&gt;Run the following command(s):&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Linux&lt;/span&gt;
wget https://github.com/flatt-security/shisho/releases/latest/download/build-x86_64-unknown-linux-gnu.zip -O shisho.zip
unzip shisho.zip
chmod +x ./shisho
mv ./shisho /usr/local/bin/shisho

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; macOS&lt;/span&gt;
wget https://github.com/flatt-security/shisho/releases/latest/download/build-x86_64-apple-darwin.zip -O shisho.zip
unzip shisho.zip
chmod +x ./shisho
mv ./shisho /usr/local/bin/shisho&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Then you'll see a…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;





&lt;p&gt;NOTE: I'm working on &lt;a href="https://shisho.dev/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=post20211014" rel="noopener noreferrer"&gt;Shisho Cloud&lt;/a&gt;, a web service providing this kind of best practice checks for infrastructure-as-code and automated patch generation for detected issues. It's in a beta stage now and all features are available for free. Please try it!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>security</category>
      <category>codereview</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Build Your Own Lint Rules for Terraform with Shisho</title>
      <dc:creator>Takashi Yoneuchi</dc:creator>
      <pubDate>Mon, 23 Aug 2021 15:44:38 +0000</pubDate>
      <link>https://dev.to/y0n3uchy/build-your-own-lint-rules-for-terraform-with-shisho-5fb7</link>
      <guid>https://dev.to/y0n3uchy/build-your-own-lint-rules-for-terraform-with-shisho-5fb7</guid>
      <description>&lt;p&gt;&lt;strong&gt;tl;dr: Shisho is an open-source static code analyzer that lets you build your own lint rules for Terraform codes. You can find and refactor specific code patterns easily with a handy configuration language.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Linter / Static Analyzer is Too Hard
&lt;/h2&gt;

&lt;p&gt;Every developer wants to avoid embedding issues in their software, while finding issues tends to be boring. So here's where a linter / a static analyzer come: they will be a great supporter of you and your team by detecting common bugs with pre-defined rules &lt;em&gt;before&lt;/em&gt; the bugs are shipped to the world.&lt;/p&gt;

&lt;p&gt;Sometimes, you will want to enforce custom rules for your code to standardize best practices specific to your team. When you want to prevent your team members from using &lt;code&gt;uniform_bucket_level_access = true&lt;/code&gt; in  &lt;code&gt;google_storage_bucket&lt;/code&gt; resources like the following snippet, for example, you hope there's a flexible linter that lets you add custom rules quickly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource "google_storage_bucket" "test" {
  project  = var.project
  name     = "${var.project}-test"
  location = var.location
  uniform_bucket_level_access = true
  force_destroy               = true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;However, &lt;strong&gt;adding and maintaining custom rules is quite hard&lt;/strong&gt;! You need to learn how to write custom rules for &lt;em&gt;each&lt;/em&gt; programming language your team use, although different programming languages have different linters or analyzers, with different DSLs and APIs. This difficulty is one of the severe problems of standard linters / static analyzers. &lt;/p&gt;
&lt;h2&gt;
  
  
  Shisho: A Customizable Static Code Analyzer
&lt;/h2&gt;

&lt;p&gt;Shisho, a lightweight static code analyzer, will help you build custom lint rules for your codebase. I'll explain what and how it is.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/flatt-security" rel="noopener noreferrer"&gt;
        flatt-security
      &lt;/a&gt; / &lt;a href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;
        shisho
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Lightweight static analyzer for several programming languages
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;shisho&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/flatt-security/shisho./docs/public/images/header.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fflatt-security%2Fshisho.%2Fdocs%2Fpublic%2Fimages%2Fheader.png" alt="shisho"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/flatt-security/shisho/releases/latest" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/b7834e03a3dfa90476a10cceb0d9f76035dd0bb5e9853c809cbdeb0896944bb6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f666c6174742d73656375726974792f73686973686f2e7376673f6c6f676f3d676974687562" alt="GitHub Release"&gt;&lt;/a&gt;
&lt;a href="https://github.com/marketplace/actions/shisho-action" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/0baa5c4c44645afc59d09f799cbdc1332d0f9af3975e12b0dada7233fd0aa008/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61726b6574706c6163652d73686973686f2d2d616374696f6e2d626c75653f6c6f676f3d676974687562" alt="GitHub Marketplace"&gt;&lt;/a&gt;
&lt;a href="https://github.com/flatt-security/shisho/blob/main/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/2119f1e2cff29e293b56b080172b8dfc9ad38f566eba084b8452b15da6a41cca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f666c6174742d73656375726974792f73686973686f" alt="License"&gt;&lt;/a&gt;
&lt;a href="https://docs.shisho.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f00af82f081e2bd6e8bee1a00aa52d19de5dc9ab2137bdbb02e4089d787f7d11/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d646f63732e73686973686f2e6465762d707572706c65" alt="Documentation"&gt;&lt;/a&gt;
&lt;a href="https://github.com/flatt-security/shisho/actions/workflows/test.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/flatt-security/shisho/actions/workflows/test.yml/badge.svg?branch=main" alt="Test"&gt;&lt;/a&gt;
&lt;a href="https://play.shisho.dev" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/8650bec9e3bc421d4ad70ba19feced3f8d003cc2e47aeab31b69c140caae1837/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c617967726f756e642d706c617967726f756e642e73686973686f2e6465762d707572706c65" alt="Playground"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Shisho is a lightweight static analyzer for developers.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Please see &lt;a href="https://docs.shisho.dev" rel="nofollow noopener noreferrer"&gt;the usage documentation&lt;/a&gt; for further information.&lt;/h3&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/flatt-security/shisho./docs/content/images/shisho-demo.gif"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fflatt-security%2Fshisho.%2Fdocs%2Fcontent%2Fimages%2Fshisho-demo.gif" alt="demo"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Try at Playground&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;You can try Shisho at &lt;a href="https://play.shisho.dev" rel="nofollow noopener noreferrer"&gt;our playground&lt;/a&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Try with Docker&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;You can try shisho in your machine as follows:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c1"&gt;echo&lt;/span&gt; &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;func test(v []string) int { return len(v) + 1; }&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;|&lt;/span&gt; docker run -i ghcr.io/flatt-security/shisho-cli:latest find &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;len(:[...])&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --lang=go&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c1"&gt;echo&lt;/span&gt; &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;func test(v []string) int { return len(v) + 1; }&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; &lt;span class="pl-k"&gt;&amp;gt;&lt;/span&gt; file.go
docker run -i -v &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;$(&lt;/span&gt;pwd&lt;span class="pl-pds"&gt;)&lt;/span&gt;&lt;/span&gt;:/workspace ghcr.io/flatt-security/shisho-cli:latest find &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;len(:[...])&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt; --lang=go /workspace/file.go&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Install with pre-built binaries&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;When you'd like to run shisho outside docker containers, please follow the instructions below:&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Linux / macOS&lt;/h3&gt;

&lt;/div&gt;
&lt;p&gt;Run the following command(s):&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Linux&lt;/span&gt;
wget https://github.com/flatt-security/shisho/releases/latest/download/build-x86_64-unknown-linux-gnu.zip -O shisho.zip
unzip shisho.zip
chmod +x ./shisho
mv ./shisho /usr/local/bin/shisho

&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; macOS&lt;/span&gt;
wget https://github.com/flatt-security/shisho/releases/latest/download/build-x86_64-apple-darwin.zip -O shisho.zip
unzip shisho.zip
chmod +x ./shisho
mv ./shisho /usr/local/bin/shisho&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Then you'll see a…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  Find Codes
&lt;/h3&gt;

&lt;p&gt;First of all, Shisho enables us to run AST-aware code search over your code. Here's an example command which finds the occurence of &lt;code&gt;uniform_bucket_level_access = true&lt;/code&gt; inside &lt;code&gt;google_storage_bucket&lt;/code&gt; resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -i -v $(pwd):/workspace ghcr.io/flatt-security/shisho-cli:latest find "
resource \"google_storage_bucket\" :[_] {
  :[...]
  uniform_bucket_level_access = true
  :[...]
}
" --lang hcl ./code.tf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command will make the following outputs in your console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbgpx0xaqkxejfqzmlghj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbgpx0xaqkxejfqzmlghj.png" alt="nYvlJB6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here &lt;code&gt;:[_]&lt;/code&gt; is an &lt;strong&gt;anonymous metavariable&lt;/strong&gt;, which matches an arbitrary single node in AST (like a function call, identifier, and so on). Similarly, &lt;code&gt;:[...]&lt;/code&gt; is an &lt;strong&gt;anonymous ellipsis metavariable&lt;/strong&gt;, which matches zero or more nodes in AST. These operators are something like capture groups in regular expressions. They let you search over your code in a structured but flexible manner.&lt;/p&gt;

&lt;p&gt;You can also define a &lt;em&gt;rule&lt;/em&gt;, which includes a pattern and the explaination for it. The following YAML snippet is an example of rules describing the use of &lt;code&gt;uniform_bucket_level_access&lt;/code&gt; is prohibited:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "1"
rules:
  - id: sample-policy
    language: hcl
    pattern: |
      resource "google_storage_bucket" :[_] {
        :[...X]
        uniform_bucket_level_access = true
        :[...Y]
      }
    message: |
      Our team policy prohibits the use of uniform bucket-level access.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find patterns by executing &lt;code&gt;shisho find path/to/rule.yaml path/to/search&lt;/code&gt; command, resulting in the following outputs:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvque1zjoxh4rd8cv8pmb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvque1zjoxh4rd8cv8pmb.png" alt="Screenshot from 2021-08-23 19-08-44"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This is how Shisho makes it possible to build your own lint rules for Terraform codes. You can use Shisho in the CI pipeline with your own rules, let alone your local machine. Please see &lt;a href="https://docs.shisho.dev/learn-shisho/03-constraint" rel="noopener noreferrer"&gt;Learn Shisho&lt;/a&gt; for further details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Refactor Codes
&lt;/h3&gt;

&lt;p&gt;Additionally, Shisho rules can include how detected code patterns should be fixed. The following YAML snippet describes a custom lint rule that suggests the use of &lt;code&gt;uniform_bucket_level_access = true&lt;/code&gt; should be deleted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "1"
rules:
  - id: sample-policy
    language: hcl
    pattern: |
      resource "google_storage_bucket" :[NAME] {
        :[...X]
        uniform_bucket_level_access = true
        :[...Y]
      }
    message: |
      Our team policy prohibits use of uniform bucket-level access.
    rewrite: |
      resource "google_storage_bucket" :[NAME] {
        :[X]
        :[Y]
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this rule is run over your codes and the use of &lt;code&gt;uniform_bucket_level_access = true&lt;/code&gt; is detected, Shisho suggests changes following the rule's &lt;code&gt;rewrite&lt;/code&gt; section like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fnmb3zlkc84hup3977q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fnmb3zlkc84hup3977q.png" alt="Screenshot from 2021-08-23 19-07-30"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Usecases
&lt;/h2&gt;

&lt;p&gt;You can use Shisho &lt;strong&gt;for standardizing your codebase&lt;/strong&gt;. In addition, it could be a means of conducting &lt;strong&gt;"security-as-code"&lt;/strong&gt; or &lt;strong&gt;"policy-as-code"&lt;/strong&gt;! &lt;/p&gt;

&lt;p&gt;For instance, when you want to keep your team's &lt;a href="https://aws.amazon.com/ebs/" rel="noopener noreferrer"&gt;EBS volumes&lt;/a&gt; encrypted, you can define a rule as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1'
rules:
  - id: 'unencrypted-ebs-volume'
    language: hcl
    message: |
      There was unencrypted EBS module.
    pattern: |
      resource  "aws_ebs_volume" :[NAME] {
        :[...X]
      }
    constraints:
      - target: X
        should: not-match
        pattern: |
          encrypted = true
    rewrite: |
      resource "aws_ebs_volume" :[NAME] {
        :[X]
        encrypted = true
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you want your colleagues to follow the naming convention for resources, the following rule will work well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "1"
rules:
  - id: "invalid-resource-name"
    language: hcl
    message: |
      A resource was named badly.
    pattern: |
      resource  :[_] :[NAME] {
        :[...]
      }
    constraints:
      - target: NAME
        should: not-match-regex
        pattern: '"team1-.*"'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule will report the result like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftbrr64fr1piubmwz6ty4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftbrr64fr1piubmwz6ty4.png" alt="Screenshot from 2021-08-24 00-34-46"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Why Shisho?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://devd.me/log/posts/static-analysis/" rel="noopener noreferrer"&gt;"Modern Static Analysis: how the best tools empower creativity"&lt;/a&gt; explains that good code analyzers or linters are often &lt;em&gt;interoperable, moldable, efficient, and community-driven&lt;/em&gt; and that &lt;a href="https://semgrep.dev/" rel="noopener noreferrer"&gt;Semgrep&lt;/a&gt; works well from these viewpoints. Semgrep is also grep-like (or sed-like) software that lets us find bugs with useful DSLs. &lt;/p&gt;

&lt;p&gt;As for Shisho, it is at least interoperable (since it's open-sourced), moldable (though some efforts are needed; see issue &lt;a href="https://github.com/flatt-security/shisho/issues/7" rel="noopener noreferrer"&gt;#7&lt;/a&gt;). Moreover, &lt;strong&gt;Shisho is surprisingly efficient&lt;/strong&gt;! Here's the result of a micro-benchmark of &lt;a href="https://semgrep.dev/" rel="noopener noreferrer"&gt;Semgrep&lt;/a&gt;, &lt;a href="https://comby.dev/" rel="noopener noreferrer"&gt;Comby&lt;/a&gt; (a similar tool), and Shisho&lt;sup id="fnref1"&gt;1&lt;/sup&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Comby (1.7.0)&lt;/td&gt;
&lt;td&gt;263.1 ms&lt;/td&gt;
&lt;td&gt;&lt;code&gt;time comby 'len(...)' '' parser.go -match-only &amp;amp;&amp;gt; /dev/null&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Semgrep (0.62.0)&lt;/td&gt;
&lt;td&gt;530.0ms&lt;/td&gt;
&lt;td&gt;&lt;code&gt;time semgrep -e 'len(...)' --lang=go parser.go &amp;amp;&amp;gt; /dev/null&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Shisho (0.1.2-alpha.2)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;22.8ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;time shisho find 'len(:[...])' --lang=go parser.go &amp;amp;&amp;gt; /dev/null&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In fact, Shisho aims to refine the existing tools and to make it more feasible to run for large projects. You can use Shisho for your monorepo without hesitation. For your information, this speed is supported by &lt;a href="https://rust-lang.org" rel="noopener noreferrer"&gt;Rust&lt;/a&gt; &lt;sup id="fnref2"&gt;2&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;On the other hand, it's true that Shisho lacks some features of Semgrep and Comby. For instance, Semgrep has &lt;a href="https://semgrep.dev/docs/writing-rules/pattern-syntax/#typed-metavariables" rel="noopener noreferrer"&gt;a feature to match patterns with type information&lt;/a&gt; while Shisho doesn't. Semgrep also has &lt;a href="https://semgrep.dev/explore" rel="noopener noreferrer"&gt;Semgrep Registry&lt;/a&gt;, in which you can share your own lint rules for the worldwide community. Now I'm making efforts to design and implement these features. Stay tuned!&lt;/p&gt;

&lt;h2&gt;
  
  
  Now What?
&lt;/h2&gt;

&lt;p&gt;This article explained the usage of Shisho for Terraform codes, but Shisho is extending other language supports! Especially Dockerfile support will be shipped soon. You can follow &lt;a href="https://twitter.com/y0n3uchy" rel="noopener noreferrer"&gt;@y0n3uchy&lt;/a&gt; to see the news on Shisho and star &lt;a href="https://github.com/flatt-security/shisho" rel="noopener noreferrer"&gt;our GitHub project&lt;/a&gt; to encourage us :-)&lt;/p&gt;

&lt;p&gt;Additionally, I'll release a SaaS which supports your Terraform development workflows with this engine. See &lt;a href="https://shisho.dev/?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=post20210824" rel="noopener noreferrer"&gt;https://shisho.dev/&lt;/a&gt; for further details.&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;Time is the average of 20 consecutive command executions. The measurement was run on Ubuntu 20.04.2 LTS with AMD Ryzen 5 3600 / 64GB RAM. The scan target was &lt;a href="https://sourcegraph.com/github.com/golang/go@5a267c840ae16c1cc7352caa14da5f500d03d338/-/blob/src/go/parser/parser.go" rel="noopener noreferrer"&gt;parser.go&lt;/a&gt;. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;Both Semgrep and Comby is written in OCaml. ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>terraform</category>
      <category>security</category>
      <category>devops</category>
      <category>codequality</category>
    </item>
  </channel>
</rss>
