build: Enable tsec checks for critical packages. (#43108)

tsec is a static analyzer that discovers Trusted Types violations.
Deploy tsec to make sure there will be no TT regression in several
critical packages, including core, platform-browser, platform-server
and their dependencies. Existing violations have been reviewed and
exempted in packages/tsec-exemption.json. Future changes to the
exemption list requires security review.

PR Close #43108
This commit is contained in:
Pei Wang
2021-08-10 23:00:20 +00:00
committed by Andrew Kushnir
parent 79eee5509f
commit 509031c734
18 changed files with 292 additions and 3 deletions
@@ -0,0 +1,20 @@
/** For building //packages/animations/browser. */
{
"extends": "../../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../../core"],
"@angular/animations": ["../"]
}
},
"include": [
"*.ts",
"src/**/*.ts"
],
"references": [
{"path": "../../core/tsconfig-tsec.json"},
{"path": "../tsconfig-tsec.json"}
]
}
+18
View File
@@ -0,0 +1,18 @@
/** For building //packages/animations. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../core"]
}
},
"include": [
"*.ts",
"src/**/*.ts"
],
"references": [
{"path": "../core/tsconfig-tsec.json"}
]
}
+20
View File
@@ -0,0 +1,20 @@
/** For building //packages/common/http. */
{
"extends": "../../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../../core"],
"@angular/common": [".."]
}
},
"include": [
"*.ts",
"src/**/*.ts"
],
"references": [
{"path": "../../core/tsconfig-tsec.json"},
{"path": "../tsconfig-tsec.json"}
]
}
+18
View File
@@ -0,0 +1,18 @@
/** For building //packages/common. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../core"]
}
},
"include": [
"*.ts",
"src/**/*.ts"
],
"references": [
{"path": "../core/tsconfig-tsec.json"}
]
}
+11
View File
@@ -0,0 +1,11 @@
/** For building //packages/compiler. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"outDir": ".tsec"
},
"include": [
"*.ts",
"src/**/*.ts"
]
}
+15
View File
@@ -0,0 +1,15 @@
/** For building //packages/core. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"outDir": ".tsec"
},
"include": [
"*.ts",
"src/**/*.ts",
"../*.d.ts"
],
"references": [
{"path": "../zone.js/lib/tsconfig-tsec.json"}
]
}
@@ -0,0 +1,25 @@
/** For building //packages/platform-browser-dynamic. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../core"],
"@angular/common": ["../common"],
"@angular/compiler": ["../compiler"],
"@angular/platform-browser": ["../platform-browser"]
}
},
"include": [
"*.ts",
"src/**/*.ts",
"../*.d.ts"
],
"references": [
{"path": "../core/tsconfig-tsec.json"},
{"path": "../common/tsconfig-tsec.json"},
{"path": "../compiler/tsconfig-tsec.json"},
{"path": "../platform-browser/tsconfig-tsec.json"}
]
}
@@ -0,0 +1,26 @@
/** For building //packages/platform-browser/animations. */
{
"extends": "../../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../../core"],
"@angular/common": ["../../common"],
"@angular/platform-browser": ["../"],
"@angular/animations": ["../../animations"],
"@angular/animations/browser": ["../../animations/browser"]
}
},
"include": [
"*.ts",
"src/**/*.ts"
],
"references": [
{"path": "../../core/tsconfig-tsec.json"},
{"path": "../../common/tsconfig-tsec.json"},
{"path": "../tsconfig-tsec.json"},
{"path": "../../animations/tsconfig-tsec.json"},
{"path": "../../animations/browser/tsconfig-tsec.json"}
]
}
@@ -0,0 +1,22 @@
/** For building //packages/platform-browser. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../core"],
"@angular/common": ["../common"]
}
},
"include": [
"*.ts",
"src/**/*.ts",
"../*.d.ts"
],
"references": [
{"path": "../core/tsconfig-tsec.json"},
{"path": "../common/tsconfig-tsec.json"},
{"path": "../zone.js/lib/tsconfig-tsec.json"}
]
}
@@ -0,0 +1,33 @@
/** For building //packages/platform-server. */
{
"extends": "../tsconfig-tsec-base.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": ".tsec",
"paths": {
"@angular/core": ["../core"],
"@angular/common": ["../common"],
"@angular/common/http": ["../common/http"],
"@angular/compiler": ["../compiler"],
"@angular/platform-browser": ["../platform-browser"],
"@angular/platform-browser/animations": ["../platform-browser/animations"],
"@angular/platform-browser-dynamic": ["../platform-browser-dynamic"],
"@angular/animations/browser": ["../animations/browser"]
}
},
"include": [
"*.ts",
"src/**/*.ts"
],
"references": [
{"path": "../core/tsconfig-tsec.json"},
{"path": "../common/tsconfig-tsec.json"},
{"path": "../common/http/tsconfig-tsec.json"},
{"path": "../compiler/tsconfig-tsec.json"},
{"path": "../platform-browser/tsconfig-tsec.json"},
{"path": "../platform-browser/animations/tsconfig-tsec.json"},
{"path": "../platform-browser-dynamic/tsconfig-tsec.json"},
{"path": "../zone.js/lib/tsconfig-tsec.json"},
{"path": "../animations/browser/tsconfig-tsec.json"}
]
}
+10
View File
@@ -0,0 +1,10 @@
/** Root tsconfig file for checking Angular packages with tsec. */
{
"extends": "./tsconfig-build.json",
"compilerOptions": {
"composite": true,
"emitDeclarationOnly": true,
"lib": ["es2017", "dom"],
"plugins": [{"name": "tsec", "exemptionConfig": "./tsec-exemption.json"}]
}
}
+10
View File
@@ -0,0 +1,10 @@
/** Main config for building all packages that need to be checked by tsec. */
{
"extends": "./tsconfig-tsec-base.json",
"include": [],
"references": [
{"path": "core/tsconfig-tsec.json"},
{"path": "platform-browser/tsconfig-tsec.json"},
{"path": "platform-server/tsconfig-tsec.json"}
]
}
+35
View File
@@ -0,0 +1,35 @@
/**
* The central exemption list of existing tsec violations. Modifications to
* this list should be carefully reviewed by a security expert.
*/
{
"ban-trustedtypes-createpolicy": [
"core/src/util/security/trusted_types_bypass.ts",
"core/src/util/security/trusted_types.ts",
"compiler/src/output/output_jit_trusted_types.ts"
],
"ban-element-innerhtml-assignments": [
"core/src/sanitization/inert_body.ts"
],
"ban-element-setattribute": [
"platform-browser/src/browser/meta.ts"
],
"ban-domparser-parsefromstring": [
"core/src/sanitization/inert_body.ts"
],
"ban-script-content-assignments": [
"platform-server/src/transfer_state.ts"
],
"ban-function-calls": [
"core/src/interface/type.ts",
"core/src/reflection/reflection_capabilities.ts",
"core/src/util/security/trusted_types.ts",
"core/src/render3/instructions/listener.ts",
"compiler/src/core.ts",
"compiler/src/output/output_jit_trusted_types.ts",
"platform-server/src/server_renderer.ts"
],
"ban-window-stringfunctiondef": [
"core/src/render3/util/misc_utils.ts"
]
}
+9
View File
@@ -0,0 +1,9 @@
/* For building //packages/zone.js/lib:zone_d_ts. */
{
"extends": "../../tsconfig-tsec-base.json",
"compilerOptions": {
"outFile": ".tsec/zone.d.ts",
"types": ["node"]
},
"files": ["zone.ts"]
}