Compare commits

...

4 Commits

Author SHA1 Message Date
Koen Vlaswinkel
808fa46704 Add better support for element types 2023-12-01 15:06:06 +01:00
Koen Vlaswinkel
a06767d545 Add ArrayElement for Java 2023-12-01 14:52:25 +01:00
Koen Vlaswinkel
7d456058d4 Add application mode suggestion queries 2023-12-01 14:23:51 +01:00
Koen Vlaswinkel
d392b9f165 Add access path suggestions queries 2023-11-30 10:32:59 +01:00
19 changed files with 865 additions and 6 deletions

View File

@@ -0,0 +1,112 @@
/** Provides classes and predicates related to handling access path suggestions for the VS Code extension. */
private import csharp
private import semmle.code.csharp.commons.Collections as Collections
private import FrameworkModeEndpointsQuery
private import ModelEditor
/** A collection type */
abstract private class CollectionType extends RefType {
abstract Type getElementType();
}
private class ArrayCollectionType extends CollectionType, ArrayType {
override Type getElementType() { result = this.(ArrayType).getElementType() }
}
private class GenericCollectionType extends CollectionType, ConstructedType,
Collections::CollectionType
{
GenericCollectionType() {
// Only include collections with a single type argument, which we expect to be lists.
count(int i | exists(this.getTypeArgument(i))) = 1
}
override Type getElementType() { result = this.getTypeArgument(0) }
}
private predicate nestedPathBase(
Endpoint endpoint, Element element, string value, string details, string defType,
boolean isInputOnly, boolean isOutputOnly
) {
endpoint.getReturnType() = element and
isInputOnly = false and
isOutputOnly = true and
value = "ReturnValue" and
details = element.toString() and
defType = "return"
or
exists(Parameter parameter |
endpoint.getAParameter() = parameter and parameter.getType() = element
|
value = "Argument[" + parameter.getPosition() + "]" and
details = parameter.getType().toString() + " " + parameter.getName() and
isInputOnly = false and
isOutputOnly = false and
defType = "parameter"
)
or
endpoint.getDeclaringType() = element and
isInputOnly = false and
isOutputOnly = false and
value = "Argument[this]" and
details = element.toString() and
defType = "class"
}
private predicate nestedPathRec(
Endpoint endpoint, Element element, string value, string details, string defType,
boolean isInputOnly, boolean isOutputOnly, int pathLength
) {
pathLength < 8 and
(
nestedPathBase(endpoint, element, value, details, defType, isInputOnly, isOutputOnly) and
pathLength = 1
or
exists(
Type prevType, string prevValue, string prevDetails, string prevDefType,
boolean prevIsInputOnly, boolean prevIsOutputOnly, int prevPathLength
|
nestedPathRec(endpoint, prevType, prevValue, prevDetails, prevDefType, prevIsInputOnly,
prevIsOutputOnly, prevPathLength) and
pathLength = prevPathLength + 1
|
element = prevType.(CollectionType).getElementType() and
value = prevValue + ".Element" and
details = element.toString() and
isInputOnly = prevIsInputOnly and
isOutputOnly = prevIsOutputOnly and
defType = "array"
or
element = prevType.(CollectionType).getElementType() and
(value = prevValue + ".WithoutElement" or value = prevValue + ".WithElement") and
details = element.toString() and
isInputOnly = true and
isOutputOnly = prevIsOutputOnly and
defType = "array"
or
element = prevType.(RefType).getAField() and
not element.(Field).isStatic() and
value = prevValue + ".Field[" + element.(Field).getFullyQualifiedName() + "]" and
details = element.(Field).getType().toString() + " " + element.(Field).getName() and
isInputOnly = false and
isOutputOnly = false and
defType = "field"
or
element = prevType.(RefType).getAProperty() and
not element.(Property).isStatic() and
value = prevValue + ".Property[" + element.(Property).getFullyQualifiedName() + "]" and
details = element.(Property).getType().toString() + " " + element.(Property).getName() and
isInputOnly = false and
isOutputOnly = false and
defType = "property"
)
)
}
predicate nestedPath(
Endpoint endpoint, Element element, string value, string details, string defType,
boolean isInputOnly, boolean isOutputOnly
) {
nestedPathRec(endpoint, element, value, details, defType, isInputOnly, isOutputOnly, _)
}

