Skip to content

[Security Hardened Shoot Cluster] Rule 1003 implementation #454

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

Merged
merged 5 commits into from
Mar 25, 2025

Conversation

AleksandarSavchev
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #431

Special notes for your reviewer:

Release note:

Implementation for rule `1003` from the `security-hardened-shoot-cluster` ruleset for provider `garden`.

@AleksandarSavchev AleksandarSavchev requested a review from a team as a code owner March 20, 2025 14:08
@gardener-robot gardener-robot added needs/review Needs review size/l Size of pull request is large (see gardener-robot robot/bots/size.py) needs/second-opinion Needs second review by someone else labels Mar 20, 2025
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 20, 2025
Copy link
Member

@dimityrmirchev dimityrmirchev left a comment

Choose a reason for hiding this comment

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

Thanks. I have some suggestions

@@ -44,7 +44,13 @@ spec:
version: <supported-version>
```

The supported versions can be found in the used `CloudProfile`.
Copy link
Member

Choose a reason for hiding this comment

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

Why is this line 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.

Must have written on top of it 😅 my bad

@@ -44,7 +44,13 @@ spec:
version: <supported-version>
```

The supported versions can be found in the used `CloudProfile`.
### 1003 - Shoot clusters should have Lakom extension configured correctly. <a id="1003"></a>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
### 1003 - Shoot clusters should have Lakom extension configured correctly. <a id="1003"></a>
### 1003 - Shoot clusters should have the Lakom extension configured. <a id="1003"></a>

Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to use must instead of should when severity is ranked HIGH?

### 1003 - Shoot clusters should have Lakom extension configured correctly. <a id="1003"></a>

#### Description
Shoot clusters should have Lakom extension configured correctly. Trusted public keys should be configured for the Lakom extension.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Shoot clusters should have Lakom extension configured correctly. Trusted public keys should be configured for the Lakom extension.
Lakom is an admission controller which implements image signature verification. Shoot clusters should have the Lakom extension configured with trusted public keys so that only trusted images are allowed in the cluster.

Shoot clusters should have Lakom extension configured correctly. Trusted public keys should be configured for the Lakom extension.

#### Fix
Follow the Lakom extension documentation on how to configure [TrustedKeysResourceName](https://github.com/gardener/gardener-extension-shoot-lakom-service/blob/v0.18.1/docs/usage/shoot-extension.md#trustedkeysresourcename)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Follow the Lakom extension documentation on how to configure [TrustedKeysResourceName](https://github.com/gardener/gardener-extension-shoot-lakom-service/blob/v0.18.1/docs/usage/shoot-extension.md#trustedkeysresourcename)
Follow the Lakom extension documentation on how to configure [TrustedKeysResourceName](https://github.com/gardener/gardener-extension-shoot-lakom-service/blob/v0.18.1/docs/usage/shoot-extension.md#trustedkeysresourcename).

}

func (r *Rule1003) Severity() rule.SeverityLevel {
return rule.SeverityMedium
Copy link
Member

Choose a reason for hiding this comment

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

You set this to MEDIUM, but the documentation says HIGH?

}

if lakomConfig.TrustedKeysResourceName == nil || len(*lakomConfig.TrustedKeysResourceName) == 0 {
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not have TrustedKeysResourceName configured.", lakomExtensionType), rule.NewTarget())), nil
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not have TrustedKeysResourceName configured.", lakomExtensionType), rule.NewTarget())), nil
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not configure trusted keys.", lakomExtensionType), rule.NewTarget())), nil


if lakomConfig.TrustedKeysResourceName == nil || len(*lakomConfig.TrustedKeysResourceName) == 0 {
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not have TrustedKeysResourceName configured.", lakomExtensionType), rule.NewTarget())), nil
} else {
Copy link
Member

Choose a reason for hiding this comment

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

No need for the else. It causes not needed nesting

return rule.Result(r, rule.PassedCheckResult(fmt.Sprintf("Extension %s is correctly configured for the shoot cluster.", lakomExtensionType), rule.NewTarget())), nil
}
case extensionLabelValue == "true" && !extensionDisabled:
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not have extension config configured for the shoot cluster.", lakomExtensionType), rule.NewTarget())), nil
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not have extension config configured for the shoot cluster.", lakomExtensionType), rule.NewTarget())), nil
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s is not configured for the shoot cluster.", lakomExtensionType), rule.NewTarget())), nil

case extensionLabelValue == "true" && !extensionDisabled:
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s does not have extension config configured for the shoot cluster.", lakomExtensionType), rule.NewTarget())), nil
case extensionLabelValue == "true" && extensionDisabled:
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s is disabled in the shoot spec and enabled in labels.", lakomExtensionType), rule.NewTarget())), nil
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a warning? What can cause this behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does make sense for this to not be marked as failed as we should never enter this case.

case extensionLabelValue == "true" && extensionDisabled:
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s is disabled in the shoot spec and enabled in labels.", lakomExtensionType), rule.NewTarget())), nil
default:
return rule.Result(r, rule.FailedCheckResult(fmt.Sprintf("Extension %s has unexpected label value: %s.", lakomExtensionType, extensionLabelValue), rule.NewTarget())), nil
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a warning?

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 have changed this one to warning now and added the changes to rule 1000 as well.

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Mar 21, 2025
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 24, 2025
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 24, 2025
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 25, 2025
Copy link
Member

@dimityrmirchev dimityrmirchev left a comment

Choose a reason for hiding this comment

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

/lgtm

@gardener-robot gardener-robot added reviewed/lgtm Has approval for merging and removed needs/changes Needs (more) changes needs/review Needs review needs/second-opinion Needs second review by someone else labels Mar 25, 2025
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 25, 2025
@AleksandarSavchev AleksandarSavchev merged commit 5a5b919 into gardener:main Mar 25, 2025
9 checks passed
@gardener-robot gardener-robot added the status/closed Issue is closed (either delivered or triaged) label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) size/l Size of pull request is large (see gardener-robot robot/bots/size.py) status/closed Issue is closed (either delivered or triaged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Hardened Shoot Cluster] Add rule 1003 to check Lakom extension configuration
6 participants