Merge branch 'main' of github.com:aydinnyunus/codeql

This commit is contained in:
Yunus AYDIN
2023-11-15 09:34:06 +03:00
48 changed files with 11447 additions and 79 deletions

View File

@@ -0,0 +1,30 @@
class Element extends @element {
string toString() { none() }
}
query predicate new_unspecified_elements(Element e, string property, string error) {
unspecified_elements(e, property, error)
or
error =
"Move semantics support removed during database downgrade. Please update your CodeQL code." and
property = "" and
(
copy_exprs(e, _) or
consume_exprs(e, _) or
borrow_exprs(e)
)
}
query predicate new_unspecified_element_children(Element e, int index, Element child) {
unspecified_element_children(e, index, child)
or
copy_exprs(e, child) and index = 0
or
consume_exprs(e, child) and index = 0
or
borrow_exprs(e) and identity_exprs(e, child) and index = 0
}
query predicate new_identity_exprs(Element e, Element child) {
identity_exprs(e, child) and not borrow_exprs(e)
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
description: Removes elements related to move semantics
compatibility: partial
unspecified_elements.rel: run downgrade.ql new_unspecified_elements
unspecified_element_children.rel: run downgrade.ql new_unspecified_element_children
identity_exprs.rel: run downgrade.ql new_identity_exprs
copy_exprs.rel: delete
consume_exprs.rel: delete
borrow_exprs.rel: delete

View File

@@ -103,11 +103,7 @@ MAP(swift::Expr, ExprTag)
MAP(swift::IdentityExpr, IdentityExprTag)
MAP(swift::ParenExpr, ParenExprTag)
MAP(swift::DotSelfExpr, DotSelfExprTag)
#if CODEQL_SWIFT_VERSION_GE(5, 9)
MAP(swift::BorrowExpr, void) // TODO (introduced in 5.9)
#else
MAP(swift::MoveExpr, void) // TODO (introduced in 5.8, gone in 5.9)
#endif
MAP(swift::BorrowExpr, BorrowExprTag)
MAP(swift::AwaitExpr, AwaitExprTag)
MAP(swift::UnresolvedMemberChainResultExpr, UnresolvedMemberChainResultExprTag)
MAP(swift::AnyTryExpr, AnyTryExprTag)
@@ -201,12 +197,10 @@ MAP(swift::Expr, ExprTag)
MAP(swift::TapExpr, TapExprTag)
MAP(swift::TypeJoinExpr, void) // TODO (introduced in 5.8)
MAP(swift::MacroExpansionExpr, void) // TODO (introduced in 5.8)
#if CODEQL_SWIFT_VERSION_GE(5, 9)
MAP(swift::CopyExpr, void) // TODO (introduced in 5.9)
MAP(swift::ConsumeExpr, void) // TODO (introduced in 5.9)
MAP(swift::CopyExpr, CopyExprTag)
MAP(swift::ConsumeExpr, ConsumeExprTag)
MAP(swift::MaterializePackExpr, void) // TODO (introduced in 5.9)
MAP(swift::SingleValueStmtExpr, SingleValueStmtExprTag)
#endif
MAP(swift::Decl, DeclTag)
MAP(swift::ValueDecl, ValueDeclTag)

View File

@@ -657,4 +657,16 @@ codeql::PackElementExpr ExprTranslator::translatePackElementExpr(
return entry;
}
codeql::CopyExpr ExprTranslator::translateCopyExpr(const swift::CopyExpr& expr) {
auto entry = createExprEntry(expr);
entry.sub_expr = dispatcher.fetchLabel(expr.getSubExpr());
return entry;
}
codeql::ConsumeExpr ExprTranslator::translateConsumeExpr(const swift::ConsumeExpr& expr) {
auto entry = createExprEntry(expr);
entry.sub_expr = dispatcher.fetchLabel(expr.getSubExpr());
return entry;
}
} // namespace codeql

View File

