Commit 0d3092ff authored by Jason A. Donenfeld's avatar Jason A. Donenfeld

internal/syscall/windows/registry: remove TestWalkFullRegistry due to false assumptions

This test's existence was predicated upon assumptions about the full
range of known data types and known data into those types. However,
we've learned from Microsoft that there are several undocumented secret
registry types that are in use by various parts of Windows, and we've
learned from inspection that many Microsoft uses of registry types don't
strictly adhere to the recommended value size. It's therefore foolhardy
to make any assumptions about what goes in and out of the registry, and
so this test, as well as its "blacklist", are meaningless.

Fixes #35084

Change-Id: I6c3fe5fb0e740e88858321b3b042c0ff1a23284e
Reviewed-on: https://go-review.googlesource.com/c/go/+/203604
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
parent 0f559941
......@@ -522,104 +522,6 @@ func TestValues(t *testing.T) {
deleteValues(t, k)
}
// These are known to be broken due to Windows bugs. See https://golang.org/issue/35084
var blackListedKeys = map[string]bool{
`HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\`: true,
`HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\`: true,
`HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Group Policy\`: true,
`HKLM\SYSTEM\ControlSet001\`: true,
`HKLM\SYSTEM\ControlSet002\`: true,
`HKLM\SYSTEM\CurrentControlSet\`: true,
`HKLM\SYSTEM\DriverDatabase\`: true,
`HKU\`: true, // Rather unfortunate, but SIDs are hard to predict.
}
func walkKey(t *testing.T, k registry.Key, kname string) {
if blackListedKeys[kname+`\`] {
return
}
names, err := k.ReadValueNames(-1)
if err != nil {
t.Fatalf("reading value names of %#q failed: %v", kname+`\`, err)
}
for _, name := range names {
if blackListedKeys[kname+`\`+name] {
continue
}
_, valtype, err := k.GetValue(name, nil)
if err != nil {
t.Fatalf("reading value type of %#q in %#q failed: %v", name, kname+`\`, err)
}
switch valtype {
case registry.NONE:
case registry.SZ:
_, _, err := k.GetStringValue(name)
if err != nil {
t.Errorf("getting %#q string value in %#q failed: %v", name, kname+`\`, err)
}
case registry.EXPAND_SZ:
s, _, err := k.GetStringValue(name)
if err != nil {
t.Errorf("getting %#q expand string value in %#q failed: %v", name, kname+`\`, err)
}
_, err = registry.ExpandString(s)
if err != nil {
t.Errorf("expanding %#q value in %#q failed: %v", name, kname+`\`, err)
}
case registry.DWORD, registry.QWORD:
_, _, err := k.GetIntegerValue(name)
if err != nil {
t.Errorf("getting %#q integer value in %#q failed: %v", name, kname+`\`, err)
}
case registry.BINARY:
_, _, err := k.GetBinaryValue(name)
if err != nil {
t.Errorf("getting %#q binary value in %#q failed: %v", name, kname+`\`, err)
}
case registry.MULTI_SZ:
_, _, err := k.GetStringsValue(name)
if err != nil {
t.Errorf("getting %#q strings value in %#q failed: %v", name, kname+`\`, err)
}
case registry.FULL_RESOURCE_DESCRIPTOR, registry.RESOURCE_LIST, registry.RESOURCE_REQUIREMENTS_LIST:
// TODO: not implemented
default:
t.Fatalf("%#q in %#q has unknown value type %d", name, kname+`\`, valtype)
}
}
names, err = k.ReadSubKeyNames(-1)
if err != nil {
t.Fatalf("reading sub-keys of %#q failed: %v", kname+`\`, err)
}
for _, name := range names {
func() {
subk, err := registry.OpenKey(k, name, registry.ENUMERATE_SUB_KEYS|registry.QUERY_VALUE)
if err != nil {
if err == syscall.ERROR_ACCESS_DENIED {
// ignore error, if we are not allowed to access this key
return
}
t.Fatalf("opening sub-keys %#q in %#q failed: %v", name, kname+`\`, err)
}
defer subk.Close()
walkKey(t, subk, kname+`\`+name)
}()
}
}
func TestWalkFullRegistry(t *testing.T) {
if testing.Short() {
t.Skip("skipping long running test in short mode")
}
walkKey(t, registry.CLASSES_ROOT, "HKCR")
walkKey(t, registry.CURRENT_USER, "HKCU")
walkKey(t, registry.LOCAL_MACHINE, "HKLM")
walkKey(t, registry.USERS, "HKU")
walkKey(t, registry.CURRENT_CONFIG, "HKCC")
}
func TestExpandString(t *testing.T) {
got, err := registry.ExpandString("%PATH%")
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment