Initial version of platform-independent CDS extractor#169
Merged
lcartey merged 28 commits intoadvanced-security:mainfrom Mar 24, 2025
Merged
Initial version of platform-independent CDS extractor#169lcartey merged 28 commits intoadvanced-security:mainfrom
lcartey merged 28 commits intoadvanced-security:mainfrom
Conversation
Adds .cmd script equivalents for autobuild.sh, index-files.sh, and pre-finalize.sh scripts -- with the (unverified) intention being that the CDS extractor should be able to run on Linux, Mac, or Windows. Migrates most of the `index-files` script logic from shell script to javascript. Adds a `package.json` file to assist with managing dependencies for the new `extractors/cds/tools/index-files.js` script.
lcartey
reviewed
Jan 27, 2025
Contributor
lcartey
left a comment
There was a problem hiding this comment.
Added some initial feedback - looking good overall, just a few specific comments.
Adds comments in index-files.js to better reflect the documented intentions from the old version of index-files.sh script. Better explains the script magic, in places. Attempts to make the index-files.js (JavaScript) script more useful as a multi-platform solution by normalizing file paths using the path.join() function.
First attempt at fixing `Indirect uncontrolled command line` code scanning alerts for the `index-fils.js` script. Improves error handling and improves the reliability and security of code that creates child (exec/spawn) processes. Attempts to improve the passing of env vars to child processes, especially for the `LGTM_INDEX_FILTERS` env var. WIP because CDS extractor invocation is still failing to identify .cds.json files. Possible problem in the way env vars are passed within the javascript extractor autobuilder shell script (to the JVM launched by the javascript extractor autobuilder).
lcartey
suggested changes
Jan 30, 2025
Fixes the invocation of the javascript extractor autobuild within the index-files.js script of the CDS extractor. Ensures that the `cwd` property/option is set when spawning the process that runs the javascript extractor autobuild. Potential working version of initial rewrite for the CDS extractor.
Changes the way the index-files.js script is invoked such that the original `--source-root` directory is used, where possible, as the current working directory for any work performed with within the extractor. Passes the original working directory as a parameter of the index-files.js script to allow that (child) script to run from the project/source root while ensuring node package dependencies are still installed in `extractors/cds/tools/node_modules`.
Forces the `cds` compilier to output JSON to a file (via stdout) instead of creating an output directory. Accounts for what appears to be a change in the behavior of the `cds` (CLI) compiler, where the `-o` (or `--dest`) option now `Writes output to the given folder instead of stdout`. ``` $ npx cds --version @cap-js/asyncapi: 1.0.2 @cap-js/db-service: 1.16.0 @cap-js/openapi: 1.1.2 @cap-js/sqlite: 1.7.7 @capire/bookshop: 1.0.0 @sap/cds: 8.5.0 @sap/cds-compiler: 5.2.0 @sap/cds-dk: 8.7.1 @sap/cds-fiori: 1.2.7 @sap/cds-foss: 5.0.1 @sap/cds-mtxs: 2.5.1 @sap/eslint-plugin-cds: 3.1.2 Node.js: v20.15.0 ```
lcartey
reviewed
Feb 6, 2025
Avoids changing directory when running the `cds` compiler, which ensures that paths generated in .cds.json files are relative to the "source root" directory. This replicates the behavior of the original index-files.sh (shell) script, which works but is probably not correct.
Adds .cmd script equivalents for autobuild.sh, index-files.sh, and pre-finalize.sh scripts -- with the (unverified) intention being that the CDS extractor should be able to run on Linux, Mac, or Windows. Migrates most of the `index-files` script logic from shell script to javascript. Adds a `package.json` file to assist with managing dependencies for the new `extractors/cds/tools/index-files.js` script.
Adds comments in index-files.js to better reflect the documented intentions from the old version of index-files.sh script. Better explains the script magic, in places. Attempts to make the index-files.js (JavaScript) script more useful as a multi-platform solution by normalizing file paths using the path.join() function.
First attempt at fixing `Indirect uncontrolled command line` code scanning alerts for the `index-fils.js` script. Improves error handling and improves the reliability and security of code that creates child (exec/spawn) processes. Attempts to improve the passing of env vars to child processes, especially for the `LGTM_INDEX_FILTERS` env var. WIP because CDS extractor invocation is still failing to identify .cds.json files. Possible problem in the way env vars are passed within the javascript extractor autobuilder shell script (to the JVM launched by the javascript extractor autobuilder).
Fixes the invocation of the javascript extractor autobuild within the index-files.js script of the CDS extractor. Ensures that the `cwd` property/option is set when spawning the process that runs the javascript extractor autobuild. Potential working version of initial rewrite for the CDS extractor.
Changes the way the index-files.js script is invoked such that the original `--source-root` directory is used, where possible, as the current working directory for any work performed with within the extractor. Passes the original working directory as a parameter of the index-files.js script to allow that (child) script to run from the project/source root while ensuring node package dependencies are still installed in `extractors/cds/tools/node_modules`.
Forces the `cds` compilier to output JSON to a file (via stdout) instead of creating an output directory. Accounts for what appears to be a change in the behavior of the `cds` (CLI) compiler, where the `-o` (or `--dest`) option now `Writes output to the given folder instead of stdout`. ``` $ npx cds --version @cap-js/asyncapi: 1.0.2 @cap-js/db-service: 1.16.0 @cap-js/openapi: 1.1.2 @cap-js/sqlite: 1.7.7 @capire/bookshop: 1.0.0 @sap/cds: 8.5.0 @sap/cds-compiler: 5.2.0 @sap/cds-dk: 8.7.1 @sap/cds-fiori: 1.2.7 @sap/cds-foss: 5.0.1 @sap/cds-mtxs: 2.5.1 @sap/eslint-plugin-cds: 3.1.2 Node.js: v20.15.0 ```
Avoids changing directory when running the `cds` compiler, which ensures that paths generated in .cds.json files are relative to the "source root" directory. This replicates the behavior of the original index-files.sh (shell) script, which works but is probably not correct.
…codeql-sap-js into data-douser/extractor-dev-2
Collaborator
Author
|
This version does not enforce the use of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds .cmd script equivalents for autobuild.sh, index-files.sh, and pre-finalize.sh scripts -- with the (unverified) intention being that the CDS extractor should be able to run on Linux, Mac, or Windows.
Migrates most of the
index-filesscript logic from shell script to javascript.Adds a
package.jsonfile to assist with managing dependencies for the newextractors/cds/tools/index-files.jsscript.