@@ -122,6 +122,8 @@ class ExprTranslator : public AstTranslatorBase<ExprTranslator> {
codeql::SingleValueStmtExpr translateSingleValueStmtExpr(const swift::SingleValueStmtExpr& expr);
codeql::PackExpansionExpr translatePackExpansionExpr(const swift::PackExpansionExpr& expr);
codeql::PackElementExpr translatePackElementExpr(const swift::PackElementExpr& expr);
codeql::CopyExpr translateCopyExpr(const swift::CopyExpr& expr);
codeql::ConsumeExpr translateConsumeExpr(const swift::ConsumeExpr& expr);
private:
void fillClosureExpr(const swift::AbstractClosureExpr& expr, codeql::ClosureExpr& entry);

View File

@@ -76,6 +76,8 @@ lib/codeql/swift/elements/expr/AwaitExprConstructor.qll 55f185fe9a656db83807b90d
lib/codeql/swift/elements/expr/BinaryExprConstructor.qll 173dca8da8b4da92f5c45f78c9be0ed2d84fbd36d3471e87c2597f1832033acf 07136c27dcdb35a9cd2587d459a7eea64a6b3c0ad8ce7ffc7bb2cdfe26b6e9bd
lib/codeql/swift/elements/expr/BindOptionalExprConstructor.qll 839b01e4fb4d7a13d5d28f97bdb94ef5e5d645a20e4c46e710066c46baa7d042 d53ece261604bf5909f7afeb57ef1042ef28382ce2bb0c6f9790b3ce1d24749c
lib/codeql/swift/elements/expr/BooleanLiteralExprConstructor.qll 3ef212f498734fc2441ecfde9889164abb430c25fce9871f2dfcdc25114fe670 f9c498db8217ad2184b1fff3d6b0640a4c41b0643ac59cf672d738ba50341059
lib/codeql/swift/elements/expr/BorrowExpr.qll ea59e5dd3fcf85e114c3a24d7405b049f8c63ee19190c40bdfce5ff81489bd35 3e0dca0efab75d6042900de9099fc27ec89a44736bace371e1f7ad05f05daebf
lib/codeql/swift/elements/expr/BorrowExprConstructor.qll d13bd08a048dbb7a83b3882a1f58539f064376e8d96e784d5b4c6f8803aa3be7 8d8d2921ec30fa387a6adcf49f0fff4d8f96444010e36d1819792f5281d54ad7
lib/codeql/swift/elements/expr/BridgeFromObjCExpr.qll b95f6d0cac24cf6c1f84cb904a1f9384c5085d3c97ab0b4b6e2cd1daa35886b6 a374e4f84c2fead34325d71a2fd4aa7289a9210c169ec2fd475c24fec29121d4
lib/codeql/swift/elements/expr/BridgeFromObjCExprConstructor.qll db5793d44c554bab954b7c2458f3ce148ddcfff07c77ca4e0267736fda932042 7261f6ca92d0adc4dbb04d06f7a42956646d782d250d626d3c57fdf1d9ed3d8b
lib/codeql/swift/elements/expr/BridgeToObjCExpr.qll 9bd4eee52d5f1c50cb509814dcb6d458097fb0e813c5450394eb328fc5c99e6f eed912e1f3c0a49c8f6fb449deddd062f347c89336fe69d50837d38a1747e1fa
@@ -96,6 +98,10 @@ lib/codeql/swift/elements/expr/ConditionalBridgeFromObjCExpr.qll bfe2e7142451c1d
lib/codeql/swift/elements/expr/ConditionalBridgeFromObjCExprConstructor.qll 446d2b437a1b54e0ba3107aad57ea9a12449a70cd9565cc724b395bf88fd9e8b 7f7bd4dd2f6cb717c7868993d183fcf7634c30666a1709b9d1577ed17467f1e7
lib/codeql/swift/elements/expr/ConditionalCheckedCastExpr.qll 61290c72da5609bcefb417a55e9d4338393af057c8634459875500710ffbeebb dadc07129e4b4ed41a8afb19a3e53ac0bf78f5b077be5f09e5609d87659a5869
lib/codeql/swift/elements/expr/ConditionalCheckedCastExprConstructor.qll 14b761095c024474f6e475a66822e9893b4e65e35c4182be9fdc5f801eb2274d 7d62113ae891dff8e371ed89d698e2df225a7580fe371165d69f42bd88ce8ecc
lib/codeql/swift/elements/expr/ConsumeExpr.qll 570b4d2e1fd00d304affc8fdda82e8eb04670caaab9d74a8d97928cc95a2b4e3 2634631565b40dd487face44581d2d28582cc80ae7bb97e39f74241d31a3a5e4
lib/codeql/swift/elements/expr/ConsumeExprConstructor.qll e2fd37095422dcfa7e01fa0e7973db1b4e0f816064a0facd10009b200c941b0e 03c9ef3df9491b4a8438800d9d8c7b6d7fe562f1cc0250748f27933abfa2c989
lib/codeql/swift/elements/expr/CopyExpr.qll f820ef6ae749267bfc198b110fb32a14e910800008eeb955a496a7e80cb8c614 4334f4938e164323d7bc58742b73f7285f16d6d641bd41ac92d5dccaa7af32eb
lib/codeql/swift/elements/expr/CopyExprConstructor.qll 2b4944e504ab0a4884a926d5532c686004147548fc1734922d0a83d23828de56 4ef6c99b3bcc0ba58b8c040339762246eb206a4f89d0ed7ca92421b964bded17
lib/codeql/swift/elements/expr/CovariantFunctionConversionExpr.qll 7726850cac33afed7bb0aad3a0e9d1211d7c287b0c17be4e2056ddcd99d35e86 aae0109a74e369d4d1a567473e24c4aac1e68cd4d4a920f11f8fc3b9db99cf6e
lib/codeql/swift/elements/expr/CovariantFunctionConversionExprConstructor.qll 8b186ad94027e2e0a8b8cf0b0a1ec703a121e786fa969aa177dd3638af3c9c04 39c3383cf658bc10c1e02cca4c82362553d24c743651337cfaa54fbe304c9b85
lib/codeql/swift/elements/expr/CovariantReturnConversionExpr.qll eca04e50ec909fd18e10bcccda791c6c09468ff58ad9445b3a93b9c57396c65a 41a8fa2608cf03885ac0df8e9a15ac14356b8ddaa1d7daf029e1912436a6598d
@@ -377,7 +383,7 @@ lib/codeql/swift/elements/type/UnresolvedTypeConstructor.qll 7f75d489b4d7ce65cae
lib/codeql/swift/elements/type/VariadicSequenceTypeConstructor.qll fc74a5a2a2effa28ef24509b20ee4373d97cf6e8c71840121bb031c6adedf584 c9b2effc1d01c13c5e6a74a111122fa79a2f6554dda3cb016d68ba397e566ec4
lib/codeql/swift/elements/type/WeakStorageType.qll edd13dd97b53040684409e187c1f975bcada6807c919e1345d8977144dbebb6f 9434c044d264a7f5f503a6422c106c9b8fedf74aaae314174473a29ea6ed17b9
lib/codeql/swift/elements/type/WeakStorageTypeConstructor.qll 5fdce3716aba6318522174a2c455a63480970222ae81c732fb19c6dd3ae2d271 60ea79d6943e129deba0deccb566cf9d73f78398b0f7f0212674d91287d6b2ae
lib/codeql/swift/elements.qll a9890434db7f1271edd3e61aebb2ddb170c3a71c22892d2d84a6d99dddbdbecf a9890434db7f1271edd3e61aebb2ddb170c3a71c22892d2d84a6d99dddbdbecf
lib/codeql/swift/elements.qll a3e46884bac3428bdec439ba97c65a69fea02e30b074b585f8db378844215fe3 a3e46884bac3428bdec439ba97c65a69fea02e30b074b585f8db378844215fe3
lib/codeql/swift/generated/AstNode.qll e00d6a46b16891778531a73722ae0b5842f849328e24aebe88bc30ac9fe438c2 40eaa0072d3ffecbff48d2baf88111daa86ef0f937abf24f032f2495739ef661
lib/codeql/swift/generated/AvailabilityInfo.qll e90fbfc3ec6830390e12a4695698d6efd8da4fa6a8a4189f466489a6dd103586 d9545da9e5d0c160679a4147001b4b1c664d9cb85ae1a169dd639c35046d274d
lib/codeql/swift/generated/AvailabilitySpec.qll 469bbd39d38dc68f1f6fb2e0766cc25b2f813c804fec44962910d5f7777632a2 57a953a8d5cf7031283393af1b3cfbc7f5941c9062e77950b32e5b5c6ae6b191
@@ -393,12 +399,12 @@ lib/codeql/swift/generated/KeyPathComponent.qll 55629a20538d7e8f4f4d4c7484e8bcfd
lib/codeql/swift/generated/Locatable.qll 41f040643ea146c8044be49fddea89bdd79efd2469617c863a4b2da0b1af3364 9a964dcbc7f5ffce2ee006ce0c9a9a99a988976fcd0446af2ba1b202911d7396
lib/codeql/swift/generated/Location.qll 5b37ecde83a871ef2089cf33e4743fc02d9cf8c676aafd9f157c59ffdb776d6b 076d8d3d2313931e8287d196854acf259700124d9c8bc591a6d36017f314260a
lib/codeql/swift/generated/OtherAvailabilitySpec.qll 31f3667ab0dc5f93230ba876b4101898d2a5a4af306925082305eff3ad9c9c0e 31f3667ab0dc5f93230ba876b4101898d2a5a4af306925082305eff3ad9c9c0e
lib/codeql/swift/generated/ParentChild.qll 2c655423a5efa7fe26070bf2272de0067c3288a37e6f8f7c85da46971e82ee1b e5dbf27a8efc0c4b9e2a53fd52ecd8afc3281a0a34386f6c900cd61ab4acaa83
lib/codeql/swift/generated/ParentChild.qll a00f7eecdc91d98ad421c6d883bf2cc6e92c213befdcc494bf8ad25f2c5d4ae2 cd2c70e5940a302108319bdc16d25f49df3165be5b94fa825b64b9b5771f117d
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll 3483726f6db9d978e40db75068d6a9ecad8f7c06516157fce783b26424bea729 864fedf2901de91f662a6d75a2eb7e26ed1a2a1a875a2b3c4e699dc7e7c4605e
lib/codeql/swift/generated/PureSynthConstructors.qll 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229 40f5c0c573ce12f16322d9efb12306750f672254cbc36a200c298cb08e504229
lib/codeql/swift/generated/Raw.qll 84fc2268f5a038e58c353d940624bb738d9a195dec5a130c4844f3f9d6a0d43c 1bb8ea3ed529d61c41302b2ea65d35155ed4fd4d3fc7764e361fc108ffd30a4f
lib/codeql/swift/generated/Synth.qll 345d99dfbb3b26173edece42dd9c00b7b49b0890e254915dc8ad393997fec1c5 fe1697b2c9dfe39ecc7e71915803773518c906c969c59ccb34252ee3d4719c5a
lib/codeql/swift/generated/SynthConstructors.qll d63f29c58f85bf4d77a31ce325a54dc972b3ceecb3fb61b8ddbb296318be4827 d63f29c58f85bf4d77a31ce325a54dc972b3ceecb3fb61b8ddbb296318be4827
lib/codeql/swift/generated/Raw.qll f15f0b35be65adb8027e17b5fd5478eabb5000ee887dafc5c40d8abd03ced3e3 75fc6fbb74e0720b736c13ec3627247c49f8201df929647cdb2985282abf23c1
lib/codeql/swift/generated/Synth.qll 93565d0244a9f5bf4ba3f19a0ffabef4b8dc48703c580b905ffeac716eea5445 74d977cfe6fbb3d90579dc45b40254549e686d91eb16999c9e69fec18ab7df28
lib/codeql/swift/generated/SynthConstructors.qll fbbf618c54843d86b4c38d7b27e12cce7661b49ce52573f791dd8fcb4bbd40f5 fbbf618c54843d86b4c38d7b27e12cce7661b49ce52573f791dd8fcb4bbd40f5
lib/codeql/swift/generated/UnknownFile.qll 5922b351b55d5becac0c1ad67b8d601bcc9499dce9ee4093b607101e7e299104 5922b351b55d5becac0c1ad67b8d601bcc9499dce9ee4093b607101e7e299104
lib/codeql/swift/generated/UnknownLocation.qll 67b8605ff5aaa0f3a8588fee2527eba5ec4e322562159c9af3d53486b7954ee9 67b8605ff5aaa0f3a8588fee2527eba5ec4e322562159c9af3d53486b7954ee9
lib/codeql/swift/generated/UnspecifiedElement.qll 01182fee4d5c86b551e89c79d0d645f5e85c0aeeeae9dcafcbd7721c3eb3cc14 cb95ab2b13da080ada10e0a3bd1b00577541c4bfe699cbd19ef45f1e00e7c651
@@ -459,6 +465,7 @@ lib/codeql/swift/generated/expr/AwaitExpr.qll 2fb54f4de6373f22ac33419d6d7c00914d
lib/codeql/swift/generated/expr/BinaryExpr.qll 3433ad4dc31b214e5eb4a8fc090000bded1cf07be7e779f9217f01518ace586f 3433ad4dc31b214e5eb4a8fc090000bded1cf07be7e779f9217f01518ace586f
lib/codeql/swift/generated/expr/BindOptionalExpr.qll 5d264f01c894ad5fe2bb3dbd2dcbac27d491e45678c1e85db686b50db691cf2e 7368a23160ddeb2f8d133579e8e990fe6cb47789e41b3461df3e5f66d855f6da
lib/codeql/swift/generated/expr/BooleanLiteralExpr.qll 6fc5314867f201e899199cf3289d0daa853bf49fd0e4300d8f3ee7ea05b0dd20 4355b2e49c2d7c9bb66094dd8f56bd112fbabb3fe2111b1ff7ec6d64333c8978
lib/codeql/swift/generated/expr/BorrowExpr.qll a46b7417349e85f8000300029af7003cb064300345fc87194d95d0a27019d901 6ccb224e19a237b3146df600c040a50998db40c03b410568f9b590f3d52f10dd
lib/codeql/swift/generated/expr/BridgeFromObjCExpr.qll 502efff92732eea47660679c29ff4ee2f79089edd570a8298352fdbb809e378d 502efff92732eea47660679c29ff4ee2f79089edd570a8298352fdbb809e378d
lib/codeql/swift/generated/expr/BridgeToObjCExpr.qll f46fe1dc0c39b471f3acde26e719cbfabe816075ad32b5a7090ec94f6ae2ed39 f46fe1dc0c39b471f3acde26e719cbfabe816075ad32b5a7090ec94f6ae2ed39
lib/codeql/swift/generated/expr/BuiltinLiteralExpr.qll e73fc5a38f0681543b9386fa523039de094b1550ff07c279bd60e1c3f6f243d0 03395da16415155096d7b01fe69a7d1cd27929481f7639cb927ffac1f4ba42e7
@@ -472,6 +479,8 @@ lib/codeql/swift/generated/expr/CollectionExpr.qll 40f0167cbf67bba45be184e9603f9
lib/codeql/swift/generated/expr/CollectionUpcastConversionExpr.qll 9925461069bd584492925baae30ab098d55ec552e557c6357e8bc82ea204d843 6462bd150d2b6dafbbb05c17e970c47e290cc1d1ae704e5ccb381800451a7188
lib/codeql/swift/generated/expr/ConditionalBridgeFromObjCExpr.qll 65bdf5e9a9e98569af93d2212b114c822e9809ad4a43b50e50e8face07268156 c20f1ff1fd6231e7691d50cc1ee0c36edd8ed3a58ce1cc378ce9e03e9423cb6e
lib/codeql/swift/generated/expr/ConditionalCheckedCastExpr.qll be657b986ae9a8ba929d3e5683d101e1a26e8d7995376ed68610477e87f48184 be657b986ae9a8ba929d3e5683d101e1a26e8d7995376ed68610477e87f48184
lib/codeql/swift/generated/expr/ConsumeExpr.qll 1b90630ffefdef29ef57ea1070b6e28580c6245f31e3c6209b5960f7c1409ab7 b0d484bdcd875121ceab93a2fc4af8d320997c1581250bbcd77a29e0cb1765f7
lib/codeql/swift/generated/expr/CopyExpr.qll a25970a0238df0ebcf63d437681b1ba3d5f750f0ab69d7c1bb9f3b600392dc90 4c64344d994a0b1fd6fbf39283d3d87423d2dd13893509b296fdbd280703ad04
lib/codeql/swift/generated/expr/CovariantFunctionConversionExpr.qll 4b48c9d01c5f67bd5a6d2ff609ac9bf87954298cd0719b5a951efb89146fcbe6 43626bf6760dfc8f49362d8f065a8f5339f822c8f76ff9be012b4471e20afde2
lib/codeql/swift/generated/expr/CovariantReturnConversionExpr.qll 0c8dffec9ed1f28902a9679ec29ba33b6a9225460180db923733ad3d14fbdd28 fee3ddce4a699c86770b2a9211e524f764ed9140860b7e6c58ca7f62566cd4ec
lib/codeql/swift/generated/expr/DeclRefExpr.qll ab3ada6eaad669a5e2f170c096d27934ddbc28638b37df77d402eb01fba4f2e6 b00075cc65fe364288022937b0e0cfd9805d94436e48cbd88dacdf5bcd4a170d
@@ -794,6 +803,10 @@ test/extractor-tests/generated/expr/CallExpr/MISSING_SOURCE.txt 66846d526b0bc432
test/extractor-tests/generated/expr/CaptureListExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
test/extractor-tests/generated/expr/CoerceExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
test/extractor-tests/generated/expr/ConditionalCheckedCastExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
test/extractor-tests/generated/expr/CopyExpr/ConsumeExpr.ql 82c89019ed578c83dfa7c7bd04e52bb795facacfc2163c4757a5f43dbc8c7e0c 21a0f3b831daf6067977e3ad150cef085a72c775182e2e280e9bca22432640a6
test/extractor-tests/generated/expr/CopyExpr/ConsumeExpr_getType.ql 18017c131ec3425ec850963fde2239648b0fcb54abc498017bbb36d4f6c2f9f7 248bb50866bc75dad94d15a19aa30a00231abd996e613d4ba3a7d361707f75e6
test/extractor-tests/generated/expr/CopyExpr/CopyExpr.ql 2e80272756531b3d7c65d9efd9474927e5cea719813acb599b61526e1957b220 1982362701e058bd32d3f9dfafbee3770a5016008cc1330237eb102f8459b506
test/extractor-tests/generated/expr/CopyExpr/CopyExpr_getType.ql 33698df9758f9399a0a7492a8432399582d2d52699572ca550c0fcdad839336e 330bd731f686d534769f7fc08d04e60dec83bced96cf39845c4374fa0629eb53
test/extractor-tests/generated/expr/DeclRefExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
test/extractor-tests/generated/expr/DefaultArgumentExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7
test/extractor-tests/generated/expr/DictionaryExpr/MISSING_SOURCE.txt 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7 66846d526b0bc4328735c3c4dd9c390a9325da5b5dfd42ec07622f9c7108a7d7

13
swift/ql/.gitattributes generated vendored
View File

@@ -78,6 +78,8 @@
/lib/codeql/swift/elements/expr/BinaryExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BindOptionalExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BooleanLiteralExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BorrowExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/BorrowExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BridgeFromObjCExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/BridgeFromObjCExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/BridgeToObjCExpr.qll linguist-generated
@@ -98,6 +100,10 @@
/lib/codeql/swift/elements/expr/ConditionalBridgeFromObjCExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/ConditionalCheckedCastExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/ConditionalCheckedCastExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/ConsumeExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/ConsumeExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/CopyExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/CopyExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/CovariantFunctionConversionExpr.qll linguist-generated
/lib/codeql/swift/elements/expr/CovariantFunctionConversionExprConstructor.qll linguist-generated
/lib/codeql/swift/elements/expr/CovariantReturnConversionExpr.qll linguist-generated
@@ -461,6 +467,7 @@
/lib/codeql/swift/generated/expr/BinaryExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BindOptionalExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BooleanLiteralExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BorrowExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BridgeFromObjCExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BridgeToObjCExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/BuiltinLiteralExpr.qll linguist-generated
@@ -474,6 +481,8 @@
/lib/codeql/swift/generated/expr/CollectionUpcastConversionExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/ConditionalBridgeFromObjCExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/ConditionalCheckedCastExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/ConsumeExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/CopyExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/CovariantFunctionConversionExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/CovariantReturnConversionExpr.qll linguist-generated
/lib/codeql/swift/generated/expr/DeclRefExpr.qll linguist-generated
@@ -796,6 +805,10 @@
/test/extractor-tests/generated/expr/CaptureListExpr/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/expr/CoerceExpr/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/expr/ConditionalCheckedCastExpr/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/expr/CopyExpr/ConsumeExpr.ql linguist-generated
/test/extractor-tests/generated/expr/CopyExpr/ConsumeExpr_getType.ql linguist-generated
/test/extractor-tests/generated/expr/CopyExpr/CopyExpr.ql linguist-generated
/test/extractor-tests/generated/expr/CopyExpr/CopyExpr_getType.ql linguist-generated
/test/extractor-tests/generated/expr/DeclRefExpr/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/expr/DefaultArgumentExpr/MISSING_SOURCE.txt linguist-generated
/test/extractor-tests/generated/expr/DictionaryExpr/MISSING_SOURCE.txt linguist-generated

View File

@@ -1,4 +1,4 @@
---
category: majorAnalysis
category: minorAnalysis
---
* AST and types related to parameter packs are now extracted

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* AST and types related to move semantics (`copy`, `consume`, `_borrow`) are now extracted

View File

@@ -1444,6 +1444,24 @@ module Exprs {
}
}
/** Control-flow for Move Semantics. See the QLDoc for `CopyExpr` for details. */
private class CopyExprTree extends AstStandardPostOrderTree {
override CopyExpr ast;
final override ControlFlowElement getChildElement(int i) {
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
}
}
/** Control-flow for Move Semantics. See the QLDoc for `ConsumeExpr` for details. */
private class ConsumeExprTree extends AstStandardPostOrderTree {
override ConsumeExpr ast;
final override ControlFlowElement getChildElement(int i) {
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
}
}
private class OpaqueValueExprTree extends AstLeafTree {
override OpaqueValueExpr ast;
}

