Ruby: String.try_convert isn't value-preserving

`String.try_convert` can convert arbitrary objects to strings, which
obviously isn't value-preserving.
This commit is contained in:
Harry Maclean
2022-03-02 13:31:59 +13:00
parent fc351fbd64
commit 37dac186a8
3 changed files with 591 additions and 590 deletions

View File

@@ -47,7 +47,7 @@ module String {
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[0]" and
output = "ReturnValue" and
preservesValue = true
preservesValue = false
}
}

View File

@@ -5,7 +5,9 @@ end
def m_try_convert
a = source "a"
sink String.try_convert(a) # $ hasValueFlow=a
b = source 1
sink String.try_convert(a) # $ hasTaintFlow=a
sink String.try_convert(b) # $ hasTaintFlow=1
end
def m_format