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

Add CIS Benchmarks support to Rancher Distributions RKE/RKE2/K3s #1513

Closed

Conversation

KiranBodipi
Copy link
Contributor

Based on the information furnished in https://ranchermanager.docs.rancher.com/v2.7/pages-for-subheaders/rancher-hardening-guides#hardening-guides-and-benchmark-versions , kube-bench executes CIS-1.23 (Kubernetes v1.23) , CIS-1.24(Kubernetes v1.24),CIS-1.7 (Kubernetes v1.25,v1.26,v1.27) CIS Benchmarks of respective distributions.

@KiranBodipi KiranBodipi force-pushed the kb-cis-support-rancher branch 2 times, most recently from d2fe885 to 90ea48d Compare October 26, 2023 07:32
@mjshastha
Copy link
Contributor

@KiranBodipi The build is failing due to a YAML linting error. Can you fix the error and rebuild?

@KiranBodipi KiranBodipi force-pushed the kb-cis-support-rancher branch 7 times, most recently from cb4e526 to 7eb142f Compare November 2, 2023 12:50
cmd/util.go Outdated
case "1.25", "1.26", "1.27":
return "k3s-cis-1.7"
}
case "rancher":
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be rancher1

Copy link
Contributor Author

@KiranBodipi KiranBodipi Nov 3, 2023

Choose a reason for hiding this comment

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

In our logic, we are always adding rancher1 to RKE gitVersion eg: v1.26.8-rancher1.
Once it goes through getPlatformInfoFromVersion logic, it always yields "rancher"
You can check the example here - https://go.dev/play/p/x2IdtlQfov4

cmd/util_test.go Outdated
{
name: "rancher1",
args: args{
platform: Platform{Name: "rancher", Version: "1.27"},
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

cmd/util.go Outdated
@@ -290,13 +295,23 @@ Alternatively, you can specify the version with --version
`

func getKubeVersion() (*KubeVersion, error) {
kubeConfig, err := rest.InClusterConfig()
Copy link
Contributor

@mjshastha mjshastha Nov 4, 2023

Choose a reason for hiding this comment

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

rest.InClusterConfig() returns error, but it doesn't handle the errors adequately. Consider adding appropriate error handling to provide better feedback to users when issues occur.

cmd/util.go Outdated
@@ -290,13 +295,23 @@ Alternatively, you can specify the version with --version
`

func getKubeVersion() (*KubeVersion, error) {
kubeConfig, err := rest.InClusterConfig()
k8sClient, err := kubernetes.NewForConfig(kubeConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

and also here

Copy link
Contributor

@mjshastha mjshastha left a comment

Choose a reason for hiding this comment

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

I'm content with the changes.

Copy link
Contributor

@deven0t deven0t left a comment

Choose a reason for hiding this comment

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

LGTM!! 🚀

@deven0t
Copy link
Contributor

deven0t commented Nov 10, 2023

@chen-keinan @mozillazg can you review the changes.

Benchmark files are taken from here https://github.com/rancher/security-scan/tree/master/package/cfg
Thanks

@mozillazg
Copy link
Collaborator

I will complete the review before next Monday.

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.

4 participants