View File

@@ -78,6 +78,7 @@ import codeql.swift.elements.expr.AwaitExpr
import codeql.swift.elements.expr.BinaryExpr
import codeql.swift.elements.expr.BindOptionalExpr
import codeql.swift.elements.expr.BooleanLiteralExpr
import codeql.swift.elements.expr.BorrowExpr
import codeql.swift.elements.expr.BridgeFromObjCExpr
import codeql.swift.elements.expr.BridgeToObjCExpr
import codeql.swift.elements.expr.BuiltinLiteralExpr
@@ -91,6 +92,8 @@ import codeql.swift.elements.expr.CollectionExpr
import codeql.swift.elements.expr.CollectionUpcastConversionExpr
import codeql.swift.elements.expr.ConditionalBridgeFromObjCExpr
import codeql.swift.elements.expr.ConditionalCheckedCastExpr
import codeql.swift.elements.expr.ConsumeExpr
import codeql.swift.elements.expr.CopyExpr
import codeql.swift.elements.expr.CovariantFunctionConversionExpr
import codeql.swift.elements.expr.CovariantReturnConversionExpr
import codeql.swift.elements.expr.DeclRefExpr

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `BorrowExpr`.
*/
private import codeql.swift.generated.expr.BorrowExpr
class BorrowExpr extends Generated::BorrowExpr { }

