Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: dashboard search text for variables SQL query#8342

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hengfeiyang merged 2 commits intomainfromfix/dashboard/variables-searching
Sep 10, 2025

Conversation

@ktx-vaidehi
Copy link
Collaborator

@ktx-vaidehiktx-vaidehi commentedSep 9, 2025
edited
Loading

PR Type

Bug fix


Description

  • Fix SQL search text interpolation

  • Quote escaped search text in query

  • Prevent malformed WHERE clause

  • Improve variable value selector reliability


Diagram Walkthrough

flowchart LR  UI["VariablesValueSelector search"] -- "builds SQL" --> SQL["SELECT with str_match()"]  SQL -- "properly quotes escaped text" --> Engine["Query executes correctly"]
Loading

File Walkthrough

Relevant files
Bug fix
VariablesValueSelector.vue
Properly quote escaped search text in SQL                               

web/src/components/dashboards/VariablesValueSelector.vue

  • Wrap escaped search text in single quotes.
  • Correct string interpolation in str_match() call.
+1/-1     

greptile-apps[bot] reacted with thumbs up emoji
@github-actionsgithub-actionsbot added the ☢️ BugSomething isn't working labelSep 9, 2025
Copy link
Contributor

@greptile-appsgreptile-appsbot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR fixes a critical SQL injection vulnerability in the dashboard variables search functionality. The issue was in theVariablesValueSelector.vue component where user-provided search text was being directly interpolated into SQL queries without proper quoting.

The vulnerability existed in the dynamic query construction for dashboard variable searches. When users search for values in dashboard variables, the system constructs a SQL query using thestr_match function. The original code was passing the escaped search text directly without surrounding quotes:

// Vulnerable codeWHEREstr_match(${field},${escapeSingleQuotes(searchText)})

This meant that even thoughescapeSingleQuotes was being used, the search text was being treated as a SQL identifier or expression rather than a string literal, potentially allowing attackers to inject malicious SQL code.

The fix adds single quotes around the escaped search text:

// Fixed codeWHEREstr_match(${field},'${escapeSingleQuotes(searchText)}')

This ensures the search text is properly treated as a string parameter to thestr_match function, preventing SQL injection while maintaining the intended search functionality. The change integrates seamlessly with the existing dashboard variable system and doesn't affect the user experience - it simply makes the SQL query construction secure.

Confidence score: 5/5

  • This PR is extremely safe to merge and fixes a critical security vulnerability with minimal risk
  • Score reflects a straightforward security fix with clear benefits and no breaking changes to functionality
  • No files require special attention beyond the single line change in VariablesValueSelector.vue

Context used:

Context - Avoid directly interpolating values into SQL queries; instead, generate parameter placeholders and bind them safely to prevent SQL injection and enable plan caching. (link)

1 file reviewed, no comments

Edit Code Review Bot Settings |Greptile

@github-actionsgithub-actionsbot changed the titlefix: dashboard search text for variables SQL queryfix: dashboard search text for variables SQL querySep 9, 2025
@github-actions
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

SQL quoting edge cases

Verify thatescapeSingleQuotes() both escapes embedded quotes and does not itself wrap the value, since the template now adds surrounding single quotes. Confirm behavior for empty strings, leading/trailing spaces aftertrim(), and wildcard or regex semantics expected bystr_match().

if (searchText) {  dummyQuery = `SELECT ${timestamp_column} FROM '${variableObject.query_data.stream}' WHERE str_match(${variableObject.query_data.field}, '${escapeSingleQuotes(searchText.trim())}')`;} else {  dummyQuery = `SELECT ${timestamp_column} FROM '${variableObject.query_data.stream}'`;}
Identifier quoting

Ensure${variableObject.query_data.field} and${variableObject.query_data.stream} are safe identifiers for the target SQL dialect. If fields can contain special characters or reserved words, consider quoting/escaping identifiers to avoid runtime errors.

let dummyQuery: string;if (searchText) {  dummyQuery = `SELECT ${timestamp_column} FROM '${variableObject.query_data.stream}' WHERE str_match(${variableObject.query_data.field}, '${escapeSingleQuotes(searchText.trim())}')`;} else {  dummyQuery = `SELECT ${timestamp_column} FROM '${variableObject.query_data.stream}'`;}

@github-actions
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                   Impact
Possible issue
Quote the field identifier

Quote the field identifier to avoid parse errors or injection when field names
contain special characters. Use consistent quoting for both identifier and string
literal to ensure the query is syntactically safe.

web/src/components/dashboards/VariablesValueSelector.vue [1462]

-dummyQuery = `SELECT ${timestamp_column} FROM '${variableObject.query_data.stream}' WHERE str_match(${variableObject.query_data.field}, '${escapeSingleQuotes(searchText.trim())}')`;+dummyQuery = `SELECT ${timestamp_column} FROM '${variableObject.query_data.stream}' WHERE str_match('${variableObject.query_data.field}', '${escapeSingleQuotes(searchText.trim())}')`;
Suggestion importance[1-10]: 3

__

Why: The existing code line is correctly identified. Quoting the field identifier may prevent issues with special characters, but it could also produce an invalid query if identifiers are not meant to be quoted in this SQL-like dialect; impact is minor and context-dependent.

Low

@hengfeiyanghengfeiyang merged commit78a5919 intomainSep 10, 2025
12 of 14 checks passed
@hengfeiyanghengfeiyang deleted the fix/dashboard/variables-searching branchSeptember 10, 2025 02:54
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ktx-kirtanktx-kirtanktx-kirtan approved these changes

+1 more reviewer

@greptile-appsgreptile-apps[bot]greptile-apps[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

☢️ BugSomething isn't workingReview effort 2/5

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@ktx-vaidehi@ktx-kirtan@hengfeiyang

[8]ページ先頭

©2009-2025 Movatter.jp