-
Notifications
You must be signed in to change notification settings - Fork 2
Add a CodeQL extractor for SAP CAP cds files #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This creates a cds extractor which implements: * An `index-files.sh` script that compiles the list of selected cds files using a compatible version of the cds compiler, then processes the resulting jsons into a database with a JS schema. * An `autobuild.sh` script which calls the `index-files.sh` script for each <10MB cds file in repository which is not in a node_modules directory. * A dbscheme based on the JS extractor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still reading through, but I've added a couple of quick thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment and a question. Otherwise, LGTM. Thank you!
Another question: Does the end user lose the capability of firing the chain of I don't think this is a significant downside since the user has to run |
npx can sometimes install the inappropriate version of the cds compiler, if one is specified by a grandparent directory. We therefore update the script to install the cds command in each relevant directory with a package.json before using the npx command.
- Include .cds files - Exclude files in node_modules directories
Also silent the npm install command
Some test cases require it. Also push the env vars into the most specific block, just to ensure that the CDS extraction is not confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you!
This pull requests adds a native CodeQL extractor for the cds service description files from SAP's cap framework.
The cds extractor supports the following scripts:
index-files.sh
- this script enables indexing a specified list of cds files. It works by:@sap/cds-dk
tool that provides thecds compile
command. It installs the package in each directory with apackage.json
file which depends on the@sap/cds
package, and will install a version compatible with the declared versions in thepackage.json file
npx cds compile -2 json --locations -o <...> ...
for each provided cds file, to produce a JSON output file representing the AST for the file..cds.json
files generated by the compiler.autobuild.sh
- this provides an autobuilder which detects all.cds
files that don't exists outsidenode_modules
, and calls thecodeql database index-files --language cds
command to index them.In addition to the cds extractor, I've also added the following:
pre-finalize.sh
script that can be injected into an existing instance of the JavaScript extractor, that enables automatic extraction of CDS files. This is most useful with a custom bundle as generated by the CodeQL Development Toolkit (qlt). The script also recognises theCODEQL_EXTRACTOR_CDS_SKIP_EXTRACTION
flag, which can be set to skip extraction of CDS files.cds-compile.sh
script that can be used with the--command
option to acodeql database create --language javascript
call to add compilation of CDS files manually.Finally, I've updated the Code Scanning workflow to use/test the new CDS extractor.
Some follow up tasks I would look at as separate PRs are:
index-files
only contains.cds
files, andwe don't optimize how often we install theEDIT: this second part is now done.@sap/cds-dk
package in a large monorepo with only a subset