Skip to content

Windows OS compatibility for CDS extractor and CAP models#297

Merged
data-douser merged 25 commits intomainfrom
dd/cds-extractor-windows-debug/1
Feb 16, 2026
Merged

Windows OS compatibility for CDS extractor and CAP models#297
data-douser merged 25 commits intomainfrom
dd/cds-extractor-windows-debug/1

Conversation

@data-douser
Copy link
Collaborator

@data-douser data-douser commented Feb 14, 2026

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:

  • Added a new GitHub Actions workflow (.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.
  • Renamed and updated the Linux CodeQL unit test workflow for clarity and consistency. (.github/workflows/ql-unit-tests-linux.yml)

Cross-Platform Path Normalization:

  • Implemented recursive normalization of $location.file paths in .cds.json files to always use POSIX forward slashes, addressing issues with Windows-generated backslash paths. This includes new utility functions normalizeCdsJsonLocations and normalizeLocationPathsInFile in extractors/cds/tools/src/filesystem.ts, and integration of these functions into the CDS compilation process. [1] [2] [3]
  • Updated path handling logic throughout the codebase (e.g., in extractors/cds/tools/src/diagnostics.ts and extractors/cds/tools/src/cds/compiler/compile.ts) to use Node's isAbsolute and to check both Windows and POSIX binary paths, improving compatibility and correctness. [1] [2] [3] [4]

Build and Dependency Updates:

  • Enhanced the build process to generate a dedicated library bundle (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]
  • Updated dependencies and devDependencies in extractors/cds/tools/package.json to newer versions for improved compatibility and security.

Other Improvements:

  • Added a .gitattributes file to enforce consistent line endings across platforms.

Future Works

  • CDS extractor support for paths-ignore config.
  • CDS extractor support for cds-indexer

data-douser and others added 16 commits December 30, 2025 10:09
…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.
@data-douser data-douser added the bug Something isn't working label Feb 14, 2026
@data-douser data-douser changed the base branch from data-douser/cds-extractor-windows-os-3 to main February 14, 2026 02:01
@data-douser data-douser reopened this Feb 14, 2026
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`.
@data-douser data-douser self-assigned this Feb 15, 2026
@data-douser data-douser added enhancement New feature or request dependencies Pull requests that update a dependency file labels Feb 15, 2026
@data-douser data-douser changed the title Windows OS compatibility test 1 Windows OS compatibility for CDS extractor and CAP models Feb 15, 2026
@data-douser data-douser marked this pull request as ready for review February 15, 2026 19:19
@data-douser data-douser requested a review from Copilot February 15, 2026 19:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.file path 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 cmd scripts, with a new cross-platform Node.js-based compilation script
  • Updates CodeQL library path handling in .qll files to normalize Windows backslash paths using replaceAll("\\", "/") for cross-platform compatibility
  • Enhances TypeScript source code with path.isAbsolute() instead of string-based checks for proper Windows path detection
  • Adds .gitattributes configuration 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

data-douser and others added 2 commits February 15, 2026 12:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@data-douser data-douser added the javascript Pull requests that update javascript code label Feb 15, 2026
@data-douser data-douser merged commit 8d7a9a7 into main Feb 16, 2026
16 checks passed
@data-douser data-douser deleted the dd/cds-extractor-windows-debug/1 branch February 16, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Pull requests that update a dependency file enhancement New feature or request javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDS extractor must support Windows OS

1 participant