Skip to content

Commit 04acfd8

Browse files
Merge pull request #158 from advanced-security/lcartey/cds-extractor
Add a CodeQL extractor for SAP CAP cds files
2 parents aed7714 + c16f2f0 commit 04acfd8

File tree

8 files changed

+1407
-23
lines changed

8 files changed

+1407
-23
lines changed

.github/workflows/code_scanning.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ on:
1010
- cron: '39 12 * * 2'
1111
workflow_dispatch:
1212

13-
env:
14-
LGTM_INDEX_XML_MODE: all
15-
LGTM_INDEX_FILETYPES: ".json:JSON\n.cds:JSON"
16-
1713
jobs:
1814
analyze-javascript:
1915
name: Analyze
@@ -37,40 +33,36 @@ jobs:
3733
mv $dir .github/codeql/extensions/$dir
3834
done
3935
40-
- name: Ensure presence of cds shell command
41-
run: |
42-
if ! command -v cds &> /dev/null
43-
then
44-
npm install -g @sap/cds-dk
45-
fi
46-
47-
# Compile .cds files to .cds.json files.
48-
- name: Compile CAP CDS files
49-
run: |
50-
for cds_file in $(find . -type f \( -iname '*.cds' \) -print)
51-
do
52-
echo "I am compiling $cds_file"
53-
cds compile $cds_file \
54-
-2 json \
55-
-o "$cds_file.json" \
56-
--locations
57-
done
58-
5936
- name: Extract CodeQL bundle version from qlt.conf.json
6037
run: |
6138
echo "BUNDLE_VERSION=$(jq .CodeQLCLIBundle qlt.conf.json -r)" >> $GITHUB_ENV
6239
6340
- name: Initialize CodeQL
41+
id: initialize-codeql
6442
uses: github/codeql-action/init@v3
43+
env:
44+
# Add our custom extractor to the CodeQL search path
45+
CODEQL_ACTION_EXTRA_OPTIONS: '{"database":{"init":["--search-path","${{ github.workspace }}/extractors"]}}'
6546
with:
6647
languages: javascript
6748
config-file: ./.github/codeql/codeql-config.yaml
49+
db-location: ${{ runner.temp }}/codeql-database
6850
tools: https://github.com/github/codeql-action/releases/download/${{env.BUNDLE_VERSION}}/codeql-bundle-linux64.tar.gz
6951
debug: true
7052

53+
- name: Run CDS extractor
54+
shell: bash
55+
run: |
56+
export CODEQL_DIST="$(dirname "${{ steps.initialize-codeql.outputs.codeql-path }}")"
57+
export CODEQL_EXTRACTOR_JAVASCRIPT_WIP_DATABASE="${{ runner.temp }}/codeql-database/javascript"
58+
${{ github.workspace }}/scripts/compile-cds.sh
59+
7160
- name: Perform CodeQL Analysis
7261
id: analyze
7362
uses: github/codeql-action/analyze@v3
63+
env:
64+
LGTM_INDEX_XML_MODE: all
65+
LGTM_INDEX_FILETYPES: ".json:JSON"
7466

7567
- name: Setup Python
7668
uses: actions/setup-python@v5

0 commit comments

Comments
 (0)