Skip to content

Rewrite escape/unescape for SQL #1245

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Rewrite escape/unescape for SQL #1245

wants to merge 5 commits into from

Conversation

ukrbublik
Copy link
Owner

Potential fix for https://github.com/ukrbublik/react-awesome-query-builder/security/code-scanning/10

To fix the issue, we need to ensure that backslashes are properly escaped in the default branch of the escapeLike function. This can be achieved by modifying the regular expression in the res.replace call on line 40 to include backslashes (\\) as part of the characters to escape. The replacement string should also escape backslashes correctly.

The updated regular expression will be /[%_\\]/g, and the replacement string will be "\\\\$&". This ensures that all occurrences of %, _, and \ are escaped consistently.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Copy link

codesandbox bot commented Apr 25, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Apr 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-awesome-query-builder-examples ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2025 3:08pm
react-awesome-query-builder-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2025 3:08pm
react-awesome-query-builder-sandbox-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2025 3:08pm

Copy link

codesandbox-ci bot commented Apr 25, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f0003b9:

Sandbox Source
@react-awesome-query-builder/examples Configuration
@react-awesome-query-builder/sandbox Configuration
@react-awesome-query-builder/sandbox-simple Configuration
@react-awesome-query-builder/sandbox-next Configuration

// escape \ -> \\\\
res = res.replace(/(\\\\)/g, "\\\\$&");
// escape % and _ with \
res = res.replace(/[%_]/g, "\\$&");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 57.54717% with 90 lines in your changes missing coverage. Please review.

Project coverage is 7.91%. Comparing base (788d3f1) to head (f0003b9).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/core/modules/utils/export.js 68.15% 57 Missing ⚠️
packages/sql/modules/import/ast.ts 0.00% 13 Missing ⚠️
packages/core/modules/config/index.js 0.00% 11 Missing ⚠️
packages/sql/modules/import/convert.ts 0.00% 8 Missing ⚠️
packages/sql/modules/import/index.ts 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (788d3f1) and HEAD (f0003b9). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (788d3f1) HEAD (f0003b9)
2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #1245       +/-   ##
==========================================
- Coverage   80.59%   7.91%   -72.69%     
==========================================
  Files         225     225               
  Lines       12424   12591      +167     
  Branches     1559    1565        +6     
==========================================
- Hits        10013     996     -9017     
- Misses       1669   11586     +9917     
+ Partials      742       9      -733     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ukrbublik ukrbublik changed the title Potential fix for code scanning alert no. 10: Incomplete string escaping or encoding Rewrite escape/unescape for SQL May 7, 2025
@ukrbublik ukrbublik force-pushed the alert-autofix-10 branch from 1ae4589 to f3082b7 Compare May 9, 2025 14:34
ukrbublik and others added 5 commits May 16, 2025 17:46
…ing or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This reverts commit 566572b.
.

pg done

like for pg

better LIKE E'' (pg)

.

.

.

.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant