[Python] tsg-parser fails to extract generic base class relations
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia riproducendo l'output di v2.26.2 tsg-python per class Bar(list[int]): pass, quindi traccia il modo in cui il parser gestisce il nodo Subscript durante la costruzione delle basi della classe. Il lavoro è completato quando la base generica produce un arco bases e CodeQL riconosce la relazione Bar -> list[int], mentre il caso non generico esistente rimane intatto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Working with typed base classes in Python (see #22291) I realised that the toolchain seems to drop generic base classes (e.g. list[int] in class Bar(list[int]):) at some point. That is, in the example code
class Foo(list): pass
class Bar(list[int]): pass
CodeQL knows the Foo -> list relation but not the Bar -> list[int] relation.
As far as I could trace it, the relation is already lost in the tsg-python parser. Using the v2.26.2 toolchain, the source code class Bar(list): pass produces the following tsg-python output (assignment nodes removed for brevity):
node 4
_kind: "Name"
_location: [0, 10, 0, 14]
ctx: "load"
variable: "list"
node 5
_kind: "ClassExpr"
_location: [0, 0, 0, 21]
_location_end: [0, 16]
inner_scope: [graph node 6]
name: "Bar"
edge 5 -> 4
bases: 0
node 6
_kind: "Class"
_location: [0, 0, 0, 21]
_location_end: [0, 16]
name: "Bar"
edge 6 -> 1
body: 0
Now if the code is extended for a generic subscription as class Bar(list[int]): pass produces the following tsg-python output (assignment nodes removed for brevity):
node 4
_kind: "Name"
_location: [0, 10, 0, 14]
ctx: "load"
variable: "list"
node 5
_kind: "Name"
_location: [0, 15, 0, 18]
ctx: "load"
variable: "int"
node 6
_kind: "Subscript"
_location: [0, 10, 0, 19]
ctx: "load"
index: [graph node 5]
value: [graph node 4]
node 7
_kind: "ClassExpr"
_location: [0, 0, 0, 26]
_location_end: [0, 21]
inner_scope: [graph node 8]
name: "Bar"
node 8
_kind: "Class"
_location: [0, 0, 0, 26]
_location_end: [0, 21]
name: "Bar"
edge 8 -> 1
body: 0
Notice that the type subscription is parsed (nodes 4, 5, 6) but the edge n -> m node for the bases: 0 relation is absent.
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 11h
- PR unite (30g)
- 129
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
-
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
-
False positive Apertafalse-positive
Difficoltà 4/5 3-5 giorni Idoneità per principianti 15/100
Tutte le issue di github/codeql
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
EricSpencer00/Resilient#4824 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
objectionary/jeo-maven-plugin#1758 ·
-
mlir
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
llvm/llvm-project#224908 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
area-CodeGen-coreclr untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100