Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
cbc1991
Initial commit
jeongsoolee09 Aug 11, 2023
33a987a
Add CDSFacade class
jeongsoolee09 Aug 11, 2023
f30750a
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Aug 14, 2023
192553b
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Aug 19, 2023
f683c70
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Aug 28, 2023
cb83f6d
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Sep 11, 2023
c9b67dd
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Sep 12, 2023
bc66c4f
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Sep 13, 2023
b4559c3
Add scaffolding
jeongsoolee09 Sep 13, 2023
57ab4ef
Merge branch 'jeongsolee09/CAP-first-draft' of github.com:advanced-se…
jeongsoolee09 Sep 13, 2023
b4b2ae5
Add SelectBuilder
jeongsoolee09 Sep 14, 2023
0ba335e
Checkpoint: Under construction
jeongsoolee09 Sep 18, 2023
86bc412
Add more
jeongsoolee09 Sep 19, 2023
340af89
Add some test cases
jeongsoolee09 Sep 26, 2023
302b329
Add `groupBy` and `having`
jeongsoolee09 Sep 26, 2023
ebb110e
Finalize SELECT draft except CQN and CQL obj
jeongsoolee09 Sep 26, 2023
c1e0b9b
Add orderBy to SELECT with propaccess and methodcall
jeongsoolee09 Sep 26, 2023
a1005b9
Add parsed CQL object cases
jeongsoolee09 Sep 26, 2023
f251685
Rename cql_test to select and nest folders
jeongsoolee09 Sep 26, 2023
71dc61b
Add test for Select
jeongsoolee09 Sep 26, 2023
66a72b0
Capture `SELECT.one.from` syntax
jeongsoolee09 Sep 26, 2023
b03babb
Turn more tests to green
jeongsoolee09 Sep 27, 2023
8d3ea62
Add variants which uses TaggedTemplate instead of MethodCall and vice…
jeongsoolee09 Sep 28, 2023
cf6bf1a
Add `isTaggedTemplateSelect` and `isMethodCallSelect`
jeongsoolee09 Sep 28, 2023
7cd3d01
Add comments to each branch
jeongsoolee09 Sep 28, 2023
6e8fbc3
Establish CqlExpression hierarchy
jeongsoolee09 Sep 28, 2023
71536fc
Make isMethodCallSelect and isTaggedTemplateSelect private
jeongsoolee09 Sep 28, 2023
390b8fb
Fix a minor error in explaining comment
jeongsoolee09 Sep 28, 2023
8b9c54b
Fix another minor error in comment
jeongsoolee09 Sep 28, 2023
536b3c8
Add `getLocation` for clickable results
jeongsoolee09 Sep 28, 2023
e44abc1
Factor out shared member predicates to a class
jeongsoolee09 Sep 29, 2023
9dfccb7
Match on property names and method names
jeongsoolee09 Sep 29, 2023
8c3661d
Move CQL models to separate file
jeongsoolee09 Sep 29, 2023
c17958b
Fix syntactical mistakes on unit tests for SELECT
jeongsoolee09 Sep 29, 2023
80f7223
Add test for INSERT CQL query expressions
jeongsoolee09 Sep 29, 2023
d09b1c0
Update tests for SELECT
jeongsoolee09 Sep 30, 2023
f046ab5
Implement classes for INSERT and add tests
jeongsoolee09 Sep 30, 2023
aed2d87
Refactor class hierarchy
jeongsoolee09 Oct 3, 2023
bb0030a
Loosen definitions and add modeling of `DELETE`, `UPDATE` and `UPSERT`
jeongsoolee09 Oct 3, 2023
3c8c76d
Debug `getAnAPIName/0`
jeongsoolee09 Oct 3, 2023
d8ae9f1
Make similar member predicates close to each other
jeongsoolee09 Oct 3, 2023
b5f0beb
Add tests for `UPDATE`
jeongsoolee09 Oct 4, 2023
71ae19e
Add a single case for `INSERT`
jeongsoolee09 Oct 4, 2023
2d6620b
Add minor delimiting comments
jeongsoolee09 Oct 4, 2023
4731166
Remove unnecessary comment
jeongsoolee09 Oct 4, 2023
4310fa5
Add unit tests for `DELETE`
jeongsoolee09 Oct 4, 2023
66eccc5
Add delete.expected and correct other unit test drivers
jeongsoolee09 Oct 4, 2023
7a1a52b
Add cases for INSERT
jeongsoolee09 Oct 5, 2023
7619b95
Add tests for upsert and add `.expected`
jeongsoolee09 Oct 5, 2023
d230597
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Oct 5, 2023
1d96665
Move contents of cap/ according to new repository structure
jeongsoolee09 Oct 5, 2023
a128396
Add lock files for dependency versions
jeongsoolee09 Oct 5, 2023
5e124b5
Add subfolders for correct import paths
jeongsoolee09 Oct 5, 2023
3bfc433
Update import path for unit tests
jeongsoolee09 Oct 9, 2023
f3a9594
Cover cases where the base obj acts as shortcut
jeongsoolee09 Oct 9, 2023
588581f
Add cases where SELECT and UPDATE act as shortcut calls
jeongsoolee09 Oct 9, 2023
ddf1223
Update .expected and remove unneeded code in update.js
jeongsoolee09 Oct 9, 2023
79f6a6f
Merge branch 'main' into jeongsolee09/CAP-first-draft
jeongsoolee09 Oct 9, 2023
2af251f
Merge branch 'main' into jeongsolee09/CAP-first-draft
knewbury01 Dec 20, 2023
c3c949b
Upgrade CodeQL dependencies and bump pack versions
knewbury01 Dec 20, 2023
4eef003
Minor additions
knewbury01 Dec 20, 2023
cf2b390
Refactor CDS
knewbury01 Dec 22, 2023
fa7a6bb
Improve cds request handler model
knewbury01 Jan 3, 2024
eead8db
Refactor cql test locations
knewbury01 Jan 5, 2024
09334a5
Fix cql query base representations
knewbury01 Jan 5, 2024
17e99e4
Update CQL models and add basic sql injection query and test for sql …
knewbury01 Jan 11, 2024
f774013
Improve cap sql model
knewbury01 Jan 15, 2024
baae66b
Improve cap cql taint steps and testing
knewbury01 Jan 16, 2024
3246352
Add comments and query format to CDS and CQL library
knewbury01 Jan 18, 2024
47965f0
Merge branch 'main' into jeongsolee09/CAP-first-draft
knewbury01 Jan 18, 2024
3bb6ec3
Merge branch 'main' into jeongsolee09/CAP-first-draft
knewbury01 Jan 19, 2024
beb10fb
Fix cap query test location
knewbury01 Jan 19, 2024
156d325
Merge branch 'jeongsolee09/CAP-first-draft' of https://github.com/adv…
knewbury01 Jan 19, 2024
1288c81
Fix naming in cap query qlref file
knewbury01 Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions javascript/frameworks/cap/ext/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
lockVersion: 1.0.0
dependencies: {}
compiled: false
9 changes: 9 additions & 0 deletions javascript/frameworks/cap/ext/qlpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
library: true
name: advanced-security/javascript-sap-cap-models
version: 0.3.0
extensionTargets:
codeql/javascript-all: "^0.8.1"
codeql/javascript-queries: "^0.8.1"
dataExtensions:
- "*.model.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import javascript
import DataFlow