View File

@@ -0,0 +1,45 @@
/**
* @name Fetch suggestions for access paths of input and output parameters of a method (application mode)
* @description A list of access paths for input and output parameters of a method. Excludes test and generated code.
* @kind table
* @id csharp/utils/modeleditor/application-mode-access-path-suggestions
* @tags modeleditor access-path-suggestions application-mode
*/
private import csharp
private import AccessPathSuggestions
private import ApplicationModeEndpointsQuery
private import ModelEditor
predicate suggestions(
string namespace, string typeName, string methodName, string methodParameters, string value,
string details, string defType, boolean isInputOnly, boolean isOutputOnly
) {
exists(ExternalEndpoint endpoint, Element element |
nestedPath(endpoint, element, value, details, defType, isInputOnly, isOutputOnly)
|
exists(aUsage(endpoint)) and
namespace = endpoint.getNamespace() and
typeName = endpoint.getTypeName() and
methodName = endpoint.getName() and
methodParameters = endpoint.getParameterTypes()
)
}
predicate inputSuggestions(
string namespace, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(namespace, typeName, methodName, methodParameters, value, details, defType, _, false)
}
predicate outputSuggestions(
string namespace, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(namespace, typeName, methodName, methodParameters, value, details, defType, false, _)
}
query predicate input = inputSuggestions/7;
query predicate output = outputSuggestions/7;

View File

@@ -10,8 +10,6 @@ import csharp
import ApplicationModeEndpointsQuery
import ModelEditor
private Call aUsage(ExternalEndpoint api) { result.getTarget().getUnboundDeclaration() = api }
from ExternalEndpoint endpoint, boolean supported, Call usage, string type, string classification
where
supported = isSupported(endpoint) and

View File

@@ -6,6 +6,8 @@ private import semmle.code.csharp.dataflow.internal.TaintTrackingPrivate
private import semmle.code.csharp.security.dataflow.flowsources.Remote
private import ModelEditor
Call aUsage(ExternalEndpoint api) { result.getTarget().getUnboundDeclaration() = api }
/**
* A class of effectively public callables in library code.
*/

View File

@@ -0,0 +1,44 @@
/**
* @name Fetch suggestions for access paths of input and output parameters of a method (framework mode)
* @description A list of access paths for input and output parameters of a method. Excludes test and generated code.
* @kind table
* @id csharp/utils/modeleditor/framework-mode-access-path-suggestions
* @tags modeleditor access-path-suggestions framework-mode
*/
private import csharp
private import AccessPathSuggestions
private import FrameworkModeEndpointsQuery
private import ModelEditor
predicate suggestions(
string namespace, string typeName, string methodName, string methodParameters, string value,
string details, string defType, boolean isInputOnly, boolean isOutputOnly
) {
exists(PublicEndpointFromSource endpoint, Element element |
nestedPath(endpoint, element, value, details, defType, isInputOnly, isOutputOnly)
|
namespace = endpoint.getNamespace() and
typeName = endpoint.getTypeName() and
methodName = endpoint.getName() and
methodParameters = endpoint.getParameterTypes()
)
}
predicate inputSuggestions(
string namespace, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(namespace, typeName, methodName, methodParameters, value, details, defType, _, false)
}
predicate outputSuggestions(
string namespace, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(namespace, typeName, methodName, methodParameters, value, details, defType, false, _)
}
query predicate input = inputSuggestions/7;
query predicate output = outputSuggestions/7;

View File

