Skip to content

Trunk

What is Trunk ?

Trunk is a tool that runs a suite of security and best practice checks against your code. It is designed to be used in CI/CD pipelines, but can also be used as a standalone tool.

Support for the following languages is currently available:

Installing Trunk

curl https://get.trunk.io -fsSL | bash
code --install-extension Trunk.io  

Trunk checks

Trunk checks cli

Trunk detects checks to enable in function of the files in the current directory, but you can also enable and disable checks manually.

  • trunck check list: list all available checks
  • trunck check enable checkname: enable a check
  • trunck check disable checkname: disable a check
  • trunck check: run all enabled checks

For example, to enable the Terraform check:

trunk check enable terraform 
1 linter was enabled:
  terraform 1.1.0

Info

You can also enable checks by modifing .trunk.yml file in your repository. See the configuration page for more information.

Examples:

trunk commnad line check example
trunk check   

Checking 68% [====================================================================================================================================================================>                                                                              ]  38/56  9.4s 
 ↳ checkov                                                                                                                                                                                                                                                                      
   ↳ modules/webapps/linux_function_app/private_endpoint.tf [lint] ⠧                                                                                                                                                                                                            
   ↳ modules/webapps/linux_function_app/variables.tf [lint] ⠧                                                                                                                                                                                                                   
 ↳ terrascan                                                                                                                                                                                                                                                                    
   ↳ modules/webapps/linux_function_app/locals.tf [lint] ⠧                                                                                                                                                                                                                      
   ↳ modules/webapps/linux_function_app/main.tf [lint] ⠧                                                                              

Trunk checks vscode

In the case of the VSCode extension, you can review your checks in your IDE:

Trunk checks vscode

And you can disable checks from quick fix menu:

Quick Fix

Trunk updates

Trunk updates cli

Trunk is updated regularly with new checks and improvements. You can update Trunk by running the following command:

trunk update

Trunk updates vscode

In the case of the VSCode extension, it will be updated automatically:

Trunk updates

References