Skip to content

Commit 91aa454

Browse files
authored
feat: Show sandbox info in PMG setup info command (#170)
1 parent a81a491 commit 91aa454

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

cmd/setup/info.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package setup
22

33
import (
44
"fmt"
5+
"sort"
56
"strconv"
7+
"strings"
68

79
"github.com/safedep/pmg/config"
810
"github.com/safedep/pmg/internal/alias"
@@ -90,5 +92,37 @@ func executeSetupInfo() error {
9092

9193
ui.PrintInfoSection("Security", securityEntries)
9294

95+
// Sandbox section
96+
sandboxCfg := cfg.Config.Sandbox
97+
sandboxEntries := make(map[string]string)
98+
sandboxEntries["Enabled"] = strconv.FormatBool(sandboxCfg.Enabled)
99+
sandboxEntries["Enforce Always"] = strconv.FormatBool(sandboxCfg.EnforceAlways)
100+
101+
if len(sandboxCfg.Policies) > 0 {
102+
pmNames := make([]string, 0, len(sandboxCfg.Policies))
103+
for name := range sandboxCfg.Policies {
104+
pmNames = append(pmNames, name)
105+
}
106+
107+
sort.Strings(pmNames)
108+
109+
policyParts := make([]string, 0, len(pmNames))
110+
for _, name := range pmNames {
111+
ref := sandboxCfg.Policies[name]
112+
status := "disabled"
113+
if ref.Enabled {
114+
status = ref.Profile
115+
}
116+
117+
policyParts = append(policyParts, fmt.Sprintf("%s(%s)", name, status))
118+
}
119+
120+
sandboxEntries["Policies"] = strings.Join(policyParts, ", ")
121+
} else {
122+
sandboxEntries["Policies"] = "None"
123+
}
124+
125+
ui.PrintInfoSection("Sandbox", sandboxEntries)
126+
93127
return nil
94128
}

0 commit comments

Comments
 (0)