Skip to content

Commit 620230d

Browse files
committed
fix(core): synchronize core sanitization schema with compiler
Synchronizes the core's copy of the DOM security schema with the compiler-side schema definitions, and removes the write_source_file target.
1 parent 3bfa4ee commit 620230d

2 files changed

Lines changed: 2 additions & 18 deletions

File tree

‎packages/core/BUILD.bazel‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
2-
load("@bazel_lib//lib:write_source_files.bzl", "write_source_file")
32
load("//adev/shared-docs/pipeline/api-gen:generate_api_docs.bzl", "generate_api_docs")
43
load("//packages/common/locales:index.bzl", "generate_base_locale_file")
54
load("//tools:defaults.bzl", "api_golden_test", "api_golden_test_npm_package", "ng_package", "tsec_test")
@@ -174,9 +173,4 @@ genrule(
174173
cmd = "cp $< $@",
175174
)
176175

177-
write_source_file(
178-
name = "dom_security_schema",
179-
check_that_out_file_exists = False,
180-
in_file = "//packages/compiler:src/schema/dom_security_schema.ts",
181-
out_file = ":src/sanitization/dom_security_schema.ts",
182-
)
176+

‎packages/core/src/sanitization/dom_security_schema.ts‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,10 @@ export function SECURITY_SCHEMA(): {[k: string]: SecurityContext} {
115115
['object', ['codebase', 'data']],
116116
]);
117117

118-
// The below are for Script SVG
119-
// See: https://developer.mozilla.org/en-US/docs/Web/API/SVGScriptElement/href
120-
registerContext(SecurityContext.RESOURCE_URL, SVG_NAMESPACE, [
121-
['script', ['src', 'href', 'xlink:href']],
122-
]);
123-
124118
registerContext(SecurityContext.URL, SVG_NAMESPACE, [['a', ['href', 'xlink:href']]]);
125119

126120
// Keep this in sync with SECURITY_SENSITIVE_ELEMENTS in packages/core/src/sanitization/sanitization.ts
127-
// The `unknown` elements refer to cases when we need to validate the input/binding in a directive (host bindings)
128-
// and the directive can be applied to multiple different elements (with different tag names). In this case we generate
129-
// a special instruction that an attribute might potentially be security-sensitive and defer the actual security check
130-
// to runtime, when we apply that directive to a concrete elements, thus we can check the combination of tag+attribute
131-
// against the set that requires sanitization.
121+
// Unknown is the internal tag name for unknown elements example used for host-bindings.
132122
// These are unsafe as `attributeName` can be `href` or `xlink:href`
133123
// See: http://b/463880509#comment7
134124
registerContext(SecurityContext.ATTRIBUTE_NO_BINDING, SVG_NAMESPACE, [

0 commit comments

Comments
 (0)