Skip to content

Commit 1f04231

Browse files
authored
Merge branch 'main' into knewbury01/webcomponent-react
2 parents 001ed58 + 378d564 commit 1f04231

File tree

52 files changed

+1502
-604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1502
-604
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
applyTo: 'extractors/cds/tools/**/*.ts'
3+
description: 'Instructions for CodeQL CDS extractor TypeScript source and test files.'
4+
---
5+
6+
# Copilot Instructions for `extractors/cds/tools/**/*.ts` files
7+
8+
## PURPOSE
9+
10+
This file contains instructions for working with TypeScript source code files in the `extractors/cds/tools/` directory of the `codeql-sap-js` repository. This includes the main `cds-extractor.ts` entry-point, modular source files in `src/**/*.ts`, and comprehensive test files in `test/**/*.test.ts`.
11+
12+
## REQUIREMENTS
13+
14+
## COMMON REQUIREMENTS
15+
16+
- ALWAYS use modern TypeScript syntax and features compatible with the configured target (ES2020).
17+
- ALWAYS follow best practices for implementing secure and efficient CodeQL extractor functionality.
18+
- ALWAYS order imports, definitions, static lists, and similar constructs alphabetically.
19+
- ALWAYS follow a test-driven development (TDD) approach by writing comprehensive tests for new features or bug fixes.
20+
- ALWAYS fix lint errors by running `npm run lint:fix` from the `extractors/cds/tools/` directory before committing changes.
21+
- ALWAYS maintain consistency between the CDS extractor's compilation behavior and the `extractors/cds/tools/test/cds-compilation-for-actions.test.sh` script to prevent CI/CD workflow failures.
22+
- **ALWAYS run `npm run build:all` from the `extractors/cds/tools/` directory and ensure it passes completely before committing any changes. This is MANDATORY and includes lint checks, test coverage, and bundle validation.**
23+
24+
### CDS EXTRACTOR SOURCE REQUIREMENTS
25+
26+
The following requirements are specific to the CDS extractor main entry-point `cds-extractor.ts` and source files matching `extractors/cds/tools/src/**/*.ts`.
27+
28+
- ALWAYS keep the main entry-point `cds-extractor.ts` focused on orchestration, delegating specific tasks to well-defined modules in `src/`.
29+
- ALWAYS gracefully handle extraction failures using tool-level diagnostics in order to avoid disrupting the overall CodeQL extraction process. Instead of exiting with a non-zero code, the CDS extractor should generate a diagnostic error (or warning) that points to the relative path (from source root) of the problematic source (e.g. `.cds`) file.
30+
31+
### CDS EXTRACTOR TESTING REQUIREMENTS
32+
33+
The following requirements are specific to the CDS extractor test files matching `extractors/cds/tools/test/**/*.test.ts`.
34+
35+
- ALWAYS write unit tests for new functions and classes in corresponding `test/src/**/*.test.ts` files.
36+
- ALWAYS use Jest testing framework with the configured `ts-jest` preset.
37+
- ALWAYS follow the AAA pattern (Arrange, Act, Assert) for test structure.
38+
- ALWAYS mock external dependencies (filesystem, child processes, network calls) using Jest mocks or `mock-fs`.
39+
- ALWAYS test both success and error scenarios with appropriate edge cases.
40+
- ALWAYS maintain test coverage above the established threshold.
41+
- **ALWAYS run `npm test` or `npm run test:coverage` from the `extractors/cds/tools/` directory and ensure all tests pass before committing changes.**
42+
43+
## PREFERENCES
44+
45+
- PREFER modular design with each major functionality implemented in its own dedicated file or module under `src/`.
46+
- PREFER the existing architectural patterns:
47+
- `src/cds/compiler/` for CDS compiler specific logic
48+
- `src/cds/parser/` for CDS parser specific logic
49+
- `src/logging/` for unified logging and performance tracking
50+
- `src/packageManager/` for dependency management and caching
51+
- `src/codeql.ts` for CodeQL JavaScript extractor integration
52+
- `src/environment.ts` for environment setup and validation
53+
- PREFER comprehensive error handling with diagnostic reporting through the `src/diagnostics.ts` module.
54+
- PREFER performance-conscious implementations that minimize filesystem operations and dependency installations.
55+
- PREFER project-aware processing that understands CDS file relationships and dependencies.
56+
57+
## CONSTRAINTS
58+
59+
- NEVER leave any trailing whitespace on any line.
60+
- NEVER directly modify any compiled files in the `dist/` directory; all changes must be made in the corresponding `src/` files and built using the build process.
61+
- NEVER commit changes without verifying that `npm run build:all` passes completely when run from the `extractors/cds/tools/` directory.
62+
- NEVER modify compilation behavior without updating the corresponding test script `extractors/cds/tools/test/cds-compilation-for-actions.test.sh`.
63+
- NEVER process CDS files in isolation - maintain project-aware context for accurate extraction.
64+
- NEVER bypass the unified logging system - use `src/logging/` utilities for all output and diagnostics.
65+
- NEVER commit extra documentation files that purely explain what has been changed and/or fixed; use git commit messages instead of adding any `.md` files that you have not explicitly been requested to create.

