Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import rest of butler exeprops code, clean up a bit, add test file wi…
…th icon and manifest
- Loading branch information
1 parent
6dbab94
commit dbd9d23
Showing
19 changed files
with
716 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package pelican | ||
|
||
// see | ||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx | ||
func isLanguageWhitelisted(key string) bool { | ||
localeID := key[:4] | ||
primaryLangID := localeID[2:] | ||
|
||
switch primaryLangID { | ||
// neutral | ||
case "00": | ||
return true | ||
// english | ||
case "09": | ||
return true | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package pelican | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/go-errors/errors" | ||
) | ||
|
||
type node = map[string]interface{} | ||
|
||
func visit(n node, key string, f func(c node)) { | ||
if c, ok := n[key].(node); ok { | ||
f(c) | ||
} | ||
} | ||
|
||
func visitMany(n node, key string, f func(c node)) { | ||
if cs, ok := n[key].([]node); ok { | ||
for _, c := range cs { | ||
f(c) | ||
} | ||
} | ||
if c, ok := n[key].(node); ok { | ||
f(c) | ||
} | ||
} | ||
|
||
func getString(n node, key string, f func(s string)) { | ||
if s, ok := n[key].(string); ok { | ||
f(s) | ||
} | ||
} | ||
|
||
func interpretManifest(info *PeInfo, manifest []byte) error { | ||
intermediate := make(node) | ||
err := json.Unmarshal([]byte(manifest), &intermediate) | ||
if err != nil { | ||
return errors.Wrap(err, 0) | ||
} | ||
|
||
assInfo := &AssemblyInfo{} | ||
|
||
interpretIdentity := func(id node, f func(id *AssemblyIdentity)) { | ||
ai := &AssemblyIdentity{} | ||
getString(id, "-name", func(s string) { ai.Name = s }) | ||
getString(id, "-version", func(s string) { ai.Version = s }) | ||
getString(id, "-type", func(s string) { ai.Type = s }) | ||
|
||
getString(id, "-processorArchitecture", func(s string) { ai.ProcessorArchitecture = s }) | ||
getString(id, "-publicKeyToken", func(s string) { ai.PublicKeyToken = s }) | ||
getString(id, "-language", func(s string) { ai.Language = s }) | ||
f(ai) | ||
} | ||
|
||
visit(intermediate, "assembly", func(assembly node) { | ||
visit(assembly, "assemblyIdentity", func(id node) { | ||
interpretIdentity(id, func(ai *AssemblyIdentity) { | ||
assInfo.Identity = ai | ||
}) | ||
}) | ||
|
||
getString(assembly, "description", func(s string) { assInfo.Description = s }) | ||
|
||
visit(assembly, "trustInfo", func(ti node) { | ||
visit(ti, "security", func(sec node) { | ||
visit(sec, "requestedPrivileges", func(rp node) { | ||
visit(rp, "requestedExecutionLevel", func(rel node) { | ||
getString(rel, "-level", func(s string) { | ||
assInfo.RequestedExecutionLevel = s | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
visit(assembly, "dependency", func(dep node) { | ||
visitMany(dep, "dependentAssembly", func(da node) { | ||
visit(da, "assemblyIdentity", func(id node) { | ||
interpretIdentity(id, func(ai *AssemblyIdentity) { | ||
info.DependentAssemblies = append(info.DependentAssemblies, ai) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
info.AssemblyInfo = assInfo | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.