Fix spurious source models for primitive types in framework mode.

This commit is contained in:
Max Schaefer
2024-01-17 15:36:31 +00:00
parent 9975f974ee
commit ae23920a6d
3 changed files with 13 additions and 7 deletions

View File

@@ -38,18 +38,15 @@ newtype TFrameworkModeEndpoint =
} or } or
TOverridableParameter(Method m, Parameter p) { TOverridableParameter(Method m, Parameter p) {
AutomodelJavaUtil::isFromSource(p) and AutomodelJavaUtil::isFromSource(p) and
not AutomodelJavaUtil::isUnexploitableType(p.getType()) and
p.getCallable() = m and p.getCallable() = m and
m instanceof ModelExclusions::ModelApi and m instanceof ModelExclusions::ModelApi and
not m.getDeclaringType().isFinal() and AutomodelJavaUtil::isOverridable(m)
not m.isFinal() and
not m.isStatic()
} or } or
TOverridableQualifier(Method m) { TOverridableQualifier(Method m) {
AutomodelJavaUtil::isFromSource(m) and AutomodelJavaUtil::isFromSource(m) and
m instanceof ModelExclusions::ModelApi and m instanceof ModelExclusions::ModelApi and
not m.getDeclaringType().isFinal() and AutomodelJavaUtil::isOverridable(m)
not m.isFinal() and
not m.isStatic()
} }
/** /**

View File

@@ -111,3 +111,12 @@ predicate isUnexploitableType(Type tp) {
tp instanceof NumberType or tp instanceof NumberType or
tp instanceof VoidType tp instanceof VoidType
} }
/**
* Holds if the given method can be overridden, that is, it is not final,
* static, or private.
*/
predicate isOverridable(Method m) {
not m.getDeclaringType().isFinal() and not m.isFinal() and
not m.isStatic() and not m.isPrivate()
}

View File

@@ -7,7 +7,7 @@ public class File {
return 0; return 0;
} }
public boolean setLastModified(long time) { // $ sinkModel=setLastModified(long):Argument[this] sourceModel=setLastModified(long):Parameter[this] SPURIOUS: sourceModel=setLastModified(long):Parameter[0] // time is not a candidate (primitive type) public boolean setLastModified(long time) { // $ sinkModel=setLastModified(long):Argument[this] sourceModel=setLastModified(long):Parameter[this] // time is not a candidate (primitive type)
return false; return false;
} // return value is not a source candidate because it's a primitive } // return value is not a source candidate because it's a primitive
} }