Commit 66e308c2 authored by Yifan Luo's avatar Yifan Luo Committed by Commit Bot

[SanitizerAPI] The initial commit.

This CL intends to create a prototyping Sanitizer API
(https://github.com/WICG/sanitizer-api) at very beginning
level.

Change-Id: I7327a3440d544b61becd81f4c9b058ee4823ffc4
Bug: 1116418
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346252
Commit-Queue: Yifan Luo <lyf@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarDaniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: default avatarYifan Luo <lyf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800191}
parent 9a8defa9
...@@ -1813,6 +1813,8 @@ generated_interface_sources_in_modules = [ ...@@ -1813,6 +1813,8 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_stats_response.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_stats_response.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_track_event.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_track_event.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_track_event.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_rtc_track_event.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_sanitizer.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_sanitizer.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_scheduler.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_scheduler.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_scheduler.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_scheduler.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_screen.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_screen.cc",
......
...@@ -581,6 +581,7 @@ static_idl_files_in_modules = get_path_info( ...@@ -581,6 +581,7 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/quota/worker_navigator_storage_quota.idl", "//third_party/blink/renderer/modules/quota/worker_navigator_storage_quota.idl",
"//third_party/blink/renderer/modules/remoteplayback/html_media_element_remote_playback.idl", "//third_party/blink/renderer/modules/remoteplayback/html_media_element_remote_playback.idl",
"//third_party/blink/renderer/modules/remoteplayback/remote_playback.idl", "//third_party/blink/renderer/modules/remoteplayback/remote_playback.idl",
"//third_party/blink/renderer/modules/sanitizer_api/sanitizer.idl",
"//third_party/blink/renderer/modules/scheduler/scheduler.idl", "//third_party/blink/renderer/modules/scheduler/scheduler.idl",
"//third_party/blink/renderer/modules/scheduler/scheduler_post_task_options.idl", "//third_party/blink/renderer/modules/scheduler/scheduler_post_task_options.idl",
"//third_party/blink/renderer/modules/scheduler/task_controller.idl", "//third_party/blink/renderer/modules/scheduler/task_controller.idl",
......
...@@ -137,6 +137,7 @@ component("modules") { ...@@ -137,6 +137,7 @@ component("modules") {
"//third_party/blink/renderer/modules/push_messaging", "//third_party/blink/renderer/modules/push_messaging",
"//third_party/blink/renderer/modules/quota", "//third_party/blink/renderer/modules/quota",
"//third_party/blink/renderer/modules/remoteplayback", "//third_party/blink/renderer/modules/remoteplayback",
"//third_party/blink/renderer/modules/sanitizer_api",
"//third_party/blink/renderer/modules/scheduler", "//third_party/blink/renderer/modules/scheduler",
"//third_party/blink/renderer/modules/screen_enumeration", "//third_party/blink/renderer/modules/screen_enumeration",
"//third_party/blink/renderer/modules/screen_orientation", "//third_party/blink/renderer/modules/screen_orientation",
......
...@@ -109,6 +109,7 @@ _idl_imports = [ ...@@ -109,6 +109,7 @@ _idl_imports = [
"//third_party/blink/renderer/modules/push_messaging/idls.gni", "//third_party/blink/renderer/modules/push_messaging/idls.gni",
"//third_party/blink/renderer/modules/quota/idls.gni", "//third_party/blink/renderer/modules/quota/idls.gni",
"//third_party/blink/renderer/modules/remoteplayback/idls.gni", "//third_party/blink/renderer/modules/remoteplayback/idls.gni",
"//third_party/blink/renderer/modules/sanitizer_api/idls.gni",
"//third_party/blink/renderer/modules/scheduler/idls.gni", "//third_party/blink/renderer/modules/scheduler/idls.gni",
"//third_party/blink/renderer/modules/screen_enumeration/idls.gni", "//third_party/blink/renderer/modules/screen_enumeration/idls.gni",
"//third_party/blink/renderer/modules/screen_orientation/idls.gni", "//third_party/blink/renderer/modules/screen_orientation/idls.gni",
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/blink/renderer/modules/modules.gni")
blink_modules_sources("sanitizer_api") {
sources = [
"sanitizer.cc",
"sanitizer.h",
]
}
lyf@chromium.org
vogelheim@chromium.org
# COMPONENT: Blink>SecurityFeature>SanitizerAPI
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
modules_idl_files = [ "sanitizer.idl" ]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sanitizer.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
Sanitizer* Sanitizer::Create(ExceptionState& exception_state) {
return MakeGarbageCollected<Sanitizer>();
}
Sanitizer::Sanitizer() = default;
Sanitizer::~Sanitizer() = default;
String Sanitizer::saneStringFrom(const String& input) {
String sanitizedString = input;
return sanitizedString;
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SANITIZER_API_SANITIZER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SANITIZER_API_SANITIZER_H_
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class ExceptionState;
class MODULES_EXPORT Sanitizer final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static Sanitizer* Create(ExceptionState&);
Sanitizer();
~Sanitizer() override;
String saneStringFrom(const String&);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SANITIZER_API_SANITIZER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/WICG/sanitizer-api
[
Exposed=Window,
RuntimeEnabled=SanitizerAPI
] interface Sanitizer {
[RaisesException] constructor();
DOMString saneStringFrom(DOMString input);
};
...@@ -1664,6 +1664,10 @@ ...@@ -1664,6 +1664,10 @@
name: "SameSiteByDefaultCookies", name: "SameSiteByDefaultCookies",
status: "test", status: "test",
}, },
{
name: "SanitizerAPI",
status: "test",
},
{ {
name: "ScreenWakeLock", name: "ScreenWakeLock",
status: "stable", status: "stable",
......
// https://wicg.github.io/sanitizer-api/
[
Exposed=Window
] interface Sanitizer {
[RaisesException] constructor();
DOMString saneStringFrom(DOMString input);
};
spec: https://wicg.github.io/sanitizer-api/
suggested_reviewers:
- ivanlish
- mozfreddyb
- otherdaniel
# TEAM: security-dev@chromium.org
# COMPONENT: Blink>SecurityFeature>SanitizerAPI
# WPT-NOTIFY: true
file://third_party/blink/renderer/modules/sanitizer_api/OWNERS
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
idl_test(
['sanitizer-api.tentative'],
['html'],
idl_array => {
idl_array.add_objects({
Sanitizer: ['new Sanitizer()']
});
}
);
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
</head>
<body>
<script>
test(t => {
s = new Sanitizer();
assert_equals("test", s.saneStringFrom("test"));
}, "SanitizerAPI exists!");
</script>
</body>
</html>
...@@ -7895,6 +7895,10 @@ interface SVGViewElement : SVGElement ...@@ -7895,6 +7895,10 @@ interface SVGViewElement : SVGElement
getter zoomAndPan getter zoomAndPan
method constructor method constructor
setter zoomAndPan setter zoomAndPan
interface Sanitizer
attribute @@toStringTag
method constructor
method saneStringFrom
interface Scheduler interface Scheduler
attribute @@toStringTag attribute @@toStringTag
getter currentTaskSignal getter currentTaskSignal
......
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