Compare commits

..

1106 Commits

Author SHA1 Message Date
Mathias Vorreiter Pedersen
214ca2a535 Merge pull request #272 from microsoft/jb1/2.22.3
Merge upstream `codeql-cli-2.22.3`
2025-08-12 16:33:08 +02:00
Mathias Vorreiter Pedersen
627ee8536c PS: Port changes from #20132 to PowerShell. 2025-08-12 14:52:12 +01:00
Josh Brown
c6ab9412b6 Merge tag 'codeql-cli/v2.22.3' into jb1/2.22.3
Compatible with CodeQL CLI 2.22.3
2025-08-11 12:56:34 -07:00
Josh Brown
09365313ef merge upstream v2.22.2 2025-08-11 12:45:33 -07:00
Josh Brown
f39c1141d8 Revert "Merge pull request #257 from microsoft/jb1/reapply-22.1-tmp"
This reverts commit 6d496ee073, reversing
changes made to 866977b6c5.
2025-08-11 12:45:01 -07:00
Chanel
337132b5e0 Merge pull request #270 from microsoft/better-api-graphs
PS: Better usability when working with nested classes
2025-08-11 08:03:50 -07:00
Mathias Vorreiter Pedersen
e96e464855 PS: Accept test changes. 2025-08-11 14:22:19 +01:00
Mathias Vorreiter Pedersen
9b5897ca3a PS: Improve api graphs. 2025-08-11 14:22:17 +01:00
Mathias Vorreiter Pedersen
1bd93b9849 PS: Add missing dataflow predicates related to models. 2025-08-08 17:08:15 +01:00
Mathias Vorreiter Pedersen
3829528467 PS: Delete stuff we don't actually need. 2025-08-08 17:07:43 +01:00
Chuan-kai Lin
da3e5479df Merge pull request #20165 from github/release-prep/2.22.3
Release preparation for version 2.22.3
2025-08-04 09:19:35 -07:00
Chuan-kai Lin
4df1c12876 Minor CHANGELOG updates 2025-08-04 09:09:25 -07:00
github-actions[bot]
fd82aeb1f8 Release preparation for version 2.22.3 2025-08-04 15:47:57 +00:00
Tom Hvitved
65bf76e3ed Merge pull request #20161 from hvitved/rust/fix-bad-joins
Rust: Fix two bad joins introduced by magic
2025-08-04 17:32:54 +02:00
Geoffrey White
8b5603cf71 Merge pull request #20160 from geoffw0/exec
Rust: Add type inference test cases resembling missing call targets in SQLx.
2025-08-04 16:03:12 +01:00
Geoffrey White
6925d4e564 Merge pull request #20129 from codeqlhelper/main
C++: Static variables are initialized to zero or null by compiler
2025-08-04 13:23:45 +01:00
Tom Hvitved
125a4b9b10 Rust: Fix two bad joins introduced by magic
```
Evaluated relational algebra for predicate TypeInference::closureParameterPath/2#9d0bf423#bbf@ba08cc1s with tuple counts:
           565067    ~172652%    {2} r1 = JOIN `Callable::Callable.getParam/1#dispred#ce0254b3_01#count_range` WITH `Callable::Generated::Callable.getNumberOfParams/0#dispred#abb45996` ON FIRST 1 OUTPUT Rhs.1, Lhs.1
            24684     ~11784%    {3}    | JOIN WITH Type::TTupleTypeParameter#5ca17706 ON FIRST 2 OUTPUT Rhs.2, Lhs.1, Lhs.0
             2970      ~1391%    {3}    | JOIN WITH `TypeInference::TypePath::singleton/1#ee45de3b` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Rhs.1
              664       ~242%    {4}    | JOIN WITH `Stdlib::FnOnceTrait.getTypeParam/0#dispred#93f20bbc` CARTESIAN PRODUCT OUTPUT Rhs.1, Lhs.0, Lhs.1, Lhs.2
              303        ~49%    {4}    | JOIN WITH Type::TDynTraitTypeParameter#e16268df ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3
              198         ~0%    {8}    | JOIN WITH `TypeInference::TypePath::singleton/1#ee45de3b` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, _, _, Rhs.1, Lhs.3, _, _
                                 {4}    | REWRITE WITH Out.2 := (In.4 ++ In.5), Tmp.3 := (In.4 ++ In.5), Tmp.6 := "[0-9]+", Tmp.7 := "", Out.3 := regexpReplaceAll(Tmp.3,Tmp.6,Tmp.7) KEEPING 4
              198         ~0%    {6}    | SCAN OUTPUT In.0, In.1, In.2, _, In.3, _
                                 {4}    | REWRITE WITH Out.3 := length(In.4), Tmp.5 := 10, TEST Out.3 <= Tmp.5 KEEPING 4
              198         ~0%    {3}    | SCAN OUTPUT In.1, In.0, In.2

           877984   ~1444714%    {1} r2 = SCAN `CallExprBase::CallExprBase.getArg/1#dispred#d775f13d` OUTPUT In.1
           299888     ~83707%    {3}    | JOIN WITH Type::TTupleTypeParameter#5ca17706_102#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.0, Rhs.2
        515462762     ~59140%    {4}    | JOIN WITH `CallExprBase::Generated::CallExprBase.getNumberOfArgs/0#dispred#0975fe12_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0, Lhs.2
          9429188  ~25728933%    {3}    | JOIN WITH TypeInference::InvokedClosureExpr#24e5dacb_1#join_rhs ON FIRST 1 OUTPUT Lhs.3, Lhs.1, Lhs.2
            53669    ~142315%    {3}    | JOIN WITH `TypeInference::TypePath::singleton/1#ee45de3b` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Rhs.1
             4003     ~10522%    {4}    | JOIN WITH `Stdlib::FnOnceTrait.getTypeParam/0#dispred#93f20bbc` CARTESIAN PRODUCT OUTPUT Rhs.1, Lhs.0, Lhs.1, Lhs.2
              370       ~910%    {4}    | JOIN WITH Type::TDynTraitTypeParameter#e16268df ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.3
              148       ~293%    {8}    | JOIN WITH `TypeInference::TypePath::singleton/1#ee45de3b` ON FIRST 1 OUTPUT Lhs.1, Lhs.2, _, _, Rhs.1, Lhs.3, _, _
                                 {4}    | REWRITE WITH Out.2 := (In.4 ++ In.5), Tmp.3 := (In.4 ++ In.5), Tmp.6 := "[0-9]+", Tmp.7 := "", Out.3 := regexpReplaceAll(Tmp.3,Tmp.6,Tmp.7) KEEPING 4
              148       ~316%    {6}    | SCAN OUTPUT In.0, In.1, In.2, _, In.3, _
                                 {4}    | REWRITE WITH Out.3 := length(In.4), Tmp.5 := 10, TEST Out.3 <= Tmp.5 KEEPING 4
              148       ~293%    {3}    | SCAN OUTPUT In.1, In.0, In.2

              346        ~75%    {3} r3 = r1 UNION r2
                                 return r3
```

and

```
Evaluated relational algebra for predicate TypeInference::fnParameterPath/2#4dea2880#bbf@d56000vi with tuple counts:
                1         ~0%    {1} r1 = SCAN `Stdlib::FnOnceTrait.getTypeParam/0#dispred#93f20bbc` OUTPUT In.1
                1         ~0%    {1}    | JOIN WITH Type::TTypeParamTypeParameter#868c69a5 ON FIRST 1 OUTPUT Rhs.1
                1         ~0%    {1}    | JOIN WITH `TypeInference::TypePath::singleton/1#ee45de3b` ON FIRST 1 OUTPUT Rhs.1
           877984   ~1350201%    {2}    | JOIN WITH `ArgList::Generated::ArgList.getArg/1#dispred#b07adc80` CARTESIAN PRODUCT OUTPUT Rhs.1, Lhs.0
           321252     ~90755%    {4}    | JOIN WITH Type::TTupleTypeParameter#5ca17706_102#join_rhs ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.0, Rhs.2
        553043191     ~65412%    {5}    | JOIN WITH `CallExprBase::Generated::CallExprBase.getNumberOfArgs/0#dispred#0975fe12_10#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Lhs.1, Lhs.2, Lhs.0, Lhs.3
         10089088  ~26772053%    {4}    | JOIN WITH TypeInference::InvokedClosureExpr#24e5dacb_1#join_rhs ON FIRST 1 OUTPUT Lhs.4, Lhs.1, Lhs.2, Lhs.3
            57729    ~157423%    {8}    | JOIN WITH `TypeInference::TypePath::singleton/1#ee45de3b` ON FIRST 1 OUTPUT Lhs.2, Lhs.3, _, _, Lhs.1, Rhs.1, _, _
                                 {4}    | REWRITE WITH Out.2 := (In.4 ++ In.5), Tmp.3 := (In.4 ++ In.5), Tmp.6 := "[0-9]+", Tmp.7 := "", Out.3 := regexpReplaceAll(Tmp.3,Tmp.6,Tmp.7) KEEPING 4
            57729    ~157423%    {6}    | SCAN OUTPUT In.0, In.1, In.2, _, In.3, _
                                 {4}    | REWRITE WITH Out.3 := length(In.4), Tmp.5 := 10, TEST Out.3 <= Tmp.5 KEEPING 4
            57729    ~157423%    {3}    | SCAN OUTPUT In.1, In.0, In.2
                                 return r1
