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
C#: Refactor C# queries to use ThreatModelFlowSource instead of RemoteFlowSource
#15419
base: main
Are you sure you want to change the base?
C#: Refactor C# queries to use ThreatModelFlowSource instead of RemoteFlowSource
#15419
Conversation
30fd992
to
d347967
Compare
|
DCA seems fine. |
d347967
to
1789d26
Compare
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Most data flow queries that track flow from *remote* flow sources now use the current *threat model* configuration instead. This doesn't lead to any changes in the produced alerts (as the default configuration is *remote* flow sources) unless the threat model configuration is changed. |
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.
It is worth mentioning the specific queries that also included local sources as default no longer does so under the default threat model configuration (e.g cs/code-injection). It is also worth bringing this up in the C# slack channel to make sure that product is informed about this change. IMO this should be perfectly fine as we don't have that many local sources defined in C# as it is - but we need to make sure that this is properly communicated both to product and via the change note. Also, it would be great to streamline this with java and furthermore it seems rather ad hoc that some queries use them while others don't. With the threat models - this will be streamlined.
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 is starting to look good @egregius313 !
Some actionable feedback that we need to consider as a part of this PR:
XMLInjection.ql,ExternalAPIsQuery.qllneeds to be re-factored to use threat models as well.- In
InsecureDirectObjectReferenceQuery.qllwe need to replaceRemoteFlowSourcewithThreatModelFlowSourceinhasIdParameter. - In
SqlInjection.ql,UncontrolledFormatString.qlthegetSourceTypepredicate needs to be updated as well <— This probably requires that we lift the abstractgetSourceTypepredicate to theSourceNodeclass instead (which will require that some further source node descriptions are provided). - Import alerts need to be cleaned up.
|
There is also an open question
|
Since `FlowSources` now re-exports `Remote`, these can be safely removed.
1789d26
to
6dd50b3
Compare
|
@michaelnebel thanks for the review!
I have added a commit d48235d which moves
I'm not sure about the deletions (I would like product's opinion on that before going through with deleting a query), but something about how to opt into the stored sources might be helpful. As I understand it, one of the things which makes things trickier in C# than Java is that the way the threat model hierarchy is setup by default, the classes which are But that means that in the long run the stored queries become largely redundant. Especially if we transition to |
Follow up to #15359.
Refactors C# queries to use
ThreatModelFlowSourceinstead ofRemoteFlowSource.Since most of the C# queries define their sources with public classes like
I cannot remove the classes without changing the public API. Therefore, I have marked the existing
RemoteSourceclasses asdeprecated, and added a new implementation based onThreatModelFlowSource. Since threat modeling includesremotesources by default, I think this is a reasonable trade-off.