forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNullMaybe.ql
More file actions
24 lines (22 loc) · 762 Bytes
/
NullMaybe.ql
File metadata and controls
24 lines (22 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* @name Dereferenced variable may be null
* @description Dereferencing a variable whose value may be 'null' may cause a
* 'NullReferenceException'.
* @kind path-problem
* @problem.severity warning
* @precision high
* @id cs/dereferenced-value-may-be-null
* @tags reliability
* correctness
* exceptions
* external/cwe/cwe-476
* quality
*/
import csharp
import semmle.code.csharp.dataflow.Nullness
import PathGraph
from
Dereference d, PathNode source, PathNode sink, Ssa::SourceVariable v, string msg, Element reason
where d.isFirstMaybeNull(v.getAnSsaDefinition(), source, sink, msg, reason)
select d, source, sink, "Variable $@ may be null at this access " + msg + ".", v, v.toString(),
reason, "this"