From 5ac3343b6d916d936737bbe28aa63b6fb2b027e9 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:55:59 +0000 Subject: [PATCH 1/8] Unified: Add TODO comments in the query for the parts we're still missing. --- .../ql/src/queries/security/CWE-312/CleartextLogging.ql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql index 7f72eb6ed7e0..ed76734b6b4f 100644 --- a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql +++ b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql @@ -32,13 +32,22 @@ module CleartextLoggingConfig implements DataFlow::ConfigSig { predicate isSource(DataFlow::Node node) { node instanceof SensitiveData } predicate isSink(DataFlow::Node node) { + // TODO: implement full sinks as in the original Swift query exists(CallExpr call | getNameFromExpr(call.getCallee()).regexpMatch("(?i)(ns)?(log|warn(ing)?|error|print).*") and node.asExpr() = call.getAnArgument().getValue() ) } + predicate isBarrier(DataFlow::Node node) { + none() // TODO: barriers for booleans, encrypted data, and MaD defined barriers as in original Swift + } + predicate isBarrierIn(DataFlow::Node node) { isSource(node) } + + predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) { + none() // TODO: implement additional flow steps as in the original Swift query + } } module CleartextLoggingFlow = TaintTracking::Global; From 0293b08d27cee2dc66db3e63e1e25d75396d9c8a Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:12:42 +0000 Subject: [PATCH 2/8] Unified: Add a few more test cases. --- .../CleartextLogging.expected | 176 ++++++++++-------- .../CleartextLoggingTest.swift | 26 +++ 2 files changed, 128 insertions(+), 74 deletions(-) diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected index bce43bade02b..f80af71bdf6e 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected @@ -16,31 +16,41 @@ | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | written | | CleartextLoggingTest.swift:220:11:220:20 | passphrase | CleartextLoggingTest.swift:220:11:220:20 | passphrase | CleartextLoggingTest.swift:220:11:220:20 | passphrase | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:220:11:220:20 | passphrase | written | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | written | -| CleartextLoggingTest.swift:245:10:245:22 | getPassword(...) | CleartextLoggingTest.swift:245:10:245:22 | getPassword(...) | CleartextLoggingTest.swift:246:8:246:8 | y | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:246:8:246:8 | y | written | -| CleartextLoggingTest.swift:250:8:250:17 | ... .password | CleartextLoggingTest.swift:250:8:250:17 | ... .password | CleartextLoggingTest.swift:250:8:250:17 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:250:8:250:17 | ... .password | written | -| CleartextLoggingTest.swift:251:8:251:22 | ... .getPassword(...) | CleartextLoggingTest.swift:251:8:251:22 | ... .getPassword(...) | CleartextLoggingTest.swift:251:8:251:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:251:8:251:22 | ... .getPassword(...) | written | -| CleartextLoggingTest.swift:268:8:268:24 | ... .value | CleartextLoggingTest.swift:268:8:268:24 | ... .value | CleartextLoggingTest.swift:268:8:268:24 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:268:8:268:24 | ... .value | written | -| CleartextLoggingTest.swift:271:8:271:29 | ... .getValue(...) | CleartextLoggingTest.swift:271:8:271:29 | ... .getValue(...) | CleartextLoggingTest.swift:271:8:271:29 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:271:8:271:29 | ... .getValue(...) | written | -| CleartextLoggingTest.swift:294:8:294:15 | password | CleartextLoggingTest.swift:294:8:294:15 | password | CleartextLoggingTest.swift:294:8:294:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:294:8:294:15 | password | written | -| CleartextLoggingTest.swift:297:18:297:25 | password | CleartextLoggingTest.swift:297:18:297:25 | password | CleartextLoggingTest.swift:297:8:297:25 | ... + ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:297:8:297:25 | ... + ... | written | -| CleartextLoggingTest.swift:315:18:315:25 | password | CleartextLoggingTest.swift:315:18:315:25 | password | CleartextLoggingTest.swift:316:8:316:16 | myString9 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:316:8:316:16 | myString9 | written | -| CleartextLoggingTest.swift:319:19:319:26 | password | CleartextLoggingTest.swift:319:19:319:26 | password | CleartextLoggingTest.swift:321:8:321:17 | myString10 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:321:8:321:17 | myString10 | written | -| CleartextLoggingTest.swift:326:2:326:9 | password | CleartextLoggingTest.swift:326:2:326:9 | password | CleartextLoggingTest.swift:327:8:327:17 | myString12 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:327:8:327:17 | myString12 | written | -| CleartextLoggingTest.swift:329:8:329:15 | password | CleartextLoggingTest.swift:329:8:329:15 | password | CleartextLoggingTest.swift:329:8:329:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:329:8:329:15 | password | written | -| CleartextLoggingTest.swift:373:18:373:24 | authKey | CleartextLoggingTest.swift:373:18:373:24 | authKey | CleartextLoggingTest.swift:373:18:373:24 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:373:18:373:24 | authKey | written | -| CleartextLoggingTest.swift:374:25:374:32 | authKey2 | CleartextLoggingTest.swift:374:25:374:32 | authKey2 | CleartextLoggingTest.swift:374:18:374:33 | String(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:374:18:374:33 | String(...) | written | -| CleartextLoggingTest.swift:375:22:375:28 | authKey | CleartextLoggingTest.swift:375:22:375:28 | authKey | CleartextLoggingTest.swift:375:22:375:28 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:375:22:375:28 | authKey | written | -| CleartextLoggingTest.swift:376:31:376:37 | authKey | CleartextLoggingTest.swift:376:31:376:37 | authKey | CleartextLoggingTest.swift:376:31:376:37 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:376:31:376:37 | authKey | written | -| CleartextLoggingTest.swift:377:33:377:39 | authKey | CleartextLoggingTest.swift:377:33:377:39 | authKey | CleartextLoggingTest.swift:377:16:377:40 | NSString(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:377:16:377:40 | NSString(...) | written | -| CleartextLoggingTest.swift:378:13:378:19 | authKey | CleartextLoggingTest.swift:378:13:378:19 | authKey | CleartextLoggingTest.swift:378:13:378:19 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:378:13:378:19 | authKey | written | -| CleartextLoggingTest.swift:379:24:379:30 | authKey | CleartextLoggingTest.swift:379:24:379:30 | authKey | CleartextLoggingTest.swift:379:24:379:30 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:379:24:379:30 | authKey | written | -| CleartextLoggingTest.swift:381:19:381:26 | authKey3 | CleartextLoggingTest.swift:381:19:381:26 | authKey3 | CleartextLoggingTest.swift:381:19:381:26 | authKey3 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:381:19:381:26 | authKey3 | written | -| CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:386:16:386:18 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:386:16:386:18 | msg | written | -| CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:391:20:391:22 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:391:20:391:22 | msg | written | -| CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:392:18:392:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:392:18:392:20 | msg | written | -| CleartextLoggingTest.swift:402:29:402:36 | password | CleartextLoggingTest.swift:402:29:402:36 | password | CleartextLoggingTest.swift:402:29:402:36 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:402:29:402:36 | password | written | -| CleartextLoggingTest.swift:403:28:403:33 | secret | CleartextLoggingTest.swift:403:28:403:33 | secret | CleartextLoggingTest.swift:403:28:403:33 | secret | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:403:28:403:33 | secret | written | -| CleartextLoggingTest.swift:411:11:411:24 | globalPassword | CleartextLoggingTest.swift:411:11:411:24 | globalPassword | CleartextLoggingTest.swift:411:11:411:24 | globalPassword | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:411:11:411:24 | globalPassword | written | +| CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:249:8:249:8 | y | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:249:8:249:8 | y | written | +| CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:253:8:253:17 | ... .password | written | +| CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | written | +| CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:256:9:256:9 | v | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:256:9:256:9 | v | written | +| CleartextLoggingTest.swift:258:8:258:26 | ... ! | CleartextLoggingTest.swift:258:8:258:26 | ... ! | CleartextLoggingTest.swift:258:8:258:26 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:258:8:258:26 | ... ! | written | +| CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:263:11:263:21 | ... .password | written | +| CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:265:11:265:22 | ... ! | CleartextLoggingTest.swift:265:11:265:22 | ... ! | CleartextLoggingTest.swift:265:11:265:22 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:265:11:265:22 | ... ! | written | +| CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:268:11:268:23 | ... .password | written | +| CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:288:8:288:24 | ... .value | CleartextLoggingTest.swift:288:8:288:24 | ... .value | CleartextLoggingTest.swift:288:8:288:24 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:288:8:288:24 | ... .value | written | +| CleartextLoggingTest.swift:291:8:291:34 | ... ! | CleartextLoggingTest.swift:291:8:291:34 | ... ! | CleartextLoggingTest.swift:291:8:291:34 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:291:8:291:34 | ... ! | written | +| CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | written | +| CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | written | +| CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:320:8:320:15 | password | written | +| CleartextLoggingTest.swift:323:18:323:25 | password | CleartextLoggingTest.swift:323:18:323:25 | password | CleartextLoggingTest.swift:323:8:323:25 | ... + ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:323:8:323:25 | ... + ... | written | +| CleartextLoggingTest.swift:341:18:341:25 | password | CleartextLoggingTest.swift:341:18:341:25 | password | CleartextLoggingTest.swift:342:8:342:16 | myString9 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:342:8:342:16 | myString9 | written | +| CleartextLoggingTest.swift:345:19:345:26 | password | CleartextLoggingTest.swift:345:19:345:26 | password | CleartextLoggingTest.swift:347:8:347:17 | myString10 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:347:8:347:17 | myString10 | written | +| CleartextLoggingTest.swift:352:2:352:9 | password | CleartextLoggingTest.swift:352:2:352:9 | password | CleartextLoggingTest.swift:353:8:353:17 | myString12 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:353:8:353:17 | myString12 | written | +| CleartextLoggingTest.swift:355:8:355:15 | password | CleartextLoggingTest.swift:355:8:355:15 | password | CleartextLoggingTest.swift:355:8:355:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:355:8:355:15 | password | written | +| CleartextLoggingTest.swift:399:18:399:24 | authKey | CleartextLoggingTest.swift:399:18:399:24 | authKey | CleartextLoggingTest.swift:399:18:399:24 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:399:18:399:24 | authKey | written | +| CleartextLoggingTest.swift:400:25:400:32 | authKey2 | CleartextLoggingTest.swift:400:25:400:32 | authKey2 | CleartextLoggingTest.swift:400:18:400:33 | String(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:400:18:400:33 | String(...) | written | +| CleartextLoggingTest.swift:401:22:401:28 | authKey | CleartextLoggingTest.swift:401:22:401:28 | authKey | CleartextLoggingTest.swift:401:22:401:28 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:401:22:401:28 | authKey | written | +| CleartextLoggingTest.swift:402:31:402:37 | authKey | CleartextLoggingTest.swift:402:31:402:37 | authKey | CleartextLoggingTest.swift:402:31:402:37 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:402:31:402:37 | authKey | written | +| CleartextLoggingTest.swift:403:33:403:39 | authKey | CleartextLoggingTest.swift:403:33:403:39 | authKey | CleartextLoggingTest.swift:403:16:403:40 | NSString(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:403:16:403:40 | NSString(...) | written | +| CleartextLoggingTest.swift:404:13:404:19 | authKey | CleartextLoggingTest.swift:404:13:404:19 | authKey | CleartextLoggingTest.swift:404:13:404:19 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:404:13:404:19 | authKey | written | +| CleartextLoggingTest.swift:405:24:405:30 | authKey | CleartextLoggingTest.swift:405:24:405:30 | authKey | CleartextLoggingTest.swift:405:24:405:30 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:405:24:405:30 | authKey | written | +| CleartextLoggingTest.swift:407:19:407:26 | authKey3 | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:412:16:412:18 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:412:16:412:18 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:417:20:417:22 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:417:20:417:22 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:418:18:418:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:418:18:418:20 | msg | written | +| CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:428:29:428:36 | password | written | +| CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:429:28:429:33 | secret | written | +| CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | written | edges | CleartextLoggingBad.swift:2:35:2:42 | password | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | provenance | | | CleartextLoggingTest.swift:182:14:182:21 | password | CleartextLoggingTest.swift:182:11:182:23 | StringInterpolationExpr | provenance | | @@ -50,19 +60,23 @@ edges | CleartextLoggingTest.swift:184:36:184:43 | password | CleartextLoggingTest.swift:184:31:184:44 | ArrayLiteral [ArrayElement] | provenance | | | CleartextLoggingTest.swift:191:16:191:23 | password | CleartextLoggingTest.swift:191:13:191:25 | StringInterpolationExpr | provenance | | | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | provenance | | -| CleartextLoggingTest.swift:245:6:245:6 | y | CleartextLoggingTest.swift:246:8:246:8 | y | provenance | | -| CleartextLoggingTest.swift:245:10:245:22 | getPassword(...) | CleartextLoggingTest.swift:245:6:245:6 | y | provenance | | -| CleartextLoggingTest.swift:297:18:297:25 | password | CleartextLoggingTest.swift:297:8:297:25 | ... + ... | provenance | | -| CleartextLoggingTest.swift:315:18:315:25 | password | CleartextLoggingTest.swift:316:8:316:16 | myString9 | provenance | | -| CleartextLoggingTest.swift:319:19:319:26 | password | CleartextLoggingTest.swift:321:8:321:17 | myString10 | provenance | | -| CleartextLoggingTest.swift:326:2:326:9 | password | CleartextLoggingTest.swift:326:21:326:31 | [post] & ... | provenance | | -| CleartextLoggingTest.swift:326:21:326:31 | [post] & ... | CleartextLoggingTest.swift:327:8:327:17 | myString12 | provenance | | -| CleartextLoggingTest.swift:374:25:374:32 | authKey2 | CleartextLoggingTest.swift:374:18:374:33 | String(...) | provenance | | -| CleartextLoggingTest.swift:377:33:377:39 | authKey | CleartextLoggingTest.swift:377:16:377:40 | NSString(...) | provenance | | -| CleartextLoggingTest.swift:385:9:385:11 | msg | CleartextLoggingTest.swift:386:16:386:18 | msg | provenance | | -| CleartextLoggingTest.swift:385:9:385:11 | msg | CleartextLoggingTest.swift:391:20:391:22 | msg | provenance | | -| CleartextLoggingTest.swift:385:9:385:11 | msg | CleartextLoggingTest.swift:392:18:392:20 | msg | provenance | | -| CleartextLoggingTest.swift:385:29:385:35 | authKey | CleartextLoggingTest.swift:385:9:385:11 | msg | provenance | | +| CleartextLoggingTest.swift:248:6:248:6 | y | CleartextLoggingTest.swift:249:8:249:8 | y | provenance | | +| CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:6:248:6 | y | provenance | | +| CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | CleartextLoggingTest.swift:255:9:255:9 | v | provenance | | +| CleartextLoggingTest.swift:255:9:255:9 | v | CleartextLoggingTest.swift:256:9:256:9 | v | provenance | | +| CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | provenance | | +| CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | provenance | | +| CleartextLoggingTest.swift:323:18:323:25 | password | CleartextLoggingTest.swift:323:8:323:25 | ... + ... | provenance | | +| CleartextLoggingTest.swift:341:18:341:25 | password | CleartextLoggingTest.swift:342:8:342:16 | myString9 | provenance | | +| CleartextLoggingTest.swift:345:19:345:26 | password | CleartextLoggingTest.swift:347:8:347:17 | myString10 | provenance | | +| CleartextLoggingTest.swift:352:2:352:9 | password | CleartextLoggingTest.swift:352:21:352:31 | [post] & ... | provenance | | +| CleartextLoggingTest.swift:352:21:352:31 | [post] & ... | CleartextLoggingTest.swift:353:8:353:17 | myString12 | provenance | | +| CleartextLoggingTest.swift:400:25:400:32 | authKey2 | CleartextLoggingTest.swift:400:18:400:33 | String(...) | provenance | | +| CleartextLoggingTest.swift:403:33:403:39 | authKey | CleartextLoggingTest.swift:403:16:403:40 | NSString(...) | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:412:16:412:18 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:417:20:417:22 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:418:18:418:20 | msg | provenance | | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:9:411:11 | msg | provenance | | nodes | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | | CleartextLoggingBad.swift:2:35:2:42 | password | semmle.label | password | @@ -89,40 +103,54 @@ nodes | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | semmle.label | bankAccount | | CleartextLoggingTest.swift:220:11:220:20 | passphrase | semmle.label | passphrase | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | semmle.label | pass_phrase | -| CleartextLoggingTest.swift:245:6:245:6 | y | semmle.label | y | -| CleartextLoggingTest.swift:245:10:245:22 | getPassword(...) | semmle.label | getPassword(...) | -| CleartextLoggingTest.swift:246:8:246:8 | y | semmle.label | y | -| CleartextLoggingTest.swift:250:8:250:17 | ... .password | semmle.label | ... .password | -| CleartextLoggingTest.swift:251:8:251:22 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | -| CleartextLoggingTest.swift:268:8:268:24 | ... .value | semmle.label | ... .value | -| CleartextLoggingTest.swift:271:8:271:29 | ... .getValue(...) | semmle.label | ... .getValue(...) | -| CleartextLoggingTest.swift:294:8:294:15 | password | semmle.label | password | -| CleartextLoggingTest.swift:297:8:297:25 | ... + ... | semmle.label | ... + ... | -| CleartextLoggingTest.swift:297:18:297:25 | password | semmle.label | password | -| CleartextLoggingTest.swift:315:18:315:25 | password | semmle.label | password | -| CleartextLoggingTest.swift:316:8:316:16 | myString9 | semmle.label | myString9 | -| CleartextLoggingTest.swift:319:19:319:26 | password | semmle.label | password | -| CleartextLoggingTest.swift:321:8:321:17 | myString10 | semmle.label | myString10 | -| CleartextLoggingTest.swift:326:2:326:9 | password | semmle.label | password | -| CleartextLoggingTest.swift:326:21:326:31 | [post] & ... | semmle.label | [post] & ... | -| CleartextLoggingTest.swift:327:8:327:17 | myString12 | semmle.label | myString12 | -| CleartextLoggingTest.swift:329:8:329:15 | password | semmle.label | password | -| CleartextLoggingTest.swift:373:18:373:24 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:374:18:374:33 | String(...) | semmle.label | String(...) | -| CleartextLoggingTest.swift:374:25:374:32 | authKey2 | semmle.label | authKey2 | -| CleartextLoggingTest.swift:375:22:375:28 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:376:31:376:37 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:377:16:377:40 | NSString(...) | semmle.label | NSString(...) | -| CleartextLoggingTest.swift:377:33:377:39 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:378:13:378:19 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:379:24:379:30 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:381:19:381:26 | authKey3 | semmle.label | authKey3 | -| CleartextLoggingTest.swift:385:9:385:11 | msg | semmle.label | msg | -| CleartextLoggingTest.swift:385:29:385:35 | authKey | semmle.label | authKey | -| CleartextLoggingTest.swift:386:16:386:18 | msg | semmle.label | msg | -| CleartextLoggingTest.swift:391:20:391:22 | msg | semmle.label | msg | -| CleartextLoggingTest.swift:392:18:392:20 | msg | semmle.label | msg | -| CleartextLoggingTest.swift:402:29:402:36 | password | semmle.label | password | -| CleartextLoggingTest.swift:403:28:403:33 | secret | semmle.label | secret | -| CleartextLoggingTest.swift:411:11:411:24 | globalPassword | semmle.label | globalPassword | +| CleartextLoggingTest.swift:248:6:248:6 | y | semmle.label | y | +| CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | semmle.label | getPassword(...) | +| CleartextLoggingTest.swift:249:8:249:8 | y | semmle.label | y | +| CleartextLoggingTest.swift:253:8:253:17 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | semmle.label | ... .passwords(...) | +| CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | semmle.label | ... .some(...) | +| CleartextLoggingTest.swift:255:9:255:9 | v | semmle.label | v | +| CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | semmle.label | ... .optionalPassword | +| CleartextLoggingTest.swift:256:9:256:9 | v | semmle.label | v | +| CleartextLoggingTest.swift:258:8:258:26 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | +| CleartextLoggingTest.swift:263:11:263:21 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | +| CleartextLoggingTest.swift:265:11:265:22 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:268:11:268:23 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | +| CleartextLoggingTest.swift:288:8:288:24 | ... .value | semmle.label | ... .value | +| CleartextLoggingTest.swift:291:8:291:34 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | semmle.label | ... .getValue(...) | +| CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | semmle.label | ... .getValue(...) | +| CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | semmle.label | ... ?? ... | +| CleartextLoggingTest.swift:320:8:320:15 | password | semmle.label | password | +| CleartextLoggingTest.swift:323:8:323:25 | ... + ... | semmle.label | ... + ... | +| CleartextLoggingTest.swift:323:18:323:25 | password | semmle.label | password | +| CleartextLoggingTest.swift:341:18:341:25 | password | semmle.label | password | +| CleartextLoggingTest.swift:342:8:342:16 | myString9 | semmle.label | myString9 | +| CleartextLoggingTest.swift:345:19:345:26 | password | semmle.label | password | +| CleartextLoggingTest.swift:347:8:347:17 | myString10 | semmle.label | myString10 | +| CleartextLoggingTest.swift:352:2:352:9 | password | semmle.label | password | +| CleartextLoggingTest.swift:352:21:352:31 | [post] & ... | semmle.label | [post] & ... | +| CleartextLoggingTest.swift:353:8:353:17 | myString12 | semmle.label | myString12 | +| CleartextLoggingTest.swift:355:8:355:15 | password | semmle.label | password | +| CleartextLoggingTest.swift:399:18:399:24 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:400:18:400:33 | String(...) | semmle.label | String(...) | +| CleartextLoggingTest.swift:400:25:400:32 | authKey2 | semmle.label | authKey2 | +| CleartextLoggingTest.swift:401:22:401:28 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:402:31:402:37 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:403:16:403:40 | NSString(...) | semmle.label | NSString(...) | +| CleartextLoggingTest.swift:403:33:403:39 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:404:13:404:19 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:405:24:405:30 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:407:19:407:26 | authKey3 | semmle.label | authKey3 | +| CleartextLoggingTest.swift:411:9:411:11 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | semmle.label | authKey | +| CleartextLoggingTest.swift:412:16:412:18 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:417:20:417:22 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:418:18:418:20 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:428:29:428:36 | password | semmle.label | password | +| CleartextLoggingTest.swift:429:28:429:33 | secret | semmle.label | secret | +| CleartextLoggingTest.swift:437:11:437:24 | globalPassword | semmle.label | globalPassword | subpaths diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift index 38c20943ea1a..e864a2821f83 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift @@ -228,6 +228,9 @@ func test1(password: String, passwordHash : String, passphrase: String, pass_phr class MyClass { var harmless = "abc" var password = "123" + var passwords[3] + var optionalPassword: String? = "123" + var credentials = ["password": "123"] func getPassword() -> String { return "" } } @@ -248,7 +251,22 @@ func test3(x: String) { let z = MyClass() NSLog(z.harmless) // safe NSLog(z.password) // $ Alert[unified/swift/cleartext-logging] + NSLog(z.passwords[0]) // $ Alert[unified/swift/cleartext-logging] + if let v = z.optionalPassword { // $ Alert[unified/swift/cleartext-logging] + NSLog(v) // $ Sink[unified/swift/cleartext-logging] + } + NSLog(z.optionalPassword!) // $ Alert[unified/swift/cleartext-logging] + NSLog(z.credentials["password"]!) // $ MISSING: Alert[unified/swift/cleartext-logging] NSLog(z.getPassword()) // $ Alert[unified/swift/cleartext-logging] + + let o: MyClass? = MyClass() + NSLog(o!.password) // $ Alert[unified/swift/cleartext-logging] + NSLog(o!.getPassword()) // $ Alert[unified/swift/cleartext-logging] + NSLog(o?.password!) // $ Alert[unified/swift/cleartext-logging] + + let a: MyClass[3] = [MyClass(), MyClass(), MyClass()] + NSLog(a[0].password) // $ Alert[unified/swift/cleartext-logging] + NSLog(a[0].getPassword()) // $ Alert[unified/swift/cleartext-logging] } struct MyOuter { @@ -259,6 +277,8 @@ struct MyOuter { } var password: MyInner + var passwords: [MyInner] + var optionalPassword: MyInner? var harmless: MyInner } @@ -266,9 +286,15 @@ func test3(mo : MyOuter) { // struct members... NSLog(mo.password.value) // $ Alert[unified/swift/cleartext-logging] + NSLog(mo.passwords[0].value) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSLog(mo.optionalPassword!.value) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSLog(mo.optionalPassword?.value!) // $ Alert[unified/swift/cleartext-logging] NSLog(mo.harmless.value) // safe NSLog(mo.password.getValue()) // $ Alert[unified/swift/cleartext-logging] + NSLog(mo.passwords[0].getValue()) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSLog(mo.optionalPassword!.getValue()) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSLog(mo.optionalPassword?.getValue() ?? "") // $ Alert[unified/swift/cleartext-logging] NSLog(mo.harmless.getValue()) // safe } From 206b42ab3dbc081d871e88d12c3b286ff556612b Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:48:23 +0000 Subject: [PATCH 3/8] Unified: Replace memberAccessParent logic with additional taint steps (similar to original Swift). --- .../codeql/unified/security/SensitiveData.qll | 4 +- .../security/CWE-312/CleartextLogging.ql | 8 ++- .../CleartextLogging.expected | 70 ++++++++++++++++--- .../CleartextLoggingTest.swift | 8 +-- 4 files changed, 71 insertions(+), 19 deletions(-) diff --git a/unified/ql/lib/codeql/unified/security/SensitiveData.qll b/unified/ql/lib/codeql/unified/security/SensitiveData.qll index fbedcddced54..da0a37ef0a13 100644 --- a/unified/ql/lib/codeql/unified/security/SensitiveData.qll +++ b/unified/ql/lib/codeql/unified/security/SensitiveData.qll @@ -36,8 +36,6 @@ private class SensitiveDataIdentifier extends SensitiveData { override SensitiveDataClassification getClassification() { result = classification } } -private Expr memberAccessParent(MemberAccessExpr e) { result = e.getParent() } - /** * A member access that might contain sensitive data. This includes a member itself and * components of a receiver chain, for example: @@ -51,7 +49,7 @@ private class SensitiveDataMemberAccess extends SensitiveData { SensitiveDataClassification classification; SensitiveDataMemberAccess() { - exists(MemberAccessExpr e | memberAccessParent*(e) = this.asExpr() | + exists(MemberAccessExpr e | e = this.asExpr() | HeuristicNames::nameIndicatesSensitiveData(e.getMemberName(), classification) ) } diff --git a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql index ed76734b6b4f..2fb40b77c854 100644 --- a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql +++ b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql @@ -45,8 +45,12 @@ module CleartextLoggingConfig implements DataFlow::ConfigSig { predicate isBarrierIn(DataFlow::Node node) { isSource(node) } - predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) { - none() // TODO: implement additional flow steps as in the original Swift query + predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { + // if `a` is sensitive, then `a.b` is also sensitive. + nodeTo.asExpr().(MemberAccessExpr).getBase() = nodeFrom.asExpr() + or + // if `a` is sensitive, then `a()` is also sensitive. + nodeTo.asExpr().(CallExpr).getCallee() = nodeFrom.asExpr() } } diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected index f80af71bdf6e..452de47b4467 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected @@ -20,17 +20,21 @@ | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:253:8:253:17 | ... .password | written | | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | written | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:256:9:256:9 | v | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:256:9:256:9 | v | written | -| CleartextLoggingTest.swift:258:8:258:26 | ... ! | CleartextLoggingTest.swift:258:8:258:26 | ... ! | CleartextLoggingTest.swift:258:8:258:26 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:258:8:258:26 | ... ! | written | +| CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:26 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:258:8:258:26 | ... ! | written | | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:263:11:263:21 | ... .password | written | | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | written | -| CleartextLoggingTest.swift:265:11:265:22 | ... ! | CleartextLoggingTest.swift:265:11:265:22 | ... ! | CleartextLoggingTest.swift:265:11:265:22 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:265:11:265:22 | ... ! | written | +| CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:22 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:265:11:265:22 | ... ! | written | | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:268:11:268:23 | ... .password | written | | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | written | -| CleartextLoggingTest.swift:288:8:288:24 | ... .value | CleartextLoggingTest.swift:288:8:288:24 | ... .value | CleartextLoggingTest.swift:288:8:288:24 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:288:8:288:24 | ... .value | written | -| CleartextLoggingTest.swift:291:8:291:34 | ... ! | CleartextLoggingTest.swift:291:8:291:34 | ... ! | CleartextLoggingTest.swift:291:8:291:34 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:291:8:291:34 | ... ! | written | -| CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | written | -| CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | written | +| CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:24 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:288:8:288:24 | ... .value | written | +| CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:28 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:289:8:289:28 | ... .value | written | +| CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:33 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:290:8:290:33 | ... .value | written | +| CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:34 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:291:8:291:34 | ... ! | written | +| CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | written | +| CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | written | +| CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | written | +| CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | written | | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:320:8:320:15 | password | written | | CleartextLoggingTest.swift:323:18:323:25 | password | CleartextLoggingTest.swift:323:18:323:25 | password | CleartextLoggingTest.swift:323:8:323:25 | ... + ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:323:8:323:25 | ... + ... | written | | CleartextLoggingTest.swift:341:18:341:25 | password | CleartextLoggingTest.swift:341:18:341:25 | password | CleartextLoggingTest.swift:342:8:342:16 | myString9 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:342:8:342:16 | myString9 | written | @@ -52,19 +56,40 @@ | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:429:28:429:33 | secret | written | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | written | edges -| CleartextLoggingBad.swift:2:35:2:42 | password | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | provenance | | -| CleartextLoggingTest.swift:182:14:182:21 | password | CleartextLoggingTest.swift:182:11:182:23 | StringInterpolationExpr | provenance | | +| CleartextLoggingBad.swift:2:33:2:43 | interpolation(...) | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | provenance | | +| CleartextLoggingBad.swift:2:35:2:42 | password | CleartextLoggingBad.swift:2:33:2:43 | interpolation(...) | provenance | | +| CleartextLoggingTest.swift:182:12:182:22 | interpolation(...) | CleartextLoggingTest.swift:182:11:182:23 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:182:14:182:21 | password | CleartextLoggingTest.swift:182:12:182:22 | interpolation(...) | provenance | | | CleartextLoggingTest.swift:183:28:183:37 | ArrayLiteral [ArrayElement] | CleartextLoggingTest.swift:183:18:183:38 | getVaList(...) | provenance | | | CleartextLoggingTest.swift:183:29:183:36 | password | CleartextLoggingTest.swift:183:28:183:37 | ArrayLiteral [ArrayElement] | provenance | | | CleartextLoggingTest.swift:184:31:184:44 | ArrayLiteral [ArrayElement] | CleartextLoggingTest.swift:184:21:184:45 | getVaList(...) | provenance | | | CleartextLoggingTest.swift:184:36:184:43 | password | CleartextLoggingTest.swift:184:31:184:44 | ArrayLiteral [ArrayElement] | provenance | | -| CleartextLoggingTest.swift:191:16:191:23 | password | CleartextLoggingTest.swift:191:13:191:25 | StringInterpolationExpr | provenance | | -| CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:191:14:191:24 | interpolation(...) | CleartextLoggingTest.swift:191:13:191:25 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:191:16:191:23 | password | CleartextLoggingTest.swift:191:14:191:24 | interpolation(...) | provenance | | +| CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | provenance | | | CleartextLoggingTest.swift:248:6:248:6 | y | CleartextLoggingTest.swift:249:8:249:8 | y | provenance | | | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:6:248:6 | y | provenance | | | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | CleartextLoggingTest.swift:255:9:255:9 | v | provenance | | | CleartextLoggingTest.swift:255:9:255:9 | v | CleartextLoggingTest.swift:256:9:256:9 | v | provenance | | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | provenance | | +| CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:26 | ... ! | provenance | | +| CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:22 | ... ! | provenance | | +| CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:24 | ... .value | provenance | Config | +| CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:28 | ... .value | provenance | Config | +| CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:27 | ... ! | provenance | | +| CleartextLoggingTest.swift:290:8:290:27 | ... ! | CleartextLoggingTest.swift:290:8:290:33 | ... .value | provenance | Config | +| CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:33 | ... .value | provenance | Config | +| CleartextLoggingTest.swift:291:8:291:33 | ... .value | CleartextLoggingTest.swift:291:8:291:34 | ... ! | provenance | | +| CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | provenance | Config | +| CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | provenance | Config | +| CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | provenance | Config | +| CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | provenance | Config | +| CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:27 | ... ! | provenance | | +| CleartextLoggingTest.swift:296:8:296:27 | ... ! | CleartextLoggingTest.swift:296:8:296:36 | ... .getValue | provenance | Config | +| CleartextLoggingTest.swift:296:8:296:36 | ... .getValue | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | provenance | Config | +| CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:36 | ... .getValue | provenance | Config | +| CleartextLoggingTest.swift:297:8:297:36 | ... .getValue | CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | provenance | Config | | CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | provenance | | | CleartextLoggingTest.swift:323:18:323:25 | password | CleartextLoggingTest.swift:323:8:323:25 | ... + ... | provenance | | | CleartextLoggingTest.swift:341:18:341:25 | password | CleartextLoggingTest.swift:342:8:342:16 | myString9 | provenance | | @@ -79,6 +104,7 @@ edges | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:9:411:11 | msg | provenance | | nodes | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingBad.swift:2:33:2:43 | interpolation(...) | semmle.label | interpolation(...) | | CleartextLoggingBad.swift:2:35:2:42 | password | semmle.label | password | | CleartextLoggingTest.swift:167:11:167:18 | password | semmle.label | password | | CleartextLoggingTest.swift:168:11:168:18 | password | semmle.label | password | @@ -90,6 +116,7 @@ nodes | CleartextLoggingTest.swift:180:17:180:24 | password | semmle.label | password | | CleartextLoggingTest.swift:181:24:181:31 | password | semmle.label | password | | CleartextLoggingTest.swift:182:11:182:23 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingTest.swift:182:12:182:22 | interpolation(...) | semmle.label | interpolation(...) | | CleartextLoggingTest.swift:182:14:182:21 | password | semmle.label | password | | CleartextLoggingTest.swift:183:18:183:38 | getVaList(...) | semmle.label | getVaList(...) | | CleartextLoggingTest.swift:183:28:183:37 | ArrayLiteral [ArrayElement] | semmle.label | ArrayLiteral [ArrayElement] | @@ -98,8 +125,10 @@ nodes | CleartextLoggingTest.swift:184:31:184:44 | ArrayLiteral [ArrayElement] | semmle.label | ArrayLiteral [ArrayElement] | | CleartextLoggingTest.swift:184:36:184:43 | password | semmle.label | password | | CleartextLoggingTest.swift:191:13:191:25 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingTest.swift:191:14:191:24 | interpolation(...) | semmle.label | interpolation(...) | | CleartextLoggingTest.swift:191:16:191:23 | password | semmle.label | password | | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | semmle.label | interpolation(...) | | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | semmle.label | bankAccount | | CleartextLoggingTest.swift:220:11:220:20 | passphrase | semmle.label | passphrase | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | semmle.label | pass_phrase | @@ -112,16 +141,37 @@ nodes | CleartextLoggingTest.swift:255:9:255:9 | v | semmle.label | v | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | semmle.label | ... .optionalPassword | | CleartextLoggingTest.swift:256:9:256:9 | v | semmle.label | v | +| CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | semmle.label | ... .optionalPassword | | CleartextLoggingTest.swift:258:8:258:26 | ... ! | semmle.label | ... ! | | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:263:11:263:21 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | +| CleartextLoggingTest.swift:265:11:265:21 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:265:11:265:22 | ... ! | semmle.label | ... ! | | CleartextLoggingTest.swift:268:11:268:23 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | +| CleartextLoggingTest.swift:288:8:288:18 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:288:8:288:24 | ... .value | semmle.label | ... .value | +| CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | semmle.label | ... .passwords(...) | +| CleartextLoggingTest.swift:289:8:289:28 | ... .value | semmle.label | ... .value | +| CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | semmle.label | ... .optionalPassword | +| CleartextLoggingTest.swift:290:8:290:27 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:290:8:290:33 | ... .value | semmle.label | ... .value | +| CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | semmle.label | ... .optionalPassword | +| CleartextLoggingTest.swift:291:8:291:33 | ... .value | semmle.label | ... .value | | CleartextLoggingTest.swift:291:8:291:34 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:294:8:294:18 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | semmle.label | ... .getValue | | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | semmle.label | ... .getValue(...) | +| CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | semmle.label | ... .passwords(...) | +| CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | semmle.label | ... .getValue | +| CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | semmle.label | ... .getValue(...) | +| CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | semmle.label | ... .optionalPassword | +| CleartextLoggingTest.swift:296:8:296:27 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:296:8:296:36 | ... .getValue | semmle.label | ... .getValue | +| CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | semmle.label | ... .getValue(...) | +| CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | semmle.label | ... .optionalPassword | +| CleartextLoggingTest.swift:297:8:297:36 | ... .getValue | semmle.label | ... .getValue | | CleartextLoggingTest.swift:297:8:297:38 | ... .getValue(...) | semmle.label | ... .getValue(...) | | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | semmle.label | ... ?? ... | | CleartextLoggingTest.swift:320:8:320:15 | password | semmle.label | password | diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift index e864a2821f83..b53da1a5d642 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift @@ -286,14 +286,14 @@ func test3(mo : MyOuter) { // struct members... NSLog(mo.password.value) // $ Alert[unified/swift/cleartext-logging] - NSLog(mo.passwords[0].value) // $ MISSING: Alert[unified/swift/cleartext-logging] - NSLog(mo.optionalPassword!.value) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSLog(mo.passwords[0].value) // $ Alert[unified/swift/cleartext-logging] + NSLog(mo.optionalPassword!.value) // $ Alert[unified/swift/cleartext-logging] NSLog(mo.optionalPassword?.value!) // $ Alert[unified/swift/cleartext-logging] NSLog(mo.harmless.value) // safe NSLog(mo.password.getValue()) // $ Alert[unified/swift/cleartext-logging] - NSLog(mo.passwords[0].getValue()) // $ MISSING: Alert[unified/swift/cleartext-logging] - NSLog(mo.optionalPassword!.getValue()) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSLog(mo.passwords[0].getValue()) // $ Alert[unified/swift/cleartext-logging] + NSLog(mo.optionalPassword!.getValue()) // $ Alert[unified/swift/cleartext-logging] NSLog(mo.optionalPassword?.getValue() ?? "") // $ Alert[unified/swift/cleartext-logging] NSLog(mo.harmless.getValue()) // safe } From 25f82eb04dbcee2c7239a9d575c10fa968f49d38 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:23:51 +0000 Subject: [PATCH 4/8] Unified: SensitiveDataCall is redundant now. --- .../codeql/unified/security/SensitiveData.qll | 21 -------------- .../CleartextLogging.expected | 28 ++++++++++++++----- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/unified/ql/lib/codeql/unified/security/SensitiveData.qll b/unified/ql/lib/codeql/unified/security/SensitiveData.qll index da0a37ef0a13..02d9dcaccf00 100644 --- a/unified/ql/lib/codeql/unified/security/SensitiveData.qll +++ b/unified/ql/lib/codeql/unified/security/SensitiveData.qll @@ -56,24 +56,3 @@ private class SensitiveDataMemberAccess extends SensitiveData { override SensitiveDataClassification getClassification() { result = classification } } - -/** - * A function call that might produce sensitive data. - */ -private class SensitiveDataCall extends SensitiveData { - SensitiveDataClassification classification; - - SensitiveDataCall() { - exists(CallExpr call, string name | - call = this.asExpr() and - name = - [ - call.getCallee().(Identifier).getValue(), - call.getCallee().(MemberAccessExpr).getMemberName() - ] and - HeuristicNames::nameIndicatesSensitiveData(name, classification) - ) - } - - override SensitiveDataClassification getClassification() { result = classification } -} diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected index 452de47b4467..02fb90b22da7 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected @@ -16,23 +16,23 @@ | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | written | | CleartextLoggingTest.swift:220:11:220:20 | passphrase | CleartextLoggingTest.swift:220:11:220:20 | passphrase | CleartextLoggingTest.swift:220:11:220:20 | passphrase | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:220:11:220:20 | passphrase | written | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | written | -| CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:249:8:249:8 | y | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:249:8:249:8 | y | written | +| CleartextLoggingTest.swift:248:10:248:20 | getPassword | CleartextLoggingTest.swift:248:10:248:20 | getPassword | CleartextLoggingTest.swift:249:8:249:8 | y | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:249:8:249:8 | y | written | | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:253:8:253:17 | ... .password | written | -| CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | written | +| CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | written | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:256:9:256:9 | v | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:256:9:256:9 | v | written | | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:26 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:258:8:258:26 | ... ! | written | -| CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:263:11:263:21 | ... .password | written | -| CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:22 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:265:11:265:22 | ... ! | written | | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:268:11:268:23 | ... .password | written | -| CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:24 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:288:8:288:24 | ... .value | written | -| CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:28 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:289:8:289:28 | ... .value | written | +| CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | CleartextLoggingTest.swift:289:8:289:28 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:289:8:289:28 | ... .value | written | | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:33 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:290:8:290:33 | ... .value | written | | CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:34 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:291:8:291:34 | ... ! | written | | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | written | -| CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | written | +| CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | written | | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | written | | CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | written | | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:320:8:320:15 | password | written | @@ -69,13 +69,19 @@ edges | CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | provenance | | | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | provenance | | | CleartextLoggingTest.swift:248:6:248:6 | y | CleartextLoggingTest.swift:249:8:249:8 | y | provenance | | +| CleartextLoggingTest.swift:248:10:248:20 | getPassword | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | provenance | Config | | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:6:248:6 | y | provenance | | +| CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | provenance | Config | | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | CleartextLoggingTest.swift:255:9:255:9 | v | provenance | | | CleartextLoggingTest.swift:255:9:255:9 | v | CleartextLoggingTest.swift:256:9:256:9 | v | provenance | | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | provenance | | | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:26 | ... ! | provenance | | +| CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | provenance | Config | +| CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | provenance | Config | | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:22 | ... ! | provenance | | +| CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | provenance | Config | | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:24 | ... .value | provenance | Config | +| CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | provenance | Config | | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:28 | ... .value | provenance | Config | | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:27 | ... ! | provenance | | | CleartextLoggingTest.swift:290:8:290:27 | ... ! | CleartextLoggingTest.swift:290:8:290:33 | ... .value | provenance | Config | @@ -83,6 +89,7 @@ edges | CleartextLoggingTest.swift:291:8:291:33 | ... .value | CleartextLoggingTest.swift:291:8:291:34 | ... ! | provenance | | | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | provenance | Config | | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | provenance | Config | +| CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | provenance | Config | | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | provenance | Config | | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | provenance | Config | | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:27 | ... ! | provenance | | @@ -133,9 +140,11 @@ nodes | CleartextLoggingTest.swift:220:11:220:20 | passphrase | semmle.label | passphrase | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | semmle.label | pass_phrase | | CleartextLoggingTest.swift:248:6:248:6 | y | semmle.label | y | +| CleartextLoggingTest.swift:248:10:248:20 | getPassword | semmle.label | getPassword | | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | semmle.label | getPassword(...) | | CleartextLoggingTest.swift:249:8:249:8 | y | semmle.label | y | | CleartextLoggingTest.swift:253:8:253:17 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | semmle.label | ... .passwords | | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | semmle.label | ... .passwords(...) | | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | semmle.label | ... .some(...) | | CleartextLoggingTest.swift:255:9:255:9 | v | semmle.label | v | @@ -143,15 +152,19 @@ nodes | CleartextLoggingTest.swift:256:9:256:9 | v | semmle.label | v | | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | semmle.label | ... .optionalPassword | | CleartextLoggingTest.swift:258:8:258:26 | ... ! | semmle.label | ... ! | +| CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | semmle.label | ... .getPassword | | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:263:11:263:21 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | semmle.label | ... .getPassword | | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:265:11:265:21 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:265:11:265:22 | ... ! | semmle.label | ... ! | | CleartextLoggingTest.swift:268:11:268:23 | ... .password | semmle.label | ... .password | +| CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | semmle.label | ... .getPassword | | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:288:8:288:18 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:288:8:288:24 | ... .value | semmle.label | ... .value | +| CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | semmle.label | ... .passwords | | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | semmle.label | ... .passwords(...) | | CleartextLoggingTest.swift:289:8:289:28 | ... .value | semmle.label | ... .value | | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | semmle.label | ... .optionalPassword | @@ -163,6 +176,7 @@ nodes | CleartextLoggingTest.swift:294:8:294:18 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | semmle.label | ... .getValue | | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | semmle.label | ... .getValue(...) | +| CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | semmle.label | ... .passwords | | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | semmle.label | ... .passwords(...) | | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | semmle.label | ... .getValue | | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | semmle.label | ... .getValue(...) | From ffe581a452efeca77aee3aaf0262069a83edc861 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:10:11 +0000 Subject: [PATCH 5/8] Unified: Add models-as-data sinks. --- .../security/CWE-312/CleartextLogging.ql | 5 +- .../CleartextLogging.expected | 47 +++++++++++++++++++ .../CleartextLoggingTest.swift | 20 ++++---- 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql index 2fb40b77c854..d947bd71c209 100644 --- a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql +++ b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql @@ -13,9 +13,6 @@ * external/cwe/cwe-532 */ -// -// FIXME: This is a deliberately dumb and noisy version of the query used to exercise data flow early on. -// import unified import codeql.unified.security.SensitiveData @@ -32,6 +29,8 @@ module CleartextLoggingConfig implements DataFlow::ConfigSig { predicate isSource(DataFlow::Node node) { node instanceof SensitiveData } predicate isSink(DataFlow::Node node) { + Models::isSink(node, "log-injection") + or // TODO: implement full sinks as in the original Swift query exists(CallExpr call | getNameFromExpr(call.getCallee()).regexpMatch("(?i)(ns)?(log|warn(ing)?|error|print).*") and diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected index 02fb90b22da7..311280cd296e 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected @@ -41,6 +41,11 @@ | CleartextLoggingTest.swift:345:19:345:26 | password | CleartextLoggingTest.swift:345:19:345:26 | password | CleartextLoggingTest.swift:347:8:347:17 | myString10 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:347:8:347:17 | myString10 | written | | CleartextLoggingTest.swift:352:2:352:9 | password | CleartextLoggingTest.swift:352:2:352:9 | password | CleartextLoggingTest.swift:353:8:353:17 | myString12 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:353:8:353:17 | myString12 | written | | CleartextLoggingTest.swift:355:8:355:15 | password | CleartextLoggingTest.swift:355:8:355:15 | password | CleartextLoggingTest.swift:355:8:355:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:355:8:355:15 | password | written | +| CleartextLoggingTest.swift:381:72:381:85 | passwordString | CleartextLoggingTest.swift:381:72:381:85 | passwordString | CleartextLoggingTest.swift:381:69:381:101 | StringInterpolationExpr | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:381:69:381:101 | StringInterpolationExpr | written | +| CleartextLoggingTest.swift:384:64:384:77 | passwordString | CleartextLoggingTest.swift:384:64:384:77 | passwordString | CleartextLoggingTest.swift:384:61:384:93 | StringInterpolationExpr | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:384:61:384:93 | StringInterpolationExpr | written | +| CleartextLoggingTest.swift:385:103:385:116 | passwordString | CleartextLoggingTest.swift:385:103:385:116 | passwordString | CleartextLoggingTest.swift:385:92:385:118 | getVaList(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:385:92:385:118 | getVaList(...) | written | +| CleartextLoggingTest.swift:392:26:392:39 | passwordString | CleartextLoggingTest.swift:392:26:392:39 | passwordString | CleartextLoggingTest.swift:392:23:392:55 | StringInterpolationExpr | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:392:23:392:55 | StringInterpolationExpr | written | +| CleartextLoggingTest.swift:393:54:393:67 | passwordString | CleartextLoggingTest.swift:393:54:393:67 | passwordString | CleartextLoggingTest.swift:393:43:393:69 | getVaList(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:393:43:393:69 | getVaList(...) | written | | CleartextLoggingTest.swift:399:18:399:24 | authKey | CleartextLoggingTest.swift:399:18:399:24 | authKey | CleartextLoggingTest.swift:399:18:399:24 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:399:18:399:24 | authKey | written | | CleartextLoggingTest.swift:400:25:400:32 | authKey2 | CleartextLoggingTest.swift:400:25:400:32 | authKey2 | CleartextLoggingTest.swift:400:18:400:33 | String(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:400:18:400:33 | String(...) | written | | CleartextLoggingTest.swift:401:22:401:28 | authKey | CleartextLoggingTest.swift:401:22:401:28 | authKey | CleartextLoggingTest.swift:401:22:401:28 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:401:22:401:28 | authKey | written | @@ -50,8 +55,13 @@ | CleartextLoggingTest.swift:405:24:405:30 | authKey | CleartextLoggingTest.swift:405:24:405:30 | authKey | CleartextLoggingTest.swift:405:24:405:30 | authKey | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:405:24:405:30 | authKey | written | | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:407:19:407:26 | authKey3 | written | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:412:16:412:18 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:412:16:412:18 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:413:18:413:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:413:18:413:20 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:414:18:414:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:414:18:414:20 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:415:17:415:37 | NSString(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:415:17:415:37 | NSString(...) | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:416:19:416:21 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:416:19:416:21 | msg | written | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:417:20:417:22 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:417:20:417:22 | msg | written | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:418:18:418:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:418:18:418:20 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:419:21:419:23 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:419:21:419:23 | msg | written | | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:428:29:428:36 | password | written | | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:429:28:429:33 | secret | written | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | written | @@ -103,12 +113,28 @@ edges | CleartextLoggingTest.swift:345:19:345:26 | password | CleartextLoggingTest.swift:347:8:347:17 | myString10 | provenance | | | CleartextLoggingTest.swift:352:2:352:9 | password | CleartextLoggingTest.swift:352:21:352:31 | [post] & ... | provenance | | | CleartextLoggingTest.swift:352:21:352:31 | [post] & ... | CleartextLoggingTest.swift:353:8:353:17 | myString12 | provenance | | +| CleartextLoggingTest.swift:381:70:381:86 | interpolation(...) | CleartextLoggingTest.swift:381:69:381:101 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:381:72:381:85 | passwordString | CleartextLoggingTest.swift:381:70:381:86 | interpolation(...) | provenance | | +| CleartextLoggingTest.swift:384:62:384:78 | interpolation(...) | CleartextLoggingTest.swift:384:61:384:93 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:384:64:384:77 | passwordString | CleartextLoggingTest.swift:384:62:384:78 | interpolation(...) | provenance | | +| CleartextLoggingTest.swift:385:102:385:117 | ArrayLiteral [ArrayElement] | CleartextLoggingTest.swift:385:92:385:118 | getVaList(...) | provenance | | +| CleartextLoggingTest.swift:385:103:385:116 | passwordString | CleartextLoggingTest.swift:385:102:385:117 | ArrayLiteral [ArrayElement] | provenance | | +| CleartextLoggingTest.swift:392:24:392:40 | interpolation(...) | CleartextLoggingTest.swift:392:23:392:55 | StringInterpolationExpr | provenance | | +| CleartextLoggingTest.swift:392:26:392:39 | passwordString | CleartextLoggingTest.swift:392:24:392:40 | interpolation(...) | provenance | | +| CleartextLoggingTest.swift:393:53:393:68 | ArrayLiteral [ArrayElement] | CleartextLoggingTest.swift:393:43:393:69 | getVaList(...) | provenance | | +| CleartextLoggingTest.swift:393:54:393:67 | passwordString | CleartextLoggingTest.swift:393:53:393:68 | ArrayLiteral [ArrayElement] | provenance | | | CleartextLoggingTest.swift:400:25:400:32 | authKey2 | CleartextLoggingTest.swift:400:18:400:33 | String(...) | provenance | | | CleartextLoggingTest.swift:403:33:403:39 | authKey | CleartextLoggingTest.swift:403:16:403:40 | NSString(...) | provenance | | | CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:412:16:412:18 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:413:18:413:20 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:414:18:414:20 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:415:34:415:36 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:416:19:416:21 | msg | provenance | | | CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:417:20:417:22 | msg | provenance | | | CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:418:18:418:20 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:419:21:419:23 | msg | provenance | | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:9:411:11 | msg | provenance | | +| CleartextLoggingTest.swift:415:34:415:36 | msg | CleartextLoggingTest.swift:415:17:415:37 | NSString(...) | provenance | | nodes | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | | CleartextLoggingBad.swift:2:33:2:43 | interpolation(...) | semmle.label | interpolation(...) | @@ -199,6 +225,21 @@ nodes | CleartextLoggingTest.swift:352:21:352:31 | [post] & ... | semmle.label | [post] & ... | | CleartextLoggingTest.swift:353:8:353:17 | myString12 | semmle.label | myString12 | | CleartextLoggingTest.swift:355:8:355:15 | password | semmle.label | password | +| CleartextLoggingTest.swift:381:69:381:101 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingTest.swift:381:70:381:86 | interpolation(...) | semmle.label | interpolation(...) | +| CleartextLoggingTest.swift:381:72:381:85 | passwordString | semmle.label | passwordString | +| CleartextLoggingTest.swift:384:61:384:93 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingTest.swift:384:62:384:78 | interpolation(...) | semmle.label | interpolation(...) | +| CleartextLoggingTest.swift:384:64:384:77 | passwordString | semmle.label | passwordString | +| CleartextLoggingTest.swift:385:92:385:118 | getVaList(...) | semmle.label | getVaList(...) | +| CleartextLoggingTest.swift:385:102:385:117 | ArrayLiteral [ArrayElement] | semmle.label | ArrayLiteral [ArrayElement] | +| CleartextLoggingTest.swift:385:103:385:116 | passwordString | semmle.label | passwordString | +| CleartextLoggingTest.swift:392:23:392:55 | StringInterpolationExpr | semmle.label | StringInterpolationExpr | +| CleartextLoggingTest.swift:392:24:392:40 | interpolation(...) | semmle.label | interpolation(...) | +| CleartextLoggingTest.swift:392:26:392:39 | passwordString | semmle.label | passwordString | +| CleartextLoggingTest.swift:393:43:393:69 | getVaList(...) | semmle.label | getVaList(...) | +| CleartextLoggingTest.swift:393:53:393:68 | ArrayLiteral [ArrayElement] | semmle.label | ArrayLiteral [ArrayElement] | +| CleartextLoggingTest.swift:393:54:393:67 | passwordString | semmle.label | passwordString | | CleartextLoggingTest.swift:399:18:399:24 | authKey | semmle.label | authKey | | CleartextLoggingTest.swift:400:18:400:33 | String(...) | semmle.label | String(...) | | CleartextLoggingTest.swift:400:25:400:32 | authKey2 | semmle.label | authKey2 | @@ -212,8 +253,14 @@ nodes | CleartextLoggingTest.swift:411:9:411:11 | msg | semmle.label | msg | | CleartextLoggingTest.swift:411:29:411:35 | authKey | semmle.label | authKey | | CleartextLoggingTest.swift:412:16:412:18 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:413:18:413:20 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:414:18:414:20 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:415:17:415:37 | NSString(...) | semmle.label | NSString(...) | +| CleartextLoggingTest.swift:415:34:415:36 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:416:19:416:21 | msg | semmle.label | msg | | CleartextLoggingTest.swift:417:20:417:22 | msg | semmle.label | msg | | CleartextLoggingTest.swift:418:18:418:20 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:419:21:419:23 | msg | semmle.label | msg | | CleartextLoggingTest.swift:428:29:428:36 | password | semmle.label | password | | CleartextLoggingTest.swift:429:28:429:33 | secret | semmle.label | secret | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | semmle.label | globalPassword | diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift index b53da1a5d642..7473b3eb973d 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift @@ -378,19 +378,19 @@ func test5(password: String, caseNum: Int) { } func test6(passwordString: String) { - let e = NSException(name: NSExceptionName("exception"), reason: "\(passwordString) is incorrect!", userInfo: nil) // $ MISSING: Alert[unified/swift/cleartext-logging] + let e = NSException(name: NSExceptionName("exception"), reason: "\(passwordString) is incorrect!", userInfo: nil) // $ Alert[unified/swift/cleartext-logging] e.raise() - NSException.raise(NSExceptionName("exception"), format: "\(passwordString) is incorrect!", arguments: getVaList([])) // $ MISSING: Alert[unified/swift/cleartext-logging] - NSException.raise(NSExceptionName("exception"), format: "%s is incorrect!", arguments: getVaList([passwordString])) // $ MISSING: Alert[unified/swift/cleartext-logging] + NSException.raise(NSExceptionName("exception"), format: "\(passwordString) is incorrect!", arguments: getVaList([])) // $ Alert[unified/swift/cleartext-logging] + NSException.raise(NSExceptionName("exception"), format: "%s is incorrect!", arguments: getVaList([passwordString])) // $ Alert[unified/swift/cleartext-logging] _ = dprintf(0, "\(passwordString) is incorrect!") // $ MISSING: Alert[unified/swift/cleartext-logging] _ = dprintf(0, "%s is incorrect!", passwordString) // $ MISSING: Alert[unified/swift/cleartext-logging] _ = dprintf(0, "%s: %s is incorrect!", "foo", passwordString) // $ MISSING: Alert[unified/swift/cleartext-logging] _ = vprintf("\(passwordString) is incorrect!", getVaList([])) // $ MISSING: Alert[unified/swift/cleartext-logging] _ = vprintf("%s is incorrect!", getVaList([passwordString])) // $ MISSING: Alert[unified/swift/cleartext-logging] - _ = vfprintf(nil, "\(passwordString) is incorrect!", getVaList([])) // $ MISSING: Alert[unified/swift/cleartext-logging] - _ = vfprintf(nil, "%s is incorrect!", getVaList([passwordString])) // $ MISSING: Alert[unified/swift/cleartext-logging] + _ = vfprintf(nil, "\(passwordString) is incorrect!", getVaList([])) // $ Alert[unified/swift/cleartext-logging] + _ = vfprintf(nil, "%s is incorrect!", getVaList([passwordString])) // $ Alert[unified/swift/cleartext-logging] _ = vasprintf_l(nil, nil, "\(passwordString) is incorrect!", getVaList([])) // good (`sprintf` is not logging) _ = vasprintf_l(nil, nil, "%s is incorrect!", getVaList([passwordString])) // good (`sprintf` is not logging) } @@ -410,13 +410,13 @@ func test7(authKey: String, authKey2: Int, authKey3: Float, password: String, se let logger = LogFile() let msg = "authKey: " + authKey // $ Alert[unified/swift/cleartext-logging] logger.log(msg) // $ Sink[unified/swift/cleartext-logging] - logger.trace(msg) // $ MISSING: Sink[unified/swift/cleartext-logging] - logger.debug(msg) // $ MISSING: Sink[unified/swift/cleartext-logging] - logger.info(NSString(string: msg)) // $ MISSING: Sink[unified/swift/cleartext-logging] - logger.notice(msg) // $ MISSING: Sink[unified/swift/cleartext-logging] + logger.trace(msg) // $ Sink[unified/swift/cleartext-logging] + logger.debug(msg) // $ Sink[unified/swift/cleartext-logging] + logger.info(NSString(string: msg)) // $ Sink[unified/swift/cleartext-logging] + logger.notice(msg) // $ Sink[unified/swift/cleartext-logging] logger.warning(msg) // $ Sink[unified/swift/cleartext-logging] logger.error(msg) // $ Sink[unified/swift/cleartext-logging] - logger.critical(msg) // $ MISSING: Sink[unified/swift/cleartext-logging] + logger.critical(msg) // $ Sink[unified/swift/cleartext-logging] logger.fatal(msg) // $ MISSING: Sink[unified/swift/cleartext-logging] let logic = Logic() From 4210d8667b82939ddaaf8eb459a537d0ab49790c Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:23:54 +0000 Subject: [PATCH 6/8] Unified: Add heuristic sinks (ported from original Swift). --- .../security/CWE-312/CleartextLogging.ql | 31 ++++++++++++++++++- .../CleartextLogging.expected | 3 ++ .../CleartextLoggingTest.swift | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql index d947bd71c209..73c2660c5d61 100644 --- a/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql +++ b/unified/ql/src/queries/security/CWE-312/CleartextLogging.ql @@ -15,6 +15,7 @@ import unified import codeql.unified.security.SensitiveData +import codeql.unified.internal.typeinference.TypeInference as TypeInference private string getNameFromExpr(Expr e) { result = e.(IdentifierExpr).getValue() @@ -22,6 +23,31 @@ private string getNameFromExpr(Expr e) { result = e.(MemberAccessExpr).getMemberName() } +/** + * Holds if `label` looks like the name of a logging function. + */ +bindingset[label] +private predicate logLikeHeuristic(string label) { + label.regexpMatch("(l|.*L)og([A-Z0-9].*)?") // e.g. "logMessage", "debugLog" +} + +predicate heuristicSink(DataFlow::Node node) { + exists(CallExpr call, FunctionDeclaration f, Expr e | + f = TypeInference::resolveCallTarget(call) and + ( + logLikeHeuristic(f.getName()) + or + exists(ClassLikeDeclaration type | + f = type.getAMemberIncludingExtensions() and + logLikeHeuristic(type.getName()) + ) + ) and + e = call.getAnArgument().getValue() and + TypeInference::inferType(e).asClass().getName() = ["String", "NSString"] and + node.asExpr() = e + ) +} + /** * A taint-tracking configuration for cleartext logging vulnerabilities. */ @@ -31,7 +57,10 @@ module CleartextLoggingConfig implements DataFlow::ConfigSig { predicate isSink(DataFlow::Node node) { Models::isSink(node, "log-injection") or - // TODO: implement full sinks as in the original Swift query + heuristicSink(node) + or + // TODO: port StringFormat.qll and use it, as in `PrintfCleartextLoggingSink` in the original Swift query + // TODO: then we shouldn't need this: exists(CallExpr call | getNameFromExpr(call.getCallee()).regexpMatch("(?i)(ns)?(log|warn(ing)?|error|print).*") and node.asExpr() = call.getAnArgument().getValue() diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected index 311280cd296e..83e22cd337d7 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected @@ -62,6 +62,7 @@ | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:417:20:417:22 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:417:20:417:22 | msg | written | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:418:18:418:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:418:18:418:20 | msg | written | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:419:21:419:23 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:419:21:419:23 | msg | written | +| CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:420:18:420:20 | msg | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:420:18:420:20 | msg | written | | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:428:29:428:36 | password | written | | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:429:28:429:33 | secret | written | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | written | @@ -133,6 +134,7 @@ edges | CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:417:20:417:22 | msg | provenance | | | CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:418:18:418:20 | msg | provenance | | | CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:419:21:419:23 | msg | provenance | | +| CleartextLoggingTest.swift:411:9:411:11 | msg | CleartextLoggingTest.swift:420:18:420:20 | msg | provenance | | | CleartextLoggingTest.swift:411:29:411:35 | authKey | CleartextLoggingTest.swift:411:9:411:11 | msg | provenance | | | CleartextLoggingTest.swift:415:34:415:36 | msg | CleartextLoggingTest.swift:415:17:415:37 | NSString(...) | provenance | | nodes @@ -261,6 +263,7 @@ nodes | CleartextLoggingTest.swift:417:20:417:22 | msg | semmle.label | msg | | CleartextLoggingTest.swift:418:18:418:20 | msg | semmle.label | msg | | CleartextLoggingTest.swift:419:21:419:23 | msg | semmle.label | msg | +| CleartextLoggingTest.swift:420:18:420:20 | msg | semmle.label | msg | | CleartextLoggingTest.swift:428:29:428:36 | password | semmle.label | password | | CleartextLoggingTest.swift:429:28:429:33 | secret | semmle.label | secret | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | semmle.label | globalPassword | diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift index 7473b3eb973d..a75dceeffad5 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift @@ -417,7 +417,7 @@ func test7(authKey: String, authKey2: Int, authKey3: Float, password: String, se logger.warning(msg) // $ Sink[unified/swift/cleartext-logging] logger.error(msg) // $ Sink[unified/swift/cleartext-logging] logger.critical(msg) // $ Sink[unified/swift/cleartext-logging] - logger.fatal(msg) // $ MISSING: Sink[unified/swift/cleartext-logging] + logger.fatal(msg) // $ Sink[unified/swift/cleartext-logging] let logic = Logic() logic.addInt(authKey2) // GOOD: not logging From cad278e11a911191a8a280be98b002453c92ea5c Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:50:35 +0000 Subject: [PATCH 7/8] Unified: Add Copilot suggested test case. --- .../CWE-312/CleartextLogging/CleartextLoggingTest.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift index a75dceeffad5..c1c550f0c210 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift @@ -460,3 +460,11 @@ func testEnums(p: Password, i: Info) { print(contents) // safe } } + +struct Secret { + let value: String +} + +func testStructConstructor() { + print(Secret(value: "abc")) // $ MISSING: Alert[unified/swift/cleartext-logging] +} From a58449f7f7730abad40237d08cff4b877c4939ec Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:52:19 +0000 Subject: [PATCH 8/8] Unified: Replace SensitiveDataCall. --- .../codeql/unified/security/SensitiveData.qll | 21 +++++++++++++ .../CleartextLogging.expected | 30 ++++++------------- .../CleartextLoggingTest.swift | 2 +- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/unified/ql/lib/codeql/unified/security/SensitiveData.qll b/unified/ql/lib/codeql/unified/security/SensitiveData.qll index 02d9dcaccf00..da0a37ef0a13 100644 --- a/unified/ql/lib/codeql/unified/security/SensitiveData.qll +++ b/unified/ql/lib/codeql/unified/security/SensitiveData.qll @@ -56,3 +56,24 @@ private class SensitiveDataMemberAccess extends SensitiveData { override SensitiveDataClassification getClassification() { result = classification } } + +/** + * A function call that might produce sensitive data. + */ +private class SensitiveDataCall extends SensitiveData { + SensitiveDataClassification classification; + + SensitiveDataCall() { + exists(CallExpr call, string name | + call = this.asExpr() and + name = + [ + call.getCallee().(Identifier).getValue(), + call.getCallee().(MemberAccessExpr).getMemberName() + ] and + HeuristicNames::nameIndicatesSensitiveData(name, classification) + ) + } + + override SensitiveDataClassification getClassification() { result = classification } +} diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected index 83e22cd337d7..10e0424d8aeb 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLogging.expected @@ -16,23 +16,23 @@ | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | written | | CleartextLoggingTest.swift:220:11:220:20 | passphrase | CleartextLoggingTest.swift:220:11:220:20 | passphrase | CleartextLoggingTest.swift:220:11:220:20 | passphrase | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:220:11:220:20 | passphrase | written | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | written | -| CleartextLoggingTest.swift:248:10:248:20 | getPassword | CleartextLoggingTest.swift:248:10:248:20 | getPassword | CleartextLoggingTest.swift:249:8:249:8 | y | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:249:8:249:8 | y | written | +| CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:249:8:249:8 | y | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:249:8:249:8 | y | written | | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | CleartextLoggingTest.swift:253:8:253:17 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:253:8:253:17 | ... .password | written | -| CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | written | +| CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | written | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:256:9:256:9 | v | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:256:9:256:9 | v | written | | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:26 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:258:8:258:26 | ... ! | written | -| CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | CleartextLoggingTest.swift:263:11:263:21 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:263:11:263:21 | ... .password | written | -| CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:22 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:265:11:265:22 | ... ! | written | | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | CleartextLoggingTest.swift:268:11:268:23 | ... .password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:268:11:268:23 | ... .password | written | -| CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | written | +| CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | written | | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:24 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:288:8:288:24 | ... .value | written | -| CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | CleartextLoggingTest.swift:289:8:289:28 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:289:8:289:28 | ... .value | written | +| CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:28 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:289:8:289:28 | ... .value | written | | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:33 | ... .value | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:290:8:290:33 | ... .value | written | | CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:26 | ... .optionalPassword | CleartextLoggingTest.swift:291:8:291:34 | ... ! | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:291:8:291:34 | ... ! | written | | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | written | -| CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | written | +| CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | written | | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:296:8:296:38 | ... .getValue(...) | written | | CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:26 | ... .optionalPassword | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:297:8:297:44 | ... ?? ... | written | | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | CleartextLoggingTest.swift:320:8:320:15 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:320:8:320:15 | password | written | @@ -66,6 +66,7 @@ | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | CleartextLoggingTest.swift:428:29:428:36 | password | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:428:29:428:36 | password | written | | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | CleartextLoggingTest.swift:429:28:429:33 | secret | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:429:28:429:33 | secret | written | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | written | +| CleartextLoggingTest.swift:469:11:469:30 | Secret(...) | CleartextLoggingTest.swift:469:11:469:30 | Secret(...) | CleartextLoggingTest.swift:469:11:469:30 | Secret(...) | This sensitive information is to $@ to a log file. | CleartextLoggingTest.swift:469:11:469:30 | Secret(...) | written | edges | CleartextLoggingBad.swift:2:33:2:43 | interpolation(...) | CleartextLoggingBad.swift:2:7:2:44 | StringInterpolationExpr | provenance | | | CleartextLoggingBad.swift:2:35:2:42 | password | CleartextLoggingBad.swift:2:33:2:43 | interpolation(...) | provenance | | @@ -80,19 +81,13 @@ edges | CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | CleartextLoggingTest.swift:197:13:197:28 | StringInterpolationExpr | provenance | | | CleartextLoggingTest.swift:197:16:197:26 | bankAccount | CleartextLoggingTest.swift:197:14:197:27 | interpolation(...) | provenance | | | CleartextLoggingTest.swift:248:6:248:6 | y | CleartextLoggingTest.swift:249:8:249:8 | y | provenance | | -| CleartextLoggingTest.swift:248:10:248:20 | getPassword | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | provenance | Config | | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | CleartextLoggingTest.swift:248:6:248:6 | y | provenance | | -| CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | provenance | Config | | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | CleartextLoggingTest.swift:255:9:255:9 | v | provenance | | | CleartextLoggingTest.swift:255:9:255:9 | v | CleartextLoggingTest.swift:256:9:256:9 | v | provenance | | | CleartextLoggingTest.swift:255:13:255:30 | ... .optionalPassword | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | provenance | | | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | CleartextLoggingTest.swift:258:8:258:26 | ... ! | provenance | | -| CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | provenance | Config | -| CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | provenance | Config | | CleartextLoggingTest.swift:265:11:265:21 | ... .password | CleartextLoggingTest.swift:265:11:265:22 | ... ! | provenance | | -| CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | provenance | Config | | CleartextLoggingTest.swift:288:8:288:18 | ... .password | CleartextLoggingTest.swift:288:8:288:24 | ... .value | provenance | Config | -| CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | provenance | Config | | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | CleartextLoggingTest.swift:289:8:289:28 | ... .value | provenance | Config | | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | CleartextLoggingTest.swift:290:8:290:27 | ... ! | provenance | | | CleartextLoggingTest.swift:290:8:290:27 | ... ! | CleartextLoggingTest.swift:290:8:290:33 | ... .value | provenance | Config | @@ -100,7 +95,6 @@ edges | CleartextLoggingTest.swift:291:8:291:33 | ... .value | CleartextLoggingTest.swift:291:8:291:34 | ... ! | provenance | | | CleartextLoggingTest.swift:294:8:294:18 | ... .password | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | provenance | Config | | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | provenance | Config | -| CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | provenance | Config | | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | provenance | Config | | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | provenance | Config | | CleartextLoggingTest.swift:296:8:296:26 | ... .optionalPassword | CleartextLoggingTest.swift:296:8:296:27 | ... ! | provenance | | @@ -168,11 +162,9 @@ nodes | CleartextLoggingTest.swift:220:11:220:20 | passphrase | semmle.label | passphrase | | CleartextLoggingTest.swift:221:11:221:21 | pass_phrase | semmle.label | pass_phrase | | CleartextLoggingTest.swift:248:6:248:6 | y | semmle.label | y | -| CleartextLoggingTest.swift:248:10:248:20 | getPassword | semmle.label | getPassword | | CleartextLoggingTest.swift:248:10:248:22 | getPassword(...) | semmle.label | getPassword(...) | | CleartextLoggingTest.swift:249:8:249:8 | y | semmle.label | y | | CleartextLoggingTest.swift:253:8:253:17 | ... .password | semmle.label | ... .password | -| CleartextLoggingTest.swift:254:8:254:18 | ... .passwords | semmle.label | ... .passwords | | CleartextLoggingTest.swift:254:8:254:21 | ... .passwords(...) | semmle.label | ... .passwords(...) | | CleartextLoggingTest.swift:255:5:255:9 | ... .some(...) | semmle.label | ... .some(...) | | CleartextLoggingTest.swift:255:9:255:9 | v | semmle.label | v | @@ -180,19 +172,15 @@ nodes | CleartextLoggingTest.swift:256:9:256:9 | v | semmle.label | v | | CleartextLoggingTest.swift:258:8:258:25 | ... .optionalPassword | semmle.label | ... .optionalPassword | | CleartextLoggingTest.swift:258:8:258:26 | ... ! | semmle.label | ... ! | -| CleartextLoggingTest.swift:260:8:260:20 | ... .getPassword | semmle.label | ... .getPassword | | CleartextLoggingTest.swift:260:8:260:22 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:263:11:263:21 | ... .password | semmle.label | ... .password | -| CleartextLoggingTest.swift:264:11:264:24 | ... .getPassword | semmle.label | ... .getPassword | | CleartextLoggingTest.swift:264:11:264:26 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:265:11:265:21 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:265:11:265:22 | ... ! | semmle.label | ... ! | | CleartextLoggingTest.swift:268:11:268:23 | ... .password | semmle.label | ... .password | -| CleartextLoggingTest.swift:269:11:269:26 | ... .getPassword | semmle.label | ... .getPassword | | CleartextLoggingTest.swift:269:11:269:28 | ... .getPassword(...) | semmle.label | ... .getPassword(...) | | CleartextLoggingTest.swift:288:8:288:18 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:288:8:288:24 | ... .value | semmle.label | ... .value | -| CleartextLoggingTest.swift:289:8:289:19 | ... .passwords | semmle.label | ... .passwords | | CleartextLoggingTest.swift:289:8:289:22 | ... .passwords(...) | semmle.label | ... .passwords(...) | | CleartextLoggingTest.swift:289:8:289:28 | ... .value | semmle.label | ... .value | | CleartextLoggingTest.swift:290:8:290:26 | ... .optionalPassword | semmle.label | ... .optionalPassword | @@ -204,7 +192,6 @@ nodes | CleartextLoggingTest.swift:294:8:294:18 | ... .password | semmle.label | ... .password | | CleartextLoggingTest.swift:294:8:294:27 | ... .getValue | semmle.label | ... .getValue | | CleartextLoggingTest.swift:294:8:294:29 | ... .getValue(...) | semmle.label | ... .getValue(...) | -| CleartextLoggingTest.swift:295:8:295:19 | ... .passwords | semmle.label | ... .passwords | | CleartextLoggingTest.swift:295:8:295:22 | ... .passwords(...) | semmle.label | ... .passwords(...) | | CleartextLoggingTest.swift:295:8:295:31 | ... .getValue | semmle.label | ... .getValue | | CleartextLoggingTest.swift:295:8:295:33 | ... .getValue(...) | semmle.label | ... .getValue(...) | @@ -267,4 +254,5 @@ nodes | CleartextLoggingTest.swift:428:29:428:36 | password | semmle.label | password | | CleartextLoggingTest.swift:429:28:429:33 | secret | semmle.label | secret | | CleartextLoggingTest.swift:437:11:437:24 | globalPassword | semmle.label | globalPassword | +| CleartextLoggingTest.swift:469:11:469:30 | Secret(...) | semmle.label | Secret(...) | subpaths diff --git a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift index c1c550f0c210..957f45b84920 100644 --- a/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift +++ b/unified/ql/test/query-tests/security/CWE-312/CleartextLogging/CleartextLoggingTest.swift @@ -466,5 +466,5 @@ struct Secret { } func testStructConstructor() { - print(Secret(value: "abc")) // $ MISSING: Alert[unified/swift/cleartext-logging] + print(Secret(value: "abc")) // $ Alert[unified/swift/cleartext-logging] }