Skip to content
KitploitKITPLOIT
FerramentasBlog
Enviar
FerramentasBlog
Enviar

Ferramentas de Hacking, PenTest e Cibersegurança para o seu Arsenal de Segurança!

Kitploit é um diretório de ferramentas de hacking, cibersegurança e pentesting. Descubra as últimas atualizações de projetos para encontrar vulnerabilidades, analisar sistemas, automatizar testes e fortalecer sua segurança.

··Feeds·Contato·Privacidade·© 2026 Kitploit

Diretório de Ferramentas

Categorias

Ver todas as categorias
Loading categories
dockle — Linter de Imagens de Contêiner para Segurança, Ajudando a construir a Imagem Docker de Melhores Práticas, Fácil de começar | Kitploit
Ferramentas/GitHubGitHub/goodwithtech/dockle
Scanners de VulnerabilidadesSegurança de ContêineresAuditoria de ConfiguraçãoDevSecOps
GitHubgoodwithtech/dockle

dockle

Linter de Imagens de Contêiner para Segurança, Ajudando a construir a Imagem Docker de Melhores Práticas, Fácil de começar

Ver Repositório
3.3k166há 1 mêsRevisado pelo Kitploit

Mais Populares

Ver todos →

Descubra as ferramentas mais usadas pela nossa comunidade.

Explore todas as ferramentas

Navegue pela nossa coleção de ferramentas

Ver todas as ferramentas →
Compartilhar
Site

Financial Contributors on Open Collective GitHub release CircleCI Go Report Card License: AGPL v3

Dockle - Linter de Imagens de Contêiner para Segurança, Ajudando a Construir a Melhor Prática de Imagem Docker, Fácil de Iniciar

Dockle ajuda você a:

  1. Construir imagens Docker de Melhor Prática
  2. Construir imagens Docker seguras
    • Checkpoints incluem CIS Benchmarks```bash $ brew untap goodwithtech/dockle # who use 0.1.16 or older version $ brew install goodwithtech/r/dockle $ dockle [YOUR_IMAGE_NAME]
root@kitploit:~
Veja [Instalação](#installation) e [Exemplos Comuns](#common-examples)

<img src="https://assets.kitploit.com/production/public/readmes/4137/343598bd4d53296c6d6d23acde8c2917d5727f03e7b3a34c1ff0865c435bb974.png" width="800">

# Comparação de Checkpoints

<img src="https://assets.kitploit.com/production/public/readmes/4137/4f4835c3a5fd70f436d9d8ea656fd8a521112fece4e35977288064d3f6f4510a.png" width="800">
<img src="https://assets.kitploit.com/production/public/readmes/4137/7bee9da0b061957af6a175a3b975dca82813c27f72ab6921dfe8ab2d6747322b.png" width="800">

# Índice

- [Características](#features)
- [Comparação](#comparison)
- [Instalação](#installation)
  - [Homebrew (Mac OS X / Linux e WSL)](#homebrew-mac-os-x--linux-and-wsl)
  - [RHEL/CentOS](#rhelcentos)
  - [Debian/Ubuntu](#debianubuntu)
  - [Arch Linux](#arch-linux)
  - [Windows](#windows)
  - [Microsoft PowerShell 7](#microsoft-powershell-7)
  - [Binário](#binary)
  - [asdf](#asdf)
  - [mise](#mise)
  - [A partir do código fonte](#from-source)
  - [Usar Docker](#use-docker)
- [Início Rápido](#quick-start)
  - [Básico](#basic)
  - [Docker](#docker)
- [Resumo de Checkpoints](#checkpoint-summary)
- [Exemplos Comuns](#common-examples)
  - [Escaneie uma imagem](#scan-an-image)
  - [Escaneie um arquivo de imagem](#scan-an-image-file)
  - [Obter ou salvar os resultados como JSON](#get-or-save-the-results-as-json)
  - [Obter ou salvar os resultados como SARIF](#get-or-save-the-results-as-sarif)
  - [Especificar código de saída](#specify-exit-code)
  - [Especificar nível de saída](#specify-exit-level)
  - [Ignorar os checkpoints especificados](#ignore-the-specified-checkpoints)
  - [Aceitar `variáveis de ambiente` / `arquivos` / `extensões de arquivo` suspeitas](#accept-suspicious-environment-variables--files--file-extensions)
  - [Rejeitar `variáveis de ambiente` / `arquivos` / `extensões de arquivo` suspeitas](#reject-suspicious-environment-variables--files--file-extensions)
- [Integração Contínua](#continuous-integration-ci)
  - [GitHub Action](#github-action)
  - [Travis CI](#travis-ci)
  - [CircleCI](#circleci)
  - [GitLab CI](#gitlab-ci)
  - [Autorização para Registro Privado Docker](#authorization-for-private-docker-registry)
    - [Docker Hub](#docker-hub)
    - [Amazon ECR (Elastic Container Registry)](#amazon-ecr-elastic-container-registry)
    - [GCR (Google Container Registry)](#gcr-google-container-registry)
    - [Registro Autogerenciado (BasicAuth)](#self-hosted-registry-basicauth)
- [Contribuidores](#contributors)
  - [Contribuidores de Código](#code-contributors)
  - [Contribuidores Financeiros](#financial-contributors)
    - [Indivíduos](#individuals)
    - [Organizações](#organizations)
- [Licença](#license)
- [Autor](#author)

# Características

- Detecta vulnerabilidades do contêiner
- Ajuda na construção de Dockerfiles de melhores práticas
- Uso simples
  - Especifique apenas o nome da imagem
  - Veja [Início Rápido](#quick-start) e [Exemplos Comuns](#common-examples)
- Suporte a CIS Benchmarks
  - Alta precisão
- DevSecOps
  - Adequado para CI como Travis CI, CircleCI, Jenkins, etc.
  - Veja [Exemplo de CI](#continuous-integration-ci)

# Comparação

|  | [Dockle](https://github.com/goodwithtech/dockle) | [Hadolint](https://github.com/hadolint/hadolint) | [Docker Bench for Security](https://github.com/docker/docker-bench-security) | [Clair](https://github.com/coreos/clair) |
|--- |---:|---:|---:|---:|
| Alvo |  Imagem | Dockerfile | Anfitrião<br/>Docker Daemon<br/>Imagem<br/>Runtime do Contêiner | Imagem |
| Como executar | Binário | Binário | ShellScript | Binário |
| Dependência | Não | Não | Algumas dependências | Não |
| Adequado para CI | ✓ | ✓ | x | x | 
| Propósito | Auditoria de Segurança<br/>Lint de Dockerfile | Lint de Dockerfile | Auditoria de Segurança<br/>Lint de Dockerfile | Escanear Vulnerabilidades |

# Instalação

## Homebrew (Mac OS X / Linux e WSL)

Você pode usar Homebrew no [Mac OS X](https://brew.sh/) ou [Linux e WSL (Subsistema Windows para Linux)](https://docs.brew.sh/Homebrew-on-Linux).```bash
$ brew install goodwithtech/r/dockle

