-
Notifications
You must be signed in to change notification settings - Fork 444
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
Set up Pysa syntax highlighting #426
Conversation
8f36da0
to
b29be99
Compare
@@ -0,0 +1,4007 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
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.
Can you point out which specific lines you changed? Maybe the output of diff
or something? It'll be too cumbersome to review a whole fork of a 3k line file.
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.
Yep, for sure - I've made a gist here to compare the differences. To summarize, I basically just changed the scope names to be pysa
rather than python
, fixed the UUID, and made all the other changes I mentioned in the PR description.
@gbleaney has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
b29be99
to
9adfcdd
Compare
@gracewgao has updated the pull request. You must reimport the pull request before landing. |
9adfcdd
to
fa7df40
Compare
@gracewgao has updated the pull request. You must reimport the pull request before landing. |
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.
Looking pretty good! Just a few more changes and then I think we're good to land
<array> | ||
<dict> | ||
<key>comment</key> | ||
<string>feature annotations in Pysa</string> |
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.
<string>feature annotations in Pysa</string> | |
<string>Taint and Feature keywords in Pysa</string> |
fa7df40
to
e59a42c
Compare
@gracewgao has updated the pull request. You must reimport the pull request before landing. |
@gbleaney has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
LGTM now. Thanks for the quick turnaround. It'll go through our internal review process now, so there may be a couple more comments, but we're on the path to landing! |
The goal here is to highlight
taint.config
files as regular JSON files and highlight.pysa
files using Python grammar rules with a couple of modifications.To do this, I declared new languages for both file types in
package.json
, and made a TextMate file for each. For thetaint.config
, it includes thesource.json
scope for the entire file and inherits all the grammar rules so that it's essentially treated the same as a JSON file. For the Pysa files, I initially tried to include the Python grammar rules and define new ones on top of that, but there were a lot of conflicts between the scopes. It also seemed redundant to undefine already-defined rules and I think forking the rules directly would also allow for more flexible customization in the future.So, I forked the official Python copy from here and made the following changes:
TaintSource
,TaintSink
,TaintInTaintOut
,Sanitize
,Via
,AttachToSource
,AttachToSink
,AttachToTito
,AddFeatureToArgument
,ViaValueOf
,WithTag
,ViaDynamicFeature
as part of thesupport.class.pysa
scopeentity.name.function.pysa
scopeself
,type
,__init__
from the Python grammar rulesFor more information about naming conventions of scopes, check the TextMate scope docs.
Here are some screenshots from running the extension in my VSCode environment:
Highlighting for feature annotations:
Highlighting for fully-qualified functions:
Highlighting for
taint.config
files:Let me know if I missed anything or if you have any other ideas for syntax highlighting!