@@ -0,0 +1,40 @@
input
| System | Console | ReadLine | () | Argument[this] | Console | class |
| System | Console | ReadLine | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| System | Console | ReadLine | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| System | Console | ReadLine | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| System | Console | Write | (System.Object) | Argument[0] | Object value | parameter |
| System | Console | Write | (System.Object) | Argument[this] | Console | class |
| System | Console | WriteLine | (System.Object) | Argument[0] | Object value | parameter |
| System | Console | WriteLine | (System.Object) | Argument[this] | Console | class |
| System | Console | WriteLine | (System.String) | Argument[0] | String value | parameter |
| System | Console | WriteLine | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| System | Console | WriteLine | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| System | Console | WriteLine | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| System | Console | WriteLine | (System.String) | Argument[this] | Console | class |
| System | Console | get_BackgroundColor | () | Argument[this] | Console | class |
| System | Console | set_ForegroundColor | (System.ConsoleColor) | Argument[0] | ConsoleColor value | parameter |
| System | Console | set_ForegroundColor | (System.ConsoleColor) | Argument[this] | Console | class |
output
| System | Console | ReadLine | () | Argument[this] | Console | class |
| System | Console | ReadLine | () | ReturnValue | String | return |
| System | Console | ReadLine | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| System | Console | ReadLine | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| System | Console | ReadLine | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| System | Console | Write | (System.Object) | Argument[0] | Object value | parameter |
| System | Console | Write | (System.Object) | Argument[this] | Console | class |
| System | Console | Write | (System.Object) | ReturnValue | Void | return |
| System | Console | WriteLine | (System.Object) | Argument[0] | Object value | parameter |
| System | Console | WriteLine | (System.Object) | Argument[this] | Console | class |
| System | Console | WriteLine | (System.Object) | ReturnValue | Void | return |
| System | Console | WriteLine | (System.String) | Argument[0] | String value | parameter |
| System | Console | WriteLine | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| System | Console | WriteLine | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| System | Console | WriteLine | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| System | Console | WriteLine | (System.String) | Argument[this] | Console | class |
| System | Console | WriteLine | (System.String) | ReturnValue | Void | return |
| System | Console | get_BackgroundColor | () | Argument[this] | Console | class |
| System | Console | get_BackgroundColor | () | ReturnValue | ConsoleColor | return |
| System | Console | set_ForegroundColor | (System.ConsoleColor) | Argument[0] | ConsoleColor value | parameter |
| System | Console | set_ForegroundColor | (System.ConsoleColor) | Argument[this] | Console | class |
| System | Console | set_ForegroundColor | (System.ConsoleColor) | ReturnValue | Void | return |

View File

@@ -0,0 +1 @@
utils/modeleditor/ApplicationModeAccessPathSuggestions.ql

View File