RHEL/CentOS```bash

VERSION=$( curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" |
grep '"tag_name":' |
sed -E 's/."v([^"]+)"./\1/'
) && rpm -ivh https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.rpm

root@kitploit:~
## Debian/Ubuntu```bash
VERSION=$(
 curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
 grep '"tag_name":' | \
 sed -E 's/.*"v([^"]+)".*/\1/' \
) && curl -L -o dockle.deb https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.deb
$ sudo dpkg -i dockle.deb && rm dockle.deb

Arch Linux

O dockle pode ser instalado a partir do Arch User Repository utilizando o pacote dockle ou dockle-bin.``` git clone https://aur.archlinux.org/dockle-bin.git cd dockle-bin makepkg -sri

root@kitploit:~
## Windows```bash
VERSION=$(
 curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
 grep '"tag_name":' | \
 sed -E 's/.*"v([^"]+)".*/\1/' \
) && curl -L -o dockle.zip https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Windows-64bit.zip
$ unzip dockle.zip && rm dockle.zip
$ ./dockle.exe [IMAGE_NAME]

Microsoft PowerShell 7```bash

if (((Invoke-WebRequest "https://api.github.com/repos/goodwithtech/dockle/releases/latest").Content) -match '"tag_name":"v(?[^"]+)"') { $VERSION=$Matches.ver && Invoke-WebRequest "https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Windows-64bit.zip" -OutFile dockle.zip && Expand-Archive dockle.zip && Remove-Item dockle.zip }

root@kitploit:~
## Binário

Você pode obter o binário da versão mais recente na [página de releases](https://github.com/goodwithtech/dockle/releases/latest).

Baixe o arquivo compactado para seu sistema operacional/arquitetura. Descompacte o arquivo e coloque o binário em algum lugar no seu `$PATH` (em sistemas UNIX, `/usr/local/bin` ou similar).

- NOTA: Certifique-se de que as permissões de execução estão ativadas. (`chmod +x dockle`)

## asdf

Você pode instalar o dockle com o [asdf version manager](https://asdf-vm.com/) usando este [plugin](https://github.com/mathew-fleisch/asdf-dockle), que automatiza o processo de instalação (e alternância) de várias versões dos binários de release do GitHub. Com o asdf já instalado, execute estes comandos para instalar o dockle:```bash
# Add dockle plugin
asdf plugin add dockle

