File tree Expand file tree Collapse file tree 4 files changed +14
-7
lines changed
javascript/frameworks/cap
lib/advanced_security/javascript/frameworks/cap Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,13 @@ class CqlShortcutMethodCallWithStringConcat instanceof CqlShortcutMethodCall {
4141}
4242
4343/**
44- * A CQL parser call (cds.ql, cds.parse.cql, ...) parameterized with a string
44+ * A CQL parser call (` cds.ql`, ` cds.parse.cql` , ...) parameterized with a string
4545 * conatenation expression.
4646 */
4747class CqlClauseParserCallWithStringConcat instanceof CqlClauseParserCall {
4848 CqlClauseParserCallWithStringConcat ( ) {
49- exists ( StringConcatenation:: getAnOperand ( super .getCdlString ( ) ) )
49+ not this .getCdlString ( ) .( StringOps:: Concatenation ) .asExpr ( ) instanceof TemplateLiteral and
50+ exists ( StringConcatenation:: getAnOperand ( this .getCdlString ( ) ) )
5051 }
5152
5253 Location getLocation ( ) { result = super .getLocation ( ) }
Original file line number Diff line number Diff line change @@ -942,11 +942,17 @@ class CqlUpsertMethodCall extends CqlShortcutMethodCall {
942942abstract class CqlClauseParserCall extends DataFlow:: CallNode {
943943 DataFlow:: ExprNode cdlString ;
944944
945+ /**
946+ * Gets the data flow node that represents the CDL string to be parsed.
947+ */
945948 DataFlow:: ExprNode getCdlString ( ) { result = cdlString }
946949}
947950
948951class GlobalCQLFunction extends CqlClauseParserCall {
949- GlobalCQLFunction ( ) { this = DataFlow:: globalVarRef ( "CQL" ) .getACall ( ) }
952+ GlobalCQLFunction ( ) {
953+ this = DataFlow:: globalVarRef ( "CQL" ) .getACall ( ) and
954+ cdlString = this .getArgument ( 0 )
955+ }
950956}
951957
952958class CdsParseCqlCall extends CqlClauseParserCall {
Original file line number Diff line number Diff line change 11import javascript
2- import advanced_security.javascript.frameworks.cap.CQL
2+ import advanced_security.javascript.frameworks.cap.CAPCqlInjectionQuery
33
4- from ParseCQLTaintedClause clause
4+ from CqlClauseParserCallWithStringConcat clause
55select clause
Original file line number Diff line number Diff line change @@ -167,9 +167,9 @@ module.exports = class Service1 extends cds.ApplicationService {
167167 } ) ;
168168
169169 /* ========== 7. Service1 running query on the database service using CQN parsed with global function `CQL` ========== */
170- this . on ( "send6 " , async ( req ) => {
170+ this . on ( "send7 " , async ( req ) => {
171171 const { id } = req . data ;
172- const query = cds . parse . cql ( `SELECT * from Entity1 where ID =` + id ) ;
172+ const query = CQL ( `SELECT * from Entity1 where ID =` + id ) ;
173173 cds . run ( query ) ;
174174 } ) ;
175175
You can’t perform that action at this time.
0 commit comments