module CDS {
// TODO: should this base type be more specific?
abstract class ServiceInstance extends DataFlow::Node { }

/**
* Call to`cds.serve`
*/
class CdsServeCall extends ServiceInstance {
CdsServeCall() { this = any(CdsFacade cds).getMember("serve").getACall() }
}

/**
* call to:
* `new cds.ApplicationService` or `new cds.Service`
*/
class ServiceConstructor extends ServiceInstance {
ServiceConstructor() { this = any(ApplicationService cds).getAnInstantiation() }
}

/**
* return value of `cds.connect.to`
*/
class ConnectTo extends ServiceInstance {
ConnectTo() { this = any(CdsFacade cds).getMember("connect").getMember("to").getACall() }
}

/** Last argument to the service methods `srv.before`, `srv.on`, and `srv.after` */
private class RequestHandler extends FunctionNode { }

private class ErrorHandler extends RequestHandler { }

/**
* Subclassing ApplicationService via `extends`:
* ```js
* class SomeService extends cds.ApplicationService
* ```
*/
class UserDefinedApplicationService extends ClassNode {
UserDefinedApplicationService() {
exists(ApplicationService cdsApplicationService |
this.getASuperClassNode() = cdsApplicationService.asSource()
)
}
}

/**
* Subclassing ApplicationService via `cds.service.impl`:
* ```js
* const cds = require('@sap/cds')
* module.exports = cds.service.impl (function() { ... })
* ```
*/
class OldStyleUserDefinedApplicationService extends MethodCallNode {
OldStyleUserDefinedApplicationService() {
exists(CdsFacade cds | this = cds.getMember("service").getMember("impl").getACall())
}
}

/**
* Parameter of a `srv.with` method call:
* ```js
* cds.serve('./srv/cat-service') .with ((srv) => {
* srv.on ('READ','Books', (req) => req.reply([...]))
* })
* ```
*
* TODO expand this to capture request handlers registered inside the function
*/
class WithCallParameter extends RequestHandler {
WithCallParameter() {
exists(MethodCallNode withCall, ServiceInstance svc |
withCall.getArgument(0) = this and
withCall.getMethodName() = "with" and
withCall.getReceiver() = svc
)
}
}

/**
* Parameter of request handler of `_.on`:
* ```js
* _.on ('READ','Books', (req) => req.reply([...]))
* ```
*/
class OnNodeParam extends ValueNode, ParameterNode {
MethodCallNode on;

OnNodeParam() {
exists(FunctionNode handler |
on.getMethodName() = "on" and
on.getLastArgument() = handler and
handler.getLastParameter() = this
)
}

MethodCallNode getOnNode() { result = on }
}

/**
* Parameter of request handler of `srv.on`:
* ```js
* this.on ('READ','Books', (req) => req.reply([...]))
* ```
* not sure how else to know which service is registering the handler
*/
class RequestSource extends OnNodeParam {
RequestSource() {
// TODO : consider - do we need to actually ever know which service the handler is associated to?
exists(UserDefinedApplicationService svc, FunctionNode init |
svc.getAnInstanceMember() = init and
init.getName() = "init" and
this.getOnNode().getEnclosingFunction() = init.getAstNode()
)
or
exists(WithCallParameter pa | this.getOnNode().getEnclosingFunction() = pa.getFunction())
}
}

class ApplicationService extends API::Node {
ApplicationService() { exists(CdsFacade c | this = c.getMember("ApplicationService")) }
}

/**
* ```js
* const cds = require('@sap/cds')
* ```
*/
class CdsFacade extends API::Node {
CdsFacade() { this = API::moduleImport("@sap/cds") }
}
}
Loading