Skip to content

fix: validate client before adding to url parameters#4613

Merged
815are merged 6 commits into
mainfrom
fix/sonarIssueS8476
May 7, 2026
Merged

fix: validate client before adding to url parameters#4613
815are merged 6 commits into
mainfrom
fix/sonarIssueS8476

Conversation

@815are
Copy link
Copy Markdown
Contributor

@815are 815are commented Apr 29, 2026

validate client before adding to url parameters
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

🦋 Changeset detected

Latest commit: 1524f12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@sap-ux-private/preview-middleware-client Patch
@sap-ux/preview-middleware Patch
@sap-ux/create Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

correction
@heimwege heimwege added the preview-middleware @sap-ux/preview-middleware label May 6, 2026
heimwege
heimwege previously approved these changes May 6, 2026
Copy link
Copy Markdown
Contributor

@heimwege heimwege left a comment

Choose a reason for hiding this comment

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

The core fix is correct and sufficient to satisfy the SonarCloud rule. The tests are well-structured.

@815are 815are marked this pull request as ready for review May 6, 2026 13:43
@815are 815are requested a review from a team as a code owner May 6, 2026 13:43
@hyperspace-insights
Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Fix: Validate sap-client Parameter Before Appending to URL

Bug Fix

🐛 Resolves a SonarCloud security issue (tssecurity:S8476) by validating the sap-client URL parameter before using it to construct a client-side request URL in registerComponentDependencyPaths.

Previously, only the length of the sap-client value was checked (must be 3 characters). Now, an additional regex check ensures the value consists entirely of digits (/^\d+$/), preventing potentially tainted non-numeric data from being injected into the URL.

Changes

  • packages/preview-middleware-client/src/flp/init.ts: Added a numeric-only regex validation (/^\d+$/.test(sapClient)) alongside the existing length check for the sap-client URL parameter.
  • packages/preview-middleware-client/test/unit/flp/init.test.ts: Added a dedicated describe block with parameterized tests covering valid clients (e.g. '001'), clients containing non-numeric characters (e.g. 'T12'), and clients exceeding 3 characters (e.g. '4444'). Also added fetchMock.mockReset() to beforeEach to improve test isolation and a minor whitespace cleanup.
  • .changeset/sparkly-clocks-laugh.md: Added a patch-level changeset entry for @sap-ux-private/preview-middleware-client describing the fix.

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.43

  • Event Trigger: pull_request.ready_for_review
  • Summary Prompt: Default Prompt
  • File Content Strategy: Full file content
  • Output Template: Default Template
  • Correlation ID: 595a23c2-8f63-4802-84ca-09fbec0a5980
  • LLM: anthropic--claude-4.6-sonnet

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

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

The PR correctly validates that sap-client is exactly 3 digits before appending it to the URL, which resolves the Sonar finding. Two issues worth addressing: the libs value built from manifest keys is still concatenated into the URL without encoding (a similar tainted-data risk), and the test suite is missing a case for a client value shorter than 3 characters, leaving that branch untested.

PR Bot Information

Version: 1.20.43

  • Event Trigger: pull_request.ready_for_review
  • File Content Strategy: Full file content
  • Correlation ID: 595a23c2-8f63-4802-84ca-09fbec0a5980
  • LLM: anthropic--claude-4.6-sonnet
  • Agent Instructions:

Comment thread packages/preview-middleware-client/src/flp/init.ts Outdated
Comment thread packages/preview-middleware-client/test/unit/flp/init.test.ts
additional test
815are added 2 commits May 7, 2026 09:04
review comment
adjustment
Copy link
Copy Markdown
Contributor

@heimwege heimwege left a comment

Choose a reason for hiding this comment

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

re-approve

Copy link
Copy Markdown
Contributor

@vadson71 vadson71 left a comment

Choose a reason for hiding this comment

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

Code changes look good
Covered by test
Didn't test locally

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

@Klaus-Keller Klaus-Keller left a comment

Choose a reason for hiding this comment

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

Thanks @815are!

  • changes to validate URL parameters looks good, exactly 3 digits
  • changeset has been added, patch is correct
  • test coverage is great
  • did a visual and AI aided review

Approved from my side.

@815are 815are merged commit f2bb2e4 into main May 7, 2026
18 checks passed
@815are 815are deleted the fix/sonarIssueS8476 branch May 7, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-middleware @sap-ux/preview-middleware

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants