Skip to content

Commit 96919ee

Browse files
author
Stephan Brandauer
committed
use ? for unknown parameternames
1 parent f8b3c27 commit 96919ee

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/EndpointFeatures.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ private module SyntacticUtilities {
563563
result =
564564
"(" +
565565
concat(string parameter, int i |
566-
parameter = f.getParameter(i).getName()
566+
parameter = getParameterNameOrUnknown(f.getParameter(i))
567567
|
568568
parameter, ", " order by i
569569
) + ")"
@@ -727,6 +727,13 @@ private module SyntacticUtilities {
727727
then result = ref.getPropertyName()
728728
else result = getUnknownSymbol()
729729
}
730+
731+
/**
732+
* Gets the parameter name if it exists, or `?` if it is unknown.
733+
*/
734+
string getParameterNameOrUnknown(Parameter p) {
735+
if exists(p.getName()) then result = p.getName() else result = getUnknownSymbol()
736+
}
730737
}
731738

732739
/**

javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/FeatureValue.expected

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| test.js:6:7:6:14 | endpoint | calleeApiName | lib3 |
1616
| test.js:6:7:6:14 | endpoint | calleeImports | ? lib3 |
1717
| test.js:6:7:6:14 | endpoint | calleeName | f |
18-
| test.js:6:7:6:14 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
18+
| test.js:6:7:6:14 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
1919
| test.js:6:7:6:14 | endpoint | contextSurroundingFunctionParameters | () |
2020
| test.js:6:7:6:14 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
2121
| test.js:6:7:6:14 | endpoint | enclosingFunctionName | |
@@ -26,7 +26,7 @@
2626
| test.js:7:11:7:18 | endpoint | calleeAccessPath | |
2727
| test.js:7:11:7:18 | endpoint | calleeAccessPathWithStructuralInfo | |
2828
| test.js:7:11:7:18 | endpoint | calleeImports | ? lib3 |
29-
| test.js:7:11:7:18 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
29+
| test.js:7:11:7:18 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
3030
| test.js:7:11:7:18 | endpoint | contextSurroundingFunctionParameters | () |
3131
| test.js:7:11:7:18 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
3232
| test.js:7:11:7:18 | endpoint | enclosingFunctionName | |
@@ -37,7 +37,7 @@
3737
| test.js:8:15:8:22 | endpoint | calleeAccessPath | |
3838
| test.js:8:15:8:22 | endpoint | calleeAccessPathWithStructuralInfo | |
3939
| test.js:8:15:8:22 | endpoint | calleeImports | ? lib3 |
40-
| test.js:8:15:8:22 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
40+
| test.js:8:15:8:22 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
4141
| test.js:8:15:8:22 | endpoint | contextSurroundingFunctionParameters | () |
4242
| test.js:8:15:8:22 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
4343
| test.js:8:15:8:22 | endpoint | enclosingFunctionName | |
@@ -50,7 +50,7 @@
5050
| test.js:9:9:9:16 | endpoint | calleeApiName | lib2 |
5151
| test.js:9:9:9:16 | endpoint | calleeImports | ? lib2 |
5252
| test.js:9:9:9:16 | endpoint | calleeName | m |
53-
| test.js:9:9:9:16 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
53+
| test.js:9:9:9:16 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
5454
| test.js:9:9:9:16 | endpoint | contextSurroundingFunctionParameters | () |
5555
| test.js:9:9:9:16 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
5656
| test.js:9:9:9:16 | endpoint | enclosingFunctionName | |
@@ -62,7 +62,7 @@
6262
| test.js:10:13:10:20 | endpoint | calleeAccessPath | |
6363
| test.js:10:13:10:20 | endpoint | calleeAccessPathWithStructuralInfo | |
6464
| test.js:10:13:10:20 | endpoint | calleeImports | ? lib2 |
65-
| test.js:10:13:10:20 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
65+
| test.js:10:13:10:20 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
6666
| test.js:10:13:10:20 | endpoint | contextSurroundingFunctionParameters | () |
6767
| test.js:10:13:10:20 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
6868
| test.js:10:13:10:20 | endpoint | enclosingFunctionName | |
@@ -73,7 +73,7 @@
7373
| test.js:11:17:11:24 | endpoint | calleeAccessPath | |
7474
| test.js:11:17:11:24 | endpoint | calleeAccessPathWithStructuralInfo | |
7575
| test.js:11:17:11:24 | endpoint | calleeImports | ? lib2 |
76-
| test.js:11:17:11:24 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
76+
| test.js:11:17:11:24 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
7777
| test.js:11:17:11:24 | endpoint | contextSurroundingFunctionParameters | () |
7878
| test.js:11:17:11:24 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
7979
| test.js:11:17:11:24 | endpoint | enclosingFunctionName | |
@@ -83,7 +83,7 @@
8383
| test.js:12:11:12:18 | endpoint | calleeAccessPath | |
8484
| test.js:12:11:12:18 | endpoint | calleeAccessPathWithStructuralInfo | |
8585
| test.js:12:11:12:18 | endpoint | calleeImports | lib1 |
86-
| test.js:12:11:12:18 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
86+
| test.js:12:11:12:18 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
8787
| test.js:12:11:12:18 | endpoint | contextSurroundingFunctionParameters | () |
8888
| test.js:12:11:12:18 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
8989
| test.js:12:11:12:18 | endpoint | enclosingFunctionName | |
@@ -96,7 +96,7 @@
9696
| test.js:13:17:13:24 | endpoint | calleeApiName | lib2 |
9797
| test.js:13:17:13:24 | endpoint | calleeImports | ? lib2 |
9898
| test.js:13:17:13:24 | endpoint | calleeName | m |
99-
| test.js:13:17:13:24 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
99+
| test.js:13:17:13:24 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
100100
| test.js:13:17:13:24 | endpoint | contextSurroundingFunctionParameters | () |
101101
| test.js:13:17:13:24 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
102102
| test.js:13:17:13:24 | endpoint | enclosingFunctionName | |
@@ -108,7 +108,7 @@
108108
| test.js:14:9:14:16 | endpoint | calleeAccessPathWithStructuralInfo | lib3 instanceorreturn instanceorreturn |
109109
| test.js:14:9:14:16 | endpoint | calleeApiName | lib3 |
110110
| test.js:14:9:14:16 | endpoint | calleeImports | ? lib3 |
111-
| test.js:14:9:14:16 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
111+
| test.js:14:9:14:16 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
112112
| test.js:14:9:14:16 | endpoint | contextSurroundingFunctionParameters | () |
113113
| test.js:14:9:14:16 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
114114
| test.js:14:9:14:16 | endpoint | enclosingFunctionName | |
@@ -121,7 +121,7 @@
121121
| test.js:15:12:15:19 | endpoint | calleeApiName | lib2 |
122122
| test.js:15:12:15:19 | endpoint | calleeImports | ? lib2 |
123123
| test.js:15:12:15:19 | endpoint | calleeName | m |
124-
| test.js:15:12:15:19 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
124+
| test.js:15:12:15:19 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
125125
| test.js:15:12:15:19 | endpoint | contextSurroundingFunctionParameters | () |
126126
| test.js:15:12:15:19 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
127127
| test.js:15:12:15:19 | endpoint | enclosingFunctionName | |
@@ -134,7 +134,7 @@
134134
| test.js:16:16:16:23 | endpoint | calleeApiName | lib2 |
135135
| test.js:16:16:16:23 | endpoint | calleeImports | ? lib2 |
136136
| test.js:16:16:16:23 | endpoint | calleeName | m |
137-
| test.js:16:16:16:23 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
137+
| test.js:16:16:16:23 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
138138
| test.js:16:16:16:23 | endpoint | contextSurroundingFunctionParameters | () |
139139
| test.js:16:16:16:23 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
140140
| test.js:16:16:16:23 | endpoint | enclosingFunctionName | |
@@ -146,7 +146,7 @@
146146
| test.js:17:15:17:22 | endpoint | calleeAccessPathWithStructuralInfo | lib1 member p instanceorreturn |
147147
| test.js:17:15:17:22 | endpoint | calleeApiName | lib1 |
148148
| test.js:17:15:17:22 | endpoint | calleeImports | lib1 |
149-
| test.js:17:15:17:22 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
149+
| test.js:17:15:17:22 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
150150
| test.js:17:15:17:22 | endpoint | contextSurroundingFunctionParameters | () |
151151
| test.js:17:15:17:22 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
152152
| test.js:17:15:17:22 | endpoint | enclosingFunctionName | |
@@ -159,7 +159,7 @@
159159
| test.js:18:27:18:34 | endpoint | calleeApiName | foo |
160160
| test.js:18:27:18:34 | endpoint | calleeImports | foo |
161161
| test.js:18:27:18:34 | endpoint | calleeName | baz |
162-
| test.js:18:27:18:34 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
162+
| test.js:18:27:18:34 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
163163
| test.js:18:27:18:34 | endpoint | contextSurroundingFunctionParameters | () |
164164
| test.js:18:27:18:34 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
165165
| test.js:18:27:18:34 | endpoint | enclosingFunctionName | |
@@ -172,7 +172,7 @@
172172
| test.js:20:13:20:20 | endpoint | calleeApiName | lib1 |
173173
| test.js:20:13:20:20 | endpoint | calleeImports | lib1 |
174174
| test.js:20:13:20:20 | endpoint | calleeName | bar |
175-
| test.js:20:13:20:20 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
175+
| test.js:20:13:20:20 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
176176
| test.js:20:13:20:20 | endpoint | contextSurroundingFunctionParameters | () |
177177
| test.js:20:13:20:20 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
178178
| test.js:20:13:20:20 | endpoint | enclosingFunctionName | |
@@ -183,7 +183,7 @@
183183
| test.js:22:21:22:28 | endpoint | calleeAccessPathWithStructuralInfo | lib3 instanceorreturn |
184184
| test.js:22:21:22:28 | endpoint | calleeApiName | lib3 |
185185
| test.js:22:21:22:28 | endpoint | calleeImports | ? lib2 lib3 |
186-
| test.js:22:21:22:28 | endpoint | contextFunctionInterfacesInFile | f(endpoint)\nfoo()\ng()\nm() |
186+
| test.js:22:21:22:28 | endpoint | contextFunctionInterfacesInFile | f(?)\nfoo()\ng()\nm() |
187187
| test.js:22:21:22:28 | endpoint | contextSurroundingFunctionParameters | () |
188188
| test.js:22:21:22:28 | endpoint | enclosingFunctionBody | f endpoint f p endpoint f p q endpoint o m endpoint o m p endpoint o m p q endpoint F endpoint o m m m endpoint f endpoint o x m endpoint o m x p m endpoint p endpoint foo bar baz endpoint foo bar endpoint f f o m endpoint |
189189
| test.js:22:21:22:28 | endpoint | enclosingFunctionName | |

javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const f = require('lib3');
2222
(f() ? f : o.m)(endpoint);
2323
});
2424

25-
function f(endpoint) {}
25+
function f({ endpoint }) {}
2626

2727
const g = async () => undefined;
2828

0 commit comments

Comments
 (0)