# Show all installable versions
asdf list-all dockle

# Install specific version
asdf install dockle latest

# Set a version globally (on your ~/.tool-versions file)
asdf global dockle latest

# Now dockle commands are available
dockle --version

mise

Pode instalar o dockle com mise, o gestor de versões de ferramentas poliglota. Com o mise já instalado, execute estes comandos para instalar o dockle:```bash

Show all installable versions

mise ls-remote dockle

Install specific version

mise install dockle@latest

Set a version globally

mise use -g dockle@latest

Now dockle commands are available

dockle --version

root@kitploit:~
## A partir do código-fonte```bash
$ GO111MODULE=off go get github.com/goodwithtech/dockle/cmd/dockle
$ cd $GOPATH/src/github.com/goodwithtech/dockle && GO111MODULE=on go build -o $GOPATH/bin/dockle cmd/dockle/main.go

Usar Docker

Existe também uma Dockle imagem no Docker Hub. Você pode experimentar dockle antes de instalar o comando.``` $ VERSION=$( curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" |
grep '"tag_name":' |
sed -E 's/."v([^"]+)"./\1/'
) && docker run --rm -v /var/run/docker.sock:/var/run/docker.sock
goodwithtech/dockle:v${VERSION} [YOUR_IMAGE_NAME]

root@kitploit:~
Você só precisa de `-v /var/run/docker.sock:/var/run/docker.sock` quando quiser escanear a imagem em sua máquina host.

# Início Rápido

## Básico

Simplesmente especifique um nome de imagem (e uma tag).```bash
$ dockle [YOUR_IMAGE_NAME]
Resultado``` FATAL - CIS-DI-0009: Use COPY instead of ADD in Dockerfile * Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json FATAL - CIS-DI-0010: Do not store credential in ENVIRONMENT vars/files * Suspicious filename found : app/credentials.json FATAL - DKL-DI-0005: Clear apt-get caches * Use 'rm -rf /var/lib/apt/lists' after 'apt-get install' : /bin/sh -c apt-get update && apt-get install -y git FATAL - DKL-LI-0001: Avoid empty password * No password user found! username : nopasswd WARN - CIS-DI-0001: Create a user for the container * Last user should not be root INFO - CIS-DI-0005: Enable Content trust for Docker * export DOCKER_CONTENT_TRUST=1 before docker pull/build INFO - CIS-DI-0008: Confirm safety of setuid/setgid files * setuid file: app/suid.txt urw-r--r-- * setgid file: app/gid.txt grw-r--r-- * setuid file: usr/bin/gpasswd urwxr-xr-x * setgid file: usr/bin/wall grwxr-xr-x * setuid file: bin/su urwxr-xr-x * setuid file: bin/umount urwxr-xr-x * setuid file: bin/mount urwxr-xr-x * setgid file: usr/bin/ssh-agent grwxr-xr-x * setuid file: etc/shadow urw-r----- * setuid file: usr/bin/chsh urwxr-xr-x * setuid file: usr/bin/chfn urwxr-xr-x * setuid file: usr/lib/openssh/ssh-keysign urwxr-xr-x * setgid file: etc/passwd grw-r--r-- * setgid file: sbin/unix_chkpwd grwxr-xr-x * setgid file: usr/bin/chage grwxr-xr-x * setuid file: usr/bin/passwd urwxr-xr-x * setgid file: usr/bin/expiry grwxr-xr-x * setuid file: usr/bin/newgrp urwxr-xr-x IGNORE - CIS-DI-0006: Add HEALTHCHECK instruction to the container image
root@kitploit:~
</details>

## Docker

Além disso, você pode usar o Docker para usar o comando `dockle` da seguinte forma.```bash
$ export DOCKLE_LATEST=$(
 curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
 grep '"tag_name":' | \
 sed -E 's/.*"v([^"]+)".*/\1/' \
)
$ docker run --rm goodwithtech/dockle:v${DOCKLE_LATEST} [YOUR_IMAGE_NAME]
  • Se você quiser escanear a imagem em sua máquina host, você precisa montar docker.sock.

    root@kitploit:~
    $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ...
    

