Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9313564

Browse files
committed
JS: Add subclassing test and fix lack of subclassing handling
1 parent ef7767b commit 9313564

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,4 +372,10 @@ predicate apiGraphHasEdge(API::Node pred, string path, API::Node succ) {
372372
)
373373
or
374374
succ = pred.getPromised() and path = "Awaited"
375+
or
376+
exists(DataFlow::ClassNode cls |
377+
pred = API::Internal::getClassInstance(cls.getADirectSubClass()) and
378+
succ = API::Internal::getClassInstance(cls) and
379+
path = ""
380+
)
375381
}

javascript/ql/test/library-tests/ModelGeneration/ModelGeneration.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ typeModel
3636
| (semi-internal-class).getAnonymous~expr2 | (semi-internal-class).getAnonymous~expr1 | Member[method] |
3737
| (subclass).A | subclass | Member[A] |
3838
| (subclass).A.prototype | (subclass).A | Instance |
39+
| (subclass).A.prototype | (subclass).B.prototype | |
3940
| (subclass).A.prototype.a | (subclass).A.prototype | Member[a] |
4041
| (subclass).B | subclass | Member[B] |
4142
| (subclass).B.prototype | (subclass).B | Instance |
43+
| (subclass).B.prototype | (subclass).C.prototype | |
4244
| (subclass).B.prototype.b | (subclass).B.prototype | Member[b] |
4345
| (subclass).C | subclass | Member[C] |
4446
| (subclass).C.prototype | (subclass).C | Instance |

javascript/ql/test/library-tests/ModelGeneration/subclass/subclass.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ export class A {
22
a() {}
33
}
44

5-
export class B {
5+
export class B extends A {
66
b() {}
77
}
88

9-
export class C {
9+
export class C extends B {
1010
c() {}
1111
}

0 commit comments

Comments
 (0)