mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
chromium policies parse.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package chromium
|
||||
|
||||
// https://chromeenterprise.google/policies/
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"m1k1o/neko_rooms/internal/types"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Parse(policiesJson string) (*types.Policies, error) {
|
||||
policies := types.Policies{}
|
||||
|
||||
policiesTmpl := map[string]interface{}{}
|
||||
if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//
|
||||
// Homepage
|
||||
//
|
||||
|
||||
if homepage, ok := policiesTmpl["HomepageLocation"]; ok {
|
||||
policies.Homepage = homepage.(string)
|
||||
}
|
||||
|
||||
//
|
||||
// Extensions
|
||||
//
|
||||
|
||||
if extensions, ok := policiesTmpl["ExtensionInstallForcelist"]; ok {
|
||||
policies.Extensions = []types.Extension{}
|
||||
for _, val := range extensions.([]interface{}) {
|
||||
s := strings.Split(val.(string), ";")
|
||||
policies.Extensions = append(
|
||||
policies.Extensions,
|
||||
types.Extension{
|
||||
ID: s[0],
|
||||
URL: s[1],
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Developer Tools
|
||||
//
|
||||
|
||||
if val, ok := policiesTmpl["DeveloperToolsAvailability"]; ok {
|
||||
policies.DeveloperTools = val.(float64) == 1
|
||||
}
|
||||
|
||||
//
|
||||
// Persistent Data
|
||||
//
|
||||
|
||||
if val, ok := policiesTmpl["DefaultCookiesSetting"]; ok {
|
||||
policies.PersistentData = val.(float64) == 1
|
||||
}
|
||||
|
||||
return &policies, nil
|
||||
}
|
||||
Reference in New Issue
Block a user