From 518809552964db8e57840789c34725888e7f0798 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:30:14 +0100 Subject: [PATCH 1/2] Swift: Use enum content in withContiguousStorageIfAvailable model. --- .../ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll | 2 +- .../ql/test/library-tests/dataflow/taint/libraries/string.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll index a14b7cfb6d0..99564af9c0b 100644 --- a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll +++ b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll @@ -26,7 +26,7 @@ private class SequenceSummaries extends SummaryModelCsv { ";Sequence;true;joined(separator:);;;Argument[-1..0];ReturnValue;taint", ";Sequence;true;first(where:);;;Argument[-1];ReturnValue;taint", ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[-1];Argument[0].Parameter[0];taint", - ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[0].ReturnValue;ReturnValue;taint", + ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[0].ReturnValue;ReturnValue.OptionalSome;taint", ] } } diff --git a/swift/ql/test/library-tests/dataflow/taint/libraries/string.swift b/swift/ql/test/library-tests/dataflow/taint/libraries/string.swift index 1de62140dae..9f684139fd3 100644 --- a/swift/ql/test/library-tests/dataflow/taint/libraries/string.swift +++ b/swift/ql/test/library-tests/dataflow/taint/libraries/string.swift @@ -639,7 +639,7 @@ func furtherTaintThroughCallbacks() { ptr in return source() }) { - sink(arg: result4) // $ MISSING: tainted=640 + sink(arg: result4) // $ tainted=640 } // using a non-closure function From ac3c4fd5efe66c0439f0addeb73b43fae5571132 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:44:21 +0100 Subject: [PATCH 2/2] Swift: Actually I think this is value flow. --- .../ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll index 99564af9c0b..da9edb8b3a9 100644 --- a/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll +++ b/swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Sequence.qll @@ -26,7 +26,7 @@ private class SequenceSummaries extends SummaryModelCsv { ";Sequence;true;joined(separator:);;;Argument[-1..0];ReturnValue;taint", ";Sequence;true;first(where:);;;Argument[-1];ReturnValue;taint", ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[-1];Argument[0].Parameter[0];taint", - ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[0].ReturnValue;ReturnValue.OptionalSome;taint", + ";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[0].ReturnValue;ReturnValue.OptionalSome;value", ] } }