Windows OS compatibility for CDS extractor and CAP models#297
Merged
data-douser merged 25 commits intomainfrom Feb 16, 2026
Merged
Windows OS compatibility for CDS extractor and CAP models#297data-douser merged 25 commits intomainfrom
data-douser merged 25 commits intomainfrom
Conversation
…dvanced-security/codeql-sap-js into data-douser/cds-extractor-windows-os-3
This commit: - renames the actions workflows that run CodeQL unit tests on Linux and Windows; - refactors the Windows workflow to address errors and inefficiencies identified after initial run; - adds a Windows equivalent script for performing CDS compilation within an actions workflow on 'windows-latest' OS.
This commit: - Adds a .gitattributes file in order to force consistent line feed (LF) endings for cross platform (Linux, Windows, etc.) testing of custom CodeQL queries and libraries. - Attempts to fix CodeQL query unit tests that are failing when run on Windows OS due to different, default LF (character) endings.
The SAP CDS compiler on Windows produces $location.file values with backslashes (e.g. "srv\service1.cds"), causing CodeQL CAP library path matching to fail. Normalize these to OS-appropriate slashes at generation time in the CDS extractor, workflow scripts, and a new standalone normalizer script. - Add normalizeCdsJsonLocations/normalizeLocationPathsInFile to filesystem.ts with 12 unit tests - Call normalizeLocationPathsInFile after compilation in compile.ts - Add normalize-cds-json-paths.mjs standalone CLI for workflow use - Update cds-compilation-for-actions.cmd/.sh to call normalizer - Fix broken for /r loop in .cmd that skipped subdirectory CDS files - Update CDL.qll comments to document the normalization contract
Replace platform-specific shell logic in cds-compilation-for-actions scripts with a cross-platform Node.js script (compile-test-cds.mjs) that reuses CDS extractor functions via a new esbuild library bundle. The .cmd and .sh wrappers now delegate entirely to `node`.
This was referenced Feb 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request significantly enhances cross-platform compatibility for the CDS extractor and CAP framework CodeQL libraries, specifically addressing Windows OS support. The PR introduces systematic path normalization, a new Windows-specific CI/CD workflow, and modernized build infrastructure to ensure the extractor and queries work reliably across Windows, Linux, and macOS.
Changes:
- Implements recursive
$location.filepath normalization in CDS JSON files to convert Windows backslashes to POSIX forward slashes, ensuring CodeQL libraries work correctly on Windows - Adds a comprehensive Windows workflow for CodeQL unit tests using PowerShell and
cmdscripts, with a new cross-platform Node.js-based compilation script - Updates CodeQL library path handling in
.qllfiles to normalize Windows backslash paths usingreplaceAll("\\", "/")for cross-platform compatibility - Enhances TypeScript source code with
path.isAbsolute()instead of string-based checks for proper Windows path detection - Adds
.gitattributesconfiguration to enforce consistent LF line endings across all platforms
Reviewed changes
Copilot reviewed 18 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.gitattributes |
Adds line ending normalization (text=auto eol=lf) for cross-platform consistency |
.github/workflows/ql-unit-tests-windows.yml |
New comprehensive Windows workflow with PowerShell-based CodeQL CLI setup and test execution |
.github/workflows/ql-unit-tests-linux.yml |
Renamed from previous workflow for consistency (content unchanged except title) |
extractors/cds/tools/workflow/compile-test-cds.mjs |
New cross-platform Node.js compilation script that uses bundled extractor functions |
extractors/cds/tools/workflow/cds-compilation-for-actions.sh |
Simplified bash wrapper delegating to Node.js script |
extractors/cds/tools/workflow/cds-compilation-for-actions.cmd |
New Windows batch wrapper delegating to Node.js script |
extractors/cds/tools/compile-test-cds-lib.ts |
New entry point for bundling extractor functions used by workflow scripts |
extractors/cds/tools/esbuild.config.mjs |
Updated build config to generate additional library bundle for workflow scripts |
extractors/cds/tools/src/filesystem.ts |
Added normalizeCdsJsonLocations and normalizeLocationPathsInFile functions for path normalization |
extractors/cds/tools/src/diagnostics.ts |
Updated to use path.isAbsolute() instead of startsWith('/') for Windows compatibility |
extractors/cds/tools/src/cds/compiler/compile.ts |
Enhanced binary path detection to check both Windows and POSIX separator patterns; calls normalization after compilation |
extractors/cds/tools/test/src/filesystem.test.ts |
Comprehensive tests for new path normalization functions with Windows-specific test cases |
extractors/cds/tools/test/src/diagnostics.test.ts |
Added Windows path handling tests documenting cross-platform behavior |
extractors/cds/tools/test/src/cds/compiler/compile.test.ts |
Added tests for Windows and POSIX binary path detection |
extractors/cds/tools/package.json |
Updated dependencies to newer versions (eslint, typescript, prettier, etc.) |
extractors/cds/tools/package-lock.json |
Lock file updates reflecting dependency changes |
javascript/frameworks/cap/lib/.../Application.qll |
Updated getFilePathRelativeToRoot to normalize backslashes to forward slashes |
javascript/frameworks/cap/lib/.../CDL.qll |
Updated path construction logic to normalize Windows paths using replaceAll("\\", "/") |
javascript/frameworks/cap/lib/.../PackageJson.qll |
Added comment explaining forward-slash normalization in getFilePathRelativeToRoot |
Files not reviewed (1)
- extractors/cds/tools/package-lock.json: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
data-douser
commented
Feb 15, 2026
javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/PackageJson.qll
Outdated
Show resolved
Hide resolved
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.
This Pull Request (PR):
What This PR Contributes
Summary of Changes
This pull request introduces significant improvements to the cross-platform compatibility and reliability of the CDS extractor tooling, especially for Windows environments and CodeQL unit testing. The main changes include normalizing file paths in generated CDS JSON files, adding a new Windows-specific workflow for running CodeQL unit tests, and updating dependencies for better compatibility.
Outline of Changes
CI/CD and Testing Improvements:
.github/workflows/ql-unit-tests-windows.yml) to run CodeQL unit tests on Windows, including robust setup, dependency installation, and result validation steps. This ensures the extractor and its tests are cross-platform and reliable..github/workflows/ql-unit-tests-linux.yml)Cross-Platform Path Normalization:
$location.filepaths in.cds.jsonfiles to always use POSIX forward slashes, addressing issues with Windows-generated backslash paths. This includes new utility functionsnormalizeCdsJsonLocationsandnormalizeLocationPathsInFileinextractors/cds/tools/src/filesystem.ts, and integration of these functions into the CDS compilation process. [1] [2] [3]extractors/cds/tools/src/diagnostics.tsandextractors/cds/tools/src/cds/compiler/compile.ts) to use Node'sisAbsoluteand to check both Windows and POSIX binary paths, improving compatibility and correctness. [1] [2] [3] [4]Build and Dependency Updates:
dist/compile-test-cds-lib.cjs) for use in test workflows, and added a new entry point (compile-test-cds-lib.ts) that re-exports relevant functions for workflow scripts. [1] [2]extractors/cds/tools/package.jsonto newer versions for improved compatibility and security.Other Improvements:
.gitattributesfile to enforce consistent line endings across platforms.Future Works
paths-ignoreconfig.