Skip to content

Commit 4c5cd0c

Browse files
committed
Add model validation for constructor summary models
1 parent 219ea28 commit 4c5cd0c

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

java/ql/lib/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,18 @@ module ModelValidation {
375375
KindVal::getInvalidModelKind()
376376
]
377377
}
378+
379+
query predicate getIncorrectConstructorSummaryModel(string msg) {
380+
exists(string namespace, string type, string name, string output |
381+
summaryModel(namespace, type, _, name, _, _, _, output, _, _, _)
382+
|
383+
type = name and
384+
output.matches("ReturnValue%") and
385+
msg =
386+
"Constructor model for " + namespace + "." + type +
387+
" should use `Argument[this]` in the output, not `ReturnValue`."
388+
)
389+
}
378390
}
379391

380392
pragma[nomagic]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
invalidModelRow
2+
getIncorrectConstructorSummaryModel
3+
| Constructor model for java.net.URI should use `Argument[this]` in the output, not `ReturnValue`. |
4+
| Constructor model for java.util.zip.ZipEntry should use `Argument[this]` in the output, not `ReturnValue`. |
5+
| Constructor model for org.apache.hc.core5.http.io.entity.BasicHttpEntity should use `Argument[this]` in the output, not `ReturnValue`. |
6+
| Constructor model for org.apache.hc.core5.http.io.entity.BufferedHttpEntity should use `Argument[this]` in the output, not `ReturnValue`. |
7+
| Constructor model for org.apache.hc.core5.http.io.entity.HttpEntityWrapper should use `Argument[this]` in the output, not `ReturnValue`. |
8+
| Constructor model for org.apache.hc.core5.http.io.entity.InputStreamEntity should use `Argument[this]` in the output, not `ReturnValue`. |
9+
| Constructor model for org.apache.http.entity.BufferedHttpEntity should use `Argument[this]` in the output, not `ReturnValue`. |
10+
| Constructor model for org.apache.http.entity.HttpEntityWrapper should use `Argument[this]` in the output, not `ReturnValue`. |
11+
| Constructor model for org.apache.http.entity.InputStreamEntity should use `Argument[this]` in the output, not `ReturnValue`. |

0 commit comments

Comments
 (0)