@@ -45,12 +45,55 @@ private class ThreatModelSourceFromDataExtension extends ThreatModelSource::Rang
4545 }
4646}
4747
48+ /**
49+ * Holds if `path` is an input or output spec for a summary with the given `base` node.
50+ */
51+ pragma [ nomagic]
52+ private predicate relevantInputOutputPath ( API:: InvokeNode base , AccessPath inputOrOutput ) {
53+ exists ( string type , string input , string output , string path |
54+ ModelOutput:: resolvedSummaryBase ( type , path , base ) and
55+ ModelOutput:: relevantSummaryModel ( type , path , input , output , _, _) and
56+ inputOrOutput = [ input , output ]
57+ )
58+ }
59+
60+ /**
61+ * Gets the API node for the first `n` tokens of the given input/output path, evaluated relative to `baseNode`.
62+ */
63+ private API:: Node getNodeFromInputOutputPath ( API:: InvokeNode baseNode , AccessPath path , int n ) {
64+ relevantInputOutputPath ( baseNode , path ) and
65+ (
66+ n = 1 and
67+ result = Shared:: getSuccessorFromInvoke ( baseNode , path .getToken ( 0 ) )
68+ or
69+ result =
70+ Shared:: getSuccessorFromNode ( getNodeFromInputOutputPath ( baseNode , path , n - 1 ) ,
71+ path .getToken ( n - 1 ) )
72+ )
73+ }
74+
75+ /**
76+ * Gets the API node for the given input/output path, evaluated relative to `baseNode`.
77+ */
78+ private API:: Node getNodeFromInputOutputPath ( API:: InvokeNode baseNode , AccessPath path ) {
79+ result = getNodeFromInputOutputPath ( baseNode , path , path .getNumToken ( ) )
80+ }
81+
82+ private predicate summaryStep ( API:: Node pred , API:: Node succ , string kind ) {
83+ exists ( string type , string path , API:: InvokeNode base , AccessPath input , AccessPath output |
84+ ModelOutput:: relevantSummaryModel ( type , path , input , output , kind , _) and
85+ ModelOutput:: resolvedSummaryBase ( type , path , base ) and
86+ pred = getNodeFromInputOutputPath ( base , input ) and
87+ succ = getNodeFromInputOutputPath ( base , output )
88+ )
89+ }
90+
4891/**
4992 * Like `ModelOutput::summaryStep` but with API nodes mapped to data-flow nodes.
5093 */
5194private predicate summaryStepNodes ( DataFlow:: Node pred , DataFlow:: Node succ , string kind ) {
5295 exists ( API:: Node predNode , API:: Node succNode |
53- Specific :: summaryStep ( predNode , succNode , kind ) and
96+ summaryStep ( predNode , succNode , kind ) and
5497 pred = predNode .asSink ( ) and
5598 succ = succNode .asSource ( )
5699 )
0 commit comments