Digitalizar um ficheiro de imagem```bash

$ docker save alpine:latest -o alpine.tar $ dockle --input alpine.tar

root@kitploit:~
### Obter ou Salvar os resultados como JSON```bash
$ dockle -f json goodwithtech/test-image:v1
$ dockle -f json -o results.json goodwithtech/test-image:v1
Resultado```json { "summary": { "fatal": 6, "warn": 2, "info": 2, "pass": 7 }, "details": [ { "code": "CIS-DI-0001", "title": "Create a user for the container", "level": "WARN", "alerts": [ "Last user should not be root" ] }, { "code": "CIS-DI-0005", "title": "Enable Content trust for Docker", "level": "INFO", "alerts": [ "export DOCKER_CONTENT_TRUST=1 before docker pull/build" ] }, { "code": "CIS-DI-0006", "title": "Add HEALTHCHECK instruction to the container image", "level": "WARN", "alerts": [ "not found HEALTHCHECK statement" ] }, { "code": "CIS-DI-0008", "title": "Remove setuid and setgid permissions in the images", "level": "INFO", "alerts": [ "Found setuid file: usr/lib/openssh/ssh-keysign urwxr-xr-x" ] }, { "code": "CIS-DI-0009", "title": "Use COPY instead of ADD in Dockerfile", "level": "FATAL", "alerts": [ "Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json " ] }, { "code": "CIS-DI-0010", "title": "Do not store secrets in ENVIRONMENT variables", "level": "FATAL", "alerts": [ "Suspicious ENV key found : MYSQL_PASSWD" ] }, { "code": "CIS-DI-0010", "title": "Do not store secret files", "level": "FATAL", "alerts": [ "Suspicious filename found : app/credentials.json " ] }, { "code": "DKL-DI-0002", "title": "Avoid sensitive directory mounting", "level": "FATAL", "alerts": [ "Avoid mounting sensitive dirs : /usr" ] }, { "code": "DKL-DI-0005", "title": "Clear apt-get caches", "level": "FATAL", "alerts": [ "Use 'rm -rf /var/lib/apt/lists' after 'apt-get install' : /bin/sh -c apt-get update \u0026\u0026 apt-get install -y git" ] }, { "code": "DKL-LI-0001", "title": "Avoid empty password", "level": "FATAL", "alerts": [ "No password user found! username : nopasswd" ] } ] } ```

Obter ou Salvar os resultados como SARIF```bash

$ dockle -f sarif goodwithtech/test-image:v1 $ dockle -f sarif -o results.json goodwithtech/test-image:v1

root@kitploit:~
<details>
<summary>Resultado</summary>```json
{
  "version": "2.1.0",
  "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Dockle",
          "informationUri": "https://github.com/goodwithtech/dockle",
          "rules": [
            {
              "id": "CIS-DI-0009",
              "shortDescription": {
                "text": "Use COPY instead of ADD in Dockerfile"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0009"
              }
            },
            {
              "id": "CIS-DI-0010",
              "shortDescription": {
                "text": "Do not store credential in ENVIRONMENT vars/files"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0010"
              }
            },
            {
              "id": "DKL-DI-0005",
              "shortDescription": {
                "text": "Clear apt-get caches"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#DKL-DI-0005"
              }
            },
            {
              "id": "DKL-LI-0001",
              "shortDescription": {
                "text": "Avoid empty password"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#DKL-LI-0001"
              }
            },
            {
              "id": "CIS-DI-0005",
              "shortDescription": {
                "text": "Enable Content trust for Docker"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0005"
              }
            },
            {
              "id": "CIS-DI-0008",
              "shortDescription": {
                "text": "Confirm safety of setuid/setgid files"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0008"
              }
            },
            {
              "id": "CIS-DI-0001",
              "shortDescription": {
                "text": "Create a user for the container"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0001"
              }
            },
            {
              "id": "CIS-DI-0006",
              "shortDescription": {
                "text": "Add HEALTHCHECK instruction to the container image"
              },
              "help": {
                "text": "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#CIS-DI-0006"
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "CIS-DI-0009",
          "level": "error",
          "message": {
            "text": "Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json "
          }
        },
        {
          "ruleId": "CIS-DI-0010",
          "level": "error",
          "message": {
            "text": "Suspicious filename found : app/credentials.json , Suspicious ENV key found : MYSQL_PASSWD"
          }
        },
        {
          "ruleId": "DKL-DI-0005",
          "level": "error",
          "message": {
            "text": "Use 'rm -rf /var/lib/apt/lists' after 'apt-get install' : /bin/sh -c apt-get update \u0026\u0026 apt-get install -y git"
          }
        },
        {
          "ruleId": "DKL-LI-0001",
          "level": "error",
          "message": {
            "text": "No password user found! username : nopasswd"
          }
        },
        {
          "ruleId": "CIS-DI-0005",
          "level": "note",
          "message": {
            "text": "export DOCKER_CONTENT_TRUST=1 before docker pull/build"
          }
        },
        {
          "ruleId": "CIS-DI-0008",
          "level": "note",
          "message": {
            "text": "setuid file: urwxr-xr-x usr/bin/newgrp, setgid file: grwxr-xr-x usr/bin/ssh-agent, setgid file: grwxr-xr-x usr/bin/expiry, setuid file: urwxr-xr-x usr/lib/openssh/ssh-keysign, setuid file: urwxr-xr-x bin/umount, setgid file: grwxr-xr-x usr/bin/chage, setuid file: urwxr-xr-x usr/bin/passwd, setgid file: grwxr-xr-x sbin/unix_chkpwd, setuid file: urwxr-xr-x usr/bin/chsh, setgid file: grwxr-xr-x usr/bin/wall, setuid file: urwxr-xr-x bin/ping, setuid file: urwxr-xr-x bin/su, setuid file: urwxr-xr-x usr/bin/chfn, setuid file: urwxr-xr-x usr/bin/gpasswd, setuid file: urwxr-xr-x bin/mount"
          }
        },
        {
          "ruleId": "CIS-DI-0001",
          "level": "none",
          "message": {
            "text": "Last user should not be root"
          }
        },
        {
          "ruleId": "CIS-DI-0006",
          "level": "none",
          "message": {
            "text": "not found HEALTHCHECK statement"
          }
        }
      ]
    }
  ]
}

