3699 Commits

Author SHA1 Message Date
Tom Hvitved
39720a17ef Rust: More type inference tests 2025-11-17 13:54:39 +01:00
Simon Friis Vindum
9971936036 Rust: Improvements to docs from review comments 2025-11-17 12:39:37 +01:00
Simon Friis Vindum
a07f015d01 Rust: Accept changes to expected files 2025-11-17 12:39:36 +01:00
Tom Hvitved
3419c00bc0 Rust: Use ToIndex instead of FromIndex in ranked forex predicates
`ToIndex` makes more sense, since we start the recursion from `0`.
2025-11-17 12:28:35 +01:00
Simon Friis Vindum
089bffff94 Rust: Make impl blocks only give rise to direct trait implementation 2025-11-17 10:22:18 +01:00
Tom Hvitved
19ff5c09d2 Rust: Cache inferCertainType
Ideally, this shouldn't be needed, as we already cache `inferType`. However, since we
have consistency checks that directly call `inferCertainType`, we need to cache it
as well to avoid recomputation.
2025-11-17 09:30:20 +01:00
Tom Hvitved
8455663255 Rust: Speedup AccessAfterLifetime.ql 2025-11-15 15:21:03 +01:00
Tom Hvitved
8668473916 Merge pull request #20683 from hvitved/rust/type-inference-arg-target-typed
Rust: Restrict type propagation into arguments
2025-11-14 10:46:04 +01:00
Tom Hvitved
4c7f9c0144 Rust: Rename ContextType -> UnknownType 2025-11-14 10:16:21 +01:00
Tom Hvitved
79bdf897d7 Rust: Context typing for constructors 2025-11-14 09:45:03 +01:00
Tom Hvitved
c16b42119d Rust: More type inference tests 2025-11-14 09:45:02 +01:00
Tom Hvitved
e69ff0d5e8 Rust: Restrict type propagation into arguments 2025-11-14 09:44:58 +01:00
Tom Hvitved
72b7dd8955 Rust: Add more type inference tests 2025-11-14 09:41:30 +01:00
Tom Hvitved
f926a076b8 Rust: Fix bad join
Before
```
Evaluated relational algebra for predicate TypeMention::NonAliasPathTypeMention.getTypeMentionForTypeParameter/1#f0c507c8@d7d71dnu with tuple counts:
            12496   ~2%    {3} r1 = SCAN `TypeMention::NonAliasPathTypeMention.getAnAssocTypeArgument/1#c61d1deb` OUTPUT In.2, In.0, In.1
            12421   ~0%    {3}    | JOIN WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.0
            12421   ~0%    {3}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Lhs.2
            12421   ~0%    {3}    | JOIN WITH cached_Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
            12421   ~0%    {3}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Lhs.2

                1   ~0%    {2} r2 = SCAN `Stdlib::FnOnceTrait.getTypeParam/0#dispred#93f20bbc` OUTPUT In.1, In.0
                1   ~0%    {2}    | JOIN WITH cached_Type::TTypeParamTypeParameter#868c69a5 ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                1   ~0%    {2}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.1, Lhs.0
             3216   ~0%    {2}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1
             3216   ~0%    {3}    | JOIN WITH `Path::Generated::Path.getSegment/0#dispred#1c7ef50f` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0
             3201   ~0%    {3}    | JOIN WITH `PathSegment::Generated::PathSegment.getParenthesizedArgList/0#dispred#cd573956` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
             3201   ~0%    {3}    | JOIN WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Lhs.0

                1   ~0%    {2} r3 = SCAN `Stdlib::FnOnceTrait.getOutputType/0#0d2e9ef1` OUTPUT In.1, In.0
                1   ~0%    {2}    | JOIN WITH cached_Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1
                1   ~0%    {2}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.1, Lhs.0
             3216   ~3%    {2}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1
             3216   ~0%    {3}    | JOIN WITH `Path::Generated::Path.getSegment/0#dispred#1c7ef50f` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0
             2958   ~0%    {3}    | JOIN WITH `PathSegment::Generated::PathSegment.getRetType/0#dispred#9d400241` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
             2958   ~0%    {3}    | JOIN WITH `RetTypeRepr::Generated::RetTypeRepr.getTypeRepr/0#dispred#fd85a980` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
             2944   ~0%    {3}    | JOIN WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Lhs.0

            54186   ~3%    {2} r4 = JOIN `TypeAlias::Generated::TypeAlias.getTypeRepr/0#dispred#5fd7e521_10#join_rhs` WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.1, Lhs.0
          1446369  ~12%    {3}    | JOIN WITH `PathResolution::ItemNode.getASuccessor/1#8f430f71_201#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Rhs.2
            36945   ~0%    {3}    | JOIN WITH `PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6` ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Rhs.1
        377232832   ~1%    {4}    | JOIN WITH `Name::Generated::Name.getText/0#dispred#107a5a39_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.0
        370815806   ~5%    {4}    | JOIN WITH `TypeAlias::Generated::TypeAlias.getName/0#dispred#bf886045_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3
          1490317   ~0%    {4}    | JOIN WITH cached_Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3
          1490317   ~0%    {4}    | JOIN WITH `Type::AssociatedTypeTypeParameter.getTrait/0#dispred#41eb3020` ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.1, Lhs.3
            36413   ~1%    {4}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e ON FIRST 2 OUTPUT Lhs.1, Lhs.3, Lhs.2, Lhs.0
            36413   ~1%    {3}    | JOIN WITH `PathResolution::ImplOrTraitItemNode.getAssocItem/1#f77bb9ed` ON FIRST 2 OUTPUT Rhs.2, Lhs.2, Lhs.3
            36413   ~0%    {3}    | JOIN WITH cached_Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
            36413   ~0%    {3}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.2, Lhs.0, Lhs.1

            54979   ~3%    {3} r5 = r1 UNION r2 UNION r3 UNION r4
                           return r5
