51Degrees / device-detection-go

European Union Public License 1.2
0 stars 3 forks source link

Can't detecting windows 11 by using MatchEvidence #4

Closed Xbozon closed 2 years ago

Xbozon commented 2 years ago

Hello, I am using the modified example https://github.com/51Degrees/device-detection-examples-go/blob/main/uach/uach.go to try to detect windows 11. Unfortunately, when setting the headers: Sec-CH-UA-Platform: Windows Sec-CH-UA-Platform-Version: 13.0.0

image

If I install version 10, everything is fine:

image

The swap is made via:

image

uach_mod.go.txt

Can you help me figure it out?

krpn commented 2 years ago

@jwrosewell, can you help with this issue please? 51Degrees sent email with required update to v4, but Client Hints are not still working...

jwrosewell commented 2 years ago

I've checked with the following Go snippet and everything is working as expected for Windows 11 values.

When the code as provided runs with a current V4 data file the following is returned.

2022/02/15 18:34:47     PlatformName: Windows
2022/02/15 18:34:47     PlatformVersion: 11.0

When the UACH evidence is removed then the following is returned.

2022/02/15 18:34:53     PlatformName: Windows
2022/02/15 18:34:53     PlatformVersion: 10.0

Notice that we're using 14.0.0 as the evidence which is the actual value returned from Windows 11 when the profile was setup. Also the presence of the double quotes surrounding the values.

The UACH specification and data it produces changes a lot and in 51Degrees' UACHit is not ready to be relied upon in place of the existing User-Agent. We have raised this issue with W3C TAG and Chromuim developers. (Please add your support via the emoji method or even your own comment). Whilst we would prefer a solution that bought order to the existing single value, and proposed such a solution, we have to work with what Google have decided.

Other than Windows 11 we have not added UACH data to the production data files yet. Assuming Google maintain their current time frame we intend to deploy UACH values to our graphs in production data files shortly before the live release of Chromium browsers that implement the change.

// Create results which supports 3 evidence key value pairs.
results := dd.NewResultsHash(manager, 3, 0)
defer results.Free()

// Create the evidence instance to support 3 evidence key value pairs.
evidence := dd.NewEvidenceHash(3)
defer evidence.Free()

// Add the evidence for the User-Agent and the two UACH values needed to
// resolve platform name.
evidence.Add(dd.HttpHeaderString,
"User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, "+
    "like Gecko) Chrome/98.0.4758.80 Safari/537.36")

// Comment out these lines to see the difference in the result.
evidence.Add(dd.HttpHeaderString, "Sec-CH-UA-Platform", "\"Windows\"")
evidence.Add(dd.HttpHeaderString, "Sec-CH-UA-Platform-Version", "\"14.0.0\"")

// Use the match with evidence method to get the result from the UACH
// evidence values.
err = results.MatchEvidence(evidence)
if err != nil {
log.Fatalln(err)
}

// Output the results to confirm the correct value.
value, _ := results.ValuesString("PlatformName", ", ")
log.Printf("\tPlatformName: %s\n", value)
value, _ = results.ValuesString("PlatformVersion", ", ")
log.Printf("\tPlatformVersion: %s\n", value)
Steve51D commented 2 years ago

Closing this following explanation from James. If this is still a problem then please feel free to re-open.

Xbozon commented 2 years ago

It works, thank you. I tested with version 13.0.0, no problems with 14.0.0.