Commit a0875cc4 authored by Dylan Cutler's avatar Dylan Cutler Committed by Commit Bot

Instrument navigator.[appVersion|platform|userAgent] using web IDL bindings...

Instrument navigator.[appVersion|platform|userAgent] using web IDL bindings for identifiability study.

HighEntropy=Direct was introduced for numeric, simple fingerprinting
surfaces in:

https://chromium-review.googlesource.com/c/chromium/src/+/2245048

This CL adds support for DOMString attributes by adding an overload to
Dactyloscoper::RecordDirectSurface.

Bug: 973801
Change-Id: I34af7fb4b928f2bd1ae894704d0dc72c31c5884f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276401
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785936}
parent 3557d7dd
......@@ -474,6 +474,7 @@ interface TestObject {
// [HighEntropy=Direct]
[HighEntropy=Direct,MeasureAs=TestAttributeHighEntropyUnsignedLong] readonly attribute unsigned long highEntropyDirectUnsignedLong;
[HighEntropy=Direct,MeasureAs=TestAttributeHighEntropyDOMString] readonly attribute DOMString highEntropyDirectDomString;
// with [CEReactions] for not overloaded method
[CEReactions] void ceReactionsNotOverloadedMethod(boolean arg);
......
......@@ -4283,6 +4283,20 @@ static void HighEntropyDirectUnsignedLongAttributeGetter(const v8::FunctionCallb
V8SetReturnValueUnsigned(info, cpp_value);
}
static void HighEntropyDirectDomStringAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestObject* impl = V8TestObject::ToImpl(holder);
ExecutionContext* execution_context = ExecutionContext::ForRelevantRealm(info);
String cpp_value(impl->highEntropyDirectDomString());
Dactyloscoper::RecordDirectSurface(execution_context, WebFeature::kTestAttributeHighEntropyDOMString, cpp_value);
V8SetReturnValueString(info, cpp_value, info.GetIsolate());
}
static void TestInterfaceAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
......@@ -11276,6 +11290,16 @@ void V8TestObject::HighEntropyDirectUnsignedLongAttributeGetterCallback(const v8
test_object_v8_internal::HighEntropyDirectUnsignedLongAttributeGetter(info);
}
void V8TestObject::HighEntropyDirectDomStringAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_highEntropyDirectDomString_Getter");
ExecutionContext* execution_context_for_measurement = CurrentExecutionContext(info.GetIsolate());
UseCounter::Count(execution_context_for_measurement, WebFeature::kTestAttributeHighEntropyDOMString);
Dactyloscoper::Record(execution_context_for_measurement, WebFeature::kTestAttributeHighEntropyDOMString);
test_object_v8_internal::HighEntropyDirectDomStringAttributeGetter(info);
}
void V8TestObject::TestInterfaceAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_testInterfaceAttribute_Getter");
......@@ -13360,6 +13384,7 @@ static void InstallV8TestObjectTemplate(
{ "highEntropyAttributeWithMeasureAs", V8TestObject::HighEntropyAttributeWithMeasureAsAttributeGetterCallback, V8TestObject::HighEntropyAttributeWithMeasureAsAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "highEntropyReadonlyAttributeWithMeasureAs", V8TestObject::HighEntropyReadonlyAttributeWithMeasureAsAttributeGetterCallback, nullptr, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "highEntropyDirectUnsignedLong", V8TestObject::HighEntropyDirectUnsignedLongAttributeGetterCallback, nullptr, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "highEntropyDirectDomString", V8TestObject::HighEntropyDirectDomStringAttributeGetterCallback, nullptr, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "testInterfaceAttribute", V8TestObject::TestInterfaceAttributeAttributeGetterCallback, V8TestObject::TestInterfaceAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
{ "size", V8TestObject::SizeAttributeGetterCallback, nullptr, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::DontEnum | v8::ReadOnly), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
};
......
......@@ -362,6 +362,7 @@ class V8TestObject {
CORE_EXPORT static void HighEntropyAttributeWithMeasureAsAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void HighEntropyReadonlyAttributeWithMeasureAsAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void HighEntropyDirectUnsignedLongAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void HighEntropyDirectDomStringAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void TestInterfaceAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void TestInterfaceAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void SizeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
......
......@@ -46,4 +46,19 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
}
}
void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
WebFeature feature,
String str) {
auto* window = DynamicTo<LocalDOMWindow>(context);
if (!window)
return;
if (str.IsEmpty())
return;
Document* document = window->document();
IdentifiabilityMetricBuilder(document->UkmSourceID())
.SetWebfeature(feature,
str.Is8Bit() ? str.Span8() : as_bytes(str.Span16()))
.Record(document->UkmRecorder());
}
} // namespace blink
......@@ -9,6 +9,7 @@
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......@@ -25,6 +26,7 @@ class CORE_EXPORT Dactyloscoper {
static void Record(ExecutionContext*, WebFeature);
static void RecordDirectSurface(ExecutionContext*, WebFeature, unsigned);
static void RecordDirectSurface(ExecutionContext*, WebFeature, String);
private:
DISALLOW_COPY_AND_ASSIGN(Dactyloscoper);
......
......@@ -33,10 +33,10 @@
interface mixin NavigatorID {
readonly attribute DOMString appCodeName; // constant "Mozilla"
readonly attribute DOMString appName; // constant "Netscape"
[HighEntropy, MeasureAs=NavigatorAppVersion] readonly attribute DOMString appVersion;
[HighEntropy, MeasureAs=NavigatorPlatform] readonly attribute DOMString platform;
[HighEntropy=Direct, MeasureAs=NavigatorAppVersion] readonly attribute DOMString appVersion;
[HighEntropy=Direct, MeasureAs=NavigatorPlatform] readonly attribute DOMString platform;
readonly attribute DOMString product; // constant "Gecko"
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=22555
// boolean taintEnabled(); // constant false
[Affects=Nothing, HighEntropy, MeasureAs=NavigatorUserAgent] readonly attribute DOMString userAgent;
[Affects=Nothing, HighEntropy=Direct, MeasureAs=NavigatorUserAgent] readonly attribute DOMString userAgent;
};
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