View File

@@ -0,0 +1,14 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module defines the hook used internally to tweak the characteristic predicate of
* `BorrowExpr` synthesized instances.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.Raw
/**
* The characteristic predicate of `BorrowExpr` synthesized instances.
* INTERNAL: Do not use.
*/
predicate constructBorrowExpr(Raw::BorrowExpr id) { any() }

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `ConsumeExpr`.
*/
private import codeql.swift.generated.expr.ConsumeExpr
class ConsumeExpr extends Generated::ConsumeExpr { }

View File

@@ -0,0 +1,14 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module defines the hook used internally to tweak the characteristic predicate of
* `ConsumeExpr` synthesized instances.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.Raw
/**
* The characteristic predicate of `ConsumeExpr` synthesized instances.
* INTERNAL: Do not use.
*/
predicate constructConsumeExpr(Raw::ConsumeExpr id) { any() }

View File

@@ -0,0 +1,8 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `CopyExpr`.
*/
private import codeql.swift.generated.expr.CopyExpr
class CopyExpr extends Generated::CopyExpr { }

View File

@@ -0,0 +1,14 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module defines the hook used internally to tweak the characteristic predicate of
* `CopyExpr` synthesized instances.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.Raw
/**
* The characteristic predicate of `CopyExpr` synthesized instances.
* INTERNAL: Do not use.
*/
predicate constructCopyExpr(Raw::CopyExpr id) { any() }

View File