Especificar código de saída

Por padrão, o Dockle sai com o código 0 mesmo se houver alguns problemas.

Use a opção --exit-code, -c para sair com um código de saída diferente de zero se um alerta WARN ou FATAL for encontrado.```bash $ dockle --exit-code 1 [IMAGE_NAME]

root@kitploit:~
### Especificar nível de saída

Por padrão, `--exit-code` é executado quando há alertas de nível `WARN` ou `FATAL`.

Use a opção `--exit-level, -l` para alterar o nível de alerta. Você pode definir `info`, `warn` ou `fatal`.```bash
$ dockle --exit-code 1 --exit-level info [IMAGE_NAME]
$ dockle --exit-code 1 --exit-level fatal [IMAGE_NAME]

Ignore os checkpoints especificados

A opção --ignore, -i pode ignorar os checkpoints especificados.```bash $ dockle -i CIS-DI-0001 -i DKL-DI-0006 [IMAGE_NAME]

root@kitploit:~
Ou, use `DOCKLE_IGNORES`:```
export DOCKLE_IGNORES=CIS-DI-0001,DKL-DI-0006
dockle [IMAGE_NAME]

Ou, use o arquivo .dockleignore:```bash $ cat .dockleignore

set root to default user because we want to run nginx

CIS-DI-0001

Use latest tag because to check the image inside only

DKL-DI-0006

root@kitploit:~
### Aceitar suspeitos `environment variables` / `files` / `file extensions````bash
# --accept-key value, --ak value             You can add acceptable keywords.
dockle -ak GPG_KEY -ak KEYCLOAK_VERSION [IMAGE_NAME]
or DOCKLE_ACCEPT_KEYS=GPG_KEY,KEYCLOAK_VERSION dockle [IMAGE_NAME]

# --accept-file value, --af value            You can add acceptable file names.
dockle -af id_rsa -af id_dsa [IMAGE_NAME]
or DOCKLE_ACCEPT_FILES=id_rsa,id_dsa dockle [IMAGE_NAME]

# --accept-file-extension value, --ae value  You can add acceptable file extensions.
dockle -ae pem -ae log [IMAGE_NAME]
or DOCKLE_ACCEPT_FILE_EXTENSIONS=pem,log dockle [IMAGE_NAME]