```

After
```
Evaluated relational algebra for predicate TypeMention::NonAliasPathTypeMention.getTypeMentionForTypeParameter/1#f0c507c8@a37ac19m with tuple counts:
          12496   ~2%    {3} r1 = SCAN `TypeMention::NonAliasPathTypeMention.getAnAssocTypeArgument/1#c61d1deb` OUTPUT In.2, In.0, In.1
          12421   ~0%    {3}    | JOIN WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.0
          12421   ~0%    {3}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Lhs.2
          12421   ~0%    {3}    | JOIN WITH Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
          12421   ~0%    {3}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Lhs.2

              1   ~0%    {2} r2 = SCAN `Stdlib::FnOnceTrait.getTypeParam/0#dispred#93f20bbc` OUTPUT In.1, In.0
              1   ~0%    {2}    | JOIN WITH Type::TTypeParamTypeParameter#868c69a5 ON FIRST 1 OUTPUT Rhs.1, Lhs.1
              1   ~0%    {2}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.1, Lhs.0
           3216   ~0%    {2}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1
           3216   ~0%    {3}    | JOIN WITH `Path::Generated::Path.getSegment/0#dispred#1c7ef50f` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0
           3201   ~0%    {3}    | JOIN WITH `PathSegment::Generated::PathSegment.getParenthesizedArgList/0#dispred#cd573956` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
           3201   ~0%    {3}    | JOIN WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Lhs.0

              1   ~0%    {2} r3 = SCAN `Stdlib::FnOnceTrait.getOutputType/0#0d2e9ef1` OUTPUT In.1, In.0
              1   ~0%    {2}    | JOIN WITH Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1
              1   ~0%    {2}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.1, Lhs.0
           3216   ~3%    {2}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e_10#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1
           3216   ~0%    {3}    | JOIN WITH `Path::Generated::Path.getSegment/0#dispred#1c7ef50f` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0
           2958   ~0%    {3}    | JOIN WITH `PathSegment::Generated::PathSegment.getRetType/0#dispred#9d400241` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
           2958   ~0%    {3}    | JOIN WITH `RetTypeRepr::Generated::RetTypeRepr.getTypeRepr/0#dispred#fd85a980` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
           2944   ~0%    {3}    | JOIN WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.2, Lhs.1, Lhs.0

          54186   ~3%    {2} r4 = JOIN `TypeAlias::Generated::TypeAlias.getTypeRepr/0#dispred#5fd7e521_10#join_rhs` WITH TypeMention::TypeMention#3ab935d1 ON FIRST 1 OUTPUT Lhs.1, Lhs.0
        1446369  ~12%    {3}    | JOIN WITH `PathResolution::ItemNode.getASuccessor/1#8f430f71_201#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Rhs.2
          36945   ~2%    {3}    | JOIN WITH `PathResolution::ImplItemNode.getTraitPath/0#dispred#3b7d1cb6` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
          36398   ~3%    {3}    | JOIN WITH TypeMention::NonAliasPathTypeMention#9123dc7e ON FIRST 1 OUTPUT Lhs.0, Lhs.2, Lhs.1
          36413   ~1%    {3}    | JOIN WITH `TypeMention::NonAliasPathTypeMention.getResolvedAlias/1#c48b878e` ON FIRST 2 OUTPUT Rhs.2, Lhs.2, Lhs.0
          36413   ~0%    {3}    | JOIN WITH Type::TAssociatedTypeTypeParameter#14a276f6 ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2
          36413   ~0%    {3}    | JOIN WITH Type::TypeParameter#f85657da ON FIRST 1 OUTPUT Lhs.2, Lhs.0, Lhs.1

          54979   ~3%    {3} r5 = r1 UNION r2 UNION r3 UNION r4
                         return r5