@@ -47,7 +47,7 @@ private class StringSummaries extends SummaryModelCsv {
";StringProtocol;true;capitalized(with:);;;Argument[-1];ReturnValue;taint",
";StringProtocol;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[0].CollectionElement;taint",
";StringProtocol;true;completePath(into:caseSensitive:matchesInto:filterTypes:);;;Argument[-1];Argument[2].CollectionElement.CollectionElement;taint",
";StringProtocol;true;components(separatedBy:);;;Argument[-1];ReturnValue;taint",
";StringProtocol;true;components(separatedBy:);;;Argument[-1];ReturnValue.CollectionElement;taint",
";StringProtocol;true;data(using:allowLossyConversion:);;;Argument[-1];ReturnValue;taint",
";StringProtocol;true;folding(options:locale:);;;Argument[-1];ReturnValue;taint",
";StringProtocol;true;getBytes(_:maxLength:usedLength:encoding:options:range:remaining:);;;Argument[-1];Argument[0].CollectionElement;taint",

View File

@@ -22,8 +22,7 @@ private class UrlFieldsInheritTaint extends TaintInheritingContent, DataFlow::Co
}
/**
* A content implying that, if a `URLRequest` is tainted, then its fields `url`, `httpBody`,
* `httpBodyStream`, `mainDocument` and `allHTTPHeaderFields` are tainted.
* A content implying that, if a `URLRequest` is tainted, then certain fields tainted.
*/
private class UrlRequestFieldsInheritTaint extends TaintInheritingContent,
DataFlow::Content::FieldContent
@@ -31,7 +30,10 @@ private class UrlRequestFieldsInheritTaint extends TaintInheritingContent,
UrlRequestFieldsInheritTaint() {
this.getField().getEnclosingDecl().asNominalTypeDecl().getName() = "URLRequest" and
this.getField().getName() =
["url", "httpBody", "httpBodyStream", "mainDocument", "allHTTPHeaderFields"]
[
"url", "httpBody", "httpBodyStream", "mainDocument", "mainDocumentURL",
"allHTTPHeaderFields"
]
}
}

View File

