Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Please avoid adding duplicate information across this changelog and JIRA/doc inp
- For questions about this change, please contact the Red Hat support team at [email protected].
- ROX-10018: The policy `OpenShift: Kubeadmin Secret Accessed` will no longer trigger if the request was from the default OpenShift `oauth-apiserver-sa` service account, because this is an expected access pattern for the OpenShift apiserver.
- Violation tags and process tags are deprecated, and will be removed in version 3.72.0.

- Users who do not want to include the RBAC factor in risk calculation can set
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you want it to be documented at all?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I think it's fine to.

the "ROX_INCLUDE_RBAC_IN_RISK" environment variable to "false" in the Central deployment spec.

## [69.1]

Expand Down
7 changes: 6 additions & 1 deletion central/risk/scorer/deployment/scorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stackrox/rox/central/risk/multipliers/image"
saStore "github.com/stackrox/rox/central/serviceaccount/datastore"
"github.com/stackrox/rox/generated/storage"
"github.com/stackrox/rox/pkg/env"
"github.com/stackrox/rox/pkg/logging"
)

Expand Down Expand Up @@ -40,9 +41,13 @@ func NewDeploymentScorer(alertGetter getters.AlertGetter, roles roleStore.DataSt
deployment.NewImageMultiplier(image.RiskyComponentCountHeading),
deployment.NewImageMultiplier(image.ComponentCountHeading),
deployment.NewImageMultiplier(image.ImageAgeHeading),
deployment.NewSAPermissionsMultiplier(roles, bindings, serviceAccounts),
},
}
if env.IncludeRBACInRisk.BooleanSetting() {
scoreImpl.ConfiguredMultipliers = append(scoreImpl.ConfiguredMultipliers,
deployment.NewSAPermissionsMultiplier(roles, bindings, serviceAccounts),
)
}

return scoreImpl
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/env/rbac_risk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package env

var (
// IncludeRBACInRisk toggles whether RBAC is included in the risk calculation.
IncludeRBACInRisk = RegisterBooleanSetting("ROX_INCLUDE_RBAC_IN_RISK", true)
)
4 changes: 4 additions & 0 deletions pkg/env/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func RegisterSetting(envVar string, opts ...SettingOption) Setting {
return s
}

func unregisterSetting(envVar string) {
delete(Settings, envVar)
}

func (s *setting) EnvVar() string {
return s.envVar
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/env/setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package env
import (
"fmt"
"os"
"strings"
"testing"
"time"

Expand All @@ -18,6 +19,7 @@ func TestWithoutDefault(t *testing.T) {

name := newRandomName()
s := RegisterSetting(name)
defer unregisterSetting(name)

a.Equal(name, s.EnvVar())
a.Empty(s.Setting())
Expand All @@ -31,6 +33,7 @@ func TestWithDefault(t *testing.T) {

name := newRandomName()
s := RegisterSetting(name, WithDefault("baz"))
defer unregisterSetting(name)

a.Equal("baz", s.Setting())

Expand All @@ -46,6 +49,7 @@ func TestWithDefaultAndAllowEmpty(t *testing.T) {

name := newRandomName()
s := RegisterSetting(name, WithDefault("baz"), AllowEmpty())
defer unregisterSetting(name)

a.Equal("baz", s.Setting())

Expand All @@ -61,6 +65,7 @@ func TestDurationSetting(t *testing.T) {

name := newRandomName()
s := registerDurationSetting(name, time.Minute)
defer unregisterSetting(name)

a.Equal(time.Minute, s.DurationSetting())
a.Equal("1m0s", s.Setting())
Expand All @@ -69,3 +74,13 @@ func TestDurationSetting(t *testing.T) {
a.Equal(time.Hour, s.DurationSetting())
a.Equal("1h0m0s", s.Setting())
}

func TestSettingEnvVarsStartWithRox(t *testing.T) {
for k := range Settings {
// This one slipped by, too late to change it, so ignore in the test.
if k == NotifyEveryRuntimeEvent.EnvVar() {
continue
}
assert.True(t, strings.HasPrefix(k, "ROX_"), "Env var %s doesn't start with ROX_", k)
}
}