Commit Graph

70 Commits

Author SHA1 Message Date
Michael Nebel
7a63c7d2a5 C#: Update test expected output. 2025-06-03 13:24:59 +02:00
Michael Nebel
0355ea8733 C#: Add some synthetic library extensions methods and tests for cs/dereferenced-value-is-always-null. 2025-06-03 13:24:56 +02:00
Michael Nebel
76c12a5c69 C#: Convert tests for cs/dereferenced-value-may-be-null to use inline expectations. 2025-06-03 13:24:54 +02:00
Michael Nebel
46c02e7fa8 C#: Convert tests for cs/dereferenced-value-is-always-null to use inline expectations. 2025-06-03 13:24:52 +02:00
Michael Nebel
bae29aeee4 C#: Update implications test expected output. 2025-01-16 16:57:33 +01:00
Michael Nebel
d40c1bebbf C#: Update expected testoutput for Nullness tests. 2025-01-14 17:14:06 +01:00
Michael Nebel
6a31fd7893 C#: Add ImplicitToString example in nullness tests. 2025-01-14 17:14:02 +01:00
Tom Hvitved
1c344d6735 C#: Adjust conditional access locations 2024-04-10 16:21:58 +02:00
Tom Hvitved
acd52192d1 C#: Adopt shared variable capture library 2024-02-26 09:53:30 +01:00
Tamas Vajk
e67035f891 Fix comment in test file 2024-01-08 10:00:39 +01:00
Tamas Vajk
91637d49d4 Fix null dereference false positive 2024-01-08 10:00:39 +01:00
Tamas Vajk
a354ca3264 Add null dereference test case with false positive 2024-01-08 10:00:39 +01:00
Tom Hvitved
84cba21a6c C#: Add a few more is (not) null tests 2023-12-04 12:22:47 +01:00
Michael Nebel
6760dd9121 C#: Base Nullness tests on stubs. 2023-08-29 15:30:24 +02:00
Tom Hvitved
3c173df69e C#: Update expected test output 2023-05-15 09:35:20 +02:00
Mathias Vorreiter Pedersen
177dd76da6 C#: Accept consistency changes. 2023-05-03 20:30:06 +01:00
erik-krogh
326666ac85 update the alert-messages of csharp queries 2022-09-26 14:01:39 +02:00
Tom Hvitved
984e01ecf0 C#: Remove FPs from cs/dereferenced-value-may-be-null
Apply a conservative approach by filtering out results for accesses to
captured nullable values, when there is an (implicit) call to the capturing
callable which is `null`-guarded. For example:

