Skip to content

Commit

Permalink
Merge pull request #16231 from adelton/issue-15933
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 16867, 16231).

Distinguish SCCs that AllowHostNetwork and AllowHostPorts from those that do not, in the score calculation.

Fixes #15933.
  • Loading branch information
openshift-merge-robot authored Oct 16, 2017
2 parents bb412d8 + 971e472 commit 989078f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func TestBootstrappedConstraints(t *testing.T) {
// ordering of expectedConstraintNames is important, we check it against scc.ByPriority
expectedConstraintNames := []string{
SecurityContextConstraintsAnyUID,
SecurityContextConstraintsHostNetwork,
SecurityContextConstraintRestricted,
SecurityContextConstraintNonRoot,
SecurityContextConstraintHostNS,
SecurityContextConstraintHostMountAndAnyUID,
SecurityContextConstraintsHostNetwork,
SecurityContextConstraintHostNS,
SecurityContextConstraintPrivileged,
}
expectedGroups, expectedUsers := getExpectedAccess()
Expand Down
12 changes: 11 additions & 1 deletion pkg/security/securitycontextconstraints/byrestrictions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func (s ByRestrictions) Less(i, j int) bool {
type points int

const (
privilegedPoints points = 200000
privilegedPoints points = 1000000

hostNetworkPoints points = 200000
hostPortsPoints points = 400000

hostVolumePoints points = 100000
nonTrivialVolumePoints points = 50000
Expand Down Expand Up @@ -62,6 +65,13 @@ func pointValue(constraint *securityapi.SecurityContextConstraints) points {
// add points based on volume requests
totalPoints += volumePointValue(constraint)

if constraint.AllowHostNetwork {
totalPoints += hostNetworkPoints
}
if constraint.AllowHostPorts {
totalPoints += hostPortsPoints
}

// add points based on capabilities
totalPoints += capabilitiesPointValue(constraint)

Expand Down

0 comments on commit 989078f

Please sign in to comment.