Rejeitar environment variables / files / file extensions suspeitos```bash

--sensitive-word value, --sw value You can add acceptable keywords.

dockle -sw PRIVATE [IMAGE_NAME] or DOCKLE_ACCEPT_KEYS=GPG_KEY,KEYCLOAK_VERSION dockle [IMAGE_NAME]

--sensitive-file value, --sf value You can add acceptable file names.

dockle -sf .env [IMAGE_NAME] or DOCKLE_REJECT_FILES=.env dockle [IMAGE_NAME]

--sensitive-file-extension value, --se value You can add acceptable file extensions.

dockle -se pfx [IMAGE_NAME] or DOCKLE_REJECT_FILE_EXTENSIONS=pfx dockle [IMAGE_NAME]

root@kitploit:~
## Integração Contínua (CI)

Você pode escanear sua imagem construída com `Dockle` no Travis CI/CircleCI.

Nestes exemplos, o teste falhará se algum aviso for encontrado.

No entanto, você pode ignorar os checkpoints alvo especificados usando o arquivo `.dockleignore`.

Ou, se você apenas deseja que os resultados sejam exibidos e não deixar o teste falhar por isso, especifique `--exit-code` como `0` no comando `dockle`.

### GitHub Action

Fornecemos o [goodwithtech/dockle-action](https://github.com/goodwithtech/dockle-action).```yaml
- uses: goodwithtech/dockle-action@main
  with:
    image: 'target'
    format: 'list'
    exit-code: '1'
    exit-level: 'warn'
    ignore: 'CIS-DI-0001,DKL-DI-0006'

Travis CI

