Skip to content

fix cmd_field_list (#1.1-dev) - #14010

Merged
mergify[bot] merged 2 commits into
matrixorigin:1.1-devfrom
YANGGMM:fix-cmd-field-list-1.1-dev
Jan 4, 2024
Merged

mergify[bot] merged 2 commits into
matrixorigin:1.1-devfrom
YANGGMM:fix-cmd-field-list-1.1-dev

Conversation

@YANGGMM

@YANGGMM YANGGMM commented Jan 4, 2024

Copy link
Copy Markdown
Contributor

fix cmd_field_list

Approved by: @daviszhen

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #https://github.com/matrixorigin/MO-Cloud/issues/2092

What this PR does / why we need it:

fix cmd_field_list

fix cmd_field_list

Approved by: @daviszhen
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Jan 4, 2024
@mergify
mergify Bot requested a review from sukki37 January 4, 2024 07:41
@mergify mergify Bot added the kind/bug Something isn't working label Jan 4, 2024
@matrix-meow

Copy link
Copy Markdown
Contributor

@YANGGMM Thanks for your contributions!

Review:

Title: fix cmd_field_list (#1.1-dev)

Body: fix cmd_field_list

Approved by: @daviszhen

This pull request aims to fix an issue with the cmd_field_list functionality. The PR is labeled as a bug fix and references issue #2092 on GitHub.

The changes made in this pull request are as follows:

In util.go:

  • Added a check for the presence of a null character in the query string using strings.IndexRune.
  • If a null character is found, the query string is truncated before the null character.
  • The truncated query string is then concatenated with cmdFieldListSql to form the final SQL string.

In parseCmdFieldList function:

  • Removed the code that finds the null character in the rest string and extracts the tableName.
  • Instead, the tableName is extracted directly from the sql string by trimming the cmdFieldListSql prefix.

Overall, the changes seem to address the issue with the cmd_field_list functionality. However, there are a few areas that could be improved:

  1. Security Issue: Null Character Handling
    The addition of null character handling in the makeCmdFieldListSql function raises a potential security issue. If the query string contains a null character, it is truncated before the null character. This can lead to unexpected behavior or even security vulnerabilities if the null character is part of a malicious input. It is recommended to handle null characters in a more secure manner, such as escaping or rejecting queries that contain null characters.

Suggestion: Implement a more secure method for handling null characters, such as escaping or rejecting queries that contain null characters.

  1. Code Optimization: Redundant Code
    In the parseCmdFieldList function, the code that finds the null character in the rest string and extracts the tableName is no longer needed since the tableName can be directly extracted from the sql string. Removing this redundant code will improve code readability and maintainability.

Suggestion: Remove the code that finds the null character in the rest string and directly extract the tableName from the sql string.

Other than these issues, the changes made in the pull request seem appropriate and address the bug with the cmd_field_list functionality. It is recommended to address the security issue and optimize the code as suggested above before merging the pull request.

@mergify
mergify Bot merged commit d1b571c into matrixorigin:1.1-dev Jan 4, 2024
@YANGGMM
YANGGMM deleted the fix-cmd-field-list-1.1-dev branch January 22, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants