`EXP39-C`: False positives related to compatible types, harmless casts
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
Direção de pesquisa
Start with the EXP39-C implementation and compare its compatibleTypes predicate with common/types/Compatible.qll, paying particular attention to typedefs and pointer compatibility. Review how casted expressions are modeled as sources and sinks, then use the provided typedef and unused-cast examples to verify that harmless casts are no longer reported.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Affected rules
EXP39-C
Description
First off, our implementation uses a compatibleTypes predicate that is incomplete and doesn't handle typedefs, and should be replaced with our common/types/Compatible.qll library. This results in thousands of false positives in certain codebases, usually due to casting to a project-specific typedef of a byte like GLBYTE*.
Secondly, while we use dataflow to trace realloc's that flow to a deref without a memset, we don't use dataflow to handle the more typical case of A* cast to B* followed by a deref. Instead, we have a type representing casted expressions that's both a sink and a source. (We check compatibility of the pointers in the cast in the select statement). This isn't strictly UB unless the pointer is dereferenced, and I do see examples of this in real code. As a related example, casts to void** are often flagged while void* is excluded. This isn't a rare exceptional use of void, it's really just a harmless cast.
Example
typedef char BYTE;
void example_function() {
int x;
(long *) &x; // harmless since it's unused
BYTE *x_bytes = (BYTE *)&x; // Allowed since BYTE is a char.
}
- Linguagem predominante
- CodeQL
- Estrelas
- 227
- Forks
- 82
- Merge médio
- 6d 7h
- PRs com merge (30d)
- 9
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de github/codeql-coding-standards
-
false positive/false negative Stardard-MISRA-C++
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
github/codeql-coding-standards#1172 ·
-
Difficulty-Low false positive/false negative false-negative Impact-Low Standard-MISRA-C
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
`RULE-0-0-1`: "unreachable statement" false positives due to over-pruning of the control-flow graph Abertafalse positive/false negative
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
github/codeql-coding-standards#1190 ·
-
false positive/false negative
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 65/100
github/codeql-coding-standards#1175 ·
-
false positive/false negative Stardard-MISRA-C++
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
github/codeql-coding-standards#1165 ·
Todas as issues de github/codeql-coding-standards
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
danielmiessler/LifeOS#2218 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
hemilabs/ui-monorepo#2332 ·
-
Help-Wanted Needs-Triage Package-Update
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/winget-pkgs#438662 ·
-
priority: p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
googleapis/librarian#7636 ·