docs/community/contribute/pr.md
Thank you for taking interest in contributing to Trivy!
Install the necessary tools for development by following their respective installation instructions.
After making changes to the Go source code, build the project with the following command:
$ mage build
$ ./trivy -h
You must pass the linter checks:
$ mage lint:run
Additionally, you need to have run go mod tidy, so execute the following command as well:
$ mage tidy
To autofix linters use the following command:
$ mage lint:fix
Your PR must pass all the unit tests. You can test it as below.
$ mage test:unit
Your PR must pass all the integration tests. You can test it as below.
$ mage test:integration
If you update protobuf files (.proto), you need to regenerate the Go code:
$ mage protoc:generate
You can also format and lint protobuf files:
$ mage protoc:fmt # Format protobuf files
$ mage protoc:lint # Lint protobuf files
$ mage protoc:breaking # Check for breaking changes against main branch
If you update CLI flags, you need to generate the CLI references. The test will fail if they are not up-to-date.
$ mage docs:generate
You can build the documents as below and view it at http://localhost:8000.
$ mage docs:serve
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.
<type>(<scope>): <subject>
The type and scope should always be lowercase as shown below.
Allowed <type> values:
Allowed <scope> values:
checks:
mode:
os:
language:
vuln:
config:
container
cli:
SBOM:
others:
The <scope> 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.
Breaking changes
A PR, introducing a breaking API change, needs to append a ! after the type/scope.
feat(alma): add support for AlmaLinux
feat(vuln)!: delete the existing CLI flag
fix(oracle): handle advisories with ksplice versions
docs(misconf): add comparison with Conftest and TFsec
chore(deps): bump go.uber.org/zap from 1.19.1 to 1.20.0
NOTE: please do not use chore(deps): update fanal 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.
Trivy is composed of several repositories that work together: