Skip to content

Commit c2141b6

Browse files
yoffRasmusWL
andauthored
Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
1 parent 280a9b4 commit c2141b6

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

python/ql/lib/modeling/ModelEditor.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ abstract class Endpoint instanceof Scope {
7575
* Gets a string representation of the parameters of this endpoint.
7676
*
7777
* The string follows a specific format:
78-
* - Positional parameters are listed in order, separated by commas.
79-
* - Keyword parameters are listed in order, separated by commas, each followed by a colon.
78+
* - Normal parameters(where arguments can be passed as either positional or keyword) are listed in order, separated by commas.
79+
* - Keyword-only parameters are listed in order, separated by commas, each followed by a colon.
8080
* - In the future, positional-only parameters will be listed in order, separated by commas, each followed by a slash.
8181
*/
8282
abstract string getParameters();
8383

8484
/**
8585
* Gets a boolean that is true iff this endpoint is supported by existing modeling.
8686
*
87-
* The check only takes Models ss Data extension models into account.
87+
* The check only takes Models as Data extension models into account.
8888
*/
8989
abstract boolean getSupportedStatus();
9090

python/ql/lib/modeling/Util.qll

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,9 @@ string computeScopePath(Scope scope) {
3838
result = scope.(Module).getName()
3939
else
4040
//recursive cases
41-
if scope instanceof Class
41+
if scope instanceof Class or scope instanceof Function
4242
then
43-
result = computeScopePath(scope.(Class).getEnclosingScope()) + "." + scope.(Class).getName()
44-
else
45-
if scope instanceof Function
46-
then
47-
result =
48-
computeScopePath(scope.(Function).getEnclosingScope()) + "." + scope.(Function).getName()
43+
result = computeScopePath(scope.getEnclosingScope()) + "." + scope.getName()
4944
else result = "unknown: " + scope.toString()
5045
}
5146

@@ -72,19 +67,17 @@ module FindModel<modelSig/2 model> {
7267
*/
7368
bindingset[path, member]
7469
string possibleMemberPathPrefix(string path, string member) {
75-
// functionName must be a substring of path
7670
exists(int index | index = path.indexOf(["Member", "Method"] + "[" + member + "]") |
7771
result = path.prefix(index)
7872
)
7973
}
8074

8175
/**
82-
* Holds if `(type,path)` evaluates to the given entity, when evalauted from a client of the current library.
76+
* Holds if `(type,path)` identifies `scope`.
8377
*/
8478
bindingset[type, path]
8579
predicate pathToScope(Scope scope, string type, string path) {
86-
scope.getLocation().getFile() instanceof RelevantFile and
87-
scope.isPublic() and // only public methods are modeled
80+
scope instanceof Endpoint
8881
computeScopePath(scope) =
8982
type.replaceAll("!", "") + "." +
9083
path.replaceAll("Member[", "").replaceAll("]", "").replaceAll("Instance.", "") +

python/ql/test/modelling/FrameworkModeEndpoints.ext.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ extensions:
1717
pack: codeql/python-all
1818
extensible: typeModel
1919
data:
20-
- ["MyPackage.Foo.C2!","MyPackage","Member[Foo].Member[C3].Member[get_C2_instance].ReturnValue"]
20+
- ["MyPackage.Foo.C2","MyPackage","Member[Foo].Member[C3].Member[get_C2_instance].ReturnValue"]

0 commit comments

Comments
 (0)