Skip to content
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

Merged
merged 8 commits into from
Nov 19, 2019
Merged

Conversation

rictic
Copy link
Collaborator

@rictic rictic commented Nov 6, 2019

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

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
@rictic
Copy link
Collaborator Author

rictic commented Nov 6, 2019

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 <script> element. It knows about attributes, but not properties. This is a regression (and very possibly a result of my local environment being in a weird state). I haven't yet tracked down what's going on in any detail.

@rictic
Copy link
Collaborator Author

rictic commented Nov 6, 2019

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",
Copy link

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?)

Copy link
Collaborator Author

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?

Copy link
Owner

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 👍

It's more rigorous than our check here.
@rictic rictic requested a review from runem November 19, 2019 17:52
Copy link
Owner

@runem runem left a 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 👍

@runem runem merged commit 7b6125b into runem:master Nov 19, 2019
@rictic rictic deleted the security-system branch November 19, 2019 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type checking with security sanitization in place
3 participants