Skip to content

Commit 68165bb

Browse files
committed
C#/Java: Address review comments.
1 parent 0abc08c commit 68165bb

File tree

2 files changed

+30
-54
lines changed

2 files changed

+30
-54
lines changed

csharp/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ private string printReadAccessPath(PropagateContentFlow::AccessPath ap) {
311311
private predicate mentionsField(PropagateContentFlow::AccessPath ap) {
312312
exists(ContentSet head, PropagateContentFlow::AccessPath tail |
313313
head = ap.getHead() and
314-
tail = ap.getTail() and
315-
(mentionsField(tail) or isField(head))
314+
tail = ap.getTail()
315+
|
316+
mentionsField(tail) or isField(head)
316317
)
317318
}
318319

@@ -369,11 +370,10 @@ private predicate apiContentFlow(
369370
private predicate hasSyntheticContent(PropagateContentFlow::AccessPath path) {
370371
exists(PropagateContentFlow::AccessPath tail, ContentSet head |
371372
head = path.getHead() and
372-
tail = path.getTail() and
373-
(
374-
exists(getSyntheticName(head)) or
375-
hasSyntheticContent(tail)
376-
)
373+
tail = path.getTail()
374+
|
375+
exists(getSyntheticName(head)) or
376+
hasSyntheticContent(tail)
377377
)
378378
}
379379

@@ -425,24 +425,6 @@ private module AccessPathSyntheticValidation {
425425
step(t1, read, t2, store)
426426
}
427427

428-
/**
429-
* Takes one or more synthetic steps.
430-
* Synth ->+ Synth
431-
*/
432-
private predicate synthPathStepRec(
433-
Type t1, PropagateContentFlow::AccessPath read, Type t2, PropagateContentFlow::AccessPath store
434-
) {
435-
hasSyntheticContent(read) and
436-
hasSyntheticContent(store) and
437-
(
438-
step(t1, read, t2, store)
439-
or
440-
exists(PropagateContentFlow::AccessPath mid, Type midType |
441-
step(t1, read, midType, mid) and synthPathStepRec(midType, mid.reverse(), t2, store)
442-
)
443-
)
444-
}
445-
446428
/**
447429
* Holds if there exists a path of steps from `read` to an exit.
448430
*
@@ -451,8 +433,11 @@ private module AccessPathSyntheticValidation {
451433
private predicate reachesSynthExit(Type t, PropagateContentFlow::AccessPath read) {
452434
synthPathExit(t, read, _, _)
453435
or
436+
hasSyntheticContent(read) and
454437
exists(PropagateContentFlow::AccessPath mid, Type midType |
455-
synthPathStepRec(t, read, midType, mid) and synthPathExit(midType, mid.reverse(), _, _)
438+
hasSyntheticContent(mid) and
439+
step(t, read, midType, mid) and
440+
reachesSynthExit(midType, mid.reverse())
456441
)
457442
}
458443

@@ -464,8 +449,11 @@ private module AccessPathSyntheticValidation {
464449
private predicate synthEntryReaches(Type t, PropagateContentFlow::AccessPath store) {
465450
synthPathEntry(_, _, t, store)
466451
or
452+
hasSyntheticContent(store) and
467453
exists(PropagateContentFlow::AccessPath mid, Type midType |
468-
synthPathEntry(_, _, midType, mid) and synthPathStepRec(midType, mid.reverse(), t, store)
454+
hasSyntheticContent(mid) and
455+
step(midType, mid, t, store) and
456+
synthEntryReaches(midType, mid.reverse())
469457
)
470458
}
471459

java/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ private string printReadAccessPath(PropagateContentFlow::AccessPath ap) {
311311
private predicate mentionsField(PropagateContentFlow::AccessPath ap) {
312312
exists(ContentSet head, PropagateContentFlow::AccessPath tail |
313313
head = ap.getHead() and
314-
tail = ap.getTail() and
315-
(mentionsField(tail) or isField(head))
314+
tail = ap.getTail()
315+
|
316+
mentionsField(tail) or isField(head)
316317
)
317318
}
318319

@@ -369,11 +370,10 @@ private predicate apiContentFlow(
369370
private predicate hasSyntheticContent(PropagateContentFlow::AccessPath path) {
370371
exists(PropagateContentFlow::AccessPath tail, ContentSet head |
371372
head = path.getHead() and
372-
tail = path.getTail() and
373-
(
374-
exists(getSyntheticName(head)) or
375-
hasSyntheticContent(tail)
376-
)
373+
tail = path.getTail()
374+
|
375+
exists(getSyntheticName(head)) or
376+
hasSyntheticContent(tail)
377377
)
378378
}
379379

@@ -425,24 +425,6 @@ private module AccessPathSyntheticValidation {
425425
step(t1, read, t2, store)
426426
}
427427

428-
/**
429-
* Takes one or more synthetic steps.
430-
* Synth ->+ Synth
431-
*/
432-
private predicate synthPathStepRec(
433-
Type t1, PropagateContentFlow::AccessPath read, Type t2, PropagateContentFlow::AccessPath store
434-
) {
435-
hasSyntheticContent(read) and
436-
hasSyntheticContent(store) and
437-
(
438-
step(t1, read, t2, store)
439-
or
440-
exists(PropagateContentFlow::AccessPath mid, Type midType |
441-
step(t1, read, midType, mid) and synthPathStepRec(midType, mid.reverse(), t2, store)
442-
)
443-
)
444-
}
445-
446428
/**
447429
* Holds if there exists a path of steps from `read` to an exit.
448430
*
@@ -451,8 +433,11 @@ private module AccessPathSyntheticValidation {
451433
private predicate reachesSynthExit(Type t, PropagateContentFlow::AccessPath read) {
452434
synthPathExit(t, read, _, _)
453435
or
436+
hasSyntheticContent(read) and
454437
exists(PropagateContentFlow::AccessPath mid, Type midType |
455-
synthPathStepRec(t, read, midType, mid) and synthPathExit(midType, mid.reverse(), _, _)
438+
hasSyntheticContent(mid) and
439+
step(t, read, midType, mid) and
440+
reachesSynthExit(midType, mid.reverse())
456441
)
457442
}
458443

@@ -464,8 +449,11 @@ private module AccessPathSyntheticValidation {
464449
private predicate synthEntryReaches(Type t, PropagateContentFlow::AccessPath store) {
465450
synthPathEntry(_, _, t, store)
466451
or
452+
hasSyntheticContent(store) and
467453
exists(PropagateContentFlow::AccessPath mid, Type midType |
468-
synthPathEntry(_, _, midType, mid) and synthPathStepRec(midType, mid.reverse(), t, store)
454+
hasSyntheticContent(mid) and
455+
step(midType, mid, t, store) and
456+
synthEntryReaches(midType, mid.reverse())
469457
)
470458
}
471459

0 commit comments

Comments
 (0)