@@ -0,0 +1,202 @@
input
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0] | String value | parameter |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | sourceStuff | () | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | sourceStuff | () | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicGenericClass`2 | stuff | (T) | Argument[0] | T arg | parameter |
| GitHub.CodeQL | PublicGenericClass`2 | stuff | (T) | Argument[this] | PublicGenericClass`2 | class |
| GitHub.CodeQL | PublicGenericClass`2 | stuff2`1 | (T2) | Argument[0] | T2 arg | parameter |
| GitHub.CodeQL | PublicGenericClass`2 | stuff2`1 | (T2) | Argument[this] | PublicGenericClass`2 | class |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[this] | PublicGenericInterface`1 | class |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff | (T) | Argument[0] | T arg | parameter |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff | (T) | Argument[this] | PublicGenericInterface`1 | class |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff2`1 | (T2) | Argument[0] | T2 arg | parameter |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff2`1 | (T2) | Argument[this] | PublicGenericInterface`1 | class |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0] | String value | parameter |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
output
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue | String | return |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | get_PublicProperty | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | neutralStuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | protectedStuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0] | String value | parameter |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | set_PublicProperty | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | sinkStuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicClass | sourceStuff | () | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | sourceStuff | () | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue | String | return |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | sourceStuff | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | staticStuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | stuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[this] | PublicClass | class |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicClass.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue | String | return |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicClass | summaryStuff | (System.String) | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicGenericClass`2 | stuff | (T) | Argument[0] | T arg | parameter |
| GitHub.CodeQL | PublicGenericClass`2 | stuff | (T) | Argument[this] | PublicGenericClass`2 | class |
| GitHub.CodeQL | PublicGenericClass`2 | stuff | (T) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicGenericClass`2 | stuff2`1 | (T2) | Argument[0] | T2 arg | parameter |
| GitHub.CodeQL | PublicGenericClass`2 | stuff2`1 | (T2) | Argument[this] | PublicGenericClass`2 | class |
| GitHub.CodeQL | PublicGenericClass`2 | stuff2`1 | (T2) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | Argument[this] | PublicGenericInterface`1 | class |
| GitHub.CodeQL | PublicGenericInterface`1 | staticStuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff | (T) | Argument[0] | T arg | parameter |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff | (T) | Argument[this] | PublicGenericInterface`1 | class |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff | (T) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff2`1 | (T2) | Argument[0] | T2 arg | parameter |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff2`1 | (T2) | Argument[this] | PublicGenericInterface`1 | class |
| GitHub.CodeQL | PublicGenericInterface`1 | stuff2`1 | (T2) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue | String | return |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue.Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue.Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | get_PublicProperty | () | ReturnValue.Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0] | String value | parameter |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | set_PublicProperty | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | staticStuff | (System.String) | ReturnValue | Void | return |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0] | String arg | parameter |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0].Field[System.String._firstChar] | Char _firstChar | field |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0].Field[System.String._stringLength] | Int32 _stringLength | field |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[0].Property[System.String.Length] | Int32 Length | property |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[this] | PublicInterface | class |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | Argument[this].Property[GitHub.CodeQL.PublicInterface.PublicProperty] | String PublicProperty | property |
| GitHub.CodeQL | PublicInterface | stuff | (System.String) | ReturnValue | Void | return |

View File

@@ -0,0 +1 @@
utils/modeleditor/FrameworkModeAccessPathSuggestions.ql

View File