.travis.yml```yaml services: - docker

env: global: - COMMIT=${TRAVIS_COMMIT::8}

before_install:

  • docker build -t dockle-ci-test:${COMMIT} .
  • export VERSION=$(curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | grep '"tag_name":' | sed -E 's/."v([^"]+)"./\1/')
  • wget https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.tar.gz
  • tar zxvf dockle_${VERSION}_Linux-64bit.tar.gz script:
  • ./dockle dockle-ci-test:${COMMIT}
  • ./dockle --exit-code 1 dockle-ci-test:${COMMIT}
root@kitploit:~
</details>

- Exemplo: https://travis-ci.org/goodwithtech/dockle-ci-test
- Repositório: https://github.com/goodwithtech/dockle-ci-test

### CircleCI

<details>
<summary>.circleci/config.yml</summary>```yaml
jobs:
  build:
    docker:
      - image: docker:18.09-git
    steps:
      - checkout
      - setup_remote_docker
      - run:
          name: Build image
          command: docker build -t dockle-ci-test:${CIRCLE_SHA1} .
      - run:
          name: Install dockle
          command: |
            apk add --update curl
            VERSION=$(
                curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" | \
                grep '"tag_name":' | \
                sed -E 's/.*"v([^"]+)".*/\1/'
            )
            wget https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.tar.gz
            tar zxvf dockle_${VERSION}_Linux-64bit.tar.gz
            mv dockle /usr/local/bin
      - run:
          name: Scan the local image with dockle
          command: dockle --exit-code 1 dockle-ci-test:${CIRCLE_SHA1}
workflows:
  version: 2
  release:
    jobs:
      - build
  • Exemplo: https://circleci.com/gh/goodwithtech/dockle-ci-test
  • Repositório: https://github.com/goodwithtech/dockle-ci-test

GitLab CI

.gitlab-ci.yml```yaml image: docker:stable stages: - test

variables: DOCKER_HOST: tcp://docker:2375/ DOCKER_DRIVER: overlay2 services:

  • docker:dind

unit_test: stage: test before_script: - apk -Uuv add bash git curl tar sed grep script: - docker build -t dockle-ci-test:${CI_COMMIT_SHORT_SHA} . - | VERSION=$( curl --silent "https://api.github.com/repos/goodwithtech/dockle/releases/latest" |
grep '"tag_name":' |
sed -E 's/."v([^"]+)"./\1/'
) && curl -L -o dockle.tar.gz https://github.com/goodwithtech/dockle/releases/download/v${VERSION}/dockle_${VERSION}_Linux-64bit.tar.gz &&
tar zxvf dockle.tar.gz - ./dockle --exit-code 1 dockle-ci-test:${CI_COMMIT_SHORT_SHA}

root@kitploit:~
</details>

- Exemplo: https://gitlab.com/tomoyamachi/dockle-ci-test/-/jobs/238215077
- Repositório: https://github.com/goodwithtech/dockle-ci-test

## Autorização para Registro Docker Privado

O `Dockle` pode baixar imagens de um registro privado, sem instalar o `Docker` ou qualquer outra ferramenta de terceiros. Foi projetado para facilitar o uso em processos de CI.

Tudo o que você precisa fazer é: instalar o `Dockle` e definir as variáveis de AMBIENTE.

- NOTA: Não recomendo usar ENV vars em sua máquina local.

### Docker Hub

Para baixar o repositório privado do Docker Hub, você precisa definir as variáveis de ambiente `DOCKLE_AUTH_URL`, `DOCKLE_USERNAME` e `DOCKLE_PASSWORD`.```bash
export DOCKLE_AUTH_URL=https://registry.hub.docker.com
export DOCKLE_USERNAME={DOCKERHUB_USERNAME}
export DOCKLE_PASSWORD={DOCKERHUB_PASSWORD}
  • NOTA: Você não precisa definir variáveis de ambiente ao baixar do repositório público.

Amazon ECR (Elastic Container Registry)

Baixar ferramenta

Resumo dos Checkpoints

  • Detalhes de cada checkpoint veja CHECKPOINT.md
CODEDESCRIÇÃOLEVEL※
Checkpoints de Imagens Docker do CIS
CIS-DI-0001Criar um usuário para o containerWARN
CIS-DI-0002Use imagens base confiáveis para containersFATAL
CIS-DI-0003Não instale pacotes desnecessários no containerFATAL
CIS-DI-0004Escanear e reconstruir as imagens para incluir patches de segurançaFATAL
CIS-DI-0005Habilitar confiança de conteúdo para DockerINFO
CIS-DI-0006Adicionar instrução HEALTHCHECK à imagem do containerINFO
CIS-DI-0007Não use instruções update sozinhas no DockerfileFATAL
CIS-DI-0008Confirme a segurança de arquivos setuid e setgidINFO
CIS-DI-0009Use COPY ao invés de ADD no DockerfileFATAL
CIS-DI-0010

Nível

Dockle tem 5 níveis de verificação.

LEVELDESCRIÇÃO
FATALSeja prático e prudente
WARNSeja prático e prudente, mas com usos limitados (mesmo em imagens oficiais)
INFOPode prejudicar a utilidade ou o desempenho
SKIPArquivos alvo não encontrados
PASSNenhum problema encontrado

Exemplos Comuns

Escanear uma imagem

Simplesmente especifique um nome de imagem (e uma tag).```bash $ dockle goodwithtech/test-image:v1

root@kitploit:~
<details>
<summary>Resultado</summary>```
FATAL   - CIS-DI-0001: Create a user for the container
        * Last user should not be root
WARN    - CIS-DI-0005: Enable Content trust for Docker
        * export DOCKER_CONTENT_TRUST=1 before docker pull/build
FATAL   - CIS-DI-0006: Add HEALTHCHECK instruction to the container image
        * not found HEALTHCHECK statement
FATAL   - CIS-DI-0007: Do not use update instructions alone in the Dockerfile
        * Use 'Always combine RUN 'apt-get update' with 'apt-get install' : /bin/sh -c apt-get update && apt-get install -y git
FATAL   - CIS-DI-0008: Remove setuid and setgid permissions in the images
        * Found setuid file: etc/passwd grw-r--r--
        * Found setuid file: usr/lib/openssh/ssh-keysign urwxr-xr-x
        * Found setuid file: app/hoge.txt ugrw-r--r--
        * Found setuid file: app/hoge.txt ugrw-r--r--
        * Found setuid file: etc/shadow urw-r-----
FATAL   - CIS-DI-0009: Use COPY instead of ADD in Dockerfile
        * Use COPY : /bin/sh -c #(nop) ADD file:81c0a803075715d1a6b4f75a29f8a01b21cc170cfc1bff6702317d1be2fe71a3 in /app/credentials.json
FATAL   - CIS-DI-0010: Do not store secrets in ENVIRONMENT variables
        * Suspicious ENV key found : MYSQL_PASSWD
FATAL   - CIS-DI-0010: Do not store secret files
        * Suspicious filename found : app/credentials.json
PASS    - DKL-DI-0001: Avoid sudo command
FATAL   - DKL-DI-0002: Avoid sensitive directory mounting
        * Avoid mounting sensitive dirs : /usr
PASS    - DKL-DI-0003: Avoid apt-get/apk/dist-upgrade
PASS    - DKL-DI-0004: Use apk add with --no-cache
FATAL   - DKL-DI-0005: Clear apt-get caches
        * Use 'apt-get clean && rm -rf /var/lib/apt/lists/*' : /bin/sh -c apt-get update && apt-get install -y git
PASS    - DKL-DI-0006: Avoid latest tag
FATAL   - DKL-LI-0001: Avoid empty password
        * No password user found! username : nopasswd
PASS    - DKL-LI-0002: Be unique UID
PASS    - DKL-LI-0002: Be unique GROUP

Dockle usa o AWS SDK. Você não precisa instalar a ferramenta de CLI aws.

Use as variáveis de ambiente do AWS CLI.```bash export AWS_ACCESS_KEY_ID={AWS ACCESS KEY} export AWS_SECRET_ACCESS_KEY={SECRET KEY} export AWS_DEFAULT_REGION={AWS REGION}

root@kitploit:~
### GCR (Google Container Registry)

O `Dockle` utiliza o Google Cloud SDK. Portanto, você não precisa instalar o comando `gcloud`.

Se você deseja usar o repositório do projeto alvo, pode configurar via `GOOGLE_APPLICATION_CREDENTIAL`.```bash
# must set DOCKLE_USERNAME empty char
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credential.json

Registro Auto-hospedado (BasicAuth)

O servidor BasicAuth precisa de DOCKLE_USERNAME e DOCKLE_PASSWORD.```bash export DOCKLE_USERNAME={USERNAME} export DOCKLE_PASSWORD={PASSWORD}

if you'd like to use 80 port, use NonSSL

export DOCKLE_NON_SSL=true

root@kitploit:~
## Contribuidores

### Contribuidores de Código

Este projeto existe graças a todas as pessoas que contribuem. [[Contribua](https://github.com/goodwithtech/dockle/blob/HEAD/CONTRIBUTING.md)].
<a href="https://github.com/goodwithtech/dockle/graphs/contributors"><img src="https://opencollective.com/dockle/contributors.svg?width=890&amp;button=false" /></a>

### Contribuidores Financeiros

Torne-se um contribuidor financeiro e ajude-nos a sustentar nossa comunidade. [[Contribua](https://opencollective.com/dockle/contribute)]

#### Indivíduos

<a href="https://opencollective.com/dockle"><img src="https://opencollective.com/dockle/individuals.svg?width=890"></a>

#### Organizações

Apoie este projeto com sua organização. Seu logotipo aparecerá aqui com um link para seu site. [[Contribua](https://opencollective.com/dockle/contribute)]

<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=dockle"><img src="https://assets.kitploit.com/production/public/readmes/4137/e063c5948228b346da42565b27ee62f2dd85648c0de86a2b184c7f111319d275.png"></a>
<a href="https://opencollective.com/dockle/organization/1/website"><img src="https://opencollective.com/dockle/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/2/website"><img src="https://opencollective.com/dockle/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/3/website"><img src="https://opencollective.com/dockle/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/4/website"><img src="https://opencollective.com/dockle/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/5/website"><img src="https://opencollective.com/dockle/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/6/website"><img src="https://opencollective.com/dockle/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/7/website"><img src="https://opencollective.com/dockle/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/8/website"><img src="https://opencollective.com/dockle/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/dockle/organization/9/website"><img src="https://opencollective.com/dockle/organization/9/avatar.svg"></a>

### Apoiadores de Programas OSS

Este projeto utiliza serviços fornecidos através dos seguintes programas OSS.

<a href="https://flatt.tech/oss/gmo/trampoline" target="_blank"><img src="https://flatt.tech/assets/images/badges/gmo-oss.svg" height="24px"/></a>
<a href="https://github.com/1Password/for-open-source" target="_blank"><img src="https://img.shields.io/badge/1Password-OSS%20Program-0094F5?logo=1password&amp;logoColor=white" height="24px"/></a>

# Licença

- Apache License 2.0

# Autor

[@tomoyamachi](https://github.com/tomoyamachi) (Tomoya Amachi)

Agradecimentos especiais a [@knqyf263](https://github.com/knqyf263) (Teppei Fukuda) e [Trivy](https://github.com/knqyf263/trivy)
Não armazene segredos em Dockerfiles
FATAL
CIS-DI-0011Instale apenas pacotes verificadosINFO
Checkpoints do Dockle para Docker
DKL-DI-0001Evite o comando sudoFATAL
DKL-DI-0002Evite montagem de diretórios sensíveisFATAL
DKL-DI-0003Evite apt-get dist-upgradeWARN
DKL-DI-0004Use apk add com --no-cacheFATAL
DKL-DI-0005Limpe os caches do apt-getFATAL
DKL-DI-0006Evite a tag latestWARN
Checkpoints do Dockle para Linux
DKL-LI-0001Evite senha vaziaFATAL
DKL-LI-0002Possua UIDs/GROUPs únicosFATAL
DKL-LI-0003Coloque apenas arquivos necessáriosINFO