```
2025-11-13 21:31:32 +01:00
Geoffrey White
e0f0305ace Rust: Add test cases for rust/access-invalid-pointer based on real world FPs. 2025-11-13 16:07:22 +00:00
Tom Hvitved
1b6b1e56ed Rust: Fix bad join
Before
```
Pipeline standard for ElementImpl::Impl::MacroExpansion::isFromMacroExpansion/1#69965d18@7580bdbj was evaluated in 205 iterations totaling 49106ms (delta sizes total: 1254645).
        8014745124  ~4%    {1} r1 = AstNodeImpl::Impl::AstNode#22e758cf AND NOT `ElementImpl::Impl::MacroExpansion::isFromMacroExpansion/1#69965d18#prev`(FIRST 1)
         822416474  ~0%    {2}    | JOIN WITH `ElementImpl::Impl::MacroExpansion::getImmediatelyEnclosingMacroInvocation/1#1eb32ecc` ON FIRST 1 OUTPUT Rhs.1, Lhs.0
           1254645  ~0%    {1}    | JOIN WITH `ElementImpl::Impl::MacroExpansion::isFromMacroExpansion/1#69965d18#prev_delta` ON FIRST 1 OUTPUT Lhs.1
                           return r1
```

After
```
Pipeline standard for ElementImpl::Impl::MacroExpansion::isFromMacroExpansion/1#69965d18@f39b84ka was evaluated in 205 iterations totaling 138ms (delta sizes total: 1254645).
        4675568  ~0%    {1} r1 = JOIN `ElementImpl::Impl::MacroExpansion::isFromMacroExpansion/1#69965d18#prev_delta` WITH `ElementImpl::Impl::MacroExpansion::getImmediatelyEnclosingMacroInvocation/1#1eb32ecc_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1
        4672186  ~0%    {1}    | JOIN WITH AstNodeImpl::Impl::AstNode#22e758cf ON FIRST 1 OUTPUT Lhs.0
        1254645  ~0%    {1}    | AND NOT `ElementImpl::Impl::MacroExpansion::isFromMacroExpansion/1#69965d18#prev`(FIRST 1)
                        return r1