@@ -0,0 +1,140 @@
/** Provides classes and predicates related to handling access path suggestions for the VS Code extension. */
private import java
private import semmle.code.java.Collections
private import semmle.code.java.Maps
private import semmle.code.java.dataflow.internal.ContainerFlow
private import ModelEditor
/**
* A type representing instantiations of class types
* that has a method which returns an iterator.
*/
private class IterableClass extends Class {
private Type elementType;
IterableClass() {
elementType =
unique(Type et |
exists(Method m, RefType return, GenericType t, int position | m.getDeclaringType() = t |
return = m.getReturnType() and
return.getSourceDeclaration().hasQualifiedName("java.util", "Iterator") and
t.getTypeParameter(position) = return.(ParameterizedType).getTypeArgument(0) and
instantiates(this, t, position, et)
)
)
}
/**
* Returns the iterator element type of `this`.
*/
Type getElementType() { result = elementType }
}
private predicate nestedPathBase(
Endpoint endpoint, Element element, string value, string details, string defType,
boolean isInputOnly, boolean isOutputOnly
) {
endpoint.getReturnType() = element and
isInputOnly = false and
isOutputOnly = true and
value = "ReturnValue" and
details = element.toString() and
defType = "return"
or
exists(Parameter parameter |
endpoint.getAParameter() = parameter and parameter.getType() = element
|
value = "Argument[" + parameter.getPosition() + "]" and
details = parameter.getType().toString() + " " + parameter.getName() and
isInputOnly = false and
isOutputOnly = false and
defType = "parameter"
)
or
endpoint.getDeclaringType() = element and
isInputOnly = false and
isOutputOnly = false and
value = "Argument[this]" and
details = element.toString() and
defType = "class"
}
private predicate nestedPathRec(
Endpoint endpoint, Element element, string value, string details, string defType,
boolean isInputOnly, boolean isOutputOnly, int pathLength
) {
pathLength < 8 and
(
nestedPathBase(endpoint, element, value, details, defType, isInputOnly, isOutputOnly) and
pathLength = 1
or
exists(
Type prevType, string prevValue, string prevDetails, string prevDefType,
boolean prevIsInputOnly, boolean prevIsOutputOnly, int prevPathLength
|
nestedPathRec(endpoint, prevType, prevValue, prevDetails, prevDefType, prevIsInputOnly,
prevIsOutputOnly, prevPathLength) and
pathLength = prevPathLength + 1
|
element = prevType.(Array).getComponentType() and
value = prevValue + ".ArrayElement" and
details = element.toString() and
isInputOnly = prevIsInputOnly and
isOutputOnly = prevIsOutputOnly and
defType = "array"
or
element = prevType.(IterableClass).getElementType() and
value = prevValue + ".Element" and
details = element.toString() and
isInputOnly = prevIsInputOnly and
isOutputOnly = prevIsOutputOnly and
defType = "array"
or
element = prevType.(ContainerType).getElementType() and
value = prevValue + ".Element" and
details = element.toString() and
isInputOnly = prevIsInputOnly and
isOutputOnly = prevIsOutputOnly and
defType = "variable"
or
element = prevType.(MapType).getKeyType() and
value = prevValue + ".MapKey" and
details = element.toString() and
isInputOnly = prevIsInputOnly and
isOutputOnly = prevIsOutputOnly and
defType = "key"
or
element = prevType.(MapType).getValueType() and
value = prevValue + ".MapValue" and
details = element.toString() and
isInputOnly = prevIsInputOnly and
isOutputOnly = prevIsOutputOnly and
defType = "misc"
or
element = prevType.(CollectionType).getElementType() and
(value = prevValue + ".WithoutElement" or value = prevValue + ".WithElement") and
details = element.toString() and
isInputOnly = true and
isOutputOnly = prevIsOutputOnly and
defType = "array"
or
element = prevType.(RefType).getAField() and
not element.(Field).isStatic() and
value =
prevValue + ".Field[" + element.(Field).getDeclaringType().getPackage() + "." +
element.(Field).getDeclaringType().getName() + "." + element.(Field).getName() + "]" and
details = element.(Field).getType().toString() + " " + element.(Field).getName() and
isInputOnly = false and
isOutputOnly = false and
defType = "field"
)
)
}
predicate nestedPath(
Endpoint endpoint, Element element, string value, string details, string defType,
boolean isInputOnly, boolean isOutputOnly
) {
nestedPathRec(endpoint, element, value, details, defType, isInputOnly, isOutputOnly, _)
}

View File

@@ -0,0 +1,45 @@
/**
* @name Fetch suggestions for access paths of input and output parameters of a method (application mode)
* @description A list of access paths for input and output parameters of a method. Excludes test and generated code.
* @kind table
* @id java/utils/modeleditor/application-mode-access-path-suggestions
* @tags modeleditor access-path-suggestions application-mode
*/
private import java
private import AccessPathSuggestions
private import ApplicationModeEndpointsQuery
private import ModelEditor
predicate suggestions(
string packageName, string typeName, string methodName, string methodParameters, string value,
string details, string defType, boolean isInputOnly, boolean isOutputOnly
) {
exists(ExternalEndpoint endpoint, Element element |
nestedPath(endpoint, element, value, details, defType, isInputOnly, isOutputOnly)
|
exists(aUsage(endpoint)) and
packageName = endpoint.getPackageName() and
typeName = endpoint.getTypeName() and
methodName = endpoint.getName() and
methodParameters = endpoint.getParameterTypes()
)
}
predicate inputSuggestions(
string packageName, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(packageName, typeName, methodName, methodParameters, value, details, defType, _, false)
}
predicate outputSuggestions(
string packageName, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(packageName, typeName, methodName, methodParameters, value, details, defType, false, _)
}
query predicate input = inputSuggestions/7;
query predicate output = outputSuggestions/7;

View File

@@ -10,10 +10,6 @@ private import java
private import ApplicationModeEndpointsQuery
private import ModelEditor
private Call aUsage(ExternalEndpoint endpoint) {
result.getCallee().getSourceDeclaration() = endpoint
}
from ExternalEndpoint endpoint, boolean supported, Call usage, string type, string classification
where
supported = isSupported(endpoint) and

