Go: Refactor SummarizedCallable.

Equivalent of https://github.com/github/codeql/pull/9210
This commit is contained in:
Owen Mansel-Chan
2022-10-20 14:41:22 +01:00
parent c768f04e32
commit 282699e5b5
2 changed files with 7 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ private newtype TNode =
MkGlobalFunctionNode(Function f) or
MkSummarizedParameterNode(DataFlowCallable c, int i) {
not exists(c.getFuncDef()) and
c instanceof SummarizedCallable and
c.asCallable() instanceof SummarizedCallable and
(
i in [0 .. c.getType().getNumParameter() - 1]
or
@@ -115,7 +115,7 @@ module Public {
exists(DataFlowCallable dfc | result = dfc.asCallable() |
this = MkSummarizedParameterNode(dfc, _)
or
this = MkSummaryInternalNode(dfc, _)
this = MkSummaryInternalNode(dfc.asCallable(), _)
)
}

View File

@@ -14,6 +14,10 @@ private module FlowSummaries {
private import semmle.go.dataflow.FlowSummary as F
}
class SummarizedCallableBase = Callable;
DataFlowCallable inject(SummarizedCallable c) { result.asCallable() = c }
/** Holds if `i` is a valid parameter position. */
predicate parameterPosition(int i) {
i = [-1 .. any(DataFlowCallable c).getType().getNumParameter()]
@@ -87,7 +91,7 @@ DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) { none() }
* `input`, output specification `output`, kind `kind`, and a flag `generated`
* stating whether the summary is autogenerated.
*/
predicate summaryElement(DataFlowCallable c, string input, string output, string kind, boolean generated) {
predicate summaryElement(Callable c, string input, string output, string kind, boolean generated) {
exists(
string namespace, string type, boolean subtypes, string name, string signature, string ext
|