Skip to content

Commit 7492bf6

Browse files
authored
Update README.md (#151)
In preparation of making the project open source
1 parent 7c97de6 commit 7492bf6

File tree

1 file changed

+90
-3
lines changed

1 file changed

+90
-3
lines changed

README.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,92 @@
1-
# Overview
2-
[CodeQL](https://codeql.github.com/) models and queries for the SAP frameworks:
1+
# CodeQL: SAP JavaScript frameworks
2+
This repository contains [CodeQL](https://codeql.github.com/) models and queries for SAP JavaScript frameworks:
33
- [CAP](javascript/frameworks/cap) (https://cap.cloud.sap/)
44
- [UI5](javascript/frameworks/ui5) (https://sapui5.hana.ondemand.com/)
5-
- [XSJS](javascript/frameworks/xsjs) (https://www.npmjs.com/package/@sap/async-xsjs)
5+
- [XSJS](javascript/frameworks/xsjs) (https://www.npmjs.com/package/@sap/async-xsjs)
6+
7+
### Published CodeQl packs
8+
- [advanced-security/javascript-sap-cap-queries](https://github.com/advanced-security/codeql-sap-js/pkgs/container/javascript-sap-cap-queries)
9+
- [advanced-security/javascript-sap-ui5-queries](https://github.com/advanced-security/codeql-sap-js/pkgs/container/javascript-sap-ui5-queries)
10+
- [advanced-security/javascript-sap-async-xsjs-queries](https://github.com/advanced-security/codeql-sap-js/pkgs/container/javascript-sap-async-xsjs-queries)
11+
12+
## Usage
13+
14+
### Analyzing a repository with [Code Scanning](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#using-query-packs)
15+
Example workflow file:
16+
```yaml
17+
jobs:
18+
analyze-javascript:
19+
name: Analyze
20+
runs-on: 'ubuntu-latest'
21+
permissions:
22+
security-events: write
23+
24+
- name: Compile CDS files
25+
run: |
26+
npm install -g @sap/cds-dk
27+
for cds_file in $(find . -type f \( -iname '*.cds' \) -print)
28+
do
29+
cds compile $cds_file \
30+
-2 json \
31+
-o "$cds_file.json" \
32+
--locations
33+
done
34+
35+
- name: Initialize CodeQL
36+
uses: github/codeql-action/init@v3
37+
with:
38+
languages: javascript
39+
config-file: .github/codeql/codeql-config.yaml
40+
41+
- name: Perform CodeQL Analysis
42+
id: analyze
43+
uses: github/codeql-action/analyze@v3
44+
```
45+
Example configuration file:
46+
```yaml
47+
name: "My CodeQL config"
48+
49+
packs:
50+
# Use these packs for JavaScript and TypeScript analysis
51+
javascript:
52+
- codeql/javascript-queries:codeql-suites/javascript-security-extended.qls
53+
- advanced-security/javascript-sap-async-xsjs-queries:codeql-suites/javascript-security-extended.qls
54+
- advanced-security/javascript-sap-cap-queries:codeql-suites/javascript-security-extended.qls
55+
- advanced-security/javascript-sap-ui5-queries:codeql-suites/javascript-security-extended.qls
56+
57+
paths-ignore:
58+
- "**/node_modules"
59+
```
60+
### Building and analyzing the CodeQL database with the CodeQL CLI
61+
62+
1. Include and index XML, JSON and CDS files by setting the necessary environment variables:
63+
```
64+
export LGTM_INDEX_XML_MODE='ALL'
65+
export LGTM_INDEX_FILETYPES=$'.json:JSON\n.cds:JSON'
66+
```
67+
2. Compile all the CDS files using the SAP cds toolkit
68+
```
69+
npm install -g @sap/cds-dk
70+
for cds_file in $(find . -type f \( -iname '*.cds' \) -print)
71+
do
72+
cds compile $cds_file \
73+
-2 json \
74+
-o "$cds_file.json" \
75+
--locations
76+
done
77+
```
78+
3. Build the database [as usual](https://docs.github.com/en/code-security/codeql-cli/codeql-cli-manual/database-create)
79+
```
80+
codeql database create <DB_NAME> --language=javascript
81+
```
82+
4. Analyze the database using one or more packs
83+
```
84+
codeql database analyze <DB_NAME> --format=sarif-latest --output=<OUTPUT_FILE> \
85+
--download advanced-security/javascript-sap-cap-queries \
86+
advanced-security/javascript-sap-ui5-queries \
87+
advanced-security/javascript-sap-async-xsjs-queries
88+
```
89+
90+
## License
91+
92+
The code in this repository is licensed under the [MIT License](LICENSE) by [GitHub](https://github.com).

0 commit comments

Comments
 (0)