mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
Add test for File.startsWith
This commit is contained in:
@@ -106,7 +106,18 @@ class TestKt {
|
|||||||
}
|
}
|
||||||
run {
|
run {
|
||||||
val source: File? = source() as File?
|
val source: File? = source() as File?
|
||||||
val normalized: File = source!!.canonicalFile.toString()
|
val normalized: File = source!!.canonicalFile
|
||||||
|
if (normalized.startsWith("/safe")) {
|
||||||
|
sink(source) // Safe
|
||||||
|
sink(normalized) // Safe
|
||||||
|
} else {
|
||||||
|
sink(source) // $ hasTaintFlow
|
||||||
|
sink(normalized) // $ hasTaintFlow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
run {
|
||||||
|
val source: File? = source() as File?
|
||||||
|
val normalized: String = source!!.canonicalFile.toString()
|
||||||
if (normalized.startsWith("/safe")) {
|
if (normalized.startsWith("/safe")) {
|
||||||
sink(source) // Safe
|
sink(source) // Safe
|
||||||
sink(normalized) // Safe
|
sink(normalized) // Safe
|
||||||
@@ -337,6 +348,17 @@ class TestKt {
|
|||||||
sink(normalized) // $ hasTaintFlow
|
sink(normalized) // $ hasTaintFlow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
run {
|
||||||
|
val source: File? = source() as File?
|
||||||
|
val normalized: File = source!!.canonicalFile
|
||||||
|
if (!normalized.startsWith("/data")) {
|
||||||
|
sink(source) // Safe
|
||||||
|
sink(normalized) // Safe
|
||||||
|
} else {
|
||||||
|
sink(source) // $ hasTaintFlow
|
||||||
|
sink(normalized) // $ hasTaintFlow
|
||||||
|
}
|
||||||
|
}
|
||||||
run {
|
run {
|
||||||
val source: File? = source() as File?
|
val source: File? = source() as File?
|
||||||
val normalized: String = source!!.canonicalFile.toString()
|
val normalized: String = source!!.canonicalFile.toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user