Skip to content

Commit 5510d05

Browse files
committed
C#: Synthetic names only needs to rely on the output stack.
1 parent 7620c05 commit 5510d05

File tree

2 files changed

+153
-203
lines changed

2 files changed

+153
-203
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/EntityFramework.qll

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,14 @@ module EntityFramework {
371371
}
372372

373373
pragma[nomagic]
374-
string getInputSynthetic(SummaryComponentStack output, DbContextClassSetProperty p) {
375-
exists(SummaryComponentStack synthetic, Property mapped |
376-
this = p.getDbContextClass() and
377-
input(this, synthetic, mapped) and
378-
output(this, output, mapped, p) and
379-
result = getFullSyntheticName(p.getSyntheticName(), synthetic, output)
374+
string getSyntheticNames(
375+
SummaryComponentStack input, SummaryComponentStack output, DbContextClassSetProperty dbSet
376+
) {
377+
exists(Property mapped |
378+
this = dbSet.getDbContextClass() and
379+
input(this, input, mapped) and
380+
output(this, output, mapped, dbSet) and
381+
result = dbSet.getSyntheticName() + "#" + SummaryComponentStack::getComponentStack(output)
380382
)
381383
}
382384
}
@@ -433,16 +435,6 @@ module EntityFramework {
433435
)
434436
}
435437

436-
bindingset[prop, stack1, stack2]
437-
private string getFullSyntheticName(
438-
string prop, SummaryComponentStack stack1, SummaryComponentStack stack2
439-
) {
440-
result =
441-
prop + "#" //
442-
+ SummaryComponentStack::getComponentStack(stack1) + "#" //
443-
+ SummaryComponentStack::getComponentStack(stack2)
444-
}
445-
446438
private class DbContextClassSetPropertySynthetic extends EFSummarizedCallable {
447439
private DbContextClassSetProperty p;
448440

@@ -453,7 +445,7 @@ module EntityFramework {
453445
) {
454446
exists(string name, DbContextClass c |
455447
preservesValue = true and
456-
name = c.getInputSynthetic(output, p) and
448+
name = c.getSyntheticNames(_, output, p) and
457449
input = SummaryComponentStack::syntheticGlobal(name)
458450
)
459451
}
@@ -464,21 +456,12 @@ module EntityFramework {
464456

465457
DbContextSaveChanges() { this = c.getASaveChanges() }
466458

467-
pragma[nomagic]
468-
string getOutputSynthetic(SummaryComponentStack input) {
469-
exists(SummaryComponentStack synthetic, Property mapped, DbContextClassSetProperty dbSet |
470-
input(c, input, mapped) and
471-
output(c, synthetic, mapped, dbSet) and
472-
result = getFullSyntheticName(dbSet.getSyntheticName(), input, synthetic)
473-
)
474-
}
475-
476459
override predicate propagatesFlow(
477460
SummaryComponentStack input, SummaryComponentStack output, boolean preservesValue
478461
) {
479462
exists(string name |
480463
preservesValue = true and
481-
name = this.getOutputSynthetic(input) and
464+
name = c.getSyntheticNames(input, _, _) and
482465
output = SummaryComponentStack::syntheticGlobal(name)
483466
)
484467
}
@@ -489,8 +472,7 @@ module EntityFramework {
489472
*/
490473
private class EFSummarizedCallableSyntheticGlobal extends SummaryComponent::SyntheticGlobal {
491474
EFSummarizedCallableSyntheticGlobal() {
492-
this = any(DbContextClass c).getInputSynthetic(_, _) or
493-
this = any(DbContextSaveChanges c).getOutputSynthetic(_)
475+
this = any(DbContextClass c).getSyntheticNames(_, _, _)
494476
}
495477
}
496478

0 commit comments

Comments
 (0)