Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: encode queryParam value and fix parsing logic for queryParams #33720

Merged
merged 3 commits into from
May 27, 2024

Conversation

rishabhrathod01
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 commented May 24, 2024

Description

  • Add encoding for Api key secret value before storing it as query param to avoid incorrect parsing.
  • Remove hardcoded "api_key" check to mask headers.
  • Used standard URL parsing APIs instead of custom
  • Added unit test to cover the case

Fixes #33742
flaws in the implementation here

Automation

/test datasource

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9256269246
Commit: 602b0f5
Cypress dashboard url: Click here!

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

@github-actions github-actions bot added the Bug Something isn't working label May 24, 2024
@rishabhrathod01 rishabhrathod01 added the Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. label May 24, 2024
@rishabhrathod01 rishabhrathod01 mentioned this pull request May 24, 2024
2 tasks
@rishabhrathod01 rishabhrathod01 added the ok-to-test Required label for CI label May 24, 2024
@rishabhrathod01 rishabhrathod01 marked this pull request as ready for review May 24, 2024 21:17
Copy link
Contributor

coderabbitai bot commented May 24, 2024

Walkthrough

The changes involve enhancing the handling and masking of API key query parameters in URLs to avoid errors with special characters such as &. This includes encoding the API key values and improving the logic for masking query parameters in URLs using URLEncoder, StandardCharsets, and UriComponentsBuilder.

Changes

File Path Change Summary
app/server/.../ApiKeyAuthentication.java Added imports for URLEncoder and StandardCharsets, encoded the value to avoid errors with special characters, and updated the queryParam method to use the encoded value.
app/server/.../RequestCaptureFilter.java Refactored the method createURIWithMaskedQueryParam into a static method maskQueryParamInURL using UriComponentsBuilder for better handling of query parameters. Changed MASKED_VALUE to static.
app/server/.../RestApiPluginTest.java Modified the initialization of authenticationDTO in the testMaskingOfAPIKeyAddedToQueryParams method to use a value with special characters ("secret&another=value").

Assessment against linked issues

Objective Addressed Explanation
Proper encoding of API key values to handle special characters (e.g., &) in query parameters (#33742)
Enhanced logic for masking query parameters in URLs (#33742)
Refactoring methods to improve code maintainability and readability (#33742)

These changes ensure that API key query parameters with special characters are correctly encoded and masked, addressing the issue described in the linked bug report.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rishabhrathod01 rishabhrathod01 requested review from NilanshBansal and sharat87 and removed request for nidhi-nair and sondermanish May 24, 2024 21:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

@rohan-arthur
Copy link
Contributor

@rishabhrathod01 do you want to create a separate issue for this so that we can track it?

@github-actions github-actions bot added Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Release labels May 27, 2024
@rishabhrathod01
Copy link
Contributor Author

@rishabhrathod01 do you want to create a separate issue for this so that we can track it?

Yes. Added the issue to the board.

Copy link
Contributor

@NilanshBansal NilanshBansal left a comment

Choose a reason for hiding this comment

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

LGTM

@rishabhrathod01 rishabhrathod01 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 27, 2024
Copy link
Member

@sharat87 sharat87 left a comment

Choose a reason for hiding this comment

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

Looks good, minor suggestion, I'll let you take a call on whether it makes sense.

@github-actions github-actions bot added the Integrations Pod Issues related to a specific integration label May 27, 2024
@rishabhrathod01 rishabhrathod01 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels May 27, 2024
@rishabhrathod01 rishabhrathod01 enabled auto-merge (squash) May 27, 2024 14:21
@rishabhrathod01 rishabhrathod01 merged commit 43bd032 into release May 27, 2024
71 checks passed
@rishabhrathod01 rishabhrathod01 deleted the fix/ApiKeySecretInParamFlaw branch May 27, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Pod Issues related to a specific integration Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Api key query param fails to mask secret when query param value has & special chars in it
5 participants