False Negative: ContainsTypeMismatch.ql misses mismatched collection lookups once the receiver is routed through a raw alias.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Inizia con il checker Likely Bugs/Collections/ContainsTypeMismatch.ql e il caso PosCase5_Var5.java descritto nell’issue. Traccia come viene recuperato il receiver Vector dopo l’assegnazione a rawVec, quindi aggiungi o aggiorna un test di regressione in modo che rawVec.lastIndexOf(arg) venga segnalato come un’incompatibilità tra Byte e Float.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
False Negative: ContainsTypeMismatch.ql misses mismatched collection lookups once the receiver is routed through a raw alias.
Version
codeql 2.24.3
Checker
- Checker id:
Likely Bugs/Collections/ContainsTypeMismatch.ql - Checker description: This checker detects calls to Java collection methods where the argument type is incompatible with the collection's element type, such as calling
containswith an argument that can never match any element in the collection.
Description of the false negative
The collection still holds Byte values and the lookup still uses a Float. The only change is that the call goes through a raw alias before reaching lastIndexOf(...).
That should not be enough to hide the type mismatch from Likely Bugs/Collections/ContainsTypeMismatch.ql.
Affected test cases
PosCase5_Var5.java
rawVec.lastIndexOf(arg) is still searching a Vector<Byte> with a Float. The raw alias obscures generics, but it does not make the lookup compatible.
// Call lastIndexOf on a Vector<Byte> with an argument of type Float (first argument) should be flagged as incompatible type.
package scensct.var.pos;
import java.util.Vector;
public class PosCase5_Var5 {
public static void main(String[] args) {
Vector<? extends Byte> vec = new Vector<Byte>();
// Wildcard capture: still Vector<Byte> compatible
Float arg = 3.14f;
// Raw type manipulation to obscure but preserve generic info
Vector rawVec = vec;
// Checker must still detect Byte vs Float incompatibility
rawVec.lastIndexOf(arg);
}
}
Cause analysis
This looks like a generic-type recovery gap. Once the receiver is widened to a raw type, the query appears to stop using the element type information from the original collection.
That is too weak for this rule. Raw aliases are common in older Java code, and they do not change the fact that a Float can never match an element from a Vector<Byte>.
References
None known.
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 16h
- PR unite (30g)
- 143
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/codeql
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
false-positive javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
false-positive
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Tutte le issue di github/codeql
Issue simili
-
ZCode 3.14.3 に対応する Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
supermomonga/zcode-acp#24 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
learningequality/ricecooker#747 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
KhronosGroup/glTF-Blender-IO#2769 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100