View File

@@ -4,6 +4,10 @@ private import semmle.code.java.dataflow.FlowSources
private import semmle.code.java.dataflow.internal.DataFlowPrivate
private import ModelEditor
Call aUsage(ExternalEndpoint endpoint) {
result.getCallee().getSourceDeclaration() = endpoint
}
/**
* A class of effectively public callables in library code.
*/

View File

@@ -0,0 +1,44 @@
/**
* @name Fetch suggestions for access paths of input and output parameters of a method (framework mode)
* @description A list of access paths for input and output parameters of a method. Excludes test and generated code.
* @kind table
* @id java/utils/modeleditor/framework-mode-access-path-suggestions
* @tags modeleditor access-path-suggestions framework-mode
*/
private import java
private import AccessPathSuggestions
private import FrameworkModeEndpointsQuery
private import ModelEditor
predicate suggestions(
string packageName, string typeName, string methodName, string methodParameters, string value,
string details, string defType, boolean isInputOnly, boolean isOutputOnly
) {
exists(PublicEndpointFromSource endpoint, Element element |
nestedPath(endpoint, element, value, details, defType, isInputOnly, isOutputOnly)
|
packageName = endpoint.getPackageName() and
typeName = endpoint.getTypeName() and
methodName = endpoint.getName() and
methodParameters = endpoint.getParameterTypes()
)
}
predicate inputSuggestions(
string packageName, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(packageName, typeName, methodName, methodParameters, value, details, defType, _, false)
}
predicate outputSuggestions(
string packageName, string typeName, string methodName, string methodParameters, string value,
string details, string defType
) {
suggestions(packageName, typeName, methodName, methodParameters, value, details, defType, false, _)
}
query predicate input = inputSuggestions/7;
query predicate output = outputSuggestions/7;

View File

@@ -0,0 +1,29 @@
input
| java.io | PrintStream | println | (Object) | Argument[0] | Object p0 | parameter |
| java.io | PrintStream | println | (Object) | Argument[this] | PrintStream | class |
| java.io | PrintStream | println | (String) | Argument[0] | String p0 | parameter |
| java.io | PrintStream | println | (String) | Argument[this] | PrintStream | class |
| java.nio.file | FileSystem | getPath | (String,String[]) | Argument[0] | String p0 | parameter |
| java.nio.file | FileSystem | getPath | (String,String[]) | Argument[1] | String[] p1 | parameter |
| java.nio.file | FileSystem | getPath | (String,String[]) | Argument[this] | FileSystem | class |
| java.nio.file | FileSystems | getDefault | () | Argument[this] | FileSystems | class |
| java.nio.file | Paths | get | (String,String[]) | Argument[0] | String p0 | parameter |
| java.nio.file | Paths | get | (String,String[]) | Argument[1] | String[] p1 | parameter |
| java.nio.file | Paths | get | (String,String[]) | Argument[this] | Paths | class |
output
| java.io | PrintStream | println | (Object) | Argument[0] | Object p0 | parameter |
| java.io | PrintStream | println | (Object) | Argument[this] | PrintStream | class |
| java.io | PrintStream | println | (Object) | ReturnValue | void | return |
| java.io | PrintStream | println | (String) | Argument[0] | String p0 | parameter |
| java.io | PrintStream | println | (String) | Argument[this] | PrintStream | class |
| java.io | PrintStream | println | (String) | ReturnValue | void | return |
| java.nio.file | FileSystem | getPath | (String,String[]) | Argument[0] | String p0 | parameter |
| java.nio.file | FileSystem | getPath | (String,String[]) | Argument[1] | String[] p1 | parameter |
| java.nio.file | FileSystem | getPath | (String,String[]) | Argument[this] | FileSystem | class |
| java.nio.file | FileSystem | getPath | (String,String[]) | ReturnValue | Path | return |
| java.nio.file | FileSystems | getDefault | () | Argument[this] | FileSystems | class |
| java.nio.file | FileSystems | getDefault | () | ReturnValue | FileSystem | return |
| java.nio.file | Paths | get | (String,String[]) | Argument[0] | String p0 | parameter |
| java.nio.file | Paths | get | (String,String[]) | Argument[1] | String[] p1 | parameter |
| java.nio.file | Paths | get | (String,String[]) | Argument[this] | Paths | class |
| java.nio.file | Paths | get | (String,String[]) | ReturnValue | Path | return |