@@ -39,7 +39,7 @@ private class WKScriptMessageBodyInheritsTaint extends TaintInheritingContent,
}
/**
* A type or extension delcaration that adopts the protocol `WKNavigationDelegate`.
* A type or extension declaration that adopts the protocol `WKNavigationDelegate`.
*/
private class AdoptsWkNavigationDelegate extends Decl {
AdoptsWkNavigationDelegate() {
@@ -74,19 +74,15 @@ private class WKNavigationDelegateSource extends RemoteFlowSource {
}
/**
* A taint step implying that, if a `WKNavigationAction` is tainted, its `request` field is also tainted.
* A content implying that, if a `WKNavigationAction` is tainted, its
* `request` field is also tainted.
*/
private class WKNavigationActionTaintStep extends AdditionalTaintStep {
override predicate step(DataFlow::Node n1, DataFlow::Node n2) {
exists(MemberRefExpr e, Expr self, VarDecl member |
self.getType().getName() = "WKNavigationAction" and
member.getName() = "request"
|
e.getBase() = self and
e.getMember() = member and
n1.asExpr() = self and
n2.asExpr() = e
)
private class UrlRequestFieldsInheritTaint extends TaintInheritingContent,
DataFlow::Content::FieldContent
{
UrlRequestFieldsInheritTaint() {
this.getField().getEnclosingDecl().asNominalTypeDecl().getName() = "WKNavigationAction" and
this.getField().getName() = "request"
}
}

View File

@@ -1201,6 +1201,40 @@ private module Impl {
)
}
private Element getImmediateChildOfConsumeExpr(
ConsumeExpr e, int index, string partialPredicateCall
) {
exists(int b, int bExpr, int n, int nSubExpr |
b = 0 and
bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and
n = bExpr and
nSubExpr = n + 1 and
(
none()
or
result = getImmediateChildOfExpr(e, index - b, partialPredicateCall)
or
index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()"
)
)
}
private Element getImmediateChildOfCopyExpr(CopyExpr e, int index, string partialPredicateCall) {
exists(int b, int bExpr, int n, int nSubExpr |
b = 0 and
bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and
n = bExpr and
nSubExpr = n + 1 and
(
none()
or
result = getImmediateChildOfExpr(e, index - b, partialPredicateCall)
or
index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()"
)
)
}
private Element getImmediateChildOfDeclRefExpr(
DeclRefExpr e, int index, string partialPredicateCall
) {
@@ -2141,6 +2175,20 @@ private module Impl {
)
}
private Element getImmediateChildOfBorrowExpr(BorrowExpr e, int index, string partialPredicateCall) {
exists(int b, int bIdentityExpr, int n |
b = 0 and
bIdentityExpr =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and
n = bIdentityExpr and
(
none()
or
result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall)
)
)
}
private Element getImmediateChildOfBridgeFromObjCExpr(
BridgeFromObjCExpr e, int index, string partialPredicateCall
) {
@@ -5078,6 +5126,10 @@ private module Impl {
or
result = getImmediateChildOfCaptureListExpr(e, index, partialAccessor)
or
result = getImmediateChildOfConsumeExpr(e, index, partialAccessor)
or
result = getImmediateChildOfCopyExpr(e, index, partialAccessor)
or
result = getImmediateChildOfDeclRefExpr(e, index, partialAccessor)
or
result = getImmediateChildOfDefaultArgumentExpr(e, index, partialAccessor)
@@ -5172,6 +5224,8 @@ private module Impl {
or
result = getImmediateChildOfBinaryExpr(e, index, partialAccessor)
or
result = getImmediateChildOfBorrowExpr(e, index, partialAccessor)
or
result = getImmediateChildOfBridgeFromObjCExpr(e, index, partialAccessor)
or
result = getImmediateChildOfBridgeToObjCExpr(e, index, partialAccessor)

View File

@@ -1119,6 +1119,42 @@ module Raw {
*/
class CollectionExpr extends @collection_expr, Expr { }
/**
* INTERNAL: Do not use.
* An expression that forces value to be moved. In the example below, `consume` marks the move expression:
*
* ```
* let y = ...
* let x = consume y
* ```
*/
class ConsumeExpr extends @consume_expr, Expr {
override string toString() { result = "ConsumeExpr" }
/**
* Gets the sub expression of this consume expression.
*/
Expr getSubExpr() { consume_exprs(this, result) }
}
/**
* INTERNAL: Do not use.
* An expression that forces value to be copied. In the example below, `copy` marks the copy expression:
*
* ```
* let y = ...
* let x = copy y
* ```
*/
class CopyExpr extends @copy_expr, Expr {
override string toString() { result = "CopyExpr" }
/**
* Gets the sub expression of this copy expression.
*/
Expr getSubExpr() { copy_exprs(this, result) }
}
/**
* INTERNAL: Do not use.
*/
@@ -1843,6 +1879,19 @@ module Raw {
override string toString() { result = "BinaryExpr" }
}
/**
* INTERNAL: Do not use.
* An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression:
*
* ```
* let y = ...
* let x = _borrow y
* ```
*/
class BorrowExpr extends @borrow_expr, IdentityExpr {
override string toString() { result = "BorrowExpr" }
}
/**
* INTERNAL: Do not use.
*/

View File

@@ -235,6 +235,10 @@ module Synth {
* INTERNAL: Do not use.
*/
TBooleanLiteralExpr(Raw::BooleanLiteralExpr id) { constructBooleanLiteralExpr(id) } or
/**
* INTERNAL: Do not use.
*/
TBorrowExpr(Raw::BorrowExpr id) { constructBorrowExpr(id) } or
/**
* INTERNAL: Do not use.
*/
@@ -279,6 +283,14 @@ module Synth {
TConditionalCheckedCastExpr(Raw::ConditionalCheckedCastExpr id) {
constructConditionalCheckedCastExpr(id)
} or
/**
* INTERNAL: Do not use.
*/
TConsumeExpr(Raw::ConsumeExpr id) { constructConsumeExpr(id) } or
/**
* INTERNAL: Do not use.
*/
TCopyExpr(Raw::CopyExpr id) { constructCopyExpr(id) } or
/**
* INTERNAL: Do not use.
*/
@@ -1195,25 +1207,25 @@ module Synth {
*/
class TExpr =
TAnyTryExpr or TAppliedPropertyWrapperExpr or TApplyExpr or TAssignExpr or TBindOptionalExpr or
TCaptureListExpr or TClosureExpr or TCollectionExpr or TDeclRefExpr or
TDefaultArgumentExpr or TDiscardAssignmentExpr or TDotSyntaxBaseIgnoredExpr or
TDynamicTypeExpr or TEnumIsCaseExpr or TErrorExpr or TExplicitCastExpr or TForceValueExpr or
TIdentityExpr or TIfExpr or TImplicitConversionExpr or TInOutExpr or
TKeyPathApplicationExpr or TKeyPathDotExpr or TKeyPathExpr or TLazyInitializationExpr or
TLiteralExpr or TLookupExpr or TMakeTemporarilyEscapableExpr or TObjCSelectorExpr or
TOneWayExpr or TOpaqueValueExpr or TOpenExistentialExpr or TOptionalEvaluationExpr or
TOtherInitializerRefExpr or TOverloadedDeclRefExpr or TPackElementExpr or
TPackExpansionExpr or TPropertyWrapperValuePlaceholderExpr or
TRebindSelfInInitializerExpr or TSequenceExpr or TSingleValueStmtExpr or TSuperRefExpr or
TTapExpr or TTupleElementExpr or TTupleExpr or TTypeExpr or TUnresolvedDeclRefExpr or
TUnresolvedDotExpr or TUnresolvedMemberExpr or TUnresolvedPatternExpr or
TUnresolvedSpecializeExpr or TVarargExpansionExpr;
TCaptureListExpr or TClosureExpr or TCollectionExpr or TConsumeExpr or TCopyExpr or
TDeclRefExpr or TDefaultArgumentExpr or TDiscardAssignmentExpr or
TDotSyntaxBaseIgnoredExpr or TDynamicTypeExpr or TEnumIsCaseExpr or TErrorExpr or
TExplicitCastExpr or TForceValueExpr or TIdentityExpr or TIfExpr or
TImplicitConversionExpr or TInOutExpr or TKeyPathApplicationExpr or TKeyPathDotExpr or
TKeyPathExpr or TLazyInitializationExpr or TLiteralExpr or TLookupExpr or
TMakeTemporarilyEscapableExpr or TObjCSelectorExpr or TOneWayExpr or TOpaqueValueExpr or
TOpenExistentialExpr or TOptionalEvaluationExpr or TOtherInitializerRefExpr or
TOverloadedDeclRefExpr or TPackElementExpr or TPackExpansionExpr or
TPropertyWrapperValuePlaceholderExpr or TRebindSelfInInitializerExpr or TSequenceExpr or
TSingleValueStmtExpr or TSuperRefExpr or TTapExpr or TTupleElementExpr or TTupleExpr or
TTypeExpr or TUnresolvedDeclRefExpr or TUnresolvedDotExpr or TUnresolvedMemberExpr or
TUnresolvedPatternExpr or TUnresolvedSpecializeExpr or TVarargExpansionExpr;
/**
* INTERNAL: Do not use.
*/
class TIdentityExpr =
TAwaitExpr or TDotSelfExpr or TParenExpr or TUnresolvedMemberChainResultExpr;
TAwaitExpr or TBorrowExpr or TDotSelfExpr or TParenExpr or TUnresolvedMemberChainResultExpr;
/**
* INTERNAL: Do not use.
@@ -1787,6 +1799,13 @@ module Synth {
result = TBooleanLiteralExpr(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TBorrowExpr`, if possible.
*/
cached
TBorrowExpr convertBorrowExprFromRaw(Raw::Element e) { result = TBorrowExpr(e) }
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TBridgeFromObjCExpr`, if possible.
@@ -1860,6 +1879,20 @@ module Synth {
result = TConditionalCheckedCastExpr(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TConsumeExpr`, if possible.
*/
cached
TConsumeExpr convertConsumeExprFromRaw(Raw::Element e) { result = TConsumeExpr(e) }
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TCopyExpr`, if possible.
*/
cached
TCopyExpr convertCopyExprFromRaw(Raw::Element e) { result = TCopyExpr(e) }
/**
* INTERNAL: Do not use.
* Converts a raw element to a synthesized `TCovariantFunctionConversionExpr`, if possible.
@@ -3702,6 +3735,10 @@ module Synth {
or
result = convertCollectionExprFromRaw(e)
or
result = convertConsumeExprFromRaw(e)
or
result = convertCopyExprFromRaw(e)
or
result = convertDeclRefExprFromRaw(e)
or
result = convertDefaultArgumentExprFromRaw(e)
@@ -3799,6 +3836,8 @@ module Synth {
TIdentityExpr convertIdentityExprFromRaw(Raw::Element e) {
result = convertAwaitExprFromRaw(e)
or
result = convertBorrowExprFromRaw(e)
or
result = convertDotSelfExprFromRaw(e)
or
result = convertParenExprFromRaw(e)
@@ -4685,6 +4724,13 @@ module Synth {
e = TBooleanLiteralExpr(result)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TBorrowExpr` to a raw DB element, if possible.
*/
cached
Raw::Element convertBorrowExprToRaw(TBorrowExpr e) { e = TBorrowExpr(result) }
/**
* INTERNAL: Do not use.
* Converts a synthesized `TBridgeFromObjCExpr` to a raw DB element, if possible.
@@ -4758,6 +4804,20 @@ module Synth {
e = TConditionalCheckedCastExpr(result)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TConsumeExpr` to a raw DB element, if possible.
*/
cached
Raw::Element convertConsumeExprToRaw(TConsumeExpr e) { e = TConsumeExpr(result) }
/**
* INTERNAL: Do not use.
* Converts a synthesized `TCopyExpr` to a raw DB element, if possible.
*/
cached
Raw::Element convertCopyExprToRaw(TCopyExpr e) { e = TCopyExpr(result) }
/**
* INTERNAL: Do not use.
* Converts a synthesized `TCovariantFunctionConversionExpr` to a raw DB element, if possible.
@@ -6598,6 +6658,10 @@ module Synth {
or
result = convertCollectionExprToRaw(e)
or
result = convertConsumeExprToRaw(e)
or
result = convertCopyExprToRaw(e)
or
result = convertDeclRefExprToRaw(e)
or
result = convertDefaultArgumentExprToRaw(e)
@@ -6695,6 +6759,8 @@ module Synth {
Raw::Element convertIdentityExprToRaw(TIdentityExpr e) {
result = convertAwaitExprToRaw(e)
or
result = convertBorrowExprToRaw(e)
or
result = convertDotSelfExprToRaw(e)
or
result = convertParenExprToRaw(e)

View File

@@ -55,6 +55,7 @@ import codeql.swift.elements.expr.AwaitExprConstructor
import codeql.swift.elements.expr.BinaryExprConstructor
import codeql.swift.elements.expr.BindOptionalExprConstructor
import codeql.swift.elements.expr.BooleanLiteralExprConstructor
import codeql.swift.elements.expr.BorrowExprConstructor
import codeql.swift.elements.expr.BridgeFromObjCExprConstructor
import codeql.swift.elements.expr.BridgeToObjCExprConstructor
import codeql.swift.elements.expr.CallExprConstructor
@@ -64,6 +65,8 @@ import codeql.swift.elements.expr.CoerceExprConstructor
import codeql.swift.elements.expr.CollectionUpcastConversionExprConstructor
import codeql.swift.elements.expr.ConditionalBridgeFromObjCExprConstructor
import codeql.swift.elements.expr.ConditionalCheckedCastExprConstructor
import codeql.swift.elements.expr.ConsumeExprConstructor
import codeql.swift.elements.expr.CopyExprConstructor
import codeql.swift.elements.expr.CovariantFunctionConversionExprConstructor
import codeql.swift.elements.expr.CovariantReturnConversionExprConstructor
import codeql.swift.elements.expr.DeclRefExprConstructor

View File

@@ -0,0 +1,25 @@
// generated by codegen/codegen.py
/**
* This module provides the generated definition of `BorrowExpr`.
* INTERNAL: Do not import directly.
*/
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.expr.IdentityExpr
module Generated {
/**
* An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression:
*
* ```
* let y = ...
* let x = _borrow y
* ```
* INTERNAL: Do not reference the `Generated::BorrowExpr` class directly.
* Use the subclass `BorrowExpr`, where the following predicates are available.
*/
class BorrowExpr extends Synth::TBorrowExpr, IdentityExpr {
override string getAPrimaryQlClass() { result = "BorrowExpr" }
}
}

View File

@@ -0,0 +1,48 @@
// generated by codegen/codegen.py
/**
* This module provides the generated definition of `ConsumeExpr`.
* INTERNAL: Do not import directly.
*/
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.expr.Expr
module Generated {
/**
* An expression that forces value to be moved. In the example below, `consume` marks the move expression:
*
* ```
* let y = ...
* let x = consume y
* ```
* INTERNAL: Do not reference the `Generated::ConsumeExpr` class directly.
* Use the subclass `ConsumeExpr`, where the following predicates are available.
*/
class ConsumeExpr extends Synth::TConsumeExpr, Expr {
override string getAPrimaryQlClass() { result = "ConsumeExpr" }
/**
* Gets the sub expression of this consume expression.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Expr getImmediateSubExpr() {
result =
Synth::convertExprFromRaw(Synth::convertConsumeExprToRaw(this)
.(Raw::ConsumeExpr)
.getSubExpr())
}
/**
* Gets the sub expression of this consume expression.
*/
final Expr getSubExpr() {
exists(Expr immediate |
immediate = this.getImmediateSubExpr() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)
}
}
}

View File

@@ -0,0 +1,46 @@
// generated by codegen/codegen.py
/**
* This module provides the generated definition of `CopyExpr`.
* INTERNAL: Do not import directly.
*/
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.expr.Expr
module Generated {
/**
* An expression that forces value to be copied. In the example below, `copy` marks the copy expression:
*
* ```
* let y = ...
* let x = copy y
* ```
* INTERNAL: Do not reference the `Generated::CopyExpr` class directly.
* Use the subclass `CopyExpr`, where the following predicates are available.
*/
class CopyExpr extends Synth::TCopyExpr, Expr {
override string getAPrimaryQlClass() { result = "CopyExpr" }
/**
* Gets the sub expression of this copy expression.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Expr getImmediateSubExpr() {
result =
Synth::convertExprFromRaw(Synth::convertCopyExprToRaw(this).(Raw::CopyExpr).getSubExpr())
}
/**
* Gets the sub expression of this copy expression.
*/
final Expr getSubExpr() {
exists(Expr immediate |
immediate = this.getImmediateSubExpr() and
if exists(this.getResolveStep()) then result = immediate else result = immediate.resolve()
)
}
}
}

View File

@@ -734,6 +734,8 @@ arguments( //dir=expr
| @capture_list_expr
| @closure_expr
| @collection_expr
| @consume_expr
| @copy_expr
| @decl_ref_expr
| @default_argument_expr
| @discard_assignment_expr
@@ -859,6 +861,16 @@ capture_list_expr_binding_decls( //dir=expr
| @dictionary_expr
;
consume_exprs( //dir=expr
unique int id: @consume_expr,
int sub_expr: @expr_or_none ref
);
copy_exprs( //dir=expr
unique int id: @copy_expr,
int sub_expr: @expr_or_none ref
);
decl_ref_exprs( //dir=expr
unique int id: @decl_ref_expr,
int decl: @decl_or_none ref
@@ -946,6 +958,7 @@ force_value_exprs( //dir=expr
@identity_expr =
@await_expr
| @borrow_expr
| @dot_self_expr
| @paren_expr
| @unresolved_member_chain_result_expr
@@ -1280,6 +1293,10 @@ binary_exprs( //dir=expr
unique int id: @binary_expr
);
borrow_exprs( //dir=expr
unique int id: @borrow_expr
);
bridge_from_obj_c_exprs( //dir=expr
unique int id: @bridge_from_obj_c_expr
);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Added AST nodes related to move semantics
compatibility: partial

View File

@@ -0,0 +1 @@
| move_semantics.swift:5:9:5:17 | ConsumeExpr | hasType: | yes | getSubExpr: | move_semantics.swift:5:17:5:17 | x |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ConsumeExpr x, string hasType, Expr getSubExpr
where
toBeTested(x) and
not x.isUnknown() and
(if x.hasType() then hasType = "yes" else hasType = "no") and
getSubExpr = x.getSubExpr()
select x, "hasType:", hasType, "getSubExpr:", getSubExpr

View File

@@ -0,0 +1 @@
| move_semantics.swift:5:9:5:17 | ConsumeExpr | Int |

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ConsumeExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()

View File

@@ -0,0 +1 @@
| move_semantics.swift:4:9:4:14 | CopyExpr | hasType: | yes | getSubExpr: | move_semantics.swift:4:14:4:14 | x |

View File

@@ -0,0 +1,11 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from CopyExpr x, string hasType, Expr getSubExpr
where
toBeTested(x) and
not x.isUnknown() and
(if x.hasType() then hasType = "yes" else hasType = "no") and
getSubExpr = x.getSubExpr()
select x, "hasType:", hasType, "getSubExpr:", getSubExpr

View File

@@ -0,0 +1 @@
| move_semantics.swift:4:9:4:14 | CopyExpr | Int |

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from CopyExpr x
where toBeTested(x) and not x.isUnknown()
select x, x.getType()

View File

@@ -0,0 +1,5 @@
//codeql-extractor-options: -enable-experimental-move-only
let x = 42
let _ = copy x
let _ = consume x

View File

@@ -1,8 +1,9 @@
| identity_expressions.swift:4:9:4:14 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:4:9:4:9 | self |
| identity_expressions.swift:4:9:4:21 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:4:9:4:19 | .x |
| identity_expressions.swift:4:28:4:31 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:4:29:4:29 | 42 |
| identity_expressions.swift:8:5:8:9 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:8:6:8:8 | call to A.init() |
| identity_expressions.swift:11:28:11:43 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:11:29:11:42 | await ... |
| identity_expressions.swift:11:29:11:42 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:11:35:11:42 | call to create() |
| identity_expressions.swift:14:5:14:21 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:14:11:14:21 | call to process() |
| identity_expressions.swift:14:11:14:19 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:14:12:14:12 | process() |
| identity_expressions.swift:5:9:5:14 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:5:9:5:9 | self |
| identity_expressions.swift:5:9:5:21 | .self | DotSelfExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:5:9:5:19 | .x |
| identity_expressions.swift:5:28:5:31 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:5:29:5:29 | 42 |
| identity_expressions.swift:9:5:9:9 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:9:6:9:8 | call to A.init() |
| identity_expressions.swift:12:28:12:43 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:12:29:12:42 | await ... |
| identity_expressions.swift:12:29:12:42 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:12:35:12:42 | call to create() |
| identity_expressions.swift:15:5:15:21 | await ... | AwaitExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:15:11:15:21 | call to process() |
| identity_expressions.swift:15:11:15:19 | (...) | ParenExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:15:12:15:12 | process() |
| identity_expressions.swift:18:9:18:17 | BorrowExpr | BorrowExpr | hasType: | yes | getSubExpr: | identity_expressions.swift:18:17:18:17 | x |

View File

@@ -1,8 +1,9 @@
| identity_expressions.swift:4:9:4:14 | .self | A |
| identity_expressions.swift:4:9:4:21 | .self | @lvalue Int |
| identity_expressions.swift:4:28:4:31 | (...) | (Int) |
| identity_expressions.swift:8:5:8:9 | (...) | (A) |
| identity_expressions.swift:11:28:11:43 | (...) | (A) |
| identity_expressions.swift:11:29:11:42 | await ... | A |
| identity_expressions.swift:14:5:14:21 | await ... | () |
| identity_expressions.swift:14:11:14:19 | (...) | (() async -> ()) |
| identity_expressions.swift:5:9:5:14 | .self | A |
| identity_expressions.swift:5:9:5:21 | .self | @lvalue Int |
| identity_expressions.swift:5:28:5:31 | (...) | (Int) |
| identity_expressions.swift:9:5:9:9 | (...) | (A) |
| identity_expressions.swift:12:28:12:43 | (...) | (A) |
| identity_expressions.swift:12:29:12:42 | await ... | A |
| identity_expressions.swift:15:5:15:21 | await ... | () |
| identity_expressions.swift:15:11:15:19 | (...) | (() async -> ()) |
| identity_expressions.swift:18:9:18:17 | BorrowExpr | Int |

View File

@@ -1,3 +1,4 @@
//codeql-extractor-options: -enable-experimental-move-only
class A {
var x: Int
init() {
@@ -13,3 +14,5 @@ func process() async { _ = (await create())}
Task.init {
await (process)()
}
let x = 42
let _ = _borrow x

View File

@@ -159,11 +159,12 @@ struct URLRequest : CustomStringConvertible, CustomDebugStringConvertible {
enum NetworkServiceType { case none }
enum Attribution { case none }
var cachePolicy: CachePolicy = .none
var httpMethod: String = ""
var url: URL = URL(string: "")!
var httpBody: Data = Data("")
var httpMethod: String? = ""
var url: URL? = URL(string: "")
var httpBody: Data? = Data("")
var httpBodyStream: InputStream? = nil
var mainDocument: URL = URL(string: "")!
var mainDocumentURL: URL? = URL(string: "")
var allHTTPHeaderFields: [String : String]? = nil
var timeoutInterval: TimeInterval = TimeInterval()
var httpShouldHandleCookies: Bool = false
@@ -204,7 +205,6 @@ func sink(data: Data) {}
func sink(string: String) {}
func sink(int: Int) {}
func sink(any: Any) {}
func taintThroughURL() {
let clean = "http://example.com/"
let tainted = source() as! String
@@ -436,14 +436,16 @@ func taintThroughUrlRequest() {
sink(any: tainted.cachePolicy)
sink(any: clean.httpMethod)
sink(any: tainted.httpMethod)
sink(any: clean.url)
sink(any: tainted.url) // $ tainted=431
sink(any: clean.httpBody)
sink(any: tainted.httpBody) // $ tainted=431
sink(any: clean.url!)
sink(any: tainted.url!) // $ tainted=431
sink(any: clean.httpBody!)
sink(any: tainted.httpBody!) // $ tainted=431
sink(any: clean.httpBodyStream!)
sink(any: tainted.httpBodyStream!) // $ tainted=431
sink(any: clean.mainDocument)
sink(any: tainted.mainDocument) // $ tainted=431
sink(any: clean.mainDocumentURL!)
sink(any: tainted.mainDocumentURL!) // $ tainted=431
sink(any: clean.allHTTPHeaderFields!)
sink(any: tainted.allHTTPHeaderFields!) // $ tainted=431
sink(any: clean.timeoutInterval)
@@ -481,19 +483,19 @@ func taintThroughUrlResource() {
let tainted = source() as! URLResource
sink(string: clean.name)
sink(string: tainted.name) // $ tainted=481
sink(string: tainted.name) // $ tainted=483
sink(string: clean.subdirectory!)
sink(string: tainted.subdirectory!) // $ tainted=481
sink(string: tainted.subdirectory!) // $ tainted=483
}
func taintUrlAsync() async throws {
let tainted = source() as! String
let urlTainted = URL(string: tainted)!
sink(any: urlTainted.lines) // $ tainted=490
sink(any: urlTainted.lines) // $ tainted=492
for try await line in urlTainted.lines {
sink(string: line) // $ MISSING: tainted=490
sink(string: line) // $ MISSING: tainted=492
}
}
@@ -510,5 +512,5 @@ func closureReturnValue() {
ptr in
return source() as! String
})
sink(string: r2) // $ tainted=511
sink(string: r2) // $ tainted=513
}

View File

@@ -76,7 +76,7 @@ struct URLRequest {}
// --- tests ---
func source() -> Any { return "" }
func source(_ label: String? = "") -> Any { return "" }
func sink(_: Any) {}
func testInheritBodyTaint() {
@@ -146,6 +146,9 @@ func testWKUserScript() {
}
func testWKNavigationAction() {
let src = source() as! WKNavigationAction
sink(src.request) // $ tainted=149
}
let src = source("WKNavigationAction") as! WKNavigationAction
sink(src.request) // $ tainted=WKNavigationAction
let keypath = \WKNavigationAction.request
sink(src[keyPath: keypath]) // $ tainted=WKNavigationAction
}

View File

@@ -1327,3 +1327,37 @@ class PackElementExpr(Expr):
https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
"""
sub_expr: Expr | child
class CopyExpr(Expr):
"""
An expression that forces value to be copied. In the example below, `copy` marks the copy expression:
```
let y = ...
let x = copy y
```
"""
sub_expr: Expr | child
@qltest.test_with(CopyExpr)
class ConsumeExpr(Expr):
"""
An expression that forces value to be moved. In the example below, `consume` marks the move expression:
```
let y = ...
let x = consume y
```
"""
sub_expr: Expr | child
class BorrowExpr(IdentityExpr):
"""
An expression that marks value as borrowed. In the example below, `_borrow` marks the borrow expression:
```
let y = ...
let x = _borrow y
```
"""
pass