mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: Show sandbox info in PMG setup info command (#170)
This commit is contained in:
@@ -2,7 +2,9 @@ package setup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/safedep/pmg/config"
|
"github.com/safedep/pmg/config"
|
||||||
"github.com/safedep/pmg/internal/alias"
|
"github.com/safedep/pmg/internal/alias"
|
||||||
@@ -90,5 +92,37 @@ func executeSetupInfo() error {
|
|||||||
|
|
||||||
ui.PrintInfoSection("Security", securityEntries)
|
ui.PrintInfoSection("Security", securityEntries)
|
||||||
|
|
||||||
|
// Sandbox section
|
||||||
|
sandboxCfg := cfg.Config.Sandbox
|
||||||
|
sandboxEntries := make(map[string]string)
|
||||||
|
sandboxEntries["Enabled"] = strconv.FormatBool(sandboxCfg.Enabled)
|
||||||
|
sandboxEntries["Enforce Always"] = strconv.FormatBool(sandboxCfg.EnforceAlways)
|
||||||
|
|
||||||
|
if len(sandboxCfg.Policies) > 0 {
|
||||||
|
pmNames := make([]string, 0, len(sandboxCfg.Policies))
|
||||||
|
for name := range sandboxCfg.Policies {
|
||||||
|
pmNames = append(pmNames, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(pmNames)
|
||||||
|
|
||||||
|
policyParts := make([]string, 0, len(pmNames))
|
||||||
|
for _, name := range pmNames {
|
||||||
|
ref := sandboxCfg.Policies[name]
|
||||||
|
status := "disabled"
|
||||||
|
if ref.Enabled {
|
||||||
|
status = ref.Profile
|
||||||
|
}
|
||||||
|
|
||||||
|
policyParts = append(policyParts, fmt.Sprintf("%s(%s)", name, status))
|
||||||
|
}
|
||||||
|
|
||||||
|
sandboxEntries["Policies"] = strings.Join(policyParts, ", ")
|
||||||
|
} else {
|
||||||
|
sandboxEntries["Policies"] = "None"
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.PrintInfoSection("Sandbox", sandboxEntries)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user