mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
1 line
306 KiB
JSON
1 line
306 KiB
JSON
{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+","tags":false},"docs":[{"location":"","text":"<p></p> <p><code>Trivy</code> (<code>tri</code> pronounced like trigger, <code>vy</code> pronounced like envy) is a simple and comprehensive vulnerability/misconfiguration scanner for containers and other artifacts. A software vulnerability is a glitch, flaw, or weakness present in the software or in an Operating System. <code>Trivy</code> detects vulnerabilities of OS packages (Alpine, RHEL, CentOS, etc.) and language-specific packages (Bundler, Composer, npm, yarn, etc.). In addition, <code>Trivy</code> scans Infrastructure as Code (IaC) files such as Terraform and Kubernetes, to detect potential configuration issues that expose your deployments to the risk of attack. <code>Trivy</code> is easy to use. Just install the binary and you're ready to scan. All you need to do for scanning is to specify a target such as an image name of the container.</p>","title":"HOME"},{"location":"#demo","text":"Demo: Vulnerability Detection Demo: Misconfiguration Detection <p>Trivy is an Aqua Security open source project. Learn about our open source work and portfolio here. Contact us about any matter by opening a GitHub Discussion here</p>","title":"Demo"},{"location":"community/cks/","text":"<p>Community Resources</p> <ul> <li>Trivy Video overview (short)</li> <li>Example questions from the exam</li> <li>More example questions</li> </ul> <p>Aqua Security Blog posts</p> <ul> <li>Supply chain security best practices</li> <li>Supply chain attacks</li> <li>If you know of interesting resources, please start a PR to add those to the list.</li> </ul>","title":"CKS preparation resources"},{"location":"community/credit/","text":"<p>Teppei Fukuda (knqyf263)</p>","title":"Author"},{"location":"community/credit/#contributors","text":"<p>Thanks to all contributors</p>","title":"Contributors"},{"location":"community/references/","text":"<p>There are external blogs and evaluations.</p>","title":"Additional References"},{"location":"community/references/#blogs","text":"<ul> <li>Trivy Vulnerability Scanner Joins the Aqua Open-source Family</li> <li>Trivy Image Vulnerability Scanner Now Under Apache 2.0 License</li> <li>DevSecOps with Trivy and GitHub Actions</li> <li>Find Image Vulnerabilities Using GitHub and Aqua Security Trivy Action</li> <li>Using Trivy to Discover Vulnerabilities in VS Code Projects</li> <li>the vulnerability remediation lifecycle of Alpine containers</li> <li>Continuous Container Vulnerability Testing with Trivy</li> <li>Open Source CVE Scanner Round-Up: Clair vs Anchore vs Trivy</li> <li>Docker Image Security: Static Analysis Tool Comparison \u2013 Anchore Engine vs Clair vs Trivy</li> </ul>","title":"Blogs"},{"location":"community/references/#links","text":"<ul> <li>Research Spike: evaluate Trivy for scanning running containers</li> <li>Istio evaluates scanners</li> </ul>","title":"Links"},{"location":"community/references/#presentations","text":"<ul> <li>Aqua Security YouTube Channel<ul> <li>Trivy - container image scanning</li> <li>Using Trivy in client server mode</li> <li>Tweaking Trivy output to fit your workflow</li> <li>How does a vulnerability scanner identify packages?</li> </ul> </li> <li>CNCF Webinar 2020<ul> <li>Trivy Open Source Scanner for Container Images \u2013 Just Download and Run!</li> </ul> </li> <li>KubeCon + CloudNativeCon Europe 2020 Virtual<ul> <li>Handling Container Vulnerabilities with Open Policy Agent - Teppei Fukuda, Aqua Security</li> </ul> </li> </ul>","title":"Presentations"},{"location":"community/tools/","text":"<p>The open source community has been hard at work developing new tools for Trivy. You can check out some of them here.</p> <p>Have you created a tool that\u2019s not listed? Add the name and description of your integration and open a pull request in the GitHub repository to get your change merged.</p>","title":"Community Tools"},{"location":"community/tools/#github-actions","text":"Actions Description gitrivy GitHub Issue + Trivy trivy-github-issues GitHub Actions for creating GitHub Issues according to the Trivy scanning result","title":"GitHub Actions"},{"location":"community/tools/#semaphore","text":"Name Description Continuous Vulnerability Testing with Trivy Tutorial on scanning code, containers, infrastructure, and Kubernetes with Semaphore CI/CD.","title":"Semaphore"},{"location":"community/tools/#circleci","text":"Orb Description fifteen5/trivy-orb Orb for running Trivy, a security scanner","title":"CircleCI"},{"location":"community/tools/#others","text":"Name Description Trivy Vulnerability Explorer Explore trivy vulnerability reports in your browser and create .trivyignore files interactively. Can be integrated in your CI/CD tooling with deep links.","title":"Others"},{"location":"community/contribute/issue/","text":"<p>Thank you for taking interest in contributing to Trivy!</p> <ul> <li>Feel free to open issues for any reason. When you open a new issue, you'll have to select an issue kind: bug/feature/support and fill the required information based on the selected template.</li> <li>Please spend a small amount of time giving due diligence to the issue tracker. Your issue might be a duplicate. If it is, please add your comment to the existing issue.</li> <li>Remember that users might search for your issue in the future, so please give it a meaningful title to help others.</li> <li>The issue should clearly explain the reason for opening, the proposal if you have any, and any relevant technical information.</li> </ul>","title":"Issues"},{"location":"community/contribute/issue/#wrong-detection","text":"<p>Trivy depends on multiple data sources. Sometime these databases contain mistakes.</p> <p>If Trivy can't detect any CVE-IDs or shows false positive result, at first please follow the next steps:</p> <ol> <li>Run Trivy with <code>-f json</code> that shows data sources.</li> <li>According to the shown data source, make sure that the security advisory in the data source is correct.</li> </ol> <p>If the data source is correct and Trivy shows wrong results, please raise an issue on Trivy.</p>","title":"Wrong detection"},{"location":"community/contribute/issue/#github-advisory-database","text":"<p>Visit here and search CVE-ID.</p> <p>If you find a problem, it'll be nice to fix it: How to contribute to a GitHub security advisory</p>","title":"GitHub Advisory Database"},{"location":"community/contribute/issue/#gitlab-advisory-database","text":"<p>Visit here and search CVE-ID.</p> <p>If you find a problem, it'll be nice to fix it: Create an issue to GitLab Advisory Database</p>","title":"GitLab Advisory Database"},{"location":"community/contribute/issue/#red-hat-cve-database","text":"<p>Visit here and search CVE-ID.</p>","title":"Red Hat CVE Database"},{"location":"community/contribute/pr/","text":"<p>Thank you for taking interest in contributing to Trivy!</p> <ol> <li>Every Pull Request should have an associated bug or feature issue unless you are fixing a trivial documentation issue.</li> <li>Please add the associated Issue link in the PR description.</li> <li>Your PR is more likely to be accepted if it focuses on just one change.</li> <li>There's no need to add or tag reviewers.</li> <li>If a reviewer commented on your code or asked for changes, please remember to respond with comment. Do not mark discussion as resolved. It's up to reviewer to mark it resolved (in case if suggested fix addresses problem properly). PRs with unresolved issues should not be merged (even if the comment is unclear or requires no action from your side).</li> <li>Please include a comment with the results before and after your change.</li> <li>Your PR is more likely to be accepted if it includes tests (We have not historically been very strict about tests, but we would like to improve this!).</li> <li>If your PR affects the user experience in some way, please update the README.md and the CLI help accordingly.</li> </ol>","title":"Pull Requests"},{"location":"community/contribute/pr/#title","text":"<p>It is not that strict, but we use the title conventions in this repository. Each commit message doesn't have to follow the conventions as long as it is clear and descriptive since it will be squashed and merged.</p>","title":"Title"},{"location":"community/contribute/pr/#format-of-the-title","text":"<pre><code><type>(<scope>): <subject>\n</code></pre> <p>The <code>type</code> and <code>scope</code> should always be lowercase as shown below.</p> <p>Allowed <code><type></code> values:</p> <ul> <li>feat for a new feature for the user, not a new feature for build script. Such commit will trigger a release bumping a MINOR version.</li> <li>fix for a bug fix for the user, not a fix to a build script. Such commit will trigger a release bumping a PATCH version.</li> <li>perf for performance improvements. Such commit will trigger a release bumping a PATCH version.</li> <li>docs for changes to the documentation.</li> <li>style for formatting changes, missing semicolons, etc.</li> <li>refactor for refactoring production code, e.g. renaming a variable.</li> <li>test for adding missing tests, refactoring tests; no production code change.</li> <li>build for updating build configuration, development tools or other changes irrelevant to the user.</li> <li>chore for updates that do not apply to the above, such as dependency updates.</li> <li>ci for changes to CI configuration files and scripts</li> <li>revert for revert to a previous commit</li> </ul> <p>Allowed <code><scope></code> values:</p> <p>checks:</p> <ul> <li>vuln</li> <li>misconf</li> <li>secret</li> </ul> <p>mode:</p> <ul> <li>image</li> <li>fs</li> <li>repo</li> <li>sbom</li> <li>server</li> </ul> <p>os:</p> <ul> <li>alpine</li> <li>redhat</li> <li>alma</li> <li>rocky</li> <li>mariner</li> <li>oracle</li> <li>debian</li> <li>ubuntu</li> <li>amazon</li> <li>suse</li> <li>photon</li> <li>distroless</li> </ul> <p>language:</p> <ul> <li>ruby</li> <li>php</li> <li>python</li> <li>nodejs</li> <li>rust</li> <li>dotnet</li> <li>java</li> <li>go</li> </ul> <p>vuln:</p> <ul> <li>os</li> <li>lang</li> </ul> <p>config:</p> <ul> <li>kubernetes</li> <li>dockerfile</li> <li>terraform</li> <li>cloudformation</li> </ul> <p>container</p> <ul> <li>docker</li> <li>podman</li> <li>containerd</li> <li>oci</li> </ul> <p>cli:</p> <ul> <li>cli</li> <li>flag</li> </ul> <p>others:</p> <ul> <li>helm</li> <li>report</li> <li>db</li> <li>deps</li> </ul> <p>The <code><scope></code> can be empty (e.g. if the change is a global or difficult to assign to a single component), in which case the parentheses are omitted.</p>","title":"Format of the title"},{"location":"community/contribute/pr/#example-titles","text":"<pre><code>feat(alma): add support for AlmaLinux\n</code></pre> <pre><code>fix(oracle): handle advisories with ksplice versions\n</code></pre> <pre><code>docs(misconf): add comparison with Conftest and TFsec\n</code></pre> <pre><code>chore(deps): bump go.uber.org/zap from 1.19.1 to 1.20.0\n</code></pre> <p>NOTE: please do not use <code>chore(deps): update fanal</code> and something like that if you add new features or fix bugs in Trivy-related projects. The PR title should describe what the PR adds or fixes even though it just updates the dependency in Trivy.</p>","title":"Example titles"},{"location":"community/contribute/pr/#unit-tests","text":"<p>Your PR must pass all the unit tests. You can test it as below.</p> <pre><code>$ make test\n</code></pre>","title":"Unit tests"},{"location":"community/contribute/pr/#integration-tests","text":"<p>Your PR must pass all the integration tests. You can test it as below.</p> <pre><code>$ make test-integration\n</code></pre>","title":"Integration tests"},{"location":"community/contribute/pr/#documentation","text":"<p>You can build the documents as below and view it at http://localhost:8000.</p> <pre><code>$ make mkdocs-serve\n</code></pre>","title":"Documentation"},{"location":"community/contribute/pr/#understand-where-your-pull-request-belongs","text":"<p>Trivy is composed of several repositories that work together:</p> <ul> <li>Trivy is the client-side, user-facing, command line tool.</li> <li>vuln-list is a vulnerabilities database, aggregated from different sources, and normalized for easy consumption. Think of this as the \"server\" side of the trivy command line tool. There should be no pull requests to this repo</li> <li>vuln-list-update is the code that maintains the vuln-list database.</li> <li>trivy-db maintains the vulnerability database pulled by Trivy CLI.</li> <li>fanal is a library for extracting system information from containers. It is being used by Trivy to find testable subjects in the container image.</li> <li>go-dep-parser is a library for parsing lock files such as package-lock.json and Gemfile.lock.</li> </ul>","title":"Understand where your pull request belongs"},{"location":"community/maintainer/help-wanted/","text":"<p>We use two labels help wanted and good first issue to identify issues that have been specially groomed for new contributors. The <code>good first issue</code> label is a subset of <code>help wanted</code> label, indicating that members have committed to providing extra assistance for new contributors. All <code>good first issue</code> items also have the <code>help wanted</code> label.</p>","title":"Overview"},{"location":"community/maintainer/help-wanted/#help-wanted","text":"<p>Items marked with the <code>help wanted</code> label need to ensure that they are:</p> <ul> <li>Low Barrier to Entry</li> </ul> <p>It should be tractable for new contributors. Documentation on how that type of change should be made should already exist.</p> <ul> <li>Clear Task</li> </ul> <p>The task is agreed upon and does not require further discussions in the community. Call out if that area of code is untested and requires new fixtures.</p> <p>API / CLI behavior is decided and included in the OP issue, for example: \"The new command syntax is <code>trivy --format yaml IMAGE_NAME</code>\"_ with expected validations called out.</p> <ul> <li>Goldilocks priority</li> </ul> <p>Not too high that a core contributor should do it, but not too low that it isn't useful enough for a core contributor to spend time to review it, answer questions, help get it into a release, etc.</p> <ul> <li>Up-To-Date</li> </ul> <p>Often these issues become obsolete and have already been done, are no longer desired, no longer make sense, have changed priority or difficulty , etc.</p>","title":"Help Wanted"},{"location":"community/maintainer/help-wanted/#good-first-issue","text":"<p>Items marked with the <code>good first issue</code> label are intended for first-time contributors. It indicates that members will keep an eye out for these pull requests and shepherd it through our processes.</p> <p>These items need to ensure that they follow the guidelines for <code>help wanted</code> labels (above) in addition to meeting the following criteria:</p> <ul> <li>No Barrier to Entry</li> </ul> <p>The task is something that a new contributor can tackle without advanced setup, or domain knowledge.</p> <ul> <li>Solution Explained</li> </ul> <p>The recommended solution is clearly described in the issue.</p> <ul> <li>Provides Context</li> </ul> <p>If background knowledge is required, this should be explicitly mentioned and a list of suggested readings included.</p> <ul> <li>Gives Examples</li> </ul> <p>Link to examples of similar implementations so new contributors have a reference guide for their changes.</p> <ul> <li>Identifies Relevant Code</li> </ul> <p>The relevant code and tests to be changed should be linked in the issue.</p> <ul> <li>Ready to Test</li> </ul> <p>There should be existing tests that can be modified, or existing test cases fit to be copied. If the area of code doesn't have tests, before labeling the issue, add a test fixture. This prep often makes a great <code>help wanted</code> task!</p>","title":"Good First Issue"},{"location":"community/maintainer/triage/","text":"<p>Triage is an important part of maintaining the health of the trivy repo. A well organized repo allows maintainers to prioritize feature requests, fix bugs, and respond to users facing difficulty with the tool as quickly as possible.</p> <p>Triage includes:</p> <ul> <li>Labeling issues</li> <li>Responding to issues</li> <li>Closing issues</li> </ul>","title":"Triage"},{"location":"community/maintainer/triage/#daily-triage","text":"<p>Daily triage has two goals:</p> <ol> <li>Responsiveness for new issues</li> <li>Responsiveness when explicitly requested information was provided</li> </ol> <p>It covers:</p> <ol> <li>Issues without a <code>kind/</code> or <code>triage/</code> label</li> <li>Issues without a <code>priority/</code> label</li> <li><code>triage/needs-information</code> issues which the user has followed up on, and now require a response.</li> </ol>","title":"Daily Triage"},{"location":"community/maintainer/triage/#categorization","text":"<p>The most important level of categorizing the issue is defining what type it is. We typically want at least one of the following labels on every issue, and some issues may fall into multiple categories:</p> <ul> <li><code>triage/support</code> - The default for most incoming issues</li> <li><code>kind/bug</code> - When it\u2019s a bug or we aren\u2019t delivering the best user experience</li> </ul> <p>Other possibilities: - <code>kind/feature</code>- Identify new feature requests - <code>kind/testing</code> - Update or fix unit/integration tests - <code>kind/cleanup</code> - Cleaning up/refactoring the codebase - <code>kind/documentation</code> - Updates or additions to trivy documentation</p> <p>If the issue is specific to a driver for OS packages or libraries:</p> <p>co/[driver for OS packages]</p> <ul> <li><code>co/alpine</code></li> <li><code>co/amazon</code></li> <li><code>co/debian</code></li> <li><code>co/oracle</code></li> <li><code>co/photon</code></li> <li><code>co/redhat</code></li> <li><code>co/suse</code></li> <li><code>co/ubuntu</code></li> </ul> <p>co/[driver for libraries of programming languages] </p> <ul> <li><code>co/bundler</code></li> <li><code>co/cargo</code></li> <li><code>co/composer</code></li> <li><code>co/npm</code></li> <li><code>co/yarn</code></li> <li><code>co/pipenv</code></li> <li><code>co/poetry</code></li> </ul> <p>Help wanted?</p> <p><code>Good First Issue</code> - bug has a proposed solution, can be implemented w/o further discussion.</p> <p><code>Help wanted</code> - if the bug could use help from a contributor</p>","title":"Categorization"},{"location":"community/maintainer/triage/#prioritization","text":"<p>If the issue is not <code>triage/support</code>, it needs a priority label.</p> <p><code>priority/critical-urgent</code> - someones top priority ASAP, such as security issue, user-visible bug, or build breakage. Rarely used.</p> <p><code>priority/important-soon</code>: in time for the next two releases. It should be attached to a milestone.</p> <p><code>priority/important-longterm</code>: 2-4 releases from now</p> <p><code>priority/backlog</code>: agreed that this would be good to have, but no one is available at the moment. Consider tagging as <code>help wanted</code></p> <p><code>priority/awaiting-more-evidence</code>: may be useful, but there is not yet enough support.</p>","title":"Prioritization"},{"location":"community/maintainer/triage/#weekly-triage","text":"<p>Weekly triage has three goals:</p> <ol> <li>Catching up on unresponded issues</li> <li>Reviewing and closing PR\u2019s</li> <li>Closing stale issues</li> </ol>","title":"Weekly Triage"},{"location":"community/maintainer/triage/#post-release-triage","text":"<p>Post-release triage occurs after a major release (around every 4-6 weeks). It focuses on:</p> <ol> <li>Closing bugs that have been resolved by the release</li> <li>Reprioritizing bugs that have not been resolved by the release</li> <li>Letting users know if we believe that there is still an issue</li> </ol> <p>This includes reviewing:</p> <ol> <li>Every issue that hasn\u2019t been touched in the last 2 days</li> <li>Re-evaluation of long-term issues</li> <li>Re-evaluation of short-term issues</li> </ol>","title":"Post-Release Triage"},{"location":"community/maintainer/triage/#responding-to-issues","text":"","title":"Responding to Issues"},{"location":"community/maintainer/triage/#needs-more-information","text":"<p>A sample response to ask for more info:</p> <p>I don\u2019t yet have a clear way to replicate this issue. Do you mind adding some additional details. Here is additional information that would be helpful:</p> <p>* The exact <code>trivy</code> command line used</p> <p>* The exact image you want to scan</p> <p>* The full output of the <code>trivy</code> command, preferably with <code>--debug</code> for extra logging.</p> <p>Thank you for sharing your experience!</p> <p>Then: Label with <code>triage/needs-information</code>.</p>","title":"Needs More Information"},{"location":"community/maintainer/triage/#issue-might-be-resolved","text":"<p>If you think a release may have resolved an issue, ask the author to see if their issue has been resolved:</p> <p>Could you please check to see if trivy addresses this issue? We've made some changes with how this is handled, and improved the trivy logs output to help us debug tricky cases like this. <p>Then: Label with <code>triage/needs-information</code>.</p>","title":"Issue might be resolved"},{"location":"community/maintainer/triage/#closing-with-care","text":"<p>Issues typically need to be closed for the following reasons:</p> <ul> <li>The issue has been addressed</li> <li>The issue is a duplicate of an existing issue</li> <li>There has been a lack of information over a long period of time</li> </ul> <p>In any of these situations, we aim to be kind when closing the issue, and offer the author action items should they need to reopen their issue or still require a solution.</p> <p>Samples responses for these situations include:</p>","title":"Closing with Care"},{"location":"community/maintainer/triage/#issue-has-been-addressed","text":"<p>@author: I believe this issue is now addressed by trivy v1.0.0, as it . If you still see this issue with trivy v1.0 or higher, please reopen this issue. <p>Thank you for reporting this issue!</p> <p>Then: Close the issue</p>","title":"Issue has been addressed"},{"location":"community/maintainer/triage/#duplicate-issue","text":"<p>This issue appears to be a duplicate of #X, do you mind if we move the conversation there?</p> <p>This way we can centralize the content relating to the issue. If you feel that this issue is not in fact a duplicate, please re-open it. If you have additional information to share, please add it to the new issue.</p> <p>Thank you for reporting this!</p> <p>Then: Label with <code>triage/duplicate</code> and close the issue.</p>","title":"Duplicate Issue"},{"location":"community/maintainer/triage/#lack-of-information","text":"<p>If an issue hasn't been active for more than four weeks, and the author has been pinged at least once, then the issue can be closed.</p> <p>Hey @author -- hopefully it's OK if I close this - there wasn't enough information to make it actionable, and some time has already passed. If you are able to provide additional details, you may reopen it at any point.</p> <p>Here is additional information that may be helpful to us:</p> <p>* Whether the issue occurs with the latest trivy release</p> <p>* The exact <code>trivy</code> command line used</p> <p>* The exact image you want to scan</p> <p>* The full output of the <code>trivy</code> command, preferably with <code>--debug</code> for extra logging.</p> <p>Thank you for sharing your experience!</p> <p>Then: Close the issue.</p>","title":"Lack of Information"},{"location":"community/maintainer/triage/#help-wanted-issues","text":"<p>We use two labels help wanted and good first issue to identify issues that have been specially groomed for new contributors.</p> <p>We have specific guidelines for how to use these labels. If you see an issue that satisfies these guidelines, you can add the <code>help wanted</code> label and the <code>good first issue</code> label. Please note that adding the <code>good first issue</code> label must also add the <code>help wanted</code> label.</p> <p>If an issue has these labels but does not satisfy the guidelines, please ask for more details to be added to the issue or remove the labels.</p>","title":"Help Wanted issues"},{"location":"docs/","text":"<p>Trivy detects two types of security issues:</p> <ul> <li>Vulnerabilities</li> <li>Misconfigurations</li> </ul> <p>Trivy can scan three different artifacts:</p> <ul> <li>Container Images</li> <li>Filesystem and Rootfs</li> <li>Git Repositories</li> </ul> <p>Trivy can be run in two different modes:</p> <ul> <li>Standalone</li> <li>Client/Server</li> </ul> <p>It is designed to be used in CI. Before pushing to a container registry or deploying your application, you can scan your local container image and other artifacts easily. See Integrations for details.</p>","title":"Docs"},{"location":"docs/#features","text":"<ul> <li>Comprehensive vulnerability detection<ul> <li>OS packages (Alpine, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)</li> <li>Language-specific packages (Bundler, Composer, Pipenv, Poetry, npm, yarn, Cargo, NuGet, Maven, and Go)</li> </ul> </li> <li>Detect IaC misconfigurations<ul> <li>A wide variety of built-in policies are provided out of the box:<ul> <li>Kubernetes</li> <li>Docker</li> <li>Terraform</li> <li>more coming soon</li> </ul> </li> <li>Support custom policies</li> </ul> </li> <li>Simple<ul> <li>Specify only an image name, a directory containing IaC configs, or an artifact name</li> <li>See Quick Start</li> </ul> </li> <li>Fast<ul> <li>The first scan will finish within 10 seconds (depending on your network). Consequent scans will finish in single seconds.</li> <li>Unlike other scanners that take long to fetch vulnerability information (~10 minutes) on the first run, and encourage you to maintain a durable vulnerability database, Trivy is stateless and requires no maintenance or preparation.</li> </ul> </li> <li>Easy installation<ul> <li><code>apt-get install</code>, <code>yum install</code> and <code>brew install</code> is possible (See Installation)</li> <li>No pre-requisites such as installation of DB, libraries, etc.</li> </ul> </li> <li>High accuracy<ul> <li>Especially Alpine Linux and RHEL/CentOS</li> <li>Other OSes are also high</li> </ul> </li> <li>DevSecOps<ul> <li>Suitable for CI such as Travis CI, CircleCI, Jenkins, GitLab CI, etc.</li> <li>See CI Example</li> </ul> </li> <li>Support multiple formats<ul> <li>container image<ul> <li>A local image in Docker Engine which is running as a daemon</li> <li>A local image in Podman (>=2.0) which is exposing a socket</li> <li>A remote image in Docker Registry such as Docker Hub, ECR, GCR and ACR</li> <li>A tar archive stored in the <code>docker save</code> / <code>podman save</code> formatted file</li> <li>An image directory compliant with OCI Image Format</li> </ul> </li> <li>local filesystem and rootfs</li> <li>remote git repository</li> </ul> </li> <li>SBOM (Software Bill of Materials) support<ul> <li>CycloneDX </li> </ul> </li> </ul> <p>Please see LICENSE for Trivy licensing information.</p>","title":"Features"},{"location":"docs/advanced/air-gap/","text":"<p>Trivy can be used in air-gapped environments. Note that an allowlist is here.</p>","title":"Air-Gapped Environment"},{"location":"docs/advanced/air-gap/#air-gapped-environment-for-vulnerabilities","text":"","title":"Air-Gapped Environment for vulnerabilities"},{"location":"docs/advanced/air-gap/#download-the-vulnerability-database","text":"<p>At first, you need to download the vulnerability database for use in air-gapped environments. Please follow oras installation instruction.</p> <p>Download <code>db.tar.gz</code>:</p> <pre><code>$ oras pull ghcr.io/aquasecurity/trivy-db:2 -a\n</code></pre>","title":"Download the vulnerability database"},{"location":"docs/advanced/air-gap/#transfer-the-db-file-into-the-air-gapped-environment","text":"<p>The way of transfer depends on the environment.</p> <pre><code>$ rsync -av -e ssh /path/to/db.tar.gz [user]@[host]:dst\n</code></pre>","title":"Transfer the DB file into the air-gapped environment"},{"location":"docs/advanced/air-gap/#put-the-db-file-in-trivys-cache-directory","text":"<p>You have to know where to put the DB file. The following command shows the default cache directory.</p> <pre><code>$ ssh user@host\n$ trivy -h | grep cache\n --cache-dir value cache directory (default: \"/home/myuser/.cache/trivy\") [$TRIVY_CACHE_DIR]\n</code></pre> <p>Put the DB file in the cache directory + <code>/db</code>.</p> <pre><code>$ mkdir -p /home/myuser/.cache/trivy/db\n$ cd /home/myuser/.cache/trivy/db\n$ tar xvf /path/to/db.tar.gz -C /home/myuser/.cache/trivy/db\nx trivy.db\nx metadata.json\n$ rm /path/to/db.tar.gz\n</code></pre> <p>In an air-gapped environment it is your responsibility to update the Trivy database on a regular basis, so that the scanner can detect recently-identified vulnerabilities. </p>","title":"Put the DB file in Trivy's cache directory"},{"location":"docs/advanced/air-gap/#run-trivy-with-skip-update-and-offline-scan-option","text":"<p>In an air-gapped environment, specify <code>--skip-update</code> so that Trivy doesn't attempt to download the latest database file. In addition, if you want to scan Java dependencies such as JAR and pom.xml, you need to specify <code>--offline-scan</code> since Trivy tries to issue API requests for scanning Java applications by default.</p> <pre><code>$ trivy image --skip-update --offline-scan alpine:3.12\n</code></pre>","title":"Run Trivy with --skip-update and --offline-scan option"},{"location":"docs/advanced/air-gap/#air-gapped-environment-for-misconfigurations","text":"","title":"Air-Gapped Environment for misconfigurations"},{"location":"docs/advanced/air-gap/#download-misconfiguration-policies","text":"<p>At first, you need to download misconfiguration policies for use in air-gapped environments. Please follow oras installation instruction.</p> <p>Download <code>bundle.tar.gz</code>:</p> <pre><code>$ oras pull ghcr.io/aquasecurity/appshield:latest -a\n</code></pre>","title":"Download misconfiguration policies"},{"location":"docs/advanced/air-gap/#transfer-misconfiguration-policies-into-the-air-gapped-environment","text":"<p>The way of transfer depends on the environment.</p> <pre><code>$ rsync -av -e ssh /path/to/bundle.tar.gz [user]@[host]:dst\n</code></pre>","title":"Transfer misconfiguration policies into the air-gapped environment"},{"location":"docs/advanced/air-gap/#put-the-misconfiguration-policies-in-trivys-cache-directory","text":"<p>You have to know where to put the misconfiguration policies file. The following command shows the default cache directory.</p> <pre><code>$ ssh user@host\n$ trivy -h | grep cache\n --cache-dir value cache directory (default: \"/home/myuser/.cache/trivy\") [$TRIVY_CACHE_DIR]\n</code></pre> <p>Put the misconfiguration policies file in the cache directory + <code>/policy/content</code>.</p> <pre><code>$ mkdir -p /home/myuser/.cache/trivy/policy/content\n$ cd /home/myuser/.cache/trivy/policy/content\n$ mv /path/to/bundle.tar.gz .\n</code></pre> <p>Then, decompress it. <code>bundle.tar.gz</code> file includes two folders: <code>docker</code>, <code>kubernetes</code> and file: <code>.manifest</code>.</p> <pre><code>$ tar xvf bundle.tar.gz \nx ./docker/\n...\nx ./kubernetes/\n...\nx ./.manifest\n$ rm bundle.tar.gz\n</code></pre> <p>In an air-gapped environment it is your responsibility to update policies on a regular basis, so that the scanner can detect recently-identified misconfigurations. </p>","title":"Put the misconfiguration policies in Trivy's cache directory"},{"location":"docs/advanced/air-gap/#run-trivy-with-skip-policy-update-option","text":"<p>In an air-gapped environment, specify <code>--skip-policy-update</code> so that Trivy doesn't attempt to download the latest misconfiguration policies.</p> <pre><code>$ trivy conf --skip-policy-update /path/to/conf\n</code></pre>","title":"Run Trivy with --skip-policy-update option"},{"location":"docs/advanced/plugins/","text":"<p>Trivy provides a plugin feature to allow others to extend the Trivy CLI without the need to change the Trivycode base. This plugin system was inspired by the plugin system used in kubectl, Helm, and Conftest.</p>","title":"Plugins"},{"location":"docs/advanced/plugins/#overview","text":"<p>Trivy plugins are add-on tools that integrate seamlessly with Trivy. They provide a way to extend the core feature set of Trivy, but without requiring every new feature to be written in Go and added to the core tool.</p> <ul> <li>They can be added and removed from a Trivy installation without impacting the core Trivy tool.</li> <li>They can be written in any programming language.</li> <li>They integrate with Trivy, and will show up in Trivy help and subcommands.</li> </ul> <p>Warning</p> <p>Trivy plugins available in public are not audited for security. You should install and run third-party plugins at your own risk, since they are arbitrary programs running on your machine.</p>","title":"Overview"},{"location":"docs/advanced/plugins/#installing-a-plugin","text":"<p>A plugin can be installed using the <code>trivy plugin install</code> command. This command takes a url and will download the plugin and install it in the plugin cache.</p> <p>Trivy adheres to the XDG specification, so the location depends on whether XDG_DATA_HOME is set. Trivy will now search XDG_DATA_HOME for the location of the Trivy plugins cache. The preference order is as follows:</p> <ul> <li>XDG_DATA_HOME if set and .trivy/plugins exists within the XDG_DATA_HOME dir</li> <li>~/.trivy/plugins</li> </ul> <p>Under the hood Trivy leverages go-getter to download plugins. This means the following protocols are supported for downloading plugins:</p> <ul> <li>OCI Registries</li> <li>Local Files</li> <li>Git</li> <li>HTTP/HTTPS</li> <li>Mercurial</li> <li>Amazon S3</li> <li>Google Cloud Storage</li> </ul> <p>For example, to download the Kubernetes Trivy plugin you can execute the following command:</p> <pre><code>$ trivy plugin install github.com/aquasecurity/trivy-plugin-kubectl\n</code></pre>","title":"Installing a Plugin"},{"location":"docs/advanced/plugins/#using-plugins","text":"<p>Once the plugin is installed, Trivy will load all available plugins in the cache on the start of the next Trivy execution. A plugin will be made in the Trivy CLI based on the plugin name. To display all plugins, you can list them by <code>trivy --help</code></p> <pre><code>$ trivy --help\nNAME:\n trivy - A simple and comprehensive vulnerability scanner for containers\n\nUSAGE:\n trivy [global options] command [command options] target\n\nVERSION:\n dev\n\nCOMMANDS:\n image, i scan an image\n filesystem, fs scan local filesystem\n repository, repo scan remote repository\n client, c client mode\n server, s server mode\n plugin, p manage plugins\n kubectl scan kubectl resources\n help, h Shows a list of commands or help for one command\n</code></pre> <p>As shown above, <code>kubectl</code> subcommand exists in the <code>COMMANDS</code> section. To call the kubectl plugin and scan existing Kubernetes deployments, you can execute the following command:</p> <pre><code>$ trivy kubectl deployment <deployment-id> -- --ignore-unfixed --severity CRITICAL\n</code></pre> <p>Internally the kubectl plugin calls the kubectl binary to fetch information about that deployment and passes the using images to Trivy. You can see the detail here.</p> <p>If you want to omit even the subcommand, you can use <code>TRIVY_RUN_AS_PLUGIN</code> environment variable.</p> <pre><code>$ TRIVY_RUN_AS_PLUGIN=kubectl trivy job your-job -- --format json\n</code></pre>","title":"Using Plugins"},{"location":"docs/advanced/plugins/#installing-and-running-plugins-on-the-fly","text":"<p><code>trivy plugin run</code> installs a plugin and runs it on the fly. If the plugin is already present in the cache, the installation is skipped.</p> <pre><code>trivy plugin run github.com/aquasecurity/trivy-plugin-kubectl pod your-pod -- --exit-code 1\n</code></pre>","title":"Installing and Running Plugins on the fly"},{"location":"docs/advanced/plugins/#uninstalling-plugins","text":"<p>Specify a plugin name with <code>trivy plugin uninstall</code> command.</p> <pre><code>$ trivy plugin uninstall kubectl\n</code></pre>","title":"Uninstalling Plugins"},{"location":"docs/advanced/plugins/#building-plugins","text":"<p>Each plugin has a top-level directory, and then a plugin.yaml file.</p> <pre><code>your-plugin/\n |\n |- plugin.yaml\n |- your-plugin.sh\n</code></pre> <p>In the example above, the plugin is contained inside of a directory named <code>your-plugin</code>. It has two files: plugin.yaml (required) and an executable script, your-plugin.sh (optional).</p> <p>The core of a plugin is a simple YAML file named plugin.yaml. Here is an example YAML of trivy-plugin-kubectl plugin that adds support for Kubernetes scanning.</p> <pre><code>name: \"kubectl\"\nrepository: github.com/aquasecurity/trivy-plugin-kubectl\nversion: \"0.1.0\"\nusage: scan kubectl resources\ndescription: |-\n A Trivy plugin that scans the images of a kubernetes resource.\n Usage: trivy kubectl TYPE[.VERSION][.GROUP] NAME\nplatforms:\n - selector: # optional\n os: darwin\n arch: amd64\n uri: ./trivy-kubectl # where the execution file is (local file, http, git, etc.)\n bin: ./trivy-kubectl # path to the execution file\n - selector: # optional\n os: linux\n arch: amd64\n uri: https://github.com/aquasecurity/trivy-plugin-kubectl/releases/download/v0.1.0/trivy-kubectl.tar.gz\n bin: ./trivy-kubectl\n</code></pre> <p>The <code>plugin.yaml</code> field should contain the following information:</p> <ul> <li>name: The name of the plugin. This also determines how the plugin will be made available in the Trivy CLI. For example, if the plugin is named kubectl, you can call the plugin with <code>trivy kubectl</code>. (required)</li> <li>version: The version of the plugin. (required)</li> <li>usage: A short usage description. (required)</li> <li>description: A long description of the plugin. This is where you could provide a helpful documentation of your plugin. (required)</li> <li>platforms: (required)</li> <li>selector: The OS/Architecture specific variations of a execution file. (optional)<ul> <li>os: OS information based on GOOS (linux, darwin, etc.) (optional)</li> <li>arch: The architecture information based on GOARCH (amd64, arm64, etc.) (optional)</li> </ul> </li> <li>uri: Where the executable file is. Relative path from the root directory of the plugin or remote URL such as HTTP and S3. (required)</li> <li>bin: Which file to call when the plugin is executed. Relative path from the root directory of the plugin. (required)</li> </ul> <p>The following rules will apply in deciding which platform to select:</p> <ul> <li>If both <code>os</code> and <code>arch</code> under <code>selector</code> match the current platform, search will stop and the platform will be used.</li> <li>If <code>selector</code> is not present, the platform will be used.</li> <li>If <code>os</code> matches and there is no more specific <code>arch</code> match, the platform will be used.</li> <li>If no <code>platform</code> match is found, Trivy will exit with an error.</li> </ul> <p>After determining platform, Trivy will download the execution file from <code>uri</code> and store it in the plugin cache. When the plugin is called via Trivy CLI, <code>bin</code> command will be executed.</p> <p>The plugin is responsible for handling flags and arguments. Any arguments are passed to the plugin from the <code>trivy</code> command.</p>","title":"Building Plugins"},{"location":"docs/advanced/plugins/#example","text":"<p>https://github.com/aquasecurity/trivy-plugin-kubectl</p>","title":"Example"},{"location":"docs/advanced/container/embed-in-dockerfile/","text":"<p>Scan your image as part of the build process by embedding Trivy in the Dockerfile. This approach can be used to update Dockerfiles currently using Aqua\u2019s Microscanner.</p> <p><pre><code>$ cat Dockerfile\nFROM alpine:3.7\n\nRUN apk add curl \\\n && curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin \\\n && trivy rootfs --exit-code 1 --no-progress /\n\n$ docker build -t vulnerable-image .\n</code></pre> Alternatively you can use Trivy in a multistage build. Thus avoiding the insecure <code>curl | sh</code>. Also the image is not changed. <pre><code>[...]\n# Run vulnerability scan on build image\nFROM build AS vulnscan\nCOPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy\nRUN trivy rootfs --exit-code 1 --no-progress /\n[...]\n</code></pre></p>","title":"Embed in Dockerfile"},{"location":"docs/advanced/container/oci/","text":"<p>An image directory compliant with Open Container Image Layout Specification.</p> <p>Buildah:</p> <pre><code>$ buildah push docker.io/library/alpine:3.11 oci:/path/to/alpine\n$ trivy image --input /path/to/alpine\n</code></pre> <p>Skopeo:</p> <pre><code>$ skopeo copy docker-daemon:alpine:3.11 oci:/path/to/alpine\n$ trivy image --input /path/to/alpine\n</code></pre>","title":"OCI Image Layout"},{"location":"docs/advanced/container/podman/","text":"<p>EXPERIMENTAL</p> <p>This feature might change without preserving backwards compatibility.</p> <p>Scan your image in Podman (>=2.0) running locally. The remote Podman is not supported. Before performing Trivy commands, you must enable the podman.sock systemd service on your machine. For more details, see here.</p> <pre><code>$ systemctl --user enable --now podman.socket\n</code></pre> <p>Then, you can scan your image in Podman.</p> <pre><code>$ cat Dockerfile\nFROM alpine:3.12\nRUN apk add --no-cache bash\n$ podman build -t test .\n$ podman images\nREPOSITORY TAG IMAGE ID CREATED SIZE\nlocalhost/test latest efc372d4e0de About a minute ago 7.94 MB\n$ trivy image test\n</code></pre>","title":"Podman"},{"location":"docs/advanced/container/unpacked-filesystem/","text":"<p>Scan an unpacked container image filesystem.</p> <p>In this case, Trivy works the same way when scanning containers</p> <pre><code>$ docker export $(docker create alpine:3.10.2) | tar -C /tmp/rootfs -xvf -\n$ trivy rootfs /tmp/rootfs\n</code></pre> Result <pre><code>2021-03-08T05:22:26.378Z INFO Need to update DB\n2021-03-08T05:22:26.380Z INFO Downloading DB...\n20.37 MiB / 20.37 MiB [-------------------------------------------------------------------------------------------------------------------------------------] 100.00% 8.24 MiB p/s 2s\n2021-03-08T05:22:30.134Z INFO Detecting Alpine vulnerabilities...\n\n/tmp/rootfs (alpine 3.10.2)\n===========================\nTotal: 20 (UNKNOWN: 0, LOW: 2, MEDIUM: 10, HIGH: 8, CRITICAL: 0)\n\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n| libcrypto1.1 | CVE-2020-1967 | HIGH | 1.1.1c-r0 | 1.1.1g-r0 | openssl: Segmentation |\n| | | | | | fault in SSL_check_chain |\n| | | | | | causes denial of service |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-1967 |\n+ +------------------+ + +---------------+---------------------------------------+\n| | CVE-2021-23839 | | | 1.1.1j-r0 | openssl: incorrect SSLv2 |\n| | | | | | rollback protection |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23839 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23840 | | | | openssl: integer |\n| | | | | | overflow in CipherUpdate |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23840 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23841 | | | | openssl: NULL pointer dereference |\n| | | | | | in X509_issuer_and_serial_hash() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23841 |\n+ +------------------+----------+ +---------------+---------------------------------------+\n| | CVE-2019-1547 | MEDIUM | | 1.1.1d-r0 | openssl: side-channel weak |\n| | | | | | encryption vulnerability |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1547 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2019-1549 | | | | openssl: information |\n| | | | | | disclosure in fork() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1549 |\n+ +------------------+ + +---------------+---------------------------------------+\n| | CVE-2019-1551 | | | 1.1.1d-r2 | openssl: Integer overflow in RSAZ |\n| | | | | | modular exponentiation on x86_64 |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1551 |\n+ +------------------+ + +---------------+---------------------------------------+\n| | CVE-2020-1971 | | | 1.1.1i-r0 | openssl: EDIPARTYNAME |\n| | | | | | NULL pointer de-reference |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-1971 |\n+ +------------------+----------+ +---------------+---------------------------------------+\n| | CVE-2019-1563 | LOW | | 1.1.1d-r0 | openssl: information |\n| | | | | | disclosure in PKCS7_dataDecode |\n| | | | | | and CMS_decrypt_set1_pkey |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1563 |\n+--------------+------------------+----------+ +---------------+---------------------------------------+\n| libssl1.1 | CVE-2020-1967 | HIGH | | 1.1.1g-r0 | openssl: Segmentation |\n| | | | | | fault in SSL_check_chain |\n| | | | | | causes denial of service |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-1967 |\n+ +------------------+ + +---------------+---------------------------------------+\n| | CVE-2021-23839 | | | 1.1.1j-r0 | openssl: incorrect SSLv2 |\n| | | | | | rollback protection |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23839 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23840 | | | | openssl: integer |\n| | | | | | overflow in CipherUpdate |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23840 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23841 | | | | openssl: NULL pointer dereference |\n| | | | | | in X509_issuer_and_serial_hash() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23841 |\n+ +------------------+----------+ +---------------+---------------------------------------+\n| | CVE-2019-1547 | MEDIUM | | 1.1.1d-r0 | openssl: side-channel weak |\n| | | | | | encryption vulnerability |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1547 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2019-1549 | | | | openssl: information |\n| | | | | | disclosure in fork() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1549 |\n+ +------------------+ + +---------------+---------------------------------------+\n| | CVE-2019-1551 | | | 1.1.1d-r2 | openssl: Integer overflow in RSAZ |\n| | | | | | modular exponentiation on x86_64 |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1551 |\n+ +------------------+ + +---------------+---------------------------------------+\n| | CVE-2020-1971 | | | 1.1.1i-r0 | openssl: EDIPARTYNAME |\n| | | | | | NULL pointer de-reference |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-1971 |\n+ +------------------+----------+ +---------------+---------------------------------------+\n| | CVE-2019-1563 | LOW | | 1.1.1d-r0 | openssl: information |\n| | | | | | disclosure in PKCS7_dataDecode |\n| | | | | | and CMS_decrypt_set1_pkey |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1563 |\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n| musl | CVE-2020-28928 | MEDIUM | 1.1.22-r3 | 1.1.22-r4 | In musl libc through 1.2.1, |\n| | | | | | wcsnrtombs mishandles particular |\n| | | | | | combinations of destination buffer... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-28928 |\n+--------------+ + + + + +\n| musl-utils | | | | | |\n| | | | | | |\n| | | | | | |\n| | | | | | |\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n</code></pre>","title":"Unpacked Filesystem"},{"location":"docs/advanced/private-registries/","text":"<p>Trivy can download images from a private registry, without installing <code>Docker</code> or any other 3rd party tools. That's because it's easy to run in a CI process.</p> <p>All you have to do is install <code>Trivy</code> and set ENV vars.</p>","title":"Overview"},{"location":"docs/advanced/private-registries/acr/","text":"<p>None, Trivy uses Azure SDK for Go. You don't need to install <code>az</code> command.</p>","title":"Requirements"},{"location":"docs/advanced/private-registries/acr/#privileges","text":"<p>Service principal must have the <code>AcrPull</code> permissions.</p>","title":"Privileges"},{"location":"docs/advanced/private-registries/acr/#creation-of-a-service-principal","text":"<pre><code>export SP_DATA=$(az ad sp create-for-rbac --name TrivyTest --role AcrPull --scope \"/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.ContainerRegistry/registries/<registry_name>\")\n</code></pre>","title":"Creation of a service principal"},{"location":"docs/advanced/private-registries/acr/#usage","text":"<pre><code># must set TRIVY_USERNAME empty char\nexport AZURE_CLIENT_ID$(echo $SP_DATA | jq -r .appId)\nexport AZURE_CLIENT_SECRET$(echo $SP_DATA | jq -r .password)\nexport AZURE_TENANT_ID$(echo $SP_DATA | jq -r .tenant)\n</code></pre>","title":"Usage"},{"location":"docs/advanced/private-registries/acr/#testing","text":"<p>You can test credentials in the following manner.</p> <pre><code>docker run -it --rm -v /tmp:/tmp\\\n -e AZURE_CLIENT_ID=${AZURE_CLIENT_ID} -e AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET} \\\n -e AZURE_TENANT_ID=${AZURE_TENANT_ID} aquasec/trivy image your_special_project.azurecr.io/your_special_image:your_special_tag\n</code></pre>","title":"Testing"},{"location":"docs/advanced/private-registries/docker-hub/","text":"<p>Docker Hub needs <code>TRIVY_USERNAME</code> and <code>TRIVY_PASSWORD</code>. You don't need to set ENV vars when download from public repository.</p> <pre><code>export TRIVY_USERNAME={DOCKERHUB_USERNAME}\nexport TRIVY_PASSWORD={DOCKERHUB_PASSWORD}\n</code></pre>","title":"Docker Hub"},{"location":"docs/advanced/private-registries/ecr/","text":"<p>Trivy uses AWS SDK. You don't need to install <code>aws</code> CLI tool. You can use AWS CLI's ENV Vars.</p>","title":"AWS ECR (Elastic Container Registry)"},{"location":"docs/advanced/private-registries/gcr/","text":"<p>None, Trivy uses Google Cloud SDK. You don't need to install <code>gcloud</code> command.</p>","title":"Requirements"},{"location":"docs/advanced/private-registries/gcr/#privileges","text":"<p>Credential file must have the <code>roles/storage.objectViewer</code> permissions. More information can be found in Google's documentation</p>","title":"Privileges"},{"location":"docs/advanced/private-registries/gcr/#json-file-format","text":"<p>The JSON file specified should have the following format provided by google's service account mechanisms:</p> <pre><code>{\n \"type\": \"service_account\",\n \"project_id\": \"your_special_project\",\n \"private_key_id\": \"XXXXXXXXXXXXXXXXXXXXxx\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nNONONONO\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"somedude@your_special_project.iam.gserviceaccount.com\",\n \"client_id\": \"1234567890\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/somedude%40your_special_project.iam.gserviceaccount.com\"\n}\n</code></pre>","title":"JSON File Format"},{"location":"docs/advanced/private-registries/gcr/#usage","text":"<p>If you want to use target project's repository, you can set them via <code>GOOGLE_APPLICATION_CREDENTIALS</code>. <pre><code># must set TRIVY_USERNAME empty char\nexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/credential.json\n</code></pre></p>","title":"Usage"},{"location":"docs/advanced/private-registries/gcr/#testing","text":"<p>You can test credentials in the following manner (assuming they are in <code>/tmp</code> on host machine).</p> <pre><code>docker run -it --rm -v /tmp:/tmp\\\n -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/service_account.json\\\n aquasec/trivy image gcr.io/your_special_project/your_special_image:your_special_tag\n</code></pre>","title":"Testing"},{"location":"docs/advanced/private-registries/self/","text":"<p>BasicAuth server needs <code>TRIVY_USERNAME</code> and <code>TRIVY_PASSWORD</code>.</p> <pre><code>export TRIVY_USERNAME={USERNAME}\nexport TRIVY_PASSWORD={PASSWORD}\n\n# if you want to use 80 port, use NonSSL\nexport TRIVY_NON_SSL=true\n</code></pre>","title":"Self-Hosted"},{"location":"docs/integrations/","text":"<p>Scan your image automatically as part of your CI workflow, failing the workflow if a vulnerability is found. When you don't want to fail the test, specify <code>--exit-code 0</code>.</p>","title":"Integrations"},{"location":"docs/integrations/aws-codepipeline/","text":"<p>See this blog post for an example of using Trivy within AWS CodePipeline.</p>","title":"AWS CodePipeline"},{"location":"docs/integrations/aws-security-hub/","text":"","title":"AWS Security Hub"},{"location":"docs/integrations/aws-security-hub/#upload-findings-to-security-hub","text":"<p>In the following example using the template <code>asff.tpl</code>, ASFF file can be generated.</p> <pre><code>$ AWS_REGION=us-west-1 AWS_ACCOUNT_ID=123456789012 trivy image --format template --template \"@contrib/asff.tpl\" -o report.asff golang:1.12-alpine\n</code></pre> <p>ASFF template needs AWS_REGION and AWS_ACCOUNT_ID from environment variables.</p> <p>Then, you can upload it with AWS CLI.</p> <pre><code>$ aws securityhub batch-import-findings --findings file://report.asff\n</code></pre>","title":"Upload findings to Security Hub"},{"location":"docs/integrations/aws-security-hub/#customize","text":"<p>You can customize asff.tpl</p> <pre><code>$ export AWS_REGION=us-west-1\n$ export AWS_ACCOUNT_ID=123456789012\n$ trivy image --format template --template \"@your-asff.tpl\" -o report.asff golang:1.12-alpine\n</code></pre>","title":"Customize"},{"location":"docs/integrations/aws-security-hub/#reference","text":"<p>https://aws.amazon.com/blogs/security/how-to-build-ci-cd-pipeline-container-vulnerability-scanning-trivy-and-aws-security-hub/</p>","title":"Reference"},{"location":"docs/integrations/bitbucket/","text":"<p>See trivy-pipe for the details.</p>","title":"Bitbucket Pipelines"},{"location":"docs/integrations/circleci/","text":"<pre><code>$ cat .circleci/config.yml\njobs:\n build:\n docker:\n - image: docker:stable-git\n steps:\n - checkout\n - setup_remote_docker\n - run:\n name: Build image\n command: docker build -t trivy-ci-test:${CIRCLE_SHA1} .\n - run:\n name: Install trivy\n command: |\n apk add --update-cache --upgrade curl\n curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin\n - run:\n name: Scan the local image with trivy\n command: trivy image --exit-code 0 --no-progress trivy-ci-test:${CIRCLE_SHA1}\nworkflows:\n version: 2\n release:\n jobs:\n - build\n</code></pre> <p>Example Repository</p>","title":"CircleCI"},{"location":"docs/integrations/github-actions/","text":"<ul> <li>Here is the Trivy Github Action</li> <li>The Microsoft Azure team have written a container-scan action that uses Trivy and Dockle</li> <li>For full control over the options specified to Trivy, this blog post describes adding Trivy into your own GitHub action workflows </li> </ul>","title":"GitHub Actions"},{"location":"docs/integrations/gitlab-ci/","text":"<p>If you're a GitLab Ultimate customer, GitLab 14.0 and above include out-of-the-box integration with Trivy. To enable it for your project, simply add the container scanning template to your <code>.gitlab-ci.yml</code> file. For more details, please refer to GitLab's documentation.</p> <p>If you're using an earlier version of GitLab, you can still use the new integration by copying the contents of the 14.0 template to your configuration.</p> <p>Alternatively, you can always use the example configurations below.</p> <pre><code>stages:\n - test\n\ntrivy:\n stage: test\n image: docker:stable\n services:\n - name: docker:dind\n entrypoint: [\"env\", \"-u\", \"DOCKER_HOST\"]\n command: [\"dockerd-entrypoint.sh\"]\n variables:\n DOCKER_HOST: tcp://docker:2375/\n DOCKER_DRIVER: overlay2\n # See https://github.com/docker-library/docker/pull/166\n DOCKER_TLS_CERTDIR: \"\"\n IMAGE: trivy-ci-test:$CI_COMMIT_SHA\n TRIVY_NO_PROGRESS: \"true\"\n TRIVY_CACHE_DIR: \".trivycache/\"\n before_script:\n - export TRIVY_VERSION=$(wget -qO - \"https://api.github.com/repos/aquasecurity/trivy/releases/latest\" | grep '\"tag_name\":' | sed -E 's/.*\"v([^\"]+)\".*/\\1/')\n - echo $TRIVY_VERSION\n - wget --no-verbose https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz -O - | tar -zxvf -\n allow_failure: true\n script:\n # Build image\n - docker build -t $IMAGE .\n # Build report\n - ./trivy image --exit-code 0 --format template --template \"@contrib/gitlab.tpl\" -o gl-container-scanning-report.json $IMAGE\n # Print report\n - ./trivy image --exit-code 0 --severity HIGH $IMAGE\n # Fail on severe vulnerabilities\n - ./trivy image --exit-code 1 --severity CRITICAL $IMAGE\n cache:\n paths:\n - .trivycache/\n # Enables https://docs.gitlab.com/ee/user/application_security/container_scanning/ (Container Scanning report is available on GitLab EE Ultimate or GitLab.com Gold)\n artifacts:\n reports:\n container_scanning: gl-container-scanning-report.json\n</code></pre> <p>Example Repository</p>","title":"GitLab CI"},{"location":"docs/integrations/gitlab-ci/#gitlab-ci-using-trivy-container","text":"<p>To scan a previously built image that has already been pushed into the GitLab container registry the following CI job manifest can be used. Note that <code>entrypoint</code> needs to be unset for the <code>script</code> section to work. In case of a non-public GitLab project Trivy additionally needs to authenticate to the registry to be able to pull your application image. Finally, it is not necessary to clone the project repo as we only work with the container image.</p> <pre><code>container_scanning:\n image:\n name: docker.io/aquasec/trivy:latest\n entrypoint: [\"\"]\n variables:\n # No need to clone the repo, we exclusively work on artifacts. See\n # https://docs.gitlab.com/ee/ci/runners/README.html#git-strategy\n GIT_STRATEGY: none\n TRIVY_USERNAME: \"$CI_REGISTRY_USER\"\n TRIVY_PASSWORD: \"$CI_REGISTRY_PASSWORD\"\n TRIVY_AUTH_URL: \"$CI_REGISTRY\"\n TRIVY_NO_PROGRESS: \"true\"\n TRIVY_CACHE_DIR: \".trivycache/\"\n FULL_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG\n script:\n - trivy --version\n # cache cleanup is needed when scanning images with the same tags, it does not remove the database\n - time trivy image --clear-cache\n # update vulnerabilities db\n - time trivy image --download-db-only\n # Builds report and puts it in the default workdir $CI_PROJECT_DIR, so `artifacts:` can take it from there\n - time trivy image --exit-code 0 --format template --template \"@/contrib/gitlab.tpl\"\n --output \"$CI_PROJECT_DIR/gl-container-scanning-report.json\" \"$FULL_IMAGE_NAME\"\n # Prints full report\n - time trivy image --exit-code 0 \"$FULL_IMAGE_NAME\"\n # Fail on critical vulnerabilities\n - time trivy image --exit-code 1 --severity CRITICAL \"$FULL_IMAGE_NAME\"\n cache:\n paths:\n - .trivycache/\n # Enables https://docs.gitlab.com/ee/user/application_security/container_scanning/ (Container Scanning report is available on GitLab EE Ultimate or GitLab.com Gold)\n artifacts:\n when: always\n reports:\n container_scanning: gl-container-scanning-report.json\n tags:\n - docker-runner\n</code></pre>","title":"GitLab CI using Trivy container"},{"location":"docs/integrations/gitlab-ci/#gitlab-ci-alternative-template","text":"<p>Depending on the edition of gitlab you have or your desired workflow, the container scanning template may not meet your needs. As an addition to the above container scanning template, a template for code climate has been included. The key things to update from the above examples are the <code>template</code> and <code>report</code> type. An updated example is below.</p> <pre><code>stages:\n - test\n\ntrivy:\n stage: test\n image: docker:stable\n services:\n - name: docker:dind\n entrypoint: [\"env\", \"-u\", \"DOCKER_HOST\"]\n command: [\"dockerd-entrypoint.sh\"]\n variables:\n DOCKER_HOST: tcp://docker:2375/\n DOCKER_DRIVER: overlay2\n # See https://github.com/docker-library/docker/pull/166\n DOCKER_TLS_CERTDIR: \"\"\n IMAGE: trivy-ci-test:$CI_COMMIT_SHA\n TRIVY_NO_PROGRESS: \"true\"\n TRIVY_CACHE_DIR: \".trivycache/\"\n before_script:\n - export TRIVY_VERSION=$(wget -qO - \"https://api.github.com/repos/aquasecurity/trivy/releases/latest\" | grep '\"tag_name\":' | sed -E 's/.*\"v([^\"]+)\".*/\\1/')\n - echo $TRIVY_VERSION\n - wget --no-verbose https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz -O - | tar -zxvf -\n allow_failure: true\n script:\n # Build image\n - docker build -t $IMAGE .\n # Image report\n - ./trivy image --exit-code 0 --format template --template \"@contrib/gitlab-codequality.tpl\" -o gl-codeclimate-image.json $IMAGE\n # Filesystem report\n - ./trivy filesystem --security-checks config,vuln --exit-code 0 --format template --template \"@contrib/gitlab-codequality.tpl\" -o gl-codeclimate-fs.json .\n # Combine report\n - apk update && apk add jq\n - jq -s 'add' gl-codeclimate-image.json gl-codeclimate-fs.json > gl-codeclimate.json\n cache:\n paths:\n - .trivycache/\n # Enables https://docs.gitlab.com/ee/user/application_security/container_scanning/ (Container Scanning report is available on GitLab EE Ultimate or GitLab.com Gold)\n artifacts:\n paths:\n - gl-codeclimate.json\n reports:\n codequality: gl-codeclimate.json\n</code></pre> <p>Currently gitlab only supports a single code quality report. There is an open feature request to support multiple reports. Until this has been implemented, if you already have a code quality report in your pipeline, you can use <code>jq</code> to combine reports. Depending on how you name your artifacts, it may be necessary to rename the artifact if you want to reuse the name. To then combine the previous artifact with the output of trivy, the following <code>jq</code> command can be used, <code>jq -s 'add' prev-codeclimate.json trivy-codeclimate.json > gl-codeclimate.json</code>.</p>","title":"Gitlab CI alternative template"},{"location":"docs/integrations/gitlab-ci/#gitlab-ci-alternative-template-example-report","text":"<p>You'll be able to see a full report in the Gitlab pipeline code quality UI, where filesystem vulnerabilities and misconfigurations include links to the flagged files and image vulnerabilities report the image/os or runtime/library that the vulnerability originates from instead.</p> <p></p>","title":"Gitlab CI alternative template example report"},{"location":"docs/integrations/travis-ci/","text":"<pre><code>$ cat .travis.yml\nservices:\n - docker\n\nenv:\n global:\n - COMMIT=${TRAVIS_COMMIT::8}\n\nbefore_install:\n - docker build -t trivy-ci-test:${COMMIT} .\n - export VERSION=$(curl --silent \"https://api.github.com/repos/aquasecurity/trivy/releases/latest\" | grep '\"tag_name\":' | sed -E 's/.*\"v([^\"]+)\".*/\\1/')\n - wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-64bit.tar.gz\n - tar zxvf trivy_${VERSION}_Linux-64bit.tar.gz\nscript:\n - ./trivy image --exit-code 0 --severity HIGH --no-progress trivy-ci-test:${COMMIT}\n - ./trivy image --exit-code 1 --severity CRITICAL --no-progress trivy-ci-test:${COMMIT}\ncache:\n directories:\n - $HOME/.cache/trivy\n</code></pre> <p>Example Repository</p>","title":"Travis CI"},{"location":"docs/misconfiguration/","text":"<p>Trivy provides built-in policies to detect configuration issues in Docker, Kubernetes and Terraform. Also, you can write your own policies in Rego to scan JSON, YAML, HCL, etc, like Conftest.</p> <p></p>","title":"Misconfiguration Scanning"},{"location":"docs/misconfiguration/filesystem/","text":"","title":"Filesystem"},{"location":"docs/misconfiguration/filesystem/#quick-start","text":"<p>Trivy scans a filesystem such as a virtual machine to detect misconfigurations.</p> <p>You have to specify <code>--security-checks config</code> to enable misconfiguration detection.</p> <pre><code>$ trivy fs --security-checks config /path/to/dir\n</code></pre> <p>Internally, it is the same as config subcommand.</p>","title":"Quick start"},{"location":"docs/misconfiguration/filesystem/#vulnerability-and-misconfiguration-scanning","text":"<p>The difference between <code>fs</code> and <code>config</code> subcommand is that <code>fs</code> can detect both vulnerabilities and misconfiguration at the same time.</p> <p>You have to specify <code>--security-checks vuln,config</code> to enable vulnerability and misconfiguration detection.</p> <pre><code>$ ls myapp/\nDockerfile Pipfile.lock\n$ trivy fs --security-checks vuln,config --severity HIGH,CRITICAL myapp/\n2021-07-09T12:03:27.564+0300 INFO Detected OS: unknown\n2021-07-09T12:03:27.564+0300 INFO Number of language-specific files: 1\n2021-07-09T12:03:27.564+0300 INFO Detecting pipenv vulnerabilities...\n2021-07-09T12:03:27.566+0300 INFO Detected config files: 1\n\nPipfile.lock (pipenv)\n=====================\nTotal: 1 (HIGH: 1, CRITICAL: 0)\n\n+----------+------------------+----------+-------------------+---------------+---------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+----------+------------------+----------+-------------------+---------------+---------------------------------------+\n| httplib2 | CVE-2021-21240 | HIGH | 0.12.1 | 0.19.0 | python-httplib2: Regular |\n| | | | | | expression denial of |\n| | | | | | service via malicious header |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-21240 |\n+----------+------------------+----------+-------------------+---------------+---------------------------------------+\n\nDockerfile (dockerfile)\n=======================\nTests: 23 (SUCCESSES: 22, FAILURES: 1, EXCEPTIONS: 0)\nFailures: 1 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Last USER command in |\n| | | | | Dockerfile should not be 'root' |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n</code></pre> <p>In the above example, Trivy detected vulnerabilities of Python dependencies and misconfigurations in Dockerfile.</p>","title":"Vulnerability and Misconfiguration scanning"},{"location":"docs/misconfiguration/iac/","text":"","title":"Infrastructure as Code (IaC)"},{"location":"docs/misconfiguration/iac/#quick-start","text":"<p>Simply specify a directory containing IaC files such as Terraform, CloudFormation and Dockerfile.</p> <pre><code>$ trivy config [YOUR_IaC_DIRECTORY]\n</code></pre> <p>Trivy will automatically fetch the managed policies and will keep them up-to-date in future scans.</p> <p>Example</p> <pre><code>$ ls build/\nDockerfile\n$ trivy config ./build\n2021-07-09T10:06:29.188+0300 INFO Need to update the built-in policies\n2021-07-09T10:06:29.188+0300 INFO Downloading the built-in policies...\n2021-07-09T10:06:30.520+0300 INFO Detected config files: 1\n\nDockerfile (dockerfile)\n=======================\nTests: 23 (SUCCESSES: 22, FAILURES: 1, EXCEPTIONS: 0)\nFailures: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Last USER command in |\n| | | | | Dockerfile should not be 'root' |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n</code></pre>","title":"Quick start"},{"location":"docs/misconfiguration/iac/#type-detection","text":"<p>The specified directory can contain mixed types of IaC files. Trivy automatically detects config types and applies relevant policies.</p> <p>For example, the following example holds IaC files for Terraform, CloudFormation, Kubernetes, and Dockerfile in the same directory.</p> <pre><code>$ ls iac/\nDockerfile deployment.yaml main.tf\n$ trivy conf --severity HIGH,CRITICAL ./iac\n</code></pre> Result <pre><code>2021-07-09T11:51:08.212+0300 INFO Need to update the built-in policies\n2021-07-09T11:51:08.212+0300 INFO Downloading the built-in policies...\n2021-07-09T11:51:09.527+0300 INFO Detected config files: 3\n\nDockerfile (dockerfile)\n=======================\nTests: 23 (SUCCESSES: 22, FAILURES: 1, EXCEPTIONS: 0)\nFailures: 1 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Last USER command in |\n| | | | | Dockerfile should not be 'root' |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n\ndeployment.yaml (kubernetes)\n============================\nTests: 28 (SUCCESSES: 15, FAILURES: 13, EXCEPTIONS: 0)\nFailures: 13 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------------+----------+------------------------------------------+\n| Kubernetes Security Check | KSV005 | SYS_ADMIN capability added | HIGH | Container 'hello-kubernetes' of |\n| | | | | Deployment 'hello-kubernetes' |\n| | | | | should not include 'SYS_ADMIN' in |\n| | | | | 'securityContext.capabilities.add' |\n| | | | | -->avd.aquasec.com/appshield/ksv005 |\n+---------------------------+------------+----------------------------+----------+------------------------------------------+\n\nmain.tf (terraform)\n===================\nTests: 23 (SUCCESSES: 14, FAILURES: 9, EXCEPTIONS: 0)\nFailures: 9 (HIGH: 6, CRITICAL: 1)\n\n+------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+\n| Terraform Security Check powered by | AWS003 | AWS Classic resource usage. | HIGH | Resource |\n| tfsec | | | | 'aws_db_security_group.my-group' |\n| | | | | uses EC2 Classic. Use a VPC instead. |\n| | | | | -->tfsec.dev/docs/aws/AWS003/ |\n+ +------------+------------------------------------------+----------+--------------------------------------------------------+\n| | AWS004 | Use of plain HTTP. | CRITICAL | Resource |\n| | | | | 'aws_alb_listener.my-alb-listener' |\n| | | | | uses plain HTTP instead of HTTPS. |\n| | | | | -->tfsec.dev/docs/aws/AWS004/ |\n+ +------------+------------------------------------------+----------+--------------------------------------------------------+\n| | AWS018 | Missing description for security | HIGH | Resource |\n| | | group/security group rule. | | 'aws_security_group_rule.my-rule' should |\n| | | | | include a description for auditing |\n| | | | | purposes. -->tfsec.dev/docs/aws/AWS018/ |\n+ +------------+------------------------------------------+ +--------------------------------------------------------+\n| | AWS025 | API Gateway domain name uses outdated | | Resource |\n| | | SSL/TLS protocols. | | 'aws_api_gateway_domain_name.empty_security_policy' |\n| | | | | defines outdated SSL/TLS policies (not using |\n| | | | | TLS_1_2). -->tfsec.dev/docs/aws/AWS025/ |\n+ + + + +--------------------------------------------------------+\n| | | | | Resource |\n| | | | | 'aws_api_gateway_domain_name.missing_security_policy' |\n| | | | | should include security_policy (defaults to outdated |\n| | | | | SSL/TLS policy). -->tfsec.dev/docs/aws/AWS025/ |\n+ + + + +--------------------------------------------------------+\n| | | | | Resource |\n| | | | | 'aws_api_gateway_domain_name.outdated_security_policy' |\n| | | | | defines outdated SSL/TLS policies (not using TLS_1_2). |\n| | | | | -->tfsec.dev/docs/aws/AWS025/ |\n+ +------------+------------------------------------------+ +--------------------------------------------------------+\n| | AZU003 | Unencrypted managed disk. | | Resource 'azurerm_managed_disk.source' |\n| | | | | defines an unencrypted managed disk. |\n| | | | | -->tfsec.dev/docs/azure/AZU003/ |\n+------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+\n</code></pre> <p>You can see the config type next to each file name.</p> <p>Example</p> <pre><code>Dockerfile (dockerfile)\n=======================\nTests: 23 (SUCCESSES: 22, FAILURES: 1, EXCEPTIONS: 0)\nFailures: 1 (HIGH: 1, CRITICAL: 0)\n\n...\n\ndeployment.yaml (kubernetes)\n============================\nTests: 28 (SUCCESSES: 15, FAILURES: 13, EXCEPTIONS: 0)\nFailures: 13 (HIGH: 1, CRITICAL: 0)\n\n...\n\nmain.tf (terraform)\n===================\nTests: 23 (SUCCESSES: 14, FAILURES: 9, EXCEPTIONS: 0)\nFailures: 9 (HIGH: 6, CRITICAL: 1)\n\n...\n\nbucket.yaml (cloudformation)\n============================\nTests: 9 (SUCCESSES: 3, FAILURES: 6, EXCEPTIONS: 0)\nFailures: 6 (UNKNOWN: 0, LOW: 0, MEDIUM: 2, HIGH: 4, CRITICAL: 0)\n</code></pre>","title":"Type detection"},{"location":"docs/misconfiguration/iac/#example","text":"<p>See here</p>","title":"Example"},{"location":"docs/misconfiguration/comparison/cfsec/","text":"<p>cfsec uses static analysis of your CloudFormation templates to spot potential security issues. Trivy uses cfsec internally to scan both JSON and YAML configuration files, but Trivy doesn't support some features provided by cfsec. This section describes the differences between Trivy and cfsec.</p> Feature Trivy cfsec Built-in Policies Custom Policies Rego1 Policy Metadata2 Show Successes Disable Policies Show Issue Lines View Statistics Filtering by Severity Supported Formats Dockerfile, JSON, YAML, Terraform, etc. CloudFormation JSON and YAML <p>cfsec is designed for CloudFormation. People who use only want to scan their CloudFormation templates should use cfsec. People who want to scan a wide range of configuration files should use Trivy.</p> <ol> <li> <p>CloudFormation files are not supported\u00a0\u21a9</p> </li> <li> <p>To enrich the results such as ID, Title, Description, Severity, etc.\u00a0\u21a9</p> </li> </ol>","title":"vs cfsec"},{"location":"docs/misconfiguration/comparison/conftest/","text":"<p>Conftest is a really nice tool to help you write tests against structured configuration data. Misconfiguration detection in Trivy is heavily inspired by Conftest and provides similar features Conftest has. This section describes the differences between Trivy and Conftest.</p> Feature Trivy Conftest Support Rego Language Built-in Policies Custom Policies Custom Data Combine Combine per Policy Policy Input Selector1 Policy Metadata2 3 Filtering by Severity Rule-based Exceptions Namespace-based Exceptions Sharing Policies Show Successes Flexible Exit Code Rego Unit Tests 4 Go Testing Verbose Trace Supported Formats 6 formats5 14 formats6 <p>Trivy offers built-in policies and a variety of options, while Conftest only supports custom policies. In other words, Conftest is simpler and lighter.</p> <p>Conftest is a general testing tool for configuration files, and Trivy is more security-focused. People who need an out-of-the-box misconfiguration scanner should use Trivy. People who don't need built-in policies and write your policies should use Conftest.</p> <ol> <li> <p>Pass only the types of configuration file as input, specified in selector\u00a0\u21a9</p> </li> <li> <p>To enrich the results such as ID, Title, Description, etc.\u00a0\u21a9</p> </li> <li> <p>Conftest supports structured errors in rules, but they are free format and not natively supported by Conftest.\u00a0\u21a9</p> </li> <li> <p>Trivy is not able to run <code>*_test.rego</code> like <code>conftest verify</code>.\u00a0\u21a9</p> </li> <li> <p>Dockerfile, HCL, HCL2, JSON, TOML, and YAML\u00a0\u21a9</p> </li> <li> <p>CUE, Dockerfile, EDN, HCL, HCL2, HOCON, Ignore files, INI, JSON, Jsonnet, TOML, VCL, XML, and YAML\u00a0\u21a9</p> </li> </ol>","title":"vs Conftest"},{"location":"docs/misconfiguration/comparison/tfsec/","text":"<p>tfsec uses static analysis of your Terraform templates to spot potential security issues. Trivy uses tfsec internally to scan Terraform HCL files, but Trivy doesn't support some features provided by tfsec. This section describes the differences between Trivy and tfsec.</p> Feature Trivy tfsec Built-in Policies Custom Policies Rego1 JSON and YAML Policy Metadata2 Show Successes Disable Policies Show Issue Lines Support .tfvars View Statistics Filtering by Severity Supported Formats Dockerfile, JSON, YAML, Terraform, etc. Terraform <p>tfsec is designed for Terraform. People who use only Terraform should use tfsec. People who want to scan a wide range of configuration files should use Trivy.</p> <ol> <li> <p>Terraform HCL files are not supported.\u00a0\u21a9</p> </li> <li> <p>To enrich the results such as ID, Title, Description, Severity, etc.\u00a0\u21a9</p> </li> </ol>","title":"vs tfsec"},{"location":"docs/misconfiguration/custom/","text":"","title":"Custom Policies"},{"location":"docs/misconfiguration/custom/#overview","text":"<p>You can write custom policies in Rego. Once you finish writing custom policies, you can pass the directory where those policies are stored with <code>--policy</code> option.</p> <pre><code>trivy conf --policy /path/to/custom_policies --namespaces user /path/to/config_dir\n</code></pre> <p>As for <code>--namespaces</code> option, the detail is described as below.</p>","title":"Overview"},{"location":"docs/misconfiguration/custom/#file-formats","text":"<p>If a file name matches the following file patterns, Trivy will parse the file and pass it as input to your Rego policy.</p> File format File pattern JSON <code>*.json</code> YAML <code>*.yaml</code> TOML <code>*.toml</code> HCL <code>*.hcl</code>, <code>*.hcl1</code>, and <code>*.hcl2</code> Dockerfile <code>Dockerfile</code>, <code>Dockerfile.*</code>, and <code>*.Dockerfile</code>","title":"File formats"},{"location":"docs/misconfiguration/custom/#configuration-languages","text":"<p>In the above general file formats, Trivy automatically identifies the following types of configuration files:</p> <ul> <li>Ansible (YAML)</li> <li>CloudFormation (JSON/YAML)</li> <li>Kubernetes (JSON/YAML)</li> </ul> <p>This is useful for filtering inputs, as described below.</p> <p>Warning</p> <p>Custom policies do not support Terraform at the moment.</p>","title":"Configuration languages"},{"location":"docs/misconfiguration/custom/#rego-format","text":"<p>A single package must contain only one policy.</p> <p>Example</p> <pre><code>package user.kubernetes.ID001\n\n__rego_metadata__ := {\n \"id\": \"ID001\",\n \"title\": \"Deployment not allowed\",\n \"severity\": \"LOW\",\n \"type\": \"Custom Kubernetes Check\",\n \"description\": \"Deployments are not allowed because of some reasons.\",\n}\n\n__rego_input__ := {\n \"selector\": [\n {\"type\": \"kubernetes\"},\n ],\n}\n\ndeny[msg] {\n input.kind == \"Deployment\"\n msg = sprintf(\"Found deployment '%s' but deployments are not allowed\", [input.metadata.name])\n}\n</code></pre> <p>In this example, ID001 \"Deployment not allowed\" is defined under <code>user.kubernetes.ID001</code>. If you add a new custom policy, it must be defined under a new package like <code>user.kubernetes.ID002</code>.</p>","title":"Rego format"},{"location":"docs/misconfiguration/custom/#policy-structure","text":"<code>package</code> (required) <ul> <li>MUST follow the Rego's specification</li> <li>MUST be unique per policy</li> <li>SHOULD include policy id for uniqueness</li> <li>MAY include the group name such as <code>kubernetes</code> for clarity<ul> <li>Group name has no effect on policy evaluation</li> </ul> </li> </ul> <code>__rego_metadata__</code> (optional) <ul> <li>SHOULD be defined for clarity since these values will be displayed in the scan results</li> </ul> <code>__rego_input__</code> (optional) <ul> <li>MAY be defined when you want to specify input format</li> </ul> <code>deny</code> (required) <ul> <li>SHOULD be <code>deny</code> or start with <code>deny_</code><ul> <li>Although <code>warn</code>, <code>warn_*</code>, <code>violation</code>, <code>violation_</code> also work for compatibility, <code>deny</code> is recommended as severity can be defined in <code>__rego_metadata__</code>.</li> </ul> </li> <li>SHOULD return <code>string</code><ul> <li>Although <code>object</code> with <code>msg</code> field is accepted, other fields are dropped and <code>string</code> is recommended.</li> <li>e.g. <code>{\"msg\": \"deny message\", \"details\": \"something\"}</code></li> </ul> </li> </ul>","title":"Policy structure"},{"location":"docs/misconfiguration/custom/#package","text":"<p>A package name must be unique per policy.</p> <p>Example</p> <pre><code>package user.kubernetes.ID001\n</code></pre> <p>By default, only <code>appshield.*</code> packages will be evaluated. If you define custom packages, you have to specify the package prefix via <code>--namespaces</code> option. </p> <pre><code>trivy conf --policy /path/to/custom_policies --namespaces user /path/to/config_dir\n</code></pre> <p>In this case, <code>user.*</code> will be evaluated. Any package prefixes such as <code>main</code> and <code>user</code> are allowed.</p>","title":"Package"},{"location":"docs/misconfiguration/custom/#metadata","text":"<p>Metadata helps enrich Trivy's scan results with useful information.</p> <p>Example</p> <pre><code>__rego_metadata__ := {\n \"id\": \"ID001\",\n \"title\": \"Deployment not allowed\",\n \"severity\": \"LOW\",\n \"type\": \"Custom Kubernetes Check\",\n \"description\": \"Deployments are not allowed because of some reasons.\",\n \"recommended_actions\": \"Remove Deployment\",\n \"url\": \"https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-resource-requests-and-limits\",\n}\n</code></pre> <p>All fields under <code>__rego_metadata__</code> are optional.</p> Field name Allowed values Default value In table In JSON id Any characters N/A title Any characters N/A severity <code>LOW</code>, <code>MEDIUM</code>, <code>HIGH</code>, <code>CRITICAL</code> UNKNOWN type Any characters N/A description Any characters recommended_actions Any characters url Any characters <p>Some fields are displayed in scan results.</p> <pre><code>deployment.yaml (kubernetes)\n============================\nTests: 28 (SUCCESSES: 14, FAILURES: 14, EXCEPTIONS: 0)\nFailures: 14 (HIGH: 1)\n\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n| Custom Kubernetes Check | ID001 | Deployment not allowed | LOW | Found deployment 'test' but deployments |\n| | | | | are not allowed |\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n</code></pre>","title":"Metadata"},{"location":"docs/misconfiguration/custom/#input","text":"<p>You can specify input format via <code>__rego_input__</code>. All fields under <code>__rego_input</code> are optional.</p> <p>Example</p> <pre><code>__rego_input__ := {\n \"combine\": false,\n \"selector\": [\n {\"type\": \"kubernetes\"},\n ],\n}\n</code></pre> <code>combine</code> (boolean) The details is here. <code>selector</code> (array) <p>This option filters the input by file formats or configuration languages. In the above example, Trivy passes only Kubernetes files to this policy. Even if Dockerfile exists in the specified directory, it will not be passed to the policy as input.</p> <p>When configuration language such as Kubernetes is not identified, file format such as JSON will be used as <code>type</code>. When configuration language is identified, it will overwrite <code>type</code>.</p> <p>Example</p> <p><code>pod.yaml</code> including Kubernetes Pod will be handled as <code>kubernetes</code>, not <code>yaml</code>. <code>type</code> is overwritten by <code>kubernetes</code> from <code>yaml</code>.</p> <p><code>type</code> accepts <code>kubernetes</code>, <code>dockerfile</code>, <code>ansible</code>, <code>cloudformation</code>, <code>json</code>, <code>yaml</code>, <code>toml</code>, or <code>hcl</code>.</p>","title":"Input"},{"location":"docs/misconfiguration/custom/combine/","text":"","title":"Combined input"},{"location":"docs/misconfiguration/custom/combine/#overview","text":"<p>Trivy usually scans each configuration file individually. Sometimes it might be useful to compare values from different configuration files simultaneously.</p> <p>When <code>combine</code> is set to true, all config files under the specified directory are combined into one input data structure.</p> <p>Example</p> <pre><code>__rego_input__ := {\n \"combine\": false,\n}\n</code></pre> <p>In \"combine\" mode, the <code>input</code> document becomes an array, where each element is an object with two fields:</p> <ul> <li><code>\"path\": \"path/to/file\"</code>: the relative file path of the respective file</li> <li><code>\"contents\": ...</code>: the parsed content of the respective file</li> </ul> <p>Now you can ensure that duplicate values match across the entirety of your configuration files.</p>","title":"Overview"},{"location":"docs/misconfiguration/custom/combine/#return-value","text":"<p>In \"combine\" mode, the <code>deny</code> entrypoint must return an object with two keys</p> <code>filepath</code> (required) the relative file path of the file being evaluated <code>msg</code> (required) the message describing an issue <p>Example</p> <pre><code>deny[res] {\n resource := input[i].contents\n ... some logic ...\n\n res := {\n \"filepath\": input[i].path,\n \"msg\": \"something bad\",\n }\n}\n</code></pre>","title":"Return value"},{"location":"docs/misconfiguration/custom/data/","text":"<p>Custom policies may require additional data in order to determine an answer.</p> <p>For example, an allowed list of resources that can be created. Instead of hardcoding this information inside of your policy, Trivy allows passing paths to data files with the <code>--data</code> flag.</p> <p>Given the following yaml file:</p> <pre><code>$ cd examples/misconf/custom-data\n$ cat data/ports.yaml [~/src/github.com/aquasecurity/trivy/examples/misconf/custom-data]\nservices:\n ports:\n - \"20\"\n - \"20/tcp\"\n - \"20/udp\"\n - \"23\"\n - \"23/tcp\"\n</code></pre> <p>This can be imported into your policy:</p> <pre><code>import data.services\n\nports := services.ports\n</code></pre> <p>Then, you need to pass data paths through <code>--data</code> option. Trivy recursively searches the specified paths for JSON (<code>*.json</code>) and YAML (<code>*.yaml</code>) files.</p> <pre><code>$ trivy conf --policy ./policy --data data --namespaces user ./configs\n</code></pre>","title":"Custom Data"},{"location":"docs/misconfiguration/custom/debug/","text":"<p>When working on more complex queries (or when learning Rego), it's useful to see exactly how the policy is applied. For this purpose you can use the <code>--trace</code> flag. This will output a large trace from Open Policy Agent like the following:</p> <p>Tip</p> <p>Only failed policies show traces. If you want to debug a passed policy, you need to make it fail on purpose.</p> <pre><code>$ trivy conf --trace configs/\n2021-07-11T16:45:58.493+0300 INFO Detected config files: 1\n\nDockerfile (dockerfile)\n=======================\nTests: 23 (SUCCESSES: 22, FAILURES: 1, EXCEPTIONS: 0)\nFailures: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Last USER command in |\n| | | | | Dockerfile should not be 'root' |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n\nID: DS002\nFile: Dockerfile\nNamespace: appshield.dockerfile.DS002\nQuery: data.appshield.dockerfile.DS002.deny\nMessage: Last USER command in Dockerfile should not be 'root'\nTRACE Enter data.appshield.dockerfile.DS002.deny = _\nTRACE | Eval data.appshield.dockerfile.DS002.deny = _\nTRACE | Index data.appshield.dockerfile.DS002.deny matched 2 rules)\nTRACE | Enter data.appshield.dockerfile.DS002.deny\nTRACE | | Eval data.appshield.dockerfile.DS002.fail_user_count\nTRACE | | Index data.appshield.dockerfile.DS002.fail_user_count (matched 1 rule)\nTRACE | | Enter data.appshield.dockerfile.DS002.fail_user_count\nTRACE | | | Eval __local559__ = data.appshield.dockerfile.DS002.get_user\nTRACE | | | Index data.appshield.dockerfile.DS002.get_user (matched 1 rule)\nTRACE | | | Enter data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Eval user = data.lib.docker.user[_]\nTRACE | | | | Index data.lib.docker.user (matched 1 rule)\nTRACE | | | | Enter data.lib.docker.user\nTRACE | | | | | Eval instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Exit data.lib.docker.user\nTRACE | | | | Eval username = user.Value[_]\nTRACE | | | | Exit data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Redo username = user.Value[_]\nTRACE | | | | Redo user = data.lib.docker.user[_]\nTRACE | | | | Redo data.lib.docker.user\nTRACE | | | | | Redo instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Exit data.lib.docker.user\nTRACE | | | | Eval username = user.Value[_]\nTRACE | | | | Exit data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Redo username = user.Value[_]\nTRACE | | | | Redo user = data.lib.docker.user[_]\nTRACE | | | | Redo data.lib.docker.user\nTRACE | | | | | Redo instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | Eval count(__local559__, __local391__)\nTRACE | | | Eval lt(__local391__, 1)\nTRACE | | | Fail lt(__local391__, 1)\nTRACE | | | Redo count(__local559__, __local391__)\nTRACE | | | Redo __local559__ = data.appshield.dockerfile.DS002.get_user\nTRACE | | Fail data.appshield.dockerfile.DS002.fail_user_count\nTRACE | Enter data.appshield.dockerfile.DS002.deny\nTRACE | | Eval data.appshield.dockerfile.DS002.fail_last_user_root\nTRACE | | Index data.appshield.dockerfile.DS002.fail_last_user_root (matched 1 rule)\nTRACE | | Enter data.appshield.dockerfile.DS002.fail_last_user_root\nTRACE | | | Eval __local560__ = data.appshield.dockerfile.DS002.get_user\nTRACE | | | Index data.appshield.dockerfile.DS002.get_user (matched 1 rule)\nTRACE | | | Enter data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Eval user = data.lib.docker.user[_]\nTRACE | | | | Index data.lib.docker.user (matched 1 rule)\nTRACE | | | | Enter data.lib.docker.user\nTRACE | | | | | Eval instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Exit data.lib.docker.user\nTRACE | | | | Eval username = user.Value[_]\nTRACE | | | | Exit data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Redo username = user.Value[_]\nTRACE | | | | Redo user = data.lib.docker.user[_]\nTRACE | | | | Redo data.lib.docker.user\nTRACE | | | | | Redo instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Exit data.lib.docker.user\nTRACE | | | | Eval username = user.Value[_]\nTRACE | | | | Exit data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Redo username = user.Value[_]\nTRACE | | | | Redo user = data.lib.docker.user[_]\nTRACE | | | | Redo data.lib.docker.user\nTRACE | | | | | Redo instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | Eval cast_array(__local560__, __local392__)\nTRACE | | | Eval user = __local392__\nTRACE | | | Eval __local561__ = data.appshield.dockerfile.DS002.get_user\nTRACE | | | Index data.appshield.dockerfile.DS002.get_user (matched 1 rule)\nTRACE | | | Enter data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Eval user = data.lib.docker.user[_]\nTRACE | | | | Index data.lib.docker.user (matched 1 rule)\nTRACE | | | | Enter data.lib.docker.user\nTRACE | | | | | Eval instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Exit data.lib.docker.user\nTRACE | | | | Eval username = user.Value[_]\nTRACE | | | | Exit data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Redo username = user.Value[_]\nTRACE | | | | Redo user = data.lib.docker.user[_]\nTRACE | | | | Redo data.lib.docker.user\nTRACE | | | | | Redo instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Exit data.lib.docker.user\nTRACE | | | | Eval username = user.Value[_]\nTRACE | | | | Exit data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo data.appshield.dockerfile.DS002.get_user\nTRACE | | | | Redo username = user.Value[_]\nTRACE | | | | Redo user = data.lib.docker.user[_]\nTRACE | | | | Redo data.lib.docker.user\nTRACE | | | | | Redo instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | | | Eval instruction.Cmd = \"user\"\nTRACE | | | | | Fail instruction.Cmd = \"user\"\nTRACE | | | | | Redo instruction = input.stages[_][_]\nTRACE | | | Eval count(__local561__, __local393__)\nTRACE | | | Eval len = __local393__\nTRACE | | | Eval minus(len, 1, __local394__)\nTRACE | | | Eval user[__local394__] = \"root\"\nTRACE | | | Exit data.appshield.dockerfile.DS002.fail_last_user_root\nTRACE | | Eval res = \"Last USER command in Dockerfile should not be 'root'\"\nTRACE | | Exit data.appshield.dockerfile.DS002.deny\nTRACE | Redo data.appshield.dockerfile.DS002.deny\nTRACE | | Redo res = \"Last USER command in Dockerfile should not be 'root'\"\nTRACE | | Redo data.appshield.dockerfile.DS002.fail_last_user_root\nTRACE | | Redo data.appshield.dockerfile.DS002.fail_last_user_root\nTRACE | | | Redo user[__local394__] = \"root\"\nTRACE | | | Redo minus(len, 1, __local394__)\nTRACE | | | Redo len = __local393__\nTRACE | | | Redo count(__local561__, __local393__)\nTRACE | | | Redo __local561__ = data.appshield.dockerfile.DS002.get_user\nTRACE | | | Redo user = __local392__\nTRACE | | | Redo cast_array(__local560__, __local392__)\nTRACE | | | Redo __local560__ = data.appshield.dockerfile.DS002.get_user\nTRACE | Exit data.appshield.dockerfile.DS002.deny = _\nTRACE Redo data.appshield.dockerfile.DS002.deny = _\nTRACE | Redo data.appshield.dockerfile.DS002.deny = _\n</code></pre>","title":"Debugging policies"},{"location":"docs/misconfiguration/custom/examples/","text":"","title":"Examples"},{"location":"docs/misconfiguration/custom/examples/#custom-policy","text":"","title":"Custom Policy"},{"location":"docs/misconfiguration/custom/examples/#kubernetes","text":"<p>See here.</p> <p>The custom policy is defined in <code>user.kubernetes.ID001</code> package. You need to pass the package prefix you want to evaluate through <code>--namespaces</code> option. In this case, the package prefix should be <code>user</code>, <code>user.kuberntes</code>, or <code>user.kubernetes.ID001</code>.</p>","title":"Kubernetes"},{"location":"docs/misconfiguration/custom/examples/#dockerfile","text":"<p>See here.</p> <p>The input will be a dictionary of stages.</p>","title":"Dockerfile"},{"location":"docs/misconfiguration/custom/examples/#single-stage","text":"Example <p>Dockerfile <pre><code>FROM foo\nCOPY . /\nRUN echo hello\n</code></pre></p> <p>Rego Input <pre><code>{\n \"stages\": {\n \"foo\": [\n {\n \"Cmd\": \"from\",\n \"EndLine\": 1,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"FROM foo\",\n \"Stage\": 0,\n \"StartLine\": 1,\n \"SubCmd\": \"\",\n \"Value\": [\n \"foo\"\n ]\n },\n {\n \"Cmd\": \"copy\",\n \"EndLine\": 2,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"COPY . /\",\n \"Stage\": 0,\n \"StartLine\": 2,\n \"SubCmd\": \"\",\n \"Value\": [\n \".\",\n \"/\"\n ]\n },\n {\n \"Cmd\": \"run\",\n \"EndLine\": 3,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"RUN echo hello\",\n \"Stage\": 0,\n \"StartLine\": 3,\n \"SubCmd\": \"\",\n \"Value\": [\n \"echo hello\"\n ]\n }\n ]\n }\n}\n</code></pre></p>","title":"Single Stage"},{"location":"docs/misconfiguration/custom/examples/#multi-stage","text":"Example <p>Dockerfile <pre><code>FROM golang:1.16 AS builder\nWORKDIR /go/src/github.com/alexellis/href-counter/\nRUN go get -d -v golang.org/x/net/html\nCOPY app.go .\nRUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .\n\nFROM alpine:latest\nRUN apk --no-cache add ca-certificates \\\n&& apk add --no-cache bash\nWORKDIR /root/\nCOPY --from=builder /go/src/github.com/alexellis/href-counter/app .\nCMD [\"./app\"]\n</code></pre></p> <p>Rego Input <pre><code>{\n \"stages\": {\n \"alpine:latest\": [\n {\n \"Cmd\": \"from\",\n \"EndLine\": 7,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"FROM alpine:latest\",\n \"Stage\": 1,\n \"StartLine\": 7,\n \"SubCmd\": \"\",\n \"Value\": [\n \"alpine:latest\"\n ]\n },\n {\n \"Cmd\": \"run\",\n \"EndLine\": 9,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"RUN apk --no-cache add ca-certificates \\u0026\\u0026 apk add --no-cache bash\",\n \"Stage\": 1,\n \"StartLine\": 8,\n \"SubCmd\": \"\",\n \"Value\": [\n \"apk --no-cache add ca-certificates \\u0026\\u0026 apk add --no-cache bash\"\n ]\n },\n {\n \"Cmd\": \"workdir\",\n \"EndLine\": 10,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"WORKDIR /root/\",\n \"Stage\": 1,\n \"StartLine\": 10,\n \"SubCmd\": \"\",\n \"Value\": [\n \"/root/\"\n ]\n },\n {\n \"Cmd\": \"copy\",\n \"EndLine\": 11,\n \"Flags\": [\n \"--from=builder\"\n ],\n \"JSON\": false,\n \"Original\": \"COPY --from=builder /go/src/github.com/alexellis/href-counter/app .\",\n \"Stage\": 1,\n \"StartLine\": 11,\n \"SubCmd\": \"\",\n \"Value\": [\n \"/go/src/github.com/alexellis/href-counter/app\",\n \".\"\n ]\n },\n {\n \"Cmd\": \"cmd\",\n \"EndLine\": 12,\n \"Flags\": [],\n \"JSON\": true,\n \"Original\": \"CMD [\\\"./app\\\"]\",\n \"Stage\": 1,\n \"StartLine\": 12,\n \"SubCmd\": \"\",\n \"Value\": [\n \"./app\"\n ]\n }\n ],\n \"golang:1.16 AS builder\": [\n {\n \"Cmd\": \"from\",\n \"EndLine\": 1,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"FROM golang:1.16 AS builder\",\n \"Stage\": 0,\n \"StartLine\": 1,\n \"SubCmd\": \"\",\n \"Value\": [\n \"golang:1.16\",\n \"AS\",\n \"builder\"\n ]\n },\n {\n \"Cmd\": \"workdir\",\n \"EndLine\": 2,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"WORKDIR /go/src/github.com/alexellis/href-counter/\",\n \"Stage\": 0,\n \"StartLine\": 2,\n \"SubCmd\": \"\",\n \"Value\": [\n \"/go/src/github.com/alexellis/href-counter/\"\n ]\n },\n {\n \"Cmd\": \"run\",\n \"EndLine\": 3,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"RUN go get -d -v golang.org/x/net/html\",\n \"Stage\": 0,\n \"StartLine\": 3,\n \"SubCmd\": \"\",\n \"Value\": [\n \"go get -d -v golang.org/x/net/html\"\n ]\n },\n {\n \"Cmd\": \"copy\",\n \"EndLine\": 4,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"COPY app.go .\",\n \"Stage\": 0,\n \"StartLine\": 4,\n \"SubCmd\": \"\",\n \"Value\": [\n \"app.go\",\n \".\"\n ]\n },\n {\n \"Cmd\": \"run\",\n \"EndLine\": 5,\n \"Flags\": [],\n \"JSON\": false,\n \"Original\": \"RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .\",\n \"Stage\": 0,\n \"StartLine\": 5,\n \"SubCmd\": \"\",\n \"Value\": [\n \"CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .\"\n ]\n }\n ]\n }\n}\n</code></pre></p>","title":"Multi Stage"},{"location":"docs/misconfiguration/custom/examples/#docker-compose","text":"<p>See here.</p> <p>Docker Compose uses YAML format for configurations. You can apply your Rego policies to <code>docker-compose.yml</code>.</p>","title":"Docker Compose"},{"location":"docs/misconfiguration/custom/examples/#hcl","text":"<p>See here.</p> <p>Trivy parses HCL files and converts into structured data.</p> <p>Warning</p> <p>Terraform HCL files are not supported yet.</p>","title":"HCL"},{"location":"docs/misconfiguration/custom/examples/#terraform-plan","text":"<p>See here.</p> <p>Use the command terraform show to convert the Terraform plan into JSON so that OPA can read the plan.</p> <pre><code>$ terraform init\n$ terraform plan --out tfplan.binary\n$ terraform show -json tfplan.binary > tfplan.json\n</code></pre> <p>For more details, see also OPA document.</p>","title":"Terraform Plan"},{"location":"docs/misconfiguration/custom/examples/#serverless-framework","text":"<p>See here.</p> <p>Server Framework uses YAML format for configurations. You can apply your Rego policies to <code>serverless.yaml</code>.</p>","title":"Serverless Framework"},{"location":"docs/misconfiguration/custom/examples/#custom-data","text":"<p>See here.</p>","title":"Custom Data"},{"location":"docs/misconfiguration/custom/examples/#combined-input","text":"<p>See here.</p>","title":"Combined Input"},{"location":"docs/misconfiguration/custom/examples/#go-testing","text":"<p>See here.</p>","title":"Go Testing"},{"location":"docs/misconfiguration/custom/testing/","text":"<p>It is highly recommended to write tests for your custom policies.</p>","title":"Testing"},{"location":"docs/misconfiguration/custom/testing/#rego-testing","text":"<p>To help you verify the correctness of your custom policies, OPA gives you a framework that you can use to write tests for your policies. By writing tests for your custom policies you can speed up the development process of new rules and reduce the amount of time it takes to modify rules as requirements evolve.</p> <p>For more details, see Policy Testing.</p> <p>Example</p> <pre><code>package user.dockerfile.ID002\n\ntest_add_denied {\n r := deny with input as {\"stages\": {\"alpine:3.13\": [\n {\"Cmd\": \"add\", \"Value\": [\"/target/resources.tar.gz\", \"resources.jar\"]},\n {\"Cmd\": \"add\", \"Value\": [\"/target/app.jar\", \"app.jar\"]},\n ]}}\n\n count(r) == 1\n r[_] == \"Consider using 'COPY /target/app.jar app.jar' command instead of 'ADD /target/app.jar app.jar'\"\n}\n</code></pre> <p>To write tests for custom policies, you can refer to existing tests under AppShield.</p>","title":"Rego testing"},{"location":"docs/misconfiguration/custom/testing/#go-testing","text":"<p>Fanal which is a core library of Trivy can be imported as a Go library. You can scan config files in Go and test your custom policies using Go's testing methods, such as table-driven tests. This allows you to use the actual configuration file as input, making it easy to prepare test data and ensure that your custom policies work in practice.</p> <p>In particular, Dockerfile and HCL need to be converted to structural data as input, which may be different from the expected input format.</p> <p>Tip</p> <p>We recommend writing OPA and Go tests both since they have different roles, like unit tests and integration tests.</p> <p>The following example stores allowed and denied configuration files in a directory. <code>Successes</code> contains the result of successes, and <code>Failures</code> contains the result of failures.</p> <pre><code>{\n name: \"disallowed ports\",\n input: \"configs/\",\n fields: fields{\n policyPaths: []string{\"policy\"},\n dataPaths: []string{\"data\"},\n namespaces: []string{\"user\"},\n },\n want: []types.Misconfiguration{\n {\n FileType: types.Dockerfile,\n FilePath: \"Dockerfile.allowed\",\n Successes: types.MisconfResults{\n {\n Namespace: \"user.dockerfile.ID002\",\n PolicyMetadata: types.PolicyMetadata{\n ID: \"ID002\",\n Type: \"Docker Custom Check\",\n Title: \"Disallowed ports exposed\",\n Severity: \"HIGH\",\n },\n },\n },\n },\n {\n FileType: types.Dockerfile,\n FilePath: \"Dockerfile.denied\",\n Failures: types.MisconfResults{\n {\n Namespace: \"user.dockerfile.ID002\",\n Message: \"Port 23 should not be exposed\",\n PolicyMetadata: types.PolicyMetadata{\n ID: \"ID002\",\n Type: \"Docker Custom Check\",\n Title: \"Disallowed ports exposed\",\n Severity: \"HIGH\",\n },\n },\n },\n },\n },\n},\n</code></pre> <p><code>Dockerfile.allowed</code> has one successful result in <code>Successes</code>, while <code>Dockerfile.denied</code> has one failure result in <code>Failures</code>.</p>","title":"Go testing"},{"location":"docs/misconfiguration/options/filter/","text":"","title":"Filter Misconfigurations"},{"location":"docs/misconfiguration/options/filter/#by-severity","text":"<p>Use <code>--severity</code> option.</p> <pre><code>trivy conf --severity HIGH,CRITICAL examples/misconf/mixed\n</code></pre> Result <pre><code>2021-07-10T17:37:13.267+0300 INFO Detected config files: 4\n\nconfigs/Dockerfile (dockerfile)\n===============================\nTests: 23 (SUCCESSES: 21, FAILURES: 2, EXCEPTIONS: 0)\nFailures: 2 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Specify at least 1 USER |\n| | | | | command in Dockerfile with |\n| | | | | non-root user as argument |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n\nconfigs/deployment.yaml (kubernetes)\n====================================\nTests: 28 (SUCCESSES: 14, FAILURES: 14, EXCEPTIONS: 0)\nFailures: 14 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n| Kubernetes Security Check | KSV006 | docker.sock is mounted to container | HIGH | Deployment 'hello-kubernetes' should |\n| | | | | not specify '/var/run/docker.socker' in |\n| | | | | 'spec.template.volumes.hostPath.path' |\n| | | | | -->avd.aquasec.com/appshield/ksv006 |\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n\nconfigs/main.tf (terraform)\n===========================\nTests: 19 (SUCCESSES: 11, FAILURES: 8, EXCEPTIONS: 0)\nFailures: 8 (HIGH: 6, CRITICAL: 1)\n\n+------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+\n| Terraform Security Check powered by | AWS003 | AWS Classic resource usage. | HIGH | Resource |\n| tfsec | | | | 'aws_db_security_group.my-group' |\n| | | | | uses EC2 Classic. Use a VPC instead. |\n| | | | | -->tfsec.dev/docs/aws/AWS003/ |\n+ +------------+------------------------------------------+----------+--------------------------------------------------------+\n| | AWS004 | Use of plain HTTP. | CRITICAL | Resource |\n| | | | | 'aws_alb_listener.my-alb-listener' |\n| | | | | uses plain HTTP instead of HTTPS. |\n| | | | | -->tfsec.dev/docs/aws/AWS004/ |\n+ +------------+------------------------------------------+----------+--------------------------------------------------------+\n| | AWS018 | Missing description for security | HIGH | Resource |\n| | | group/security group rule. | | 'aws_security_group_rule.my-rule' should |\n| | | | | include a description for auditing |\n| | | | | purposes. -->tfsec.dev/docs/aws/AWS018/ |\n+ +------------+------------------------------------------+ +--------------------------------------------------------+\n| | AWS025 | API Gateway domain name uses outdated | | Resource |\n| | | SSL/TLS protocols. | | 'aws_api_gateway_domain_name.empty_security_policy' |\n| | | | | defines outdated SSL/TLS policies (not using |\n| | | | | TLS_1_2). -->tfsec.dev/docs/aws/AWS025/ |\n+ + + + +--------------------------------------------------------+\n| | | | | Resource |\n| | | | | 'aws_api_gateway_domain_name.missing_security_policy' |\n| | | | | should include security_policy (defaults to outdated |\n| | | | | SSL/TLS policy). -->tfsec.dev/docs/aws/AWS025/ |\n+ + + + +--------------------------------------------------------+\n| | | | | Resource |\n| | | | | 'aws_api_gateway_domain_name.outdated_security_policy' |\n| | | | | defines outdated SSL/TLS policies (not using TLS_1_2). |\n| | | | | -->tfsec.dev/docs/aws/AWS025/ |\n+ +------------+------------------------------------------+ +--------------------------------------------------------+\n| | AZU003 | Unencrypted managed disk. | | Resource 'azurerm_managed_disk.source' |\n| | | | | defines an unencrypted managed disk. |\n| | | | | -->tfsec.dev/docs/azure/AZU003/ |\n+------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+\n\nconfigs/variables.tf (terraform)\n================================\nTests: 1 (SUCCESSES: 1, FAILURES: 0, EXCEPTIONS: 0)\nFailures: 0 (HIGH: 0, CRITICAL: 0)\n</code></pre>","title":"By Severity"},{"location":"docs/misconfiguration/options/filter/#by-misconfiguration-ids","text":"<p>Use <code>.trivyignore</code>.</p> <pre><code>$ cat .trivyignore\n# Accept the risk\nAWS003\nAWS018\nAWS025\n\n$ trivy conf --severity HIGH,CRITICAL examples/misconf/mixed\n</code></pre> Result <pre><code>2021-07-10T17:38:51.306+0300 INFO Detected config files: 4\n\nconfigs/Dockerfile (dockerfile)\n===============================\nTests: 23 (SUCCESSES: 21, FAILURES: 2, EXCEPTIONS: 0)\nFailures: 2 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Specify at least 1 USER |\n| | | | | command in Dockerfile with |\n| | | | | non-root user as argument |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n\nconfigs/deployment.yaml (kubernetes)\n====================================\nTests: 28 (SUCCESSES: 14, FAILURES: 14, EXCEPTIONS: 0)\nFailures: 14 (HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n| Kubernetes Security Check | KSV006 | docker.sock is mounted to container | HIGH | Deployment 'hello-kubernetes' should |\n| | | | | not specify '/var/run/docker.socker' in |\n| | | | | 'spec.template.volumes.hostPath.path' |\n| | | | | -->avd.aquasec.com/appshield/ksv006 |\n+---------------------------+------------+-------------------------------------+----------+------------------------------------------+\n\nconfigs/main.tf (terraform)\n===========================\nTests: 19 (SUCCESSES: 11, FAILURES: 8, EXCEPTIONS: 0)\nFailures: 8 (HIGH: 1, CRITICAL: 1)\n\n+------------------------------------------+------------+---------------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+------------------------------------------+------------+---------------------------+----------+------------------------------------------+\n| Terraform Security Check powered by | AWS004 | Use of plain HTTP. | CRITICAL | Resource |\n| tfsec | | | | 'aws_alb_listener.my-alb-listener' |\n| | | | | uses plain HTTP instead of HTTPS. |\n| | | | | -->tfsec.dev/docs/aws/AWS004/ |\n+ +------------+---------------------------+----------+------------------------------------------+\n| | AZU003 | Unencrypted managed disk. | HIGH | Resource 'azurerm_managed_disk.source' |\n| | | | | defines an unencrypted managed disk. |\n| | | | | -->tfsec.dev/docs/azure/AZU003/ |\n+------------------------------------------+------------+---------------------------+----------+------------------------------------------+\n\nconfigs/variables.tf (terraform)\n================================\nTests: 1 (SUCCESSES: 1, FAILURES: 0, EXCEPTIONS: 0)\nFailures: 0 (HIGH: 0, CRITICAL: 0)\n</code></pre>","title":"By Misconfiguration IDs"},{"location":"docs/misconfiguration/options/filter/#by-exceptions","text":"<p>See Exceptions</p>","title":"By Exceptions"},{"location":"docs/misconfiguration/options/filter/#show-successes-and-exceptions","text":"<p>Use <code>--include-non-failures</code> option to show successes and exceptions as well as failures.</p> <pre><code>trivy conf --severity CRITICAL --include-non-failures examples/misconf/mixed\n</code></pre> Result <pre><code>2021-07-10T17:44:02.049+0300 INFO Detected config files: 4\n\nconfigs/Dockerfile (dockerfile)\n===============================\nTests: 23 (SUCCESSES: 21, FAILURES: 2, EXCEPTIONS: 0)\nFailures: 2 (CRITICAL: 0)\n\n+---------------------------+------------+------------------------------------------+----------+--------+-----------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | STATUS | MESSAGE |\n+---------------------------+------------+------------------------------------------+----------+--------+-----------------+\n| Dockerfile Security Check | DS006 | COPY '--from' refers to the current | CRITICAL | PASS | No issues found |\n| | | image | | | |\n+ +------------+------------------------------------------+ + + +\n| | DS007 | Multiple ENTRYPOINT instructions are | | | |\n| | | listed | | | |\n+ +------------+------------------------------------------+ + + +\n| | DS008 | Exposed port is out of range | | | |\n+ +------------+------------------------------------------+ + + +\n| | DS010 | 'sudo' is used | | | |\n+ +------------+------------------------------------------+ + + +\n| | DS011 | COPY with more than two arguments is not | | | |\n| | | ending with slash | | | |\n+ +------------+------------------------------------------+ + + +\n| | DS012 | Duplicate aliases are defined in | | | |\n| | | different FROMs | | | |\n+---------------------------+------------+------------------------------------------+----------+--------+-----------------+\n\n...\n</code></pre>","title":"Show Successes and Exceptions"},{"location":"docs/misconfiguration/options/others/","text":"<p>Hint</p> <p>See also Others in Vulnerability section.</p>","title":"Others"},{"location":"docs/misconfiguration/options/others/#file-patterns","text":"<p>When a directory is given as an input, Trivy will recursively look for and test all files based on file patterns. The default file patterns are here.</p> <p>In addition to the default file patterns, the <code>--file-patterns</code> option takes regexp patterns to look for your files. For example, it may be useful when your file name of Dockerfile doesn't match the default patterns.</p> <p>This can be repeated for specifying multiple file patterns. Allowed values are here:</p> <ul> <li>dockerfile</li> <li>yaml</li> <li>json</li> <li>toml</li> <li>hcl</li> </ul> <p>For more details, see an example</p>","title":"File patterns"},{"location":"docs/misconfiguration/options/policy/","text":"","title":"Policy"},{"location":"docs/misconfiguration/options/policy/#pass-custom-policies","text":"<p>You can pass directories including your custom policies through <code>--policy</code> option. This can be repeated for specifying multiple directories.</p> <pre><code>cd examplex/misconf/\ntrivy conf --policy custom-policy/policy --policy combine/policy --namespaces user misconf/mixed\n</code></pre> <p>For more details, see Custom Policies.</p> <p>Tip</p> <p>You also need to specify <code>--namespaces</code> option.</p>","title":"Pass custom policies"},{"location":"docs/misconfiguration/options/policy/#pass-custom-data","text":"<p>You can pass directories including your custom data through <code>--data</code> option. This can be repeated for specifying multiple directories.</p> <pre><code>cd examples/misconf/custom-data\ntrivy conf --policy ./policy --data ./data --namespaces user ./configs\n</code></pre> <p>For more details, see Custom Data.</p>","title":"Pass custom data"},{"location":"docs/misconfiguration/options/policy/#pass-namespaces","text":"<p>By default, Trivy evaluate policies defined in <code>appshield.*</code>. If you want to evaluate custom policies in other packages, you have to specify package prefixes through <code>--namespaces</code> option. This can be repeated for specifying multiple packages.</p> <pre><code>trivy conf --policy ./policy --namespaces main --namespaces user ./configs\n</code></pre>","title":"Pass namespaces"},{"location":"docs/misconfiguration/options/policy/#skip-update-of-built-in-policies","text":"<p><code>Trivy</code> downloads built-in policies when it starts operating. Then, it checks for updates every 24 hours. You can use the <code>--skip-policy-update</code> option to skip it. If you skip it the first time, the built-in policies will not be loaded.</p> <p>Note</p> <p>Even if you specify the option the first time, it will be loaded as Terraform policies are written in Go.</p> <pre><code>trivy conf --skip-policy-update examples/misconf/mixed [~/src/github.com/aquasecurity/trivy]\n</code></pre> Result <pre><code>2021-07-10T18:04:19.083+0300 INFO No builtin policies were loaded\n2021-07-10T18:04:19.174+0300 INFO Detected config files: 2\n\nconfigs/main.tf (terraform)\n===========================\nTests: 19 (SUCCESSES: 11, FAILURES: 8, EXCEPTIONS: 0)\nFailures: 8 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 1, CRITICAL: 1)\n\n+------------------------------------------+------------+------------------------------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+------------------------------------------+------------+------------------------------------------+----------+------------------------------------------+\n| Terraform Security Check powered by | AWS004 | Use of plain HTTP. | CRITICAL | Resource |\n| tfsec | | | | 'aws_alb_listener.my-alb-listener' |\n| | | | | uses plain HTTP instead of HTTPS. |\n| | | | | -->tfsec.dev/docs/aws/AWS004/ |\n+ +------------+------------------------------------------+----------+------------------------------------------+\n| | AWS006 | An ingress security group rule allows | MEDIUM | Resource |\n| | | traffic from /0. | | 'aws_security_group_rule.my-rule' |\n| | | | | defines a fully open |\n| | | | | ingress security group rule. |\n| | | | | -->tfsec.dev/docs/aws/AWS006/ |\n+ +------------+------------------------------------------+----------+------------------------------------------+\n| | AZU003 | Unencrypted managed disk. | HIGH | Resource 'azurerm_managed_disk.source' |\n| | | | | defines an unencrypted managed disk. |\n| | | | | -->tfsec.dev/docs/azure/AZU003/ |\n+------------------------------------------+------------+------------------------------------------+----------+------------------------------------------+\n\nconfigs/variables.tf (terraform)\n================================\nTests: 1 (SUCCESSES: 1, FAILURES: 0, EXCEPTIONS: 0)\nFailures: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)\n</code></pre>","title":"Skip update of built-in policies"},{"location":"docs/misconfiguration/options/report/","text":"<p>See Reports Formats in Vulnerability section.</p> <p>Caution</p> <p>Misconfiguration scanning doesn't support default templates such as XML for now.</p>","title":"Report Formats"},{"location":"docs/misconfiguration/policy/builtin/","text":"","title":"Built-in Policies"},{"location":"docs/misconfiguration/policy/builtin/#policy-sources","text":"<p>Built-in policies are mainly written in Rego. Those policies are managed under AppShield repository. Terraform policies are currently powered by tfsec and CloudFormation policies are powered by cfsec.</p> Config type Source Kubernetes AppShield Dockerfile AppShield Terraform tfsec CloudFormation cfsec <p>For suggestions or issues regarding policy content, please open an issue under AppShield, tfsec or cfsec repository.</p> <p>Ansible are coming soon.</p>","title":"Policy Sources"},{"location":"docs/misconfiguration/policy/builtin/#policy-distribution","text":"<p>AppShield policies are distributed as an OPA bundle on GitHub Container Registry (GHCR). When misconfiguration detection is enabled, Trivy pulls the OPA bundle from GHCR as an OCI artifact and stores it in the cache. Those policies are then loaded into Trivy OPA engine and used for detecting misconfigurations.</p>","title":"Policy Distribution"},{"location":"docs/misconfiguration/policy/builtin/#update-interval","text":"<p>Trivy checks for updates to OPA bundle on GHCR every 24 hours and pulls it if there are any updates.</p>","title":"Update Interval"},{"location":"docs/misconfiguration/policy/exceptions/","text":"<p>Exceptions lets you to specify cases where you allow policy violations. Trivy supports two types of exceptions.</p> <p>Info</p> <p>Exceptions can be applied to built-in policies as well as custom policies.</p>","title":"Exceptions"},{"location":"docs/misconfiguration/policy/exceptions/#namespace-based-exceptions","text":"<p>There are some cases where you need to disable built-in policies partially or fully. Namespace-based exceptions lets you rough choose which individual packages to exempt.</p> <p>To use namespace-based exceptions, create a Rego rule with the name <code>exception</code> that returns the package names to exempt. The <code>exception</code> rule must be defined under <code>namespace.exceptions</code>. <code>data.namespaces</code> includes all package names.</p> <p>Example</p> <pre><code>package namespace.exceptions\n\nimport data.namespaces\n\nexception[ns] {\n ns := data.namespaces[_]\n startswith(ns, \"appshield\")\n}\n</code></pre> <p>This example exempts all built-in policies for Kubernetes.</p> <p>For more details, see an example.</p>","title":"Namespace-based exceptions"},{"location":"docs/misconfiguration/policy/exceptions/#rule-based-exceptions","text":"<p>There are some cases where you need more flexibility and granularity in defining which cases to exempt. Rule-based exceptions lets you granularly choose which individual rules to exempt, while also declaring under which conditions to exempt them.</p> <p>To use rule-based exceptions, create a Rego rule with the name <code>exception</code> that returns the rule name suffixes to exempt, prefixed by <code>deny_</code> (for example, returning <code>foo</code> will exempt <code>deny_foo</code>). The rule can make any other assertion, for example, on the input or data documents. This is useful to specify the exemption for a specific case.</p> <p>Note that if you specify the empty string, the exception will match all rules named <code>deny</code>.</p> <pre><code>exception[rules] {\n # Logic\n\n rules = [\"foo\",\"bar\"]\n}\n</code></pre> <p>The above would provide an exception from <code>deny_foo</code> and <code>deny_bar</code>.</p> <p>Example</p> <pre><code>package user.kubernetes.ID100\n\n__rego_metadata := {\n \"id\": \"ID100\",\n \"title\": \"Deployment not allowed\",\n \"severity\": \"HIGH\",\n \"type\": \"Kubernetes Custom Check\",\n}\n\ndeny_deployment[msg] {\n input.kind == \"Deployment\"\n msg = sprintf(\"Found deployment '%s' but deployments are not allowed\", [name])\n}\n\nexception[rules] {\n input.kind == \"Deployment\"\n input.metadata.name == \"allow-deployment\"\n\n rules := [\"deployment\"]\n}\n</code></pre> <p>If you want to apply rule-based exceptions to built-in policies, you have to define the exception under the same package.</p> <p>Example</p> <pre><code>package appshield.kubernetes.KSV012\n\nexception[rules] {\n input.metadata.name == \"can-run-as-root\"\n rules := [\"\"]\n}\n</code></pre> <p>This exception is applied to KSV012 in AppShield. You can get the package names in AppShield repository or the JSON output from Trivy.</p> <p>For more details, see an example.</p>","title":"Rule-based exceptions"},{"location":"docs/references/troubleshooting/","text":"","title":"Troubleshooting"},{"location":"docs/references/troubleshooting/#scan","text":"","title":"Scan"},{"location":"docs/references/troubleshooting/#timeout","text":"<p>Error</p> <pre><code>$ trivy image ...\n...\nanalyze error: timeout: context deadline exceeded\n</code></pre> <p>Your scan may time out. Java takes a particularly long time to scan. Try increasing the value of the ---timeout option such as <code>--timeout 15m</code>.</p>","title":"Timeout"},{"location":"docs/references/troubleshooting/#certification","text":"<p>Error</p> <p>Error: x509: certificate signed by unknown authority</p> <p><code>TRIVY_INSECURE</code> can be used to allow insecure connections to a container registry when using SSL.</p> <pre><code>$ TRIVY_INSECURE=true trivy image [YOUR_IMAGE]\n</code></pre>","title":"Certification"},{"location":"docs/references/troubleshooting/#github-rate-limiting","text":"<p>Error</p> <pre><code>$ trivy image ...\n...\nAPI rate limit exceeded for xxx.xxx.xxx.xxx.\n</code></pre> <p>Specify GITHUB_TOKEN for authentication https://developer.github.com/v3/#rate-limiting</p> <pre><code>$ GITHUB_TOKEN=XXXXXXXXXX trivy alpine:3.10\n</code></pre>","title":"GitHub Rate limiting"},{"location":"docs/references/troubleshooting/#maven-rate-limiting-inconsistent-jar-vulnerability-reporting","text":"<p>Error</p> <pre><code>$ trivy image ...\n...\nstatus 403 Forbidden from http://search.maven.org/solrsearch/select\n</code></pre> <p>Trivy calls Maven API for better detection of JAR files, but many requests may exceed rate limiting. This can easily happen if you are running more than one instance of Trivy which is concurrently scanning multiple images. Once this starts happening Trivy's vulnerability reporting on jar files may become inconsistent. There are two options to resolve this issue:</p> <p>The first is to enable offline scanning using the <code>--offline-scan</code> option to stop Trivy from making API requests. This option affects only vulnerability scanning. The vulnerability database and builtin policies are downloaded as usual. If you want to skip them as well, you can try <code>--skip-update</code> and <code>--skip-policy-update</code>. Note that a number of vulnerabilities might be fewer than without the <code>--offline-scan</code> option.</p> <p>The second, more scalable, option is the place Trivy behind a rate-limiting forward-proxy to the Maven Central API. One way to achieve this is to use nginx. You can use the following nginx config to enable both rate-limiting and caching (the caching greatly reduces the number of calls to the Maven Central API, especially if you are scanning a lot of similar images):</p> <pre><code>limit_req_zone global zone=maven:1m rate=10r/s;\nproxy_cache_path /tmp/cache keys_zone=mavencache:10m;\n\nserver {\n listen 80;\n proxy_cache mavencache;\n\n location / {\n limit_req zone=maven burst=1000;\n proxy_cache_valid any 1h;\n proxy_pass https://search.maven.org:443;\n }\n}\n</code></pre> <p>This config file will allow a maximum of 10 requests per second to the Maven API, this number was determined experimentally so you might want to use something else if it doesn't fit your needs.</p> <p>Once nginx is up and running, you need to tell all your Trivy deployments to proxy their Maven API calls through nginx. You can do this by setting the <code>MAVEN_CENTRAL_URL</code> environment variable. For example, if your nginx proxy is running at <code>127.0.0.1</code>, you can set <code>MAVEN_CENTRAL_URL=http://127.0.0.1/solrsearch/select</code>.</p>","title":"Maven rate limiting / inconsistent jar vulnerability reporting"},{"location":"docs/references/troubleshooting/#running-in-parallel-takes-same-time-as-series-run","text":"<p>When running trivy on multiple images simultaneously, it will take same time as running trivy in series. This is because of a limitation of boltdb.</p> <p>Bolt obtains a file lock on the data file so multiple processes cannot open the same database at the same time. Opening an already open Bolt database will cause it to hang until the other process closes it.</p> <p>Reference : boltdb: Opening a database.</p>","title":"Running in parallel takes same time as series run"},{"location":"docs/references/troubleshooting/#error-downloading-vulnerability-db","text":"<p>Error</p> <p>FATAL failed to download vulnerability DB</p> <p>If trivy is running behind corporate firewall, you have to add the following urls to your allowlist.</p> <ul> <li>ghcr.io</li> <li>pkg-containers.githubusercontent.com</li> </ul>","title":"Error downloading vulnerability DB"},{"location":"docs/references/troubleshooting/#old-db-schema","text":"<p>Error</p> <p>--skip-update cannot be specified with the old DB schema.</p> <p>Trivy v0.23.0 or later requires Trivy DB v2. Please update your local database or follow [the instruction of air-gapped environment][../advanced/air-gap.md].</p>","title":"Old DB schema"},{"location":"docs/references/troubleshooting/#homebrew","text":"","title":"Homebrew"},{"location":"docs/references/troubleshooting/#scope-error","text":"<p>Error</p> <p>Error: Your macOS keychain GitHub credentials do not have sufficient scope!</p> <pre><code>$ brew tap aquasecurity/trivy\nError: Your macOS keychain GitHub credentials do not have sufficient scope!\nScopes they need: none\nScopes they have:\nCreate a personal access token:\nhttps://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew\necho 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc\n</code></pre> <p>Try:</p> <pre><code>$ printf \"protocol=https\\nhost=github.com\\n\" | git credential-osxkeychain erase\n</code></pre>","title":"Scope error"},{"location":"docs/references/troubleshooting/#already-installed","text":"<p>Error</p> <p>Error: aquasecurity/trivy/trivy 64 already installed</p> <pre><code>$ brew upgrade\n...\nError: aquasecurity/trivy/trivy 64 already installed\n</code></pre> <p>Try:</p> <pre><code>$ brew unlink trivy && brew uninstall trivy\n($ rm -rf /usr/local/Cellar/trivy/64)\n$ brew install aquasecurity/trivy/trivy\n</code></pre>","title":"Already installed"},{"location":"docs/references/troubleshooting/#others","text":"","title":"Others"},{"location":"docs/references/troubleshooting/#unknown-error","text":"<p>Try again with <code>--reset</code> option:</p> <pre><code>$ trivy image --reset\n</code></pre>","title":"Unknown error"},{"location":"docs/references/cli/","text":"<p>Trivy has several sub commands, image, fs, repo, client and server.</p> <pre><code>NAME:\n trivy - A simple and comprehensive vulnerability scanner for containers\n\nUSAGE:\n trivy [global options] command [command options] target\n\nVERSION:\n dev\n\nCOMMANDS:\n image, i scan an image\n filesystem, fs scan local filesystem\n repository, repo scan remote repository\n client, c client mode\n server, s server mode\n config, conf scan config files\n plugin, p manage plugins\n version print the version\n help, h Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n --quiet, -q suppress progress bar and log output (default: false) [$TRIVY_QUIET]\n --debug, -d debug mode (default: false) [$TRIVY_DEBUG]\n --cache-dir value cache directory (default: \"/Users/teppei/Library/Caches/trivy\") [$TRIVY_CACHE_DIR]\n --help, -h show help (default: false)\n --version, -v print the version (default: false)\n</code></pre>","title":"Overview"},{"location":"docs/references/cli/client/","text":"<pre><code>NAME:\n trivy client - client mode\n\nUSAGE:\n trivy client [command options] image_name\n\nOPTIONS:\n --template value, -t value output template [$TRIVY_TEMPLATE]\n --format value, -f value format (table, json, sarif, template) (default: \"table\") [$TRIVY_FORMAT]\n --input value, -i value input file path instead of image name [$TRIVY_INPUT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]\n --removed-pkgs detect vulnerabilities of removed packages (only for Alpine) (default: false) [$TRIVY_REMOVED_PKGS]\n --vuln-type value comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]\n --list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]\n --offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]\n --token value for authentication [$TRIVY_TOKEN]\n --token-header value specify a header name for token (default: \"Trivy-Token\") [$TRIVY_TOKEN_HEADER]\n --remote value server address (default: \"http://localhost:4954\") [$TRIVY_REMOTE]\n --custom-headers value custom headers [$TRIVY_CUSTOM_HEADERS]\n --help, -h show help (default: false)\n</code></pre>","title":"Client"},{"location":"docs/references/cli/config/","text":"<pre><code>NAME:\n trivy config - scan config files\n\nUSAGE:\n trivy config [command options] dir\n\nOPTIONS:\n --template value, -t value output template [$TRIVY_TEMPLATE]\n --format value, -f value format (table, json, sarif, template) (default: \"table\") [$TRIVY_FORMAT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]\n --skip-policy-update skip updating built-in policies (default: false) [$TRIVY_SKIP_POLICY_UPDATE]\n --reset remove all caches and database (default: false) [$TRIVY_RESET]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --skip-files value specify the file paths to skip traversal [$TRIVY_SKIP_FILES]\n --skip-dirs value specify the directories where the traversal is skipped [$TRIVY_SKIP_DIRS]\n --policy value, --config-policy value specify paths to the Rego policy files directory, applying config files [$TRIVY_POLICY]\n --data value, --config-data value specify paths from which data for the Rego policies will be recursively loaded [$TRIVY_DATA]\n --policy-namespaces value, --namespaces value Rego namespaces (default: \"users\") [$TRIVY_POLICY_NAMESPACES]\n --file-patterns value specify file patterns [$TRIVY_FILE_PATTERNS]\n --include-successes include successes of misconfigurations (default: false) [$TRIVY_INCLUDE_SUCCESSES]\n --help, -h show help (default: false)\n</code></pre>","title":"Config"},{"location":"docs/references/cli/fs/","text":"<pre><code>NAME:\n trivy filesystem - scan local filesystem\n\nUSAGE:\n trivy filesystem [command options] dir\n\nOPTIONS:\n --template value, -t value output template [$TRIVY_TEMPLATE]\n --format value, -f value format (table, json, sarif, template) (default: \"table\") [$TRIVY_FORMAT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]\n --skip-db-update, --skip-update skip updating vulnerability database (default: false) [$TRIVY_SKIP_UPDATE, $TRIVY_SKIP_DB_UPDATE]\n --skip-policy-update skip updating built-in policies (default: false) [$TRIVY_SKIP_POLICY_UPDATE]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]\n --vuln-type value comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]\n --security-checks value comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --cache-backend value cache backend (e.g. redis://localhost:6379) (default: \"fs\") [$TRIVY_CACHE_BACKEND]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]\n --ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]\n --list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]\n --offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]\n --skip-files value specify the file paths to skip traversal [$TRIVY_SKIP_FILES]\n --skip-dirs value specify the directories where the traversal is skipped [$TRIVY_SKIP_DIRS]\n --config-policy value specify paths to the Rego policy files directory, applying config files [$TRIVY_CONFIG_POLICY]\n --config-data value specify paths from which data for the Rego policies will be recursively loaded [$TRIVY_CONFIG_DATA]\n --policy-namespaces value, --namespaces value Rego namespaces (default: \"users\") [$TRIVY_POLICY_NAMESPACES]\n --server value server address [$TRIVY_SERVER]\n --token value for authentication [$TRIVY_TOKEN]\n --token-header value specify a header name for token (default: \"Trivy-Token\") [$TRIVY_TOKEN_HEADER]\n --custom-headers value custom headers [$TRIVY_CUSTOM_HEADERS]\n --help, -h show help (default: false)\n</code></pre>","title":"Filesystem"},{"location":"docs/references/cli/image/","text":"<pre><code>NAME:\n trivy image - scan an image\n\nUSAGE:\n trivy image [command options] image_name\n\nOPTIONS:\n --template value, -t value output template [$TRIVY_TEMPLATE]\n --format value, -f value format (table, json, sarif, template) (default: \"table\") [$TRIVY_FORMAT]\n --input value, -i value input file path instead of image name [$TRIVY_INPUT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]\n --skip-update skip db update (default: false) [$TRIVY_SKIP_UPDATE]\n --download-db-only download/update vulnerability database but don't run a scan (default: false) [$TRIVY_DOWNLOAD_DB_ONLY]\n --reset remove all caches and database (default: false) [$TRIVY_RESET]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]\n --ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]\n --removed-pkgs detect vulnerabilities of removed packages (only for Alpine) (default: false) [$TRIVY_REMOVED_PKGS]\n --vuln-type value comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]\n --list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]\n --offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]\n --skip-files value specify the file path to skip traversal [$TRIVY_SKIP_FILES]\n --skip-dirs value specify the directory where the traversal is skipped [$TRIVY_SKIP_DIRS]\n --cache-backend value cache backend (e.g. redis://localhost:6379) (default: \"fs\") [$TRIVY_CACHE_BACKEND]\n --help, -h show help (default: false)\n</code></pre>","title":"Image"},{"location":"docs/references/cli/plugins/","text":"<p>Trivy provides a plugin feature to allow others to extend the Trivy CLI without the need to change the Trivycode base. This plugin system was inspired by the plugin system used in kubectl, Helm, and Conftest.</p>","title":"Plugins"},{"location":"docs/references/cli/plugins/#overview","text":"<p>Trivy plugins are add-on tools that integrate seamlessly with Trivy. They provide a way to extend the core feature set of Trivy, but without requiring every new feature to be written in Go and added to the core tool.</p> <ul> <li>They can be added and removed from a Trivy installation without impacting the core Trivy tool.</li> <li>They can be written in any programming language.</li> <li>They integrate with Trivy, and will show up in Trivy help and subcommands.</li> </ul> <p>Warning</p> <p>Trivy plugins available in public are not audited for security. You should install and run third-party plugins at your own risk, since they are arbitrary programs running on your machine.</p>","title":"Overview"},{"location":"docs/references/cli/plugins/#installing-a-plugin","text":"<p>A plugin can be installed using the <code>trivy plugin install</code> command. This command takes a url and will download the plugin and install it in the plugin cache.</p> <p>Trivy adheres to the XDG specification, so the location depends on whether XDG_DATA_HOME is set. Trivy will now search XDG_DATA_HOME for the location of the Trivy plugins cache. The preference order is as follows:</p> <ul> <li>XDG_DATA_HOME if set and .trivy/plugins exists within the XDG_DATA_HOME dir</li> <li>~/.trivy/plugins</li> </ul> <p>Under the hood Trivy leverages go-getter to download plugins. This means the following protocols are supported for downloading plugins:</p> <ul> <li>OCI Registries</li> <li>Local Files</li> <li>Git</li> <li>HTTP/HTTPS</li> <li>Mercurial</li> <li>Amazon S3</li> <li>Google Cloud Storage</li> </ul> <p>For example, to download the Kubernetes Trivy plugin you can execute the following command:</p> <pre><code>$ trivy plugin install github.com/aquasecurity/trivy-plugin-kubectl\n</code></pre>","title":"Installing a Plugin"},{"location":"docs/references/cli/plugins/#using-plugins","text":"<p>Once the plugin is installed, Trivy will load all available plugins in the cache on the start of the next Trivy execution. A plugin will be made in the Trivy CLI based on the plugin name. To display all plugins, you can list them by <code>trivy --help</code></p> <pre><code>$ trivy --help\nNAME:\n trivy - A simple and comprehensive vulnerability scanner for containers\n\nUSAGE:\n trivy [global options] command [command options] target\n\nVERSION:\n dev\n\nCOMMANDS:\n image, i scan an image\n filesystem, fs scan local filesystem\n repository, repo scan remote repository\n client, c client mode\n server, s server mode\n plugin, p manage plugins\n kubectl scan kubectl resources\n help, h Shows a list of commands or help for one command\n</code></pre> <p>As shown above, <code>kubectl</code> subcommand exists in the <code>COMMANDS</code> section. To call the kubectl plugin and scan existing Kubernetes deployments, you can execute the following command:</p> <pre><code>$ trivy kubectl deployment <deployment-id> -- --ignore-unfixed --severity CRITICAL\n</code></pre> <p>Internally the kubectl plugin calls the kubectl binary to fetch information about that deployment and passes the using images to Trivy. You can see the detail here.</p> <p>If you want to omit even the subcommand, you can use <code>TRIVY_RUN_AS_PLUGIN</code> environment variable.</p> <pre><code>$ TRIVY_RUN_AS_PLUGIN=kubectl trivy job your-job -- --format json\n</code></pre>","title":"Using Plugins"},{"location":"docs/references/cli/plugins/#installing-and-running-plugins-on-the-fly","text":"<p><code>trivy plugin run</code> installs a plugin and runs it on the fly. If the plugin is already present in the cache, the installation is skipped.</p> <pre><code>trivy plugin run github.com/aquasecurity/trivy-plugin-kubectl pod your-pod -- --exit-code 1\n</code></pre>","title":"Installing and Running Plugins on the fly"},{"location":"docs/references/cli/plugins/#uninstalling-plugins","text":"<p>Specify a plugin name with <code>trivy plugin uninstall</code> command.</p> <pre><code>$ trivy plugin uninstall kubectl\n</code></pre>","title":"Uninstalling Plugins"},{"location":"docs/references/cli/plugins/#building-plugins","text":"<p>Each plugin has a top-level directory, and then a plugin.yaml file.</p> <pre><code>your-plugin/\n |\n |- plugin.yaml\n |- your-plugin.sh\n</code></pre> <p>In the example above, the plugin is contained inside of a directory named <code>your-plugin</code>. It has two files: plugin.yaml (required) and an executable script, your-plugin.sh (optional).</p> <p>The core of a plugin is a simple YAML file named plugin.yaml. Here is an example YAML of trivy-plugin-kubectl plugin that adds support for Kubernetes scanning.</p> <pre><code>name: \"kubectl\"\nrepository: github.com/aquasecurity/trivy-plugin-kubectl\nversion: \"0.1.0\"\nusage: scan kubectl resources\ndescription: |-\n A Trivy plugin that scans the images of a kubernetes resource.\n Usage: trivy kubectl TYPE[.VERSION][.GROUP] NAME\nplatforms:\n - selector: # optional\n os: darwin\n arch: amd64\n uri: ./trivy-kubectl # where the execution file is (local file, http, git, etc.)\n bin: ./trivy-kubectl # path to the execution file\n - selector: # optional\n os: linux\n arch: amd64\n uri: https://github.com/aquasecurity/trivy-plugin-kubectl/releases/download/v0.1.0/trivy-kubectl.tar.gz\n bin: ./trivy-kubectl\n</code></pre> <p>The <code>plugin.yaml</code> field should contain the following information:</p> <ul> <li>name: The name of the plugin. This also determines how the plugin will be made available in the Trivy CLI. For example, if the plugin is named kubectl, you can call the plugin with <code>trivy kubectl</code>. (required)</li> <li>version: The version of the plugin. (required)</li> <li>usage: A short usage description. (required)</li> <li>description: A long description of the plugin. This is where you could provide a helpful documentation of your plugin. (required)</li> <li>platforms: (required)</li> <li>selector: The OS/Architecture specific variations of a execution file. (optional)<ul> <li>os: OS information based on GOOS (linux, darwin, etc.) (optional)</li> <li>arch: The architecture information based on GOARCH (amd64, arm64, etc.) (optional)</li> </ul> </li> <li>uri: Where the executable file is. Relative path from the root directory of the plugin or remote URL such as HTTP and S3. (required)</li> <li>bin: Which file to call when the plugin is executed. Relative path from the root directory of the plugin. (required)</li> </ul> <p>The following rules will apply in deciding which platform to select:</p> <ul> <li>If both <code>os</code> and <code>arch</code> under <code>selector</code> match the current platform, search will stop and the platform will be used.</li> <li>If <code>selector</code> is not present, the platform will be used.</li> <li>If <code>os</code> matches and there is no more specific <code>arch</code> match, the platform will be used.</li> <li>If no <code>platform</code> match is found, Trivy will exit with an error.</li> </ul> <p>After determining platform, Trivy will download the execution file from <code>uri</code> and store it in the plugin cache. When the plugin is called via Trivy CLI, <code>bin</code> command will be executed.</p> <p>The plugin is responsible for handling flags and arguments. Any arguments are passed to the plugin from the <code>trivy</code> command.</p>","title":"Building Plugins"},{"location":"docs/references/cli/plugins/#example","text":"<p>https://github.com/aquasecurity/trivy-plugin-kubectl</p>","title":"Example"},{"location":"docs/references/cli/repo/","text":"<pre><code>NAME:\n trivy repository - scan remote repository\n\nUSAGE:\n trivy repository [command options] repo_url\n\nOPTIONS:\n --template value, -t value output template [$TRIVY_TEMPLATE]\n --format value, -f value format (table, json, sarif, template) (default: \"table\") [$TRIVY_FORMAT]\n --input value, -i value input file path instead of image name [$TRIVY_INPUT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]\n --skip-update skip db update (default: false) [$TRIVY_SKIP_UPDATE]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]\n --removed-pkgs detect vulnerabilities of removed packages (only for Alpine) (default: false) [$TRIVY_REMOVED_PKGS]\n --vuln-type value comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --cache-backend value cache backend (e.g. redis://localhost:6379) (default: \"fs\") [$TRIVY_CACHE_BACKEND]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]\n --quiet, -q suppress progress bar and log output (default: false) [$TRIVY_QUIET]\n --ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]\n --list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]\n --offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]\n --skip-files value specify the file path to skip traversal [$TRIVY_SKIP_FILES]\n --skip-dirs value specify the directory where the traversal is skipped [$TRIVY_SKIP_DIRS]\n --help, -h show help (default: false)\n</code></pre>","title":"Repository"},{"location":"docs/references/cli/rootfs/","text":"<pre><code>NAME:\n trivy rootfs - scan rootfs\n\nUSAGE:\n trivy rootfs [command options] dir\n\nOPTIONS:\n --template value, -t value output template [$TRIVY_TEMPLATE]\n --format value, -f value format (table, json, sarif, template) (default: \"table\") [$TRIVY_FORMAT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --exit-code value Exit code when vulnerabilities were found (default: 0) [$TRIVY_EXIT_CODE]\n --skip-db-update, --skip-update skip updating vulnerability database (default: false) [$TRIVY_SKIP_UPDATE, $TRIVY_SKIP_DB_UPDATE]\n --skip-policy-update skip updating built-in policies (default: false) [$TRIVY_SKIP_POLICY_UPDATE]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --ignore-unfixed display only fixed vulnerabilities (default: false) [$TRIVY_IGNORE_UNFIXED]\n --vuln-type value comma-separated list of vulnerability types (os,library) (default: \"os,library\") [$TRIVY_VULN_TYPE]\n --security-checks value comma-separated list of what security issues to detect (vuln,config) (default: \"vuln\") [$TRIVY_SECURITY_CHECKS]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --cache-backend value cache backend (e.g. redis://localhost:6379) (default: \"fs\") [$TRIVY_CACHE_BACKEND]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --no-progress suppress progress bar (default: false) [$TRIVY_NO_PROGRESS]\n --ignore-policy value specify the Rego file to evaluate each vulnerability [$TRIVY_IGNORE_POLICY]\n --list-all-pkgs enabling the option will output all packages regardless of vulnerability (default: false) [$TRIVY_LIST_ALL_PKGS]\n --offline-scan do not issue API requests to identify dependencies (default: false) [$TRIVY_OFFLINE_SCAN]\n --skip-files value specify the file paths to skip traversal [$TRIVY_SKIP_FILES]\n --skip-dirs value specify the directories where the traversal is skipped [$TRIVY_SKIP_DIRS]\n --config-policy value specify paths to the Rego policy files directory, applying config files [$TRIVY_CONFIG_POLICY]\n --config-data value specify paths from which data for the Rego policies will be recursively loaded [$TRIVY_CONFIG_DATA]\n --policy-namespaces value, --namespaces value Rego namespaces (default: \"users\") [$TRIVY_POLICY_NAMESPACES]\n --help, -h show help (default: false)\n</code></pre>","title":"Rootfs"},{"location":"docs/references/cli/sbom/","text":"<pre><code>NAME:\n trivy sbom - generate SBOM for an artifact\n\nUSAGE:\n trivy sbom [command options] ARTIFACT\n\nOPTIONS:\n --output value, -o value output file name [$TRIVY_OUTPUT]\n --clear-cache, -c clear image caches without scanning (default: false) [$TRIVY_CLEAR_CACHE]\n --ignorefile value specify .trivyignore file (default: \".trivyignore\") [$TRIVY_IGNOREFILE]\n --timeout value timeout (default: 5m0s) [$TRIVY_TIMEOUT]\n --severity value, -s value severities of vulnerabilities to be displayed (comma separated) (default: \"UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL\") [$TRIVY_SEVERITY]\n --artifact-type value, --type value input artifact type (image, fs, repo, archive) (default: \"image\") [$TRIVY_ARTIFACT_TYPE]\n --sbom-format value, --format value SBOM format (cyclonedx) (default: \"cyclonedx\") [$TRIVY_SBOM_FORMAT]\n --help, -h show help (default: false)\n</code></pre>","title":"SBOM"},{"location":"docs/references/cli/server/","text":"<pre><code>NAME:\n trivy server - server mode\n\nUSAGE:\n trivy server [command options] [arguments...]\n\nOPTIONS:\n --skip-update skip db update (default: false) [$TRIVY_SKIP_UPDATE]\n --download-db-only download/update vulnerability database but don't run a scan (default: false) [$TRIVY_DOWNLOAD_DB_ONLY]\n --reset remove all caches and database (default: false) [$TRIVY_RESET]\n --cache-backend value cache backend (e.g. redis://localhost:6379) (default: \"fs\") [$TRIVY_CACHE_BACKEND]\n --token value for authentication [$TRIVY_TOKEN]\n --token-header value specify a header name for token (default: \"Trivy-Token\") [$TRIVY_TOKEN_HEADER]\n --listen value listen address (default: \"localhost:4954\") [$TRIVY_LISTEN]\n --help, -h show help (default: false)\n</code></pre>","title":"Server"},{"location":"docs/references/modes/client-server/","text":"<p>Trivy has client/server mode. Trivy server has vulnerability database and Trivy client doesn't have to download vulnerability database. It is useful if you want to scan images at multiple locations and do not want to download the database at every location.</p>","title":"Client/Server"},{"location":"docs/references/modes/client-server/#server","text":"<p>At first, you need to launch Trivy server. It downloads vulnerability database automatically and continue to fetch the latest DB in the background. <pre><code>$ trivy server --listen localhost:8080\n2019-12-12T15:17:06.551+0200 INFO Need to update DB\n2019-12-12T15:17:56.706+0200 INFO Reopening DB...\n2019-12-12T15:17:56.707+0200 INFO Listening localhost:8080...\n</code></pre></p> <p>If you want to accept a connection from outside, you have to specify <code>0.0.0.0</code> or your ip address, not <code>localhost</code>.</p> <pre><code>$ trivy server --listen 0.0.0.0:8080\n</code></pre>","title":"Server"},{"location":"docs/references/modes/client-server/#client","text":"<p>Then, specify the remote address. <pre><code>$ trivy client --remote http://localhost:8080 alpine:3.10\n</code></pre></p> Result <pre><code>alpine:3.10 (alpine 3.10.2)\n===========================\nTotal: 3 (UNKNOWN: 0, LOW: 1, MEDIUM: 2, HIGH: 0, CRITICAL: 0)\n\n+---------+------------------+----------+-------------------+---------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION |\n+---------+------------------+----------+-------------------+---------------+\n| openssl | CVE-2019-1549 | MEDIUM | 1.1.1c-r0 | 1.1.1d-r0 |\n+ +------------------+ + + +\n| | CVE-2019-1563 | | | |\n+ +------------------+----------+ + +\n| | CVE-2019-1547 | LOW | | |\n+---------+------------------+----------+-------------------+---------------+\n</code></pre>","title":"Client"},{"location":"docs/references/modes/client-server/#authentication","text":"<pre><code>$ trivy server --listen localhost:8080 --token dummy\n</code></pre> <pre><code>$ trivy client --remote http://localhost:8080 --token dummy alpine:3.10\n</code></pre>","title":"Authentication"},{"location":"docs/references/modes/client-server/#architecture","text":"<p></p>","title":"Architecture"},{"location":"docs/references/modes/standalone/","text":"<p><code>trivy image</code>, <code>trivy filesystem</code>, and <code>trivy repo</code> works as standalone mode.</p>","title":"Standalone"},{"location":"docs/references/modes/standalone/#image","text":"<p></p>","title":"Image"},{"location":"docs/references/modes/standalone/#filesystem","text":"<p></p>","title":"Filesystem"},{"location":"docs/references/modes/standalone/#git-repository","text":"<p></p>","title":"Git Repository"},{"location":"docs/sbom/","text":"<p>Trivy currently supports the following SBOM formats.</p> <ul> <li>CycloneDX</li> </ul> <p>To generate SBOM, you can use the <code>--format</code> option for each subcommand such as <code>image</code> and <code>fs</code>.</p> <pre><code>$ trivy image --format cyclonedx --output result.json alpine:3.15\n</code></pre> <p>In addition, you can use the <code>trivy sbom</code> subcommand.</p> <pre><code>$ trivy sbom alpine:3.15\n</code></pre> Result <pre><code>{\n \"bomFormat\": \"CycloneDX\",\n \"specVersion\": \"1.3\",\n \"serialNumber\": \"urn:uuid:2be5773d-7cd3-4b4b-90a5-e165474ddace\",\n \"version\": 1,\n \"metadata\": {\n \"timestamp\": \"2022-02-22T15:11:40.270597Z\",\n \"tools\": [\n {\n \"vendor\": \"aquasecurity\",\n \"name\": \"trivy\",\n \"version\": \"dev\"\n }\n ],\n \"component\": {\n \"bom-ref\": \"pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64\",\n \"type\": \"container\",\n \"name\": \"alpine:3.15\",\n \"version\": \"\",\n \"purl\": \"pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:SchemaVersion\",\n \"value\": \"2\"\n },\n {\n \"name\": \"aquasecurity:trivy:ImageID\",\n \"value\": \"sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18\"\n },\n {\n \"name\": \"aquasecurity:trivy:RepoDigest\",\n \"value\": \"alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300\"\n },\n {\n \"name\": \"aquasecurity:trivy:DiffID\",\n \"value\": \"sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759\"\n },\n {\n \"name\": \"aquasecurity:trivy:RepoTag\",\n \"value\": \"alpine:3.15\"\n }\n ]\n }\n },\n \"components\": [\n {\n \"bom-ref\": \"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0\",\n \"type\": \"library\",\n \"name\": \"alpine-baselayout\",\n \"version\": \"3.2.0-r18\",\n \"licenses\": [\n {\n \"expression\": \"GPL-2.0-only\"\n }\n ],\n \"purl\": \"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:SrcName\",\n \"value\": \"alpine-baselayout\"\n },\n {\n \"name\": \"aquasecurity:trivy:SrcVersion\",\n \"value\": \"3.2.0-r18\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDigest\",\n \"value\": \"sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDiffID\",\n \"value\": \"sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759\"\n }\n ]\n },\n ...(snip)...\n {\n \"bom-ref\": \"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0\",\n \"type\": \"library\",\n \"name\": \"zlib\",\n \"version\": \"1.2.11-r3\",\n \"licenses\": [\n {\n \"expression\": \"Zlib\"\n }\n ],\n \"purl\": \"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:SrcName\",\n \"value\": \"zlib\"\n },\n {\n \"name\": \"aquasecurity:trivy:SrcVersion\",\n \"value\": \"1.2.11-r3\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDigest\",\n \"value\": \"sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDiffID\",\n \"value\": \"sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759\"\n }\n ]\n },\n {\n \"bom-ref\": \"3da6a469-964d-4b4e-b67d-e94ec7c88d37\",\n \"type\": \"operating-system\",\n \"name\": \"alpine\",\n \"version\": \"3.15.0\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:Type\",\n \"value\": \"alpine\"\n },\n {\n \"name\": \"aquasecurity:trivy:Class\",\n \"value\": \"os-pkgs\"\n }\n ]\n }\n ],\n \"dependencies\": [\n {\n \"ref\": \"3da6a469-964d-4b4e-b67d-e94ec7c88d37\",\n \"dependsOn\": [\n \"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0\",\n \"pkg:apk/alpine/alpine-keys@2.4-r1?distro=3.15.0\",\n \"pkg:apk/alpine/apk-tools@2.12.7-r3?distro=3.15.0\",\n \"pkg:apk/alpine/busybox@1.34.1-r3?distro=3.15.0\",\n \"pkg:apk/alpine/ca-certificates-bundle@20191127-r7?distro=3.15.0\",\n \"pkg:apk/alpine/libc-utils@0.7.2-r3?distro=3.15.0\",\n \"pkg:apk/alpine/libcrypto1.1@1.1.1l-r7?distro=3.15.0\",\n \"pkg:apk/alpine/libretls@3.3.4-r2?distro=3.15.0\",\n \"pkg:apk/alpine/libssl1.1@1.1.1l-r7?distro=3.15.0\",\n \"pkg:apk/alpine/musl@1.2.2-r7?distro=3.15.0\",\n \"pkg:apk/alpine/musl-utils@1.2.2-r7?distro=3.15.0\",\n \"pkg:apk/alpine/scanelf@1.3.3-r0?distro=3.15.0\",\n \"pkg:apk/alpine/ssl_client@1.34.1-r3?distro=3.15.0\",\n \"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0\"\n ]\n },\n {\n \"ref\": \"pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64\",\n \"dependsOn\": [\n \"3da6a469-964d-4b4e-b67d-e94ec7c88d37\"\n ]\n }\n ]\n}\n</code></pre> <p><code>fs</code>, <code>repo</code> and <code>archive</code> also work with <code>sbom</code> subcommand.</p> <pre><code># filesystem\n$ trivy sbom --artifact-type fs /path/to/project\n\n# repository\n$ trivy sbom --artifact-type repo github.com/aquasecurity/trivy-ci-test\n\n# container image archive\n$ trivy sbom --artifact-type archive alpine.tar\n</code></pre>","title":"SBOM"},{"location":"docs/sbom/cyclonedx/","text":"<p>Trivy generates JSON reports in the CycloneDX format. Note that XML format is not supported at the moment.</p> <p>You can use the regular subcommands (like <code>image</code>, <code>fs</code> and <code>rootfs</code>) and specify <code>cyclonedx</code> with the <code>--format</code> option.</p> <pre><code>$ trivy image --format cyclonedx --output result.json alpine:3.15\n</code></pre> Result <pre><code>$ cat result.json | jq .\n{\n \"bomFormat\": \"CycloneDX\",\n \"specVersion\": \"1.4\",\n \"serialNumber\": \"urn:uuid:2be5773d-7cd3-4b4b-90a5-e165474ddace\",\n \"version\": 1,\n \"metadata\": {\n \"timestamp\": \"2022-02-22T15:11:40.270597Z\",\n \"tools\": [\n {\n \"vendor\": \"aquasecurity\",\n \"name\": \"trivy\",\n \"version\": \"dev\"\n }\n ],\n \"component\": {\n \"bom-ref\": \"pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64\",\n \"type\": \"container\",\n \"name\": \"alpine:3.15\",\n \"version\": \"\",\n \"purl\": \"pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:SchemaVersion\",\n \"value\": \"2\"\n },\n {\n \"name\": \"aquasecurity:trivy:ImageID\",\n \"value\": \"sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18\"\n },\n {\n \"name\": \"aquasecurity:trivy:RepoDigest\",\n \"value\": \"alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300\"\n },\n {\n \"name\": \"aquasecurity:trivy:DiffID\",\n \"value\": \"sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759\"\n },\n {\n \"name\": \"aquasecurity:trivy:RepoTag\",\n \"value\": \"alpine:3.15\"\n }\n ]\n }\n },\n \"components\": [\n {\n \"bom-ref\": \"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0\",\n \"type\": \"library\",\n \"name\": \"alpine-baselayout\",\n \"version\": \"3.2.0-r18\",\n \"licenses\": [\n {\n \"expression\": \"GPL-2.0-only\"\n }\n ],\n \"purl\": \"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:SrcName\",\n \"value\": \"alpine-baselayout\"\n },\n {\n \"name\": \"aquasecurity:trivy:SrcVersion\",\n \"value\": \"3.2.0-r18\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDigest\",\n \"value\": \"sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDiffID\",\n \"value\": \"sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759\"\n }\n ]\n },\n ...(snip)...\n {\n \"bom-ref\": \"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0\",\n \"type\": \"library\",\n \"name\": \"zlib\",\n \"version\": \"1.2.11-r3\",\n \"licenses\": [\n {\n \"expression\": \"Zlib\"\n }\n ],\n \"purl\": \"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:SrcName\",\n \"value\": \"zlib\"\n },\n {\n \"name\": \"aquasecurity:trivy:SrcVersion\",\n \"value\": \"1.2.11-r3\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDigest\",\n \"value\": \"sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3\"\n },\n {\n \"name\": \"aquasecurity:trivy:LayerDiffID\",\n \"value\": \"sha256:8d3ac3489996423f53d6087c81180006263b79f206d3fdec9e66f0e27ceb8759\"\n }\n ]\n },\n {\n \"bom-ref\": \"3da6a469-964d-4b4e-b67d-e94ec7c88d37\",\n \"type\": \"operating-system\",\n \"name\": \"alpine\",\n \"version\": \"3.15.0\",\n \"properties\": [\n {\n \"name\": \"aquasecurity:trivy:Type\",\n \"value\": \"alpine\"\n },\n {\n \"name\": \"aquasecurity:trivy:Class\",\n \"value\": \"os-pkgs\"\n }\n ]\n }\n ],\n \"dependencies\": [\n {\n \"ref\": \"3da6a469-964d-4b4e-b67d-e94ec7c88d37\",\n \"dependsOn\": [\n \"pkg:apk/alpine/alpine-baselayout@3.2.0-r18?distro=3.15.0\",\n \"pkg:apk/alpine/alpine-keys@2.4-r1?distro=3.15.0\",\n \"pkg:apk/alpine/apk-tools@2.12.7-r3?distro=3.15.0\",\n \"pkg:apk/alpine/busybox@1.34.1-r3?distro=3.15.0\",\n \"pkg:apk/alpine/ca-certificates-bundle@20191127-r7?distro=3.15.0\",\n \"pkg:apk/alpine/libc-utils@0.7.2-r3?distro=3.15.0\",\n \"pkg:apk/alpine/libcrypto1.1@1.1.1l-r7?distro=3.15.0\",\n \"pkg:apk/alpine/libretls@3.3.4-r2?distro=3.15.0\",\n \"pkg:apk/alpine/libssl1.1@1.1.1l-r7?distro=3.15.0\",\n \"pkg:apk/alpine/musl@1.2.2-r7?distro=3.15.0\",\n \"pkg:apk/alpine/musl-utils@1.2.2-r7?distro=3.15.0\",\n \"pkg:apk/alpine/scanelf@1.3.3-r0?distro=3.15.0\",\n \"pkg:apk/alpine/ssl_client@1.34.1-r3?distro=3.15.0\",\n \"pkg:apk/alpine/zlib@1.2.11-r3?distro=3.15.0\"\n ]\n },\n {\n \"ref\": \"pkg:oci/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300?repository_url=index.docker.io%2Flibrary%2Falpine&arch=amd64\",\n \"dependsOn\": [\n \"3da6a469-964d-4b4e-b67d-e94ec7c88d37\"\n ]\n }\n ],\n \"vulnerabilities\": [\n {\n \"id\": \"CVE-2021-42386\",\n \"source\": {\n \"name\": \"alpine\",\n \"url\": \"https://secdb.alpinelinux.org/\"\n },\n \"ratings\": [\n {\n \"source\": {\n \"name\": \"nvd\"\n },\n \"score\": 7.2,\n \"severity\": \"high\",\n \"method\": \"CVSSv31\",\n \"vector\": \"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H\"\n },\n {\n \"source\": {\n \"name\": \"nvd\"\n },\n \"score\": 6.5,\n \"severity\": \"medium\",\n \"method\": \"CVSSv2\",\n \"vector\": \"AV:N/AC:L/Au:S/C:P/I:P/A:P\"\n },\n {\n \"source\": {\n \"name\": \"redhat\"\n },\n \"score\": 6.6,\n \"severity\": \"medium\",\n \"method\": \"CVSSv31\",\n \"vector\": \"CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H\"\n }\n ],\n \"cwes\": [\n 416\n ],\n \"description\": \"A use-after-free in Busybox's awk applet leads to denial of service and possibly code execution when processing a crafted awk pattern in the nvalloc function\",\n \"advisories\": [\n {\n \"url\": \"https://access.redhat.com/security/cve/CVE-2021-42386\"\n },\n {\n \"url\": \"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42386\"\n }\n ],\n \"published\": \"2021-11-15 21:15:00 +0000 UTC\",\n \"updated\": \"2022-01-04 17:14:00 +0000 UTC\",\n \"affects\": [\n {\n \"ref\": \"pkg:apk/alpine/busybox@1.33.1-r3?distro=3.14.2\"\n },\n {\n \"ref\": \"pkg:apk/alpine/ssl_client@1.33.1-r3?distro=3.14.2\"\n }\n ]\n }\n ]\n}\n</code></pre>","title":"CycloneDX"},{"location":"docs/vulnerability/distributions/","text":"","title":"Distributions"},{"location":"docs/vulnerability/distributions/#cbl-mariner","text":"<p>Trivy scans CBL-Mariner.</p>","title":"CBL-Mariner"},{"location":"docs/vulnerability/distributions/#support","text":"<p>The following table provides an outline of the features Trivy offers.</p> Version Container image Virtual machine Distroless Multi-arch Unfixed support 1.0 \u2714 \u2714 amd64, arm64 \u2714 2.0 \u2714 \u27141 amd64, arm64 \u2714","title":"Support"},{"location":"docs/vulnerability/distributions/#examples","text":"<pre><code>$ trivy image cblmariner.azurecr.io/base/core:1.0\n2022-01-31T15:02:27.754+0200 INFO Detected OS: cbl-mariner\n2022-01-31T15:02:27.754+0200 INFO Detecting CBL-Mariner vulnerabilities...\n2022-01-31T15:02:27.757+0200 INFO Number of language-specific files: 0\n\ncblmariner.azurecr.io/base/core:1.0 (cbl-mariner 1.0.20220122)\n==============================================================\nTotal: 14 (UNKNOWN: 0, LOW: 0, MEDIUM: 5, HIGH: 4, CRITICAL: 5) \n</code></pre>","title":"Examples"},{"location":"docs/vulnerability/distributions/#data-source","text":"<p>See here.</p> <ol> <li> <p>It is supposed to work, but we've not tested it yet.\u00a0\u21a9</p> </li> </ol>","title":"Data source"},{"location":"docs/vulnerability/detection/data-source/","text":"OS Source Arch Linux Vulnerable Issues Alpine Linux secdb Amazon Linux 1 Amazon Linux Security Center Amazon Linux 2 Amazon Linux Security Center Debian Security Bug Tracker OVAL Ubuntu Ubuntu CVE Tracker RHEL/CentOS OVAL Security Data AlmaLinux AlmaLinux Product Errata Rocky Linux Rocky Linux UpdateInfo Oracle Linux OVAL CBL-Mariner OVAL OpenSUSE/SLES CVRF Photon OS Photon Security Advisory","title":"OS"},{"location":"docs/vulnerability/detection/data-source/#programming-language","text":"Language Source Commercial Use Delay1 PHP PHP Security Advisories Database \u2705 - GitHub Advisory Database (Composer) \u2705 - Python GitHub Advisory Database (pip) \u2705 - Open Source Vulnerabilities (PyPI) \u2705 - Ruby Ruby Advisory Database \u2705 - GitHub Advisory Database (RubyGems) \u2705 - Node.js Ecosystem Security Working Group \u2705 - GitHub Advisory Database (npm) \u2705 - Java GitLab Advisories Community \u2705 1 month GitHub Advisory Database (Maven) \u2705 - Go GitLab Advisories Community \u2705 1 month The Go Vulnerability Database \u2705 - Rust Open Source Vulnerabilities (crates.io) \u2705 - .NET GitHub Advisory Database (NuGet) \u2705 -","title":"Programming Language"},{"location":"docs/vulnerability/detection/data-source/#others","text":"Name Source National Vulnerability Database NVD <ol> <li> <p>Intentional delay between vulnerability disclosure and registration in the DB\u00a0\u21a9</p> </li> </ol>","title":"Others"},{"location":"docs/vulnerability/detection/language/","text":"<p><code>Trivy</code> automatically detects the following files in the container and scans vulnerabilities in the application dependencies.</p> Language File Image7 Rootfs8 Filesystem9 Repository10 Dev dependencies Ruby Gemfile.lock - - \u2705 \u2705 included gemspec \u2705 \u2705 - - included Python Pipfile.lock - - \u2705 \u2705 excluded poetry.lock - - \u2705 \u2705 included requirements.txt - - \u2705 \u2705 included egg package1 \u2705 \u2705 - - excluded wheel package2 \u2705 \u2705 - - excluded PHP composer.lock \u2705 \u2705 \u2705 \u2705 excluded Node.js package-lock.json - - \u2705 \u2705 excluded yarn.lock - - \u2705 \u2705 included package.json \u2705 \u2705 - - excluded .NET packages.lock.json \u2705 \u2705 \u2705 \u2705 included packages.config \u2705 \u2705 \u2705 \u2705 excluded Java JAR/WAR/PAR/EAR34 \u2705 \u2705 - - included pom.xml5 - - \u2705 \u2705 excluded Go Binaries built by Go6 \u2705 \u2705 - - excluded go.sum - - \u2705 \u2705 included Rust Cargo.lock \u2705 \u2705 \u2705 \u2705 included <p>The path of these files does not matter.</p> <p>Example: Dockerfile</p> <ol> <li> <p><code>*.egg-info</code>, <code>*.egg-info/PKG-INFO</code>, <code>*.egg</code> and <code>EGG-INFO/PKG-INFO</code> \u21a9</p> </li> <li> <p><code>.dist-info/META-DATA</code> \u21a9</p> </li> <li> <p><code>*.jar</code>, <code>*.war</code>, <code>*.par</code> and <code>*.ear</code> \u21a9</p> </li> <li> <p>It requires Internet access\u00a0\u21a9</p> </li> <li> <p>It requires Internet access when the POM doesn't exist in your local repository\u00a0\u21a9</p> </li> <li> <p>UPX-compressed binaries don't work\u00a0\u21a9</p> </li> <li> <p>\u2705 means \"enabled\" and <code>-</code> means \"disabled\" in the image scanning\u00a0\u21a9</p> </li> <li> <p>\u2705 means \"enabled\" and <code>-</code> means \"disabled\" in the rootfs scanning\u00a0\u21a9</p> </li> <li> <p>\u2705 means \"enabled\" and <code>-</code> means \"disabled\" in the filesystem scanning\u00a0\u21a9</p> </li> <li> <p>\u2705 means \"enabled\" and <code>-</code> means \"disabled\" in the git repository scanning\u00a0\u21a9</p> </li> </ol>","title":"Language-specific Packages"},{"location":"docs/vulnerability/detection/os/","text":"<p>The unfixed/unfixable vulnerabilities mean that the patch has not yet been provided on their distribution. Trivy doesn't support self-compiled packages/binaries, but official packages provided by vendors such as Red Hat and Debian.</p> OS Supported Versions Target Packages Detection of unfixed vulnerabilities Alpine Linux 2.2 - 2.7, 3.0 - 3.15, edge Installed by apk NO Red Hat Universal Base Image1 7, 8 Installed by yum/rpm YES Red Hat Enterprise Linux 6, 7, 8 Installed by yum/rpm YES CentOS 6, 7, 8 Installed by yum/rpm YES AlmaLinux 8 Installed by yum/rpm NO Rocky Linux 8 Installed by yum/rpm NO Oracle Linux 5, 6, 7, 8 Installed by yum/rpm NO CBL-Mariner 1.0, 2.0 Installed by yum/rpm YES Amazon Linux 1, 2 Installed by yum/rpm NO openSUSE Leap 42, 15 Installed by zypper/rpm NO SUSE Enterprise Linux 11, 12, 15 Installed by zypper/rpm NO Photon OS 1.0, 2.0, 3.0, 4.0 Installed by tdnf/yum/rpm NO Debian GNU/Linux wheezy, jessie, stretch, buster, bullseye Installed by apt/apt-get/dpkg YES Ubuntu All versions supported by Canonical Installed by apt/apt-get/dpkg YES Distroless2 Any Installed by apt/apt-get/dpkg YES <ol> <li> <p>https://developers.redhat.com/products/rhel/ubi\u00a0\u21a9</p> </li> <li> <p>https://github.com/GoogleContainerTools/distroless\u00a0\u21a9</p> </li> </ol>","title":"Supported OS"},{"location":"docs/vulnerability/detection/supported/","text":"","title":"Supported"},{"location":"docs/vulnerability/detection/supported/#container-runtime","text":"<ul> <li>Docker Engine</li> <li>Podman</li> </ul>","title":"Container Runtime"},{"location":"docs/vulnerability/detection/supported/#container-registry","text":"<ul> <li>Docker Registry HTTP API V2</li> <li>OCI Distribution Specification</li> </ul>","title":"Container Registry"},{"location":"docs/vulnerability/detection/supported/#image-tar-formats","text":"<p>Trivy scans a tar image with the following format.</p> <ul> <li>Docker Image Specification<ul> <li>Moby Project</li> <li>Buildah</li> <li>Podman</li> <li>img</li> </ul> </li> <li>Kaniko</li> </ul>","title":"Image Tar Formats"},{"location":"docs/vulnerability/detection/supported/#image-layout","text":"<ul> <li>OCI Image Format Specification</li> </ul>","title":"Image Layout"},{"location":"docs/vulnerability/examples/cache/","text":"","title":"Cache"},{"location":"docs/vulnerability/examples/cache/#clear-caches","text":"<p>The <code>--clear-cache</code> option removes caches.</p> <p>The scan is not performed.</p> <pre><code>$ trivy image --clear-cache\n</code></pre> Result <pre><code>2019-11-15T15:13:26.209+0200 INFO Reopening vulnerability DB\n2019-11-15T15:13:26.209+0200 INFO Removing image caches...\n</code></pre>","title":"Clear Caches"},{"location":"docs/vulnerability/examples/cache/#cache-directory","text":"<p>Specify where the cache is stored with <code>--cache-dir</code>.</p> <pre><code>$ trivy --cache-dir /tmp/trivy/ image python:3.4-alpine3.9\n</code></pre>","title":"Cache Directory"},{"location":"docs/vulnerability/examples/cache/#cache-backend","text":"<p>EXPERIMENTAL</p> <p>This feature might change without preserving backwards compatibility.</p> <p>Trivy supports local filesystem and Redis as the cache backend. This option is useful especially for client/server mode.</p> <p>Two options: - <code>fs</code> - the cache path can be specified by <code>--cache-dir</code> - <code>redis://</code> - <code>redis://[HOST]:[PORT]</code></p> <pre><code>$ trivy server --cache-backend redis://localhost:6379\n</code></pre> <p>Trivy also support for connecting to Redis using TLS, you only need to specify <code>--redis-ca</code> , <code>--redis-cert</code> , and <code>--redis-key</code> option.</p> <pre><code>$ trivy server --cache-backend redis://localhost:6379 \\\n --redis-ca /path/to/ca-cert.pem \\\n --redis-cert /path/to/cert.pem \\\n --redis-key /path/to/key.pem\n</code></pre> <p>TLS option for redis is hidden from Trivy command-line flag, but you still can use it.</p>","title":"Cache Backend"},{"location":"docs/vulnerability/examples/db/","text":"","title":"Vulnerability DB"},{"location":"docs/vulnerability/examples/db/#skip-update-of-vulnerability-db","text":"<p><code>Trivy</code> downloads its vulnerability database every 12 hours when it starts operating. This is usually fast, as the size of the DB is only 10~30MB. But if you want to skip even that, use the <code>--skip-db-update</code> option.</p> <pre><code>$ trivy image --skip-db-update python:3.4-alpine3.9\n</code></pre> Result <pre><code>2019-05-16T12:48:08.703+0900 INFO Detecting Alpine vulnerabilities...\n\npython:3.4-alpine3.9 (alpine 3.9.2)\n===================================\nTotal: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)\n\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |\n| | | | | | with long nonces |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n</code></pre>","title":"Skip update of vulnerability DB"},{"location":"docs/vulnerability/examples/db/#only-download-vulnerability-database","text":"<p>You can also ask <code>Trivy</code> to simply retrieve the vulnerability database. This is useful to initialize workers in Continuous Integration systems.</p> <pre><code>$ trivy image --download-db-only\n</code></pre>","title":"Only download vulnerability database"},{"location":"docs/vulnerability/examples/db/#db-repository","text":"<p><code>Trivy</code> could also download the vulnerability database from an external OCI registry by using <code>--db-repository</code> option.</p> <pre><code>$ trivy image --db-repository registry.gitlab.com/gitlab-org/security-products/dependencies/trivy-db\n</code></pre>","title":"DB Repository"},{"location":"docs/vulnerability/examples/filter/","text":"","title":"Filter Vulnerabilities"},{"location":"docs/vulnerability/examples/filter/#hide-unfixed-vulnerabilities","text":"<p>By default, <code>Trivy</code> also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the <code>--ignore-unfixed</code> option.</p> <pre><code>$ trivy image --ignore-unfixed ruby:2.4.0\n</code></pre> Result <pre><code>2019-05-16T12:49:52.656+0900 INFO Updating vulnerability database...\n2019-05-16T12:50:14.786+0900 INFO Detecting Debian vulnerabilities...\n\nruby:2.4.0 (debian 8.7)\n=======================\nTotal: 4730 (UNKNOWN: 1, LOW: 145, MEDIUM: 3487, HIGH: 1014, CRITICAL: 83)\n\n+------------------------------+------------------+----------+----------------------------+----------------------------------+-----------------------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+------------------------------+------------------+----------+----------------------------+----------------------------------+-----------------------------------------------------+\n| apt | CVE-2019-3462 | CRITICAL | 1.0.9.8.3 | 1.0.9.8.5 | Incorrect sanitation of the |\n| | | | | | 302 redirect field in HTTP |\n| | | | | | transport method of... |\n+ +------------------+----------+ +----------------------------------+-----------------------------------------------------+\n| | CVE-2016-1252 | MEDIUM | | 1.0.9.8.4 | The apt package in Debian |\n| | | | | | jessie before 1.0.9.8.4, in |\n| | | | | | Debian unstable before... |\n+------------------------------+------------------+----------+----------------------------+----------------------------------+-----------------------------------------------------+\n| bash | CVE-2019-9924 | HIGH | 4.3-11 | 4.3-11+deb8u2 | bash: BASH_CMD is writable in |\n| | | | | | restricted bash shells |\n+ +------------------+ + +----------------------------------+-----------------------------------------------------+\n| | CVE-2016-7543 | | | 4.3-11+deb8u1 | bash: Specially crafted |\n| | | | | | SHELLOPTS+PS4 variables allows |\n| | | | | | command substitution |\n+ +------------------+----------+ + +-----------------------------------------------------+\n| | CVE-2016-0634 | MEDIUM | | | bash: Arbitrary code execution |\n| | | | | | via malicious hostname |\n+ +------------------+----------+ +----------------------------------+-----------------------------------------------------+\n| | CVE-2016-9401 | LOW | | 4.3-11+deb8u2 | bash: popd controlled free |\n+------------------------------+------------------+----------+----------------------------+----------------------------------+-----------------------------------------------------+\n...\n</code></pre>","title":"Hide Unfixed Vulnerabilities"},{"location":"docs/vulnerability/examples/filter/#by-severity","text":"<p>Use <code>--severity</code> option.</p> <pre><code>$ trivy image --severity HIGH,CRITICAL ruby:2.4.0\n</code></pre> Result <pre><code>2019-05-16T01:51:46.255+0900 INFO Updating vulnerability database...\n2019-05-16T01:51:49.213+0900 INFO Detecting Debian vulnerabilities...\n\nruby:2.4.0 (debian 8.7)\n=======================\nTotal: 1785 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1680, CRITICAL: 105)\n\n+-----------------------------+------------------+----------+---------------------------+----------------------------------+-------------------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+-----------------------------+------------------+----------+---------------------------+----------------------------------+-------------------------------------------------+\n| apt | CVE-2019-3462 | CRITICAL | 1.0.9.8.3 | 1.0.9.8.5 | Incorrect sanitation of the |\n| | | | | | 302 redirect field in HTTP |\n| | | | | | transport method of... |\n+-----------------------------+------------------+----------+---------------------------+----------------------------------+-------------------------------------------------+\n| bash | CVE-2019-9924 | HIGH | 4.3-11 | 4.3-11+deb8u2 | bash: BASH_CMD is writable in |\n| | | | | | restricted bash shells |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2016-7543 | | | 4.3-11+deb8u1 | bash: Specially crafted |\n| | | | | | SHELLOPTS+PS4 variables allows |\n| | | | | | command substitution |\n+-----------------------------+------------------+ +---------------------------+----------------------------------+-------------------------------------------------+\n| binutils | CVE-2017-8421 | | 2.25-5 | | binutils: Memory exhaustion in |\n| | | | | | objdump via a crafted PE file |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2017-14930 | | | | binutils: Memory leak in |\n| | | | | | decode_line_info |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2017-7614 | | | | binutils: NULL |\n| | | | | | pointer dereference in |\n| | | | | | bfd_elf_final_link function |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2014-9939 | | | | binutils: buffer overflow in |\n| | | | | | ihex.c |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2017-13716 | | | | binutils: Memory leak with the |\n| | | | | | C++ symbol demangler routine |\n| | | | | | in libiberty |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2018-12699 | | | | binutils: heap-based buffer |\n| | | | | | overflow in finish_stab in |\n| | | | | | stabs.c |\n+-----------------------------+------------------+ +---------------------------+----------------------------------+-------------------------------------------------+\n| bsdutils | CVE-2015-5224 | | 2.25.2-6 | | util-linux: File name |\n| | | | | | collision due to incorrect |\n| | | | | | mkstemp use |\n+ +------------------+ + +----------------------------------+-------------------------------------------------+\n| | CVE-2016-2779 | | | | util-linux: runuser tty hijack |\n| | | | | | via TIOCSTI ioctl |\n+-----------------------------+------------------+----------+---------------------------+----------------------------------+-------------------------------------------------+\n</code></pre>","title":"By Severity"},{"location":"docs/vulnerability/examples/filter/#by-vulnerability-ids","text":"<p>Use <code>.trivyignore</code>.</p> <pre><code>$ cat .trivyignore\n# Accept the risk\nCVE-2018-14618\n\n# No impact in our settings\nCVE-2019-1543\n\n$ trivy image python:3.4-alpine3.9\n</code></pre> Result <pre><code>2019-05-16T12:53:10.076+0900 INFO Updating vulnerability database...\n2019-05-16T12:53:28.134+0900 INFO Detecting Alpine vulnerabilities...\n\npython:3.4-alpine3.9 (alpine 3.9.2)\n===================================\nTotal: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)\n</code></pre>","title":"By Vulnerability IDs"},{"location":"docs/vulnerability/examples/filter/#by-type","text":"<p>Use <code>--vuln-type</code> option.</p> <pre><code>$ trivy image --vuln-type os ruby:2.4.0\n</code></pre> <p>Available values: - library - os</p> Result <pre><code>2019-05-22T19:36:50.530+0200 \u001b[34mINFO\u001b[0m Updating vulnerability database...\n2019-05-22T19:36:51.681+0200 \u001b[34mINFO\u001b[0m Detecting Alpine vulnerabilities...\n2019-05-22T19:36:51.685+0200 \u001b[34mINFO\u001b[0m Updating npm Security DB...\n2019-05-22T19:36:52.389+0200 \u001b[34mINFO\u001b[0m Detecting npm vulnerabilities...\n2019-05-22T19:36:52.390+0200 \u001b[34mINFO\u001b[0m Updating pipenv Security DB...\n2019-05-22T19:36:53.406+0200 \u001b[34mINFO\u001b[0m Detecting pipenv vulnerabilities...\n\nruby:2.4.0 (debian 8.7)\nTotal: 4751 (UNKNOWN: 1, LOW: 150, MEDIUM: 3504, HIGH: 1013, CRITICAL: 83)\n\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| curl | CVE-2018-14618 | CRITICAL | 7.61.0-r0 | 7.61.1-r0 | curl: NTLM password overflow |\n| | | | | | via integer overflow |\n+ +------------------+----------+ +---------------+----------------------------------+\n| | CVE-2018-16839 | HIGH | | 7.61.1-r1 | curl: Integer overflow leading |\n| | | | | | to heap-based buffer overflow in |\n| | | | | | Curl_sasl_create_plain_message() |\n+ +------------------+ + +---------------+----------------------------------+\n| | CVE-2019-3822 | | | 7.61.1-r2 | curl: NTLMv2 type-3 header |\n| | | | | | stack buffer overflow |\n+ +------------------+ + +---------------+----------------------------------+\n| | CVE-2018-16840 | | | 7.61.1-r1 | curl: Use-after-free when |\n| | | | | | closing \"easy\" handle in |\n| | | | | | Curl_close() |\n+ +------------------+----------+ +---------------+----------------------------------+\n| | CVE-2019-3823 | MEDIUM | | 7.61.1-r2 | curl: SMTP end-of-response |\n| | | | | | out-of-bounds read |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2018-16890 | | | | curl: NTLM type-2 heap |\n| | | | | | out-of-bounds buffer read |\n+ +------------------+ + +---------------+----------------------------------+\n| | CVE-2018-16842 | | | 7.61.1-r1 | curl: Heap-based buffer |\n| | | | | | over-read in the curl tool |\n| | | | | | warning formatting |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| git | CVE-2018-17456 | HIGH | 2.15.2-r0 | 2.15.3-r0 | git: arbitrary code execution |\n| | | | | | via .gitmodules |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2018-19486 | | | | git: Improper handling of |\n| | | | | | PATH allows for commands to be |\n| | | | | | executed from... |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| libssh2 | CVE-2019-3855 | CRITICAL | 1.8.0-r2 | 1.8.1-r0 | libssh2: Integer overflow in |\n| | | | | | transport read resulting in |\n| | | | | | out of bounds write... |\n+ +------------------+----------+ + +----------------------------------+\n| | CVE-2019-3861 | MEDIUM | | | libssh2: Out-of-bounds reads |\n| | | | | | with specially crafted SSH |\n| | | | | | packets |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3857 | | | | libssh2: Integer overflow in |\n| | | | | | SSH packet processing channel |\n| | | | | | resulting in out of... |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3856 | | | | libssh2: Integer overflow in |\n| | | | | | keyboard interactive handling |\n| | | | | | resulting in out of bounds... |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3863 | | | | libssh2: Integer overflow |\n| | | | | | in user authenticate |\n| | | | | | keyboard interactive allows |\n| | | | | | out-of-bounds writes |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3862 | | | | libssh2: Out-of-bounds memory |\n| | | | | | comparison with specially |\n| | | | | | crafted message channel |\n| | | | | | request |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3860 | | | | libssh2: Out-of-bounds reads |\n| | | | | | with specially crafted SFTP |\n| | | | | | packets |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3858 | | | | libssh2: Zero-byte allocation |\n| | | | | | with a specially crafted SFTP |\n| | | | | | packed leading to an... |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-3859 | | | | libssh2: Unchecked use of |\n| | | | | | _libssh2_packet_require and |\n| | | | | | _libssh2_packet_requirev |\n| | | | | | resulting in out-of-bounds |\n| | | | | | read |\n+---------+------------------+ +-------------------+---------------+----------------------------------+\n| libxml2 | CVE-2018-14404 | | 2.9.7-r0 | 2.9.8-r1 | libxml2: NULL pointer |\n| | | | | | dereference in |\n| | | | | | xpath.c:xmlXPathCompOpEval() |\n| | | | | | can allow attackers to cause |\n| | | | | | a... |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2018-14567 | | | | libxml2: Infinite loop when |\n| | | | | | --with-lzma is used allows for |\n| | | | | | denial of service... |\n+ +------------------+----------+ + +----------------------------------+\n| | CVE-2018-9251 | LOW | | | libxml2: infinite loop in |\n| | | | | | xz_decomp function in xzlib.c |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| openssh | CVE-2019-6109 | MEDIUM | 7.5_p1-r9 | 7.5_p1-r10 | openssh: Missing character |\n| | | | | | encoding in progress display |\n| | | | | | allows for spoofing of scp... |\n+ +------------------+ + + +----------------------------------+\n| | CVE-2019-6111 | | | | openssh: Improper validation |\n| | | | | | of object names allows |\n| | | | | | malicious server to overwrite |\n| | | | | | files... |\n+ +------------------+----------+ + +----------------------------------+\n| | CVE-2018-20685 | LOW | | | openssh: scp client improper |\n| | | | | | directory name validation |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| sqlite | CVE-2018-20346 | MEDIUM | 3.21.0-r1 | 3.25.3-r0 | CVE-2018-20505 CVE-2018-20506 |\n| | | | | | sqlite: Multiple flaws in |\n| | | | | | sqlite which can be triggered |\n| | | | | | via... |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n| tar | CVE-2018-20482 | LOW | 1.29-r1 | 1.31-r0 | tar: Infinite read loop in |\n| | | | | | sparse_dump_region function in |\n| | | | | | sparse.c |\n+---------+------------------+----------+-------------------+---------------+----------------------------------+\n</code></pre>","title":"By Type"},{"location":"docs/vulnerability/examples/filter/#by-open-policy-agent","text":"<p>EXPERIMENTAL</p> <p>This feature might change without preserving backwards compatibility.</p> <p>Trivy supports Open Policy Agent (OPA) to filter vulnerabilities. You can specify a Rego file with <code>--ignore-policy</code> option.</p> <p>The Rego package name must be <code>trivy</code> and it must include a rule called <code>ignore</code> which determines if each individual vulnerability should be excluded (ignore=true) or not (ignore=false). In the policy, each vulnerability will be available for inspection as the <code>input</code> variable. The structure of each vulnerability input is the same as for the Trivy JSON output. There is a built-in Rego library with helper functions that you can import into your policy using: <code>import data.lib.trivy</code>. For more info about the helper functions, look at the library here</p> <p>To get started, see the example policy.</p> <pre><code>$ trivy image --ignore-policy contrib/example_policy/basic.rego centos:7\n</code></pre> Result <pre><code>centos:7 (centos 7.9.2009)\n==========================\nTotal: 9 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 4, CRITICAL: 5)\n\n+--------------+------------------+----------+-------------------+-------------------+-----------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+--------------+------------------+----------+-------------------+-------------------+-----------------------------------------+\n| glib2 | CVE-2015-8385 | HIGH | 2.56.1-7.el7 | | pcre: buffer overflow caused |\n| | | | | | by named forward reference |\n| | | | | | to duplicate group number... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2015-8385 |\n+ +------------------+ + +-------------------+-----------------------------------------+\n| | CVE-2016-3191 | | | | pcre: workspace overflow for |\n| | | | | | (*ACCEPT) with deeply nested |\n| | | | | | parentheses (8.39/13, 10.22/12) |\n| | | | | | -->avd.aquasec.com/nvd/cve-2016-3191 |\n+ +------------------+ + +-------------------+-----------------------------------------+\n| | CVE-2021-27219 | | | 2.56.1-9.el7_9 | glib: integer overflow in |\n| | | | | | g_bytes_new function on |\n| | | | | | 64-bit platforms due to an... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-27219 |\n+--------------+------------------+----------+-------------------+-------------------+-----------------------------------------+\n| glibc | CVE-2019-1010022 | CRITICAL | 2.17-317.el7 | | glibc: stack guard protection bypass |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-1010022 |\n+--------------+ + + +-------------------+ +\n| glibc-common | | | | | |\n| | | | | | |\n+--------------+------------------+ +-------------------+-------------------+-----------------------------------------+\n| nss | CVE-2021-43527 | | 3.53.1-3.el7_9 | 3.67.0-4.el7_9 | nss: Memory corruption in |\n| | | | | | decodeECorDsaSignature with |\n| | | | | | DSA signatures (and RSA-PSS) |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-43527 |\n+--------------+ + + + + +\n| nss-sysinit | | | | | |\n| | | | | | |\n| | | | | | |\n| | | | | | |\n+--------------+ + + + + +\n| nss-tools | | | | | |\n| | | | | | |\n| | | | | | |\n| | | | | | |\n+--------------+------------------+----------+-------------------+-------------------+-----------------------------------------+\n| openssl-libs | CVE-2020-1971 | HIGH | 1:1.0.2k-19.el7 | 1:1.0.2k-21.el7_9 | openssl: EDIPARTYNAME |\n| | | | | | NULL pointer de-reference |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-1971 |\n+--------------+------------------+----------+-------------------+-------------------+-----------------------------------------+\n</code></pre>","title":"By Open Policy Agent"},{"location":"docs/vulnerability/examples/others/","text":"","title":"Others"},{"location":"docs/vulnerability/examples/others/#skip-files","text":"<p>Trivy traversals directories and looks for all lock files by default. If your image contains lock files which are not maintained by you, you can skip the file.</p> <pre><code>$ trivy image --skip-files \"/Gemfile.lock\" --skip-files \"/var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0/Gemfile.lock\" quay.io/fluentd_elasticsearch/fluentd:v2.9.0\n</code></pre>","title":"Skip Files"},{"location":"docs/vulnerability/examples/others/#skip-directories","text":"<p>Trivy traversals directories and look for all lock files by default. If your image contains lock files which are not maintained by you, you can skip traversal in the specific directory.</p> <pre><code>$ trivy image --skip-dirs /var/lib/gems/2.5.0/gems/fluent-plugin-detect-exceptions-0.0.13 --skip-dirs \"/var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0\" quay.io/fluentd_elasticsearch/fluentd:v2.9.0\n</code></pre>","title":"Skip Directories"},{"location":"docs/vulnerability/examples/others/#exit-code","text":"<p>By default, <code>Trivy</code> exits with code 0 even when vulnerabilities are detected. Use the <code>--exit-code</code> option if you want to exit with a non-zero exit code.</p> <pre><code>$ trivy image --exit-code 1 python:3.4-alpine3.9\n</code></pre> Result <pre><code>2019-05-16T12:51:43.500+0900 INFO Updating vulnerability database...\n2019-05-16T12:52:00.387+0900 INFO Detecting Alpine vulnerabilities...\n\npython:3.4-alpine3.9 (alpine 3.9.2)\n===================================\nTotal: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)\n\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |\n| | | | | | with long nonces |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n</code></pre> <p>This option is useful for CI/CD. In the following example, the test will fail only when a critical vulnerability is found.</p> <pre><code>$ trivy image --exit-code 0 --severity MEDIUM,HIGH ruby:2.4.0\n$ trivy image --exit-code 1 --severity CRITICAL ruby:2.4.0\n</code></pre>","title":"Exit Code"},{"location":"docs/vulnerability/examples/others/#reset","text":"<p>The <code>--reset</code> option removes all caches and database. After this, it takes a long time as the vulnerability database needs to be rebuilt locally.</p> <pre><code>$ trivy image --reset\n</code></pre> Result <pre><code>2019-05-16T13:05:31.935+0900 INFO Resetting...\n</code></pre>","title":"Reset"},{"location":"docs/vulnerability/examples/report/","text":"","title":"Report Formats"},{"location":"docs/vulnerability/examples/report/#table-default","text":"<pre><code>$ trivy image -f table golang:1.12-alpine\n</code></pre>","title":"Table (Default)"},{"location":"docs/vulnerability/examples/report/#json","text":"<pre><code>$ trivy image -f json -o results.json golang:1.12-alpine\n</code></pre> <p>Caution</p> <p>v0.20.0 changes the JSON schema. For more details, see here.</p> Result <pre><code>2019-05-16T01:46:31.777+0900 INFO Updating vulnerability database...\n2019-05-16T01:47:03.007+0900 INFO Detecting Alpine vulnerabilities...\n</code></pre> JSON <pre><code>[\n {\n \"Target\": \"php-app/composer.lock\",\n \"Vulnerabilities\": null\n },\n {\n \"Target\": \"node-app/package-lock.json\",\n \"Vulnerabilities\": [\n {\n \"VulnerabilityID\": \"CVE-2018-16487\",\n \"PkgName\": \"lodash\",\n \"InstalledVersion\": \"4.17.4\",\n \"FixedVersion\": \"\\u003e=4.17.11\",\n \"Title\": \"lodash: Prototype pollution in utilities function\",\n \"Description\": \"A prototype pollution vulnerability was found in lodash \\u003c4.17.11 where the functions merge, mergeWith, and defaultsDeep can be tricked into adding or modifying properties of Object.prototype.\",\n \"Severity\": \"HIGH\",\n \"References\": [\n \"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-16487\",\n ]\n }\n ]\n },\n {\n \"Target\": \"trivy-ci-test (alpine 3.7.1)\",\n \"Vulnerabilities\": [\n {\n \"VulnerabilityID\": \"CVE-2018-16840\",\n \"PkgName\": \"curl\",\n \"InstalledVersion\": \"7.61.0-r0\",\n \"FixedVersion\": \"7.61.1-r1\",\n \"Title\": \"curl: Use-after-free when closing \\\"easy\\\" handle in Curl_close()\",\n \"Description\": \"A heap use-after-free flaw was found in curl versions from 7.59.0 through 7.61.1 in the code related to closing an easy handle. \",\n \"Severity\": \"HIGH\",\n \"References\": [\n \"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-16840\",\n ]\n },\n {\n \"VulnerabilityID\": \"CVE-2019-3822\",\n \"PkgName\": \"curl\",\n \"InstalledVersion\": \"7.61.0-r0\",\n \"FixedVersion\": \"7.61.1-r2\",\n \"Title\": \"curl: NTLMv2 type-3 header stack buffer overflow\",\n \"Description\": \"libcurl versions from 7.36.0 to before 7.64.0 are vulnerable to a stack-based buffer overflow. \",\n \"Severity\": \"HIGH\",\n \"References\": [\n \"https://curl.haxx.se/docs/CVE-2019-3822.html\",\n \"https://lists.apache.org/thread.html/8338a0f605bdbb3a6098bb76f666a95fc2b2f53f37fa1ecc89f1146f@%3Cdevnull.infra.apache.org%3E\"\n ]\n },\n {\n \"VulnerabilityID\": \"CVE-2018-16839\",\n \"PkgName\": \"curl\",\n \"InstalledVersion\": \"7.61.0-r0\",\n \"FixedVersion\": \"7.61.1-r1\",\n \"Title\": \"curl: Integer overflow leading to heap-based buffer overflow in Curl_sasl_create_plain_message()\",\n \"Description\": \"Curl versions 7.33.0 through 7.61.1 are vulnerable to a buffer overrun in the SASL authentication code that may lead to denial of service.\",\n \"Severity\": \"HIGH\",\n \"References\": [\n \"https://github.com/curl/curl/commit/f3a24d7916b9173c69a3e0ee790102993833d6c5\",\n ]\n },\n {\n \"VulnerabilityID\": \"CVE-2018-19486\",\n \"PkgName\": \"git\",\n \"InstalledVersion\": \"2.15.2-r0\",\n \"FixedVersion\": \"2.15.3-r0\",\n \"Title\": \"git: Improper handling of PATH allows for commands to be executed from the current directory\",\n \"Description\": \"Git before 2.19.2 on Linux and UNIX executes commands from the current working directory (as if '.' were at the end of $PATH) in certain cases involving the run_command() API and run-command.c, because there was a dangerous change from execvp to execv during 2017.\",\n \"Severity\": \"HIGH\",\n \"References\": [\n \"https://usn.ubuntu.com/3829-1/\",\n ]\n },\n {\n \"VulnerabilityID\": \"CVE-2018-17456\",\n \"PkgName\": \"git\",\n \"InstalledVersion\": \"2.15.2-r0\",\n \"FixedVersion\": \"2.15.3-r0\",\n \"Title\": \"git: arbitrary code execution via .gitmodules\",\n \"Description\": \"Git before 2.14.5, 2.15.x before 2.15.3, 2.16.x before 2.16.5, 2.17.x before 2.17.2, 2.18.x before 2.18.1, and 2.19.x before 2.19.1 allows remote code execution during processing of a recursive \\\"git clone\\\" of a superproject if a .gitmodules file has a URL field beginning with a '-' character.\",\n \"Severity\": \"HIGH\",\n \"References\": [\n \"http://www.securitytracker.com/id/1041811\",\n ]\n }\n ]\n },\n {\n \"Target\": \"python-app/Pipfile.lock\",\n \"Vulnerabilities\": null\n },\n {\n \"Target\": \"ruby-app/Gemfile.lock\",\n \"Vulnerabilities\": null\n },\n {\n \"Target\": \"rust-app/Cargo.lock\",\n \"Vulnerabilities\": null\n }\n]\n</code></pre> <p><code>VulnerabilityID</code>, <code>PkgName</code>, <code>InstalledVersion</code>, and <code>Severity</code> in <code>Vulnerabilities</code> are always filled with values, but other fields might be empty.</p>","title":"JSON"},{"location":"docs/vulnerability/examples/report/#sarif","text":"<p>Sarif can be generated with the <code>--format sarif</code> option.</p> <pre><code>$ trivy image --format sarif -o report.sarif golang:1.12-alpine\n</code></pre> <p>This SARIF file can be uploaded to GitHub code scanning results, and there is a Trivy GitHub Action for automating this process.</p>","title":"SARIF"},{"location":"docs/vulnerability/examples/report/#template","text":"","title":"Template"},{"location":"docs/vulnerability/examples/report/#custom-template","text":"<pre><code>$ trivy image --format template --template \"{{ range . }} {{ .Target }} {{ end }}\" golang:1.12-alpine\n</code></pre> Result <pre><code>2020-01-02T18:02:32.856+0100 INFO Detecting Alpine vulnerabilities...\n golang:1.12-alpine (alpine 3.10.2)\n</code></pre> <p>You can compute different figures within the template using sprig functions. As an example you can summarize the different classes of issues:</p> <pre><code>$ trivy image --format template --template '{{- $critical := 0 }}{{- $high := 0 }}{{- range . }}{{- range .Vulnerabilities }}{{- if eq .Severity \"CRITICAL\" }}{{- $critical = add $critical 1 }}{{- end }}{{- if eq .Severity \"HIGH\" }}{{- $high = add $high 1 }}{{- end }}{{- end }}{{- end }}Critical: {{ $critical }}, High: {{ $high }}' golang:1.12-alpine\n</code></pre> Result <pre><code>Critical: 0, High: 2\n</code></pre> <p>For other features of sprig, see the official sprig documentation.</p>","title":"Custom Template"},{"location":"docs/vulnerability/examples/report/#load-templates-from-a-file","text":"<p>You can load templates from a file prefixing the template path with an @.</p> <pre><code>$ trivy image --format template --template \"@/path/to/template\" golang:1.12-alpine\n</code></pre>","title":"Load templates from a file"},{"location":"docs/vulnerability/examples/report/#default-templates","text":"<p>If Trivy is installed using rpm then default templates can be found at <code>/usr/local/share/trivy/templates</code>.</p>","title":"Default Templates"},{"location":"docs/vulnerability/examples/report/#xml","text":"<p>In the following example using the template <code>junit.tpl</code> XML can be generated. <pre><code>$ trivy image --format template --template \"@contrib/junit.tpl\" -o junit-report.xml golang:1.12-alpine\n</code></pre></p>","title":"XML"},{"location":"docs/vulnerability/examples/report/#asff","text":"<p>Trivy also supports an ASFF template for reporting findings to AWS Security Hub</p>","title":"ASFF"},{"location":"docs/vulnerability/examples/report/#html","text":"<pre><code>$ trivy image --format template --template \"@contrib/html.tpl\" -o report.html golang:1.12-alpine\n</code></pre> <p>The following example shows use of default HTML template when Trivy is installed using rpm.</p> <pre><code>$ trivy image --format template --template \"@/usr/local/share/trivy/templates/html.tpl\" -o report.html golang:1.12-alpine\n</code></pre>","title":"HTML"},{"location":"docs/vulnerability/languages/golang/","text":"","title":"Go"},{"location":"docs/vulnerability/languages/golang/#features","text":"<p>Trivy supports two types of Go scanning, Go Modules and binaries built by Go. The following table provides an outline of the features Trivy offers.</p> Artifact Offline1 Dev dependencies Modules \u2713 Include Binaries \u2713 Exclude <p>Note</p> <p>Trivy scans only dependencies of the Go project. Let's say you scan the Docker binary, Trivy doesn't detect vulnerabilities of Docker itself. Also, when you scan go.mod in Kubernetes, the Kubernetes vulnerabilities will not be found.</p>","title":"Features"},{"location":"docs/vulnerability/languages/golang/#go-modules","text":"<p>Depending on Go versions, the required files are different.</p> Version Required files Offline License >=1.17 go.mod \u2713 - <1.17 go.mod, go.sum \u2713 - <p>In Go 1.17+ projects, Trivy uses <code>go.mod</code> for direct/indirect dependencies. On the other hand, it uses <code>go.mod</code> for direct dependencies and <code>go.sum</code> for indirect dependencies in Go 1.16 or less.</p> <p>Go 1.17+ holds actually needed indirect dependencies in <code>go.mod</code>, and it reduces false detection. <code>go.sum</code> in Go 1.16 or less contains all indirect dependencies that are even not needed for compiling. If you want to have better detection, please consider updating the Go version in your project.</p> <p>Note</p> <p>The Go version doesn't mean your CLI version, but the Go version in your go.mod.</p> <pre><code>module github.com/aquasecurity/trivy\n\ngo 1.18\n\nrequire (\n github.com/CycloneDX/cyclonedx-go v0.5.0\n ...\n)\n</code></pre> <p>To update the Go version in your project, you need to run the following command.</p> <pre><code>$ go mod tidy -go=1.18\n</code></pre>","title":"Go Modules"},{"location":"docs/vulnerability/languages/golang/#go-binaries","text":"<p>Trivy scans binaries built by Go. If there is a Go binary in your container image, Trivy automatically finds and scans it.</p> <p>Also, you can scan your local binaries.</p> <pre><code>$ trivy fs ./your_binary\n</code></pre> <ol> <li> <p>It doesn't require the Internet access.\u00a0\u21a9</p> </li> </ol>","title":"Go binaries"},{"location":"docs/vulnerability/scanning/","text":"<p>Trivy scans Container Images, Rootfs, Filesystem, and Git Repositories to detect vulnerabilities.</p> <p></p>","title":"Vulnerability Scanning"},{"location":"docs/vulnerability/scanning/filesystem/","text":"<p>Scan a local project including language-specific files.</p> <pre><code>$ trivy fs /path/to/project\n</code></pre>","title":"Filesystem"},{"location":"docs/vulnerability/scanning/filesystem/#standalone-mode","text":"","title":"Standalone mode"},{"location":"docs/vulnerability/scanning/filesystem/#local-project","text":"<p>Trivy will look for vulnerabilities based on lock files such as Gemfile.lock and package-lock.json.</p> <pre><code>$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test\n</code></pre> Result <pre><code>2020-06-01T17:06:58.652+0300 WARN OS is not detected and vulnerabilities in OS packages are not detected.\n2020-06-01T17:06:58.652+0300 INFO Detecting pipenv vulnerabilities...\n2020-06-01T17:06:58.691+0300 INFO Detecting cargo vulnerabilities...\n\nPipfile.lock\n============\nTotal: 10 (UNKNOWN: 2, LOW: 0, MEDIUM: 6, HIGH: 2, CRITICAL: 0)\n\n+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+\n| django | CVE-2020-7471 | HIGH | 2.0.9 | 3.0.3, 2.2.10, 1.11.28 | django: potential |\n| | | | | | SQL injection via |\n| | | | | | StringAgg(delimiter) |\n+ +------------------+----------+ +------------------------+------------------------------------+\n| | CVE-2019-19844 | MEDIUM | | 3.0.1, 2.2.9, 1.11.27 | Django: crafted email address |\n| | | | | | allows account takeover |\n+ +------------------+ + +------------------------+------------------------------------+\n| | CVE-2019-3498 | | | 2.1.5, 2.0.10, 1.11.18 | python-django: Content |\n| | | | | | spoofing via URL path in |\n| | | | | | default 404 page |\n+ +------------------+ + +------------------------+------------------------------------+\n| | CVE-2019-6975 | | | 2.1.6, 2.0.11, 1.11.19 | python-django: |\n| | | | | | memory exhaustion in |\n| | | | | | django.utils.numberformat.format() |\n+---------------------+------------------+----------+-------------------+------------------------+------------------------------------+\n...\n</code></pre>","title":"Local Project"},{"location":"docs/vulnerability/scanning/filesystem/#single-file","text":"<p>It's also possible to scan a single file.</p> <pre><code>$ trivy fs ~/src/github.com/aquasecurity/trivy-ci-test/Pipfile.lock\n</code></pre>","title":"Single file"},{"location":"docs/vulnerability/scanning/filesystem/#clientserver-mode","text":"<p>You must launch Trivy server in advance. </p> <pre><code>$ trivy server\n</code></pre> <p>Then, Trivy works as a client if you specify the <code>--server</code> option.</p> <pre><code>$ trivy fs --server http://localhost:4954 --severity CRITICAL ./integration/testdata/fixtures/fs/pom/\n</code></pre> Result <pre><code>pom.xml (pom)\n=============\nTotal: 4 (CRITICAL: 4)\n\n+---------------------------------------------+------------------+----------+-------------------+--------------------------------+---------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------------------------------------------+------------------+----------+-------------------+--------------------------------+---------------------------------------+\n| com.fasterxml.jackson.core:jackson-databind | CVE-2017-17485 | CRITICAL | 2.9.1 | 2.8.11, 2.9.4 | jackson-databind: Unsafe |\n| | | | | | deserialization due to |\n| | | | | | incomplete black list (incomplete |\n| | | | | | fix for CVE-2017-15095)... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2017-17485 |\n+ +------------------+ + +--------------------------------+---------------------------------------+\n| | CVE-2020-9546 | | | 2.7.9.7, 2.8.11.6, 2.9.10.4 | jackson-databind: Serialization |\n| | | | | | gadgets in shaded-hikari-config |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-9546 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2020-9547 | | | | jackson-databind: Serialization |\n| | | | | | gadgets in ibatis-sqlmap |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-9547 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2020-9548 | | | | jackson-databind: Serialization |\n| | | | | | gadgets in anteros-core |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-9548 |\n+---------------------------------------------+------------------+----------+-------------------+--------------------------------+---------------------------------------+\n</code></pre>","title":"Client/Server mode"},{"location":"docs/vulnerability/scanning/git-repository/","text":"<p>Scan your remote git repository</p> <pre><code>$ trivy repo https://github.com/knqyf263/trivy-ci-test\n</code></pre> Result <pre><code>2021-03-09T15:04:19.003+0200 INFO Detecting cargo vulnerabilities...\n2021-03-09T15:04:19.005+0200 INFO Detecting pipenv vulnerabilities...\n\nCargo.lock\n==========\nTotal: 7 (UNKNOWN: 7, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)\n\n+----------+-------------------+----------+-------------------+------------------------------+---------------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+----------+-------------------+----------+-------------------+------------------------------+---------------------------------------------+\n| ammonia | RUSTSEC-2019-0001 | UNKNOWN | 1.9.0 | >= 2.1.0 | Uncontrolled recursion leads |\n| | | | | | to abort in HTML serialization |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2019-0001 |\n+----------+-------------------+ +-------------------+------------------------------+---------------------------------------------+\n| openssl | RUSTSEC-2016-0001 | | 0.8.3 | >= 0.9.0 | SSL/TLS MitM vulnerability |\n| | | | | | due to insecure defaults |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2016-0001 |\n+----------+-------------------+ +-------------------+------------------------------+---------------------------------------------+\n| smallvec | RUSTSEC-2018-0018 | | 0.6.9 | >= 0.6.13 | smallvec creates uninitialized |\n| | | | | | value of any type |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2018-0018 |\n+ +-------------------+ + +------------------------------+---------------------------------------------+\n| | RUSTSEC-2019-0009 | | | >= 0.6.10 | Double-free and use-after-free |\n| | | | | | in SmallVec::grow() |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2019-0009 |\n+ +-------------------+ + + +---------------------------------------------+\n| | RUSTSEC-2019-0012 | | | | Memory corruption in SmallVec::grow() |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2019-0012 |\n+ +-------------------+ + +------------------------------+---------------------------------------------+\n| | RUSTSEC-2021-0003 | | | >= 0.6.14, < 1.0.0, >= 1.6.1 | Buffer overflow in SmallVec::insert_many |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2021-0003 |\n+----------+-------------------+ +-------------------+------------------------------+---------------------------------------------+\n| tempdir | RUSTSEC-2018-0017 | | 0.3.7 | | `tempdir` crate has been |\n| | | | | | deprecated; use `tempfile` instead |\n| | | | | | -->rustsec.org/advisories/RUSTSEC-2018-0017 |\n+----------+-------------------+----------+-------------------+------------------------------+---------------------------------------------+\n\nPipfile.lock\n============\nTotal: 20 (UNKNOWN: 3, LOW: 0, MEDIUM: 7, HIGH: 5, CRITICAL: 5)\n\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| django | CVE-2019-19844 | CRITICAL | 2.0.9 | 3.0.1, 2.2.9, 1.11.27 | Django: crafted email address |\n| | | | | | allows account takeover |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-19844 |\n+ +------------------+ + +------------------------+---------------------------------------+\n| | CVE-2020-7471 | | | 3.0.3, 2.2.10, 1.11.28 | django: potential SQL injection |\n| | | | | | via StringAgg(delimiter) |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-7471 |\n+ +------------------+----------+ +------------------------+---------------------------------------+\n| | CVE-2019-6975 | HIGH | | 2.1.6, 2.0.11, 1.11.19 | python-django: memory exhaustion in |\n| | | | | | django.utils.numberformat.format() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-6975 |\n+ +------------------+ + +------------------------+---------------------------------------+\n| | CVE-2020-9402 | | | 3.0.4, 2.2.11, 1.11.29 | django: potential SQL injection |\n| | | | | | via \"tolerance\" parameter in |\n| | | | | | GIS functions and aggregates... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-9402 |\n+ +------------------+----------+ +------------------------+---------------------------------------+\n| | CVE-2019-3498 | MEDIUM | | 2.1.5, 2.0.10, 1.11.18 | python-django: Content spoofing |\n| | | | | | via URL path in default 404 page |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-3498 |\n+ +------------------+ + +------------------------+---------------------------------------+\n| | CVE-2020-13254 | | | 3.0.7, 2.2.13 | django: potential data leakage |\n| | | | | | via malformed memcached keys |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-13254 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2020-13596 | | | | django: possible XSS via |\n| | | | | | admin ForeignKeyRawIdWidget |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-13596 |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| django-cors-headers | pyup.io-37132 | UNKNOWN | 2.5.2 | 3.0.0 | In django-cors-headers |\n| | | | | | version 3.0.0, |\n| | | | | | ``CORS_ORIGIN_WHITELIST`` |\n| | | | | | requires URI schemes, and |\n| | | | | | optionally ports. This... |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| djangorestframework | CVE-2020-25626 | MEDIUM | 3.9.2 | 3.11.2 | django-rest-framework: XSS |\n| | | | | | Vulnerability in API viewer |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-25626 |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| httplib2 | CVE-2021-21240 | HIGH | 0.12.1 | 0.19.0 | python-httplib2: Regular |\n| | | | | | expression denial of |\n| | | | | | service via malicious header |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-21240 |\n+ +------------------+----------+ +------------------------+---------------------------------------+\n| | CVE-2020-11078 | MEDIUM | | 0.18.0 | python-httplib2: CRLF injection |\n| | | | | | via an attacker controlled |\n| | | | | | unescaped part of uri for... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-11078 |\n+ +------------------+----------+ + +---------------------------------------+\n| | pyup.io-38303 | UNKNOWN | | | Httplib2 0.18.0 is an |\n| | | | | | important security update to |\n| | | | | | patch a CWE-93 CRLF... |\n+---------------------+------------------+ +-------------------+------------------------+---------------------------------------+\n| jinja2 | pyup.io-39525 | | 2.10.1 | 2.11.3 | This affects the package |\n| | | | | | jinja2 from 0.0.0 and before |\n| | | | | | 2.11.3. The ReDOS... |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| py | CVE-2020-29651 | HIGH | 1.8.0 | | python-py: ReDoS in the py.path.svnwc |\n| | | | | | component via mailicious input |\n| | | | | | to blame functionality... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-29651 |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| pyyaml | CVE-2019-20477 | CRITICAL | 5.1 | | PyYAML: command execution |\n| | | | | | through python/object/apply |\n| | | | | | constructor in FullLoader |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-20477 |\n+ +------------------+ + +------------------------+---------------------------------------+\n| | CVE-2020-14343 | | | 5.4 | PyYAML: incomplete |\n| | | | | | fix for CVE-2020-1747 |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-14343 |\n+ +------------------+ + +------------------------+---------------------------------------+\n| | CVE-2020-1747 | | | 5.3.1 | PyYAML: arbitrary command |\n| | | | | | execution through python/object/new |\n| | | | | | when FullLoader is used |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-1747 |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n| urllib3 | CVE-2019-11324 | HIGH | 1.24.1 | 1.24.2 | python-urllib3: Certification |\n| | | | | | mishandle when error should be thrown |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-11324 |\n+ +------------------+----------+ +------------------------+---------------------------------------+\n| | CVE-2019-11236 | MEDIUM | | | python-urllib3: CRLF injection |\n| | | | | | due to not encoding the |\n| | | | | | '\\r\\n' sequence leading to... |\n| | | | | | -->avd.aquasec.com/nvd/cve-2019-11236 |\n+ +------------------+ + +------------------------+---------------------------------------+\n| | CVE-2020-26137 | | | 1.25.9 | python-urllib3: CRLF injection |\n| | | | | | via HTTP request method |\n| | | | | | -->avd.aquasec.com/nvd/cve-2020-26137 |\n+---------------------+------------------+----------+-------------------+------------------------+---------------------------------------+\n</code></pre>","title":"Git Repository"},{"location":"docs/vulnerability/scanning/git-repository/#scanning-private-repositories","text":"<p>In order to scan private GitHub or GitLab repositories, the environment variable <code>GITHUB_TOKEN</code> or <code>GITLAB_TOKEN</code> must be set, respectively, with a valid token that has access to the private repository being scanned.</p> <p>The <code>GITHUB_TOKEN</code> environment variable will take precedence over <code>GITLAB_TOKEN</code>, so if a private GitLab repository will be scanned, then <code>GITHUB_TOKEN</code> must be unset.</p> <p>For example:</p> <pre><code>$ export GITHUB_TOKEN=\"your_private_github_token\"\n$ trivy repo <your private GitHub repo URL>\n$\n$ # or\n$ export GITLAB_TOKEN=\"your_private_gitlab_token\"\n$ trivy repo <your private GitLab repo URL>\n</code></pre>","title":"Scanning Private Repositories"},{"location":"docs/vulnerability/scanning/image/","text":"","title":"Image"},{"location":"docs/vulnerability/scanning/image/#container-images","text":"<p>Simply specify an image name (and a tag).</p> <pre><code>$ trivy image [YOUR_IMAGE_NAME]\n</code></pre> <p>For example:</p> <pre><code>$ trivy image python:3.4-alpine\n</code></pre> Result <pre><code>2019-05-16T01:20:43.180+0900 INFO Updating vulnerability database...\n2019-05-16T01:20:53.029+0900 INFO Detecting Alpine vulnerabilities...\n\npython:3.4-alpine3.9 (alpine 3.9.2)\n===================================\nTotal: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)\n\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |\n| | | | | | with long nonces |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n</code></pre>","title":"Container Images"},{"location":"docs/vulnerability/scanning/image/#tar-files","text":"<pre><code>$ docker pull ruby:3.1-alpine3.15\n$ docker save ruby:3.1-alpine3.15 -o ruby-3.1.tar\n$ trivy image --input ruby-3.1.tar\n</code></pre> Result <pre><code>2022-02-03T10:08:19.127Z INFO Detected OS: alpine\n2022-02-03T10:08:19.127Z WARN This OS version is not on the EOL list: alpine 3.15\n2022-02-03T10:08:19.127Z INFO Detecting Alpine vulnerabilities...\n2022-02-03T10:08:19.127Z INFO Number of language-specific files: 2\n2022-02-03T10:08:19.127Z INFO Detecting gemspec vulnerabilities...\n2022-02-03T10:08:19.128Z INFO Detecting node-pkg vulnerabilities...\n2022-02-03T10:08:19.128Z WARN This OS version is no longer supported by the distribution: alpine 3.15.0\n2022-02-03T10:08:19.128Z WARN The vulnerability detection may be insufficient because security updates are not provided\n\nruby-3.1.tar (alpine 3.15.0)\n============================\nTotal: 3 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 3, CRITICAL: 0)\n\n+----------+------------------+----------+-------------------+---------------+---------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+----------+------------------+----------+-------------------+---------------+---------------------------------------+\n| gmp | CVE-2021-43618 | HIGH | 6.2.1-r0 | 6.2.1-r1 | gmp: Integer overflow and resultant |\n| | | | | | buffer overflow via crafted input |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-43618 |\n+----------+ + + + + +\n| gmp-dev | | | | | |\n| | | | | | |\n| | | | | | |\n+----------+ + + + + +\n| libgmpxx | | | | | |\n| | | | | | |\n| | | | | | |\n+----------+------------------+----------+-------------------+---------------+---------------------------------------+\n\nNode.js (node-pkg)\n==================\nTotal: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)\n\n\nRuby (gemspec)\n==============\nTotal: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)\n</code></pre>","title":"Tar Files"},{"location":"docs/vulnerability/scanning/rootfs/","text":"<p>Scan a root filesystem (such as a host machine, a virtual machine image, or an unpacked container image filesystem).</p> <pre><code>$ trivy rootfs /path/to/rootfs\n</code></pre>","title":"Rootfs"},{"location":"docs/vulnerability/scanning/rootfs/#from-inside-containers","text":"<p>Scan your container from inside the container.</p> <pre><code>$ docker run --rm -it alpine:3.11\n/ # curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin\n/ # trivy rootfs /\n</code></pre> Result <pre><code>2021-03-08T05:22:26.378Z INFO Need to update DB\n2021-03-08T05:22:26.380Z INFO Downloading DB...\n20.37 MiB / 20.37 MiB [-------------------------------------------------------------------------------------------------------------------------------------] 100.00% 8.24 MiB p/s 2s\n2021-03-08T05:22:30.134Z INFO Detecting Alpine vulnerabilities...\n2021-03-08T05:22:30.138Z INFO Trivy skips scanning programming language libraries because no supported file was detected\n\n313430f09696 (alpine 3.11.7)\n============================\nTotal: 6 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 6, CRITICAL: 0)\n\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n| libcrypto1.1 | CVE-2021-23839 | HIGH | 1.1.1i-r0 | 1.1.1j-r0 | openssl: incorrect SSLv2 |\n| | | | | | rollback protection |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23839 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23840 | | | | openssl: integer |\n| | | | | | overflow in CipherUpdate |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23840 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23841 | | | | openssl: NULL pointer dereference |\n| | | | | | in X509_issuer_and_serial_hash() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23841 |\n+--------------+------------------+ + + +---------------------------------------+\n| libssl1.1 | CVE-2021-23839 | | | | openssl: incorrect SSLv2 |\n| | | | | | rollback protection |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23839 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23840 | | | | openssl: integer |\n| | | | | | overflow in CipherUpdate |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23840 |\n+ +------------------+ + + +---------------------------------------+\n| | CVE-2021-23841 | | | | openssl: NULL pointer dereference |\n| | | | | | in X509_issuer_and_serial_hash() |\n| | | | | | -->avd.aquasec.com/nvd/cve-2021-23841 |\n+--------------+------------------+----------+-------------------+---------------+---------------------------------------+\n</code></pre>","title":"From Inside Containers"},{"location":"docs/vulnerability/scanning/rootfs/#other-examples","text":"<ul> <li>Embed in Dockerfile</li> <li>Unpacked container image filesystem</li> </ul>","title":"Other Examples"},{"location":"getting-started/further/","text":"","title":"Further Reading"},{"location":"getting-started/further/#presentations","text":"<ul> <li>Aqua Security YouTube Channel<ul> <li>Trivy - container image scanning</li> <li>Using Trivy in client server mode</li> <li>Tweaking Trivy output to fit your workflow</li> <li>How does a vulnerability scanner identify packages?</li> </ul> </li> <li>CNCF Webinar 2020<ul> <li>Trivy Open Source Scanner for Container Images \u2013 Just Download and Run!</li> </ul> </li> <li>KubeCon + CloudNativeCon Europe 2020 Virtual<ul> <li>Handling Container Vulnerabilities with Open Policy Agent - Teppei Fukuda, Aqua Security</li> </ul> </li> </ul>","title":"Presentations"},{"location":"getting-started/further/#blogs","text":"<ul> <li>Trivy Vulnerability Scanner Joins the Aqua Open-source Family</li> <li>Trivy Image Vulnerability Scanner Now Under Apache 2.0 License</li> <li>DevSecOps with Trivy and GitHub Actions</li> <li>Find Image Vulnerabilities Using GitHub and Aqua Security Trivy Action</li> <li>Using Trivy to Discover Vulnerabilities in VS Code Projects</li> </ul>","title":"Blogs"},{"location":"getting-started/installation/","text":"","title":"Installation"},{"location":"getting-started/installation/#rhelcentos","text":"Repository <p>Add repository setting to <code>/etc/yum.repos.d</code>.</p> <pre><code>$ sudo vim /etc/yum.repos.d/trivy.repo\n[trivy]\nname=Trivy repository\nbaseurl=https://aquasecurity.github.io/trivy-repo/rpm/releases/$releasever/$basearch/\ngpgcheck=0\nenabled=1\n$ sudo yum -y update\n$ sudo yum -y install trivy\n</code></pre> RPM <pre><code>rpm -ivh https://github.com/aquasecurity/trivy/releases/download/v0.26.0/trivy_0.26.0_Linux-64bit.rpm\n</code></pre>","title":"RHEL/CentOS"},{"location":"getting-started/installation/#debianubuntu","text":"Repository <p>Add repository setting to <code>/etc/apt/sources.list.d</code>.</p> <pre><code>sudo apt-get install wget apt-transport-https gnupg lsb-release\nwget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -\necho deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list\nsudo apt-get update\nsudo apt-get install trivy\n</code></pre> DEB <pre><code>wget https://github.com/aquasecurity/trivy/releases/download/v0.26.0/trivy_0.26.0_Linux-64bit.deb\nsudo dpkg -i trivy_0.26.0_Linux-64bit.deb\n</code></pre>","title":"Debian/Ubuntu"},{"location":"getting-started/installation/#arch-linux","text":"<p>Package trivy-bin can be installed from the Arch User Repository.</p> pikaur <pre><code>pikaur -Sy trivy-bin\n</code></pre> yay <pre><code>yay -Sy trivy-bin\n</code></pre>","title":"Arch Linux"},{"location":"getting-started/installation/#homebrew","text":"<p>You can use homebrew on macOS and Linux.</p> <pre><code>brew install aquasecurity/trivy/trivy\n</code></pre>","title":"Homebrew"},{"location":"getting-started/installation/#nixnixos","text":"<p>You can use nix on Linux or macOS and on others unofficially.</p> <p>Note that trivy is currently only in the unstable channels.</p> <pre><code>nix-env --install trivy\n</code></pre> <p>Or through your configuration on NixOS or with home-manager as usual</p>","title":"Nix/NixOS"},{"location":"getting-started/installation/#install-script","text":"<p>This script downloads Trivy binary based on your OS and architecture.</p> <pre><code>curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.26.0\n</code></pre>","title":"Install Script"},{"location":"getting-started/installation/#binary","text":"<p>Download the archive file for your operating system/architecture from here. Unpack the archive, and put the binary somewhere in your <code>$PATH</code> (on UNIX-y systems, /usr/local/bin or the like). Make sure it has execution bits turned on.</p>","title":"Binary"},{"location":"getting-started/installation/#from-source","text":"<pre><code>mkdir -p $GOPATH/src/github.com/aquasecurity\ncd $GOPATH/src/github.com/aquasecurity\ngit clone --depth 1 --branch v0.26.0 https://github.com/aquasecurity/trivy\ncd trivy/cmd/trivy/\nexport GO111MODULE=on\ngo install\n</code></pre>","title":"From source"},{"location":"getting-started/installation/#docker","text":"","title":"Docker"},{"location":"getting-started/installation/#docker-hub","text":"<p>Replace [YOUR_CACHE_DIR] with the cache directory on your machine.</p> <pre><code>docker pull aquasec/trivy:0.26.0\n</code></pre> <p>Example:</p> Linux <pre><code>docker run --rm -v [YOUR_CACHE_DIR]:/root/.cache/ aquasec/trivy:0.26.0 image [YOUR_IMAGE_NAME]\n</code></pre> macOS <pre><code>docker run --rm -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy:0.26.0 image [YOUR_IMAGE_NAME\n</code></pre> <p>If you would like to scan the image on your host machine, you need to mount <code>docker.sock</code>.</p> <pre><code>docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \\\n -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy:0.26.0 python:3.4-alpine\n</code></pre> <p>Please re-pull latest <code>aquasec/trivy</code> if an error occurred.</p> Result <pre><code>2019-05-16T01:20:43.180+0900 INFO Updating vulnerability database...\n2019-05-16T01:20:53.029+0900 INFO Detecting Alpine vulnerabilities...\n\npython:3.4-alpine3.9 (alpine 3.9.2)\n===================================\nTotal: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)\n\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |\n| | | | | | with long nonces |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n</code></pre>","title":"Docker Hub"},{"location":"getting-started/installation/#github-container-registry","text":"<p>The same image is hosted on GitHub Container Registry as well.</p> <pre><code>docker pull ghcr.io/aquasecurity/trivy:0.26.0\n</code></pre>","title":"GitHub Container Registry"},{"location":"getting-started/installation/#amazon-ecr-public","text":"<p>The same image is hosted on Amazon ECR Public as well.</p> <pre><code>docker pull public.ecr.aws/aquasecurity/trivy:0.26.0\n</code></pre>","title":"Amazon ECR Public"},{"location":"getting-started/installation/#helm","text":"","title":"Helm"},{"location":"getting-started/installation/#installing-from-the-the-aqua-chart-repository","text":"<pre><code>helm repo add aquasecurity https://aquasecurity.github.io/helm-charts/\nhelm repo update\nhelm search repo trivy\nhelm install my-trivy aquasecurity/trivy\n</code></pre>","title":"Installing from the the Aqua Chart Repository"},{"location":"getting-started/installation/#installing-the-chart","text":"<p>To install the chart with the release name <code>my-release</code>:</p> <pre><code>helm install my-release .\n</code></pre> <p>The command deploys Trivy on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.</p> <p>Tip: List all releases using <code>helm list</code>.</p>","title":"Installing the Chart"},{"location":"getting-started/overview/","text":"<p>Trivy detects two types of security issues:</p> <ul> <li>Vulnerabilities<ul> <li>OS packages (Alpine, Red Hat Universal Base Image, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, CBL-Mariner, Oracle Linux, Debian, Ubuntu, Amazon Linux, openSUSE Leap, SUSE Enterprise Linux, Photon OS and Distroless)</li> <li>Language-specific packages (Bundler, Composer, Pipenv, Poetry, npm, yarn, Cargo, NuGet, Maven, and Go)</li> </ul> </li> <li>Misconfigurations<ul> <li>Kubernetes</li> <li>Docker</li> <li>Terraform</li> <li>CloudFormation</li> <li>more coming soon</li> </ul> </li> </ul> <p>Trivy can scan three different artifacts:</p> <ul> <li>Container Images</li> <li>Filesystem</li> <li>Git Repositories</li> </ul> <p>It is designed to be used in CI. Before pushing to a container registry or deploying your application, you can scan your local container image and other artifacts easily. See Integrations for details.</p>","title":"Overview"},{"location":"getting-started/quickstart/","text":"","title":"Quick Start"},{"location":"getting-started/quickstart/#scan-image-for-vulnerabilities","text":"<p>Simply specify an image name (and a tag).</p> <pre><code>$ trivy image [YOUR_IMAGE_NAME]\n</code></pre> <p>For example:</p> <pre><code>$ trivy image python:3.4-alpine\n</code></pre> Result <pre><code>2019-05-16T01:20:43.180+0900 INFO Updating vulnerability database...\n2019-05-16T01:20:53.029+0900 INFO Detecting Alpine vulnerabilities...\n\npython:3.4-alpine3.9 (alpine 3.9.2)\n===================================\nTotal: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)\n\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n| openssl | CVE-2019-1543 | MEDIUM | 1.1.1a-r1 | 1.1.1b-r1 | openssl: ChaCha20-Poly1305 |\n| | | | | | with long nonces |\n+---------+------------------+----------+-------------------+---------------+--------------------------------+\n</code></pre> <p>For more details, see here.</p>","title":"Scan image for vulnerabilities"},{"location":"getting-started/quickstart/#scan-directory-for-misconfigurations","text":"<p>Simply specify a directory containing IaC files such as Terraform and Dockerfile.</p> <pre><code>$ trivy config [YOUR_IAC_DIR]\n</code></pre> <p>For example:</p> <pre><code>$ ls build/\nDockerfile\n$ trivy config ./build\n</code></pre> Result <pre><code>2021-07-09T10:06:29.188+0300 INFO Need to update the built-in policies\n2021-07-09T10:06:29.188+0300 INFO Downloading the built-in policies...\n2021-07-09T10:06:30.520+0300 INFO Detected config files: 1\n\nDockerfile (dockerfile)\n=======================\nTests: 23 (SUCCESSES: 22, FAILURES: 1, EXCEPTIONS: 0)\nFailures: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)\n\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n| Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Last USER command in |\n| | | | | Dockerfile should not be 'root' |\n| | | | | -->avd.aquasec.com/appshield/ds002 |\n+---------------------------+------------+----------------------+----------+------------------------------------------+\n</code></pre> <p>For more details, see here.</p>","title":"Scan directory for misconfigurations"}]} |