-
Notifications
You must be signed in to change notification settings - Fork 4
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: update go version & kin-openapi #1348
base: main
Are you sure you want to change the base?
Conversation
@publi0 vou botar como WIP. Assim que eu resolver isso, libero o PR. |
if value == schema_flags.ValueHelpIsRequired { | ||
value = schema_flags.ValueVerbatimStringPrefix + value | ||
} else if strings.HasPrefix(value, schema_flags.ValueVerbatimStringPrefix) || strings.Contains(value, "$") { | ||
value = fmt.Sprintf("'%s'", data) // keep quotes and wrap in single, so shell doesn't replace variables |
Check failure
Code scanning / CodeQL
Potentially unsafe quoting Critical
JSON value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 hours ago
To fix the problem, we need to ensure that any single quotes in the data
are properly escaped before embedding it into a single-quoted string. This can be achieved by replacing single quotes with escaped single quotes (\'
). Additionally, we should escape any existing backslashes to prevent them from interfering with the escaping of single quotes.
The best way to fix the problem without changing existing functionality is to use the strings.ReplaceAll
function to escape single quotes and backslashes in the data
string before embedding it into the single-quoted string.
-
Copy modified lines R182-R184 -
Copy modified lines R188-R190 -
Copy modified lines R193-R195
@@ -181,3 +181,5 @@ | ||
} else if strings.HasPrefix(value, schema_flags.ValueVerbatimStringPrefix) || strings.Contains(value, "$") { | ||
value = fmt.Sprintf("'%s'", data) // keep quotes and wrap in single, so shell doesn't replace variables | ||
escapedData := strings.ReplaceAll(string(data), `\`, `\\`) | ||
escapedData = strings.ReplaceAll(escapedData, "'", "\\'") | ||
value = fmt.Sprintf("'%s'", escapedData) // keep quotes and wrap in single, so shell doesn't replace variables | ||
} | ||
@@ -185,6 +187,10 @@ | ||
default: | ||
return fmt.Sprintf("'%s'", data) | ||
escapedData := strings.ReplaceAll(string(data), `\`, `\\`) | ||
escapedData = strings.ReplaceAll(escapedData, "'", "\\'") | ||
return fmt.Sprintf("'%s'", escapedData) | ||
} | ||
} | ||
return fmt.Sprintf("'%s'", data) | ||
escapedData := strings.ReplaceAll(string(data), `\`, `\\`) | ||
escapedData = strings.ReplaceAll(escapedData, "'", "\\'") | ||
return fmt.Sprintf("'%s'", escapedData) | ||
} |
} | ||
return | ||
default: | ||
return fmt.Sprintf("'%s'", data) |
Check failure
Code scanning / CodeQL
Potentially unsafe quoting Critical
JSON value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 2 hours ago
To fix the problem, we need to ensure that any single quotes in the user-provided data are properly escaped before embedding them in a string. The best way to fix this is to use strings.ReplaceAll
to escape single quotes and backslashes in the data
string. This will prevent any premature termination of the string literal.
- We will replace single quotes with
\'
and backslashes with\\
in thedata
string. - This change will be made in the
getExampleFormattedValue
function in themgc/cli/cmd/show_help.go
file.
-
Copy modified lines R182-R184 -
Copy modified lines R188-R190
@@ -181,3 +181,5 @@ | ||
} else if strings.HasPrefix(value, schema_flags.ValueVerbatimStringPrefix) || strings.Contains(value, "$") { | ||
value = fmt.Sprintf("'%s'", data) // keep quotes and wrap in single, so shell doesn't replace variables | ||
escapedData := strings.ReplaceAll(string(data), `\`, `\\`) | ||
escapedData = strings.ReplaceAll(escapedData, `'`, `\\'`) | ||
value = fmt.Sprintf("'%s'", escapedData) // keep quotes and wrap in single, so shell doesn't replace variables | ||
} | ||
@@ -185,3 +187,5 @@ | ||
default: | ||
return fmt.Sprintf("'%s'", data) | ||
escapedData := strings.ReplaceAll(string(data), `\`, `\\`) | ||
escapedData = strings.ReplaceAll(escapedData, `'`, `\\'`) | ||
return fmt.Sprintf("'%s'", escapedData) | ||
} |
What does this PR do?
How Has This Been Tested?
Unit Tests: Describe the unit tests you have written and their outcomes.
Integration Tests: Detail the integration tests performed and their results.
Manual Testing: Explain the manual testing process, including steps taken and evidence such as screenshots or logs.
Checklist
pre-commit run --all-files
Screenshots/Videos