Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Go: Add Rs Cors Support #14873
base: main
Are you sure you want to change the base?
Go: Add Rs Cors Support #14873
Changes from all commits
3b78477
28288e0
9958ad9
d7e2fbc
8277c60
4b95ea0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning
Code scanning / CodeQL
Class QLDoc style. Warning
Check warning
Code scanning / CodeQL
Class QLDoc style. Warning
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.
This isn't actually correct: if
v
isa.b.c
thenthis
is theVariable a
and the thing that has typeOptions
isa.b.c
. I didn't notice this when you originally modeled GinCors. Can I ask why you are doing it this way? Is there a particular case where just usingVariable
or just usingSsaWithFields
doesn't work?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 at it more carefully, I see that, because of the way that they are modeled,
RsOptions
andGinConfig
are confined to be local variables defined in functions. Is that what you intended? Might you ever want to reason about one that is defined at package scope?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.
@owen-mc
I can change this to just use SSAWithFields. I will ensure that the getBaseVariable() is removed. I see the problem with the current model is that since I am using SSAVariable, getSourceVariable's result is by definition a local variable. I would like to support package variables as well. I have tried to remove SSAs all together and just use Node, but cannot find a way for two nodes to know if they actually represent the same variable. If you can think of any way to do this that would be great.
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.
Sorry I wasn't clearer about why the way they are modeled means they have to be local variables. Well done for figuring it out - coming back to this after four months, it took me a few minutes, even with your explanation.
I would say that SSAWithFields works great as long as you don't mind missing out writes to global variables. You may decide that in practice, that pattern doesn't come up and you're okay with not spotting it.
When dealing with just nodes, I think the normal way to think about them "representing the same variable" is whether there is value/taint flow from one to another.
There is an approach to this kind of thing in
go/ql/src/experimental/CWE-1004/AuthCookie.qll
, but I'm not sure it's necessarily one that I'd recommend.I'll ask the rest of the codeql-go team if they can think of a better way of doing it.
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.
@owen-mc let me know if you have any updates on this :)
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.
Yes, sorry I didn't get back to you. The best way to include global variables is to copy this code which defines
SsaWithFields
and replace the root case with a read from a global variable. I guessGlobalWithFields
would be the obvious name.