```
2025-08-04 14:22:50 +02:00
Geoffrey White
2ec6dafd18 Rust: Add a type inference test case resembling missing call targets in SQLx. 2025-08-04 10:21:59 +01:00
Simon Friis Vindum
9aebc58214 Merge pull request #20147 from paldepind/rust/type-limit-metric
Rust: Add metric for DCA and debug predicates for type that reach the length limit
2025-08-04 07:53:14 +02:00
Mathias Vorreiter Pedersen
1fab97b765 Merge pull request #20149 from MathiasVP/expose-definition-from-dataflow-ssa
C++: Expose SSA definitions from dataflow
2025-08-01 12:04:04 +01:00
Mathias Vorreiter Pedersen
0e9286dd34 C++: Fix QLDoc. 2025-08-01 11:37:12 +01:00
Mathias Vorreiter Pedersen
b70836e241 C++: Modify the API to not expose dataflow nodes. 2025-08-01 11:34:49 +01:00
Mathias Vorreiter Pedersen
33d05984c8 C++: Stick the exposed SSA classes into a public SSA module. 2025-08-01 11:34:47 +01:00
Mathias Vorreiter Pedersen
32e6d0934e C++: Drive-by fix: These files imported both the public dataflow files and the internal ones. Let's only import the internal ones. 2025-08-01 11:34:45 +01:00
Mathias Vorreiter Pedersen
7ede3aa516 C++: Fix imports. 2025-08-01 10:35:34 +01:00
Mathias Vorreiter Pedersen
0d91622d18 C++: Rename SsaInternals to SsaImpl and SsaInternalsCommon to SsaImplCommon. 2025-08-01 10:34:14 +01:00
codeqlhelper
4323e6853f Update cpp/ql/src/change-notes/2025-07-27-avoid-reporting-static-global-variable.md
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
2025-07-31 21:17:29 +08:00
Mathias Vorreiter Pedersen
c8f4b287d1 C++: Add a comment on the old SSA library. 2025-07-31 14:07:38 +01:00
Mathias Vorreiter Pedersen
7e93b99ff9 C++: Add change note. 2025-07-31 13:57:19 +01:00
Mathias Vorreiter Pedersen
8691075aae Update cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-31 13:52:21 +01:00
Mathias Vorreiter Pedersen
5a91aa2105 C++: Expose SSA definitions from dataflow. 2025-07-31 13:45:03 +01:00
Simon Friis Vindum
abc58ac8b3 Rust: Add metric and debug predicates for type that reach the length limit 2025-07-31 14:20:32 +02:00
Mathias Vorreiter Pedersen
1dae787605 C++: Drive-by fix suggested by Schack. This now matches the predicate in C#. 2025-07-31 12:58:05 +01:00
Ian Lynagh
492e27b8e8 Merge pull request #20141 from igfoo/igfoo/kotlin-2.2.20-beta2
Kotlin: Support 2.2.20-beta2
2025-07-31 12:00:17 +01:00
Ian Lynagh
e589019e04 Kotlin: Use 2.2.20-Beta2 rather than 2.2.20-Beta1 2025-07-30 14:14:14 +01:00
Ian Lynagh
4ea6133042 Kotlin: Add 2.2.20-Beta2 jars 2025-07-30 14:13:02 +01:00
Ian Lynagh
c78818d7dd Kotlin: Remove *2.2.20-Beta1* jars 2025-07-30 14:12:43 +01:00
Simon Friis Vindum
3bc1d47738 Merge pull request #20130 from paldepind/rust/type-inference-fn
Rust: Implement type inference for closures and calls to closures
2025-07-30 13:13:57 +02:00
codeqlhelper
ee3e7e34ba Merge pull request #1 from geoffw0/initnotrun .expected
CPP: Add .expected file for the InitialisationNotRun test
2025-07-30 18:36:29 +08:00
Geoffrey White
c0638a5fcb CPP: Update .expected for the changes here. 2025-07-30 11:24:57 +01:00
Anders Schack-Mulligen
5ca9c090a8 Merge pull request #20132 from aschackmull/ssa/guardvalue
SSA: Update data flow integration and BarrierGuard interface to use GuardValue.
2025-07-30 12:23:17 +02:00
Geoffrey White
d6fddde6e0 CPP: Add .expected (results before query changes here). 2025-07-30 11:22:56 +01:00
Geoffrey White
43bca84310 CPP: Convert test to use a stub rather than a library include. 2025-07-30 11:22:53 +01:00
Simon Friis Vindum
5b152cfdec Rust: Fix typo in change note
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
2025-07-29 18:38:14 +02:00
Simon Friis Vindum
5540b9df71 Merge branch 'main' into rust/type-inference-fn 2025-07-29 16:43:17 +02:00
Anders Schack-Mulligen
3b8234ecec SSA: Update data flow integration and BarrierGuard interface to use GuardValue. 2025-07-28 11:29:12 +02:00
Simon Friis Vindum
8e474c946e Rust: Add change note for type inference for closures 2025-07-28 10:27:33 +02:00
Simon Friis Vindum
2c758a9842 Rust: Add type inference for closures and calls to first-class functions 2025-07-27 21:28:10 +02:00
Simon Friis Vindum
8c6c28d61f Rust: Add type inference tests for closures 2025-07-27 21:16:30 +02:00
codeqlhelper
75e545a67f Create 2025-07-27-avoid-reporting-static-global-variable.md 2025-07-28 00:00:41 +08:00
codeqlhelper
cf21997c0f Reduce false alarms raised by static variables
Static variables are initialized to zero or null by compiler, no need to get an initializer of them.
See https://stackoverflow.com/questions/13251083/the-initialization-of-static-variables-in-c
See 6.7.8/10 in the C99 Standard.

A relevant PR: https://github.com/github/codeql/pull/16527
2025-07-27 23:46:53 +08:00
codeqlhelper
89dcad48f4 Create InitialisationNotRun.qlref 2025-07-27 23:42:50 +08:00
codeqlhelper
c2d0a12e1e Create test for InitialisationNotRun 2025-07-27 23:40:00 +08:00
Mathias Vorreiter Pedersen
f8bdfa4666 Merge pull request #264 from microsoft/simple-type-sanitizers
PS: Add simple type-based sanitizer to SQL injection query
2025-07-25 11:41:01 +01:00
Mathias Vorreiter Pedersen
b0d61928bf Merge pull request #265 from microsoft/dilan/iac-setup
CodeQL for IaC (infrastructure as code) Setup
2025-07-25 11:40:21 +01:00
dilanbhalla
cb63c6aed0 Add 'iac' language support to CodeQL workflow
Added 'iac' to the list of supported languages for CodeQL.
2025-07-24 12:55:38 -07:00
Dilan Bhalla
eb15e3bcc9 Add codeql-extractor-iac as submodule in iac/ 2025-07-24 12:43:16 -07:00
Mathias Vorreiter Pedersen
ffc53d7764 PS: Accept test changes. 2025-07-24 20:03:59 +01:00
Mathias Vorreiter Pedersen
7b4d2a9edf PS: Lower casing in command-line injection query. 2025-07-24 20:03:48 +01:00
Mathias Vorreiter Pedersen
b66c99ba76 PS: Lower casing in frameworks. 2025-07-24 20:03:27 +01:00
Mathias Vorreiter Pedersen
e3b3f0b343 PS: Consistent lower casing in api graphs, control-flow graph, and dataflow nodes. 2025-07-24 20:03:10 +01:00
Mathias Vorreiter Pedersen
3880d9fa8d PS: More consistent lower casing in the AST classes. 2025-07-24 20:02:03 +01:00
Mathias Vorreiter Pedersen
71fec26542 PS: Lower case all parameter types. 2025-07-24 18:07:59 +01:00
Mathias Vorreiter Pedersen
f9c3bde6d5 PS: Fix false positive by adding a type-based sanitizer. 2025-07-24 18:06:06 +01:00
Mathias Vorreiter Pedersen
e7956301a4 PS: Add false positive. 2025-07-24 18:00:49 +01:00
Mathias Vorreiter Pedersen
ae4b3e8542 Merge pull request #263 from microsoft/remove-env-reads-from-sql-injection
PS: Remove environment variables from `powershell/microsoft/public/sql-injection`
2025-07-24 16:33:05 +01:00
Mathias Vorreiter Pedersen
7991eb4919 PS: Accept test changes. 2025-07-24 00:16:20 +01:00
Mathias Vorreiter Pedersen
3ba87996e3 PS: Unhide some dataflow nodes to make paths more explicit. 2025-07-24 00:11:45 +01:00
Mathias Vorreiter Pedersen
95926cbc70 PS: Remove environment variables as flow sources from 'powershell/microsoft/public/sql-injection'. 2025-07-24 00:11:31 +01:00
Mathias Vorreiter Pedersen
7c83d9d54b Merge pull request #262 from microsoft/powershell-smb-settings
Powershell SMB settings
2025-07-23 19:58:04 +01:00
Chanel
a0dbf930a2 Update powershell/ql/src/queries/security/cwe-319/UnsafeSMBSettings.ql
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-07-23 11:30:30 -07:00
Chanel Young
482fda7541 formatting 2025-07-23 11:22:12 -07:00
Chanel Young
4e0ea04d3b add query, tests 2025-07-23 11:16:11 -07:00
Chanel
c961340f54 Merge pull request #260 from microsoft/powershell-unsafe-deserialization
Powershell Unsafe Deserialize query
2025-07-22 10:49:10 -07:00
Chanel
d78280ea0f Merge branch 'main' into powershell-unsafe-deserialization 2025-07-22 10:07:10 -07:00
Chanel
3b90949d4d Update powershell/ql/src/queries/security/cwe-502/BinaryFormatterDeserialization.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-07-22 10:06:59 -07:00
Chanel
2e93ec5490 Update powershell/ql/src/queries/security/cwe-502/UnsafeDeserialization.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-07-22 10:06:52 -07:00
Chanel
6d62e8717a Update powershell/ql/src/queries/security/cwe-502/BinaryFormatterDeserialization.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-07-22 10:06:46 -07:00
Chanel
9266713d19 Update powershell/ql/src/queries/security/cwe-502/BinaryFormatterDeserialization.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-07-22 10:06:39 -07:00
Chanel Young
1149d33691 updated .expected test file 2025-07-17 13:19:07 -07:00
Chanel
03a7d3d243 Merge pull request #261 from microsoft/global-flow-through-env-variables-2
PS: Global flow through environment variables
2025-07-17 12:30:14 -07:00
Mathias Vorreiter Pedersen
b72af27e81 PS: Add tests showing that there is no flow starting at environment variables, but we still have flow through them. 2025-07-17 20:05:21 +01:00
Mathias Vorreiter Pedersen
a95f3b3f47 PS: Accept test changes. 2025-07-17 19:01:09 +01:00
Mathias Vorreiter Pedersen
6ab627955f PS: Implement global dataflow for environment variable write/reads. 2025-07-17 18:59:25 +01:00
Mathias Vorreiter Pedersen
2541bcdf5e PS: Add test cases. 2025-07-17 18:59:19 +01:00
Mathias Vorreiter Pedersen
3f4a16978e PS: Change the AST so that an 'EnvVariable' is actually a 'Variable', and make it possible for a 'VarAccess' to target a read/write of an environment variable. 2025-07-17 18:48:11 +01:00
Chanel Young
6ac935469f move logic to qlls 2025-07-17 08:27:36 -07:00
Chanel Young
cb8496bbfe added queries, tests, docs 2025-07-16 14:27:23 -07:00
Mathias Vorreiter Pedersen
ef3654f9cf PS: Small cleanup. 2025-07-16 20:21:08 +01:00
Chanel
5fde17736b Merge pull request #258 from microsoft/fix-call-operator-bug
PS: Fix bug in `CallOperator::getCommand`
2025-07-16 09:50:46 -07:00
Mathias Vorreiter Pedersen
72af800101 PS: Accept test changes. 2025-07-16 14:33:02 +01:00
Mathias Vorreiter Pedersen
205d2e58ff PS: Add dot sourcing as a sink. 2025-07-16 14:33:01 +01:00
Mathias Vorreiter Pedersen
670ad745ca PS: Add false negative. 2025-07-16 14:32:42 +01:00
Mathias Vorreiter Pedersen
5f07641bd3 PS: Fix false positive by fixing the 'getCommand' predicates in 'CallOperatorCfgNode' and 'CallOperator'. Also fix 'DotSourcingOperator::getPath' while here. 2025-07-16 14:31:51 +01:00
Mathias Vorreiter Pedersen
75d37dcead PS: Add false positive. 2025-07-16 13:46:44 +01:00
Mathias Vorreiter Pedersen
f39d08ecfa PS: Fix spelling. 2025-07-16 13:45:09 +01:00
Josh Brown
6d496ee073 Merge pull request #257 from microsoft/jb1/reapply-22.1-tmp
Revert #251, Reapply `codeql-cli/v2.22.1`
2025-07-10 16:08:14 -07:00
Josh Brown
b1b0892ae6 Merge branch 'main' into jb1/reapply-22.1-tmp 2025-07-10 15:15:45 -07:00
Josh Brown
4c5945f4aa Manual merge 2025-07-10 15:08:14 -07:00
Josh Brown
5fb45c89e9 Revert "Merge pull request #251 from microsoft/jb1/upstream-zipslip"
This reverts commit 4dfa5d2858, reversing
changes made to 8cd58aa6e8.
2025-07-10 14:57:38 -07:00
Chanel
866977b6c5 Merge pull request #256 from microsoft/jb1/qhelpfix
QHelp: Terminate p tag
2025-07-10 10:51:18 -07:00
Josh Brown
3606679eee Terminate p tag 2025-07-10 10:35:09 -07:00
Josh Brown
4dfa5d2858 Merge pull request #251 from microsoft/jb1/upstream-zipslip
Manual merge upstream
2025-07-10 09:48:55 -07:00
Josh Brown
87e0b08531 Merge branch 'main' into jb1/upstream-zipslip 2025-07-10 09:35:03 -07:00
Josh Brown
81f9e88040 run add-overlay-annotations.py 2025-07-09 22:37:51 -07:00
Mathias Vorreiter Pedersen
8cd58aa6e8 Merge pull request #255 from microsoft/add-iwr-as-flow-source
PS: Add more flow sources
2025-07-09 14:56:43 +01:00
Mathias Vorreiter Pedersen
d1988774a3 PS: Add more flow sources and accept test changes. 2025-07-09 12:22:33 +01:00
Mathias Vorreiter Pedersen
1816356515 PS: Add test with missing remote flow. 2025-07-09 12:20:41 +01:00
Mathias Vorreiter Pedersen
3101cc81e6 Merge pull request #253 from microsoft/add-set-execution-policy-bypass-query
PS: Add query for insecure uses of `Set-ExecutionPolicy`
2025-07-07 19:33:06 +01:00
Mathias Vorreiter Pedersen
398d27b779 PS: Fix missing AST child. 2025-07-07 19:15:18 +01:00
Mathias Vorreiter Pedersen
28de6ede04 PS: Also require '-Force' with a truthy value. Note the 'NOT DETECTED' test. We will fix that in the next commit. 2025-07-07 19:14:01 +01:00
Mathias Vorreiter Pedersen
1d64a7949b Merge pull request #252 from microsoft/add-more-remote-flow-sources
PS: Add flow sources from `System.Net.WebClient`
2025-07-07 14:50:03 +01:00
Lindsay Simpkins
d4571f5b95 Merge pull request #254 from microsoft/implement-localExprTaint
PS: Actually implement `localExprTaint`
2025-07-07 08:23:11 -04:00
Mathias Vorreiter Pedersen
b6b4df5ce0 PS: Implement 'localExprTaint' instead of leaving it as 'none()'. 2025-07-04 20:24:22 +01:00
Mathias Vorreiter Pedersen
4e524a189d PS: Add tests. 2025-07-04 19:44:49 +01:00
Mathias Vorreiter Pedersen
f7c9899450 PS: Add documentation. 2025-07-04 19:44:39 +01:00
Mathias Vorreiter Pedersen
2731983fbe PS: Add query for insecure uses of 'Set-ExecutionPolicy'. 2025-07-04 19:44:15 +01:00
Mathias Vorreiter Pedersen
52ff5d3fbc Merge pull request #246 from microsoft/powershell-commandinjection-invokesinkfix
InvokeSink fix
2025-07-04 18:17:09 +01:00
Chanel Young
654bf2f42f random newline to reset git latest pusher 2025-07-04 10:07:57 -07:00
Mathias Vorreiter Pedersen
766cf826bb PS: Add more models and accept test changes. 2025-07-04 18:01:45 +01:00
Mathias Vorreiter Pedersen
bd9043576d PS: Add test with missing remote flow source. 2025-07-04 18:00:19 +01:00
Chanel
8aa8dde439 Merge branch 'main' into powershell-commandinjection-invokesinkfix 2025-07-04 09:59:15 -07:00
Mathias Vorreiter Pedersen
2a26c43c19 PS: Cleanup a few manually generated models. 2025-07-04 17:01:25 +01:00
Mathias Vorreiter Pedersen
eec092c4c4 PS: Mark the BAD results in the test appropriately. 2025-07-04 11:13:15 +01:00
Mathias Vorreiter Pedersen
7d07773a33 PS: Accept test changes. 2025-07-04 11:12:55 +01:00
Mathias Vorreiter Pedersen
0585c2f9e5 PS: Gets back the previously-lost false negative by making the variable property name expression the sink when there is a call to 'Invoke'. 2025-07-04 11:12:31 +01:00
Josh Brown
4122283ec8 Manual merge 2025-07-01 16:10:55 -07:00
Lindsay Simpkins
849e0b4e1f Merge pull request #248 from microsoft/fix-ps-performance
PS: Fix lots of performance problems
2025-06-20 23:14:39 -04:00
Lindsay Simpkins
52f5ac528c Merge branch 'main' into fix-ps-performance 2025-06-20 23:01:38 -04:00
Lindsay Simpkins
6ab05cd387 Merge pull request #249 from microsoft/fix-fps-on-sql-injection
PS: Fix FPs on `powershell/microsoft/public/sql-injection`
2025-06-20 16:36:54 -04:00
Mathias Vorreiter Pedersen
cb89695c1d PS: Improve alert message. 2025-06-20 20:40:53 +01:00
Mathias Vorreiter Pedersen
9032d863bd PS: Accept test changes. 2025-06-20 16:40:44 +01:00
Mathias Vorreiter Pedersen
1486200146 PS: Allow for implicit reads at sinks in 'ps/sql-injection'. 2025-06-20 16:34:16 +01:00
Mathias Vorreiter Pedersen
1ff04d9f94 PS: Add new false negative. 2025-06-20 16:30:49 +01:00
Mathias Vorreiter Pedersen
72178f0a36 PS: Accept test changes. 2025-06-20 14:54:39 +01:00
Mathias Vorreiter Pedersen
05a7cfd264 PS: Don't implicitly read any element. Instead, only read positional contents. 2025-06-20 14:54:15 +01:00
Mathias Vorreiter Pedersen
25d94fabcc PS: Add false positive to 'ps/sql-injection'. 2025-06-20 14:51:17 +01:00
Mathias Vorreiter Pedersen
0912cc337f PS: Accept test changes. 2025-06-20 14:25:58 +01:00
Mathias Vorreiter Pedersen
c18db919c9 PS: Model 'inputfile' as a sink for SQL injections. 2025-06-20 14:25:45 +01:00
Mathias Vorreiter Pedersen
b82bd2cd2f PS: Add false positive to 'ps/sql-injection'. 2025-06-20 14:23:55 +01:00
Mathias Vorreiter Pedersen
86cc09b622 PS: Start with a SCAN of 'getProcessBlock' as this ensures we start with a small pipeline. 2025-06-19 22:11:26 +01:00
Mathias Vorreiter Pedersen
31fbb6fd55 PS: Prevent bad magic by calling a HOP to compute the transitive closure. 2025-06-19 22:11:25 +01:00
Mathias Vorreiter Pedersen
2d045ea345 PS: Prevent join on integer. 2025-06-19 22:11:24 +01:00
Mathias Vorreiter Pedersen
c50b0c6323 PS: Prevent join on boolean. 2025-06-19 22:11:22 +01:00
Mathias Vorreiter Pedersen
a38d57f080 PS: Fix cartesian product. 2025-06-19 22:11:20 +01:00
Mathias Vorreiter Pedersen
f513259f24 PS: Format, add a helper predicate and add an explicit 'this' to silence a warning. 2025-06-19 22:11:19 +01:00
Mathias Vorreiter Pedersen
9be1f2d1d1 PS: Replace another 'forex' with explicit recursion. 2025-06-19 22:11:17 +01:00
Mathias Vorreiter Pedersen
8664842f91 PS: Remove two more 'forex's. 2025-06-19 22:11:16 +01:00
Mathias Vorreiter Pedersen
b79f3666a9 PS: Replace a 'forex' with explicit recursion. 2025-06-19 22:11:14 +01:00
Mathias Vorreiter Pedersen
ebc167c529 PS: Fix join in 'count'. 2025-06-19 22:11:13 +01:00
Mathias Vorreiter Pedersen
ae83d56df1 PS: Rename predicate. 2025-06-19 22:11:00 +01:00
Mathias Vorreiter Pedersen
f69cfdcd5a PS: Autoformat. 2025-06-19 22:03:40 +01:00
Mathias Vorreiter Pedersen
9ed32b14a2 PS: Add some QLDoc. 2025-06-19 22:02:45 +01:00
Mathias Vorreiter Pedersen
3ba3b11207 PS: Prevent magic on 'getParent'. 2025-06-19 22:02:22 +01:00
Mathias Vorreiter Pedersen
56977c76f8 Merge pull request #247 from microsoft/add-get-callee-on-call-nodes
PS: Add `Node.getCallee` predicate on `DataFlow::CallNode`
2025-06-16 15:48:41 +01:00
Mathias Vorreiter Pedersen
229914f7f3 PS: Add 'Node.getCallee' predicate on DataFlow::CallNode. 2025-06-16 15:24:26 +01:00
Chanel Young
f882af95d8 update to invokesink 2025-06-12 14:30:46 -07:00
dilanbhalla
8e09d96df5 Merge pull request #240 from microsoft/auto/sync-main-pr
Sync Main (autogenerated)
2025-06-12 11:07:49 -07:00
dilanbhalla
dae058250b Merge branch 'main' into auto/sync-main-pr 2025-06-12 10:55:48 -07:00
dilanbhalla
ed8cc6afff Merge pull request #245 from microsoft/fix-extensional-warnings-powershell
PS: Remove unnecessary data extension pattern to fix warning
2025-06-12 10:55:36 -07:00
Mathias Vorreiter Pedersen
b88ed68499 PS: Remove unnecessary data extension pattern. All the models are matched by the other two patterns. 2025-06-12 11:41:25 +01:00
dilanbhalla
7bfefefbf7 Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Compatible with the latest released version of the CodeQL CLI
2025-06-11 17:00:14 +00:00
dilanbhalla
b8a78f79eb Merge branch 'main' of https://github.com/microsoft/codeql into auto/sync-main-pr 2025-06-10 18:59:32 +00:00
dilanbhalla
64bc3ed473 Merge pull request #244 from microsoft/lwsimpkins/fix-qhelp
fix failing qhelp files
2025-06-10 11:02:12 -07:00
Lindsay Simpkins
7668175804 Merge branch 'main' into lwsimpkins/fix-qhelp 2025-06-09 17:56:59 -04:00
dilanbhalla
9521d06424 Merge branch 'main' of https://github.com/microsoft/codeql into auto/sync-main-pr 2025-06-09 19:59:12 +00:00
Lindsay Simpkins
077549da16 fix failing qhelp files 2025-06-09 15:31:19 -04:00
dilanbhalla
3d84e5ac3b Merge pull request #243 from microsoft/lwsimpkins/fix-qhelp
fix powershell qhelp files
2025-06-09 12:06:45 -07:00
Lindsay Simpkins
25fb1aabd2 fix powershell qhelp files 2025-06-09 14:01:54 -04:00
dilanbhalla
58acb60b47 Merge branch 'main' of https://github.com/microsoft/codeql into auto/sync-main-pr 2025-06-03 19:32:15 +00:00
dilanbhalla
06448780ed Merge pull request #242 from microsoft/powershell-guardpredicate-fix
added hasbranchedge
2025-06-03 12:31:26 -07:00
Chanel Young
0d11efc5cb added hasbranchedge 2025-06-03 11:53:29 -07:00
dilanbhalla
464558688d Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Compatible with the latest released version of the CodeQL CLI
2025-06-02 22:04:24 +00:00
Chanel
8ef818cd8d Merge pull request #239 from microsoft/dilan/sync-main-auth-2
Sync Main: Auth Bug (fix attempt 2)
2025-06-02 15:03:25 -07:00
dilanbhalla
8aa10995ba Update sync-main.yml 2025-06-02 14:40:39 -07:00
dilanbhalla
126ddf9271 Merge pull request #238 from microsoft/dilan/sync-repo-auth
Auth Bug: Sync Main
2025-06-02 10:31:30 -07:00
dilanbhalla
8ef8210327 Update sync-main.yml 2025-06-02 10:26:22 -07:00
Mathias Vorreiter Pedersen
10a886325d Merge pull request #237 from microsoft/fix-fps-in-tainted-path
C#: Fix FPs (and a small FN) in `cs/path-injection`
2025-05-30 14:51:01 +01:00
Mathias Vorreiter Pedersen
2186fef8bf C#: Accept test changes. 2025-05-27 18:44:59 +01:00
Mathias Vorreiter Pedersen
4dfa88626a C#: Recognize more path-normalization steps. 2025-05-27 18:44:57 +01:00
Mathias Vorreiter Pedersen
db7119c29f C#: Add a false positive. 2025-05-27 18:44:56 +01:00
Mathias Vorreiter Pedersen
a2d4c20068 C#: Fix FN by blocking flow out of the function call instead of out of the argument (which is incorrect when there is use-use flow). 2025-05-27 18:44:54 +01:00
Mathias Vorreiter Pedersen
03e671aff1 C#: Add a false negative. 2025-05-27 18:44:53 +01:00
Mathias Vorreiter Pedersen
b40a43701c C#: Small optimization. Avoid a small CP between sinks and states. 2025-05-27 18:44:51 +01:00
Mathias Vorreiter Pedersen
0e887d8697 Merge pull request #235 from microsoft/update-typegen-2
PS: Restructure generated files
2025-05-21 17:43:10 +01:00
Chanel
a17f10d4a9 Merge branch 'main' into update-typegen-2 2025-05-21 09:27:44 -07:00
Mathias Vorreiter Pedersen
a410e85d85 PS: Accept test changes. 2025-05-21 16:35:07 +01:00
Mathias Vorreiter Pedersen
8875962f9b PS: Fix pack name in data extension files. 2025-05-21 16:35:06 +01:00
Mathias Vorreiter Pedersen
b409cbddf1 PS: Add back the manual models. 2025-05-21 16:35:01 +01:00
Mathias Vorreiter Pedersen
1a7908cd57 PS: Add generated models for .NET runtime. 2025-05-21 16:35:00 +01:00
Mathias Vorreiter Pedersen
61021b6d6f PS: Regenerate models. 2025-05-21 16:34:47 +01:00
Mathias Vorreiter Pedersen
2f0b064ee2 Merge pull request #234 from microsoft/share-global-cfg-library
C++/C#/Shared: Convert the global control-flow library to a shared parameterize module and make it available in C#
2025-05-19 19:24:14 +01:00
Mathias Vorreiter Pedersen
f00c370204 C#: Instantiate the (now shared) global control-flow library. 2025-05-19 19:04:20 +01:00
Mathias Vorreiter Pedersen
7cc091912f C++/Shared: Convert the global control-flow library to a shared parameterized module. 2025-05-19 19:03:59 +01:00
Mathias Vorreiter Pedersen
198a594b7a Merge pull request #149 from microsoft/interprocedural-controlflow
C++: Add an interprocedural control-flow library
2025-05-19 15:52:17 +01:00
Mathias Vorreiter Pedersen
bac9c7d30d Merge branch 'main' into interprocedural-controlflow 2025-05-19 15:30:24 +01:00
Mathias Vorreiter Pedersen
c3b0c2d924 PS: Update typegen script and documentation. 2025-05-16 12:08:54 +01:00
dilanbhalla
60ca4964ad Merge pull request #233 from microsoft/dilan/powershell-dotnet-publish-flags
PowerShell: .NET Publish Flags
2025-05-15 12:26:02 -07:00
dilanbhalla
5127ace92c Update build-win64.ps1 2025-05-15 12:18:19 -07:00
dilanbhalla
77e6056665 Update build-osx64.ps1 2025-05-15 12:18:07 -07:00
dilanbhalla
50622e529e Update build-linux64.ps1 2025-05-15 12:16:53 -07:00
dilanbhalla
dd965dd646 Merge pull request #232 from microsoft/dilan/powershell-osx-specific-buildscripts
PowerShell: OS-specific buildscripts
2025-05-15 12:07:22 -07:00
dilanbhalla
0d38a98bad Update powershell-pr-check.yml 2025-05-15 12:00:45 -07:00
dilanbhalla
e250f9b6ce Create build-linux64.ps1 2025-05-15 11:59:37 -07:00
dilanbhalla
0fab231c33 Update build-win64.ps1 2025-05-15 11:58:26 -07:00
dilanbhalla
c632477eb3 Create build-osx64.ps1 2025-05-15 11:57:58 -07:00
dilanbhalla
5be20a0d10 Rename build.ps1 to build-win64.ps1 2025-05-15 11:52:25 -07:00
dilanbhalla
d1c2fa0266 Merge pull request #230 from microsoft/auto/sync-main-pr
Sync Main (autogenerated)
2025-05-15 10:50:21 -07:00
Dilan Bhalla
ae515a4b5f Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Compatible with the latest released version of the CodeQL CLI
2025-05-15 10:20:16 -07:00
dilanbhalla
2ef6dd9cbc Merge pull request #225 from microsoft/cleanup-upgrade-downgrade-story-2
PS: Cleanup upgrade/downgrade chains
2025-05-14 10:50:34 -07:00
Mathias Vorreiter Pedersen
2bf076df49 PS: Also include the downgrade scripts when building the PowerShell extractor and injecting it into the CLI. 2025-05-13 18:58:26 +01:00
Mathias Vorreiter Pedersen
07d723291b PS: Add a single upgrade script that upgrades the old dbscheme to the current dbscheme, and add a single downgrade script that downgrades the current dbscheme to the old dbscheme. IMPORTANT: the .gitattributes ensure that we keep CLRF (i.e., windows) line-endings on the old dbscheme scripts so that they match what is produced by the extractor. 2025-05-13 18:50:13 +01:00
Mathias Vorreiter Pedersen
a489bfd125 PS: Delete all the existing upgrade and downgrade scripts. 2025-05-13 18:46:45 +01:00
Denis Levin
a1bfbb37e7 Two more modules and an update to some cached refs for GO (#224)
Co-authored-by: Denis Levin <denisl@microsoft.com>
2025-05-08 11:59:28 -07:00
Josh Brown
c87545ee12 Merge pull request #223 from microsoft/denisl/afewmissedCGChanges
Looks like I've missed a few CG changes - checking in
2025-05-07 19:19:53 -07:00
Denis Levin
526f161e97 Merge branch 'main' into denisl/afewmissedCGChanges 2025-05-07 16:40:32 -07:00
Denis Levin
b87431ac35 Looks like I've missed a few CG changes - checking in 2025-05-07 14:53:37 -07:00
dilanbhalla
c31abb7f0f Merge pull request #222 from microsoft/revert-218-update-csharp-stub-models
Revert "Update the C# stub models"
2025-05-02 16:23:19 -07:00
dilanbhalla
0ec0f5ce35 Revert "Update the C# stub models" 2025-05-02 14:44:25 -07:00
dilanbhalla
0d7e5faa0e Merge pull request #219 from microsoft/ps-run-tests-on-prs
PS: Run tests on PRs
2025-05-02 12:10:16 -07:00
dilanbhalla
e70d9ff4ca Merge branch 'main' into ps-run-tests-on-prs 2025-05-02 10:56:01 -07:00
dilanbhalla
d76de83121 Merge pull request #218 from microsoft/update-csharp-stub-models
Update the C# stub models
2025-05-01 14:35:21 -07:00
Sid Gawri
43ab8cb98e Merge branch 'main' of https://github.com/microsoft/codeql into update-csharp-stub-models 2025-05-01 17:31:54 -04:00
Josh Brown
f0e0d76ca6 Merge pull request #220 from microsoft/auto/sync-main-pr
Sync Main (autogenerated)
2025-05-01 11:07:26 -07:00
dilanbhalla
63884ff714 Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Compatible with the latest released version of the CodeQL CLI
2025-05-01 13:06:40 +00:00
Mathias Vorreiter Pedersen
3dc74e9fdb PS: Harden the build script so that you can run it from any folder. 2025-05-01 12:36:11 +01:00
Mathias Vorreiter Pedersen
337cb8b308 PS: Make it possible to run the build script from a command prompt that is running from %SYSTEMROOT%. See https://learn.microsoft.com/en-us/answers/questions/574694/msbuild-error-msb1009-project-file-does-not-exist 2025-05-01 12:31:11 +01:00
Mathias Vorreiter Pedersen
3cca0a6ec0 Update powershell-pr-check.yml 2025-05-01 12:25:04 +01:00
Mathias Vorreiter Pedersen
f029d2a494 Update powershell-pr-check.yml 2025-05-01 12:21:18 +01:00
Mathias Vorreiter Pedersen
3bea9e5693 Update powershell-pr-check.yml 2025-05-01 12:18:59 +01:00
Mathias Vorreiter Pedersen
7c37c54b03 Update powershell-pr-check.yml 2025-05-01 12:07:59 +01:00
Mathias Vorreiter Pedersen
1724948f75 Update powershell-pr-check.yml 2025-05-01 12:06:01 +01:00
Mathias Vorreiter Pedersen
3b2057b148 Update powershell-pr-check.yml 2025-05-01 12:01:06 +01:00
Mathias Vorreiter Pedersen
d6c6015558 PS: Run tests on PRs 2025-05-01 11:58:55 +01:00
Sid Gawri
d824bdf8d2 system.web + system.net 2025-04-30 18:37:42 -04:00
Mathias Vorreiter Pedersen
f7d081874b Merge pull request #217 from microsoft/accept-parent-test-changes
PS: Accept missing test changes
2025-04-30 20:25:05 +01:00
Mathias Vorreiter Pedersen
2f03911b45 PS: Accept test changes. 2025-04-30 20:20:07 +01:00
Chanel
f6aec284d1 Merge pull request #216 from microsoft/ps-string-literals
PS: Lift string literals to the public AST
2025-04-30 10:09:38 -07:00
Mathias Vorreiter Pedersen
dbfd07024d PS: Add some tests for string literals. 2025-04-30 13:46:43 +01:00
Mathias Vorreiter Pedersen
a7c0305430 PS: Lift StringLiterals to the public AST from the raw AST. 2025-04-30 13:46:32 +01:00
Chanel
64dd13d4eb Merge pull request #215 from microsoft/ps-add-sql-injection-query
PS: Add SQL injection query
2025-04-29 10:31:55 -07:00
Mathias Vorreiter Pedersen
c6678949b9 PS: Add query test for the new SQL injection query. 2025-04-29 17:57:59 +01:00
Mathias Vorreiter Pedersen
e4d5b1e65e PS: Add a query for SQL injection. 2025-04-29 17:57:43 +01:00
Mathias Vorreiter Pedersen
c015c746b8 PS: Lower case more predicate results for consistency. 2025-04-29 17:45:04 +01:00
Denis Levin
aee5b23207 Merge pull request #212 from microsoft/denisl/goreferenceupdate
Update go references in mod and sum files
2025-04-28 16:26:21 -07:00
Josh Brown
b672950baf Merge branch 'main' into denisl/goreferenceupdate 2025-04-25 09:14:05 +10:00
Mathias Vorreiter Pedersen
4d00aa39ea Merge pull request #213 from microsoft/powershell-better-api-for-normalizednames
PS: Better API for normalizing names + get rid of warnings
2025-04-24 12:09:24 +01:00
Chanel
1930059e77 Merge pull request #214 from microsoft/dilan/powershell-lib-pack-org
PowerShell Lib Pack: Change microsoft-sdl to microsoft
2025-04-23 11:24:22 -07:00
Dilan Bhalla
084c75c8cf changing microsoft-sdl/powershell-all to microsoft/powershell-all 2025-04-23 10:45:45 -07:00
dilanbhalla
c3926d3cba Update qlpack.yml 2025-04-23 10:26:27 -07:00
dilanbhalla
a3b32af3dc Update qlpack.yml 2025-04-23 10:25:20 -07:00
Chanel
b1cd6721e0 Merge branch 'main' into powershell-better-api-for-normalizednames 2025-04-23 09:52:53 -07:00
Mathias Vorreiter Pedersen
0a1f89b8eb PS: Delete more stuff that's being deprecated and replace with non-deprecated versions. 2025-04-23 16:00:20 +01:00
Mathias Vorreiter Pedersen
06fd1c6513 PS: Delete deprecated unnecessary predicates. 2025-04-23 16:00:19 +01:00
Mathias Vorreiter Pedersen
5ec59c3b34 PS: Get rid of unnecessary module. 2025-04-23 16:00:18 +01:00
Mathias Vorreiter Pedersen
9e83dee8fe PS: Accept test changes. 2025-04-23 15:16:29 +01:00
Mathias Vorreiter Pedersen
f5e7af1df6 PS: Fix tests. 2025-04-23 15:16:26 +01:00
Mathias Vorreiter Pedersen
b65d41b498 PS: Cleanup and autoformat. 2025-04-23 12:36:48 +01:00
Mathias Vorreiter Pedersen
2e0560119c PS: Add matchesName and getAName to make it easier to match case insensitively. 2025-04-23 12:34:08 +01:00
Mathias Vorreiter Pedersen
7360d800f2 PS: Rename getName to getLowerCaseName. 2025-04-23 12:31:46 +01:00
Denis Levin
42776fb2fe Merge branch 'main' into denisl/goreferenceupdate 2025-04-22 16:49:28 -07:00
dilanbhalla
2f62351116 Merge pull request #211 from microsoft/dilan/publish-pack-bug-2
Pack Publish Bug
2025-04-22 16:12:19 -07:00
dilanbhalla
ba58c012cd Update microsoft-codeql-pack-publish.yml 2025-04-22 15:48:09 -07:00
Chanel
e669dc651b Merge pull request #210 from microsoft/dilan/pack-publish-typo
Pack Publish Typo
2025-04-22 15:33:16 -07:00
dilanbhalla
9efbecc677 Update microsoft-codeql-pack-publish.yml 2025-04-22 15:30:11 -07:00
Denis Levin
47fc9f2d10 Update go language references in mod and sum files to prevent vulnerable reference warining for CVE-2024-45337
in golang.org/x/crypto
2025-04-22 15:10:47 -07:00
Chanel
3126366768 Merge pull request #170 from microsoft/dilan/publish-opensource-packs
Publish Public Packs
2025-04-22 12:49:30 -07:00
dilanbhalla
b1129475d7 Merge branch 'main' into dilan/publish-opensource-packs 2025-04-22 12:46:24 -07:00
dilanbhalla
a3c5e48738 Update microsoft-codeql-pack-publish.yml 2025-04-22 12:45:26 -07:00
dilanbhalla
082141e40d Update microsoft-codeql-pack-publish.yml 2025-04-22 12:28:37 -07:00
dilanbhalla
054434365c Merge pull request #209 from microsoft/dilan/workflow-bugs
Fix Sync-Main Workflow Bugs
2025-04-22 11:37:25 -07:00
dilanbhalla
358862e9bd Update sync-main.yml 2025-04-22 11:30:41 -07:00
dilanbhalla
916b264e1b Update sync-main-tags.yml 2025-04-22 11:29:32 -07:00
dilanbhalla
4b3c612833 Merge branch 'main' into dilan/publish-opensource-packs 2025-04-22 11:27:46 -07:00
dilanbhalla
d3c6c3bcc6 Merge pull request #208 from microsoft/auto/sync-main-pr
Sync Main (autogenerated)
2025-04-22 10:15:07 -07:00
dilanbhalla
b28b84fad6 Merge branch 'main' of https://github.com/microsoft/codeql into auto/sync-main-pr 2025-04-22 16:59:08 +00:00
Chanel
12db85ad9c Merge pull request #206 from microsoft/psscriptanalyzer-port
Psscriptanalyzer port
2025-04-22 09:35:05 -07:00
Chanel Young
f375b81272 remove reference to command injection owasp 2025-04-22 09:26:48 -07:00
Chanel
3a66e8e71a Update powershell/ql/src/experimental/UsernameOrPasswordParameter.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-04-22 09:20:45 -07:00
Chanel
f82cfc7bd4 Update powershell/ql/src/experimental/UsernameOrPasswordParameter.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-04-22 09:20:31 -07:00
Chanel
6419794f3b Update powershell/ql/src/experimental/HardcodedComputerName.qhelp
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-04-22 09:18:31 -07:00
Chanel Young
faa47f9bfb ConvertToSecureStringAsPlainText 2025-04-22 09:17:57 -07:00
Chanel Young
2898910c04 Merge branch 'psscriptanalyzer-port' of https://github.com/microsoft/codeql into psscriptanalyzer-port 2025-04-22 09:12:04 -07:00
Chanel Young
7432884af0 Merge branch 'main' into psscriptanalyzer-port 2025-04-22 09:00:08 -07:00
dilanbhalla
9f44cb23f1 Merge branch 'main' of https://github.com/microsoft/codeql into auto/sync-main-pr 2025-04-22 15:59:07 +00:00
Mathias Vorreiter Pedersen
bfb7b0b9d0 Merge branch 'main' into psscriptanalyzer-port 2025-04-22 16:42:23 +01:00
Mathias Vorreiter Pedersen
6a5d0877c4 Merge pull request #207 from microsoft/switch-parameters
PS: Proper AST support for switch arguments
2025-04-22 16:41:40 +01:00
Chanel
a98a7b8e97 Merge branch 'main' into switch-parameters 2025-04-22 08:13:25 -07:00
dilanbhalla
ff154b11d0 Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Compatible with the latest released version of the CodeQL CLI
2025-04-22 14:59:21 +00:00
Mathias Vorreiter Pedersen
09ebc76a23 PS: Accept test changes. 2025-04-22 15:32:35 +01:00
Mathias Vorreiter Pedersen
e9fd50b67c PS: Handle switch arguments by synthesizing a boolean true literal and represent them as named arguments. 2025-04-22 15:28:43 +01:00
Mathias Vorreiter Pedersen
72266cb000 PS: Drive-by cleanup in Constant.qll 2025-04-22 15:12:14 +01:00
Mathias Vorreiter Pedersen
b9fdc78c16 PS: Add argument tests. 2025-04-22 15:12:00 +01:00
Chanel Young
43954b7262 removed irrelevant tags 2025-04-21 17:01:12 -07:00
Chanel Young
e91912e30d cleanup 2025-04-21 16:50:36 -07:00
Chanel Young
7359f912c5 added initial psscriptanalyzer rules, docs, tests 2025-04-21 16:44:52 -07:00
dilanbhalla
7462e4003f Merge pull request #204 from microsoft/dilan/sync-main-tags
Sync Upstream Tags
2025-04-21 14:55:28 -07:00
dilanbhalla
7e32709574 Merge branch 'main' into dilan/sync-main-tags 2025-04-21 14:54:14 -07:00
dilanbhalla
2007479e56 Merge pull request #205 from microsoft/LWSimpkins/rust-module-import-fix
Update DataFlowImpl.qll
2025-04-21 14:07:10 -07:00
Lindsay Simpkins
57f060beed Update DataFlowImpl.qll 2025-04-21 16:41:36 -04:00
Dilan Bhalla
7553e14873 sync upstream tags to main 2025-04-21 12:21:23 -07:00
Chanel
03bce1c59f Merge pull request #202 from microsoft/fix-to-string-on-unknown-static-read
PS: Fix `toString` on unknown static field access
2025-04-18 09:23:02 -07:00
Chanel
37a6b0460e Merge branch 'main' into fix-to-string-on-unknown-static-read 2025-04-18 09:21:15 -07:00
Mathias Vorreiter Pedersen
21210c6cb3 Merge pull request #203 from microsoft/add-missing-downgrade-and-upgrade-scripts
PS: Add missing downgrade and upgrade scripts
2025-04-18 13:34:18 +01:00
Mathias Vorreiter Pedersen
4518f18b9f PS: Delete a cycle in the upgrade script. 2025-04-18 12:41:13 +01:00
Mathias Vorreiter Pedersen
e7e88d3946 PS: Add upgrade script from some unknown dbscheme to the dbscheme that existed when Mathias joined Microsoft 2025-04-18 12:40:58 +01:00
Chanel
fe7d8ff61f Merge pull request #201 from microsoft/powershell-injectionhunter-port
Powershell Command Injection query updates
2025-04-17 11:03:19 -07:00
Chanel Young
12b918e900 pr feedback: removed toString, updated .expected 2025-04-17 10:39:42 -07:00
Mathias Vorreiter Pedersen
b70f7e219c PS: Fix missing toString and accept test changes. 2025-04-17 17:01:33 +01:00
Mathias Vorreiter Pedersen
7d7268349d PS: Add an example with a missing toString. 2025-04-17 16:53:26 +01:00
Mathias Vorreiter Pedersen
b09d9f6772 PS: Autoformat. 2025-04-17 16:49:47 +01:00
Chanel Young
ed553d393b merged work into CommandInjection query 2025-04-16 14:32:30 -07:00
Chanel Young
2266cd2eb8 moved folder, added tests/docs 2025-04-16 12:13:07 -07:00
Chanel Young
50a771edee Merge branch 'main' into powershell-injectionhunter-port 2025-04-16 11:19:26 -07:00
Chanel Young
5f643509f0 added script block, expandstring sinks, moved sanitizers to separate file 2025-04-16 11:18:02 -07:00
Chanel
c9b1356853 Merge pull request #200 from microsoft/files-reads-as-flow-sources
PS: Handle more flow sources
2025-04-16 10:03:44 -07:00
Mathias Vorreiter Pedersen
396a283da9 PS: Add tests for flow sources. 2025-04-15 22:43:21 +01:00
Mathias Vorreiter Pedersen
826e6a9ee8 PS: Add an inline expectations test library for flow sources. 2025-04-15 22:43:19 +01:00
Mathias Vorreiter Pedersen
dcc127832e PS: Make remote flow sources flow sources. 2025-04-15 22:43:18 +01:00
Mathias Vorreiter Pedersen
fa3fc4a0c3 PS: Fix more problems in MaD rows for sources. 2025-04-15 22:43:16 +01:00
Mathias Vorreiter Pedersen
a146630a09 PS: Delete redundant files. 2025-04-15 22:43:14 +01:00
Mathias Vorreiter Pedersen
43d9c701f8 PS: Rename Field and Property to Member. 2025-04-15 22:43:03 +01:00
Mathias Vorreiter Pedersen
f38948764c PS: Make type names lower case. 2025-04-15 22:36:31 +01:00
Mathias Vorreiter Pedersen
993511735a PS: Make method names lower case. 2025-04-15 22:02:46 +01:00
Chanel Young
b4d8673a38 Merge branch 'main' of https://github.com/microsoft/codeql into powershell-injectionhunter-port 2025-04-14 15:18:37 -07:00
Mathias Vorreiter Pedersen
6455992402 PS: Add two more flow sources. 2025-04-10 20:44:11 +01:00
Mathias Vorreiter Pedersen
3d18175885 PS: Make it possible to specify a named argument that must be present in MaD. 2025-04-10 20:42:50 +01:00
Mathias Vorreiter Pedersen
43de3a131b PS: Use the existing MaD rows to model file reads as flow sources. 2025-04-10 20:25:17 +01:00
Chanel
1637df0a3f Merge pull request #199 from microsoft/fix-top-level-arguments
PS: Fix a couple of missing local flow sources
2025-04-10 11:18:31 -07:00
Mathias Vorreiter Pedersen
4aa9f85b5d PS: Accept test changes. 2025-04-10 19:02:54 +01:00
Mathias Vorreiter Pedersen
9adf028d41 PS: Fix environment variables. 2025-04-10 19:02:07 +01:00
Mathias Vorreiter Pedersen
bf9ed3bcb7 PS: Accept test changes. 2025-04-10 18:52:27 +01:00
Mathias Vorreiter Pedersen
6084789f09 PS: Fix the top level arguments after the AST cleanup. 2025-04-10 18:50:06 +01:00
Mathias Vorreiter Pedersen
793fd5eb7e PS: Delete a redundant file. 2025-04-10 18:49:45 +01:00
dilanbhalla
5abde74f0c Merge pull request #198 from microsoft/dilan/sync-main-bugs-7
Sync Main Error Handling Improvement
2025-04-10 10:34:55 -07:00
dilanbhalla
4628c187bd Update sync-main.yml 2025-04-10 10:26:00 -07:00
Chanel
419de4fd22 Merge pull request #196 from microsoft/autogenerate-lots-of-models
PS: Add autogenerated summary models
2025-04-09 11:16:36 -07:00
Mathias Vorreiter Pedersen
b55ee68a99 Merge branch 'main' into autogenerate-lots-of-models 2025-04-09 11:12:09 -07:00
dilanbhalla
89ddb30a96 Merge pull request #197 from microsoft/auto/sync-main-pr
Sync Main (autogenerated)
2025-04-09 10:46:13 -07:00
dilanbhalla
0f034b32e0 Merge pull request #194 from microsoft/dilan/sync-main-bugs-6
Sync Main: More Misc Bugs
2025-04-09 10:46:07 -07:00
dilanbhalla
c5b024a9dd Update sync-main.yml 2025-04-09 10:26:10 -07:00
dilanbhalla
b8b4e44e81 Update sync-main.yml 2025-04-09 10:24:00 -07:00
dilanbhalla
86b3eaeb64 Merge branch 'main' into dilan/sync-main-bugs-6 2025-04-09 10:18:16 -07:00
dilanbhalla
0d97cd6be6 Merge branch 'main' of https://github.com/microsoft/codeql into auto/sync-main-pr 2025-04-09 17:17:29 +00:00
dilanbhalla
88a7c3a63d Update sync-main.yml 2025-04-09 10:16:42 -07:00
dilanbhalla
e7edf1bab9 Update sync-main.yml 2025-04-09 10:13:45 -07:00
dilanbhalla
a93d65b2d1 Update sync-main.yml 2025-04-09 10:11:23 -07:00
Mathias Vorreiter Pedersen
f8207fa92a PS: Add a testcase to demonstrate flow through Join-String. 2025-04-09 15:20:41 +01:00
Mathias Vorreiter Pedersen
ebb91dceb7 PS: Add a few more models after fixing MaD for Element content. 2025-04-09 15:20:39 +01:00
Mathias Vorreiter Pedersen
6de4765fe6 PS: Support implicit imports in API graphs. 2025-04-09 15:20:38 +01:00
Mathias Vorreiter Pedersen
a5afc3c582 PS: Flow through pipelines. 2025-04-09 15:20:36 +01:00
Mathias Vorreiter Pedersen
5f12d7c970 PS: Taint flow through all calls to 'toString'. 2025-04-09 15:20:35 +01:00
Mathias Vorreiter Pedersen
763effb50d PS: Add more models and support pipeline parameters in MaD. 2025-04-09 15:20:33 +01:00
Mathias Vorreiter Pedersen
f38c5f5b4f PS: Add lots of models. 2025-04-09 15:20:32 +01:00
Mathias Vorreiter Pedersen
02c027d9f6 Merge pull request #183 from microsoft/hashcons-for-csharp
C#: Add a hash-cons library for C#
2025-04-09 04:21:50 -07:00
Mathias Vorreiter Pedersen
7612ef922f Merge pull request #186 from microsoft/powershell-automatic-variables-as-member-edges
PS: Fix more Chanel-reported PowerShell issues
2025-04-09 04:21:38 -07:00
dilanbhalla
79909e93a2 Update sync-main.yml 2025-04-08 16:34:50 -07:00
dilanbhalla
70f9401ba2 Update sync-main.yml 2025-04-08 16:31:56 -07:00
github-actions[bot]
1e24627de3 Merge tag 'codeql-cli/latest' into auto/sync-main-pr
Compatible with the latest released version of the CodeQL CLI
2025-04-08 23:27:08 +00:00
dilanbhalla
a7dcc9fa6f Update sync-main.yml 2025-04-08 16:26:10 -07:00
dilanbhalla
3d57ea9d8c Update sync-main.yml 2025-04-08 16:22:18 -07:00
dilanbhalla
98338fe6c8 Update sync-main.yml 2025-04-08 16:16:34 -07:00
dilanbhalla
2a8c8dbdb7 Update sync-main.yml 2025-04-08 16:12:47 -07:00
dilanbhalla
d2eadbffad Update sync-main.yml 2025-04-08 16:07:41 -07:00
dilanbhalla
87d55921c6 Update sync-main.yml 2025-04-08 16:01:38 -07:00
dilanbhalla
9f2b3eb95e Update sync-main.yml 2025-04-08 15:53:16 -07:00
dilanbhalla
826d43da88 Update sync-main.yml 2025-04-08 15:50:41 -07:00
dilanbhalla
544f0ca81d Update sync-main.yml 2025-04-08 15:43:31 -07:00
dilanbhalla
7a168b0d5c Update sync-main.yml 2025-04-08 15:37:42 -07:00
dilanbhalla
be4f1f1482 Update sync-main.yml 2025-04-08 15:34:53 -07:00
dilanbhalla
eb41d97d48 Update sync-main.yml 2025-04-08 15:28:59 -07:00
dilanbhalla
9bbffb6fd8 Update sync-main.yml 2025-04-08 15:09:55 -07:00
dilanbhalla
9a59b1c807 Update sync-main.yml 2025-04-08 14:57:47 -07:00
dilanbhalla
d92e61eeff Update sync-main.yml 2025-04-08 14:47:57 -07:00
dilanbhalla
3a630ad276 Update sync-main.yml 2025-04-08 14:22:13 -07:00
dilanbhalla
7259356af1 Update sync-main.yml 2025-04-08 14:21:33 -07:00
dilanbhalla
71ccc9675a Update sync-main.yml 2025-04-08 14:05:42 -07:00
dilanbhalla
bc8220f76b Update sync-main.yml 2025-04-08 13:21:17 -07:00
dilanbhalla
d384e41953 Update sync-main.yml 2025-04-08 12:49:03 -07:00
dilanbhalla
3324c30a71 Update sync-main.yml 2025-04-08 12:48:34 -07:00
dilanbhalla
9442bf39eb Update sync-main.yml 2025-04-08 12:47:13 -07:00
dilanbhalla
0d40476820 Update sync-main.yml 2025-04-08 12:28:52 -07:00
dilanbhalla
e2bac165fe Update sync-main.yml 2025-04-08 11:58:41 -07:00
dilanbhalla
ed31f43cfd Update sync-main.yml 2025-04-08 11:51:21 -07:00
dilanbhalla
d81989f345 Update sync-main.yml 2025-04-08 11:48:02 -07:00
dilanbhalla
75fb343e38 Update sync-main.yml 2025-04-08 11:41:29 -07:00
dilanbhalla
b6762463f7 Update sync-main.yml 2025-04-08 11:33:40 -07:00
dilanbhalla
dc9fdb596e Update sync-main.yml 2025-04-08 11:29:26 -07:00
dilanbhalla
c1665fdc0f Update sync-main.yml 2025-04-08 11:26:20 -07:00
dilanbhalla
db6d82c9b2 Update sync-main.yml 2025-04-08 11:17:22 -07:00
dilanbhalla
7e90d99c28 Update sync-main.yml 2025-04-08 11:14:08 -07:00
dilanbhalla
e098dd3d50 Merge pull request #193 from microsoft/dilan/sync-main-bugs-5
Sync Main: More Bugs (Failed PR Creation)
2025-04-08 10:26:50 -07:00
dilanbhalla
ae5709d894 Update sync-main.yml 2025-04-04 18:55:57 -07:00
dilanbhalla
41406d1b16 Merge pull request #192 from microsoft/dilan/sync-main-bugs-4
Sync Main: More Misc Bugs (token related bugs)
2025-04-04 15:58:20 -07:00
dilanbhalla
3c92f6b74d Update sync-main.yml 2025-04-04 15:41:21 -07:00
dilanbhalla
fb938abfd9 Merge pull request #191 from microsoft/dilan/sync-main-bugs-3
Sync Main: More Misc Token Bugs
2025-04-04 15:34:45 -07:00
dilanbhalla
e0a6a4edc6 Update sync-main.yml 2025-04-04 15:03:01 -07:00
dilanbhalla
52ceda1e40 Merge pull request #190 from microsoft/dilan/sync-main-bugs-2
Sync Main Various Bugs (permissions/tokens, git debugging, etc.)
2025-04-04 14:58:43 -07:00
dilanbhalla
856826019d Merge branch 'main' into dilan/sync-main-bugs-2 2025-04-04 14:55:31 -07:00
dilanbhalla
cda36a8550 Update sync-main.yml 2025-04-04 14:53:52 -07:00
dilanbhalla
13e53055a5 Merge pull request #189 from microsoft/dilan/sync-main-bugs-1
Sync Main Misc Git Bugs
2025-04-04 14:40:02 -07:00
dilanbhalla
157c57a3d4 Update sync-main.yml 2025-04-04 14:22:39 -07:00
dilanbhalla
452f56fa7f Merge pull request #188 from microsoft/dilan/sync-main-trigger
Adding push trigger to sync-main
2025-04-04 14:13:23 -07:00
dilanbhalla
3c4592591b Update sync-main.yml 2025-04-04 14:11:00 -07:00
dilanbhalla
6cbc80a69b Merge pull request #187 from microsoft/dilan/sync-main-createpr
Policy update: Sync-Main Create PR (instead of direct push)
2025-04-04 14:08:35 -07:00
dilanbhalla
2af55138da Update sync-main.yml 2025-04-04 14:00:05 -07:00
dilanbhalla
e0b8e20f9b Update sync-main.yml 2025-04-04 13:57:18 -07:00
dilanbhalla
6da7e4cb84 Update sync-main.yml 2025-04-04 13:53:14 -07:00
Chanel Young
6db354e82d Merge branch 'main' of https://github.com/microsoft/codeql into powershell-injectionhunter-port 2025-04-04 09:20:29 -07:00
Chanel Young
38f0f07d57 modeled some user input, sanitizers 2025-04-04 09:03:39 -07:00
Chanel
a2d4296329 Merge branch 'main' into powershell-automatic-variables-as-member-edges 2025-04-04 09:03:09 -07:00
Mathias Vorreiter Pedersen
8a58af8f84 PS: Add a model for 'EscapeSingleQuotedStringContent' and add a test. 2025-04-04 15:48:19 +01:00
Mathias Vorreiter Pedersen
65abf48ad6 PS: Add missing taint-flow and dataflow dispatch from models. 2025-04-04 15:40:35 +01:00
Mathias Vorreiter Pedersen
f482c9dba7 PS: Make the implementation of 'getExtraNodeFromType' more complete. This is still not good enough, but it's enough to get the flow we need for now. 2025-04-04 15:39:56 +01:00
Mathias Vorreiter Pedersen
03f356188b PS: Accept test changes. 2025-04-04 12:33:15 +01:00
Mathias Vorreiter Pedersen
cdd68b3951 PS: Improve the location of synthesized variables. 2025-04-04 12:33:13 +01:00
Mathias Vorreiter Pedersen
ebc732756f PS: Get rid of the pipelineVARIABLE and only have pipelinePARAMETER (and similarly for the by-propertyname versions). 2025-04-04 12:33:12 +01:00
Mathias Vorreiter Pedersen
16348b5484 PS: Consistently use the pipeline parameter as the parameter when it supplied in the program. 2025-04-04 12:33:11 +01:00
Josh Brown
c5c3236f99 Merge branch 'main' into hashcons-for-csharp 2025-04-04 07:30:49 +11:00
Mathias Vorreiter Pedersen
22bdcf0af2 PS: Force lower casing on method edges. 2025-04-03 20:33:04 +01:00
Mathias Vorreiter Pedersen
4df449d4b0 PS: Add an edge from the root node to automatic variables, and from a member read qualifier to a read. 2025-04-03 20:30:52 +01:00
Mathias Vorreiter Pedersen
4b14e5e7ec PS: Lift automatic variables to the cfg and dataflow layers. 2025-04-03 20:30:15 +01:00
Mathias Vorreiter Pedersen
50c57c2cb2 PS: Drive-by: Assign a location to top-level functions. 2025-04-03 20:29:44 +01:00
dilanbhalla
6873ebae16 Merge pull request #185 from microsoft/fix-ssa-for-powershell-2
PS: Fixup SSA after GitHub's 2.21.0 changes
2025-04-03 12:05:43 -07:00
Josh Brown
e261510528 Merge branch 'main' into hashcons-for-csharp 2025-04-04 05:52:23 +11:00
Mathias Vorreiter Pedersen
2f215c1e0f PS: Accept test changes. 2025-04-03 19:48:13 +01:00
Mathias Vorreiter Pedersen
403c182dc9 PS: Fixup SSA after GitHub's recent changes. 2025-04-03 19:48:06 +01:00
Chanel Young
22ff3a3e01 Merge branch 'main' of https://github.com/microsoft/codeql into powershell-injectionhunter-port 2025-04-03 11:24:31 -07:00
Chanel Young
656b734391 initial query 2025-04-03 11:23:49 -07:00
Chanel
7c59a748a8 Merge pull request #184 from microsoft/fix-parameter-by-name-flow-3
PS: Fix the last remaining missing flows after AST prettification
2025-04-03 11:20:23 -07:00
Mathias Vorreiter Pedersen
38536a9e38 PS: Accept test changes. 2025-04-03 18:46:12 +01:00
Mathias Vorreiter Pedersen
5151eb3b64 PS: Add dataflow for pipeline-by-property-name variables. 2025-04-03 18:46:11 +01:00
Mathias Vorreiter Pedersen
86ec291145 PS: Improve toString on phi nodes. 2025-04-03 18:46:10 +01:00
Mathias Vorreiter Pedersen
3acbd83297 PS: Drive-by fix: The variable access in a foreach loop implicitly writes to the variable. 2025-04-03 18:46:09 +01:00
Mathias Vorreiter Pedersen
4d04b11468 PS: Add some implicit reads at process blocks, and fix CFG for process blocks so that these reads appear in the CFG. 2025-04-03 18:46:08 +01:00
Mathias Vorreiter Pedersen
cd8e5e6d8d PS: Subclass AnyElement into positional or key-ional. 2025-04-03 18:46:06 +01:00
Mathias Vorreiter Pedersen
70ca6868aa C#: Make a few more modules private. 2025-04-03 18:18:46 +01:00
Mathias Vorreiter Pedersen
61259735fd C#: Add a hash-cons library for C#. 2025-04-03 18:13:01 +01:00
Chanel
b452339b23 Merge pull request #182 from microsoft/fix-parameter-by-name-flow-2
PS: Fix parameter/argument name mapping for named parameters
2025-04-01 11:29:01 -07:00
Mathias Vorreiter Pedersen
5fa3beb13d PS: Normalize parameter keywords and accept test changes. 2025-04-01 19:21:42 +01:00
Mathias Vorreiter Pedersen
1c380fb7fb PS: Add another missing flow found by Chanel. 2025-04-01 19:21:41 +01:00
Chanel
898297b542 Merge pull request #181 from microsoft/powershell-ast-modernization-follow-up
PS: Fix more taint-tracking/dataflow regressions
2025-04-01 09:46:48 -07:00
Mathias Vorreiter Pedersen
8ae92a5cdb PS: Accept test changes. 2025-04-01 15:08:36 +01:00
Mathias Vorreiter Pedersen
129b7876d7 PS: Allow shadowing of automatic variables. 2025-04-01 15:08:35 +01:00
Mathias Vorreiter Pedersen
08dc8183e0 PS: Add Chanel's missing flow example. 2025-04-01 15:08:33 +01:00
Mathias Vorreiter Pedersen
0b9720c908 PS: Accept test changes. 2025-03-31 20:12:51 +01:00
Mathias Vorreiter Pedersen
88f638dc5c PS: Fix more pipeline flow. 2025-03-31 20:12:43 +01:00
Mathias Vorreiter Pedersen
ee4104b78c PS: Fix parent-child mapping for iterator pipeline access synthesis. 2025-03-29 11:51:33 +00:00
Mathias Vorreiter Pedersen
a6a17344ff PS: Easier debugging with strings for child indices. 2025-03-29 11:18:23 +00:00
Mathias Vorreiter Pedersen
e17a169b8b Merge pull request #180 from microsoft/powershell-ast-modernization-follow-up
PS: Fix PowerShell dataflow/taint-tracking failures
2025-03-28 13:19:00 -07:00
Mathias Vorreiter Pedersen
7102ebbcf7 PS: Accept test changes. 2025-03-28 19:39:54 +00:00
Mathias Vorreiter Pedersen
3643b93033 fixup! PS: Define pre-return node and implicit-wrapping nodes using the script block instead of the individual elements. 2025-03-28 19:36:18 +00:00
Mathias Vorreiter Pedersen
5d5448df62 PS: Also use the new library to handle array expressions. 2025-03-28 19:36:06 +00:00
Mathias Vorreiter Pedersen
b2cf155ff5 PS: Define pre-return node and implicit-wrapping nodes using the script block instead of the individual elements. 2025-03-28 19:35:41 +00:00
Mathias Vorreiter Pedersen
ee8c586200 PS: Use the new library to calculate returned expressions. 2025-03-28 19:34:50 +00:00
Mathias Vorreiter Pedersen
a9861e13e9 PS: Add a library that calculated escaping values much more efficiently using the forward/reverse pruning technique. 2025-03-28 19:33:23 +00:00
Mathias Vorreiter Pedersen
f85767f47e PS: add a super class for all loop-related CFG nodes. 2025-03-28 19:32:36 +00:00
Mathias Vorreiter Pedersen
19454a50e9 PS: Small additions to the CFG classes and a small bugfix. 2025-03-28 19:32:07 +00:00
Mathias Vorreiter Pedersen
18d94f2078 PS: Don't include the variable in the IPA definition for variable accesses. 2025-03-28 19:31:15 +00:00
Mathias Vorreiter Pedersen
2da8da0777 PS: Add helper predicates for if statements. 2025-03-28 19:30:16 +00:00
Mathias Vorreiter Pedersen
ee0a21e67f PS: Make child mapping classes private. 2025-03-28 19:29:45 +00:00
Mathias Vorreiter Pedersen
7b9a41aa92 PS: Handle this parameters in a few more places. 2025-03-27 18:03:06 +00:00
Mathias Vorreiter Pedersen
dcb98ab5a1 PS: Don't include the this parameter in getParameter. 2025-03-27 18:01:28 +00:00
Mathias Vorreiter Pedersen
cea435cf1f Merge pull request #178 from microsoft/powershell-ipa-the-ast
PS: Simplify the AST in Powershell
2025-03-27 09:37:38 -07:00
Mathias Vorreiter Pedersen
0fc57789bf PS: Accept dataflow/taint-tracking/type-tracking regressions. 2025-03-27 16:01:42 +00:00
Mathias Vorreiter Pedersen
c840f86707 PS: Accept CFG test changes. 2025-03-27 16:01:41 +00:00
Mathias Vorreiter Pedersen
655d80ee7b PS: Repair tests and accept test changes in syntax tests. 2025-03-27 16:01:39 +00:00
Mathias Vorreiter Pedersen
7551cce537 PS: Make API graphs compile again. There is still some TODOs here, but at least it compiles. 2025-03-27 16:01:38 +00:00
Mathias Vorreiter Pedersen
8092345fee PS: Make type-tracking and taint-tracking compile again. 2025-03-27 16:01:36 +00:00
Mathias Vorreiter Pedersen
8f9bc1e4b2 PS: Make SSA compile again. 2025-03-27 16:01:35 +00:00
Mathias Vorreiter Pedersen
c2e24ea3a4 PS: Make CFG construction compile again. 2025-03-27 16:01:33 +00:00
Mathias Vorreiter Pedersen
9efc3ec380 PS: Make dataflow compile again. 2025-03-27 16:01:30 +00:00
Mathias Vorreiter Pedersen
cc13922206 PS: Make the experimental query compile again. 2025-03-27 16:01:28 +00:00
Mathias Vorreiter Pedersen
171f5ca698 PS: Inside a process block the name of a pipeline parameter actually refers to the individual elements in the pipeline. Add a synthesized variable access that represents this. 2025-03-27 16:01:26 +00:00
Mathias Vorreiter Pedersen
9f4d1c624d PS: PowerShell doesn't have a notion of true, false, null, etc. In the extracted AST these are just variables with special names. We insert synthesized AST elements that represent these special variables. 2025-03-27 16:01:24 +00:00
Mathias Vorreiter Pedersen
7adb020977 PS: Remove arguments that are just names for a named argument. 2025-03-27 16:01:23 +00:00
Mathias Vorreiter Pedersen
3bb6021cb2 PS: Remove the CmdExpr AST elements and synthesize StmtExpr instead where needed. 2025-03-27 16:01:21 +00:00
Mathias Vorreiter Pedersen
8eb5e65ac4 PS: Synthesize Function and Type classes instead of relying on the statement that defines them. 2025-03-27 16:01:20 +00:00
Mathias Vorreiter Pedersen
17661342f8 PS: expr-to-stmt conversions. 2025-03-27 16:01:18 +00:00
Mathias Vorreiter Pedersen
0b4a7f9436 PS: Synthesize a simpler notion of parameters. 2025-03-27 16:01:17 +00:00
Mathias Vorreiter Pedersen
5bc0a263ec PS: A call to set-variable is an explicit assignment. 2025-03-27 16:01:15 +00:00
Mathias Vorreiter Pedersen
faa94735bf PS: Add an implicit this parameter to all methods. 2025-03-27 16:01:14 +00:00
Mathias Vorreiter Pedersen
31f14ba99a PS: Add synthesis framework for cleaning up the AST. 2025-03-27 16:01:11 +00:00
Mathias Vorreiter Pedersen
0dd756d72d PS: Add support for variables. 2025-03-27 16:01:10 +00:00
Mathias Vorreiter Pedersen
11c84ccaf4 PS: Add the IPA type representing the AST. 2025-03-27 16:01:09 +00:00
Mathias Vorreiter Pedersen
b52c6ea4ba PS: Add control-flow node version of all the user-facing ast classes. 2025-03-27 16:01:07 +00:00
Mathias Vorreiter Pedersen
a207c8008b PS: Add 'raw' AST classes coming directly from the extractor. 2025-03-27 16:01:06 +00:00
Mathias Vorreiter Pedersen
665202195c PS: Add user-facing AST classes. 2025-03-27 16:01:04 +00:00
Mathias Vorreiter Pedersen
d79eb013c8 PS: Delete the old AST. 2025-03-26 18:00:10 +00:00
Mathias Vorreiter Pedersen
44e4e3eb54 PS: Extract more powershell files and fix off-by-one error in locations. 2025-03-25 16:59:28 +00:00
Dilan
4c138212bc Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2025-03-18 13:06:17 +00:00
Dilan
0869a11411 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2025-03-06 15:59:15 +00:00
Mathias Vorreiter Pedersen
4ddc425156 Merge pull request #175 from gfs/gfs/PowershellExtractorNetUpgrade
Update .NET Version for Powershell Extractor to Net 9.0
2025-02-27 18:05:34 +00:00
Mathias Vorreiter Pedersen
faa51c17e1 Merge branch 'main' into gfs/PowershellExtractorNetUpgrade 2025-02-27 17:59:31 +00:00
Mathias Vorreiter Pedersen
2172ced0be Merge pull request #176 from microsoft/dilan/powershell-pr-token
Fix PowerShell PR Token
2025-02-27 17:58:41 +00:00
dilanbhalla
17ae251137 Update powershell-pr-check.yml 2025-02-27 09:34:15 -08:00
Gabe Stocco
b018fb9c8f Add gitignore for build artifacts from powershell extractor 2025-02-26 12:40:27 -08:00
Gabe Stocco
43cdff9725 Update dependencies.
Update projects to use NET 9.0 (required by System.Management 7.5 and later)
2025-02-26 12:36:35 -08:00
Gabe Stocco
ee2688fbcb Update project to net 8. 2025-02-26 12:30:05 -08:00
Mathias Vorreiter Pedersen
4e6f4639f7 Merge pull request #174 from microsoft/revert-ps-module-extraction
PS: Revert extraction of code found via `PSModulePath`
2025-02-26 12:29:39 +00:00
Mathias Vorreiter Pedersen
abc23e038a Merge branch 'main' into revert-ps-module-extraction 2025-02-26 12:26:17 +00:00
Mathias Vorreiter Pedersen
29c11a4a5e PS: Add upgrade and downgrade scripts. 2025-02-24 14:23:49 +00:00
Mathias Vorreiter Pedersen
5b5b15361a PS: Make the prepare db script work on the Microsoft repo. 2025-02-24 14:23:47 +00:00
Mathias Vorreiter Pedersen
4bfd6fd345 PS: Revert psmodule path file extraction. 2025-02-24 14:23:46 +00:00
Mathias Vorreiter Pedersen
1978e10c05 PS: Remove extractor option to skip psmodule extraction. 2025-02-24 14:23:35 +00:00
Dilan
0628e4990b Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2025-02-21 18:59:16 +00:00
dilanbhalla
d76e438a90 Merge pull request #173 from microsoft/powershell-update-basic-block-library-for-2.20.5
PS: Match the changes from #18696
2025-02-21 10:13:16 -08:00
Mathias Vorreiter Pedersen
6909792627 PS: Also get rid of an easy-to-fix SSA warning. 2025-02-21 12:22:06 +00:00
Mathias Vorreiter Pedersen
efb43bca3e PS: Match the changes from #18696. 2025-02-21 12:16:00 +00:00
Mathias Vorreiter Pedersen
61796da374 Merge pull request #171 from microsoft/ps-add-dotnet-type-models
PS: Add .NET and PowerShell SDK type models.
2025-02-19 18:37:43 +00:00
Mathias Vorreiter Pedersen
3dbe7f4fa6 PS: Add the type model generation script and add a short readme. 2025-02-19 14:10:28 +00:00
Mathias Vorreiter Pedersen
6ef09412a9 PS: Add .NET and PowerShell SDK type models. 2025-02-19 00:05:51 +00:00
dilanbhalla
c39c091690 Update microsoft-codeql-pack-publish.yml 2025-02-14 11:06:14 -08:00
dilanbhalla
8c466139cb Update microsoft-codeql-pack-publish.yml 2025-02-14 11:05:16 -08:00
dilanbhalla
e79d4c9123 Update microsoft-codeql-pack-publish.yml 2025-02-14 10:50:32 -08:00
dilanbhalla
c4fa83bea8 Update microsoft-codeql-pack-publish.yml 2025-02-14 10:47:33 -08:00
dilanbhalla
4e0bfa3f66 Merge branch 'main' into dilan/publish-opensource-packs 2025-02-14 10:42:11 -08:00
Raul Garcia
5c54c81907 Merge pull request #169 from microsoft/dilan/metadata-bug-cpp
Metadata Bug in C++ Query
2025-02-12 16:46:26 -08:00
dilanbhalla
9ba49adc04 Update ArgumentIsSizeofOrOperation.ql 2025-02-12 15:15:17 -08:00
dilanbhalla
ad3299124c Merge pull request #168 from microsoft/dilan/reduce-pr-check-perms
Reduce GitHub Workflow Perms
2025-02-10 13:16:37 -08:00
dilanbhalla
6ccedebd12 Update sync-main.yml 2025-02-10 13:13:34 -08:00
dilanbhalla
898e4ff8af reduce powershell pr check perms 2025-02-10 12:52:03 -08:00
dilanbhalla
d5f75d49d8 Merge pull request #167 from microsoft/update-ruby-internal-dataflow-files
Ruby: Update internal dataflow files.
2025-02-10 09:24:09 -08:00
Mathias Vorreiter Pedersen
6ed2eb1478 Ruby: Update internal dataflow files. 2025-02-10 12:43:07 +00:00
dilanbhalla
233c0cfda0 Merge pull request #166 from microsoft/dilan/resolve-ruby-df-error
resolving ruby df error
2025-02-07 16:00:23 -08:00
Dilan Bhalla
41b5d19137 resolving ruby df error 2025-02-07 14:10:07 -08:00
dilanbhalla
e7bb37a18f Merge pull request #165 from microsoft/dilan/microsoft-namespace-edit
Microsoft Public Namespace Fix
2025-02-07 10:19:42 -08:00
dilanbhalla
e200aa5cdd Merge branch 'main' into dilan/microsoft-namespace-edit 2025-02-07 10:11:06 -08:00
Dilan Bhalla
414feffcaa microsoft-public -> public 2025-02-07 10:09:34 -08:00
Mathias Vorreiter Pedersen
7f7e9348e9 Merge pull request #164 from microsoft/dilan/include-microsoft-public-tests
Include Tests for Microsoft Open Source Queries
2025-02-07 14:46:48 +00:00
Mathias Vorreiter Pedersen
642780e7d6 C++: Accept more test changes. 2025-02-07 14:41:47 +00:00
Dilan Bhalla
ba97b92148 microsoft public namespace edit 2025-02-06 23:41:09 -08:00
Dilan Bhalla
312bc523a6 adding msft open source tests 2025-02-06 17:11:09 -08:00
Dilan
b0c11b5a78 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2025-02-06 21:05:28 +00:00
dilanbhalla
9be5b3c344 Merge pull request #163 from microsoft/update-powershell-cfg-library-after-2.20.4
PS: Fixup CFG library in preparation for 2.20.4
2025-02-06 13:03:57 -08:00
dilanbhalla
c749c19db4 Update CommandInjection.ql 2025-02-06 12:04:51 -08:00
dilanbhalla
fa74d05211 Update CommandInjection.ql 2025-02-06 12:04:39 -08:00
dilanbhalla
14ab30ce1f Update DoNotUseInvokeExpression.ql 2025-02-06 12:04:29 -08:00
Mathias Vorreiter Pedersen
c43b682862 PS: Ensure that the PowerShell CFG library compiles with CodeQL version 2.20.4. 2025-02-06 19:55:29 +00:00
Raul Garcia
cd9a0f1776 Merge pull request #161 from microsoft/dilan/query-id-msft-namespace
Add Microsoft-Public Namespace to Query IDs
2025-02-04 12:05:42 -08:00
Dilan Bhalla
54f0bc1afb adding msft namespace to msft query ids 2025-02-04 11:54:38 -08:00
Dilan Bhalla
405a4f545b working for first version, updating to autoincrementing logic 2025-02-02 23:12:13 -08:00
Dilan Bhalla
c8077a5117 minor fix 2025-02-02 22:58:46 -08:00
Dilan Bhalla
d6da994507 minor fix 2025-02-02 22:46:15 -08:00
Dilan Bhalla
d09d8c83ed minor fix 2025-02-02 22:37:43 -08:00
Dilan Bhalla
dd9e87c777 minor fix 2025-02-02 22:35:44 -08:00
Dilan Bhalla
d59576e55b minor fix 2025-02-02 22:30:34 -08:00
Dilan Bhalla
9c7dca6774 minor fix 2025-01-31 16:30:58 -08:00
Dilan Bhalla
19ea28c7d5 minor fix 2025-01-31 16:26:11 -08:00
Dilan Bhalla
472a51e3b5 minor fix 2025-01-31 16:02:17 -08:00
Dilan Bhalla
c3a0bc25f9 minor fix 2025-01-31 16:00:11 -08:00
Dilan Bhalla
1eb5e9bc87 accidentally removed codeql install step 2025-01-31 15:56:38 -08:00
Dilan Bhalla
efe01c151e first time publish, hardcode to 0.0.1 2025-01-31 15:49:10 -08:00
Dilan Bhalla
4e24f3231f minor fix 2025-01-31 15:46:10 -08:00
Dilan Bhalla
c99146a041 minor fix 2025-01-31 15:39:04 -08:00
Dilan Bhalla
cc4ce3b8d1 minor fix 2025-01-31 15:37:48 -08:00
Dilan Bhalla
6958dff31f minor fix 2025-01-31 15:36:35 -08:00
Dilan Bhalla
d1b30ef13d minor fix 2025-01-31 15:34:47 -08:00
Dilan Bhalla
a6fe1b5ed1 open source package publish 2025-01-31 15:33:54 -08:00
dilanbhalla
a88f3ce16d Merge pull request #160 from microsoft/dilan/remove-js-dataflow-deprecation-labels
TEMPORARY: Remove JavaScript Deprecation Labels
2025-01-31 14:18:55 -08:00
Dilan Bhalla
34a577de00 missed deprecation label removal for code injection query 2025-01-31 14:17:51 -08:00
Dilan Bhalla
714036110c removing javascript dataflow deprecations 2025-01-31 11:17:08 -08:00
Mathias Vorreiter Pedersen
29d07ae059 Merge pull request #159 from microsoft/dataflow-stack-cleanup-3
Java: Update file that was forgotten in #157
2025-01-31 18:04:25 +00:00
Mathias Vorreiter Pedersen
403ad3c7bd Shared: Add missing transitive closure. 2025-01-31 12:04:34 +00:00
Mathias Vorreiter Pedersen
712d8aa322 Java: Update file that was forgotten in the dataflow-stack PR. 2025-01-31 10:19:21 +00:00
Mathias Vorreiter Pedersen
df06d34625 Merge branch 'main' into interprocedural-controlflow 2025-01-30 18:40:23 +00:00
dilanbhalla
3237b2c3f7 Merge pull request #158 from microsoft/dataflow-stack-cleanup-2
Java/C#: Add missing files from #157
2025-01-30 10:07:50 -08:00
Mathias Vorreiter Pedersen
d144c26c04 Java/C#: Add missing files. 2025-01-30 17:44:32 +00:00
dilanbhalla
ee6624a425 Merge pull request #157 from microsoft/dataflow-stack-cleanup
Shared: Refactor `DataFlowStack`
2025-01-30 09:29:13 -08:00
Mathias Vorreiter Pedersen
c825ca8ec6 Shared: Refactor DataFlowStack so that we don't depend on our own modifications to the shared dataflow library files. 2025-01-30 16:21:21 +00:00
Mathias Vorreiter Pedersen
464ae8baf1 Shared: Autoformat. 2025-01-30 16:19:20 +00:00
Mathias Vorreiter Pedersen
e4378b26b8 All languages: Get rid of the Microsoft modifications to the GitHub dataflow files. 2025-01-30 15:40:52 +00:00
dilanbhalla
81fa6fcd2a Merge pull request #155 from microsoft/brodes/open_source_query_transition
Brodes/open source query transition
2025-01-29 01:29:16 -08:00
Ben Rodes
350742abc8 Merge branch 'main' into brodes/open_source_query_transition 2025-01-28 14:41:39 -05:00
Dilan
25a46a882b Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2025-01-28 19:01:55 +00:00
dilanbhalla
fee6373fa8 Merge pull request #156 from microsoft/update-powershell-dataflow-after-shared-changes
Powershell: Fix dataflow library after GitHub changes
2025-01-28 11:00:45 -08:00
dilanbhalla
273738e47c Merge branch 'main' into update-powershell-dataflow-after-shared-changes 2025-01-28 11:00:32 -08:00
Ben Rodes
da10292d8f Merge branch 'main' into brodes/open_source_query_transition 2025-01-28 12:18:18 -05:00
dilanbhalla
547b56223f Update sync-main.yml 2025-01-27 11:31:54 -08:00
dilanbhalla
e3494af9e0 Update sync-main.yml 2025-01-27 11:29:44 -08:00
dilanbhalla
70e27a4add Update sync-main.yml 2025-01-27 11:23:18 -08:00
Josh Brown
2fa64d0db5 Accept test case changed lines 2025-01-23 14:04:26 -08:00
Josh Brown
a09847f518 Merge new versions of cpp leap year queries 2025-01-23 12:47:40 -08:00
Mathias Vorreiter Pedersen
25f8f049c3 Powershell: Update changes to remain in sync with GitHub's shared libraries. 2025-01-23 18:06:22 +00:00
REDMOND\brodes
1376b0c355 Deprecated and hardcoded protocol queries and help 2025-01-15 16:26:55 -05:00
REDMOND\brodes
69cbbffd8f Adding UncheckedBoundsEnumAsIndex ql, help and example 2025-01-15 16:20:04 -05:00
REDMOND\brodes
34fe60dbfb KDF ql and qhelp 2025-01-15 16:18:33 -05:00
REDMOND\brodes
5d3f35bc8f HardcodedIVCNG qhelp and ql 2025-01-15 16:13:13 -05:00
REDMOND\brodes
4eb92afd25 Banned Modes ql and qhelp 2025-01-15 16:10:31 -05:00
REDMOND\brodes
9f09e67693 Adding BannedEncryption qhelp, ql, cap and cng qll, cryptofilters qll and misc. crypto example files 2025-01-15 13:16:57 -05:00
REDMOND\brodes
9668fb3875 SizeOfConstIntMacro qhelp, ql, examples and related qll. 2025-01-15 13:03:29 -05:00
REDMOND\brodes
ad626acbd3 Adding ArgumentIsSizeofOrOperation.qhelp, ql, and example files. 2025-01-15 13:01:08 -05:00
REDMOND\brodes
0f8f96c62e Adding IncorrectUsageOfRtlCompareMemory.qhelp, ql and example files. 2025-01-15 12:59:34 -05:00
REDMOND\brodes
7edf552023 Adding BadOverflowGuard qhelp, example code for help, and ql file. 2025-01-15 12:56:36 -05:00
REDMOND\brodes
936ecfc4cd All remaining leap year ql and qhelp files. 2025-01-15 12:37:21 -05:00
REDMOND\brodes
7eee4f2ea5 Adding LeapYear.qll and Adding365DaysPerYear ql and help. 2025-01-15 12:25:41 -05:00
REDMOND\brodes
99fa75b818 Leap Year Examples 2025-01-15 12:11:01 -05:00
Chanel
0bb0031802 Merge pull request #154 from microsoft/invoke-expression-ps-query
invoke expression powershell query
2025-01-09 15:43:37 -08:00
Chanel
6d55972f67 Merge branch 'main' into invoke-expression-ps-query 2025-01-09 15:37:53 -08:00
Dilan
4fd7aec87f Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2025-01-09 21:59:09 +00:00
Chanel
7f5e5ffa37 Apply suggestions from code review
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2025-01-09 10:41:16 -08:00
Chanel Young
17f9c9a0b5 invoke expression powershell query 2025-01-09 10:22:32 -08:00
dilanbhalla
faa5554ea7 Merge pull request #153 from microsoft/revert-152-dilan/rust-exclude-broken-queries
Revert "Remove Broken Rust Queries" + Stub DataflowStack required Interface
2024-12-19 10:21:08 -08:00
Josh Brown
2d97d0f629 WIP stubbing for DataFlowStack 2024-12-18 23:18:25 -08:00
Josh Brown
618732228d WIP stubbing for DataFlowStack 2024-12-18 23:16:23 -08:00
Josh Brown
5a17608c12 WIP stubbing for DataFlowStack 2024-12-18 23:13:25 -08:00
Josh Brown
fa1013ad15 Remove deprecated zipslip DataFlow configuration class, update test case 2024-12-18 22:03:31 -08:00
Josh Brown
00b556cc54 Revert "Remove Broken Rust Queries" 2024-12-19 16:39:08 +11:00
dilanbhalla
aec5d89621 Merge pull request #152 from microsoft/dilan/rust-exclude-broken-queries
Remove Broken Rust Queries
2024-12-17 17:11:04 -08:00
Dilan Bhalla
9575c0ed2a excluding broken queries 2024-12-17 17:07:36 -08:00
Dilan
2e6d9e7ca5 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-12-10 18:26:05 +00:00
dilanbhalla
46cbe2f260 Merge pull request #151 from microsoft/dilan/remove-deprecated-dataflow
Remove Deprecated DataFlow Libs
2024-12-10 10:24:48 -08:00
Dilan Bhalla
f91c91e4e2 resolve dataflow conflict 2024-12-09 13:36:44 -08:00
Mathias Vorreiter Pedersen
57f5b9748c C++: Instantiate the new shared library for C++. 2024-12-05 19:26:42 +00:00
Mathias Vorreiter Pedersen
f514753d63 C++: Add a 'shared' interprocedural control-flow library. I am keeping it in the cpp directory now to avoid qlpack headache. 2024-12-05 19:26:12 +00:00
dilanbhalla
58f8523276 Merge pull request #147 from microsoft/revert-146-dilan/msft-extractor-queries
Revert "Failed Extraction Queries"
2024-12-03 10:51:11 -08:00
dilanbhalla
a7cdda7a5b Revert "Failed Extraction Queries" 2024-12-03 10:50:15 -08:00
Dilan
0e25de1af0 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-12-02 13:59:17 +00:00
Mathias Vorreiter Pedersen
029fb0bcf2 Merge pull request #145 from microsoft/jb1/isLibraryFile-nomagic
No magic on `ClassifyFiles::isLibraryFile`
2024-11-26 11:50:19 +00:00
Josh Brown
52d7a3bb99 Merge remote-tracking branch 'origin/main' into jb1/isLibraryFile-nomagic 2024-11-26 03:43:07 -08:00
Mathias Vorreiter Pedersen
2d66955750 Merge pull request #146 from microsoft/dilan/msft-extractor-queries
Failed Extraction Queries
2024-11-25 13:19:24 +00:00
Dilan Bhalla
eb56cb94b0 metadata fixes 2024-11-22 14:29:43 -08:00
Dilan Bhalla
e3a04757d7 msft extractor queries 2024-11-22 14:11:02 -08:00
Josh Brown
e60df2c50e Merge branch 'main' into jb1/isLibraryFile-nomagic 2024-11-22 14:56:11 +11:00
Josh Brown
15f92fcda8 No magic isLibraryFile 2024-11-21 19:52:03 -08:00
dilanbhalla
54d9eda50a Update powershell-pr-check.yml 2024-11-20 14:09:27 -08:00
dilanbhalla
6fb39c65c5 Update powershell-pr-check.yml 2024-11-20 14:09:06 -08:00
dilanbhalla
b22ee5752d Update powershell-pr-check.yml 2024-11-20 13:28:52 -08:00
dilanbhalla
ac868f412c Update powershell-pr-check.yml 2024-11-20 13:21:15 -08:00
dilanbhalla
5dca7cd175 Merge pull request #143 from microsoft/dilan/powershell-pr-check
PowerShell PR Check
2024-11-20 12:35:22 -08:00
dilanbhalla
44e48a7588 Update powershell-pr-check.yml 2024-11-20 12:17:06 -08:00
dilanbhalla
514285c2fc Update sync-main.yml 2024-11-20 12:16:38 -08:00
dilanbhalla
105f7395d7 Delete powershell/ql/src/queries/security/cwe-078/test.ql 2024-11-20 12:14:08 -08:00
dilanbhalla
147784a102 Create test.ql 2024-11-20 12:11:39 -08:00
dilanbhalla
7257b4a0a2 Update powershell-pr-check.yml 2024-11-20 12:08:15 -08:00
dilanbhalla
1dd5e34e0e Create powershell-pr-check.yml 2024-11-20 12:04:11 -08:00
Lindsay Simpkins
861ae8abc4 Merge pull request #142 from microsoft/lsimpkins/powershell-buildmodes
PS: support buildmode none in extractor
2024-11-20 14:11:51 -05:00
Lindsay Simpkins
ff03d6c22a PS: support buildmode none in extractor 2024-11-19 19:38:55 -05:00
Mathias Vorreiter Pedersen
e9b7925432 Merge pull request #141 from microsoft/powershell-cmd-injection-fewer-sinks
PS: Improve sinks in `powershell/command-injection`
2024-11-12 20:25:17 +00:00
Mathias Vorreiter Pedersen
ba8a37c625 PS: Add more injetion sinks and type models. 2024-11-12 20:12:57 +00:00
Mathias Vorreiter Pedersen
308afb996b PS: Add common GAC (global assembly cache) assemblies and all automatic varibles. 2024-11-12 20:12:54 +00:00
Mathias Vorreiter Pedersen
f103fed6de PS: Use ! to mark static members/methods. 2024-11-12 20:12:52 +00:00
Mathias Vorreiter Pedersen
50c05517d2 PS: Include implicit qualifiers. 2024-11-12 20:05:20 +00:00
Mathias Vorreiter Pedersen
a382d08915 PS: Don't raise an alert on all call operator node arguments. 2024-11-11 15:25:18 +00:00
Mathias Vorreiter Pedersen
5b5f6ec3c3 Merge pull request #140 from microsoft/powershell-storestep-avoid-cp
PS: Remove accidental CP
2024-11-11 12:28:43 +00:00
Mathias Vorreiter Pedersen
446b3ea0e1 PS: Accept test changes. 2024-11-11 12:28:00 +00:00
Mathias Vorreiter Pedersen
7fe9cce53f PS: Avoid CP. 2024-11-11 12:19:46 +00:00
Mathias Vorreiter Pedersen
50188a2175 PS: Drive-by: Fix toString on Cmd. 2024-11-11 12:19:33 +00:00
Mathias Vorreiter Pedersen
86a40b9b0b Merge pull request #138 from microsoft/powershell-tainted-command-query
PS: Add the first non-experimental query
2024-11-08 20:44:15 +01:00
Mathias Vorreiter Pedersen
87cbfd191f Merge pull request #139 from microsoft/powershell-fix-multiple-cfg-successors
PS: Fix multiple CFG successors
2024-11-08 20:43:59 +01:00
Mathias Vorreiter Pedersen
40f50dd472 PS: Ensure the parameter has the right enclosing function. 2024-11-08 19:41:52 +00:00
Mathias Vorreiter Pedersen
b3de6a23ea PS: Add tests. 2024-11-08 16:07:12 +00:00
Mathias Vorreiter Pedersen
40cf8dd387 PS: Add test dependency on powereshell-queries. 2024-11-08 16:07:11 +00:00
Mathias Vorreiter Pedersen
e8274a66a5 PS: Add qhelp. 2024-11-08 16:07:09 +00:00
Mathias Vorreiter Pedersen
299c3e9eed PS: Add 'powershell/command-injection' query. 2024-11-08 16:07:07 +00:00
Mathias Vorreiter Pedersen
0fb75afd33 Merge pull request #137 from microsoft/powershell-taint-through-string-interpolation
PS: Taint-flow through string interpolation
2024-11-08 17:06:23 +01:00
Mathias Vorreiter Pedersen
f16b2cbd76 PS: Accept test changes. 2024-11-08 16:04:10 +00:00
Mathias Vorreiter Pedersen
5a715c7d11 PS: Flow through string interpolation. 2024-11-08 16:01:23 +00:00
Mathias Vorreiter Pedersen
d5d3712db4 PS: Add taint test. 2024-11-08 15:59:26 +00:00
Mathias Vorreiter Pedersen
16aacd87e0 Merge pull request #136 from microsoft/powershell-first-query-preps
PS: Add AST and CFG classes for operator `&` and add environment variable reads as local flow sources
2024-11-08 16:07:08 +01:00
Mathias Vorreiter Pedersen
4a2fd527ed PS: Add reads of environment variables as local flow sources. 2024-11-08 15:01:18 +00:00
Mathias Vorreiter Pedersen
9f0f0ca8a4 PS: Add placeholder for speculative flow now that this has been merged on the GitHub side. 2024-11-08 15:00:37 +00:00
Mathias Vorreiter Pedersen
aaa01820e0 PS: Add AST and CFG nodes for operator &. 2024-11-08 14:59:56 +00:00
Dilan
1e1fd4566c Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-11-07 17:59:18 +00:00
Mathias Vorreiter Pedersen
f96a984b1f Merge pull request #135 from microsoft/api-graphs-qualified-calls
PS: Allow `Instance` on explicit module uses
2024-11-07 14:03:34 +01:00
Mathias Vorreiter Pedersen
2255fda9e6 PS: Accept test changes. These are all from the changes to 'toString' from the previous commit. 2024-11-07 12:59:06 +00:00
Mathias Vorreiter Pedersen
a086d63f31 PS: Drive-by fix: Better toString on Cmd. 2024-11-07 12:47:58 +00:00
Mathias Vorreiter Pedersen
7531d88f6d PS: Allow explicit module qualifiers to be selected with the 'instance' path. 2024-11-07 12:47:23 +00:00
Mathias Vorreiter Pedersen
689a34b823 PS: Add a public dataflow node class for TypeNames. 2024-11-07 12:46:08 +00:00
Mathias Vorreiter Pedersen
938069d5ba PS: Include more module IPA nodes. 2024-11-07 12:45:06 +00:00
Mathias Vorreiter Pedersen
8550178112 Merge pull request #134 from microsoft/powershell-mad
PS: Add API graphs and models-as-data libraries
2024-11-06 15:05:36 +01:00
Mathias Vorreiter Pedersen
18d8de1fc8 PS: Add a bunch of source models. 2024-11-06 13:43:18 +00:00
Mathias Vorreiter Pedersen
d02ad25aaa PS: Add (empty) model-related files. 2024-11-06 13:43:16 +00:00
Mathias Vorreiter Pedersen
4344e70543 PS: Include certain statements as local source nodes. 2024-11-06 13:43:14 +00:00
Mathias Vorreiter Pedersen
4f58b19217 PS: Add wrapper classes for local and remote flow sources. 2024-11-06 13:43:13 +00:00
Mathias Vorreiter Pedersen
2ffbf179d8 PS: Dataflow additions to support api graphs. 2024-11-06 13:43:10 +00:00
Mathias Vorreiter Pedersen
9a03d10eb1 PS: Add API graph files. 2024-11-06 13:43:07 +00:00
Mathias Vorreiter Pedersen
314951779d PS: Add shared files for API graphs. 2024-11-06 13:43:03 +00:00
Mathias Vorreiter Pedersen
5852fe40d8 PS: Add a concept of 'source call' vs. 'library call' to avoid non-monotonic recursion in the next commits. 2024-11-06 13:43:01 +00:00
Mathias Vorreiter Pedersen
cfde677eb2 PS: AST and control-flow additions required for MaD and Api graphs. 2024-11-06 13:42:58 +00:00
Mathias Vorreiter Pedersen
68c729f8cd PS: Models-as-data skeleton. 2024-11-06 13:41:05 +00:00
Mathias Vorreiter Pedersen
9fb5711cc6 PS: Drive-by fix: Match Ruby's implementation of 'getAMatchingContent'. 2024-11-06 13:41:04 +00:00
Mathias Vorreiter Pedersen
94220ec26b PS: Make use of static type information in dataflow dispatch. 2024-11-06 13:41:03 +00:00
Mathias Vorreiter Pedersen
92a8c84ce6 PS: Add predicates for getting the static type of a parameter. 2024-11-06 13:41:02 +00:00
Mathias Vorreiter Pedersen
ef36d6b03c Merge pull request #133 from microsoft/powershell-extract-implicit-models-followup
PS: #132 follow-up
2024-11-06 12:53:49 +01:00
Mathias Vorreiter Pedersen
a2158e2b68 PS: Add an extractor option to control whether to extract PSModulePath files and use that new option when running ql tests. 2024-11-06 11:52:27 +00:00
Mathias Vorreiter Pedersen
43f986c8c8 Merge pull request #132 from microsoft/powershell-extract-implicit-models
PS: Extract source files found via `PSModulePath`
2024-11-06 11:19:20 +01:00
Mathias Vorreiter Pedersen
a56cbfe425 PS: Upgrade and downgrade scripts. 2024-11-06 10:14:33 +00:00
Mathias Vorreiter Pedersen
28ddb9aa5b PS: Mark which files are from the PSModulePath environment variable. 2024-11-06 10:14:31 +00:00
Mathias Vorreiter Pedersen
261d7d7679 PS: Also extract .psd1 files. 2024-11-06 10:14:28 +00:00
Mathias Vorreiter Pedersen
df962d7626 PS: Also extract files from the PSModulePath environment variable. 2024-11-06 10:14:26 +00:00
Mathias Vorreiter Pedersen
e6f8df7f96 Merge pull request #131 from microsoft/powershell-splitting
PS: Use the new shared control-flow splitting library
2024-11-04 14:57:55 +00:00
Mathias Vorreiter Pedersen
faf3d7c943 PS: Accept test changes. 2024-11-04 14:49:52 +00:00
Mathias Vorreiter Pedersen
38451a8285 PS: Implement conditional splitting in the Powershell CFG. 2024-11-04 14:49:36 +00:00
dilanbhalla
7a252e4089 Merge pull request #130 from microsoft/dilan/powershell-suites
Adding powershell suites
2024-11-01 14:15:08 -07:00
Dilan Bhalla
027e01d18c adding powershell suites 2024-11-01 14:13:38 -07:00
dilanbhalla
fcd875d75f Merge pull request #129 from microsoft/dilan/powershell-splitting-fix
commenting out problematic powershell qll code
2024-10-30 11:05:06 -07:00
Dilan Bhalla
4ff362fdb6 commenting out problematic powershell qll code 2024-10-30 11:03:10 -07:00
Raul Garcia
490957ad86 Merge pull request #117 from microsoft/SqlConnFP_fix
Fixing a false positive in cs/insecure-sql-connection
2024-10-22 10:03:14 -07:00
Raul Garcia
97bfc5dad7 Update csharp/ql/src/Security Features/CWE-327/InsecureSQLConnectionInitializerGood.cs
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2024-10-22 09:20:19 -07:00
Raul Garcia
8b9139f18b Update csharp/ql/src/Security Features/CWE-327/InsecureSQLConnectionInitializerBad.cs
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2024-10-22 09:20:12 -07:00
Raul Garcia
0662013ef5 Update csharp/ql/src/Security Features/CWE-327/InsecureSQLConnection.ql
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2024-10-22 09:20:01 -07:00
Dilan
7ad49cf3ff Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-10-21 17:59:16 +00:00
Mathias Vorreiter Pedersen
2f835e5f19 Merge pull request #128 from microsoft/powershell-taint-through-operations
PS: Taint through operations
2024-10-17 17:03:01 +01:00
Mathias Vorreiter Pedersen
d70d40913c PS: Accept test changes. 2024-10-17 16:52:17 +01:00
Mathias Vorreiter Pedersen
d0febd7aae PS: Add taint flow through all operations. 2024-10-17 16:52:16 +01:00
Mathias Vorreiter Pedersen
cd017db09f PS: Add taint versions of local flow tests. 2024-10-17 16:52:14 +01:00
Mathias Vorreiter Pedersen
c728c7dba5 PS: Add helper predicates and classes to operations. 2024-10-17 16:52:13 +01:00
Mathias Vorreiter Pedersen
34781b8730 PS: Add test with missing flow. 2024-10-17 16:52:11 +01:00
Mathias Vorreiter Pedersen
0890b22048 Merge pull request #127 from microsoft/powershell-fix-if-extraction
PS: Fix if statement clause extraction
2024-10-17 14:08:59 +01:00
Mathias Vorreiter Pedersen
e6c7ac2b21 PS: Accept test changes. 2024-10-17 14:07:11 +01:00
Mathias Vorreiter Pedersen
cc1348516f PS: Don't double increment when looping through if clauses. 2024-10-17 14:06:39 +01:00
Mathias Vorreiter Pedersen
e55c718a5e Merge pull request #126 from microsoft/powershell-global-parameter-positions
PS: Include parameter positions for top level functions
2024-10-17 11:53:25 +01:00
Mathias Vorreiter Pedersen
6bb859dab0 PS: Accept test changes. 2024-10-17 11:52:34 +01:00
Mathias Vorreiter Pedersen
9278f03753 PS: Include parameter positions for top levels. 2024-10-17 11:52:31 +01:00
Mathias Vorreiter Pedersen
97d5af7b6b PS: Add failing test. 2024-10-17 11:42:29 +01:00
Mathias Vorreiter Pedersen
c93daeb99f Merge pull request #125 from microsoft/global-parameters
PS: Global parameter support
2024-10-16 20:17:16 +01:00
Mathias Vorreiter Pedersen
dec3e7191c PS: Add test and accept test changes. 2024-10-16 20:15:01 +01:00
Mathias Vorreiter Pedersen
b426c1fc62 PS: Make top level a function as well. 2024-10-16 20:12:10 +01:00
Mathias Vorreiter Pedersen
56c703ec80 PS: Move a bunch of predicates into ScriptBlock. 2024-10-16 20:11:49 +01:00
Mathias Vorreiter Pedersen
d3b9e139c4 PS: Extend the set of sources in tests. 2024-10-16 18:54:24 +01:00
Mathias Vorreiter Pedersen
3c18124faf PS: Add taint-tracking files. 2024-10-16 18:26:34 +01:00
Mathias Vorreiter Pedersen
4cd37d63d7 Merge pull request #124 from microsoft/powershell-more-correct-value-from-property-name
PS: Allow for `ValueFromPipelineByPropertyName` to also read off an `ElementContent`
2024-10-16 16:47:51 +01:00
Mathias Vorreiter Pedersen
ef75ffef56 PS: Accept test changes. 2024-10-16 16:43:02 +01:00
Mathias Vorreiter Pedersen
a8de859dfb PS: Add a failing test. 2024-10-16 16:41:06 +01:00
Mathias Vorreiter Pedersen
7836a09e8a fixup! PS: Rename a few classes and tests. 2024-10-16 16:40:32 +01:00
Mathias Vorreiter Pedersen
70bc32a542 PS: Make sure we handle pipeline-value-from-property-name variables when passed an array. 2024-10-16 16:39:30 +01:00
Mathias Vorreiter Pedersen
b66f3b02aa PS: Rename a few classes and tests. 2024-10-16 16:26:51 +01:00
Mathias Vorreiter Pedersen
bfa9210b4b Merge pull request #123 from microsoft/flow-through-ValueFromPipelineByPropertyName
PS: Flow through `ValueFromPipelineByPropertyName` parameters
2024-10-15 16:11:42 +01:00
Mathias Vorreiter Pedersen
34c821fd2d PS: Drive-by fix. 2024-10-15 16:09:42 +01:00
Mathias Vorreiter Pedersen
3c38133bf3 PS: Drive-by fix. 2024-10-15 16:09:40 +01:00
Mathias Vorreiter Pedersen
fb74de4860 PS: Accept test changes. 2024-10-15 16:09:36 +01:00
Mathias Vorreiter Pedersen
fad9133343 PS: Add a read step out of property name parameter nodes. 2024-10-15 16:09:32 +01:00
Mathias Vorreiter Pedersen
87cc9cd88a PS: Also ignore pipeline property name parameters in the pipeline-related predicates. 2024-10-15 15:48:05 +01:00
Mathias Vorreiter Pedersen
1dcd3180b1 PS: Add test with missing flow. 2024-10-15 15:43:39 +01:00
Mathias Vorreiter Pedersen
a16b51a0bb Merge pull request #122 from microsoft/powershell-flow-through-conversions
PS: Flow through conversions
2024-10-15 13:39:28 +01:00
Mathias Vorreiter Pedersen
0e298a80e8 PS: Flow through parentheses. 2024-10-15 13:37:20 +01:00
Mathias Vorreiter Pedersen
e683f04e7b PS: Rename getExpr to getBase on ParenExpr. 2024-10-15 13:37:03 +01:00
Mathias Vorreiter Pedersen
959cbd7467 PS: Add another failing test with parentheses. 2024-10-15 13:36:17 +01:00
Mathias Vorreiter Pedersen
72e18ac135 PS: Flow through conversions. 2024-10-15 13:26:39 +01:00
Mathias Vorreiter Pedersen
43fcbcaffb PS: Rename getExpr to getBase on ConvertExpr. 2024-10-15 13:26:18 +01:00
Mathias Vorreiter Pedersen
97672f9e91 PS: Add test. 2024-10-15 13:21:43 +01:00
Mathias Vorreiter Pedersen
91d3f11bcc Merge pull request #121 from microsoft/flow-through-hashtables
PS: Flow through hash table creation, reads, and writes
2024-10-15 12:58:44 +01:00
Mathias Vorreiter Pedersen
2aacb580e2 PS: Accept test changes. 2024-10-15 12:54:17 +01:00
Mathias Vorreiter Pedersen
96de8111b5 PS: Dataflow through hash table creation, reads and writes. 2024-10-15 12:53:34 +01:00
Mathias Vorreiter Pedersen
656f98d361 PS: AST and CFG improvements to hash tables. 2024-10-15 12:53:07 +01:00
Mathias Vorreiter Pedersen
37c12639ed PS: Improve constant expression AST hierachy. 2024-10-15 12:52:41 +01:00
Mathias Vorreiter Pedersen
c8d70470a0 PS: Add tests with missing flow. 2024-10-15 12:46:54 +01:00
Mathias Vorreiter Pedersen
8aa119b6dc Merge pull request #120 from microsoft/flow-through-array-expr
PS: Flow through arrays
2024-10-14 20:15:07 +01:00
Mathias Vorreiter Pedersen
bc7c893006 PS: Accept test changes. 2024-10-14 20:10:51 +01:00
Mathias Vorreiter Pedersen
8bed9536bf PS: Flow through array expressions. 2024-10-14 20:09:19 +01:00
Mathias Vorreiter Pedersen
e63778a009 PS: CFG and AST helpers. 2024-10-14 20:08:54 +01:00
Mathias Vorreiter Pedersen
efee104f3d PS: Generalize the current ReturnContainer computation. 2024-10-14 20:06:46 +01:00
Mathias Vorreiter Pedersen
eb0f094e0b Merge pull request #119 from microsoft/powershell-unwrapping
PS: Flow through pipelines
2024-10-14 20:02:01 +01:00
Mathias Vorreiter Pedersen
1b454ed3e1 PS: add tests and accept test changes. 2024-10-14 18:14:52 +01:00
Mathias Vorreiter Pedersen
0aa6670247 PS: Model underscore parameters as pipeline parameters. 2024-10-14 18:14:50 +01:00
Mathias Vorreiter Pedersen
a0e17ee37b PS: Implicitly read any element content at sinks when doing taint flow. 2024-10-14 18:14:47 +01:00
Mathias Vorreiter Pedersen
1ec0f53a18 PS: Don't perform store steps and (and index removal, and all the othe complex return business) when there is only a single returned expression. 2024-10-14 18:14:45 +01:00
Mathias Vorreiter Pedersen
b2225fe7b5 PS: Drive-by performance fix: Don't generate N store steps when storing into an unknown index. 2024-10-14 18:14:43 +01:00
Mathias Vorreiter Pedersen
01a556e583 PS: Ensure the constants 0 .. 10 always exists. 2024-10-14 18:14:42 +01:00
Mathias Vorreiter Pedersen
51269633b0 PS: Pipeline flow. 2024-10-14 18:14:40 +01:00
Mathias Vorreiter Pedersen
cc995b1059 PS: Generalize getARead. 2024-10-14 18:14:38 +01:00
Mathias Vorreiter Pedersen
950a10be90 PS: Fix CFG ordering on CmdExpr. 2024-10-14 18:14:35 +01:00
Mathias Vorreiter Pedersen
830bf57d3a PS: Pipeline parameter and argument positions. 2024-10-14 18:14:33 +01:00
Mathias Vorreiter Pedersen
cbf9496202 PS: Helper predicates and classes. 2024-10-14 18:14:31 +01:00
Mathias Vorreiter Pedersen
3c19578e89 PS: Hide the new nodes and enure that we still show the old return node. 2024-10-14 18:14:28 +01:00
Mathias Vorreiter Pedersen
93a48646e6 PS: Accept test changes. 2024-10-14 18:14:26 +01:00
Mathias Vorreiter Pedersen
6797f8f729 PS: Add flow into, and out of, the new implicit unwrapping nodes. 2024-10-14 18:14:23 +01:00
Mathias Vorreiter Pedersen
15a22e5746 PS: Make the new return node an acual return node. 2024-10-14 18:14:21 +01:00
Mathias Vorreiter Pedersen
91a6dce01b PS: Add read step when we need unwrapping. 2024-10-14 18:14:17 +01:00
Mathias Vorreiter Pedersen
ea2f155a1f PS: Add two new kinds of nodes: A node that represents implicit unwrapping and a new node to hold the final return value of a function. 2024-10-14 16:51:55 +01:00
Mathias Vorreiter Pedersen
706eff2b14 PS: Us control-flow nodes in 'ReturnContainer' instead of dataflow nodes. 2024-10-11 11:59:44 +01:00
Mathias Vorreiter Pedersen
76bd4150b4 PS: Drive-by fix: '' is the same thing as '' 2024-10-11 11:17:37 +01:00
REDMOND\brodes
e0ee60f3dd Updated expected file. 2024-10-10 13:31:53 -04:00
Mathias Vorreiter Pedersen
8a575c4d20 Merge pull request #118 from microsoft/powershell-add-return-and-out-nodes
PS: Add flow out of functions
2024-10-10 12:28:56 +01:00
Raul Garcia
c1f7422f0e Fixing test cases 2024-10-09 16:53:33 -07:00
Raul Garcia
a179fa021f Fixing Test cases 2024-10-09 14:44:48 -07:00
Mathias Vorreiter Pedersen
1527479518 PS: Accept test changes. 2024-10-09 19:29:04 +01:00
Mathias Vorreiter Pedersen
a6b256371f PS: Add return and out nodes. 2024-10-09 19:29:03 +01:00
Mathias Vorreiter Pedersen
54521ad54d PS: Add a 'CallNode' helper class. 2024-10-09 19:29:02 +01:00
Mathias Vorreiter Pedersen
b34e36984d PS: Add failing tests. 2024-10-09 19:29:01 +01:00
REDMOND\brodes
b95b275136 qlref's were incorrect. 2024-10-09 13:55:28 -04:00
Mathias Vorreiter Pedersen
0814a90668 Merge pull request #116 from microsoft/powershell-add-empty-completion
PS: Add `Emptiness` completion to get rid of CFG inconsistencies
2024-10-08 20:02:08 +02:00
Mathias Vorreiter Pedersen
31f232d205 PS: Accept test changes. 2024-10-08 18:57:16 +01:00
Mathias Vorreiter Pedersen
7eb98c1122 PS: Add an emptiness successor to get rid of CFG inconsistencies. 2024-10-08 18:57:00 +01:00
Mathias Vorreiter Pedersen
a4e1860d4f Merge pull request #115 from microsoft/powershell-fix-dead-end-for-stmt
Powershell fix dead end for stmt
2024-10-08 16:47:57 +02:00
Mathias Vorreiter Pedersen
7ef8bfa8d7 PS: Don't interpret Cfg.ql as a graph. 2024-10-08 15:45:01 +01:00
Mathias Vorreiter Pedersen
6557081a96 PS: Accept test changes. 2024-10-08 15:39:10 +01:00
Mathias Vorreiter Pedersen
892b038565 PS: Support missing elements in for statements. 2024-10-08 15:38:46 +01:00
Mathias Vorreiter Pedersen
7e66dc3481 Merge pull request #114 from microsoft/powershell-flow-into-this
PS: Support flow through `this`
2024-10-08 16:38:08 +02:00
Mathias Vorreiter Pedersen
fb8d67f64f PS: Accept test changes. 2024-10-08 15:20:39 +01:00
Mathias Vorreiter Pedersen
455e56d804 PS: Support 'this' as a parameter in SSA and dataflow. 2024-10-08 15:20:36 +01:00
Mathias Vorreiter Pedersen
61d5f4412c PS: AST support for 'this'. 2024-10-08 15:20:33 +01:00
Mathias Vorreiter Pedersen
a429485b56 PS: Create an internal class to model 'Arguments'. 2024-10-08 15:20:31 +01:00
Mathias Vorreiter Pedersen
597147be71 PS: Refactor the way we do 'internal' AST related classes. 2024-10-08 15:20:29 +01:00
Mathias Vorreiter Pedersen
ca1c9120b5 PS: Add test with missing flow. 2024-10-08 15:20:27 +01:00
Mathias Vorreiter Pedersen
68b74f8af2 PS: Accept changes that hadn't been accepted before. 2024-10-08 15:20:24 +01:00
Dilan
878bd5b098 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-10-04 20:59:08 +00:00
Mathias Vorreiter Pedersen
78a1d069bc Merge pull request #113 from microsoft/powershell-element-content
PS: Add `ElementContent` for tracking flow through arrays
2024-10-04 21:18:58 +02:00
Mathias Vorreiter Pedersen
494ef7a44c PS: Fix missing flow. 2024-10-04 20:08:20 +01:00
Mathias Vorreiter Pedersen
4d8809a808 PS: Add another class of missing flow. 2024-10-04 20:06:22 +01:00
Mathias Vorreiter Pedersen
1de38e2cbc PS: Accept test changes. 2024-10-04 19:48:44 +01:00
Mathias Vorreiter Pedersen
3c80652b91 PS: Autoformat and silence 'unused paramter' warning. 2024-10-04 19:33:29 +01:00
Mathias Vorreiter Pedersen
cbfd0b363b PS: Add element content flow for reads and writes into arrays. 2024-10-04 19:33:28 +01:00
Mathias Vorreiter Pedersen
1f558a0b7f PS: Add CFG classes for array literals. 2024-10-04 19:33:27 +01:00
Mathias Vorreiter Pedersen
28b654df46 PS: Add helper clases for index expression. 2024-10-04 19:33:26 +01:00
Mathias Vorreiter Pedersen
22e508b85b PS: Introduce a class for constant values. 2024-10-04 19:33:23 +01:00
Mathias Vorreiter Pedersen
820f4b2575 PS: Add tests with arrays. 2024-10-04 19:33:22 +01:00
Raul Garcia
64aca2632b Fixing a false positive in cs/insecure-sql-connection, and adding a new query to remediate a false negative 2024-10-03 18:37:33 -07:00
Mathias Vorreiter Pedersen
421258b8f9 Merge pull request #112 from microsoft/powershell-more-type-flow
PS: Add more type-tracking flow
2024-10-03 20:47:01 +02:00
Mathias Vorreiter Pedersen
b622e09fe7 PS: Accept test changes. 2024-10-03 19:43:55 +01:00
Mathias Vorreiter Pedersen
e38f6301a6 PS: Also support type tracking of objects constructed with New-Object. 2024-10-03 19:43:54 +01:00
Mathias Vorreiter Pedersen
32f7f1b7e4 PS: Merge the non-member function and member function classes. Also rename member function to 'Method' since that's the name used by Powershell documentation. 2024-10-03 19:43:51 +01:00
Mathias Vorreiter Pedersen
5103d34dbf PS: Add tests. 2024-10-03 19:07:21 +01:00
Mathias Vorreiter Pedersen
46ead0d7f7 Merge pull request #111 from microsoft/powershell-more-control-flow
PS: More control flow
2024-10-03 12:30:51 +02:00
Mathias Vorreiter Pedersen
bcbb1bbce0 PS: Accept tests. 2024-10-03 11:25:26 +01:00
Mathias Vorreiter Pedersen
52129a981f PS: Add lots of missing control flow. We're now complete on 'fleschutz/PowerShell'. 2024-10-03 11:25:15 +01:00
Mathias Vorreiter Pedersen
c7976d5090 Merge pull request #110 from microsoft/powershell-dataflow-fixes
Powershell: Fix dataflow/SSA consistency errors.
2024-10-03 12:17:51 +02:00
Mathias Vorreiter Pedersen
7eac066118 Powershell: Fix dataflow/SSA consistency errors. 2024-10-03 11:11:44 +01:00
Mathias Vorreiter Pedersen
c7850b141d Merge pull request #109 from microsoft/powershell-call-target-resolution
PS: Resolve function calls
2024-10-02 17:56:21 +02:00
Mathias Vorreiter Pedersen
953bd09c1c Merge pull request #106 from microsoft/tainted-path-barrier-with-state
C#: Make `StartsWith` and `EndsWith` sanitizers on normalized paths
2024-10-02 17:32:56 +02:00
Mathias Vorreiter Pedersen
816aa79a45 PS: Add helper predicate on 'Call' for getting a runtime target. 2024-10-02 15:37:19 +01:00
Mathias Vorreiter Pedersen
b05409380a PS: Resolve non-member function calls using the dataflow's lambda call resolution features. 2024-10-02 15:36:39 +01:00
Mathias Vorreiter Pedersen
f6a5b4b182 PS: Resolve member function calls using the shared type-tracking library. 2024-10-02 15:34:45 +01:00
Mathias Vorreiter Pedersen
b6dfbc3182 PS: Instantiate most of the shared type-tracking library. 2024-10-02 15:30:50 +01:00
Mathias Vorreiter Pedersen
9049407fb4 PS: More AST cleanup. 2024-10-02 14:45:20 +01:00
Mathias Vorreiter Pedersen
655cb8ef9a PS: Fix 'getEnclosingScope' and add 'getEnclosingFunction'. 2024-10-02 14:44:09 +01:00
Mathias Vorreiter Pedersen
43c75504e1 PS: Also support method calls as calls. 2024-10-02 12:56:36 +01:00
Mathias Vorreiter Pedersen
e36e6175dd Merge pull request #108 from microsoft/fix-powershell-compilation
PS: Fix compile errors and warnings.
2024-10-02 13:38:21 +02:00
Mathias Vorreiter Pedersen
32502a5be7 PS: Fix compile errors and warnings. 2024-10-02 12:31:51 +01:00
Ben Rodes
939b2181d4 Wchar fp fixes (#107)
* Adding tests and updated expected file with false positives to correct.

(cherry picked from commit 26e58532ee)

* Modifications to the query to address false positives.

(cherry picked from commit cc24f1ed9f)

* Updating expected file, false positives now resolved.

(cherry picked from commit 92c8d39ba3)

* Correct comment.

(cherry picked from commit 338ab96593)

* Changing from hasIntermediateType to getABaseType.

(cherry picked from commit c4737c7fbb)

* Switching to looking for explicit declaration of unsigned char, to avoid cases where unsigned char is the default char width for `char`.

(cherry picked from commit 51e787b316)

* Altering ordering for exists statement to be clearer.

(cherry picked from commit 31324fc778)

* Altering exists predicate ordering to be clearer.

(cherry picked from commit c91f7f4918)

* Changing name of predicate to be clearer, and removing an unused parameter.

(cherry picked from commit 318e75c094)

* Removing unnecessary bracket/singleton set literal.

(cherry picked from commit 162519185d)

* Formatting.

(cherry picked from commit c496503053)
2024-10-01 09:51:10 -04:00
Mathias Vorreiter Pedersen
758196ed8d C#: Accept test changes. 2024-10-01 12:40:49 +01:00
Mathias Vorreiter Pedersen
89bdcfb53d C#: Allow 'StartsWith' and 'EndsWith' to be barriers when the path is normalized. 2024-10-01 12:34:40 +01:00
Mathias Vorreiter Pedersen
9457e5305e C#: Add a flow state to represent whether the path is normalized. 2024-10-01 12:33:04 +01:00
Mathias Vorreiter Pedersen
864bde242f C#: Add a FP testcase. 2024-10-01 12:26:58 +01:00
Mathias Vorreiter Pedersen
60cda950dc Merge pull request #105 from microsoft/powershell-argument-parameter-matching
PS: Implement argument/parameter matching in dataflow
2024-09-27 12:30:26 +01:00
Mathias Vorreiter Pedersen
b6019655ce PS: Use named sets to model parameter and argument matching. 2024-09-26 18:53:31 +01:00
Mathias Vorreiter Pedersen
e4c702ef14 PS: Represent sets of parameter names. 2024-09-26 18:53:30 +01:00
Mathias Vorreiter Pedersen
7f25caf3f6 PS: Add various helper predicates. 2024-09-26 18:53:29 +01:00
Mathias Vorreiter Pedersen
5e2051bdea PS: Add test. 2024-09-26 18:53:28 +01:00
Mathias Vorreiter Pedersen
5803e0611e Merge pull request #104 from microsoft/powershell-field-flow
PS: Add field flow
2024-09-26 11:31:12 +01:00
Mathias Vorreiter Pedersen
1ce4c2fcbf PS: Add tests. 2024-09-24 16:53:56 +01:00
Mathias Vorreiter Pedersen
f51e0b0133 PS: Add field flow. 2024-09-24 16:53:48 +01:00
Mathias Vorreiter Pedersen
3fa466efa9 Merge pull request #102 from microsoft/powershell-very-basic-flow-steps
PS: Add very basic dataflow steps
2024-09-23 18:23:58 +01:00
Mathias Vorreiter Pedersen
f2d89a24f8 PS: Add flow steps from SSA and from right-hand of assignment to assignment. 2024-09-23 17:24:29 +01:00
Mathias Vorreiter Pedersen
dd2c5ef897 Merge pull request #101 from microsoft/add-inline-expectations-test-for-dataflow
PS: Add `InineExpectationsTest` library for dataflow tests
2024-09-23 16:29:35 +01:00
Mathias Vorreiter Pedersen
6beb8ee576 PS: Autoformat. 2024-09-23 16:27:42 +01:00
Mathias Vorreiter Pedersen
15b33ee612 PS: Add tests. 2024-09-23 16:27:39 +01:00
Mathias Vorreiter Pedersen
7fc82194e8 PS: Add inline expectations test library. 2024-09-23 16:27:37 +01:00
Mathias Vorreiter Pedersen
ccbfe0f168 PS: Prepare AST and other libraries for inline expectations tests. 2024-09-23 16:27:36 +01:00
Mathias Vorreiter Pedersen
67631e2d36 PS: Update AST hierachy after #100. 2024-09-23 16:27:34 +01:00
Mathias Vorreiter Pedersen
be8a76335b Merge pull request #100 from microsoft/powershell-fewer-pipelines-in-db
PS: Remove spurious `Pipeline`s in the DB
2024-09-23 13:24:17 +01:00
Mathias Vorreiter Pedersen
974017bb70 PS: Accept test changes. 2024-09-23 13:12:35 +01:00
Mathias Vorreiter Pedersen
0e606e69f7 PS: Add up and downgrade scripts. 2024-09-23 13:12:31 +01:00
Mathias Vorreiter Pedersen
18dd6d0b48 Add Powershell to the upgrade script prepation script. 2024-09-23 12:59:21 +01:00
Mathias Vorreiter Pedersen
26a75da26f PS: Don't generate a 'Pipeline' element when the pipeline wraps a single element. 2024-09-23 12:58:17 +01:00
dilanbhalla
ba1646fe90 Merge pull request #99 from microsoft/dilan/2.19.0-upgrade-conflict
Dilan/2.19.0 upgrade conflict
2024-09-22 02:05:31 -07:00
Dilan Bhalla
a763263cbd resolving merge conflict 2024-09-22 02:04:29 -07:00
dilanbhalla
2ee42cbc3b Merge pull request #98 from microsoft/dilan/2.19.0-upgrade
2.19.0 upgrade
2024-09-18 15:04:52 -07:00
Dilan Bhalla
e370fa2dec 2.19.0 upgrade fix 2024-09-18 14:48:55 -07:00
Dilan Bhalla
14ce258807 2.19.0 upgrade 2024-09-18 14:28:42 -07:00
Mathias Vorreiter Pedersen
8fd89829cc Merge pull request #97 from microsoft/powershell-integrate-ssa-into-dataflow
PS: Integrate SSA computations into dataflow
2024-09-17 10:02:52 +01:00
Mathias Vorreiter Pedersen
f14e1cc782 PS: Add more expression classes and a helper class for calls. 2024-09-16 20:32:25 +01:00
Mathias Vorreiter Pedersen
d616506f23 PS: Integrate SSA computations into dataflow. 2024-09-16 19:36:39 +01:00
Mathias Vorreiter Pedersen
c87873bd26 PS: Add more cfg classes and helper predicats. 2024-09-16 19:36:37 +01:00
Mathias Vorreiter Pedersen
88e32ba3e1 PS: Add local-flow test. 2024-09-16 19:16:23 +01:00
Mathias Vorreiter Pedersen
9bdfaa07b2 Merge pull request #96 from microsoft/powershell-param-def-class
PS: Place parameter definitions in the SSA graph
2024-09-16 18:41:44 +01:00
Mathias Vorreiter Pedersen
fbcac1020f PS: Add some simple SSA tests. 2024-09-16 13:36:57 +01:00
Mathias Vorreiter Pedersen
0312dce009 PS: Fix the scope of parameters. 2024-09-16 13:34:04 +01:00
Mathias Vorreiter Pedersen
a6a157a476 PS: Add initial parameter definitions. 2024-09-16 13:33:56 +01:00
Mathias Vorreiter Pedersen
f0429fa0f3 Merge pull request #95 from microsoft/powershell-ssa-consistency
PS: Add SSA consistency queries and include parameter read/writes as SSA read/writes
2024-09-13 13:51:13 +01:00
Mathias Vorreiter Pedersen
cf59c60495 PS: Shorter names. 2024-09-13 13:47:39 +01:00
Mathias Vorreiter Pedersen
3cebf8ba75 PS: Also include parameter reads and writes as SSA reads and writes. 2024-09-13 13:47:15 +01:00
Mathias Vorreiter Pedersen
ec6422c1b6 PS: Add a concept of a local scope variable (which includes both parameters and local variables). 2024-09-13 13:43:45 +01:00
Mathias Vorreiter Pedersen
dfeb667b8a PS: Add SSA consistency query file. 2024-09-13 13:43:17 +01:00
Mathias Vorreiter Pedersen
3459440a3c Merge pull request #94 from microsoft/add-more-cfg-tests
PS: Add more CFG tests
2024-09-13 13:40:21 +01:00
Mathias Vorreiter Pedersen
e12fd07074 PS: Add more tests. 2024-09-13 13:37:03 +01:00
Mathias Vorreiter Pedersen
4343d6b592 Merge pull request #93 from microsoft/powershell-ssa-skeleton
PS: SSA skeleton and various fixes
2024-09-13 12:20:45 +01:00
Mathias Vorreiter Pedersen
9499972878 PS: Run tests and accept test changes. 2024-09-13 12:14:30 +01:00
Mathias Vorreiter Pedersen
c26fdc3103 PS: A few CFG bugfixes. 2024-09-13 12:14:11 +01:00
Mathias Vorreiter Pedersen
645db5bc90 PS: Add SSA library. 2024-09-12 18:26:42 +01:00
Mathias Vorreiter Pedersen
8b4e065fa2 PS: Port the Ruby framework for lifting parent/child relations at the AST level to parent/child relations at the CFG level. 2024-09-12 18:26:41 +01:00
Mathias Vorreiter Pedersen
9107075f41 PS: Fixup CFG after the introduction of variables into the AST. 2024-09-12 18:26:39 +01:00
Mathias Vorreiter Pedersen
810978d3ab PS: Create an entity that represents a local variable and a parameter and introduce those into the AST. 2024-09-12 18:26:38 +01:00
Mathias Vorreiter Pedersen
e99404a051 PS: Fix missing parent relation for block statements. 2024-09-12 18:26:36 +01:00
Dilan
f63c2b071d Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-09-12 14:59:27 +00:00
Mathias Vorreiter Pedersen
b5950b0d3f Merge pull request #92 from microsoft/powershell-dataflow-skeleton
PS: Add dataflow skeleton
2024-09-11 11:35:35 +01:00
Mathias Vorreiter Pedersen
faf774f79b PS: Add dataflow skeleton 2024-09-10 18:25:58 +01:00
Mathias Vorreiter Pedersen
198ece98ce Merge pull request #91 from microsoft/powershell-cfg-for-if-and-match
PS: CFG for `if`, `match`, exceptions
2024-09-09 18:11:25 +01:00
Mathias Vorreiter Pedersen
dbbb9b32f8 Merge branch 'main' into powershell-cfg-for-if-and-match 2024-09-09 18:09:19 +01:00
Mathias Vorreiter Pedersen
e133b5cedb Merge pull request #88 from microsoft/more-specific-dbscheme-column-types
PS: Small dbscheme updates
2024-09-09 17:52:08 +01:00
Mathias Vorreiter Pedersen
5e4f52a52b Merge pull request #90 from microsoft/powershell-even-more-ast-classes
PS: Add more AST classes
2024-09-09 17:51:56 +01:00
Mathias Vorreiter Pedersen
3bb5582ffe Merge pull request #89 from microsoft/powershell-consistency-query
PS: Add consistency queries
2024-09-09 17:51:46 +01:00
Mathias Vorreiter Pedersen
f51a486c1c PS: CFG for try/catch and throw. 2024-09-06 10:48:19 +01:00
Mathias Vorreiter Pedersen
4c59de4fde PS: Implement CFG for if statements and switches. 2024-09-06 10:33:21 +01:00
Mathias Vorreiter Pedersen
fd29c470c0 PS: More cleanup of AST by fixing up toStrings and adding helper predicates. 2024-09-06 10:00:43 +01:00
Mathias Vorreiter Pedersen
830de2c904 PS: Add more AST classes. 2024-09-05 23:12:56 +01:00
Mathias Vorreiter Pedersen
084c868c8f PS: Add consistency queries. 2024-09-05 18:21:43 +01:00
Mathias Vorreiter Pedersen
3f98f372a0 PS: Add an en try in the library qlpack to point to the upgrade folder. 2024-09-03 20:03:35 +01:00
Mathias Vorreiter Pedersen
b9774d20d9 PS: Fill in properties scripts. Since we didn't change anything these are basically noopts in this case. 2024-09-03 20:03:19 +01:00
Mathias Vorreiter Pedersen
cac0500d57 PS: Add upgrade and downgrade files. This is automatically done by running the script in 'github/codeql/blob/main/misc/scripts/prepare-db-upgrade.sh' (after adding powershell to line 83). 2024-09-03 20:02:34 +01:00
Mathias Vorreiter Pedersen
2f7545cee8 PS: Fixup the corresponding QL to match the state of the dbscheme. 2024-09-03 19:59:28 +01:00
Mathias Vorreiter Pedersen
581254e06f PS: A couple of small dbscheme changes.
1. Flip the name of the child and parent column for 'parent' to reflect
how this is actually populated by the extractor.
2. Make some of the coumns more specific to the actual data type.
3. Make `@named_attribute_argument` an `@ast` branch.
2024-09-03 19:55:39 +01:00
Mathias Vorreiter Pedersen
20e76b39b3 Merge pull request #85 from microsoft/powershell-cfg-for-function-bodies-and-loops
PS: Control-flow for function bodies and loops
2024-09-03 19:51:22 +01:00
Mathias Vorreiter Pedersen
435ee53054 Merge pull request #87 from microsoft/powershell-port-injection-query
PS: Port `powershell/command-injection` from the internal repo
2024-09-03 18:39:07 +01:00
Mathias Vorreiter Pedersen
105e19e8e1 PS: New id to avoid overlapping with the internal query. 2024-09-03 18:36:08 +01:00
Mathias Vorreiter Pedersen
1cb059c381 PS: Fixup 'powershell/command-injection' so that it compiles after all the AST name changes. 2024-09-03 18:18:16 +01:00
Mathias Vorreiter Pedersen
c2bdc7aa52 PS: Add experimental query from the internal repo. 2024-09-03 18:18:15 +01:00
dilanbhalla
2fe3cee812 Merge pull request #86 from microsoft/dilan/2.18.3-upgrade
2.18.3 upgrade
2024-09-03 00:07:09 -07:00
Dilan Bhalla
db7c90d3dd 2.18.3 upgrade 2024-09-03 00:02:09 -07:00
Mathias Vorreiter Pedersen
39cdf0d896 PS: Accept test changes. 2024-08-30 16:15:20 +01:00
Mathias Vorreiter Pedersen
177fbccb61 PS: Add control-flow for loops. 2024-08-30 16:15:18 +01:00
Mathias Vorreiter Pedersen
41ba97b05c PS: Specify when a completion should be a boolan completion. 2024-08-30 16:15:17 +01:00
Mathias Vorreiter Pedersen
5dee69bc33 PS: Add loop CFG tests. 2024-08-30 16:15:16 +01:00
Mathias Vorreiter Pedersen
f00f55f460 PS: Accept test changes. 2024-08-30 16:15:14 +01:00
Mathias Vorreiter Pedersen
b3332da759 PS: Implement more control-flow trees. 2024-08-30 16:15:13 +01:00
Mathias Vorreiter Pedersen
a70cf44acb PS: Convert ScriptBlockTree to an abstract class and have TopLevel script blocks extend it. 2024-08-30 16:11:46 +01:00
Mathias Vorreiter Pedersen
1fa2cdf8a8 Add testcases with functions. 2024-08-30 16:11:45 +01:00
Mathias Vorreiter Pedersen
94a740f6b9 PS: Add continue completion and successor. 2024-08-30 16:11:44 +01:00
Mathias Vorreiter Pedersen
2d8a8c00ca PS: Shorter predicate names for statement blocks. 2024-08-30 16:11:42 +01:00
Mathias Vorreiter Pedersen
7ad60ca59c PS: Proper subclassing of binary expressions. 2024-08-30 16:11:41 +01:00
Mathias Vorreiter Pedersen
4e915f70d0 PS: Add unary expression AST class. 2024-08-30 16:11:40 +01:00
Mathias Vorreiter Pedersen
8575c53447 PS: Move 'getBody' up to the parent class. 2024-08-30 16:11:39 +01:00
Mathias Vorreiter Pedersen
844216afdc PS: Better toString in a couple of classes. 2024-08-30 16:11:37 +01:00
Mathias Vorreiter Pedersen
c2f0c01f19 PS: Create a common subclass for non-member and member functions. 2024-08-30 16:11:36 +01:00
Mathias Vorreiter Pedersen
04f80108ea Merge pull request #84 from microsoft/powershell-cfg-skeleton
PS: Initial CFG skeleton
2024-08-30 16:03:59 +01:00
Mathias Vorreiter Pedersen
f21cde2365 PS: Implement _just enough_ control flow to make the first example work. 2024-08-28 15:31:49 +01:00
Mathias Vorreiter Pedersen
626328c014 PS: Flip the parent child relation. 2024-08-28 15:02:51 +01:00
Mathias Vorreiter Pedersen
db46ca0bbf PS: Add parent-child test that demonstrates that the relation is flipped. 2024-08-28 15:02:50 +01:00
Mathias Vorreiter Pedersen
8d59e09216 PS: Shorter predicate names and better toString messages. 2024-08-28 15:02:48 +01:00
Mathias Vorreiter Pedersen
c69d70a97f PS: Add CFG test skeleton. 2024-08-28 15:02:45 +01:00
Mathias Vorreiter Pedersen
d29cb30ba5 PS: Add CFG skeleton. 2024-08-27 17:57:51 +01:00
Mathias Vorreiter Pedersen
b38c34ac58 PS: Accept test changes that I forgot to accept. 2024-08-27 17:52:25 +01:00
Mathias Vorreiter Pedersen
33ccf3f7f9 Merge pull request #82 from microsoft/powershell-index-files-options
PS: More fine-grained file indexing support
2024-08-27 17:47:48 +01:00
Mathias Vorreiter Pedersen
22a30ab952 Merge pull request #83 from microsoft/powershell-more-ast-classes
PS: Copy existing AST classes from internal repo
2024-08-27 00:28:24 +01:00
Mathias Vorreiter Pedersen
fd4b2b2c89 PS: Warn on implicit this to make CI happy. 2024-08-26 19:37:29 +01:00
Mathias Vorreiter Pedersen
c30feab8ac PS: Port existing tests from internal repo. 2024-08-26 19:21:31 +01:00
Mathias Vorreiter Pedersen
71349afae7 PS: Add more AST classes. 2024-08-26 19:21:28 +01:00
Mathias Vorreiter Pedersen
023c88a073 PS: Use shorter and more standard names. 2024-08-26 18:54:51 +01:00
Mathias Vorreiter Pedersen
efba031745 PS: Fixup AST by adding missing imports. Also use extends instead of instanceof in AST classes. 2024-08-26 18:54:47 +01:00
Mathias Vorreiter Pedersen
0c4a3f4871 Add lib files from the internal repo. 2024-08-26 18:54:43 +01:00
Mathias Vorreiter Pedersen
98a098c5fa PS: Support LGTM_INDEX_INCLUDE in the extractor. 2024-08-26 17:20:54 +01:00
Mathias Vorreiter Pedersen
8473678995 PS: Support --file-list option in the extractor. 2024-08-26 15:08:53 +01:00
dilanbhalla
9ba4ffdb14 Merge pull request #81 from microsoft/open-source-powershell-extractor
PS: Open source the powershell extractor
2024-08-23 12:26:22 -07:00
Mathias Vorreiter Pedersen
95d02e68c8 PS: Add readme with slight modifications from the internal repo. 2024-08-14 18:11:06 +01:00
Mathias Vorreiter Pedersen
4f8a94b4e8 PS: Add simple build script. 2024-08-14 18:11:04 +01:00
Mathias Vorreiter Pedersen
58fc649657 PS: Copy extractor and various scripts from internal repo to public repo. 2024-08-14 18:11:02 +01:00
Dilan
0550ff1040 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-08-13 14:59:34 +00:00
Ben Rodes
d4c0c4059d Brodes/overflow buffer fixes (#79)
* Addreessing false positive due to incorrect use of getType

* Addressing false positive with strncpy.

* BufferAccess must be reachable. False positives observed where accesses occur in dead code.

* Formatting and updating tests.
2024-08-12 16:00:11 -04:00
dilanbhalla
fd512d2a2d Merge pull request #80 from microsoft/more-2.18.1-upgrade-fixes
C#: More merge conflict fixes
2024-08-12 12:02:12 -07:00
Mathias Vorreiter Pedersen
fe6655b0d9 C#: More merge conflict fixes. 2024-08-12 19:23:07 +01:00
Lindsay Simpkins
aeaca1de7d Merge pull request #78 from microsoft/fix-join-order-in-zipslip-query
C#: Fix join order in `cs/zipslip`
2024-08-09 10:27:04 -07:00
Mathias Vorreiter Pedersen
a826163cb4 C#: Fix join order in 'getFilePathArgument'. 2024-08-09 15:20:30 +01:00
Mathias Vorreiter Pedersen
be175aa1a0 C#: Prevent bad magic in a few predicates. 2024-08-09 15:19:54 +01:00
dilanbhalla
24517e3034 Merge pull request #77 from microsoft/dilan/2.18.1-upgrade-2
2.18.1 Upgrade Fix (DataFlowPrivate libraries)
2024-08-02 15:56:56 -07:00
Dilan Bhalla
ed8ada30e8 apply Mathias patch 2024-08-02 15:45:35 -07:00
dilanbhalla
be7fce57c2 Merge pull request #76 from microsoft/dilan/2.18.1-upgrade-2
2.18.1 Upgrade
2024-07-31 15:31:13 -07:00
Dilan Bhalla
73ee8ef664 2.18.1 merge conflict 2024-07-31 14:53:08 -07:00
Dilan Bhalla
db6fb7b5a3 2.18.1 merge 2024-07-31 14:52:51 -07:00
Dilan
7bc16a378d Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-07-11 09:59:18 +00:00
Chanel
471d4672c1 Merge pull request #74 from microsoft/users/chanely/insecure-sql-connection-versioncheck
Update to insecure sql connection to check for version
2024-06-27 12:14:53 -07:00
Dilan
ee338e3caa Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-06-27 17:59:08 +00:00
Josh Brown
5dd5e80d6e autoformat 2024-06-26 13:23:23 -07:00
Chanel Young
f12f74ec77 delete unused predicate 2024-06-26 12:58:21 -07:00
Chanel Young
72d31c82aa check if using version > 4.0, where encrypt true by default 2024-06-26 12:57:25 -07:00
Ben Rodes
9401ab219e Update WeakEncryption.ql 2024-06-14 10:01:05 -04:00
dilanbhalla
f98735d499 Merge pull request #73 from microsoft/dilan/2.17.5-upgrade-revised
2.17.5 Upgrade
2024-06-12 13:44:58 -07:00
Dilan Bhalla
c01daaa40e upgrading to 2.17.5 2024-06-12 12:35:56 -07:00
Josh Brown
cccbdf25c7 Merge pull request #72 from microsoft/jb1/v2.17.4-2
Import v2.17.4 commit history
2024-06-05 04:57:00 +10:00
Josh Brown
28fdf7bf53 Merge tag 'codeql-cli/v2.17.4' into jb1/v2.17.4-2
Compatible with CodeQL CLI 2.17.4
2024-06-04 11:54:03 -07:00
Josh Brown
959f3fa97c Manual Merge DataFlowStack changes 2024-06-04 11:46:21 -07:00
Josh Brown
3f4156ced6 Merge pull request #71 from microsoft/jb1/v2.17.4
Merge upstream/v2.17.4
2024-06-05 04:38:10 +10:00
Josh Brown
e9a6ddab04 Manual merge, accept cs/zipslip test diff 2024-06-04 11:18:22 -07:00
Chanel
3b91979b14 Merge pull request #70 from microsoft/users/chanely-insecure-sql-connection
Fixing FP case for Insecure SQL connection
2024-05-16 14:44:44 -07:00
Chanel Young
300d048dbb fp case if encrypt set in initializer 2024-05-16 13:30:26 -07:00
Lindsay Simpkins
651031b15e python crypto update hmac module library (#69) 2024-05-16 09:35:27 -04:00
Ben Rodes
d548e47010 False positive workaround for incorrectly identified OpenSSL functions. (#67) 2024-05-14 14:55:51 -04:00
dilanbhalla
e1949c7d69 Merge pull request #64 from microsoft/jb1/v2.17.2
Merge upstream codeql-cli/v2.17.2
2024-05-09 15:06:11 -07:00
Josh Brown
d0329609e3 Manual merge v2.17.2 2024-05-09 13:23:42 -07:00
Dilan
7d944ccd43 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-04-24 15:59:16 +00:00
Josh Brown
5d2aa8b1ca Merge pull request #49 from microsoft/jb1/zipslip-performance-fix
Zipslip performance fix
2024-04-19 03:24:42 +10:00
Josh Brown
20033b9b04 Merge pull request #58 from microsoft/jb1/improper-array-index
Jb1/improper array index
2024-04-19 03:24:27 +10:00
Josh Brown
db49d95e77 Filter out tests directories 2024-04-17 11:47:23 -07:00
Josh Brown
88e77ade8e False positive test case 2024-04-09 16:25:09 -07:00
dilanbhalla
9709ebb2a3 Merge pull request #62 from microsoft/jb1/dfs-patch
DFS CPP + Java Compile Error patch
2024-04-09 16:05:51 -07:00
Josh Brown
7d8abf0eef DataflowStack Signature fix 2024-04-09 15:28:49 -07:00
dilanbhalla
f99d2b0f78 Merge pull request #61 from microsoft/upstream-test
Merge upstream/main
2024-04-05 15:45:16 -07:00
Josh Brown
30bf0a7c8b manual merge 2024-04-05 15:30:56 -07:00
Josh Brown
37d5c69e18 minor formatting 2024-04-05 14:53:07 -07:00
Josh Brown
31a1f43bba constrain TT for SanitizedGuardTaintTrackingconfiguration to be only sourced from methods where there is a rootsanitizerMethodCall wihtin it 2024-03-28 10:50:59 -07:00
Josh Brown
f5197d75d8 autoformat + update hasQualifiedName 2024-03-28 10:50:59 -07:00
Josh Brown
80dc5f0d27 revert to enhanced version with performance issue 2024-03-28 10:50:58 -07:00
Denis Levin
baee3a3db3 Extendign password variable detection with patterns and antipatterns from C# query (#59) 2024-03-27 12:50:52 -04:00
Dilan
3325cb9ec6 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-03-26 12:59:35 +00:00
Josh Brown
720285f724 Filter out sources from test directories 2024-03-25 11:10:13 -07:00
Josh Brown
a3eecc33a8 Filter our sources in test folders 2024-03-22 14:47:14 -07:00
Dilan
955fd2cc5a Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-03-21 13:00:21 +00:00
dilanbhalla
ebb37ac0c2 Merge pull request #57 from microsoft/dilan/2.16.4-merge
2.16.4 Upgrade + ZipSlip Expected File Conflict
2024-03-11 14:29:53 -07:00
Dilan Bhalla
dfdb5c9c9d merging 2.16.4, resolving zipslip .expected file conflict 2024-03-11 14:12:21 -07:00
Chanel
bbdf97e8f3 Merge pull request #55 from microsoft/dilan/chanel-sql-tedious
Chanel PR (SQL Tedious Package)
2024-02-28 11:13:22 -08:00
dilanbhalla
8e05f2a1f0 Update SQL.qll 2024-02-27 13:38:39 -08:00
dilanbhalla
134010ac7e Update SQL.qll 2024-02-27 13:30:38 -08:00
dilanbhalla
fd51a7dbc1 Update README.md (test) 2024-02-26 14:56:15 -08:00
dilanbhalla
fb78b0dc93 Update README.md (test) 2024-02-26 14:36:02 -08:00
dilanbhalla
3d25260891 Update README.md (test) 2024-02-26 14:33:56 -08:00
dilanbhalla
47c41bd3e2 Update README.md (test) 2024-02-26 14:29:39 -08:00
Dilan Bhalla
87fd2fc067 upgrading to 2.16.3, resolving zipslip merge conflict 2024-02-22 15:24:05 -08:00
Josh Brown
98fb82fd10 Merge pull request #53 from microsoft/jb1/dataflowstack/java
DataFlowStack - Java Impl
2024-02-17 05:30:34 +11:00
Josh Brown
ba1eab32ba Merge remote-tracking branch 'origin/main' into jb1/dataflowstack/java 2024-02-15 17:34:46 -08:00
Josh Brown
34cec001b6 java DataFlowStack impl 2024-02-14 10:57:40 -08:00
Dilan
50dad18134 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-02-12 18:59:04 +00:00
Josh Brown
5e9826a345 Merge pull request #26 from microsoft/jb1/lib/dataflowstack
DataFlowStack Common Library Init
2024-02-09 10:00:33 +11:00
Josh Brown
c92c212ea0 fix syntax errors introduced 2024-02-08 14:17:16 -08:00
Josh Brown
df915dc60c Merge commit '737dd9d4c1' into jb1/lib/dataflowstack 2024-02-08 08:18:04 -08:00
Josh Brown
9147b9dd21 Merge branch 'jb1/lib/dataflowstack' of github.com:microsoft/codeql into jb1/lib/dataflowstack 2024-02-07 12:56:08 -08:00
Josh Brown
beed67ad23 Address PR Comments 2024-02-07 12:56:00 -08:00
Josh Brown
c0fd03499a Update shared/dataflowstack/codeql/dataflowstack/DataFlowStack.qll 2024-02-08 06:15:29 +11:00
Josh Brown
3056e8cdab Remove getNode as required interface 2024-01-29 16:15:57 -08:00
Josh Brown
2314d3be16 stubs 2024-01-29 16:14:20 -08:00
Josh Brown
151d001713 stub predicates for DataFlowCall 2024-01-27 18:18:43 -08:00
Josh Brown
39500b1965 getAnArgumentNode 2024-01-26 18:59:41 -08:00
Dilan
737dd9d4c1 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-01-25 14:59:06 +00:00
Josh Brown
bba946a06e filling out further definitions, and code comments 2024-01-18 18:10:55 -08:00
Dilan
6c2c786571 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2024-01-16 14:59:23 +00:00
Josh Brown
9c1e33e66d FlowStackFrame class working, TODO: getSucceedingTerminalStateFrame() 2024-01-12 15:13:37 -08:00
Josh Brown
e4a30bf791 BiStackAnalysisInit 2024-01-03 17:29:43 -08:00
Josh Brown
4e84c84e2d Manual merge main 2023-12-29 17:01:56 -08:00
Josh Brown
f661529122 Merge pull request #37 from microsoft/jb1/df-java-isSource
MethodCallInsecureFileCreation isSource
2023-12-29 09:37:06 +11:00
Josh Brown
2f163b070a MethodCallInsecureFileCreation isSource 2023-12-28 10:08:50 -08:00
Josh Brown
0f48db2694 Merge pull request #36 from microsoft/jb1/upgrade-shared-df-pathnode
Upgrade Shared DataFlow PathNode Signature
2023-12-28 05:15:22 +11:00
Josh Brown
5a8185dcaf Syntax fix - extra or 2023-12-22 11:47:31 -08:00
Josh Brown
f57a5d7650 Upgrade shared DataFlow PathNode signature to include getASuccessor(), isSource() 2023-12-22 10:45:16 -08:00
Dilan
ff202c9e88 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-12-20 19:59:37 +00:00
Josh Brown
59732036b2 cpp getARuntimeTarget 2023-12-15 12:18:47 -08:00
Josh Brown
079f0fdbb5 StackFrameAnalysis example 2023-12-14 15:27:21 -08:00
Josh Brown
d1b1650cdd StackFrameAnalysis module 2023-12-14 14:26:26 -08:00
Josh Brown
09bc54b644 Merge commit '2bc9039d8486ec0be727ae3836237e97ec791e85' into jb1/lib/dataflowstack 2023-12-13 10:38:13 -08:00
Josh Brown
5750c8df72 Removing comment 2023-12-13 10:09:41 -08:00
Dilan
2bc9039d84 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-12-11 16:59:07 +00:00
Josh Brown
d9aac53ec0 Merge remote-tracking branch 'origin/main' into jb1/lib/dataflowstack 2023-12-06 08:34:02 -08:00
Dilan
9214f63b5f Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-11-30 18:37:51 +00:00
dilanbhalla
e83425813b Merge pull request #33 from microsoft/dilan/revert-printf-qll
Revert Printf.qll
2023-11-30 10:36:49 -08:00
dilanbhalla
b6b67b35ce Update Printf.qll 2023-11-30 10:36:03 -08:00
Josh Brown
3559a5a5a1 Merge pull request #31 from microsoft/jb1/performance/revert-zipslip
Revert Zipslip to upstream
2023-11-28 05:34:04 +11:00
Josh Brown
c06ae12d58 Revert Zipslip to upstream 2023-11-16 10:47:57 -08:00
Dilan
954d489613 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-11-13 13:01:39 +00:00
Ben Rodes
b6eaf2fa61 Adding missing strsafe sprintf variants. (#30)
(cherry picked from commit bdae2af0e2)
2023-11-08 14:46:09 -05:00
Josh Brown
c161ed42e1 dataflowstack init 2023-11-02 17:18:08 -07:00
Ben Rodes
d9364c060e Merge pull request #14482 from MathiasVP/additional-call-targets-for-cpp (#23)
C++: Add an abstract class that can be used to extend `viableCallable`

Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-10-23 10:12:11 -04:00
Dilan Bhalla
1cdf4aafb0 manual merge for 2.15.1, resolve zipslip conflict 2023-10-19 12:51:03 -07:00
dilanbhalla
90b7fd52c0 Update ZipSlipQuery.qll 2023-10-19 12:24:39 -07:00
dilanbhalla
6066e82071 Merge pull request #22 from microsoft/brodes/additional_target_cherry_pick
Brodes/additional target cherry pick
2023-10-18 11:15:35 -07:00
Benjamin Rodes
075e992ebe Revert "Cherry picking commit bbf9bcde2a (#21)"
This reverts commit d4e5b27969.
2023-10-18 10:32:58 -04:00
Benjamin Rodes
1026d89158 Merge branch 'main' into brodes/additional_target_cherry_pick 2023-10-18 10:23:06 -04:00
Benjamin Rodes
f19919bb52 Revert "Cherry picking commit bbf9bcde2a (#21)"
d4e5b27969
This reverts commit d4e5b27969.
2023-10-18 10:17:53 -04:00
Ben Rodes
d4e5b27969 Cherry picking commit bbf9bcde2a (#21)
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-10-17 13:46:36 -04:00
Mathias Vorreiter Pedersen
ab827a5acd Cherry picking commit bbf9bcde2a 2023-10-17 13:43:06 -04:00
Dilan
8555600c44 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-10-11 13:02:07 +00:00
Josh Brown
ea63fc03d5 Merge pull request #14289 from microsoft/jb1/16-cryptography-models-libraries-and-queries-migration (#19)
16 cryptography models libraries and queries migration

Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
2023-10-04 13:34:09 -04:00
Dilan
2bc3e28b18 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-09-26 13:59:31 +00:00
dilanbhalla
e5f74ddf8f Update sync-main.yml 2023-09-14 11:56:27 -07:00
Dilan
4d77490444 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-09-14 16:13:35 +00:00
dilanbhalla
73a4cc89e3 Update sync-main.yml 2023-09-13 19:03:40 -07:00
dilanbhalla
c2fee6758f Update sync-main.yml 2023-09-13 19:03:25 -07:00
dilanbhalla
c30661e1c1 Update CONTRIBUTING.md 2023-09-13 18:50:16 -07:00
dilanbhalla
3a75325ecb Update README.md 2023-09-13 18:49:48 -07:00
dilanbhalla
d185c94549 Update sync-main.yml 2023-09-13 18:45:37 -07:00
dilanbhalla
4e656de043 Update CONTRIBUTING.md 2023-09-13 18:38:11 -07:00
dilanbhalla
fc00da801f Update README.md 2023-09-12 21:19:42 -07:00
Dilan
bc2bb19491 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-09-12 16:13:57 +00:00
Dilan Bhalla
cd16271a56 Merge branch 'main' of https://github.com/github/codeql 2023-08-30 10:48:32 -07:00
Dilan Bhalla
3d7e6792e5 modifying gh libs instead of creating msft copies 2023-08-28 18:59:16 -07:00
Dilan Bhalla
76cec33ba8 Microsoft 2.14.3 resolving taintflow warning 2023-08-28 16:46:52 -07:00
Dilan Bhalla
7f61bfe155 fixing tainttracking module 2.14.3 2023-08-28 15:37:36 -07:00
Dilan
eb0e2c48ea Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-08-28 22:03:51 +00:00
Dilan Bhalla
d9b45c817d Merge branch 'main' of https://github.com/microsoft/codeql 2023-08-27 23:53:31 -07:00
Dilan Bhalla
5ee67421b7 microsoft dataflow fix for 2.14.3 2023-08-27 23:53:25 -07:00
Dilan Bhalla
6b23eeebc5 Merge branch 'main' of https://github.com/github/codeql 2023-08-27 23:45:53 -07:00
Dilan
019cff2fc0 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-08-25 17:41:23 +00:00
dilanbhalla
0a9fc79525 Update sync-main.yml 2023-08-25 10:40:26 -07:00
dilanbhalla
f2994e70d0 Update DataFlow.qll 2023-08-25 10:39:28 -07:00
Dilan Bhalla
da08e0b4bd Reverting temp dataflow from 2.14.3 to 2.14.1 2023-08-24 00:51:51 -07:00
Dilan Bhalla
8a9fd3539e Adding internal C++ dataflow library 2023-08-23 00:05:19 -07:00
Dilan Bhalla
7acd76dc4c temporarily disable sync main until 2.14.3 2023-08-22 09:56:49 -07:00
Dilan
08147f08df Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-07-28 12:01:37 +00:00
Dilan
d3e36cb49e Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-07-13 18:33:38 +00:00
Dilan
acda5fd88b Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-07-06 12:01:35 +00:00
dilanbhalla
72471f6993 Ben update to iterator.qll 2023-06-26 10:09:42 -07:00
Dilan
eb7a6667d7 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-06-19 20:49:44 +00:00
microsoft-github-policy-service[bot]
7b1c964869 Auto merge mandatory file pr
This pr is auto merged as it contains a mandatory file and is opened for more than 10 days.
2023-06-12 18:05:12 +00:00
microsoft-github-policy-service[bot]
c8f19d6ef0 Microsoft mandatory file 2023-06-02 16:20:00 +00:00
Dilan
7976cf8e77 Merge tag 'codeql-cli/latest'
Compatible with the latest released version of the CodeQL CLI
2023-05-31 17:57:24 +00:00
dilanbhalla
cb47517020 Update sync-main.yml 2023-05-31 10:56:29 -07:00
dilanbhalla
4b0d2b972f Update sync-main.yml 2023-05-31 10:45:25 -07:00
dilanbhalla
4e5a095e1c Merge pull request #9 from microsoft/jb1/zipslip-fix
Manual Merge: C# ZipSlip Conflict
2023-05-24 11:19:13 -07:00
Josh Brown
56b1047f66 Manual merge + updated test case of C# ZipSlip 2023-05-23 17:23:56 +10:00
Dilan Bhalla
6fbc070aaf sync with upstream repository 2023-04-26 17:10:42 -07:00
Dilan Bhalla
b3cd535bdd removing dead code test 2023-04-24 15:46:38 -07:00
Dilan Bhalla
bc51aee6ec removing debugging git log line 2023-04-24 15:27:05 -07:00
Dilan Bhalla
9c72cba7e2 removing unshallow 2023-04-24 15:16:50 -07:00
Dilan Bhalla
8ce078ef2c unshallow fetch 2023-04-24 15:14:27 -07:00
Dilan Bhalla
54716a84cf remove allow unrelated histories on git merge 2023-04-24 15:04:49 -07:00
Dilan Bhalla
4fb30f35b3 test predicate 2023-04-24 14:59:43 -07:00
Dilan Bhalla
fd05c130d4 allow unrelated histories on merge 2023-04-24 14:55:18 -07:00
Dilan Bhalla
b0e4305c95 josh zipslip improvements 2023-04-24 14:49:27 -07:00
Dilan Bhalla
885d2491d8 merge instead of rebase 2023-04-24 14:46:35 -07:00
4401 changed files with 210998 additions and 1916 deletions

5
.gitattributes vendored
View File

@@ -88,3 +88,8 @@
# swift prebuilt resources
/swift/third_party/resources/*.zip filter=lfs diff=lfs merge=lfs -text
/swift/third_party/resources/*.tar.zst filter=lfs diff=lfs merge=lfs -text
# This upgrade script must use windows line-endings to be compatible with old
# databases.
/powershell/ql/lib/upgrades/ce269c61feda10a8ca0d16519085f7e55741a694/old.dbscheme eol=crlf
/powershell/downgrades/802d5b9f407fb0dac894df1c0b4584f2215e1512/semmlecode.powershell.dbscheme eol=crlf

View File

@@ -0,0 +1,152 @@
name: Microsoft CodeQL Pack Publish
on:
workflow_dispatch:
jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Fail if not on main branch
run: |
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "This workflow can only run on the 'main' branch."
exit 1
fi
codeqlversion:
needs: check-branch
runs-on: ubuntu-latest
outputs:
codeql_version: ${{ steps.set_codeql_version.outputs.codeql_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set CodeQL Version
id: set_codeql_version
run: |
git fetch
git fetch --tags
CURRENT_COMMIT=$(git rev-list -1 HEAD)
CURRENT_TAG=$(git describe --tags --abbrev=0 --match 'codeql-cli/v*' $CURRENT_COMMIT)
CODEQL_VERSION="${CURRENT_TAG#codeql-cli/}"
echo "CODEQL_VERSION=$CODEQL_VERSION" >> $GITHUB_OUTPUT
publishlibs:
environment: secure-publish
needs: codeqlversion
runs-on: ubuntu-latest
strategy:
matrix:
language: ['powershell']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install CodeQL
shell: bash
run: |
gh extension install github/gh-codeql
gh codeql download "${{ needs.codeqlversion.outputs.codeql_version }}"
gh codeql set-version "${{ needs.codeqlversion.outputs.codeql_version }}"
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Publish OS Microsoft CodeQL Lib Pack
shell: bash
run: |
# Download latest qlpack
gh codeql pack download "microsoft/$LANGUAGE-all"
PACK_DIR="$HOME/.codeql/packages/microsoft/$LANGUAGE-all"
VERSION_COUNT=$(ls -d "$PACK_DIR"/*/ | wc -l)
[[ "$VERSION_COUNT" -ne 1 ]] && { echo "Expected exactly one version in $PACK_DIR, but found $VERSION_COUNT. Exiting."; exit 1; }
# Increment version
CURRENT_VERSION=$(ls -v "$PACK_DIR" | tail -n 1)
MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1)
MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2)
PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3)
NEXT_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
# Extract dependencies from the existing qlpack.yml before deleting
DEPENDENCIES=$(yq 'select(has("dependencies")) | .dependencies | {"dependencies": .}' "$LANGUAGE/ql/lib/qlpack.yml" 2>/dev/null)
DATAEXTENSIONS=$(yq 'select(has("dataExtensions")) | .dataExtensions | {"dataExtensions": .}' "$LANGUAGE/ql/lib/qlpack.yml" 2>/dev/null)
rm -f "$LANGUAGE/ql/lib/qlpack.yml" "$LANGUAGE/ql/lib/qlpack.lock"
# Create new qlpack.yml with modified content
cat <<EOF > "$LANGUAGE/ql/lib/qlpack.yml"
name: microsoft/$LANGUAGE-all
version: $NEXT_VERSION
extractor: $LANGUAGE
groups:
- $LANGUAGE
- microsoft-all
dbscheme: semmlecode.$LANGUAGE.dbscheme
extractor: $LANGUAGE
library: true
upgrades: upgrades
$DEPENDENCIES
$DATAEXTENSIONS
warnOnImplicitThis: true
EOF
# Publish pack
cat "$LANGUAGE/ql/lib/qlpack.yml"
gh codeql pack publish "$LANGUAGE/ql/lib"
env:
LANGUAGE: ${{ matrix.language }}
GITHUB_TOKEN: ${{ secrets.PACKAGE_PUBLISH }}
publish:
environment: secure-publish
needs: codeqlversion
runs-on: ubuntu-latest
strategy:
matrix:
language: ['csharp', 'cpp', 'java', 'javascript', 'python', 'ruby', 'go', 'rust', 'swift', 'powershell', 'iac']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install CodeQL
shell: bash
run: |
gh extension install github/gh-codeql
gh codeql download "${{ needs.codeqlversion.outputs.codeql_version }}"
gh codeql set-version "${{ needs.codeqlversion.outputs.codeql_version }}"
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Publish OS Microsoft CodeQL Pack
shell: bash
run: |
# Download latest qlpack
gh codeql pack download "microsoft/$LANGUAGE-queries"
PACK_DIR="$HOME/.codeql/packages/microsoft/$LANGUAGE-queries"
VERSION_COUNT=$(ls -d "$PACK_DIR"/*/ | wc -l)
[[ "$VERSION_COUNT" -ne 1 ]] && { echo "Expected exactly one version in $PACK_DIR, but found $VERSION_COUNT. Exiting."; exit 1; }
# Increment version
CURRENT_VERSION=$(ls -v "$PACK_DIR" | tail -n 1)
MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1)
MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2)
PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3)
NEXT_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
# Extract dependencies from the existing qlpack.yml before deleting
DEPENDENCIES=$(yq 'select(has("dependencies")) | .dependencies | {"dependencies": .}' "$LANGUAGE/ql/src/qlpack.yml" 2>/dev/null)
rm -f "$LANGUAGE/ql/src/qlpack.yml" "$LANGUAGE/ql/src/qlpack.lock"
# Create new qlpack.yml with modified content
cat <<EOF > "$LANGUAGE/ql/src/qlpack.yml"
name: microsoft/$LANGUAGE-queries
version: $NEXT_VERSION
extractor: $LANGUAGE
groups:
- $LANGUAGE
- queries
$DEPENDENCIES
EOF
# Publish pack
cat "$LANGUAGE/ql/src/qlpack.yml"
gh codeql pack publish "$LANGUAGE/ql/src"
env:
LANGUAGE: ${{ matrix.language }}
GITHUB_TOKEN: ${{ secrets.PACKAGE_PUBLISH }}

View File

@@ -0,0 +1,32 @@
name: PowerShell PR Check
on:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
powershell-pr-check:
name: powershell-pr-check
runs-on: windows-latest
if: github.repository == 'microsoft/codeql'
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ github.token }}
- name: Setup CodeQL
uses: ./.github/actions/fetch-codeql
with:
channel: release
- name: Install PowerShell
run: |
$path = Split-Path (Get-Command codeql).Source
./powershell/build-win64.ps1 $path
- name: Run QL tests
run: |
codeql test run --threads=0 powershell/ql/test

28
.github/workflows/sync-main-tags.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Sync Main Tags
on:
pull_request:
types:
- closed
branches:
- main
jobs:
sync-main-tags:
name: Sync Main Tags
runs-on: ubuntu-latest
if: github.repository == 'microsoft/codeql' && github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'auto/sync-main-pr'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Push Tags
run: |
git remote add upstream https://github.com/github/codeql.git
git fetch upstream --tags --force
git push --force origin --tags
env:
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}

91
.github/workflows/sync-main.yml vendored Normal file
View File

@@ -0,0 +1,91 @@
name: Sync Main
on:
push:
branches:
- main
paths:
- .github/workflows/sync-main.yml
schedule:
- cron: '55 * * * *'
jobs:
sync-main:
name: Sync-main
runs-on: ubuntu-latest
if: github.repository == 'microsoft/codeql'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}
- name: Git config
shell: bash
run: |
git config user.name "dilanbhalla"
git config user.email "dilanbhalla@microsoft.com"
- name: Git checkout auto/sync-main-pr
shell: bash
run: |
git fetch origin
if git ls-remote --exit-code --heads origin auto/sync-main-pr > /dev/null; then
echo "Branch exists remotely. Checking it out."
git checkout -B auto/sync-main-pr origin/auto/sync-main-pr
else
echo "Branch does not exist remotely. Creating from main."
git checkout -B auto/sync-main-pr origin/main
git push -u origin auto/sync-main-pr
fi
- name: Sync origin/main
shell: bash
run: |
echo "::group::Sync with main branch"
git pull origin auto/sync-main-pr; exitCode=$?; if [ $exitCode -ne 0 ]; then exitCode=0; fi
git pull origin main --no-rebase
git push --force origin auto/sync-main-pr
echo "::endgroup::"
- name: Sync upstream/codeql-cli/latest
shell: bash
run: |
echo "::group::Set up remote"
git remote add upstream https://github.com/github/codeql.git
git fetch upstream --tags --force
echo "::endgroup::"
echo "::group::Merge codeql-cli/latest"
set -x
git merge codeql-cli/latest
set +x
echo "::endgroup::"
- name: Push sync branch
run: |
git push origin auto/sync-main-pr
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- name: Create PR if it doesn't exist
shell: bash
run: |
pr_number=$(gh pr list --repo microsoft/codeql --head auto/sync-main-pr --base main --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
echo "PR from auto/sync-main-pr to main already exists (PR #$pr_number). Exiting gracefully."
else
if git fetch origin main auto/sync-main-pr && [ -n "$(git rev-list origin/main..origin/auto/sync-main-pr)" ]; then
echo "PR does not exist. Creating one..."
gh pr create --repo microsoft/codeql --fill -B main -H auto/sync-main-pr \
--label 'autogenerated' \
--title 'Sync Main (autogenerated)' \
--body "This PR syncs the latest changes from \`codeql-cli/latest\` into \`main\`." \
--reviewer 'MathiasVP' \
--reviewer 'ropwareJB'
else
echo "No changes to sync from auto/sync-main-pr to main. Exiting gracefully."
fi
fi
env:
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "iac"]
path = iac
url = https://github.com/advanced-security/codeql-extractor-iac

View File

@@ -230,7 +230,7 @@ use_repo(
"kotlin-compiler-2.1.0-Beta1",
"kotlin-compiler-2.1.20-Beta1",
"kotlin-compiler-2.2.0-Beta1",
"kotlin-compiler-2.2.20-Beta1",
"kotlin-compiler-2.2.20-Beta2",
"kotlin-compiler-embeddable-1.6.0",
"kotlin-compiler-embeddable-1.6.20",
"kotlin-compiler-embeddable-1.7.0",
@@ -243,7 +243,7 @@ use_repo(
"kotlin-compiler-embeddable-2.1.0-Beta1",
"kotlin-compiler-embeddable-2.1.20-Beta1",
"kotlin-compiler-embeddable-2.2.0-Beta1",
"kotlin-compiler-embeddable-2.2.20-Beta1",
"kotlin-compiler-embeddable-2.2.20-Beta2",
"kotlin-stdlib-1.6.0",
"kotlin-stdlib-1.6.20",
"kotlin-stdlib-1.7.0",
@@ -256,7 +256,7 @@ use_repo(
"kotlin-stdlib-2.1.0-Beta1",
"kotlin-stdlib-2.1.20-Beta1",
"kotlin-stdlib-2.2.0-Beta1",
"kotlin-stdlib-2.2.20-Beta1",
"kotlin-stdlib-2.2.20-Beta2",
)
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")

View File

@@ -29,3 +29,5 @@ You can install the [CodeQL for Visual Studio Code](https://marketplace.visualst
### Tasks
The `.vscode/tasks.json` file defines custom tasks specific to working in this repository. To invoke one of these tasks, select the `Terminal | Run Task...` menu option, and then select the desired task from the dropdown. You can also invoke the `Tasks: Run Task` command from the command palette.

41
SECURITY.md Normal file
View File

@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.8 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->

View File

@@ -1,3 +1,7 @@
## 0.4.14
No user-facing changes.
## 0.4.13
### Bug Fixes

View File

@@ -0,0 +1,3 @@
## 0.4.14
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 0.4.13
lastReleaseVersion: 0.4.14

View File

@@ -1,5 +1,5 @@
name: codeql/actions-all
version: 0.4.14-dev
version: 0.4.14
library: true
warnOnImplicitThis: true
dependencies:

View File

@@ -1,3 +1,7 @@
## 0.6.6
No user-facing changes.
## 0.6.5
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 0.6.6
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 0.6.5
lastReleaseVersion: 0.6.6

View File

@@ -1,5 +1,5 @@
name: codeql/actions-queries
version: 0.6.6-dev
version: 0.6.6
library: false
warnOnImplicitThis: true
groups: [actions, queries]

View File

@@ -1,3 +1,13 @@
## 5.4.0
### New Features
* Exposed various SSA-related classes (`Definition`, `PhiNode`, `ExplicitDefinition`, `DirectExplicitDefinition`, and `IndirectExplicitDefinition`) which were previously only usable inside the internal dataflow directory.
### Minor Analysis Improvements
* The `cpp/overrun-write` query now recognizes more bound checks and thus produces fewer false positives.
## 5.3.0
### Deprecated APIs

View File

@@ -0,0 +1,4 @@
---
category: feature
---
* Added a new class `AdditionalCallTarget` for specifying additional call targets.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* The `cpp/overrun-write` query now recognizes more bound checks and thus produces fewer false positives.

View File

@@ -0,0 +1,9 @@
## 5.4.0
### New Features
* Exposed various SSA-related classes (`Definition`, `PhiNode`, `ExplicitDefinition`, `DirectExplicitDefinition`, and `IndirectExplicitDefinition`) which were previously only usable inside the internal dataflow directory.
### Minor Analysis Improvements
* The `cpp/overrun-write` query now recognizes more bound checks and thus produces fewer false positives.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 5.3.0
lastReleaseVersion: 5.4.0

View File

@@ -115,6 +115,10 @@ private string normalizeFunctionName(Function f, string algType) {
(result.matches("RSA") implies not f.getName().toUpperCase().matches("%UNIVERSAL%")) and
//rsaz functions deemed to be too low level, and can be ignored
not f.getLocation().getFile().getBaseName().matches("rsaz_exp.c") and
// SHA false positives
(result.matches("SHA") implies not f.getName().toUpperCase().matches("%SHAKE%")) and
// CAST false positives
(result.matches("CAST") implies not f.getName().toUpperCase().matches(["%UPCAST%", "%DOWNCAST%"])) and
// General False positives
// Functions that 'get' do not set an algorithm, and therefore are considered ignorable
not f.getName().toLowerCase().matches("%get%")

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-all
version: 5.3.1-dev
version: 5.4.0
groups: cpp
dbscheme: semmlecode.cpp.dbscheme
extractor: cpp
@@ -15,6 +15,7 @@ dependencies:
codeql/tutorial: ${workspace}
codeql/util: ${workspace}
codeql/xml: ${workspace}
codeql/global-controlflow: ${workspace}
dataExtensions:
- ext/*.model.yml
- ext/generated/**/*.model.yml

View File

@@ -15,6 +15,13 @@ class StandardSsa extends SsaHelper {
}
/**
* NOTE: If possible, prefer the SSA classes exposed by the new dataflow
* library:
* ```
* import semmle.code.cpp.dataflow.new.DataFlow
* // use `DataFlow::Ssa::Definition`
* ```
*
* A definition of one or more SSA variables, including phi node definitions.
* An _SSA variable_, as defined in the literature, is effectively the pair of
* an `SsaDefinition d` and a `StackVariable v`, written `(d, v)` in this

View File

@@ -0,0 +1,11 @@
import cpp
/**
* Provides classes for performing global (inter-procedural) control flow analyses.
*/
module ControlFlow {
private import internal.ControlFlowSpecific
private import codeql.globalcontrolflow.ControlFlow
import ControlFlowMake<Location, CppControlFlow>
import Public
}

View File

@@ -0,0 +1,41 @@
private import semmle.code.cpp.ir.IR
private import cpp as Cpp
private import ControlFlowPublic
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate as DataFlowPrivate
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
predicate edge(Node n1, Node n2) { n1.asInstruction().getASuccessor() = n2.asInstruction() }
predicate callTarget(CallNode call, Callable target) {
exists(DataFlowPrivate::DataFlowCall dfCall | dfCall.asCallInstruction() = call.asInstruction() |
DataFlowImplCommon::viableCallableCached(dfCall).asSourceCallable() = target
or
DataFlowImplCommon::viableCallableLambda(dfCall, _).asSourceCallable() = target
)
}
predicate flowEntry(Callable c, Node entry) {
entry.asInstruction().(EnterFunctionInstruction).getEnclosingFunction() = c
}
predicate flowExit(Callable c, Node exitNode) {
exitNode.asInstruction().(ExitFunctionInstruction).getEnclosingFunction() = c
}
Callable getEnclosingCallable(Node n) { n.getEnclosingFunction() = result }
predicate hiddenNode(Node n) { n.asInstruction() instanceof PhiInstruction }
private newtype TSplit = TNone() { none() }
class Split extends TSplit {
abstract string toString();
abstract Cpp::Location getLocation();
abstract predicate entry(Node n1, Node n2);
abstract predicate exit(Node n1, Node n2);
abstract predicate blocked(Node n1, Node n2);
}

View File

@@ -0,0 +1,79 @@
private import semmle.code.cpp.ir.IR
private import cpp
private newtype TNode = TInstructionNode(Instruction i)
abstract private class NodeImpl extends TNode {
/** Gets the `Instruction` associated with this node, if any. */
Instruction asInstruction() { result = this.(InstructionNode).getInstruction() }
/** Gets the `Expr` associated with this node, if any. */
Expr asExpr() { result = this.(ExprNode).getExpr() }
/** Gets the `Parameter` associated with this node, if any. */
Parameter asParameter() { result = this.(ParameterNode).getParameter() }
/** Gets the location of this node. */
Location getLocation() { none() }
/**
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
final predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
/** Gets a textual representation of this node. */
abstract string toString();
/** Gets the enclosing callable of this node. */
abstract Callable getEnclosingFunction();
}
final class Node = NodeImpl;
private class InstructionNode extends NodeImpl {
Instruction instr;
InstructionNode() { this = TInstructionNode(instr) }
/** Gets the `Instruction` associated with this node. */
Instruction getInstruction() { result = instr }
final override Location getLocation() { result = instr.getLocation() }
final override string toString() { result = instr.getAst().toString() }
final override Callable getEnclosingFunction() { result = instr.getEnclosingFunction() }
}
private class ExprNode extends InstructionNode {
Expr e;
ExprNode() { e = this.getInstruction().getConvertedResultExpression() }
/** Gets the `Expr` associated with this node. */
Expr getExpr() { result = e }
}
private class ParameterNode extends InstructionNode {
override InitializeParameterInstruction instr;
Parameter p;
ParameterNode() { p = instr.getParameter() }
/** Gets the `Parameter` associated with this node. */
Parameter getParameter() { result = p }
}
class CallNode extends InstructionNode {
override CallInstruction instr;
}
class Callable = Function;

View File

@@ -0,0 +1,19 @@
/**
* Provides IR-specific definitions for use in the data flow library.
*/
private import cpp
private import codeql.globalcontrolflow.ControlFlow
module Private {
import ControlFlowPrivate
}
module Public {
import ControlFlowPublic
}
module CppControlFlow implements InputSig<Location> {
import Private
import Public
}

View File

@@ -1,6 +1,5 @@
private import cpp
private import semmle.code.cpp.ir.IR
private import semmle.code.cpp.ir.dataflow.DataFlow
private import DataFlowPrivate
private import DataFlowUtil
private import DataFlowImplCommon as DataFlowImplCommon
@@ -60,7 +59,7 @@ private module VirtualDispatch {
* `resolve` predicate to stitch that information together and resolve the
* call.
*/
abstract DataFlow::Node getDispatchValue();
abstract Node getDispatchValue();
/** Gets a candidate target for this call. */
abstract Function resolve();
@@ -72,17 +71,13 @@ private module VirtualDispatch {
* parameter is true when the search is allowed to continue backwards into
* a parameter; non-recursive callers should pass `_` for `allowFromArg`.
*/
predicate flowsFrom(DataFlow::Node src, boolean allowFromArg) {
predicate flowsFrom(Node src, boolean allowFromArg) {
src = this.getDispatchValue() and allowFromArg = true
or
exists(DataFlow::Node other, boolean allowOtherFromArg |
this.flowsFrom(other, allowOtherFromArg)
|
exists(Node other, boolean allowOtherFromArg | this.flowsFrom(other, allowOtherFromArg) |
// Call argument
exists(DataFlowCall call, Position i |
other
.(DataFlow::ParameterNode)
.isParameterOf(pragma[only_bind_into](call).getStaticCallTarget(), i) and
other.(ParameterNode).isParameterOf(pragma[only_bind_into](call).getStaticCallTarget(), i) and
src.(ArgumentNode).argumentOf(call, pragma[only_bind_into](pragma[only_bind_out](i)))
) and
allowOtherFromArg = true and
@@ -96,7 +91,7 @@ private module VirtualDispatch {
allowFromArg = false
or
// Local flow
DataFlow::localFlowStep(src, other) and
localFlowStep(src, other) and
allowFromArg = allowOtherFromArg
or
// Flow from global variable to load.
@@ -159,11 +154,11 @@ private module VirtualDispatch {
private class DataSensitiveExprCall extends DataSensitiveCall {
DataSensitiveExprCall() { not exists(this.getStaticCallTarget()) }
override DataFlow::Node getDispatchValue() { result.asOperand() = this.getCallTargetOperand() }
override Node getDispatchValue() { result.asOperand() = this.getCallTargetOperand() }
override Function resolve() {
exists(FunctionInstruction fi |
this.flowsFrom(DataFlow::instructionNode(fi), _) and
this.flowsFrom(instructionNode(fi), _) and
result = fi.getFunctionSymbol()
) and
(
@@ -186,7 +181,7 @@ private module VirtualDispatch {
)
}
override DataFlow::Node getDispatchValue() { result.asInstruction() = this.getArgument(-1) }
override Node getDispatchValue() { result.asInstruction() = this.getArgument(-1) }
override MemberFunction resolve() {
exists(Class overridingClass |
@@ -213,7 +208,7 @@ private module VirtualDispatch {
pragma[noinline]
private predicate hasFlowFromCastFrom(Class derivedClass) {
exists(ConvertToBaseInstruction toBase |
this.flowsFrom(DataFlow::instructionNode(toBase), _) and
this.flowsFrom(instructionNode(toBase), _) and
derivedClass = toBase.getDerivedClass()
)
}
@@ -270,7 +265,7 @@ private predicate mayBenefitFromCallContext(
exists(InitializeParameterInstruction init |
not exists(call.getStaticCallTarget()) and
init.getEnclosingFunction() = f.getUnderlyingCallable() and
call.flowsFrom(DataFlow::instructionNode(init), _) and
call.flowsFrom(instructionNode(init), _) and
init.getParameter().getIndex() = arg
)
}

View File

@@ -4,7 +4,7 @@ private import semmle.code.cpp.ir.IR
private import DataFlowDispatch
private import semmle.code.cpp.ir.internal.IRCppLanguage
private import semmle.code.cpp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
private import SsaInternals as Ssa
private import SsaImpl as Ssa
private import DataFlowImplCommon as DataFlowImplCommon
private import codeql.util.Unit
private import Node0ToString
@@ -1982,19 +1982,23 @@ module IteratorFlow {
predicate allowFlowIntoUncertainDef(IteratorSsa::UncertainWriteDefinition def) { any() }
class GuardValue = Void;
class Guard extends Void {
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
predicate hasValueBranchEdge(
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, GuardValue val
) {
none()
}
predicate controlsBranchEdge(
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch
predicate valueControlsBranchEdge(
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, GuardValue val
) {
none()
}
}
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, GuardValue val) {
none()
}

View File

@@ -13,7 +13,7 @@ private import semmle.code.cpp.models.interfaces.DataFlow
private import semmle.code.cpp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
private import DataFlowPrivate
private import ModelUtil
private import SsaInternals as Ssa
private import SsaImpl as SsaImpl
private import DataFlowImplCommon as DataFlowImplCommon
private import codeql.util.Unit
private import Node0ToString
@@ -39,38 +39,39 @@ private newtype TIRDataFlowNode =
TNode0(Node0Impl node) { DataFlowImplCommon::forceCachingInSameStage() } or
TGlobalLikeVariableNode(GlobalLikeVariable var, int indirectionIndex) {
indirectionIndex =
[getMinIndirectionsForType(var.getUnspecifiedType()) .. Ssa::getMaxIndirectionsForType(var.getUnspecifiedType())]
[getMinIndirectionsForType(var.getUnspecifiedType()) .. SsaImpl::getMaxIndirectionsForType(var.getUnspecifiedType())]
} or
TPostUpdateNodeImpl(Operand operand, int indirectionIndex) {
operand = any(FieldAddress fa).getObjectAddressOperand() and
indirectionIndex = [0 .. Ssa::countIndirectionsForCppType(Ssa::getLanguageType(operand))]
indirectionIndex =
[0 .. SsaImpl::countIndirectionsForCppType(SsaImpl::getLanguageType(operand))]
or
Ssa::isModifiableByCall(operand, indirectionIndex)
SsaImpl::isModifiableByCall(operand, indirectionIndex)
} or
TSsaSynthNode(Ssa::SynthNode n) or
TSsaSynthNode(SsaImpl::SynthNode n) or
TSsaIteratorNode(IteratorFlow::IteratorFlowNode n) or
TRawIndirectOperand0(Node0Impl node, int indirectionIndex) {
Ssa::hasRawIndirectOperand(node.asOperand(), indirectionIndex)
SsaImpl::hasRawIndirectOperand(node.asOperand(), indirectionIndex)
} or
TRawIndirectInstruction0(Node0Impl node, int indirectionIndex) {
not exists(node.asOperand()) and
Ssa::hasRawIndirectInstruction(node.asInstruction(), indirectionIndex)
SsaImpl::hasRawIndirectInstruction(node.asInstruction(), indirectionIndex)
} or
TFinalParameterNode(Parameter p, int indirectionIndex) {
exists(Ssa::FinalParameterUse use |
exists(SsaImpl::FinalParameterUse use |
use.getParameter() = p and
use.getIndirectionIndex() = indirectionIndex
)
} or
TFinalGlobalValue(Ssa::GlobalUse globalUse) or
TInitialGlobalValue(Ssa::GlobalDef globalUse) or
TFinalGlobalValue(SsaImpl::GlobalUse globalUse) or
TInitialGlobalValue(SsaImpl::GlobalDef globalUse) or
TBodyLessParameterNodeImpl(Parameter p, int indirectionIndex) {
// Rule out parameters of catch blocks.
not exists(p.getCatchBlock()) and
// We subtract one because `getMaxIndirectionsForType` returns the maximum
// indirection for a glvalue of a given type, and this doesn't apply to
// parameters.
indirectionIndex = [0 .. Ssa::getMaxIndirectionsForType(p.getUnspecifiedType()) - 1] and
indirectionIndex = [0 .. SsaImpl::getMaxIndirectionsForType(p.getUnspecifiedType()) - 1] and
not any(InitializeParameterInstruction init).getParameter() = p
} or
TFlowSummaryNode(FlowSummaryImpl::Private::SummaryNode sn)
@@ -81,7 +82,7 @@ private newtype TIRDataFlowNode =
class FieldAddress extends Operand {
FieldAddressInstruction fai;
FieldAddress() { fai = this.getDef() and not Ssa::ignoreOperand(this) }
FieldAddress() { fai = this.getDef() and not SsaImpl::ignoreOperand(this) }
/** Gets the field associated with this instruction. */
Field getField() { result = fai.getField() }
@@ -126,7 +127,7 @@ predicate conversionFlow(
)
or
additional = true and
Ssa::isAdditionalConversionFlow(opFrom, instrTo)
SsaImpl::isAdditionalConversionFlow(opFrom, instrTo)
)
or
isPointerArith = true and
@@ -183,7 +184,7 @@ class Node extends TIRDataFlowNode {
or
this.asOperand().getUse() = block.getInstruction(i)
or
exists(Ssa::SynthNode ssaNode |
exists(SsaImpl::SynthNode ssaNode |
this.(SsaSynthNode).getSynthNode() = ssaNode and
ssaNode.getBasicBlock() = block and
ssaNode.getIndex() = i
@@ -364,10 +365,10 @@ class Node extends TIRDataFlowNode {
* pointed to by `p`.
*/
Expr asDefinition(boolean uncertain) {
exists(StoreInstruction store, Ssa::Definition def |
exists(StoreInstruction store, SsaImpl::Definition def |
store = this.asInstruction() and
result = asDefinitionImpl(store) and
Ssa::defToNode(this, def, _) and
SsaImpl::defToNode(this, def, _) and
if def.isCertain() then uncertain = false else uncertain = true
)
}
@@ -627,7 +628,7 @@ class OperandNode extends Node, Node0 {
* For example, `stripPointers(int*&)` is `int*` and `stripPointers(int*)` is `int`.
*/
Type stripPointer(Type t) {
result = any(Ssa::Indirection ind | ind.getType() = t).getBaseType()
result = any(SsaImpl::Indirection ind | ind.getType() = t).getBaseType()
or
result = t.(PointerToMemberType).getBaseType()
or
@@ -694,12 +695,12 @@ class PostFieldUpdateNode extends PostUpdateNodeImpl {
* in a data flow graph.
*/
class SsaSynthNode extends Node, TSsaSynthNode {
Ssa::SynthNode node;
SsaImpl::SynthNode node;
SsaSynthNode() { this = TSsaSynthNode(node) }
/** Gets the synthesized SSA node associated with this node. */
Ssa::SynthNode getSynthNode() { result = node }
SsaImpl::SynthNode getSynthNode() { result = node }
override DataFlowCallable getEnclosingCallable() {
result.asSourceCallable() = this.getFunction()
@@ -782,12 +783,12 @@ class SideEffectOperandNode extends Node instanceof IndirectOperand {
* from a function body.
*/
class FinalGlobalValue extends Node, TFinalGlobalValue {
Ssa::GlobalUse globalUse;
SsaImpl::GlobalUse globalUse;
FinalGlobalValue() { this = TFinalGlobalValue(globalUse) }
/** Gets the underlying SSA use. */
Ssa::GlobalUse getGlobalUse() { result = globalUse }
SsaImpl::GlobalUse getGlobalUse() { result = globalUse }
override DataFlowCallable getEnclosingCallable() {
result.asSourceCallable() = this.getFunction()
@@ -814,12 +815,12 @@ class FinalGlobalValue extends Node, TFinalGlobalValue {
* a function body.
*/
class InitialGlobalValue extends Node, TInitialGlobalValue {
Ssa::GlobalDef globalDef;
SsaImpl::GlobalDef globalDef;
InitialGlobalValue() { this = TInitialGlobalValue(globalDef) }
/** Gets the underlying SSA definition. */
Ssa::GlobalDef getGlobalDef() { result = globalDef }
SsaImpl::GlobalDef getGlobalDef() { result = globalDef }
override DataFlowCallable getEnclosingCallable() {
result.asSourceCallable() = this.getFunction()
@@ -1288,11 +1289,11 @@ class UninitializedNode extends Node {
LocalVariable v;
UninitializedNode() {
exists(Ssa::Definition def, Ssa::SourceVariable sv |
exists(SsaImpl::Definition def, SsaImpl::SourceVariable sv |
def.getIndirectionIndex() = 0 and
def.getValue().asInstruction() instanceof UninitializedInstruction and
Ssa::defToNode(this, def, sv) and
v = sv.getBaseVariable().(Ssa::BaseIRVariable).getIRVariable().getAst()
SsaImpl::defToNode(this, def, sv) and
v = sv.getBaseVariable().(SsaImpl::BaseIRVariable).getIRVariable().getAst()
)
}
@@ -1722,7 +1723,7 @@ private module Cached {
cached
predicate flowsToBackEdge(Node n) {
exists(Node succ, IRBlock bb1, IRBlock bb2 |
Ssa::ssaFlow(n, succ) and
SsaImpl::ssaFlow(n, succ) and
bb1 = n.getBasicBlock() and
bb2 = succ.getBasicBlock() and
bb1 != bb2 and
@@ -1820,7 +1821,7 @@ private module Cached {
predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo, string model) {
(
// Def-use/Use-use flow
Ssa::ssaFlow(nodeFrom, nodeTo)
SsaImpl::ssaFlow(nodeFrom, nodeTo)
or
IteratorFlow::localFlowStep(nodeFrom, nodeTo)
or
@@ -1833,7 +1834,7 @@ private module Cached {
|
simpleOperandLocalFlowStep(iFrom, opTo) and
// Omit when the instruction node also represents the operand.
not iFrom = Ssa::getIRRepresentationOfOperand(opTo)
not iFrom = SsaImpl::getIRRepresentationOfOperand(opTo)
)
or
// Indirect operand -> (indirect) instruction flow
@@ -1906,7 +1907,7 @@ private module Cached {
// We also want a write coming out of an `OutNode` to flow `nodeTo`.
// This is different from `reverseFlowInstruction` since `nodeFrom` can never
// be an `OutNode` when it's defined by an instruction.
Ssa::outNodeHasAddressAndIndex(nodeFrom, address, indirectionIndex)
SsaImpl::outNodeHasAddressAndIndex(nodeFrom, address, indirectionIndex)
)
}
@@ -2099,7 +2100,7 @@ private newtype TContent =
TFieldContent(Field f, int indirectionIndex) {
// the indirection index for field content starts at 1 (because `TFieldContent` is thought of as
// the address of the field, `FieldAddress` in the IR).
indirectionIndex = [1 .. Ssa::getMaxIndirectionsForType(f.getUnspecifiedType())] and
indirectionIndex = [1 .. SsaImpl::getMaxIndirectionsForType(f.getUnspecifiedType())] and
// Reads and writes of union fields are tracked using `UnionContent`.
not f.getDeclaringType() instanceof Union
} or
@@ -2111,7 +2112,9 @@ private newtype TContent =
// field can be read by any read of the union's fields. Again, the indirection index
// is 1-based (because 0 is considered the address).
indirectionIndex =
[1 .. max(Ssa::getMaxIndirectionsForType(getAFieldWithSize(u, bytes).getUnspecifiedType()))]
[1 .. max(SsaImpl::getMaxIndirectionsForType(getAFieldWithSize(u, bytes)
.getUnspecifiedType())
)]
)
} or
TElementContent(int indirectionIndex) {
@@ -2354,7 +2357,7 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
controls(g, result, edge)
)
or
result = Ssa::BarrierGuard<guardChecksNode/3>::getABarrierNode()
result = SsaImpl::BarrierGuard<guardChecksNode/3>::getABarrierNode()
}
/**
@@ -2453,7 +2456,7 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
)
or
result =
Ssa::BarrierGuardWithIntParam<guardChecksIndirectNode/4>::getABarrierNode(indirectionIndex)
SsaImpl::BarrierGuardWithIntParam<guardChecksIndirectNode/4>::getABarrierNode(indirectionIndex)
}
}
@@ -2490,7 +2493,7 @@ module InstructionBarrierGuard<instructionGuardChecksSig/3 instructionGuardCheck
controls(g, result, edge)
)
or
result = Ssa::BarrierGuard<guardChecksNode/3>::getABarrierNode()
result = SsaImpl::BarrierGuard<guardChecksNode/3>::getABarrierNode()
}
bindingset[value, n]
@@ -2520,7 +2523,7 @@ module InstructionBarrierGuard<instructionGuardChecksSig/3 instructionGuardCheck
)
or
result =
Ssa::BarrierGuardWithIntParam<guardChecksIndirectNode/4>::getABarrierNode(indirectionIndex)
SsaImpl::BarrierGuardWithIntParam<guardChecksIndirectNode/4>::getABarrierNode(indirectionIndex)
}
}
@@ -2576,3 +2579,16 @@ Function getARuntimeTarget(Call call) {
result = DataFlowImplCommon::viableCallableLambda(dfCall, _).asSourceCallable()
)
}
/** A module that provides static single assignment (SSA) information. */
module Ssa {
class Definition = SsaImpl::Definition;
class ExplicitDefinition = SsaImpl::ExplicitDefinition;
class DirectExplicitDefinition = SsaImpl::DirectExplicitDefinition;
class IndirectExplicitDefinition = SsaImpl::IndirectExplicitDefinition;
class PhiNode = SsaImpl::PhiNode;
}

View File

@@ -4,15 +4,15 @@
*/
private import semmle.code.cpp.ir.IR
private import semmle.code.cpp.ir.dataflow.DataFlow
private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs
private import DataFlowUtil
private import DataFlowPrivate
private import SsaInternals as Ssa
private import SsaImpl as Ssa
/**
* Gets the instruction that goes into `input` for `call`.
*/
DataFlow::Node callInput(CallInstruction call, FunctionInput input) {
Node callInput(CallInstruction call, FunctionInput input) {
// An argument or qualifier
exists(int index |
result.asOperand() = call.getArgumentOperand(index) and
@@ -62,8 +62,8 @@ Node callOutput(CallInstruction call, FunctionOutput output) {
result = callOutputWithIndirectionIndex(call, output, _)
}
DataFlow::Node callInput(CallInstruction call, FunctionInput input, int d) {
exists(DataFlow::Node n | n = callInput(call, input) and d > 0 |
Node callInput(CallInstruction call, FunctionInput input, int d) {
exists(Node n | n = callInput(call, input) and d > 0 |
// An argument or qualifier
hasOperandAndIndex(result, n.asOperand(), d)
or
@@ -85,7 +85,7 @@ private IndirectReturnOutNode getIndirectReturnOutNode(CallInstruction call, int
*/
bindingset[d]
Node callOutput(CallInstruction call, FunctionOutput output, int d) {
exists(DataFlow::Node n, int indirectionIndex |
exists(Node n, int indirectionIndex |
n = callOutputWithIndirectionIndex(call, output, indirectionIndex) and d > 0
|
// The return value

View File

@@ -1,6 +1,6 @@
private import cpp
private import semmle.code.cpp.ir.IR
private import SsaInternals as Ssa
private import SsaImpl as Ssa
/**
* A property provider that hides all instructions and operands that are not relevant for IR dataflow.

View File

@@ -2,7 +2,7 @@ private import cpp
private import semmle.code.cpp.ir.IR
private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
private import SsaInternals as Ssa
private import SsaImpl as Ssa
private import PrintIRUtilities
/**

View File

@@ -1,4 +1,4 @@
private import codeql.ssa.Ssa as SsaImplCommon
private import codeql.ssa.Ssa as Ssa
private import semmle.code.cpp.ir.IR
private import DataFlowUtil
private import DataFlowImplCommon as DataFlowImplCommon
@@ -12,7 +12,7 @@ private import semmle.code.cpp.ir.internal.IRCppLanguage
private import semmle.code.cpp.ir.dataflow.internal.ModelUtil
private import semmle.code.cpp.ir.implementation.raw.internal.TranslatedInitialization
private import DataFlowPrivate
import SsaInternalsCommon
import SsaImplCommon
private module SourceVariables {
cached
@@ -884,7 +884,7 @@ private predicate baseSourceVariableIsGlobal(
)
}
private module SsaInput implements SsaImplCommon::InputSig<Location> {
private module SsaInput implements Ssa::InputSig<Location> {
import InputSigCommon
import SourceVariables
@@ -958,9 +958,11 @@ class GlobalDef extends Definition {
GlobalLikeVariable getVariable() { result = impl.getVariable() }
}
private module SsaImpl = SsaImplCommon::Make<Location, SsaInput>;
private module SsaImpl = Ssa::Make<Location, SsaInput>;
private module DataFlowIntegrationInput implements SsaImpl::DataFlowIntegrationInputSig {
private import codeql.util.Boolean
class Expr extends Instruction {
Expr() {
exists(IRBlock bb, int i |
@@ -992,10 +994,14 @@ private module DataFlowIntegrationInput implements SsaImpl::DataFlowIntegrationI
result instanceof FalseEdge
}
class GuardValue = Boolean;
class Guard instanceof IRGuards::IRGuardCondition {
string toString() { result = super.toString() }
predicate hasBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
predicate hasValueBranchEdge(
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, GuardValue branch
) {
exists(EdgeKind kind |
super.getBlock() = bb1 and
kind = getConditionalEdge(branch) and
@@ -1003,12 +1009,14 @@ private module DataFlowIntegrationInput implements SsaImpl::DataFlowIntegrationI
)
}
predicate controlsBranchEdge(SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, boolean branch) {
this.hasBranchEdge(bb1, bb2, branch)
predicate valueControlsBranchEdge(
SsaInput::BasicBlock bb1, SsaInput::BasicBlock bb2, GuardValue branch
) {
this.hasValueBranchEdge(bb1, bb2, branch)
}
}
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, boolean branch) {
predicate guardDirectlyControlsBlock(Guard guard, SsaInput::BasicBlock bb, GuardValue branch) {
guard.(IRGuards::IRGuardCondition).controls(bb, branch)
}
@@ -1037,7 +1045,8 @@ module BarrierGuardWithIntParam<guardChecksNodeSig/4 guardChecksNode> {
}
private predicate guardChecks(
DataFlowIntegrationInput::Guard g, SsaImpl::Definition def, boolean branch, int indirectionIndex
DataFlowIntegrationInput::Guard g, SsaImpl::Definition def,
DataFlowIntegrationInput::GuardValue branch, int indirectionIndex
) {
exists(UseImpl use |
guardChecksNode(g, use.getNode(), branch, indirectionIndex) and
@@ -1116,9 +1125,11 @@ class PhiNode extends Definition instanceof SsaImpl::PhiNode {
/** An static single assignment (SSA) definition. */
class Definition extends SsaImpl::Definition {
// TODO: Include prior definitions of uncertain writes or rename predicate
// i.e. the disjunct `SsaImpl::uncertainWriteDefinitionInput(this, result)`
private Definition getAPhiInputOrPriorDefinition() { result = this.(PhiNode).getAnInput() }
private Definition getAPhiInputOrPriorDefinition() {
result = this.(PhiNode).getAnInput()
or
SsaImpl::uncertainWriteDefinitionInput(this, result)
}
/**
* Gets a definition that ultimately defines this SSA definition and is
@@ -1129,6 +1140,36 @@ class Definition extends SsaImpl::Definition {
not result instanceof PhiNode
}
/** Gets an `Operand` that represents a use of this definition. */
Operand getAUse() {
exists(SourceVariable sv, IRBlock bb, int i, UseImpl use |
ssaDefReachesRead(sv, this, bb, i) and
use.hasIndexInBlock(bb, i, sv) and
result = use.getNode().asOperand()
)
}
/**
* Gets an `Operand` that represents an indirect use of this definition.
*
* The use is indirect because the operand represents a pointer that points
* to the value written by this definition. For example in:
* ```cpp
* 1. int x = 42;
* 2. int* p = &x;
* ```
* There is an `ExplicitDefinition` corresponding to `x = 42` on line 1 and
* the definition has an indirect use on line 2 because `&x` points to the
* value that was defined by the definition.
*/
Operand getAnIndirectUse(int indirectionIndex) {
exists(SourceVariable sv, IRBlock bb, int i, UseImpl use |
ssaDefReachesRead(sv, this, bb, i) and
use.hasIndexInBlock(bb, i, sv) and
result = use.getNode().asIndirectOperand(indirectionIndex)
)
}
/**
* INTERNAL: Do not use.
*/
@@ -1161,4 +1202,63 @@ class Definition extends SsaImpl::Definition {
Type getUnspecifiedType() { result = this.getUnderlyingType().getUnspecifiedType() }
}
/**
* An SSA definition that corresponds to an explicit definition.
*/
class ExplicitDefinition extends Definition, SsaImpl::WriteDefinition {
DefImpl def;
ExplicitDefinition() {
exists(IRBlock bb, int i, SourceVariable sv |
this.definesAt(sv, bb, i) and
def.hasIndexInBlock(sv, bb, i)
)
}
/**
* Gets the `Instruction` computing the value that is written to the
* associated SSA variable by this SSA definition.
*
* If `this.getIndirectionIndex() = 0` (i.e., if `this` is an instance of
* `DirectExplicitDefinition`) then the SSA variable is present in the source
* code.
* However, if `this.getIndirectionIndex() > 0` (i.e., if `this` is an
* instance of `IndirectExplicitDefinition`) then the SSA variable associated
* with this definition represents the memory pointed to by a variable in the
* source code.
*/
Instruction getAssignedInstruction() { result = def.getValue().asInstruction() }
}
/**
* An explicit SSA definition that writes an indirect value to a pointer.
*
* For example in:
* ```cpp
* int x = 42; // (1)
* int* p = &x; // (2)
* ```
* There are three `ExplicitDefinition`:
* 1. A `DirectExplicitDefinition` at (1) which writes `42` to the SSA variable
* corresponding to `x`.
* 2. A `DirectExplicitDefinition` at (2) which writes `&x` to the SSA variable
* corresponding to `p`.
* 3. A `IndirectExplicitDefinition` at (2) which writes `*&x` (i.e., `x`) to
* the SSA variable corresponding to `*p`.
*/
class IndirectExplicitDefinition extends ExplicitDefinition {
IndirectExplicitDefinition() { this.getIndirectionIndex() > 0 }
}
/**
* An SSA definition that corresponds to an explicit definition.
*
* Unlike `ExplicitDefinition` this class does not include indirect
* explicit definition. See `IndirectExplicitDefinition` if you want to include
* those.
*/
class DirectExplicitDefinition extends ExplicitDefinition {
DirectExplicitDefinition() { this.getIndirectionIndex() = 0 }
}
import SsaCached

View File

@@ -5,7 +5,7 @@ private import semmle.code.cpp.models.interfaces.DataFlow
private import semmle.code.cpp.models.interfaces.SideEffect
private import DataFlowUtil
private import DataFlowPrivate
private import SsaInternals as Ssa
private import SsaImpl as Ssa
private import semmle.code.cpp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
private import semmle.code.cpp.ir.dataflow.FlowSteps

View File

@@ -26,6 +26,14 @@ private class IteratorTraits extends Class {
}
Type getIteratorType() { result = this.getTemplateArgument(0) }
Type getValueType() {
exists(TypedefType t |
this.getAMember() = t and
t.getName() = "value_type" and
result = t.getUnderlyingType()
)
}
}
/**
@@ -34,16 +42,13 @@ private class IteratorTraits extends Class {
*/
private class IteratorByTraits extends Iterator {
IteratorTraits trait;
IteratorByTraits() { trait.getIteratorType() = this }
override Type getValueType() {
exists(TypedefType t |
trait.getAMember() = t and
t.getName() = "value_type" and
result = t.getUnderlyingType()
)
IteratorByTraits() {
trait.getIteratorType() = this and
not trait.getValueType() = this
}
override Type getValueType() { result = trait.getValueType() }
}
/**

View File

@@ -1,3 +1,9 @@
## 1.4.5
### Minor Analysis Improvements
* The "Initialization code not run" query (`cpp/initialization-not-run`) no longer reports an alert on static global variables that have no dereference.
## 1.4.4
### Minor Analysis Improvements

View File

@@ -32,9 +32,18 @@ predicate called(Function f) {
exists(FunctionAccess fa | fa.getTarget() = f)
}
predicate staticWithoutDereference(GlobalVariable v) {
v.isStatic() and
not exists(VariableAccess va |
va = v.getAnAccess() and
dereferenced(va)
)
}
from GlobalVariable v
where
global(v) and
not staticWithoutDereference(v) and
not exists(VariableAccess lval |
v.getAnAccess() = lval and
lval.isUsedAsLValue() and

View File

@@ -11,7 +11,7 @@ It is not safe to assume that a year is 365 days long.</p>
<recommendation>
<p>Determine whether the time span in question contains a leap day, then perform the calculation using the correct number
of days. Alternatively, use an established library routine that already contains correct leap year logic.</p>
of days. Alternatively, use an established library routine that already contains correct leap year logic.</p>
</recommendation>
<references>

View File

@@ -4,8 +4,8 @@
* value of 365, it may be a sign that leap years are not taken
* into account.
* @kind problem
* @problem.severity warning
* @id cpp/leap-year/adding-365-days-per-year
* @problem.severity error
* @id cpp/microsoft/public/leap-year/adding-365-days-per-year
* @precision medium
* @tags leap-year
* correctness
@@ -13,11 +13,13 @@
import cpp
import LeapYear
import semmle.code.cpp.dataflow.new.DataFlow
from Expr source, Expr sink
where
PossibleYearArithmeticOperationCheckFlow::flow(DataFlow::exprNode(source),
DataFlow::exprNode(sink))
select sink,
"An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios.",
source, source.toString()
"$@: This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios.",
sink.getEnclosingFunction(), sink.getEnclosingFunction().toString(), source, source.toString(),
sink, sink.toString()

View File

@@ -0,0 +1,17 @@
/**
* @name Leap Year Invalid Check (AntiPattern 5)
* @description An expression is used to check a year is presumably a leap year, but the conditions used are insufficient.
* @kind problem
* @problem.severity warning
* @id cpp/microsoft/public/leap-year/invalid-leap-year-check
* @precision medium
* @tags leap-year
* correctness
*/
import cpp
import LeapYear
from Mod4CheckedExpr exprMod4
where not exists(ExprCheckLeapYear lyCheck | lyCheck.getAChild*() = exprMod4)
select exprMod4, "Possible Insufficient Leap Year check (AntiPattern 5)"

View File

@@ -3,7 +3,7 @@
*/
import cpp
import semmle.code.cpp.ir.dataflow.TaintTracking
import semmle.code.cpp.dataflow.new.TaintTracking
import semmle.code.cpp.commons.DateTime
/**
@@ -41,6 +41,271 @@ class CheckForLeapYearOperation extends Expr {
}
}
bindingset[modVal]
Expr moduloCheckEQ_0(EQExpr eq, int modVal) {
exists(RemExpr rem | rem = eq.getLeftOperand() |
result = rem.getLeftOperand() and
rem.getRightOperand().getValue().toInt() = modVal
) and
eq.getRightOperand().getValue().toInt() = 0
}
bindingset[modVal]
Expr moduloCheckNEQ_0(NEExpr neq, int modVal) {
exists(RemExpr rem | rem = neq.getLeftOperand() |
result = rem.getLeftOperand() and
rem.getRightOperand().getValue().toInt() = modVal
) and
neq.getRightOperand().getValue().toInt() = 0
}
/**
* Returns if the two expressions resolve to the same value, albeit it is a fuzzy attempt.
* SSA is not fit for purpose here as calls break SSA equivalence.
*/
predicate exprEq_propertyPermissive(Expr e1, Expr e2) {
not e1 = e2 and
(
DataFlow::localFlow(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
or
if e1 instanceof ThisExpr and e2 instanceof ThisExpr
then any()
else
/* If it's a direct Access, check that the target is the same. */
if e1 instanceof Access
then e1.(Access).getTarget() = e2.(Access).getTarget()
else
/* If it's a Call, compare qualifiers and only permit no-argument Calls. */
if e1 instanceof Call
then
e1.(Call).getTarget() = e2.(Call).getTarget() and
e1.(Call).getNumberOfArguments() = 0 and
e2.(Call).getNumberOfArguments() = 0 and
if e1.(Call).hasQualifier()
then exprEq_propertyPermissive(e1.(Call).getQualifier(), e2.(Call).getQualifier())
else any()
else
/* If it's a binaryOperation, compare op and recruse */
if e1 instanceof BinaryOperation
then
e1.(BinaryOperation).getOperator() = e2.(BinaryOperation).getOperator() and
exprEq_propertyPermissive(e1.(BinaryOperation).getLeftOperand(),
e2.(BinaryOperation).getLeftOperand()) and
exprEq_propertyPermissive(e1.(BinaryOperation).getRightOperand(),
e2.(BinaryOperation).getRightOperand())
else
// Otherwise fail (and permit the raising of a finding)
if e1 instanceof Literal
then e1.(Literal).getValue() = e2.(Literal).getValue()
else none()
)
}
/**
* An expression that is the subject of a mod-4 check.
* ie `expr % 4 == 0`
*/
class Mod4CheckedExpr extends Expr {
Mod4CheckedExpr() { exists(Expr e | e = moduloCheckEQ_0(this, 4)) }
}
/**
* Year Div of 100 not equal to 0:
* - `year % 100 != 0`
* - `!(year % 100 == 0)`
*/
abstract class ExprCheckCenturyComponentDiv100 extends Expr {
abstract Expr getYearExpr();
}
/**
* The normal form of the expression `year % 100 != 0`.
*/
final class ExprCheckCenturyComponentDiv100Normative extends ExprCheckCenturyComponentDiv100 {
ExprCheckCenturyComponentDiv100Normative() { exists(moduloCheckNEQ_0(this, 100)) }
override Expr getYearExpr() { result = moduloCheckNEQ_0(this, 100) }
}
/**
* The inverted form of the expression `year % 100 != 0`, ie `!(year % 100 == 0)`
*/
final class ExprCheckCenturyComponentDiv100Inverted extends ExprCheckCenturyComponentDiv100, NotExpr
{
ExprCheckCenturyComponentDiv100Inverted() { exists(moduloCheckEQ_0(this.getOperand(), 100)) }
override Expr getYearExpr() { result = moduloCheckEQ_0(this.getOperand(), 100) }
}
/**
* A check that an expression is divisible by 400 or not
* - `(year % 400 == 0)`
* - `!(year % 400 != 0)`
*/
abstract class ExprCheckCenturyComponentDiv400 extends Expr {
abstract Expr getYearExpr();
}
/**
* The normative form of expression is divisible by 400:
* ie `year % 400 == 0`
*/
final class ExprCheckCenturyComponentDiv400Normative extends ExprCheckCenturyComponentDiv400 {
ExprCheckCenturyComponentDiv400Normative() { exists(moduloCheckEQ_0(this, 400)) }
override Expr getYearExpr() {
exists(Expr e |
e = moduloCheckEQ_0(this, 400) and
(
if e instanceof ConvertedYearByOffset
then result = e.(ConvertedYearByOffset).getYearOperand()
else result = e
)
)
}
}
/**
* An arithmetic operation that seemingly converts an operand between time formats.
*/
class ConvertedYearByOffset extends BinaryArithmeticOperation {
ConvertedYearByOffset() {
this.getAnOperand().getValue().toInt() instanceof TimeFormatConversionOffset
}
Expr getYearOperand() {
this.getLeftOperand().getValue().toInt() instanceof TimeFormatConversionOffset and
result = this.getRightOperand()
or
this.getRightOperand().getValue().toInt() instanceof TimeFormatConversionOffset and
result = this.getLeftOperand()
}
}
/**
* A flow configuration to track DataFlow from a `CovertedYearByOffset` to some `StructTmLeapYearFieldAccess`.
*/
module LocalConvertedYearByOffsetToLeapYearCheckFlowConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node n) { not n.asExpr() instanceof ConvertedYearByOffset }
predicate isSink(DataFlow::Node n) { n.asExpr() instanceof StructTmLeapYearFieldAccess }
}
module LocalConvertedYearByOffsetToLeapYearCheckFlow =
DataFlow::Global<LocalConvertedYearByOffsetToLeapYearCheckFlowConfig>;
/**
* The set of ints (or strings) which represent a value that is typically used to convert between time data types.
*/
final class TimeFormatConversionOffset extends int {
TimeFormatConversionOffset() {
this =
[
1900, // tm_year represents years since 1900
1970, // converting from/to Unix epoch
2000, // some systems may use 2000 for 2-digit year conversions
]
}
}
/**
* The inverted form of expression is divisible by 400:
* ie `!(year % 400 != 0)`
*/
final class ExprCheckCenturyComponentDiv400Inverted extends ExprCheckCenturyComponentDiv400, NotExpr
{
ExprCheckCenturyComponentDiv400Inverted() { exists(moduloCheckNEQ_0(this.getOperand(), 400)) }
override Expr getYearExpr() { result = moduloCheckNEQ_0(this.getOperand(), 400) }
}
/**
* The Century component of a Leap-Year guard
*/
class ExprCheckCenturyComponent extends LogicalOrExpr {
ExprCheckCenturyComponent() {
exists(ExprCheckCenturyComponentDiv400 exprDiv400, ExprCheckCenturyComponentDiv100 exprDiv100 |
this.getAnOperand() = exprDiv100 and
this.getAnOperand() = exprDiv400 and
exprEq_propertyPermissive(exprDiv100.getYearExpr(), exprDiv400.getYearExpr())
)
}
Expr getYearExpr() {
exists(ExprCheckCenturyComponentDiv400 exprDiv400 |
this.getAnOperand() = exprDiv400 and
result = exprDiv400.getYearExpr()
)
}
}
/**
* A **Valid** Leap year check expression.
*/
abstract class ExprCheckLeapYear extends Expr { }
/**
* A valid Leap-Year guard expression of the following form:
* `dt.Year % 4 == 0 && (dt.Year % 100 != 0 || dt.Year % 400 == 0)`
*/
final class ExprCheckLeapYearFormA extends ExprCheckLeapYear, LogicalAndExpr {
ExprCheckLeapYearFormA() {
exists(Expr e, ExprCheckCenturyComponent centuryCheck |
e = moduloCheckEQ_0(this.getLeftOperand(), 4) and
centuryCheck = this.getAnOperand().getAChild*() and
exprEq_propertyPermissive(e, centuryCheck.getYearExpr())
)
}
}
/**
* A valid Leap-Year guard expression of the following forms:
* `year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)`
* `(year + 1900) % 400 == 0 || (year % 100 != 0 && year % 4 == 0)`
*/
final class ExprCheckLeapYearFormB extends ExprCheckLeapYear, LogicalOrExpr {
ExprCheckLeapYearFormB() {
exists(VariableAccess va1, VariableAccess va2, VariableAccess va3 |
va1 = moduloCheckEQ_0(this.getAnOperand(), 400) and
va2 = moduloCheckNEQ_0(this.getAnOperand().(LogicalAndExpr).getAnOperand(), 100) and
va3 = moduloCheckEQ_0(this.getAnOperand().(LogicalAndExpr).getAnOperand(), 4) and
// The 400-leap year check may be offset by [1900,1970,2000].
exists(Expr va1_subExpr | va1_subExpr = va1.getAChild*() |
exprEq_propertyPermissive(va1_subExpr, va2) and
exprEq_propertyPermissive(va2, va3)
)
)
}
}
Expr leapYearOpEnclosingElement(CheckForLeapYearOperation op) { result = op.getEnclosingElement() }
/**
* A value that resolves as a constant integer that represents some normalization or conversion between date types.
*/
pragma[inline]
private predicate isNormalizationPrimitiveValue(Expr e) {
e.getValue().toInt() = [1900, 2000, 1980, 80]
}
/**
* A normalization operation is an expression that is merely attempting to convert between two different datetime schemes,
* and does not apply any additional mutation to the represented value.
*/
pragma[inline]
predicate isNormalizationOperation(Expr e) {
isNormalizationPrimitiveValue([e, e.(Operation).getAChild()])
or
// Special case for transforming marshaled 2-digit year date:
// theTime.wYear += 100*value;
e.(Operation).getAChild().(MulExpr).getValue().toInt() = 100
}
/**
* Get the field accesses used in a `ExprCheckLeapYear` expression.
*/
LeapYearFieldAccess leapYearCheckFieldAccess(ExprCheckLeapYear a) { result = a.getAChild*() }
/**
* A `YearFieldAccess` that would represent an access to a year field on a struct and is used for arguing about leap year calculations.
*/
@@ -73,48 +338,7 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
this.isModified() and
exists(Operation op |
op.getAnOperand() = this and
(
op instanceof AssignArithmeticOperation and
not (
op.getAChild().getValue().toInt() = 1900
or
op.getAChild().getValue().toInt() = 2000
or
op.getAChild().getValue().toInt() = 1980
or
op.getAChild().getValue().toInt() = 80
or
// Special case for transforming marshaled 2-digit year date:
// theTime.wYear += 100*value;
exists(MulExpr mulBy100 | mulBy100 = op.getAChild() |
mulBy100.getAChild().getValue().toInt() = 100
)
)
or
exists(BinaryArithmeticOperation bao |
bao = op.getAnOperand() and
// we're specifically interested in calculations that update the existing
// value (like `x = x + 1`), so look for a child `YearFieldAccess`.
bao.getAChild*() instanceof YearFieldAccess and
not (
bao.getAChild().getValue().toInt() = 1900
or
bao.getAChild().getValue().toInt() = 2000
or
bao.getAChild().getValue().toInt() = 1980
or
bao.getAChild().getValue().toInt() = 80
or
// Special case for transforming marshaled 2-digit year date:
// theTime.wYear += 100*value;
exists(MulExpr mulBy100 | mulBy100 = op.getAChild() |
mulBy100.getAChild().getValue().toInt() = 100
)
)
)
or
op instanceof CrementOperation
)
not isNormalizationOperation(op)
)
}
@@ -155,9 +379,7 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
// but these centurial years are leap years if they are exactly divisible by 400
//
// https://aa.usno.navy.mil/faq/docs/calendars.php
this.isUsedInMod4Operation() and
this.additionalModulusCheckForLeapYear(400) and
this.additionalModulusCheckForLeapYear(100)
this = leapYearCheckFieldAccess(_)
}
}
@@ -175,19 +397,9 @@ class StructTmLeapYearFieldAccess extends LeapYearFieldAccess {
StructTmLeapYearFieldAccess() { this.getTarget().getName() = "tm_year" }
override predicate isUsedInCorrectLeapYearCheck() {
this.isUsedInMod4Operation() and
this.additionalModulusCheckForLeapYear(400) and
this.additionalModulusCheckForLeapYear(100) and
// tm_year represents years since 1900
(
this.additionalAdditionOrSubstractionCheckForLeapYear(1900)
or
// some systems may use 2000 for 2-digit year conversions
this.additionalAdditionOrSubstractionCheckForLeapYear(2000)
or
// converting from/to Unix epoch
this.additionalAdditionOrSubstractionCheckForLeapYear(1970)
)
this = leapYearCheckFieldAccess(_) and
/* There is some data flow from some conversion arithmetic to this expression. */
LocalConvertedYearByOffsetToLeapYearCheckFlow::flow(_, DataFlow::exprNode(this))
}
}
@@ -206,10 +418,10 @@ class ChecksForLeapYearFunctionCall extends FunctionCall {
}
/**
* Data flow configuration for finding a variable access that would flow into
* A `DataFlow` configuraiton for finding a variable access that would flow into
* a function call that includes an operation to check for leap year.
*/
private module LeapYearCheckConfig implements DataFlow::ConfigSig {
private module LeapYearCheckFlowConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof VariableAccess }
predicate isSink(DataFlow::Node sink) {
@@ -217,11 +429,10 @@ private module LeapYearCheckConfig implements DataFlow::ConfigSig {
}
}
module LeapYearCheckFlow = DataFlow::Global<LeapYearCheckConfig>;
module LeapYearCheckFlow = DataFlow::Global<LeapYearCheckFlowConfig>;
/**
* Data flow configuration for finding an operation with hardcoded 365 that will flow into
* a `FILEINFO` field.
* A `DataFlow` configuration for finding an operation with hardcoded 365 that will flow into a `_FILETIME` field.
*/
private module FiletimeYearArithmeticOperationCheckConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
@@ -246,46 +457,72 @@ module FiletimeYearArithmeticOperationCheckFlow =
DataFlow::Global<FiletimeYearArithmeticOperationCheckConfig>;
/**
* Taint configuration for finding an operation with hardcoded 365 that will flow into any known date/time field.
* A `DataFlow` configuration for finding an operation with hardcoded 365 that will flow into any known date/time field.
*/
private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
exists(Operation op | op = source.asExpr() |
op.getAChild*().getValue().toInt() = 365 and
(
not op.getParent() instanceof Expr or
op.getParent() instanceof Assignment
)
)
}
predicate isBarrierIn(DataFlow::Node node) { isSource(node) }
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
// flow from anything on the RHS of an assignment to a time/date structure to that
// assignment.
exists(StructLikeClass dds, FieldAccess fa, Assignment aexpr, Expr e |
e = node1.asExpr() and
fa = node2.asExpr()
|
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
fa.getQualifier().getUnderlyingType() = dds and
aexpr.getLValue() = fa and
aexpr.getRValue().getAChild*() = e
)
// NOTE: addressing current issue with new IR dataflow, where
// constant folding occurs before dataflow nodes are associated
// with the constituent literals.
source.asExpr().getAChild*().getValue().toInt() = 365 and
not exists(DataFlow::Node parent | parent.asExpr().getAChild+() = source.asExpr())
}
predicate isSink(DataFlow::Node sink) {
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
aexpr.getRValue() = sink.asExpr()
|
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
fa.getQualifier().getUnderlyingType() = dds and
fa.isModified() and
aexpr.getLValue() = fa
aexpr.getLValue() = fa and
sink.asExpr() = aexpr.getRValue()
)
}
}
module PossibleYearArithmeticOperationCheckFlow =
TaintTracking::Global<PossibleYearArithmeticOperationCheckConfig>;
/**
* A `YearFieldAccess` that is modifying the year by any arithmetic operation.
*
* NOTE:
* To change this class to work for general purpose date transformations that do not check the return value,
* make the following changes:
* - change `extends LeapYearFieldAccess` to `extends FieldAccess`.
* - change `this.isModifiedByArithmeticOperation()` to `this.isModified()`.
* Expect a lower precision for a general purpose version.
*/
class DateStructModifiedFieldAccess extends LeapYearFieldAccess {
DateStructModifiedFieldAccess() {
exists(Field f, StructLikeClass struct |
f.getAnAccess() = this and
struct.getAField() = f and
struct.getUnderlyingType() instanceof UnpackedTimeType and
this.isModifiedByArithmeticOperation()
)
}
}
/**
* This is a list of APIs that will get the system time, and therefore guarantee that the value is valid.
*/
class SafeTimeGatheringFunction extends Function {
SafeTimeGatheringFunction() {
this.getQualifiedName() = ["GetFileTime", "GetSystemTime", "NtQuerySystemTime"]
}
}
/**
* This list of APIs should check for the return value to detect problems during the conversion.
*/
class TimeConversionFunction extends Function {
TimeConversionFunction() {
this.getQualifiedName() =
[
"FileTimeToSystemTime", "SystemTimeToFileTime", "SystemTimeToTzSpecificLocalTime",
"SystemTimeToTzSpecificLocalTimeEx", "TzSpecificLocalTimeToSystemTime",
"TzSpecificLocalTimeToSystemTimeEx", "RtlLocalTimeToSystemTime",
"RtlTimeToSecondsSince1970", "_mkgmtime"
]
}
}

View File

@@ -0,0 +1,26 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<include src="LeapYear.inc.qhelp" />
<p>This anti-pattern occurs when a developer uses conditional logic to execute a different path of code for a leap year than for a common year, without fully testing both code paths.</p>
<p>Though using a framework or library's leap year function is better than manually calculating the leap year (as described in anti-pattern 5), it can still be a source of errors if the result is used to execute a different code path. The bug is especially easy to be masked if the year is derived from the current time of the system clock. See Prevention Measures for techniques to avoid this bug.</p>
</overview>
<recommendation>
<ul>
<li>Avoid using conditional logic that creates a separate branch in your code for leap year.</li>
<li>Ensure your code is testable, and test how it will behave when presented with leap year dates of February 29th and December 31st as inputs.</li>
</ul>
</recommendation>
<example>
<p>Note in the following examples, that year, month, and day might instead be .wYear, .wMonth, and .wDay fields of a SYSTEMTIME structure, or might be .tm_year, .tm_mon, and .tm_mday fields of a struct tm.</p>
<sample src="examples/LeapYearConditionalLogicBad.c" />
</example>
<references>
<li>NASA / Goddard Space Flight Center - <a href="https://eclipse.gsfc.nasa.gov/SEhelp/calendars.html">Calendars</a></li>
<li>Wikipedia - <a href="https://en.wikipedia.org/wiki/Leap_year_bug"> Leap year bug</a> </li>
<li>Microsoft Azure blog - <a href="https://azure.microsoft.com/en-us/blog/is-your-code-ready-for-the-leap-year/"> Is your code ready for the leap year?</a> </li>
</references>
</qhelp>

View File

@@ -0,0 +1,28 @@
/**
* @name Leap Year Conditional Logic (AntiPattern 7)
* @description Conditional logic is present for leap years and common years, potentially leading to untested code pathways.
* @kind problem
* @problem.severity warning
* @id cpp/microsoft/public/leap-year/conditional-logic-branches
* @precision medium
* @tags leap-year
* correctness
*/
import cpp
import LeapYear
import semmle.code.cpp.dataflow.new.DataFlow
class IfStmtLeapYearCheck extends IfStmt {
IfStmtLeapYearCheck() {
this.hasElse() and
exists(ExprCheckLeapYear lyCheck, DataFlow::Node source, DataFlow::Node sink |
source.asExpr() = lyCheck and
sink.asExpr() = this.getCondition() and
DataFlow::localFlow(source, sink)
)
}
}
from IfStmtLeapYearCheck lyCheckIf
select lyCheckIf, "Leap Year conditional statement may have untested code paths"

View File

@@ -15,10 +15,10 @@
</recommendation>
<example>
<p>In this example, we are adding 1 year to the current date. This may work most of the time, but on any given February 29th, the resulting value will be invalid.</p>
<sample src="UncheckedLeapYearAfterYearModificationBad.c" />
<sample src="examples/UncheckedLeapYearAfterYearModificationBad.c" />
<p>To fix this bug, check the result for leap year.</p>
<sample src="UncheckedLeapYearAfterYearModificationGood.c" />
<sample src="examples/UncheckedLeapYearAfterYearModificationGood.c" />
</example>
<references>

View File

@@ -1,9 +1,9 @@
/**
* @name Year field changed using an arithmetic operation without checking for leap year
* @name Year field changed using an arithmetic operation without checking for leap year (AntiPattern 1)
* @description A field that represents a year is being modified by an arithmetic operation, but no proper check for leap years can be detected afterwards.
* @kind problem
* @problem.severity warning
* @id cpp/leap-year/unchecked-after-arithmetic-year-modification
* @id cpp/microsoft/public/leap-year/unchecked-after-arithmetic-year-modification
* @precision medium
* @tags leap-year
* correctness
@@ -12,13 +12,16 @@
import cpp
import LeapYear
from Variable var, LeapYearFieldAccess yfa
where
exists(VariableAccess va |
/**
* Holds if there is no known leap-year verification for the given `YearWriteOp`.
* Binds the `var` argument to the qualifier of the `ywo` argument.
*/
bindingset[ywo]
predicate isYearModifedWithoutExplicitLeapYearCheck(Variable var, YearWriteOp ywo) {
exists(VariableAccess va, YearFieldAccess yfa |
yfa = ywo.getYearAccess() and
yfa.getQualifier() = va and
var.getAnAccess() = va and
// The year is modified with an arithmetic operation. Avoid values that are likely false positives
yfa.isModifiedByArithmeticOperationNotForNormalization() and
// Avoid false positives
not (
// If there is a local check for leap year after the modification
@@ -41,8 +44,10 @@ where
LeapYearCheckFlow::flow(DataFlow::exprNode(yfacheck), DataFlow::exprNode(fc.getAnArgument()))
)
or
// If there is a successor or predecessor that sets the month = 1
exists(MonthFieldAccess mfa, AssignExpr ae |
// If there is a successor or predecessor that sets the month or day to a fixed value
exists(FieldAccess mfa, AssignExpr ae, int val |
mfa instanceof MonthFieldAccess or mfa instanceof DayFieldAccess
|
mfa.getQualifier() = var.getAnAccess() and
mfa.isModified() and
(
@@ -50,10 +55,87 @@ where
yfa.getBasicBlock() = mfa.getBasicBlock().getASuccessor+()
) and
ae = mfa.getEnclosingElement() and
ae.getAnOperand().getValue().toInt() = 1
ae.getAnOperand().getValue().toInt() = val
)
)
)
select yfa,
"Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found.",
yfa.getTarget(), yfa.getTarget().toString(), var, var.toString()
}
/**
* The set of all write operations to the Year field of a date struct.
*/
abstract class YearWriteOp extends Operation {
/** Extracts the access to the Year field */
abstract YearFieldAccess getYearAccess();
/** Get the expression which represents the new value. */
abstract Expr getMutationExpr();
}
/**
* A unary operation (Crement) performed on a Year field.
*/
class YearWriteOpUnary extends YearWriteOp, UnaryOperation {
YearWriteOpUnary() { this.getOperand() instanceof YearFieldAccess }
override YearFieldAccess getYearAccess() { result = this.getOperand() }
override Expr getMutationExpr() { result = this }
}
/**
* An assignment operation or mutation on the Year field of a date object.
*/
class YearWriteOpAssignment extends YearWriteOp, Assignment {
YearWriteOpAssignment() { this.getLValue() instanceof YearFieldAccess }
override YearFieldAccess getYearAccess() { result = this.getLValue() }
override Expr getMutationExpr() {
// Note: may need to use DF analysis to pull out the original value,
// if there is excessive false positives.
if this.getOperator() = "="
then
exists(DataFlow::Node source, DataFlow::Node sink |
sink.asExpr() = this.getRValue() and
OperationToYearAssignmentFlow::flow(source, sink) and
result = source.asExpr()
)
else result = this
}
}
/**
* A DataFlow configuration for identifying flows from some non trivial access or literal
* to the Year field of a date object.
*/
module OperationToYearAssignmentConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node n) {
not n.asExpr() instanceof Access and
not n.asExpr() instanceof Literal
}
predicate isSink(DataFlow::Node n) {
exists(Assignment a |
a.getLValue() instanceof YearFieldAccess and
a.getRValue() = n.asExpr()
)
}
}
module OperationToYearAssignmentFlow = DataFlow::Global<OperationToYearAssignmentConfig>;
from Variable var, YearWriteOp ywo, Expr mutationExpr
where
mutationExpr = ywo.getMutationExpr() and
isYearModifedWithoutExplicitLeapYearCheck(var, ywo) and
not isNormalizationOperation(mutationExpr) and
not ywo instanceof AddressOfExpr and
not exists(Call c, TimeConversionFunction f | f.getACallToThisFunction() = c |
c.getAnArgument().getAChild*() = var.getAnAccess() and
ywo.getASuccessor*() = c
)
select ywo,
"$@: Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found.",
ywo.getEnclosingFunction(), ywo.getEnclosingFunction().toString(),
ywo.getYearAccess().getTarget(), ywo.getYearAccess().getTarget().toString(), var, var.toString()

View File

@@ -27,10 +27,10 @@
</recommendation>
<example>
<p>In this example, we are adding 1 year to the current date. This may work most of the time, but on any given February 29th, the resulting value will be invalid.</p>
<sample src="UncheckedLeapYearAfterYearModificationBad.c" />
<sample src="examples/UncheckedLeapYearAfterYearModificationBad.c" />
<p>To fix this bug, you must verify the return value for <code>SystemTimeToFileTime</code> and handle any potential error accordingly.</p>
<sample src="UncheckedLeapYearAfterYearModificationGood.c" />
<sample src="examples/UncheckedLeapYearAfterYearModificationGood.c" />
</example>
<references>

View File

@@ -1,11 +1,11 @@
/**
* @name Unchecked return value for time conversion function
* @name Unchecked return value for time conversion function (AntiPattern 6)
* @description When the return value of a fallible time conversion function is
* not checked for failure, its output parameters may contain
* invalid dates.
* @kind problem
* @problem.severity warning
* @id cpp/leap-year/unchecked-return-value-for-time-conversion-function
* @id cpp/microsoft/public/leap-year/unchecked-return-value-for-time-conversion-function
* @precision medium
* @tags leap-year
* correctness
@@ -14,51 +14,6 @@
import cpp
import LeapYear
/**
* A `YearFieldAccess` that is modifying the year by any arithmetic operation.
*
* NOTE:
* To change this class to work for general purpose date transformations that do not check the return value,
* make the following changes:
* - change `extends LeapYearFieldAccess` to `extends FieldAccess`.
* - change `this.isModifiedByArithmeticOperation()` to `this.isModified()`.
* Expect a lower precision for a general purpose version.
*/
class DateStructModifiedFieldAccess extends LeapYearFieldAccess {
DateStructModifiedFieldAccess() {
exists(Field f, StructLikeClass struct |
f.getAnAccess() = this and
struct.getAField() = f and
struct.getUnderlyingType() instanceof UnpackedTimeType and
this.isModifiedByArithmeticOperation()
)
}
}
/**
* This is a list of APIs that will get the system time, and therefore guarantee that the value is valid.
*/
class SafeTimeGatheringFunction extends Function {
SafeTimeGatheringFunction() {
this.getQualifiedName() = ["GetFileTime", "GetSystemTime", "NtQuerySystemTime"]
}
}
/**
* This list of APIs should check for the return value to detect problems during the conversion.
*/
class TimeConversionFunction extends Function {
TimeConversionFunction() {
this.getQualifiedName() =
[
"FileTimeToSystemTime", "SystemTimeToFileTime", "SystemTimeToTzSpecificLocalTime",
"SystemTimeToTzSpecificLocalTimeEx", "TzSpecificLocalTimeToSystemTime",
"TzSpecificLocalTimeToSystemTimeEx", "RtlLocalTimeToSystemTime",
"RtlTimeToSecondsSince1970", "_mkgmtime"
]
}
}
from FunctionCall fcall, TimeConversionFunction trf, Variable var
where
fcall = trf.getACallToThisFunction() and
@@ -104,5 +59,6 @@ where
)
)
select fcall,
"Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe.",
trf, trf.getQualifiedName().toString(), var, var.getName()
"$@: Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe.",
fcall.getEnclosingFunction(), fcall.getEnclosingFunction().toString(), trf,
trf.getQualifiedName().toString(), var, var.getName()

View File

@@ -16,15 +16,15 @@
</recommendation>
<example>
<p>In this example, we are allocating 365 integers, one for each day of the year. This code will fail on a leap year, when there are 366 days.</p>
<sample src="UnsafeArrayForDaysOfYearBad.c" />
<sample src="examples/UnsafeArrayForDaysOfYearBad.c" />
<p>When using arrays, allocate the correct number of elements to match the year.</p>
<sample src="UnsafeArrayForDaysOfYearGood.c" />
<sample src="examples/UnsafeArrayForDaysOfYearGood.c" />
</example>
<references>
<li>NASA / Goddard Space Flight Center - <a href="https://eclipse.gsfc.nasa.gov/SEhelp/calendars.html">Calendars</a></li>
<li>Wikipedia - <a href="https://en.wikipedia.org/wiki/Leap_year_bug"> Leap year bug</a> </li>
<li>Wikipedia - <a href="https://en.wikipedia.org/wiki/Leap_year_bug"> Leap year bug</a></li>
<li>Microsoft Azure blog - <a href="https://azure.microsoft.com/en-us/blog/is-your-code-ready-for-the-leap-year/"> Is your code ready for the leap year?</a> </li>
</references>
</qhelp>

View File

@@ -1,41 +1,62 @@
/**
* @name Unsafe array for days of the year
* @name Unsafe array for days of the year (AntiPattern 4)
* @description An array of 365 items typically indicates one entry per day of the year, but without considering leap years, which would be 366 days.
* An access on a leap year could result in buffer overflow bugs.
* @kind problem
* @problem.severity warning
* @id cpp/leap-year/unsafe-array-for-days-of-the-year
* @id cpp/microsoft/public/leap-year/unsafe-array-for-days-of-the-year
* @precision low
* @tags security
* leap-year
* @tags leap-year
* correctness
*/
import cpp
class LeapYearUnsafeDaysOfTheYearArrayType extends ArrayType {
LeapYearUnsafeDaysOfTheYearArrayType() { this.getArraySize() = 365 }
}
/* Note: We used to have a `LeapYearUnsafeDaysOfTheYearArrayType` class which was the
set of ArrayType that had a fixed length of 365. However, to eliminate false positives,
we use `isElementAnArrayOfFixedSize` that *also* finds arrays of 366 items, where the programmer
has also catered for leap years.
So, instead of `instanceof` checks, for simplicity, we simply pass in 365/366 as integers as needed.
*/
from Element element, string allocType
where
bindingset[size]
predicate isElementAnArrayOfFixedSize(
Element element, Type t, Declaration f, string allocType, int size
) {
exists(NewArrayExpr nae |
element = nae and
nae.getAllocatedType() instanceof LeapYearUnsafeDaysOfTheYearArrayType and
allocType = "an array allocation"
nae.getAllocatedType().(ArrayType).getArraySize() = size and
allocType = "an array allocation" and
f = nae.getEnclosingFunction() and
t = nae.getAllocatedType().(ArrayType).getBaseType()
)
or
exists(Variable var |
var = element and
var.getType() instanceof LeapYearUnsafeDaysOfTheYearArrayType and
allocType = "an array allocation"
var.getType().(ArrayType).getArraySize() = size and
allocType = "an array allocation" and
f = var and
t = var.getType().(ArrayType).getBaseType()
)
or
exists(ConstructorCall cc |
element = cc and
cc.getTarget().hasName("vector") and
cc.getArgument(0).getValue().toInt() = 365 and
allocType = "a std::vector allocation"
cc.getArgument(0).getValue().toInt() = size and
allocType = "a std::vector allocation" and
f = cc.getEnclosingFunction() and
t = cc.getTarget().getDeclaringType()
)
}
from Element element, string allocType, Declaration f, Type t
where
isElementAnArrayOfFixedSize(element, t, f, allocType, 365) and
not exists(Element element2, Declaration f2 |
isElementAnArrayOfFixedSize(element2, t, f2, _, 366) and
if f instanceof Function then f = f2 else f.getParentScope() = f2.getParentScope()
)
select element,
"There is " + allocType +
" with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios."
"$@: There is " + allocType +
" with a hard-coded set of 365 elements, which may indicate the number of days in a year without considering leap year scenarios.",
f, f.toString()

View File

@@ -0,0 +1,21 @@
// Checking for leap year
bool isLeapYear = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
if (isLeapYear)
{
// untested path
}
else
{
// tested path
}
// Checking specifically for the leap day
if (month == 2 && day == 29) // (or 1 with a tm_mon value)
{
// untested path
}
else
{
// tested path
}

View File

@@ -0,0 +1,20 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Checking for overflow of an addition by comparing against one of the arguments of the addition fails if the size of all the argument types are smaller than 4 bytes. This is because the result of the addition is promoted to a 4 byte int.</p>
</overview>
<recommendation>
<p>Check the overflow by comparing the addition against a value that is at least 4 bytes.</p>
</recommendation>
<example>
<p>In this example, the result of the comparison will result in an integer overflow.</p>
<sample src="BadOverflowGuardBadCode.c" />
<p>To fix the bug, check the overflow by comparing the addition against a value that is at least 4 bytes.</p>
<sample src="BadOverflowGuardGoodCode.c" />
</example>
</qhelp>

View File

@@ -0,0 +1,31 @@
/**
* @name Bad overflow check
* @description Checking for overflow of an addition by comparing against one
* of the arguments of the addition fails if the size of all the
* argument types are smaller than 4 bytes. This is because the
* result of the addition is promoted to a 4 byte int.
* @kind problem
* @problem.severity error
* @tags security
* external/cwe/cwe-190
* external/cwe/cwe-191
* @id cpp/microsoft/public/badoverflowguard
*/
import cpp
/*
* Example:
*
* uint16 v, uint16 b
* if ((v + b < v) <-- bad check for overflow
*/
from AddExpr a, Variable v, RelationalOperation cmp
where
a.getAnOperand() = v.getAnAccess() and
forall(Expr op | op = a.getAnOperand() | op.getType().getSize() < 4) and
cmp.getAnOperand() = a and
cmp.getAnOperand() = v.getAnAccess() and
not a.getExplicitlyConverted().getType().getSize() < 4
select cmp, "Bad overflow check"

View File

@@ -0,0 +1,9 @@
unsigned short CheckForInt16OverflowBadCode(unsigned short v, unsigned short b)
{
if (v + b < v) // BUG: "v + b" will be promoted to 32 bits
{
// ... do something
}
return v + b;
}

View File

@@ -0,0 +1,9 @@
unsigned short CheckForInt16OverflowCorrectCode(unsigned short v, unsigned short b)
{
if (v + b > 0x00FFFF)
{
// ... do something
}
return v + b;
}

View File

@@ -0,0 +1,29 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p><code>RtlCompareMemory</code> routine compares two blocks of memory and returns the number of bytes that match, not a boolean value indicating a full comparison like <code>RtlEqualMemory</code> does.</p>
<p>This query detects the return value of <code>RtlCompareMemory</code> being handled as a boolean.</p>
</overview>
<recommendation>
<p>Any findings from this rule may indicate that the return value of a call to <code>RtlCompareMemory</code> is being incorrectly interpreted as a boolean.</p>
<p>Review the logic of the call, and if necessary, replace the function call with <code>RtlEqualMemory</code>.</p>
</recommendation>
<example>
<p>The following example is a typical one where an identity comparison is intended, but the wrong API is being used.</p>
<sample src="IncorrectUsageOfRtlCompareMemoryBad.c" />
<p>In this example, the fix is to replace the call to <code>RtlCompareMemory</code> with <code>RtlEqualMemory</code>.</p>
<sample src="IncorrectUsageOfRtlCompareMemoryGood.c" />
</example>
<references>
<li>Books online <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlcomparememory">RtlCompareMemory function (wdm.h)</a></li>
<li>Books online <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlequalmemory">RtlEqualMemory macro (wdm.h)</a></li>
</references>
</qhelp>

View File

@@ -0,0 +1,69 @@
/**
* @id cpp/microsoft/public/drivers/incorrect-usage-of-rtlcomparememory
* @name Incorrect usage of RtlCompareMemory
* @description `RtlCompareMemory` routine compares two blocks of memory and returns the number of bytes that match, not a boolean value indicating a full comparison like `RtlEqualMemory` does.
* This query detects the return value of `RtlCompareMemory` being handled as a boolean.
* @security.severity Important
* @kind problem
* @problem.severity error
* @precision high
* @tags security
* kernel
*/
import cpp
predicate isLiteralABooleanMacro(Literal l) {
exists(MacroInvocation mi | mi.getExpr() = l |
mi.getMacroName() in ["true", "false", "TRUE", "FALSE"]
)
}
from FunctionCall fc, Function f, Expr e, string msg
where
f.getQualifiedName() = "RtlCompareMemory" and
f.getACallToThisFunction() = fc and
(
exists(UnaryLogicalOperation ulo | e = ulo |
ulo.getAnOperand() = fc and
msg = "as an operand in an unary logical operation"
)
or
exists(BinaryLogicalOperation blo | e = blo |
blo.getAnOperand() = fc and
msg = "as an operand in a binary logical operation"
)
or
exists(Conversion conv | e = conv |
(
conv.getType().hasName("bool") or
conv.getType().hasName("BOOLEAN") or
conv.getType().hasName("_Bool")
) and
conv.getUnconverted() = fc and
msg = "as a boolean"
)
or
exists(IfStmt s | e = s.getControllingExpr() |
s.getControllingExpr() = fc and
msg = "as the controlling expression in an If statement"
)
or
exists(EqualityOperation bao, Expr e2 | e = bao |
bao.hasOperands(fc, e2) and
isLiteralABooleanMacro(e2) and
msg =
"as an operand in an equality operation where the other operand is a boolean value (high precision result)"
)
or
exists(EqualityOperation bao, Expr e2 | e = bao |
bao.hasOperands(fc, e2) and
(e2.(Literal).getValue().toInt() = 1 or e2.(Literal).getValue().toInt() = 0) and
not isLiteralABooleanMacro(e2) and
msg =
"as an operand in an equality operation where the other operand is likely a boolean value (lower precision result, needs to be reviewed)"
)
)
select e,
"This $@ is being handled $@ instead of the number of matching bytes. Please review the usage of this function and consider replacing it with `RtlEqualMemory`.",
fc, "call to `RtlCompareMemory`", e, msg

View File

@@ -0,0 +1,5 @@
//bug, the code assumes RtlCompareMemory is comparing for identical values & return false if not identical
if (!RtlCompareMemory(pBuffer, ptr, 16))
{
return FALSE;
}

View File

@@ -0,0 +1,5 @@
//fixed
if (!RtlEqualMemory(pBuffer, ptr, 16))
{
return FALSE;
}

View File

@@ -0,0 +1,22 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>If the argument for a <code>sizeof</code> call is a binary operation or a <code>sizeof</code> call, it is typically a sign that there is a confusion on the usage of the sizeof usage.</p>
</overview>
<recommendation>
<p>Any findings from this rule may indicate that the <code>sizeof</code> is being used incorrectly.</p>
<p>Review the logic of the call.</p>
</recommendation>
<example>
<p>The following example shows a case where <code>sizeof</code> a binary operation by mistake.</p>
<sample src="ArgumentIsSizeofOrOperationBad.c" />
<p>In this example, the fix is to multiply the result of <code>sizeof</code> by the number of elements.</p>
<sample src="ArgumentIsSizeofOrOperationGood.c" />
</example>
</qhelp>

View File

@@ -0,0 +1,62 @@
/**
* @id cpp/microsoft/public/sizeof/sizeof-or-operation-as-argument
* @name Usage of an expression that is a binary operation, or sizeof call passed as an argument to a sizeof call
* @description When the `expr` passed to `sizeof` is a binary operation, or a sizeof call, this is typically a sign that there is a confusion on the usage of sizeof.
* @kind problem
* @problem.severity error
* @precision high
* @tags security
*/
import cpp
import SizeOfTypeUtils
/**
* Windows SDK corecrt_math.h defines a macro _CLASS_ARG that
* intentionally misuses sizeof to determine the size of a floating point type.
* Explicitly ignoring any hit in this macro.
*/
predicate isPartOfCrtFloatingPointMacroExpansion(Expr e) {
exists(MacroInvocation mi |
mi.getMacroName() = "_CLASS_ARG" and
mi.getMacro().getFile().getBaseName() = "corecrt_math.h" and
mi.getAnExpandedElement() = e
)
}
/**
* Determines if the sizeOfExpr is ignorable.
*/
predicate ignorableSizeof(SizeofExprOperator sizeofExpr) {
// a common pattern found is to sizeof a binary operation to check a type
// to then perfomr an onperaiton for a 32 or 64 bit type.
// these cases often look like sizeof(x) >=4
// more generally we see binary operations frequently used in different type
// checks, where the sizeof is part of some comparison operation of a switch statement guard.
// sizeof as an argument is also similarly used, but seemingly less frequently.
exists(ComparisonOperation comp | comp.getAnOperand() = sizeofExpr)
or
exists(ConditionalStmt s | s.getControllingExpr() = sizeofExpr)
or
// another common practice is to use bit-wise operations in sizeof to allow the compiler to
// 'pack' the size appropriate but get the size of the result out of a sizeof operation.
sizeofExpr.getExprOperand() instanceof BinaryBitwiseOperation
}
from SizeofExprOperator sizeofExpr, string message, Expr op
where
exists(string tmpMsg |
(
op instanceof BinaryOperation and tmpMsg = "binary operator"
or
op instanceof SizeofOperator and tmpMsg = "sizeof"
) and
if sizeofExpr.isInMacroExpansion()
then message = tmpMsg + "(in a macro expansion)"
else message = tmpMsg
) and
op = sizeofExpr.getExprOperand() and
not isPartOfCrtFloatingPointMacroExpansion(op) and
not ignorableSizeof(sizeofExpr)
select sizeofExpr, "$@: $@ of $@ inside sizeof.", sizeofExpr, message,
sizeofExpr.getEnclosingFunction(), "Usage", op, message

View File

@@ -0,0 +1,5 @@
#define SIZEOF_CHAR sizeof(char)
char* buffer;
// bug - the code is really going to allocate sizeof(size_t) instead o fthe intended sizeof(char) * 10
buffer = (char*) malloc(sizeof(SIZEOF_CHAR * 10));

View File

@@ -0,0 +1,4 @@
#define SIZEOF_CHAR sizeof(char)
char* buffer;
buffer = (char*) malloc(SIZEOF_CHAR * 10);

View File

@@ -0,0 +1,26 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>If the argument for a <code>sizeof</code> call is a macro that expands to a constant integer type, it is a likely indication that the macro operation may be misused or that the argument was selected by mistake (i.e. typo).</p>
<p>This query detects if the argument for <code>sizeof</code> is a macro that expands to a constant integer value.</p>
<p>NOTE: This rule will ignore multicharacter literal values that are exactly 4 bytes long as it matches the length of <code>int</code> and may be expected.</p>
</overview>
<recommendation>
<p>Any findings from this rule may indicate that the <code>sizeof</code> is being used incorrectly.</p>
<p>Review the logic of the call.</p>
</recommendation>
<example>
<p>The following example shows a case where <code>sizeof</code> a constant was used instead of the <code>sizeof</code> of a structure by mistake as the names are similar.</p>
<sample src="SizeOfConstIntMacroBad.c" />
<p>In this example, the fix is to replace the argument for <code>sizeof</code> with the structure name.</p>
<sample src="SizeOfConstIntMacroGood.c" />
</example>
</qhelp>

View File

@@ -0,0 +1,54 @@
/**
* @id cpp/microsoft/public/sizeof/const-int-argument
* @name Passing a constant integer macro to sizeof
* @description The expression passed to sizeof is a macro that expands to an integer constant. A data type was likely intended instead.
* @kind problem
* @problem.severity error
* @precision high
* @tags security
*/
import cpp
import SizeOfTypeUtils
predicate isExprAConstInteger(Expr e, MacroInvocation mi) {
exists(Type type |
type = e.getExplicitlyConverted().getType() and
isTypeDangerousForSizeof(type) and
// Special case for wide-char literals when the compiler doesn't recognize wchar_t (i.e. L'\\', L'\0')
// Accounting for parenthesis "()" around the value
not exists(Macro m | m = mi.getMacro() |
m.getBody().toString().regexpMatch("^[\\s(]*L'.+'[\\s)]*$")
) and
// Special case for token pasting operator
not exists(Macro m | m = mi.getMacro() | m.getBody().toString().regexpMatch("^.*\\s*##\\s*.*$")) and
// Special case for multichar literal integers that are exactly 4 character long (i.e. 'val1')
not exists(Macro m | m = mi.getMacro() |
e.getType().toString() = "int" and
m.getBody().toString().regexpMatch("^'.{4}'$")
) and
e.isConstant()
)
}
int countMacros(Expr e) { result = count(MacroInvocation mi | mi.getExpr() = e | mi) }
predicate isSizeOfExprOperandMacroInvocationAConstInteger(
SizeofExprOperator sizeofExpr, MacroInvocation mi
) {
exists(Expr e |
e = mi.getExpr() and
e = sizeofExpr.getExprOperand() and
isExprAConstInteger(e, mi) and
// Special case for FPs that involve an inner macro that resolves to 0 such as _T('\0')
not exists(int macroCount | macroCount = countMacros(e) |
macroCount > 1 and e.(Literal).getValue().toInt() = 0
)
)
}
from SizeofExprOperator sizeofExpr, MacroInvocation mi
where isSizeOfExprOperandMacroInvocationAConstInteger(sizeofExpr, mi)
select sizeofExpr,
"$@: sizeof of integer macro $@ will always return the size of the underlying integer type.",
sizeofExpr, sizeofExpr.getEnclosingFunction().getName(), mi.getMacro(), mi.getMacro().getName()

View File

@@ -0,0 +1,12 @@
#define SOMESTRUCT_ERRNO_THAT_MATTERS 0x8000000d
typedef struct {
int a;
bool b;
} SOMESTRUCT_THAT_MATTERS;
//bug, the code is using SOMESTRUCT_ERRNO_THAT_MATTERS by mistake instead of SOMESTRUCT_THAT_MATTERS
if (somedata.length >= sizeof(SOMESTRUCT_ERRNO_THAT_MATTERS))
{
/// Do something
}

View File

@@ -0,0 +1,11 @@
#define SOMESTRUCT_ERRNO_THAT_MATTERS 0x8000000d
typedef struct {
int a;
bool b;
} SOMESTRUCT_THAT_MATTERS;
if (somedata.length >= sizeof(SOMESTRUCT_THAT_MATTERS))
{
/// Do something
}

View File

@@ -0,0 +1,45 @@
import cpp
/**
* Holds if `type` is a `Type` that typically should not be used for `sizeof` in macros or function return values.
*/
predicate isTypeDangerousForSizeof(Type type) {
(
type instanceof IntegralOrEnumType and
// ignore string literals
not type instanceof WideCharType and
not type instanceof CharType
)
}
/**
* Holds if `type` is a `Type` that typically should not be used for `sizeof` in macros or function return values.
* This predicate extends the types detected in exchange of precision.
* For higher precision, please use `isTypeDangerousForSizeof`
*/
predicate isTypeDangerousForSizeofLowPrecision(Type type) {
(
// UINT8/BYTE are typedefs to char, so we treat them separately.
// WCHAR is sometimes a typedef to UINT16, so we treat it separately too.
type.getName() = "UINT8"
or
type.getName() = "BYTE"
or
not type.getName() = "WCHAR" and
exists(Type ut |
ut = type.getUnderlyingType() and
ut instanceof IntegralOrEnumType and
not ut instanceof WideCharType and
not ut instanceof CharType
)
)
}
/**
* Holds if the `Function` return type is dangerous as input for `sizeof`.
*/
class FunctionWithTypeDangerousForSizeofLowPrecision extends Function {
FunctionWithTypeDangerousForSizeofLowPrecision() {
exists(Type type | type = this.getType() | isTypeDangerousForSizeofLowPrecision(type))
}
}

View File

@@ -0,0 +1,46 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
Finds explicit uses of symmetric encryption algorithms that are weak, obsolete, or otherwise unapproved.
</p>
<p>
Encryption algorithms such as DES, (uses keys of 56 bits only), RC2 (uses keys of 128 bits only), and TripleDES (provides at most 112 bits of security) are considered to be weak.
</p>
<p>
These cryptographic algorithms do not provide as much security assurance as more modern counterparts.
</p>
</overview>
<recommendation>
<p>
For Microsoft internal security standards:
</p>
<p>
For WinCrypt, switch to ALG_SID_AES, ALG_SID_AES_128, ALG_SID_AES_192, or ALG_SID_AES_256.
</p>
<p>
For BCrypt, switch to AES or any algorithm other than RC2, RC4, DES, DESX, 3DES, 3DES_112. AES_GMAC and AES_CMAC require crypto board review.
</p>
</recommendation>
<example>
<p>Violations:</p>
<sample src="examples/WeakEncryption/WeakEncryption1.cpp" />
<sample src="examples/WeakEncryption/WeakEncryption3.cpp" />
<p>Solutions:</p>
<sample src="examples/WeakEncryption/WeakEncryption2.cpp" />
<sample src="examples/WeakEncryption/WeakEncryption4.cpp" />
</example>
<references>
<li>Microsoft Docs: <a href="https://learn.microsoft.com/en-us/security/engineering/cryptographic-recommendations">Microsoft SDL Cryptographic Recommendations</a>.</li>
</references>
</qhelp>

View File

@@ -0,0 +1,58 @@
/**
* @name Weak cryptography
* @description Finds explicit uses of symmetric encryption algorithms that are weak, obsolete, or otherwise unapproved.
* @kind problem
* @id cpp/microsoft/public/weak-crypto/banned-encryption-algorithms
* @problem.severity error
* @precision high
* @tags security
* external/cwe/cwe-327
*/
import cpp
import CryptoFilters
import CryptoDataflowCapi
import CryptoDataflowCng
import experimental.cryptography.Concepts
predicate isCapiOrCNGBannedAlg(Expr e, string msg) {
exists(FunctionCall fc |
CapiCryptCreateEncryptionBanned::flow(DataFlow::exprNode(e),
DataFlow::exprNode(fc.getArgument(1)))
or
BCryptOpenAlgorithmProviderBannedEncryption::flow(DataFlow::exprNode(e),
DataFlow::exprNode(fc.getArgument(1)))
) and
msg =
"Call to a cryptographic function with a banned symmetric encryption algorithm: " +
e.getValueText()
}
predicate isGeneralBannedAlg(SymmetricEncryptionAlgorithm alg, Expr confSink, string msg) {
// Handle unknown cases in a separate query
not alg.getEncryptionName() = unknownAlgorithm() and
exists(string resMsg |
(
not alg.getEncryptionName().matches("AES%") and
resMsg = "Use of banned symmetric encryption algorithm: " + alg.getEncryptionName() + "."
) and
(
if alg.hasConfigurationSink() and alg.configurationSink() != alg
then (
confSink = alg.configurationSink() and msg = resMsg + " Algorithm used at sink: $@."
) else (
confSink = alg and msg = resMsg
)
)
)
}
from Expr sink, Expr confSink, string msg
where
(
isCapiOrCNGBannedAlg(sink, msg) and confSink = sink
or
isGeneralBannedAlg(sink, confSink, msg)
) and
not isSrcSinkFiltered(sink, confSink)
select sink, msg, confSink, confSink.toString()

View File

@@ -0,0 +1,29 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p> Violation - Use of one of the following unsafe encryption modes that is not approved: ECB, OFB, CFB, CTR, CCM, or GCM.</p>
<p> These modes are vulnerable to attacks and may cause exposure of sensitive information. For example, using <code> ECB </code> to encrypt a plaintext block always produces a same cipher text, so it can easily tell if two encrypted messages are identical. Using approved modes can avoid these unnecessary risks.</p>
</overview>
<recommendation>
<p> - Use only approved modes CBC, CTS and XTS.</p>
</recommendation>
<example>
<p>Violation:</p>
<sample src="examples/BannedModesCAPI/BannedModesCAPI1.cpp" />
<p>Solution:</p>
<sample src="examples/BannedModesCAPI/BannedModesCAPI2.cpp" />
</example>
<references>
<li>Microsoft Docs: <a href="https://learn.microsoft.com/en-us/security/engineering/cryptographic-recommendations">Microsoft SDL Cryptographic Recommendations</a>.</li>
</references>
</qhelp>

View File

@@ -0,0 +1,40 @@
/**
* @name Weak cryptography
* @description Finds explicit uses of block cipher chaining mode algorithms that are not approved. (CAPI)
* @kind problem
* @id cpp/microsoft/public/weak-crypto/capi/banned-modes
* @problem.severity error
* @precision high
* @tags security
* external/cwe/cwe-327
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
import CryptoDataflowCapi
module CapiSetBlockCipherConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr().isConstant() and
// KP_MODE
// CRYPT_MODE_CBC 1 - Cipher block chaining - Microsoft-Only: Only mode allowed by Crypto Board from this list (CBC-MAC)
// CRYPT_MODE_ECB 2 - Electronic code book - Generally not recommended for usage in cryptographic protocols at all
// CRYPT_MODE_OFB 3 - Output feedback mode - Microsoft-Only: Banned, usage requires Crypto Board review
// CRYPT_MODE_CFB 4 - Cipher feedback mode - Microsoft-Only: Banned, usage requires Crypto Board review
// CRYPT_MODE_CTS 5 - Ciphertext stealing mode - Microsoft-Only: CTS is approved by Crypto Board, but should probably use CNG and not CAPI
source.asExpr().getValue().toInt() != 1
}
predicate isSink(DataFlow::Node sink) {
exists(CapiCryptCryptSetKeyParamtoKPMODE call | sink.asIndirectExpr() = call.getArgument(2))
}
}
module CapiSetBlockCipherTrace = DataFlow::Global<CapiSetBlockCipherConfiguration>;
from CapiCryptCryptSetKeyParamtoKPMODE call, DataFlow::Node src, DataFlow::Node sink
where
sink.asIndirectExpr() = call.getArgument(2) and
CapiSetBlockCipherTrace::flow(src, sink)
select call,
"Call to 'CryptSetKeyParam' function with argument dwParam = KP_MODE is setting up a banned block cipher mode."

View File

@@ -0,0 +1,31 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p> Violation - Use of one of the following unsafe encryption modes that is not approved: ECB, OFB, CFB, CTR, CCM, or GCM.</p>
<p> These modes are vulnerable to attacks and may cause exposure of sensitive information. For example, using <code> ECB </code> to encrypt a plaintext block always produces a same cipher text, so it can easily tell if two encrypted messages are identical. Using approved modes can avoid these unnecessary risks.</p>
</overview>
<recommendation>
<p> - Use only approved modes CBC, CTS and XTS.</p>
</recommendation>
<example>
<p>Violation:</p>
<sample src="examples/BannedModesCNG/BannedModesCNG1.cpp" />
<p>Solution:</p>
<sample src="examples/BannedModesCNG/BannedModesCNG2.cpp" />
</example>
<references>
<li>Microsoft Docs: <a href="https://learn.microsoft.com/en-us/security/engineering/cryptographic-recommendations">Microsoft SDL Cryptographic Recommendations</a>.</li>
</references>
</qhelp>

View File

@@ -0,0 +1,23 @@
/**
* @name Weak cryptography
* @description Finds explicit uses of block cipher chaining mode algorithms that are not approved. (CNG)
* @kind problem
* @id cpp/microsoft/public/weak-crypto/cng/banned-modes
* @problem.severity error
* @precision high
* @tags security
* external/cwe/cwe-327
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
import CryptoDataflowCng
from CngBCryptSetPropertyParamtoKChainingMode call, DataFlow::Node src, DataFlow::Node sink
where
sink.asIndirectArgument() = call.getArgument(2) and
CngBCryptSetPropertyChainingBannedModeIndirectParameter::flow(src, sink)
or
sink.asExpr() = call.getArgument(2) and CngBCryptSetPropertyChainingBannedMode::flow(src, sink)
select call,
"Call to 'BCryptSetProperty' function with argument pszProperty = \"ChainingMode\" is setting up a banned block cipher mode."

View File

@@ -0,0 +1,97 @@
/**
* Provides classes and predicates for identifying expressions that are use Crypto API (CAPI).
*/
import cpp
private import semmle.code.cpp.dataflow.new.DataFlow
/**
* Dataflow that detects a call to CryptSetKeyParam dwParam = KP_MODE (CAPI)
*/
module CapiCryptCryptSetKeyParamtoKPMODEConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr().getValue().toInt() = 4 // KP_MODE
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// CryptSetKeyParam 2nd argument specifies the key parameter to set
sink.asExpr() = call.getArgument(1) and
call.getTarget().hasGlobalName("CryptSetKeyParam")
)
}
}
module CapiCryptCryptSetKeyParamtoKPMODE =
DataFlow::Global<CapiCryptCryptSetKeyParamtoKPMODEConfiguration>;
/**
* A function call to CryptSetKeyParam with dwParam = KP_MODE (CAPI)
*/
class CapiCryptCryptSetKeyParamtoKPMODE extends FunctionCall {
CapiCryptCryptSetKeyParamtoKPMODE() {
exists(Expr var |
CapiCryptCryptSetKeyParamtoKPMODE::flow(DataFlow::exprNode(var),
DataFlow::exprNode(this.getArgument(1)))
)
}
}
// CAPI-specific DataFlow configuration
module CapiCryptCreateHashBannedConfiguration implements DataFlow::ConfigSig {
// This mechnism will verify for approved set of values to call, rejecting anythign that is not in the list.
// NOTE: This mechanism is not guaranteed to work with CSPs that do not use the same algorithms defined in Wincrypt.h
//
predicate isSource(DataFlow::Node source) {
// Verify if source matched the mask for CAPI ALG_CLASS_HASH == 32768
source.asExpr().getValue().toInt().bitShiftRight(13) = 4 and
// The following hash algorithms are safe to use, anything else is considered banned
not (
source.asExpr().getValue().toInt().bitXor(32768) = 12 or // ALG_SID_SHA_256
source.asExpr().getValue().toInt().bitXor(32768) = 13 or // ALG_SID_SHA_384
source.asExpr().getValue().toInt().bitXor(32768) = 14 // ALG_SID_SHA_512
)
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// CryptCreateHash 2nd argument specifies the hash algorithm to be used.
sink.asExpr() = call.getArgument(1) and
call.getTarget().hasGlobalName("CryptCreateHash")
)
}
}
module CapiCryptCreateHashBanned = DataFlow::Global<CapiCryptCreateHashBannedConfiguration>;
// CAPI-specific DataFlow configuration
module CapiCryptCreateEncryptionBannedConfiguration implements DataFlow::ConfigSig {
// This mechanism will verify for approved set of values to call, rejecting anything that is not in the list.
// NOTE: This mechanism is not guaranteed to work with CSPs that do not use the same algorithms defined in Wincrypt.h
//
predicate isSource(DataFlow::Node source) {
// Verify if source matched the mask for CAPI ALG_CLASS_DATA_ENCRYPT == 24576
source.asExpr().getValue().toInt().bitShiftRight(13) = 3 and
// The following algorithms are safe to use, anything else is considered banned
not (
source.asExpr().getValue().toInt().bitXor(26112) = 14 or // ALG_SID_AES_128
source.asExpr().getValue().toInt().bitXor(26112) = 15 or // ALG_SID_AES_192
source.asExpr().getValue().toInt().bitXor(26112) = 16 or // ALG_SID_AES_256
source.asExpr().getValue().toInt().bitXor(26112) = 17 // ALG_SID_AES
)
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// CryptGenKey or CryptDeriveKey 2nd argument specifies the hash algorithm to be used.
sink.asExpr() = call.getArgument(1) and
(
call.getTarget().hasGlobalName("CryptGenKey") or
call.getTarget().hasGlobalName("CryptDeriveKey")
)
)
}
}
module CapiCryptCreateEncryptionBanned =
DataFlow::Global<CapiCryptCreateEncryptionBannedConfiguration>;

View File

@@ -0,0 +1,137 @@
/**
* Provides classes and predicates for identifying expressions that are use crypto API Next Generation (CNG).
*/
import cpp
private import semmle.code.cpp.dataflow.new.DataFlow
/**
* Dataflow that detects a call to BCryptSetProperty pszProperty = ChainingMode (CNG)
*/
module CngBCryptSetPropertyParamtoKChainingModeConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr().getValue().toString().matches("ChainingMode")
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// BCryptSetProperty 2nd argument specifies the key parameter to set
sink.asExpr() = call.getArgument(1) and
call.getTarget().hasGlobalName("BCryptSetProperty")
)
}
}
module CngBCryptSetPropertyParamtoKChainingMode =
DataFlow::Global<CngBCryptSetPropertyParamtoKChainingModeConfiguration>;
/**
* A function call to BCryptSetProperty pszProperty = ChainingMode (CNG)
*/
class CngBCryptSetPropertyParamtoKChainingMode extends FunctionCall {
CngBCryptSetPropertyParamtoKChainingMode() {
exists(Expr var |
CngBCryptSetPropertyParamtoKChainingMode::flow(DataFlow::exprNode(var),
DataFlow::exprNode(this.getArgument(1)))
)
}
}
predicate isChaniningModeCbc(DataFlow::Node source) {
// Verify if algorithm is in the approved list.
exists(string s | s = source.asExpr().getValue().toString() |
s.regexpMatch("ChainingMode[A-Za-z0-9/]+") and
// Property Strings
// BCRYPT_CHAIN_MODE_NA L"ChainingModeN/A" - The algorithm does not support chaining
// BCRYPT_CHAIN_MODE_CBC L"ChainingModeCBC" - Microsoft-Only: Only mode allowed by Crypto Board from this list (CBC-MAC)
// BCRYPT_CHAIN_MODE_ECB L"ChainingModeECB" - Generally not recommended for usage in cryptographic protocols at all
// BCRYPT_CHAIN_MODE_CFB L"ChainingModeCFB" - Microsoft-Only: Banned, usage requires Crypto Board review
// BCRYPT_CHAIN_MODE_CCM L"ChainingModeCCM" - Microsoft-Only: Banned, usage requires Crypto Board review
// BCRYPT_CHAIN_MODE_GCM L"ChainingModeGCM" - Microsoft-Only: Only for TLS, other usage requires Crypto Board review
not s.matches("ChainingModeCBC")
)
}
module CngBCryptSetPropertyChainingBannedModeConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { isChaniningModeCbc(source) }
predicate isSink(DataFlow::Node sink) {
exists(CngBCryptSetPropertyParamtoKChainingMode call |
// BCryptOpenAlgorithmProvider 3rd argument sets the chaining mode value
sink.asExpr() = call.getArgument(2)
)
}
}
module CngBCryptSetPropertyChainingBannedMode =
DataFlow::Global<CngBCryptSetPropertyChainingBannedModeConfiguration>;
module CngBCryptSetPropertyChainingBannedModeIndirectParameterConfiguration implements
DataFlow::ConfigSig
{
predicate isSource(DataFlow::Node source) { isChaniningModeCbc(source) }
predicate isSink(DataFlow::Node sink) {
exists(CngBCryptSetPropertyParamtoKChainingMode call |
// CryptSetKeyParam 3rd argument specifies the mode (KP_MODE)
sink.asIndirectExpr() = call.getArgument(2)
)
}
}
module CngBCryptSetPropertyChainingBannedModeIndirectParameter =
DataFlow::Global<CngBCryptSetPropertyChainingBannedModeIndirectParameterConfiguration>;
// CNG-specific DataFlow configuration
module BCryptOpenAlgorithmProviderBannedHashConfiguration implements DataFlow::ConfigSig {
// NOTE: Unlike the CAPI scenario, CNG will use this method to load and initialize
// a cryptographic provider for any type of algorithm,not only hash.
// Therefore, we have to take a banned-list instead of approved list approach.
//
predicate isSource(DataFlow::Node source) {
// Verify if algorithm is marked as banned.
source.asExpr().getValue().toString().matches("MD_")
or
source.asExpr().getValue().toString().matches("SHA1")
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// BCryptOpenAlgorithmProvider 2nd argument specifies the algorithm to be used
sink.asExpr() = call.getArgument(1) and
call.getTarget().hasGlobalName("BCryptOpenAlgorithmProvider")
)
}
}
module BCryptOpenAlgorithmProviderBannedHash =
DataFlow::Global<BCryptOpenAlgorithmProviderBannedHashConfiguration>;
// CNG-specific DataFlow configuration
module BCryptOpenAlgorithmProviderBannedEncryptionConfiguration implements DataFlow::ConfigSig {
// NOTE: Unlike the CAPI scenario, CNG will use this method to load and initialize
// a cryptographic provider for any type of algorithm,not only encryption.
// Therefore, we have to take a banned-list instead of approved list approach.
//
predicate isSource(DataFlow::Node source) {
// Verify if algorithm is marked as banned.
source.asExpr().getValue().toString().matches("RC_") or
source.asExpr().getValue().toString().matches("DES") or
source.asExpr().getValue().toString().matches("DESX") or
source.asExpr().getValue().toString().matches("3DES") or
source.asExpr().getValue().toString().matches("3DES_112") or
source.asExpr().getValue().toString().matches("AES_GMAC") or // Microsoft Only: Requires Cryptoboard review
source.asExpr().getValue().toString().matches("AES_CMAC") // Microsoft Only: Requires Cryptoboard review
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// BCryptOpenAlgorithmProvider 2nd argument specifies the algorithm to be used
sink.asExpr() = call.getArgument(1) and
call.getTarget().hasGlobalName("BCryptOpenAlgorithmProvider")
)
}
}
module BCryptOpenAlgorithmProviderBannedEncryption =
DataFlow::Global<BCryptOpenAlgorithmProviderBannedEncryptionConfiguration>;

View File

@@ -0,0 +1,45 @@
import cpp
/**
* Determines if an element should be filtered (ignored)
* from any result set.
*
* The current strategy is to determine if the element
* resides in a path that appears to be a library (in particular openssl).
*
* It is therefore important that the element being examined represents
* a use or configuration of cryptography in the user code.
* E.g., if a global variable were defined in an OpenSSL library
* representing a bad/vuln algorithm, and this global were assessed
* it would appear to be ignorable, as it exists in a a filtered library.
* The use of that global must be examined with this filter.
*
* ASSUMPTION/CAVEAT: note if an openssl library wraps a dangerous crypo use
* this filter approach will ignore the wrapper call, unless it is also flagged
* as dangerous. e.g., SomeWraper(){ ... <md5 use> ...}
* The wrapper if defined in openssl would result in ignoring
* the use of MD5 internally, since it's use is entirely in openssl.
*
* TODO: these caveats need to be reassessed in the future.
*/
predicate isUseFiltered(Element e) {
e.getFile().getAbsolutePath().toLowerCase().matches("%openssl%")
}
/**
* Filtered only if both src and sink are considered filtered.
*
* This approach is meant to partially address some of the implications of
* `isUseFiltered`. Specifically, if an algorithm is specified by a user
* and some how passes to a user inside openssl, then this filter
* would not ignore that the user was specifying the use of something dangerous.
*
* e.g., if a wrapper in openssl existed of the form SomeWrapper(string alg, ...){ ... <operation using alg> ...}
* and the user did something like SomeWrapper("MD5", ...), this would not be ignored.
*
* The source in the above example would the algorithm, and the sink is the configuration sink
* of the algorithm.
*/
predicate isSrcSinkFiltered(Element src, Element sink) {
isUseFiltered(src) and isUseFiltered(sink)
}

View File

@@ -0,0 +1,23 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>An initialization vector (IV) is an input to a cryptographic primitive being used to provide the initial state. The IV is typically required to be random or pseudorandom (randomized scheme), but sometimes an IV only needs to be unpredictable or unique (stateful scheme).</p>
<p>Randomization is crucial for some encryption schemes to achieve semantic security, a property whereby repeated usage of the scheme under the same key does not allow an attacker to infer relationships between (potentially similar) segments of the encrypted message.</p>
</overview>
<recommendation>
<p>All symmetric block ciphers must also be used with an appropriate initialization vector (IV) according to the mode of operation being used.</p>
<p>If using a randomized scheme such as CBC, it is recommended to use cryptographically secure pseudorandom number generator such as <code>BCryptGenRandom</code>.</p>
</recommendation>
<references>
<li>
<a href="https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptencrypt">BCryptEncrypt function (bcrypt.h)</a>
<a href="https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom">BCryptGenRandom function (bcrypt.h)</a>
<a href="https://en.wikipedia.org/wiki/Initialization_vector">Initialization vector (Wikipedia)</a>
</li>
</references>
</qhelp>

View File

@@ -0,0 +1,58 @@
/**
* @name Weak cryptography
* @description Finds usage of a static (hardcoded) IV. (CNG)
* @kind problem
* @id cpp/microsoft/public/weak-crypto/cng/hardcoded-iv
* @problem.severity error
* @precision high
* @tags security
* external/cwe/cwe-327
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
/**
* Gets const element of `ArrayAggregateLiteral`.
*/
Expr getConstElement(ArrayAggregateLiteral lit) {
exists(int n |
result = lit.getElementExpr(n, _) and
result.isConstant()
)
}
/**
* Gets the last element in an `ArrayAggregateLiteral`.
*/
Expr getLastElement(ArrayAggregateLiteral lit) {
exists(int n |
result = lit.getElementExpr(n, _) and
not exists(lit.getElementExpr(n + 1, _))
)
}
module CngBCryptEncryptHardcodedIVConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
exists(AggregateLiteral lit |
getLastElement(lit) = source.asDefinition() and
exists(getConstElement(lit))
)
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// BCryptEncrypt 5h argument specifies the IV
sink.asIndirectExpr() = call.getArgument(4) and
call.getTarget().hasGlobalName("BCryptEncrypt")
)
}
}
module Flow = DataFlow::Global<CngBCryptEncryptHardcodedIVConfiguration>;
from DataFlow::Node sl, DataFlow::Node fc, AggregateLiteral lit
where
Flow::flow(sl, fc) and
getLastElement(lit) = sl.asDefinition()
select lit, "Calling BCryptEncrypt with a hard-coded IV on function "

View File

@@ -0,0 +1,14 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Use of KDF algorithm BCryptDeriveKeyPBKDF2 uses insecure hash from BCryptOpenAlgorithmProvider.</p>
</overview>
<recommendation>
<p>Use SHA 256, 384, or 512.</p>
</recommendation>
</qhelp>

View File

@@ -0,0 +1,85 @@
/**
* @name KDF may only use SHA256/384/512 in generating a key.
* @description KDF may only use SHA256/384/512 in generating a key.
* @kind problem
* @id cpp/microsoft/public/kdf-insecure-hash
* @problem.severity error
* @precision high
* @tags security
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
module BannedHashAlgorithmConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
// Verify if algorithm is marked as banned.
not source.asExpr().getValue().toString().matches("SHA256") and
not source.asExpr().getValue().toString().matches("SHA384") and
not source.asExpr().getValue().toString().matches("SHA512")
}
predicate isSink(DataFlow::Node sink) {
exists(FunctionCall call |
// Argument 1 (0-based) specified the algorithm ID.
// NTSTATUS BCryptOpenAlgorithmProvider(
// [out] BCRYPT_ALG_HANDLE *phAlgorithm,
// [in] LPCWSTR pszAlgId,
// [in] LPCWSTR pszImplementation,
// [in] ULONG dwFlags
// );
sink.asExpr() = call.getArgument(1) and
call.getTarget().hasGlobalName("BCryptOpenAlgorithmProvider")
)
}
}
module BannedHashAlgorithmTrace = DataFlow::Global<BannedHashAlgorithmConfig>;
module BCRYPT_ALG_HANDLE_Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
exists(FunctionCall call |
// Argument 0 (0-based) specified the algorithm handle
// NTSTATUS BCryptOpenAlgorithmProvider(
// [out] BCRYPT_ALG_HANDLE *phAlgorithm,
// [in] LPCWSTR pszAlgId,
// [in] LPCWSTR pszImplementation,
// [in] ULONG dwFlags
// );
source.asDefiningArgument() = call.getArgument(0) and
call.getTarget().hasGlobalName("BCryptOpenAlgorithmProvider")
)
}
predicate isSink(DataFlow::Node sink) {
// Algorithm handle is the 0th (0-based) argument of the call
// NTSTATUS BCryptDeriveKeyPBKDF2(
// [in] BCRYPT_ALG_HANDLE hPrf,
// [in, optional] PUCHAR pbPassword,
// [in] ULONG cbPassword,
// [in, optional] PUCHAR pbSalt,
// [in] ULONG cbSalt,
// [in] ULONGLONG cIterations,
// [out] PUCHAR pbDerivedKey,
// [in] ULONG cbDerivedKey,
// [in] ULONG dwFlags
// );
exists(Call c | c.getTarget().getName() = "BCryptDeriveKeyPBKDF2" |
c.getArgument(0) = sink.asExpr()
)
}
}
module BCRYPT_ALG_HANDLE_Trace = DataFlow::Global<BCRYPT_ALG_HANDLE_Config>;
from DataFlow::Node src1, DataFlow::Node src2, DataFlow::Node sink1, DataFlow::Node sink2
where
BannedHashAlgorithmTrace::flow(src1, sink1) and
exists(Call c |
c.getAnArgument() = sink1.asExpr() and src2.asDefiningArgument() = c.getAnArgument()
|
BCRYPT_ALG_HANDLE_Trace::flow(src2, sink2)
)
select sink2.asExpr(),
"BCRYPT_ALG_HANDLE is passed to this to KDF derived from insecure hashing function $@. Must use SHA256 or higher.",
src1.asExpr(), src1.asExpr().getValue()

View File

@@ -0,0 +1,14 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Use of KDF algorithm BCryptDeriveKeyPBKDF2 uses low iteration count (less than 100k).</p>
</overview>
<recommendation>
<p>Use a minimum of 100,000 for iteration count.</p>
</recommendation>
</qhelp>

View File

@@ -0,0 +1,51 @@
/**
* @name Use iteration count at least 100k to prevent brute force attacks
* @description When deriving cryptographic keys from user-provided inputs such as password, use sufficient iteration count (at least 100k).
* This query traces constants of <100k to the iteration count parameter of CNG's BCryptDeriveKeyPBKDF2.
* This query traces constants of less than the min length to the target parameter.
* NOTE: if the constant is modified, or if a non-constant gets to the iteration count, this query will not flag these cases.
* The rationale currently is that this query is meant to validate common uses of key derivation.
* Non-common uses (modifying the iteration count somehow or getting the count from outside sources) are assumed to be intentional.
* @kind problem
* @id cpp/microsoft/public/kdf-low-iteration-count
* @problem.severity error
* @precision high
* @tags security
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
module IterationCountDataFlowConfig implements DataFlow::ConfigSig {
/**
* Defines the source for iteration count when it's coming from a fixed value
* Any expression that has an assigned value < 100000 could be a source.
*/
predicate isSource(DataFlow::Node src) { src.asExpr().getValue().toInt() < 100000 }
predicate isSink(DataFlow::Node sink) {
// iterations count is the 5th (0-based) argument of the call
// NTSTATUS BCryptDeriveKeyPBKDF2(
// [in] BCRYPT_ALG_HANDLE hPrf,
// [in, optional] PUCHAR pbPassword,
// [in] ULONG cbPassword,
// [in, optional] PUCHAR pbSalt,
// [in] ULONG cbSalt,
// [in] ULONGLONG cIterations,
// [out] PUCHAR pbDerivedKey,
// [in] ULONG cbDerivedKey,
// [in] ULONG dwFlags
// );
exists(Call c | c.getTarget().getName() = "BCryptDeriveKeyPBKDF2" |
c.getArgument(5) = sink.asExpr()
)
}
}
module IterationCountDataFlow = DataFlow::Global<IterationCountDataFlowConfig>;
from DataFlow::Node src, DataFlow::Node sink
where IterationCountDataFlow::flow(src, sink)
select sink.asExpr(),
"Iteration count $@ is passed to this to KDF. Use at least 100000 iterations when deriving cryptographic key from password.",
src, src.asExpr().getValue()

View File

@@ -0,0 +1,14 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Use of KDF algorithm BCryptDeriveKeyPBKDF2 uses small key size (less than 16 bytes).</p>
</overview>
<recommendation>
<p>Use a minimum of 16 bytes for key size.</p>
</recommendation>
</qhelp>

View File

@@ -0,0 +1,46 @@
/**
* @name Small KDF derived key length.
* @description KDF derived keys should be a minimum of 128 bits (16 bytes).
* This query traces constants of less than the min length to the target parameter.
* NOTE: if the constant is modified, or if a non-constant gets to the target, this query will not flag these cases.
* The rationale currently is that this query is meant to validate common uses of key derivation.
* Non-common uses (modifying the values somehow or getting the count from outside sources) are assumed to be intentional.
* @kind problem
* @id cpp/microsoft/public/kdf-small-key-size
* @problem.severity error
* @precision high
* @tags security
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
module KeyLenConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node src) { src.asExpr().getValue().toInt() < 16 }
predicate isSink(DataFlow::Node sink) {
// Key length size is the 7th (0-based) argument of the call
// NTSTATUS BCryptDeriveKeyPBKDF2(
// [in] BCRYPT_ALG_HANDLE hPrf,
// [in, optional] PUCHAR pbPassword,
// [in] ULONG cbPassword,
// [in, optional] PUCHAR pbSalt,
// [in] ULONG cbSalt,
// [in] ULONGLONG cIterations,
// [out] PUCHAR pbDerivedKey,
// [in] ULONG cbDerivedKey,
// [in] ULONG dwFlags
// );
exists(Call c | c.getTarget().getName() = "BCryptDeriveKeyPBKDF2" |
c.getArgument(7) = sink.asExpr()
)
}
}
module KeyLenTrace = DataFlow::Global<KeyLenConfig>;
from DataFlow::Node src, DataFlow::Node sink
where KeyLenTrace::flow(src, sink)
select sink.asExpr(),
"Key size $@ is passed to this to KDF. Use at least 16 bytes for key length when deriving cryptographic key from password.",
src.asExpr(), src.asExpr().getValue()

View File

@@ -0,0 +1,15 @@
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Use of KDF algorithm BCryptDeriveKeyPBKDF2 uses small salt size (less than 16 bytes).</p>
</overview>
<recommendation>
<p>Use a minimum of 16 bytes for salt size.</p>
</recommendation>
</qhelp>

View File

@@ -0,0 +1,46 @@
/**
* @name Small KDF salt length.
* @description KDF salts should be a minimum of 128 bits (16 bytes).
* This query traces constants of less than the min length to the target parameter.
* NOTE: if the constant is modified, or if a non-constant gets to the target, this query will not flag these cases.
* The rationale currently is that this query is meant to validate common uses of key derivation.
* Non-common uses (modifying the values somehow or getting the count from outside sources) are assumed to be intentional.
* @kind problem
* @id cpp/microsoft/public/kdf-small-salt-size
* @problem.severity error
* @precision high
* @tags security
*/
import cpp
import semmle.code.cpp.dataflow.new.DataFlow
module SaltLenConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node src) { src.asExpr().getValue().toInt() < 16 }
predicate isSink(DataFlow::Node sink) {
// Key length size is the 7th (0-based) argument of the call
// NTSTATUS BCryptDeriveKeyPBKDF2(
// [in] BCRYPT_ALG_HANDLE hPrf,
// [in, optional] PUCHAR pbPassword,
// [in] ULONG cbPassword,
// [in, optional] PUCHAR pbSalt,
// [in] ULONG cbSalt,
// [in] ULONGLONG cIterations,
// [out] PUCHAR pbDerivedKey,
// [in] ULONG cbDerivedKey,
// [in] ULONG dwFlags
// );
exists(Call c | c.getTarget().getName() = "BCryptDeriveKeyPBKDF2" |
c.getArgument(4) = sink.asExpr()
)
}
}
module SaltLenTrace = DataFlow::Global<SaltLenConfig>;
from DataFlow::Node src, DataFlow::Node sink
where SaltLenTrace::flow(src, sink)
select sink.asExpr(),
"Salt size $@ is passed to this to KDF. Use at least 16 bytes for salt size when deriving cryptographic key from password.",
src, src.asExpr().getValue()

View File

@@ -0,0 +1,11 @@
#include <windows.h>
#include <stdio.h>
#include <wincrypt.h>
int main(){
DWORD ivLen;
HCRYPTKEY hKey;
//BAD
CryptGetKeyParam(hKey, CRYPT_MODE_ECB, NULL, &ivLen, 0);
}

View File

@@ -0,0 +1,11 @@
#include <windows.h>
#include <stdio.h>
#include <wincrypt.h>
int main(){
DWORD ivLen;
HCRYPTKEY hKey;
//OKAY
CryptGetKeyParam(hKey, CRYPT_MODE_CBC, NULL, &ivLen, 0);
}

View File

@@ -0,0 +1,14 @@
#include <windows.h>
#include <stdio.h>
#include <bcrypt.h>
int main(){
BCRYPT_ALG_HANDLE aes;
//BAD
status = BCryptSetProperty(aes,
BCRYPT_CHAINING_MODE,
(PBYTE)BCRYPT_CHAIN_MODE_ECB,
sizeof(BCRYPT_CHAIN_MODE_ECB),
0);
}

View File

@@ -0,0 +1,14 @@
#include <windows.h>
#include <stdio.h>
#include <bcrypt.h>
int main(){
BCRYPT_ALG_HANDLE aes;
//OKAY
status = BCryptSetProperty(aes,
BCRYPT_CHAINING_MODE,
(PBYTE)BCRYPT_CHAIN_MODE_CBC,
sizeof(BCRYPT_CHAIN_MODE_CBC),
0);
}

View File

@@ -0,0 +1,14 @@
#include <windows.h>
#include <stdio.h>
#include <wincrypt.h>
int main(){
HCRYPTPROV hCryptProv;
HCRYPTKEY hKey;
//BAD
if(CryptGenKey( hCryptProv, CALG_DES_128, KEYLENGTH | CRYPT_EXPORTABLE, &hKey))
{
printf("A session key has been created.\n");
}
}

View File

@@ -0,0 +1,14 @@
#include <windows.h>
#include <stdio.h>
#include <wincrypt.h>
int main(){
HCRYPTPROV hCryptProv;
HCRYPTKEY hKey;
//OKAY
if(CryptGenKey( hCryptProv, CALG_AES_128, KEYLENGTH | CRYPT_EXPORTABLE, &hKey))
{
printf("A session key has been created.\n");
}
}

Some files were not shown because too many files have changed in this diff Show More