View File

@@ -0,0 +1 @@
utils/modeleditor/ApplicationModeAccessPathSuggestions.ql

View File

@@ -0,0 +1,70 @@
input
| com.github.codeql.test | PublicClass | neutralStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | neutralStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | protectedStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | protectedStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | sinkStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | sinkStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | sourceStuff | () | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | staticStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | staticStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | stuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | stuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | summaryStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | summaryStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicGenericClass | stuff | (Object) | Argument[0] | T arg | parameter |
| com.github.codeql.test | PublicGenericClass | stuff | (Object) | Argument[this] | PublicGenericClass | class |
| com.github.codeql.test | PublicGenericClass | stuff2 | (Object) | Argument[0] | T3 arg | parameter |
| com.github.codeql.test | PublicGenericClass | stuff2 | (Object) | Argument[this] | PublicGenericClass | class |
| com.github.codeql.test | PublicGenericInterface | staticStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicGenericInterface | staticStuff | (String) | Argument[this] | PublicGenericInterface | class |
| com.github.codeql.test | PublicGenericInterface | stuff | (Object) | Argument[0] | T arg | parameter |
| com.github.codeql.test | PublicGenericInterface | stuff | (Object) | Argument[this] | PublicGenericInterface | class |
| com.github.codeql.test | PublicGenericInterface | stuff2 | (Object) | Argument[0] | T2 arg | parameter |
| com.github.codeql.test | PublicGenericInterface | stuff2 | (Object) | Argument[this] | PublicGenericInterface | class |
| com.github.codeql.test | PublicInterface | staticStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicInterface | staticStuff | (String) | Argument[this] | PublicInterface | class |
| com.github.codeql.test | PublicInterface | stuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicInterface | stuff | (String) | Argument[this] | PublicInterface | class |
output
| com.github.codeql.test | PublicClass | neutralStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | neutralStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | neutralStuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicClass | protectedStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | protectedStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | protectedStuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicClass | sinkStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | sinkStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | sinkStuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicClass | sourceStuff | () | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | sourceStuff | () | ReturnValue | String | return |
| com.github.codeql.test | PublicClass | staticStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | staticStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | staticStuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicClass | stuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | stuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | stuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicClass | summaryStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicClass | summaryStuff | (String) | Argument[this] | PublicClass | class |
| com.github.codeql.test | PublicClass | summaryStuff | (String) | ReturnValue | String | return |
| com.github.codeql.test | PublicGenericClass | stuff | (Object) | Argument[0] | T arg | parameter |
| com.github.codeql.test | PublicGenericClass | stuff | (Object) | Argument[this] | PublicGenericClass | class |
| com.github.codeql.test | PublicGenericClass | stuff | (Object) | ReturnValue | void | return |
| com.github.codeql.test | PublicGenericClass | stuff2 | (Object) | Argument[0] | T3 arg | parameter |
| com.github.codeql.test | PublicGenericClass | stuff2 | (Object) | Argument[this] | PublicGenericClass | class |
| com.github.codeql.test | PublicGenericClass | stuff2 | (Object) | ReturnValue | void | return |
| com.github.codeql.test | PublicGenericInterface | staticStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicGenericInterface | staticStuff | (String) | Argument[this] | PublicGenericInterface | class |
| com.github.codeql.test | PublicGenericInterface | staticStuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicGenericInterface | stuff | (Object) | Argument[0] | T arg | parameter |
| com.github.codeql.test | PublicGenericInterface | stuff | (Object) | Argument[this] | PublicGenericInterface | class |
| com.github.codeql.test | PublicGenericInterface | stuff | (Object) | ReturnValue | void | return |
| com.github.codeql.test | PublicGenericInterface | stuff2 | (Object) | Argument[0] | T2 arg | parameter |
| com.github.codeql.test | PublicGenericInterface | stuff2 | (Object) | Argument[this] | PublicGenericInterface | class |
| com.github.codeql.test | PublicGenericInterface | stuff2 | (Object) | ReturnValue | void | return |
| com.github.codeql.test | PublicInterface | staticStuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicInterface | staticStuff | (String) | Argument[this] | PublicInterface | class |
| com.github.codeql.test | PublicInterface | staticStuff | (String) | ReturnValue | void | return |
| com.github.codeql.test | PublicInterface | stuff | (String) | Argument[0] | String arg | parameter |
| com.github.codeql.test | PublicInterface | stuff | (String) | Argument[this] | PublicInterface | class |
| com.github.codeql.test | PublicInterface | stuff | (String) | ReturnValue | void | return |