```
bool M(int? i, IEnumerable<int> @is)
{
    if (i.HasValue)
        return @is.Any(j => j == i.Value); // GOOD
    return false;
}
```
2022-02-08 14:01:57 +01:00
Tom Hvitved
7948d965a0 C#: Add nullness tests for captured variables 2022-02-08 13:52:29 +01:00
Tamas Vajk
b7f13a7e1f C#: Change generic method names to include <> and type args/params 2021-09-06 11:48:22 +02:00
Tamas Vajk
5e2770339f Add adjusted expected files 2021-07-01 16:09:11 +02:00
Tamas Vajk
03d1a3e0ad Trim test files + remove duplicate newlines 2021-07-01 16:09:11 +02:00
Tamas Vajk
c29d11087b C#: Start using 'options' files in tests 2021-07-01 16:08:47 +02:00
Tom Hvitved
063733ad52 C#: Implement CFG for not patterns 2021-01-25 13:52:17 +01:00
Tom Hvitved
d4ee8cdd18 C#: Always create basic blocks for nodes with a conditional predecessor 2020-11-27 15:08:33 +01:00
Tom Hvitved
94deed39a2 C#: Represent all expressions in post-order in the CFG 2020-11-12 20:04:48 +01:00
Tom Hvitved
f1d6f7cd0c C#: Model assertions in the CFG 2020-10-02 17:56:41 +02:00
Tom Hvitved
17f0ac4b20 C#: Add more CFG assertion tests 2020-10-02 15:35:33 +02:00
Tom Hvitved
06dbec78f7 C#: Add Guard::controlsBasicBlock() and simplify Guard::isEquality() 2020-09-21 16:15:12 +02:00
Tom Hvitved
05307b8757 C#: Remove more FPs in cs/dereferenced-value-may-be-null 2020-07-30 12:16:59 +02:00
Tom Hvitved
4f4d9d35be C#: Add more nullness tests 2020-07-30 12:15:49 +02:00
Tom Hvitved
d39a33655f C#: Fix false-positives in cs/dereferenced-value-may-be-null
Dereferencing an expression of a nullable type should only be reported when
the expression is not clearly non-null.
2020-07-28 16:27:36 +02:00
Tom Hvitved
ce2368de96 C#: Add tests for null-coalescing assignment 2020-07-28 11:07:47 +02:00
Tom Hvitved
4ca5e3755f C#: Add false-positive test for NullMaybe.ql 2020-03-31 14:06:16 +02:00
Tom Hvitved
a8660d446e C#: Fix typo 2020-03-26 14:54:03 +01:00
Tom Hvitved
fb2b239db7 C#: Add test for cs/dereferenced-value-may-be-null 2020-03-16 15:38:29 +01:00
Calum Grant
a868456628 C#: Address review comments 2020-01-22 14:21:12 +00:00
Calum Grant
9d7c9e0ba4 C#: Default parameter values are maybe null
C#: Update test output
2020-01-20 14:37:20 +00:00
Calum Grant
631b4248b5 C#: Add a nullness test 2020-01-20 11:13:31 +00:00
Tom Hvitved
aa0c78cd85 C#: Teach guards library about more null guards 2019-09-20 09:58:04 +02:00
Tom Hvitved
40fafc5fda C#: Teach comparison library about dynamic comparison operations 2019-09-20 09:51:35 +02:00
Tom Hvitved
cb7db8f4c0 C#: Add more nullness tests 2019-09-20 09:18:55 +02:00
Tom Hvitved
41cd13a637 C#: Update expected test output 2019-09-10 09:17:50 +02:00
Tom Hvitved
1e7ee8ddad C#: Loop unrolling for foreach statements 2019-09-01 10:34:51 +02:00
Tom Hvitved
bb735c0220 C#: Teach guards library about collections 2019-09-01 10:34:51 +02:00
Calum Grant
83ab044a73 C#: Update expected test output. 2019-08-29 18:12:58 +01:00
Tom Hvitved
51d093add0 C#: Address review comments 2019-06-25 17:01:48 +02:00
Tom Hvitved
946be967f8 C#: Break up a big cached stage into multiple stages
- Add `Caching.qll` for controlling caching across multiple files.
- Move `isUncertainRefCall()` out of cached module in `Assignable.qll` to avoid
  collapsing with CFG stage.
- Remove dependency on `AlwaysNullExpr` in `NullValue::getAnExpr()` to avoid
  collapsing with CFG stage.
- Avoid caching pre-SSA library as it should only be used during the CFG construction
  stage.
2019-06-12 16:05:45 +02:00
Tom Hvitved
a1e58cedac C#: Refactor recursive patterns implementation
- Extract names of properties in a propery match, using the `exprorstmt_name` relation.
- Simplify extraction of properties by not distinguishing between top-level patterns
  and nested patterns.
- Introduce `PatternExpr` to capture patterns in `is` expressions, `case` statements,
  and `switch` expression arms.
- Generalize `IsTypeExpr`, `IsPatternExpr`, `IsRecursivePatternExpr`, and `IsConstantExpr`
  to just `IsExpr` with a member predicate `PatternExpr getPattern()`.
- Generalize `TypeCase`, `RecursivePatternCase`, and `ConstCase` to just `CaseStmt` with
  a member predicate `PatternExpr getPattern()`.
- Introduce classes `Switch` and `Case` as base classes of switch statements/expressions
  and case statements/switch expression arms, respectively.
- Simplify CFG logic using the generalized classes.
- Generalize guards library to cover `switch` expressions tests.
- Generalize data flow library to cover `switch` expression assignments.
2019-05-24 13:49:05 +01:00
Tom Hvitved
6c182564e7 C#: Adjustments to CIL/nullness analyses
- Cache predicates in the same stage using a cached module.
- Introduce `DefUse::defUseVariableUpdate()` and use in `CallableReturns.qll`.
  The updated file `csharp/ql/test/library-tests/cil/dataflow/Nullness.expected`
  demonstrates why this is needed.
- Utilize CIL analysis in `Guards::nonNullValue()`.
- Analyze SSA definitions in `AlwaysNullExpr`, similar to `NonNullExpr`.
2019-03-22 15:11:31 +01:00