Rust: Make SummarizedCallable extend Function instead of string#19268
Rust: Make SummarizedCallable extend Function instead of string#19268hvitved merged 1 commit intogithub:mainfrom
SummarizedCallable extend Function instead of string#19268Conversation
| Type inferType(AstNode n) { result = inferType(n, TypePath::nil()) } | ||
|
|
||
| /** Provides predicates for debugging the type inference implementation. */ | ||
| private module Debug { |
Check warning
Code scanning / CodeQL
Dead code Warning
| /** Provides predicates for debugging the type inference implementation. */ | ||
| private module Debug { | ||
| private Locatable getRelevantLocatable() { | ||
| exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | |
Check warning
Code scanning / CodeQL
Omittable 'exists' variable Warning
| /** Provides predicates for debugging the type inference implementation. */ | ||
| private module Debug { | ||
| private Locatable getRelevantLocatable() { | ||
| exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | |
Check warning
Code scanning / CodeQL
Omittable 'exists' variable Warning
| /** Provides predicates for debugging the type inference implementation. */ | ||
| private module Debug { | ||
| private Locatable getRelevantLocatable() { | ||
| exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | |
Check warning
Code scanning / CodeQL
Omittable 'exists' variable Warning
86ccc96 to
a91cc6b
Compare
d8b7085 to
10a72f7
Compare
9b1cd94 to
2a2e7d5
Compare
e0a2c1d to
dc9700e
Compare
dc9700e to
4224947
Compare
b0991ad to
c29c5f9
Compare
c1959ca to
73c4919
Compare
afa16ea to
58cd7b0
Compare
geoffw0
left a comment
There was a problem hiding this comment.
Test and DCA changes LGTM (I haven't reviewed the QL changes).
There are some losses (in particular: common data flow paths in tests) but they're well understood / documented with plans in place to get them back. 👍
| use futures_rustls::TlsConnector; | ||
| use std::io; | ||
| use std::pin::Pin; | ||
| use std::task::{Context, Poll}; |
There was a problem hiding this comment.
Why are we changing the imports for this test?
If it was done by an auto-formatter can be avoid doing that in future, we do not want to test only auto-formatted target code.
There was a problem hiding this comment.
Yes, it was auto-format.
rust/ql/test/query-tests/security/CWE-089/SqlInjection.expected
Outdated
Show resolved
Hide resolved
rust/ql/test/utils-tests/modelgenerator/CaptureSummaryModels.expected
Outdated
Show resolved
Hide resolved
58cd7b0 to
b978d35
Compare
b978d35 to
433756d
Compare
paldepind
left a comment
There was a problem hiding this comment.
Looks great! Only one nitpick.
One question, is using string for SummarizedCallable the approach taken for dynamic languages? Or is that some third approach?
| target = result.asCfgScope() | ||
| or | ||
| target = result.asSummarizedCallable() | ||
| ) |
There was a problem hiding this comment.
I guess this is a key change? We now use getStaticTarget target in both cases, whereas we previously used getACall in the later case, which used extractor provided canonical paths internally.
There was a problem hiding this comment.
Absolutely correct.
| filepath.matches("%/test.rs") and | ||
| startline = 74 | ||
| filepath.matches("%/main.rs") and | ||
| startline = 52 |
There was a problem hiding this comment.
It would be nice not to commit these changes. For instance, when looking at the history of a file it's easier if the commits that show up actually make meaningful changes.
There was a problem hiding this comment.
Good point, I'll avoid that going forward.
| filepath.matches("%/main.rs") and | ||
| startline = 1718 | ||
| filepath.matches("%/sqlx.rs") and | ||
| startline = [56 .. 60] |
Yes, that is indeed the approach taken there, where there are no extracted entities to use. |
This PR changes the base class of
SummarizedCallablefromstringtoFunction, thereby reusing the existing function entities already extracted instead of synthesizing new entities.This is a big step towards using QL computed canonical paths in models-as-data instead of using extractor provided canonical paths.
A lot of preliminary PRs mean that we mostly retain results, however as witnessed by the tests, we still lose some results. This is largely because:
impl<T> Foo for T.Derefs in type inference.