.github/workflows/cds-extractor-dist-bundle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919

2020
steps:
2121
- name: Checkout repository
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v5
2323

2424
- name: Setup Node.js
25-
uses: actions/setup-node@v4
25+
uses: actions/setup-node@v6
2626
with:
2727
node-version: '20'
2828
cache: 'npm'

.github/workflows/code_scanning.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- name: Checkout repository
27-
uses: actions/checkout@v4
27+
uses: actions/checkout@v5
2828

2929
- name: Prepare local CodeQL model packs
3030
run: |
@@ -89,7 +89,7 @@ jobs:
8989
9090
- name: Upload sarif change
9191
if: steps.validate.outcome != 'success'
92-
uses: actions/upload-artifact@v4
92+
uses: actions/upload-artifact@v5
9393
with:
9494
name: sarif
9595
path: |

.github/workflows/codeql-ql.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "CodeQL - QL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
codeql:
12+
uses: advanced-security/reusable-workflows/.github/workflows/codeql-ql.yml@main
13+
secrets: inherit

.github/workflows/run-codeql-unit-tests-javascript.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix: ${{ steps.export-unit-test-matrix.outputs.matrix }}
1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222

2323
- name: Install QLT
2424
id: install-qlt
@@ -43,7 +43,7 @@ jobs:
4343

4444
steps:
4545
- name: Checkout repository
46-
uses: actions/checkout@v4
46+
uses: actions/checkout@v5
4747

4848
- name: Install QLT
4949
id: install-qlt
@@ -78,7 +78,7 @@ jobs:
7878
qlt query run install-packs
7979
8080
- name: Setup Node.js for CDS compilation
81-
uses: actions/setup-node@v4
81+
uses: actions/setup-node@v6
8282
with:
8383
node-version: '18'
8484
cache: 'npm'
@@ -121,7 +121,7 @@ jobs:
121121
--work-dir $RUNNER_TMP
122122
123123
- name: Upload test results
124-
uses: actions/upload-artifact@v4
124+
uses: actions/upload-artifact@v5
125125
with:
126126
name: test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
127127
path: |
@@ -135,7 +135,7 @@ jobs:
135135
steps:
136136

137137
- name: Checkout repository
138-
uses: actions/checkout@v4
138+
uses: actions/checkout@v5
139139

140140
- name: Install QLT
141141
id: install-qlt
@@ -146,7 +146,7 @@ jobs:
146146

147147

148148
- name: Collect test results
149-
uses: actions/download-artifact@v4
149+
uses: actions/download-artifact@v6
150150

151151
- name: Validate test results
152152
run: |

.github/workflows/update-codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121

2222
- name: Check latest CodeQL CLI version and update qlt.conf.json
2323
id: check-version

extractors/cds/tools/cds-extractor.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ try {
183183
if (!extractorResult.success && extractorResult.error) {
184184
cdsExtractorLog('error', `Error running JavaScript extractor: ${extractorResult.error}`);
185185
if (codeqlExePath) {
186-
addJavaScriptExtractorDiagnostic(sourceRoot, extractorResult.error, codeqlExePath);
186+
addJavaScriptExtractorDiagnostic(
187+
sourceRoot,
188+
extractorResult.error,
189+
codeqlExePath,
190+
sourceRoot,
191+
);
187192
}
188193
logExtractorStop(false, 'JavaScript extractor failed');
189194
} else {
@@ -223,7 +228,12 @@ try {
223228
if (!extractorResult.success && extractorResult.error) {
224229
cdsExtractorLog('error', `Error running JavaScript extractor: ${extractorResult.error}`);
225230
if (codeqlExePath) {
226-
addJavaScriptExtractorDiagnostic(sourceRoot, extractorResult.error, codeqlExePath);
231+
addJavaScriptExtractorDiagnostic(
232+
sourceRoot,
233+
extractorResult.error,
234+
codeqlExePath,
235+
sourceRoot,
236+
);
227237
}
228238
logExtractorStop(false, 'JavaScript extractor failed');
229239
} else {
@@ -316,6 +326,7 @@ try {
316326
cdsFilePathsToProcess[0], // Use first file as representative
317327
`Compilation orchestration failed: ${String(error)}`,
318328
codeqlExePath,
329+
sourceRoot,
319330
);
320331
}
321332
}
@@ -350,7 +361,12 @@ if (!extractorResult.success && extractorResult.error) {
350361
// Use the first CDS file as a representative file for the diagnostic
351362
const firstProject = Array.from(dependencyGraph.projects.values())[0];
352363
const representativeFile = firstProject.cdsFiles[0] || sourceRoot;
353-
addJavaScriptExtractorDiagnostic(representativeFile, extractorResult.error, codeqlExePath);
364+
addJavaScriptExtractorDiagnostic(
365+
representativeFile,
366+
extractorResult.error,
367+
codeqlExePath,
368+
sourceRoot,
369+
);
354370
}
355371

356372
logExtractorStop(false, 'JavaScript extractor failed');

0 commit comments

Comments
 (0)