View File

@@ -0,0 +1 @@
utils/modeleditor/FrameworkModeAccessPathSuggestions.ql

View File

@@ -0,0 +1,84 @@
/**
* @name Fetch suggestions for access paths of input and output parameters of a method (framework mode).
* @description A list of access paths for input and output parameters of a method. Excludes test and generated code.
* @kind table
* @id ruby/utils/modeleditor/framework-mode-access-path-suggestions
* @tags modeleditor access-path-suggestions framework-mode
*/
private import ruby
private import codeql.ruby.ApiGraphs
private import queries.modeling.internal.Util as Util
predicate simpleParameters(string type, string path, string value, string details) {
exists(DataFlow::MethodNode methodNode, DataFlow::ParameterNode paramNode |
methodNode.getLocation().getFile() instanceof Util::RelevantFile and
(
// Check that this parameter belongs to this method
// TODO: find a way to do this easier
paramNode = methodNode.getParameter(_) or
paramNode = methodNode.getKeywordParameter(_) or
paramNode = methodNode.getSelfParameter() or
paramNode = methodNode.getHashSplatParameter()
// Block parameter explicitly excluded because it's already included
// as part of the blockArguments predicate
)
|
Util::pathToMethod(methodNode, type, path) and
value = Util::getArgumentPath(paramNode) and
details = paramNode.toString()
)
}
predicate blockArguments(string type, string path, string value, string details) {
exists(DataFlow::MethodNode methodNode, DataFlow::CallNode callNode |
methodNode.getLocation().getFile() instanceof Util::RelevantFile and
callNode = methodNode.getABlockCall()
|
(
exists(DataFlow::ExprNode argNode, int i | argNode = callNode.getPositionalArgument(i) |
value = "Argument[block].Parameter[" + i + "]" and
details = argNode.toString()
)
or
exists(DataFlow::ExprNode argNode, string keyword |
argNode = callNode.getKeywordArgument(keyword)
|
value = "Argument[block].Parameter[" + keyword + ":]" and
details = ":" + keyword
)
or
value = "Argument[block]" and details = callNode.toString()
) and
Util::pathToMethod(methodNode, type, path)
)
}
predicate returnValue(string type, string path, string value, string details) {
exists(DataFlow::MethodNode methodNode, DataFlow::Node returnNode |
methodNode.getLocation().getFile() instanceof Util::RelevantFile and
returnNode = methodNode.getAReturnNode()
|
Util::pathToMethod(methodNode, type, path) and
value = "ReturnValue" and
details = returnNode.toString()
)
}
predicate inputSuggestions(string type, string path, string value, string details, string defType) {
simpleParameters(type, path, value, details) and defType = "parameter"
or
blockArguments(type, path, value, details) and defType = "parameter"
}
predicate outputSuggestions(string type, string path, string value, string details, string defType) {
simpleParameters(type, path, value, details) and defType = "parameter"
or
blockArguments(type, path, value, details) and defType = "parameter"
or
returnValue(type, path, value, details) and defType = "return"
}
query predicate input = inputSuggestions/5;
query predicate output = outputSuggestions/5;