```
2025-11-13 15:26:01 +01:00
Tom Hvitved
bfa35629ac Merge pull request #20744 from hvitved/rust/path-resolution-unqualified-use-tree
Rust: Handle unqualified `UseTree`s in path resolution
2025-11-13 11:18:41 +01:00
Tom Hvitved
c6164b33e5 Address review comment 2025-11-13 10:47:04 +01:00
Geoffrey White
e43000f7cf Rust: Correct ordering in query suite .expected lists. 2025-11-13 09:21:04 +00:00
Geoffrey White
12cbb64ef8 Rust: Add query to suite .expected lists. 2025-11-13 09:00:56 +00:00
Geoffrey White
15fa99a288 Rust: Clarify some confusing text in the .qhelp. 2025-11-13 09:00:46 +00:00
Geoffrey White
42aca4a171 Apply suggestions from code review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2025-11-13 08:51:41 +00:00
Geoffrey White
0675a29ae6 Rust: Minor corrections. 2025-11-12 19:26:45 +00:00
Tom Hvitved
467bd541d2 Merge pull request #20770 from hvitved/rust/attribute-macro-expansion-filter
Rust: Remove elements superseded by attribute macro expansions
2025-11-12 19:52:09 +01:00
Geoffrey White
7a62642ed7 Rust: Change note. 2025-11-12 18:17:12 +00:00
Geoffrey White
49063ac8a9 Rust: Cut down the example for readability. 2025-11-12 18:13:02 +00:00
Geoffrey White
dcae0ef975 Rust: I prefer the original certificates reference from the Go .qhelp. 2025-11-12 18:10:44 +00:00
Geoffrey White
87d66c69a3 Rust: Clean up the .qhelp a little. 2025-11-12 18:10:02 +00:00
Geoffrey White
bb78fdf150 Rust: Add qhelp and examples (translated from Go, by Copilot). 2025-11-12 16:50:50 +00:00
Geoffrey White
c77eef39e2 Rust: Convert the query to a path-problem with global data flow. 2025-11-12 16:21:46 +00:00
Geoffrey White
209f394b5e Rust: Fix the alert message. 2025-11-12 15:51:03 +00:00
Geoffrey White
f8ef48b924 Rust: Add query test. 2025-11-12 15:44:15 +00:00
Geoffrey White
9598772477 Update rust/ql/examples/snippets/simple_constant_password.ql
Co-authored-by: Tom Hvitved <hvitved@github.com>
2025-11-12 14:37:45 +00:00
Geoffrey White
f6b7aeaaca Rust: Add prototype query. 2025-11-11 16:01:10 +00:00
Geoffrey White
109abddc36 Apply suggestions from code review
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
2025-11-11 09:32:14 +00:00
Geoffrey White
8624f9c660 Merge pull request #20749 from github/copilot/add-secure-cookie-test-cases
Add test coverage for actix-web, poem, and http-types cookie secure attribute
2025-11-11 09:26:26 +00:00
Geoffrey White
4b212239e1 Rust: Remove unnecessary .(BlockExpr). 2025-11-10 12:35:39 +00:00
Tom Hvitved
de367eaad6 Update rust/ql/lib/codeql/rust/elements/internal/ElementImpl.qll
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-10 12:42:28 +01:00
Tom Hvitved
c81f5f5190 Rust: Remove elements superseded by attribute macro expansions 2025-11-10 09:18:58 +01:00
Tom Hvitved
0bf458a56f Rust: Run codegen 2025-11-09 20:40:13 +01:00
Geoffrey White
61481b51e7 Rust: Change note. 2025-11-07 16:55:35 +00:00
Geoffrey White
7e3ab99d6b Rust: Add much more detailed code comments, since these are examples. 2025-11-07 13:48:03 +00:00
Geoffrey White
7b6e06e8de Rust: Add simple constant password example. 2025-11-07 13:30:53 +00:00
Geoffrey White
49aefe2110 Rust: Add simple SQL injection example. 2025-11-06 18:49:55 +00:00
Geoffrey White
6ce0a0d9df Rust: Add example from the basic-query-for-rust-code.rst. 2025-11-06 17:50:59 +00:00
Geoffrey White
84b50606ed Rust: Add example queries pack. 2025-11-06 17:33:15 +00:00
Tom Hvitved
000f33fcbf Merge pull request #20765 from hvitved/rust/variable-if-let-guard
Rust: Handle variables introduced in if-let guards
2025-11-06 13:49:38 +01:00
Geoffrey White
b4b444de48 Merge pull request #20746 from geoffw0/mv3
Rust: Clean up some models
2025-11-06 10:07:43 +00:00
Geoffrey White
680870dbf3 Rust: Fix after merge. 2025-11-06 09:39:51 +00:00
Tom Hvitved
f8cde74eac Merge pull request #20736 from github/copilot/add-constaccess-class
Rust: Add ConstAccess class with getConst() predicate
2025-11-06 10:25:06 +01:00