Skip to content

Commit 63c71b4

Browse files
committed
Add model validation for constructor summary models
1 parent 219ea28 commit 63c71b4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,24 @@ module ModelValidation {
367367
)
368368
}
369369

370+
string getIncorrectConstructorSummaryOutput() {
371+
exists(string namespace, string type, string name, string output |
372+
summaryModel(namespace, type, _, name, _, _, _, output, _, _, _)
373+
|
374+
type = name and
375+
output.matches("ReturnValue%") and
376+
result =
377+
"Constructor model for " + namespace + "." + type +
378+
" should use `Argument[this]` in the output, not `ReturnValue`."
379+
)
380+
}
381+
370382
/** Holds if some row in a MaD flow model appears to contain typos. */
371383
query predicate invalidModelRow(string msg) {
372384
msg =
373385
[
374386
getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(),
375-
KindVal::getInvalidModelKind()
387+
getIncorrectConstructorSummaryOutput(), KindVal::getInvalidModelKind()
376388
]
377389
}
378390
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| Constructor model for java.net.URI should use `Argument[this]` in the output, not `ReturnValue`. |
2+
| Constructor model for java.util.zip.ZipEntry should use `Argument[this]` in the output, not `ReturnValue`. |
3+
| Constructor model for org.apache.hc.core5.http.io.entity.BasicHttpEntity should use `Argument[this]` in the output, not `ReturnValue`. |
4+
| Constructor model for org.apache.hc.core5.http.io.entity.BufferedHttpEntity should use `Argument[this]` in the output, not `ReturnValue`. |
5+
| Constructor model for org.apache.hc.core5.http.io.entity.HttpEntityWrapper should use `Argument[this]` in the output, not `ReturnValue`. |
6+
| Constructor model for org.apache.hc.core5.http.io.entity.InputStreamEntity should use `Argument[this]` in the output, not `ReturnValue`. |
7+
| Constructor model for org.apache.http.entity.BufferedHttpEntity should use `Argument[this]` in the output, not `ReturnValue`. |
8+
| Constructor model for org.apache.http.entity.HttpEntityWrapper should use `Argument[this]` in the output, not `ReturnValue`. |
9+
| Constructor model for org.apache.http.entity.InputStreamEntity should use `Argument[this]` in the output, not `ReturnValue`. |

0 commit comments

Comments
 (0)