GeezerVison is showing github.com — Add model validation for constructor summary models · github/codeql@63e8061
File tree
Expand file treeCollapse file tree
Open diff view settings
cpp/ql/lib/semmle/code/cpp/dataflow
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll +15-1Lines changed: 15 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -353,12 +353,26 @@ module CsvValidation { |
353 | 353 | ) |
354 | 354 | } |
355 | 355 |
|
| 356 | + string getIncorrectConstructorSummaryOutput() { |
| 357 | + exists(string namespace, string type, string name, string output | |
| 358 | + type = name or |
| 359 | + type = name + "<" + any(string s) |
| 360 | + | |
| 361 | + summaryModel(namespace, type, _, name, _, _, _, output, _, _, _) and |
| 362 | + output.matches("ReturnValue%") and |
| 363 | + result = |
| 364 | + "Constructor model for " + namespace + "." + type + |
| 365 | + " should use `Argument[-1]` in the output, not `ReturnValue`." |
| 366 | + ) |
| 367 | + } |
| 368 | + |
356 | 369 | /** Holds if some row in a CSV-based flow model appears to contain typos. */ |
357 | 370 | query predicate invalidModelRow(string msg) { |
358 | 371 | msg = |
359 | 372 | [ |
360 | 373 | getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(), |
361 | | - getInvalidModelSubtype(), getInvalidModelColumnCount(), KindVal::getInvalidModelKind() |
| 374 | + getInvalidModelSubtype(), getInvalidModelColumnCount(), KindVal::getInvalidModelKind(), |
| 375 | + getIncorrectConstructorSummaryOutput() |
362 | 376 | ] |
363 | 377 | } |
364 | 378 | } |
|