From f9c7ea1c1da46c5dbf6d8dc0762cec5f1558f807 Mon Sep 17 00:00:00 2001 From: Esben Sparre Andreasen Date: Wed, 30 Mar 2022 23:10:14 +0200 Subject: [PATCH] improve feature tests with more cases --- .../FeatureValue.expected | 38 +++++++++++++++++++ .../NonTotalFeature.expected | 32 ++++++++++++++++ .../test/generic_feature_testing/test.html | 3 ++ .../test/generic_feature_testing/test.js | 17 ++++++--- 4 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.html diff --git a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/FeatureValue.expected b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/FeatureValue.expected index 6b0a4b9e6a4..1577c7aee41 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/FeatureValue.expected +++ b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/FeatureValue.expected @@ -1,3 +1,9 @@ +| test.html:2:61:2:68 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | +| test.html:2:61:2:68 | endpoint | argumentIndex | 0 | +| test.html:2:61:2:68 | endpoint | calleeAccessPath | | +| test.html:2:61:2:68 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | $event.target.files.item | +| test.html:2:61:2:68 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.html:2:61:2:68 | endpoint | calleeName | item | | test.js:2:7:2:14 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | | test.js:2:7:2:14 | endpoint | argumentIndex | 0 | | test.js:2:7:2:14 | endpoint | calleeAccessPath | | @@ -27,3 +33,35 @@ | test.js:7:17:7:24 | endpoint | calleeAccessPath | | | test.js:7:17:7:24 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | o.m | | test.js:7:17:7:24 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.js:8:11:8:18 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | ? | +| test.js:8:11:8:18 | endpoint | calleeAccessPath | | +| test.js:8:11:8:18 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | F | +| test.js:8:11:8:18 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.js:9:17:9:24 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | +| test.js:9:17:9:24 | endpoint | argumentIndex | 0 | +| test.js:9:17:9:24 | endpoint | calleeAccessPath | | +| test.js:9:17:9:24 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | o.m().m().m | +| test.js:9:17:9:24 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.js:9:17:9:24 | endpoint | calleeName | m | +| test.js:10:9:10:16 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | +| test.js:10:9:10:16 | endpoint | argumentIndex | 0 | +| test.js:10:9:10:16 | endpoint | calleeAccessPath | | +| test.js:10:9:10:16 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | f() | +| test.js:10:9:10:16 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.js:11:12:11:19 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | +| test.js:11:12:11:19 | endpoint | argumentIndex | 0 | +| test.js:11:12:11:19 | endpoint | calleeAccessPath | | +| test.js:11:12:11:19 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | o.?.m | +| test.js:11:12:11:19 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.js:11:12:11:19 | endpoint | calleeName | m | +| test.js:12:16:12:23 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | +| test.js:12:16:12:23 | endpoint | argumentIndex | 0 | +| test.js:12:16:12:23 | endpoint | calleeAccessPath | | +| test.js:12:16:12:23 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | o.m.?.p.m | +| test.js:12:16:12:23 | endpoint | calleeAccessPathWithStructuralInfo | | +| test.js:12:16:12:23 | endpoint | calleeName | m | +| test.js:13:15:13:22 | endpoint | ParameterAccessPathSimpleFromArgumentTraversal | 0 | +| test.js:13:15:13:22 | endpoint | argumentIndex | 0 | +| test.js:13:15:13:22 | endpoint | calleeAccessPath | | +| test.js:13:15:13:22 | endpoint | calleeAccessPathSimpleFromArgumentTraversal | (await p) | +| test.js:13:15:13:22 | endpoint | calleeAccessPathWithStructuralInfo | | diff --git a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/NonTotalFeature.expected b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/NonTotalFeature.expected index 5c7ab7db0e0..4a2787fca30 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/NonTotalFeature.expected +++ b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/NonTotalFeature.expected @@ -1,3 +1,7 @@ +| test.html:2:61:2:68 | endpoint | calleeApiName | +| test.html:2:61:2:68 | endpoint | enclosingFunctionBody | +| test.html:2:61:2:68 | endpoint | enclosingFunctionName | +| test.html:2:61:2:68 | endpoint | receiverName | | test.js:2:7:2:14 | endpoint | calleeApiName | | test.js:2:7:2:14 | endpoint | enclosingFunctionBody | | test.js:2:7:2:14 | endpoint | enclosingFunctionName | @@ -29,3 +33,31 @@ | test.js:7:17:7:24 | endpoint | enclosingFunctionBody | | test.js:7:17:7:24 | endpoint | enclosingFunctionName | | test.js:7:17:7:24 | endpoint | receiverName | +| test.js:8:11:8:18 | endpoint | argumentIndex | +| test.js:8:11:8:18 | endpoint | calleeApiName | +| test.js:8:11:8:18 | endpoint | calleeName | +| test.js:8:11:8:18 | endpoint | enclosingFunctionBody | +| test.js:8:11:8:18 | endpoint | enclosingFunctionName | +| test.js:8:11:8:18 | endpoint | receiverName | +| test.js:9:17:9:24 | endpoint | calleeApiName | +| test.js:9:17:9:24 | endpoint | enclosingFunctionBody | +| test.js:9:17:9:24 | endpoint | enclosingFunctionName | +| test.js:9:17:9:24 | endpoint | receiverName | +| test.js:10:9:10:16 | endpoint | calleeApiName | +| test.js:10:9:10:16 | endpoint | calleeName | +| test.js:10:9:10:16 | endpoint | enclosingFunctionBody | +| test.js:10:9:10:16 | endpoint | enclosingFunctionName | +| test.js:10:9:10:16 | endpoint | receiverName | +| test.js:11:12:11:19 | endpoint | calleeApiName | +| test.js:11:12:11:19 | endpoint | enclosingFunctionBody | +| test.js:11:12:11:19 | endpoint | enclosingFunctionName | +| test.js:11:12:11:19 | endpoint | receiverName | +| test.js:12:16:12:23 | endpoint | calleeApiName | +| test.js:12:16:12:23 | endpoint | enclosingFunctionBody | +| test.js:12:16:12:23 | endpoint | enclosingFunctionName | +| test.js:12:16:12:23 | endpoint | receiverName | +| test.js:13:15:13:22 | endpoint | calleeApiName | +| test.js:13:15:13:22 | endpoint | calleeName | +| test.js:13:15:13:22 | endpoint | enclosingFunctionBody | +| test.js:13:15:13:22 | endpoint | enclosingFunctionName | +| test.js:13:15:13:22 | endpoint | receiverName | diff --git a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.html b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.html new file mode 100644 index 00000000000..3a0943e74a0 --- /dev/null +++ b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.js b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.js index b7a42fd53b0..0724d1ea833 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.js +++ b/javascript/ql/experimental/adaptivethreatmodeling/test/generic_feature_testing/test.js @@ -1,9 +1,14 @@ -(function(){ +(async function(){ f(endpoint); - f({p: endpoint}) - f({p: {q: endpoint}}) + f({p: endpoint}); + f({p: {q: endpoint}}); o.m(endpoint); - o.m({p: endpoint}) - o.m({p: {q: endpoint}}) - + o.m({p: endpoint}); + o.m({p: {q: endpoint}}); + new F(endpoint); + o.m().m().m(endpoint); + f()(endpoint); + o[x].m(endpoint); + o.m[x].p.m(endpoint); + (await p)(endpoint); }); \ No newline at end of file