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

Default to deny all security policy. #1320

Merged
merged 1 commit into from
Mar 16, 2022
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
4 changes: 2 additions & 2 deletions internal/guest/runtime/hcsv2/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"syscall"
"time"

shellwords "github.com/mattn/go-shellwords"
"github.com/mattn/go-shellwords"
"github.com/pkg/errors"

"github.com/Microsoft/hcsshim/internal/guest/gcserr"
Expand Down Expand Up @@ -66,7 +66,7 @@ func NewHost(rtime runtime.Runtime, vsock transport.Transport) *Host {
rtime: rtime,
vsock: vsock,
securityPolicyEnforcerSet: false,
securityPolicyEnforcer: &securitypolicy.OpenDoorSecurityPolicyEnforcer{},
securityPolicyEnforcer: &securitypolicy.ClosedDoorSecurityPolicyEnforcer{},
}
}

Expand Down
1 change: 0 additions & 1 deletion internal/tools/securitypolicy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,3 @@ isn't in the TOML configuration.
If the version of the pause container changes from 3.1, you will need to update
the hardcoded root hash by running the `dmverity-vhd` to compute the root hash
for the new container and update this tool accordingly.

7 changes: 6 additions & 1 deletion internal/uvm/security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ func (uvm *UtilityVM) SetSecurityPolicy(ctx context.Context, policy string) erro
}

if policy == "" {
return nil
openDoorPolicy := securitypolicy.NewOpenDoorPolicy()
policyString, err := openDoorPolicy.EncodeToString()
if err != nil {
return err
}
policy = policyString
}

uvm.m.Lock()
Expand Down
5 changes: 3 additions & 2 deletions pkg/securitypolicy/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,13 @@ type SecurityPolicy struct {
Containers Containers `json:"containers"`
}

// EncodeToString returns base64 encoded string representation of SecurityPolicy.
func (sp *SecurityPolicy) EncodeToString() (string, error) {
j, err := json.Marshal(sp)
jsn, err := json.Marshal(sp)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(j), nil
return base64.StdEncoding.EncodeToString(jsn), nil
}

type Containers struct {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.