Skip to content

Commit 8447f63

Browse files
committed
securitypolicyenforcer: Remove the standard JSON enforcer
This commit removes the long deprecated standard JSON enforcer - all confidential containers now has to either use Rego (the default), or the open_door enforcer if provided with an empty policy or a policy that is `{"allow_all": true}` (both case checked against host data). Note that the host can still choose either rego or open_door, and this is not measured into host data, but the policy check in createOpenDoorEnforcer ensures that if the policy is a rego policy, trying to use an open_door enforcer will error, leaving the enforcer at the default (which for confidential is a deny-everything ClosedDoorSecurityPolicyEnforcer). Closes: https://portal.microsofticm.com/imp/v5/incidents/details/31000000387867/summary Signed-off-by: Tingmao Wang <[email protected]>
1 parent 38c6693 commit 8447f63

File tree

5 files changed

+48
-1627
lines changed

5 files changed

+48
-1627
lines changed

pkg/securitypolicy/rego_utils_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,40 +2218,6 @@ func (*generatedConstraints) Generate(r *rand.Rand, _ int) reflect.Value {
22182218
return reflect.ValueOf(c)
22192219
}
22202220

2221-
type testConfig struct {
2222-
container *securityPolicyContainer
2223-
layers []string
2224-
containerID string
2225-
policy *StandardSecurityPolicyEnforcer
2226-
}
2227-
2228-
func setupContainerWithOverlay(gc *generatedConstraints, valid bool) (tc *testConfig, err error) {
2229-
sp := NewStandardSecurityPolicyEnforcer(gc.containers, ignoredEncodedPolicyString)
2230-
2231-
containerID := testDataGenerator.uniqueContainerID()
2232-
c := selectContainerFromContainerList(gc.containers, testRand)
2233-
2234-
var layerPaths []string
2235-
if valid {
2236-
layerPaths, err = testDataGenerator.createValidOverlayForContainer(sp, c)
2237-
if err != nil {
2238-
return nil, fmt.Errorf("error creating valid overlay: %w", err)
2239-
}
2240-
} else {
2241-
layerPaths, err = testDataGenerator.createInvalidOverlayForContainer(sp, c)
2242-
if err != nil {
2243-
return nil, fmt.Errorf("error creating invalid overlay: %w", err)
2244-
}
2245-
}
2246-
2247-
return &testConfig{
2248-
container: c,
2249-
layers: layerPaths,
2250-
containerID: containerID,
2251-
policy: sp,
2252-
}, nil
2253-
}
2254-
22552221
func generateConstraints(r *rand.Rand, maxContainers int32) *generatedConstraints {
22562222
var containers []*securityPolicyContainer
22572223

pkg/securitypolicy/securitypolicy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var apiCodeTemplate string
2626
var APICode = strings.Replace(apiCodeTemplate, "@@API_VERSION@@", apiVersion, 1)
2727
var FrameworkCode = strings.Replace(frameworkCodeTemplate, "@@FRAMEWORK_VERSION@@", frameworkVersion, 1)
2828

29-
var ErrInvalidOpenDoorPolicy = errors.New("allow_all cannot be set to 'true' when Containers are non-empty")
29+
var ErrInvalidOpenDoorPolicy = errors.New("Invalid policy for open-door enforcer")
3030

3131
type EnvVarRule string
3232

0 commit comments

Comments
 (0)