Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(misconf): Use updated terminology for misconfiguration checks #6476

Merged
merged 30 commits into from May 2, 2024

Conversation

simar7
Copy link
Member

@simar7 simar7 commented Apr 10, 2024

Description

This PR updates the references in the code (and the UX) to use the updated terminology of a "check".

Related issues

Related PRs

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@simar7 simar7 self-assigned this Apr 10, 2024
Signed-off-by: Simar <simar@linux.com>
@simar7
Copy link
Member Author

simar7 commented Apr 11, 2024

We probably have to update these flags as well: https://github.com/aquasecurity/trivy/blob/main/pkg/flag/rego_flags.go#L10-L44

@nikpivkin
Copy link
Contributor

@simar7 I opened PR in testodcker.

@knqyf263 Can you take a look?

@simar7 simar7 marked this pull request as ready for review April 19, 2024 00:47
@simar7
Copy link
Member Author

simar7 commented Apr 19, 2024

Note: tests are failing as this will fix them.

Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @simar7
left some comments.

Also take a look linter error, please.

go.mod Outdated Show resolved Hide resolved
docs/docs/scanner/misconfiguration/policy/exceptions.md Outdated Show resolved Hide resolved
docs/docs/scanner/misconfiguration/policy/builtin.md Outdated Show resolved Hide resolved
pkg/commands/app.go Outdated Show resolved Hide resolved
pkg/flag/misconf_flags.go Show resolved Hide resolved
Copy link
Contributor

@DmitriyLewen DmitriyLewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some small comments

docs/docs/scanner/misconfiguration/policy/builtin.md Outdated Show resolved Hide resolved
docs/docs/scanner/misconfiguration/policy/builtin.md Outdated Show resolved Hide resolved
docs/docs/scanner/misconfiguration/policy/exceptions.md Outdated Show resolved Hide resolved
docs/docs/scanner/misconfiguration/policy/exceptions.md Outdated Show resolved Hide resolved
go.mod Outdated
@@ -1,8 +1,6 @@
module github.com/aquasecurity/trivy

go 1.22

toolchain go1.22.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... what version of Go are you using on your local PC?
Why was this removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to be honest. Maybe it's redundant to specify toolchain when the go version is the same? https://go.dev/ref/mod#go-mod-file-toolchain

I run the following:

$ go version
go version go1.22.0 darwin/arm64

If you get rid of the patch version from the go directive within go.mod, I get this error:

$ go mod tidy
go: downloading go1.22 (darwin/arm64)
go: download go1.22 for darwin/arm64: toolchain not available

Running go mod tidy on the version in main automatically removes the toolchain directive and replaces it with this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm... this is strange...
my Go doesn't remove toolchain 😄 :

➜  trivy git:(main) git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
➜  trivy git:(main) go mod tidy
➜  trivy git:(main) go version
go version go1.22.2 darwin/arm64

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm taking a look again to see what's going on. I will upgrade to Go 1.22.2 as you and try again.

Copy link
Member Author

@simar7 simar7 Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DmitriyLewen I don't have a good answer but after updating to go 1.22.2, go removed the toolchain directive for me but added a patch version to the go version https://github.com/aquasecurity/trivy/pull/6476/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R3

I personally think since our go version and toolchain are same, this behavior is normal and expected as specifying the same version for the toolchain and go version are redundant. But I'm not sure why I'm not able to replicate the behavior you see on your end.

Could you try the following?

  1. Restore the go version from the main branch into my branch
  2. Try running go mod tidy

Copy link
Collaborator

@knqyf263 knqyf263 Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go also applies MVS to the Go version. Since trivy-checks uses go 1.22.0 now, Go chooses 1.22.0 rather than 1.22.
https://github.com/aquasecurity/trivy-checks/blob/55f3883e2b99a9a48a31c9db17270ab0af5b38f0/go.mod#L3

I'd suggest removing the patch version in trivy-checks. Otherwise, we need to bump the patch version every time (1.22.0 => 1.22.1 => 1.22.2...).

diff --git a/go.mod b/go.mod
index 2cf4c04..6352ca5 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/aquasecurity/trivy-checks

-go 1.22.0
+go 1.22

 require (
        github.com/aquasecurity/trivy v0.50.2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @knqyf263 for that info. I had a hunch it could be that but didn't get to it. Good to know about MVS!

I've updated trivy-checks repo and also used it within Trivy here

pkg/cloud/aws/commands/run_test.go Outdated Show resolved Hide resolved
pkg/iac/rego/load_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just reviewed go.mod and pkg/flag

@simar7
Copy link
Member Author

simar7 commented May 1, 2024

I'd like @nikpivkin to review once again when he's back.

Copy link
Contributor

@nikpivkin nikpivkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simar7 simar7 added this pull request to the merge queue May 2, 2024
Merged via the queue into main with commit 37da98d May 2, 2024
21 checks passed
@simar7 simar7 deleted the check-bundle branch May 2, 2024 18:39
fl0pp5 added a commit to altlinux/trivy that referenced this pull request May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore(misconf): Simplify nomenclature for misconfig checks
4 participants