Skip to content

Commit 5347cc1

Browse files
committed
Improve extractor command example in README.md
1 parent b9b1568 commit 5347cc1

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# CodeQL: SAP JavaScript frameworks
22

3+
[cloud-cap-samples]: https://github.com/SAP-samples/cloud-cap-samples
4+
35
This repository contains [CodeQL](https://codeql.github.com/) models and queries for SAP JavaScript frameworks:
46

57
- [CAP](javascript/frameworks/cap) [https://cap.cloud.sap](https://cap.cloud.sap/)
@@ -109,14 +111,28 @@ codeql database analyze <DB_NAME> --format=sarif-latest --output=<OUTPUT_FILE> \
109111

110112
The following example invocation of `codeql database create` includes the `--command` option to invoke the CDS extractor as an extension of the `javascript` extractor, which is used by `codeql` to create the database. The `pre-finalize.sh` script is a minimal wrapper around the `codeql database index-files` command, which we expect to run the `extractors/cds/tools/index-files.js` script to index the JSON files pre-generated by the CDS extractor.
111113

114+
The below example assumes that:
115+
116+
- The [`SAP-samples/cloud-cap-samples`][cloud-cap-samples] repository has been cloned to a sibling directory of the one containing the this repository.
117+
- The [`SAP-samples/cloud-cap-samples`][cloud-cap-samples] repository is intended as the source code root (i.e. target project) for the database.
118+
- The database directory (e.g., `~/codeql-home/databases/cloud-cap-samples-real`) is either absent or empty.
119+
112120
```shell
113-
codeql database create \
114-
--search-path ./extractors/ \
115-
--language javascript \
116-
--command "./extractors/javascript/tools/pre-finalize.sh" \
117-
~/codeql-home/databases/cloud-cap-samples-real
121+
_d="$(pwd)" && codeql database create \
122+
--command="${_d}/extractors/javascript/tools/pre-finalize.sh" \
123+
--language="javascript" \
124+
--search-path="${_d}/extractors/" \
125+
--source-root="${_d}/../cloud-cap-samples/" \
126+
-- ~/codeql-home/databases/cloud-cap-samples-real
118127
```
119128

129+
NOTES:
130+
131+
- The `--source-root` option must be adjusted to match the actual location of the target project (e.g., GitHub repository).
132+
- The database directory path (last argument) must be adjusted to match the desired location of the created database.
133+
- Running the above command multiple times with the same database directory will result in an error. The `--overwrite` command-line option can be used to avoid this error.
134+
- See `codeql database create -h -v` for verbose command help.
135+
120136
## License
121137

122138
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](LICENSE.txt) for the full terms.

0 commit comments

Comments
 (0)