-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial security type checking. #62
Conversation
This adds basic support for type checking code with Safe Types sanitization in place. This can be trivially extended to support checking with Trusted Types, but I'm starting simple. Trusted Types is also still working through the standards process, so I don't want to ship anything prematurely here. See the conversation at https://groups.google.com/a/chromium.org/g/blink-dev/c/Il-wfnw9TAw
There's something slightly odd going on, at least when I run this locally. The analyzer doesn't seem to know about any properties on the |
Also may depend on runem/ts-simple-type#56 |
@@ -165,6 +168,7 @@ export function makeConfig(userOptions: Partial<LitAnalyzerConfig> = {}): LitAna | |||
return { | |||
strict: userOptions.strict || false, | |||
rules: makeRules(userOptions), | |||
securitySystem: userOptions.securitySystem || "off", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this come straight from a user config file, or can we assume it's validated as a partial config already? (Otherwise should this validate and throw?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following convention here, I didn't throw. Added some validation, since I didn't see other validation. @runem what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration given to lit-analyzer
is not validated as of now. First of all, I think the CLI should throw on invalid values, but ts-lit-plugin
should only log warnings (no reason to crash when running in the IDE).
Therefore, I think that we should implement one of these solutions:
a. export a validateConfig
function that validates the raw, partial config.
b. extend makeConfig
with an option to assert values (perhaps a callback that is called on invalid config values).
I also think makeConfig
should properly fall back to default values when encountering an invalid value (which it doesn't do for all attributes right now).
I created an issue for it here #65 so that it can be done in a future, separate PR 👍
packages/lit-analyzer/src/analyze/util/type/is-assignable-binding-under-security-system.ts
Outdated
Show resolved
Hide resolved
packages/lit-analyzer/src/analyze/util/type/is-assignable-in-attribute-binding.ts
Outdated
Show resolved
Hide resolved
packages/lit-analyzer/src/analyze/util/type/is-assignable-binding-under-security-system.ts
Outdated
Show resolved
Hide resolved
It's more rigorous than our check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! I'll merge this PR now 👍
This adds basic support for type checking code with Safe Types sanitization in place. This can be trivially extended to support checking with Trusted Types, but I'm starting simple.
Trusted Types is also still working through the standards process, so I don't want to ship anything prematurely here. See the conversation at https://groups.google.com/a/chromium.org/g/blink-dev/c/Il-wfnw9TAw
Fixes #28