Skip to content

Commit fd0d13a

Browse files
committed
Fix a regression in applicationserviceinstance
1 parent 39b2397 commit fd0d13a

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CDS.qll

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,26 @@ import advanced_security.javascript.frameworks.cap.CQL
77
import advanced_security.javascript.frameworks.cap.RemoteFlowSources
88

99
/**
10-
* The CDS facade that provides useful interfaces to the current CAP application.
10+
* The CDS facade object that provides useful interfaces to the current CAP application.
11+
* It also acts as a shortcut to `cds.db` when imported via `"@sap/cds"`.
12+
*
1113
* ```js
1214
* const cds = require('@sap/cds')
1315
* ```
1416
*/
17+
/* TODO: Does the `cds` object imported with `"@sap/cds/lib"` also have shortcut to `cds.db`? */
1518
class CdsFacade extends API::Node {
16-
CdsFacade() { this = API::moduleImport(["@sap/cds", "@sap/cds/lib"]) }
19+
string importPath;
20+
21+
CdsFacade() {
22+
importPath = ["@sap/cds", "@sap/cds/lib"] and
23+
this = API::moduleImport(importPath)
24+
}
25+
26+
/**
27+
* Holds if this CDS facade object is imported via path `"@sap/cds/lib"`.
28+
*/
29+
predicate isFromCdsLib() { importPath = "@sap/cds/lib" }
1730

1831
Node getNode() { result = this.asSource() }
1932
}
@@ -36,7 +49,7 @@ class CdsEntitiesCall extends DataFlow::CallNode {
3649
* The property `db` of on a CDS facade, often accessed as `cds.db`.
3750
*/
3851
class CdsDb extends SourceNode {
39-
CdsDb() { exists(CdsFacade cds | this = cds.getMember("db").asSource()) }
52+
CdsDb() { exists(CdsFacade cds | not cds.isFromCdsLib() | this = cds.getMember("db").asSource()) }
4053

4154
MethodCallNode getRunCall() { result = this.getAMemberCall("run") }
4255

@@ -268,7 +281,7 @@ abstract class CdsDbService extends ServiceInstance {
268281

269282
class GloballyAccessedCdsDbService extends CdsDbService {
270283
GloballyAccessedCdsDbService() {
271-
exists(CdsFacade cds |
284+
exists(CdsFacade cds | not cds.isFromCdsLib() |
272285
this = cds.getMember("db").asSource() or
273286
this = cds.asSource()
274287
)

javascript/frameworks/cap/src/sensitive-exposure/SensitiveExposure.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import DataFlow::PathGraph
2121
* via `cds.entities`
2222
* ```javascript
2323
* // Obtained through `cds.entities`
24-
* const { Service1 } = cds.entities("sample.application.namespace");
24+
* const Service1 = cds.entities("sample.application.namespace");
2525
* ```
2626
*/
2727
class EntityEntry extends DataFlow::CallNode {

javascript/frameworks/cap/test/models/cds/applicationserviceinstance/applicationserviceinstance.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| applicationserviceinstance.js:1:13:1:31 | require("@sap/cds") |
12
| applicationserviceinstance.js:2:11:2:60 | new cds ... ptions) |
23
| applicationserviceinstance.js:3:12:3:67 | await n ... ptions) |
34
| applicationserviceinstance.js:3:18:3:67 | new cds ... ptions) |

0 commit comments

Comments
 (0)