github / github/codeql

False positive: Dereferenced variable may be null ignore NRT attributes

Abierto
#20,828 2 comentarios 0 reacciones 0 asignados Ver en GitHub
C# false-positive
Lenguaje dominante
CodeQL
Estrellas
10.1k
Forks
2.1k
Merge medio
2 d 15 h
PR fusionados (30 d)
141

Descripción

**Description of the false positive**

NRT attributes appear to be ignored by CodeQL. This results in lots of noise as we have to explicitly mark each point of use as a false positive and so safe.

**Code samples or links to source code**

```cs
if (TryConvertContractState(tradingPhase, state, out Models.ContractState? contractState))
return contractState.Value;
```
when it is defined as:
```cs
private static bool TryConvertContractState(
string tradingPhase, string state,
[NotNullWhen(true)] out PersistedModels.ContractState? cdmState)
{}
```

**URL to the alert on GitHub code scanning (optional)**

Private Repo, but the view query source goes to: https://github.com/github/codeql/blob/aa3000df1310b332ba1c84afec3bacb0aeb4dbbd/csharp/ql/src/CSI/NullMaybe.ql

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start with csharp/ql/src/CSI/NullMaybe.ql, the query source linked in the report, and review how it handles the C# sample using [NotNullWhen(true)]. Reproduce the reported alert with the provided TryConvertContractState example; done means the valid contractState.Value dereference is no longer reported as a nullability issue.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
security
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.