Skip to content

Rust: Avoid overlapping path resolution consistency checks #19825

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions rust/ql/consistency-queries/PathResolutionConsistency.ql
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ private import codeql.rust.internal.PathResolution
private import codeql.rust.internal.PathResolutionConsistency as PathResolutionConsistency
private import codeql.rust.elements.Locatable
private import codeql.Locations
import PathResolutionConsistency

class SourceLocatable extends Locatable {
Location getLocation() {
if super.getLocation().fromSource()
then result = super.getLocation()
else result instanceof EmptyLocation
}
SourceLocatable() { this.fromSource() }
}

query predicate multipleMethodCallTargets(SourceLocatable a, SourceLocatable b) {
PathResolutionConsistency::multipleMethodCallTargets(a, b)
query predicate multipleCallTargets(SourceLocatable a) {
PathResolutionConsistency::multipleCallTargets(a, _)
}

query predicate multiplePathResolutions(SourceLocatable a, SourceLocatable b) {
PathResolutionConsistency::multiplePathResolutions(a, b)
query predicate multiplePathResolutions(SourceLocatable a) {
PathResolutionConsistency::multiplePathResolutions(a, _)
}

query predicate multipleCanonicalPaths(SourceLocatable i, SourceLocatable c, string path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ query predicate multiplePathResolutions(Path p, ItemNode i) {
not use.isGlob() and
not use.hasUseTreeList()
).getPath() and
// avoid overlap with `multipleCallTargets` below
not p = any(CallExpr ce).getFunction().(PathExpr).getPath() and
strictcount(resolvePath(p)) > 1
}

/** Holds if `call` has multiple static call targets including `target`. */
query predicate multipleMethodCallTargets(MethodCallExpr call, Callable target) {
query predicate multipleCallTargets(CallExprBase call, Callable target) {
target = call.getStaticTarget() and
strictcount(call.getStaticTarget()) > 1
}
Expand Down Expand Up @@ -51,8 +53,8 @@ int getPathResolutionInconsistencyCounts(string type) {
type = "Multiple path resolutions" and
result = count(Path p | multiplePathResolutions(p, _) | p)
or
type = "Multiple static method call targets" and
result = count(CallExprBase call | multipleMethodCallTargets(call, _) | call)
type = "Multiple static call targets" and
result = count(CallExprBase call | multipleCallTargets(call, _) | call)
or
type = "Multiple record fields" and
result = count(FieldExpr fe | multipleStructFields(fe, _) | fe)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
multipleCallTargets
| proc_macro.rs:16:12:16:16 | ...::to_tokens(...) |
| proc_macro.rs:26:10:26:12 | ...::to_tokens(...) |
| proc_macro.rs:27:10:27:16 | ...::to_tokens(...) |
| proc_macro.rs:42:16:42:26 | ...::to_tokens(...) |
| proc_macro.rs:44:27:44:30 | ...::to_tokens(...) |
| proc_macro.rs:46:18:46:28 | ...::to_tokens(...) |
multiplePathResolutions
| macro_expansion.rs:1:5:1:14 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |
| macro_expansion.rs:1:5:1:14 | proc_macro | proc_macro.rs:0:0:0:0 | Crate(proc_macro@0.0.1) |
| macro_expansion.rs:1:5:1:14 | proc_macro |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
multipleCallTargets
| main.rs:225:14:225:29 | ...::deref(...) |
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
multiplePathResolutions
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:532:10:532:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:538:10:538:18 | ...::from | file://:0:0:0:0 | fn from |
multipleCallTargets
| main.rs:532:10:532:21 | ...::from(...) |
| main.rs:538:10:538:21 | ...::from(...) |
Original file line number Diff line number Diff line change
@@ -1,105 +1,84 @@
multipleMethodCallTargets
| test.rs:618:25:618:49 | address.to_socket_addrs() | file://:0:0:0:0 | fn to_socket_addrs |
| test.rs:618:25:618:49 | address.to_socket_addrs() | file://:0:0:0:0 | fn to_socket_addrs |
| test_futures_io.rs:35:26:35:63 | pinned.poll_read(...) | file://:0:0:0:0 | fn poll_read |
| test_futures_io.rs:35:26:35:63 | pinned.poll_read(...) | file://:0:0:0:0 | fn poll_read |
| test_futures_io.rs:35:26:35:63 | pinned.poll_read(...) | file://:0:0:0:0 | fn poll_read |
| test_futures_io.rs:62:22:62:50 | pinned.poll_fill_buf(...) | file://:0:0:0:0 | fn poll_fill_buf |
| test_futures_io.rs:62:22:62:50 | pinned.poll_fill_buf(...) | file://:0:0:0:0 | fn poll_fill_buf |
| test_futures_io.rs:69:23:69:67 | ... .poll_fill_buf(...) | file://:0:0:0:0 | fn poll_fill_buf |
| test_futures_io.rs:69:23:69:67 | ... .poll_fill_buf(...) | file://:0:0:0:0 | fn poll_fill_buf |
| test_futures_io.rs:93:26:93:63 | pinned.poll_read(...) | file://:0:0:0:0 | fn poll_read |
| test_futures_io.rs:93:26:93:63 | pinned.poll_read(...) | file://:0:0:0:0 | fn poll_read |
| test_futures_io.rs:93:26:93:63 | pinned.poll_read(...) | file://:0:0:0:0 | fn poll_read |
| test_futures_io.rs:116:22:116:50 | pinned.poll_fill_buf(...) | file://:0:0:0:0 | fn poll_fill_buf |
| test_futures_io.rs:116:22:116:50 | pinned.poll_fill_buf(...) | file://:0:0:0:0 | fn poll_fill_buf |
| web_frameworks.rs:101:14:101:23 | a.as_str() | file://:0:0:0:0 | fn as_str |
| web_frameworks.rs:101:14:101:23 | a.as_str() | file://:0:0:0:0 | fn as_str |
| web_frameworks.rs:102:14:102:25 | a.as_bytes() | file://:0:0:0:0 | fn as_bytes |
| web_frameworks.rs:102:14:102:25 | a.as_bytes() | file://:0:0:0:0 | fn as_bytes |
multiplePathResolutions
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:112:62:112:73 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:119:58:119:69 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:777:23:777:61 | ...::try_from | file://:0:0:0:0 | fn try_from |
| test.rs:777:23:777:61 | ...::try_from | file://:0:0:0:0 | fn try_from |
| test.rs:777:23:777:61 | ...::try_from | file://:0:0:0:0 | fn try_from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test.rs:806:50:806:61 | ...::from | file://:0:0:0:0 | fn from |
| test_futures_io.rs:25:23:25:61 | ...::try_from | file://:0:0:0:0 | fn try_from |
| test_futures_io.rs:25:23:25:61 | ...::try_from | file://:0:0:0:0 | fn try_from |
| test_futures_io.rs:25:23:25:61 | ...::try_from | file://:0:0:0:0 | fn try_from |
| test_futures_io.rs:145:26:145:43 | ...::with_capacity | file://:0:0:0:0 | fn with_capacity |
| test_futures_io.rs:145:26:145:43 | ...::with_capacity | file://:0:0:0:0 | fn with_capacity |
| web_frameworks.rs:40:5:40:26 | ...::write_str | file://:0:0:0:0 | fn write_str |
| web_frameworks.rs:40:5:40:26 | ...::write_str | file://:0:0:0:0 | fn write_str |
| web_frameworks.rs:40:5:40:26 | ...::write_str | file://:0:0:0:0 | fn write_str |
| web_frameworks.rs:40:5:40:26 | ...::write_str | file://:0:0:0:0 | fn write_str |
multipleCanonicalPaths
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord>::to_ordering |
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord>::to_ordering |
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord>::to_ordering |
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord>::to_ordering |
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord>::to_ordering |
| file://:0:0:0:0 | fn to_ordering | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord>::to_ordering |
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as core::cmp::Ord> |
| file://:0:0:0:0 | impl Ord for Equal { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Equal as typenum::marker_traits::Ord> |
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as core::cmp::Ord> |
| file://:0:0:0:0 | impl Ord for Greater { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Greater as typenum::marker_traits::Ord> |
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as core::cmp::Ord> |
| file://:0:0:0:0 | impl Ord for Less { ... } | file://:0:0:0:0 | Crate(typenum@1.18.0) | <typenum::Less as typenum::marker_traits::Ord> |
multipleCallTargets
| test.rs:98:14:98:43 | ...::_print(...) |
| test.rs:109:14:109:33 | ...::_print(...) |
| test.rs:112:62:112:77 | ...::from(...) |
| test.rs:119:58:119:73 | ...::from(...) |
| test.rs:135:22:135:43 | ...::_print(...) |
| test.rs:140:22:140:43 | ...::_print(...) |
| test.rs:144:22:144:44 | ...::_print(...) |
| test.rs:160:26:160:110 | ...::_print(...) |
| test.rs:168:26:168:111 | ...::_print(...) |
| test.rs:178:30:178:68 | ...::_print(...) |
| test.rs:187:26:187:105 | ...::_print(...) |
| test.rs:609:18:609:38 | ...::_print(...) |
| test.rs:614:18:614:45 | ...::_print(...) |
| test.rs:618:25:618:49 | address.to_socket_addrs() |
| test.rs:632:38:632:42 | ...::_print(...) |
| test.rs:636:38:636:54 | ...::_print(...) |
| test.rs:641:38:641:51 | ...::_print(...) |
| test.rs:651:34:651:52 | ...::_print(...) |
| test.rs:670:14:670:43 | ...::_print(...) |
| test.rs:685:18:685:42 | ...::_print(...) |
| test.rs:689:18:689:42 | ...::_print(...) |
| test.rs:694:18:694:45 | ...::_print(...) |
| test.rs:701:30:701:34 | ...::_print(...) |
| test.rs:705:30:705:52 | ...::_print(...) |
| test.rs:714:30:714:43 | ...::_print(...) |
| test.rs:724:30:724:34 | ...::_print(...) |
| test.rs:728:30:728:52 | ...::_print(...) |
| test.rs:737:30:737:43 | ...::_print(...) |
| test.rs:752:14:752:43 | ...::_print(...) |
| test.rs:766:14:766:34 | ...::_print(...) |
| test.rs:777:23:777:80 | ...::try_from(...) |
| test.rs:806:50:806:66 | ...::from(...) |
| test.rs:806:50:806:66 | ...::from(...) |
| test.rs:808:14:808:31 | ...::_print(...) |
| test.rs:811:14:811:31 | ...::_print(...) |
| test.rs:814:14:814:31 | ...::_print(...) |
| test.rs:817:14:817:30 | ...::_print(...) |
| test.rs:819:27:819:36 | ...::_print(...) |
| test.rs:820:28:820:41 | ...::_print(...) |
| test.rs:823:14:823:33 | ...::_print(...) |
| test.rs:825:27:825:36 | ...::_print(...) |
| test.rs:826:28:826:41 | ...::_print(...) |
| test.rs:829:14:829:31 | ...::_print(...) |
| test.rs:831:27:831:36 | ...::_print(...) |
| test.rs:832:28:832:41 | ...::_print(...) |
| test.rs:835:14:835:34 | ...::_print(...) |
| test.rs:837:27:837:36 | ...::_print(...) |
| test.rs:838:28:838:41 | ...::_print(...) |
| test.rs:841:14:841:25 | ...::_print(...) |
| test.rs:843:27:843:36 | ...::_print(...) |
| test.rs:844:28:844:41 | ...::_print(...) |
| test.rs:847:14:847:31 | ...::_print(...) |
| test.rs:849:27:849:36 | ...::_print(...) |
| test.rs:850:28:850:41 | ...::_print(...) |
| test.rs:853:14:853:30 | ...::_print(...) |
| test.rs:855:27:855:36 | ...::_print(...) |
| test.rs:856:28:856:41 | ...::_print(...) |
| test.rs:859:14:859:33 | ...::_print(...) |
| test.rs:861:27:861:36 | ...::_print(...) |
| test.rs:862:28:862:41 | ...::_print(...) |
| test.rs:865:14:865:36 | ...::_print(...) |
| test.rs:867:27:867:36 | ...::_print(...) |
| test.rs:868:28:868:41 | ...::_print(...) |
| test.rs:871:14:871:38 | ...::_print(...) |
| test.rs:873:27:873:36 | ...::_print(...) |
| test.rs:874:28:874:41 | ...::_print(...) |
| test.rs:877:14:877:45 | ...::_print(...) |
| test.rs:879:27:879:36 | ...::_print(...) |
| test.rs:880:28:880:41 | ...::_print(...) |
| test.rs:883:14:883:29 | ...::_print(...) |
| test.rs:885:27:885:36 | ...::_print(...) |
| test.rs:886:28:886:41 | ...::_print(...) |
| test_futures_io.rs:25:23:25:80 | ...::try_from(...) |
| test_futures_io.rs:35:26:35:63 | pinned.poll_read(...) |
| test_futures_io.rs:62:22:62:50 | pinned.poll_fill_buf(...) |
| test_futures_io.rs:69:23:69:67 | ... .poll_fill_buf(...) |
| test_futures_io.rs:93:26:93:63 | pinned.poll_read(...) |
| test_futures_io.rs:116:22:116:50 | pinned.poll_fill_buf(...) |
| test_futures_io.rs:145:26:145:49 | ...::with_capacity(...) |
| web_frameworks.rs:40:5:40:26 | ...::write_str(...) |
| web_frameworks.rs:40:5:40:26 | ...::write_str(...) |
| web_frameworks.rs:101:14:101:23 | a.as_str() |
| web_frameworks.rs:102:14:102:25 | a.as_bytes() |
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
multipleMethodCallTargets
| main.rs:64:16:64:25 | s.as_str() | file://:0:0:0:0 | fn as_str |
| main.rs:64:16:64:25 | s.as_str() | file://:0:0:0:0 | fn as_str |
multiplePathResolutions
| main.rs:52:14:52:25 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:52:14:52:25 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:52:14:52:25 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:52:14:52:25 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:52:14:52:25 | ...::from | file://:0:0:0:0 | fn from |
| main.rs:52:14:52:25 | ...::from | file://:0:0:0:0 | fn from |
multipleCallTargets
| main.rs:52:14:52:29 | ...::from(...) |
| main.rs:64:16:64:25 | s.as_str() |
Loading