@@ -543,68 +543,90 @@ private module Spanner {
543543 API:: Node database ( ) {
544544 result =
545545 spanner ( ) .getReturn ( ) .getMember ( "instance" ) .getReturn ( ) .getMember ( "database" ) .getReturn ( )
546+ or
547+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "Database" )
546548 }
547549
548550 /**
549551 * Gets a node that refers to an instance of the `v1.SpannerClient` class.
550552 */
551553 API:: Node v1SpannerClient ( ) {
552554 result = spanner ( ) .getMember ( "v1" ) .getMember ( "SpannerClient" ) .getInstance ( )
555+ or
556+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "v1.SpannerClient" )
553557 }
554558
555559 /**
556560 * Gets a node that refers to a transaction object.
557561 */
558562 API:: Node transaction ( ) {
559- result = database ( ) .getMember ( "runTransaction" ) .getParameter ( 0 ) .getParameter ( 1 )
563+ result =
564+ database ( )
565+ .getMember ( [ "runTransaction" , "runTransactionAsync" ] )
566+ .getParameter ( [ 0 , 1 ] )
567+ .getParameter ( 1 )
568+ or
569+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "Transaction" )
570+ }
571+
572+ /** Gets an API node referring to a `BatchTransaction` object. */
573+ API:: Node batchTransaction ( ) {
574+ result = database ( ) .getMember ( "batchTransaction" ) .getReturn ( )
575+ or
576+ result = database ( ) .getMember ( "createBatchTransaction" ) .getReturn ( ) .getPromised ( )
577+ or
578+ result = API:: Node:: ofType ( "@google-cloud/spanner" , "BatchTransaction" )
560579 }
561580
562581 /**
563582 * A call to a Spanner method that executes a SQL query.
564583 */
565- abstract class SqlExecution extends DatabaseAccess , DataFlow:: InvokeNode {
566- /**
567- * Gets the position of the query argument; default is zero, which can be overridden
568- * by subclasses.
569- */
570- int getQueryArgumentPosition ( ) { result = 0 }
571-
572- override DataFlow:: Node getAQueryArgument ( ) {
573- result = getArgument ( getQueryArgumentPosition ( ) ) or
574- result = getOptionArgument ( getQueryArgumentPosition ( ) , "sql" )
575- }
576- }
584+ abstract class SqlExecution extends DatabaseAccess , DataFlow:: InvokeNode { }
577585
578586 /**
579- * A call to `Database.run`, `Database.runPartitionedUpdate` or `Database.runStream` .
587+ * A SQL execution that takes the input directly in the first argument or in the `sql` option .
580588 */
581- class DatabaseRunCall extends SqlExecution {
582- DatabaseRunCall ( ) {
589+ class SqlExecutionDirect extends SqlExecution {
590+ SqlExecutionDirect ( ) {
583591 this = database ( ) .getMember ( [ "run" , "runPartitionedUpdate" , "runStream" ] ) .getACall ( )
592+ or
593+ this = transaction ( ) .getMember ( [ "run" , "runStream" , "runUpdate" ] ) .getACall ( )
594+ or
595+ this = batchTransaction ( ) .getMember ( "createQueryPartitions" ) .getACall ( )
596+ }
597+
598+ override DataFlow:: Node getAQueryArgument ( ) {
599+ result = getArgument ( 0 )
600+ or
601+ result = getOptionArgument ( 0 , "sql" )
584602 }
585603 }
586604
587605 /**
588- * A call to `Transaction.run`, `Transaction.runStream` or `Transaction.runUpdate` .
606+ * A SQL execution that takes an array of SQL strings or { sql: string } objects .
589607 */
590- class TransactionRunCall extends SqlExecution {
591- TransactionRunCall ( ) {
592- this = transaction ( ) .getMember ( [ "run" , "runStream" , "runUpdate" ] ) .getACall ( )
608+ class SqlExecutionBatch extends SqlExecution , API:: CallNode {
609+ SqlExecutionBatch ( ) { this = transaction ( ) .getMember ( "batchUpdate" ) .getACall ( ) }
610+
611+ override DataFlow:: Node getAQueryArgument ( ) {
612+ // just use the whole array as the query argument, as arrays becomes tainted if one of the elements
613+ // are tainted
614+ result = getArgument ( 0 )
615+ or
616+ result = getParameter ( 0 ) .getUnknownMember ( ) .getMember ( "sql" ) .getARhs ( )
593617 }
594618 }
595619
596620 /**
597- * A call to `v1.SpannerClient.executeSql` or `v1.SpannerClient.executeStreamingSql`.
621+ * A SQL execution that only takes the input in the `sql` option, and do not accept query strings
622+ * directly.
598623 */
599- class ExecuteSqlCall extends SqlExecution {
600- ExecuteSqlCall ( ) {
624+ class SqlExecutionWithOption extends SqlExecution {
625+ SqlExecutionWithOption ( ) {
601626 this = v1SpannerClient ( ) .getMember ( [ "executeSql" , "executeStreamingSql" ] ) .getACall ( )
602627 }
603628
604- override DataFlow:: Node getAQueryArgument ( ) {
605- // `executeSql` and `executeStreamingSql` do not accept query strings directly
606- result = getOptionArgument ( 0 , "sql" )
607- }
629+ override DataFlow:: Node getAQueryArgument ( ) { result = getOptionArgument ( 0 , "sql" ) }
608630 }
609631
610632 /**
0 commit comments