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

#ab55467 #211

Closed
wants to merge 18 commits into from
Closed

#ab55467 #211

wants to merge 18 commits into from

Conversation

spbsoluble
Copy link
Collaborator

No description provided.

Keyfactor and others added 18 commits February 21, 2024 20:02
* fix(ci): Add KFC 11.x test labs
* fix(store-types): Store type create omits empty fields.
* fix(pam-types): `types-list` does not crash on nil httpResponse.
* chore: Update license year, and bump AKV runner go version
* fix(tests): Remove "ProviderTypeParams" from pam-types tests for KFC v11.0.0+
* fix(tests): Fix nil pointer issues on tests.
* feat(stores): `stores export` now allows for `--all` and user interactive exports
---------

Signed-off-by: sbailey <[email protected]>
Co-authored-by: Keyfactor <[email protected]>
…onfig file data.

chore(deps): update `keyfactor-go-client`

Signed-off-by: sbailey <[email protected]>
} else {
fmt.Println(fmt.Sprintf("%s", result))
if jerr != nil {
output = fmt.Sprintf("{\"message\": \"%s\"}", result)

Check failure

Code scanning / CodeQL

Potentially unsafe quoting Critical

If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.

Copilot Autofix AI 2 months ago

To fix the problem, we need to ensure that any user-provided data embedded in a JSON string is properly escaped. The best way to fix this is to use a structured API for building JSON strings or to manually escape any quotes in the result variable before embedding it in the JSON string.

In this case, we will use the strconv.Quote function to properly escape the result variable. This function will add double quotes around the string and escape any special characters, including double quotes, within the string.

Suggested changeset 1
cmd/helpers.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/cmd/helpers.go b/cmd/helpers.go
--- a/cmd/helpers.go
+++ b/cmd/helpers.go
@@ -342,3 +342,3 @@
 		if jerr != nil {
-			output = fmt.Sprintf("{\"message\": \"%s\"}", result)
+			output = fmt.Sprintf("{\"message\": %s}", strconv.Quote(fmt.Sprintf("%s", result)))
 			fmt.Println(output)
EOF
@@ -342,3 +342,3 @@
if jerr != nil {
output = fmt.Sprintf("{\"message\": \"%s\"}", result)
output = fmt.Sprintf("{\"message\": %s}", strconv.Quote(fmt.Sprintf("%s", result)))
fmt.Println(output)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
jsonOutput, err := json.MarshalIndent(output, "", " ")
if err != nil {
//then output a { "message": "result" } json
output = fmt.Sprintf("{\"message\": \"%s\"}", result)

Check failure

Code scanning / CodeQL

Potentially unsafe quoting Critical

If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.
If this
JSON value
contains a double quote, it could break out of the enclosing quotes.

Copilot Autofix AI 2 months ago

To fix the problem, we need to ensure that any user-provided data embedded in a JSON string is properly escaped. The best way to achieve this is to use a structured API for building JSON objects or to manually escape special characters in the data.

In this case, we will use the strconv.Quote function to properly escape the result before embedding it in the JSON string. This function will handle escaping special characters and wrapping the string in double quotes.

Suggested changeset 1
cmd/helpers.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/cmd/helpers.go b/cmd/helpers.go
--- a/cmd/helpers.go
+++ b/cmd/helpers.go
@@ -349,3 +349,3 @@
 			//then output a { "message": "result" } json
-			output = fmt.Sprintf("{\"message\": \"%s\"}", result)
+			output = fmt.Sprintf("{\"message\": %s}", strconv.Quote(fmt.Sprintf("%s", result)))
 			fmt.Println(output)
EOF
@@ -349,3 +349,3 @@
//then output a { "message": "result" } json
output = fmt.Sprintf("{\"message\": \"%s\"}", result)
output = fmt.Sprintf("{\"message\": %s}", strconv.Quote(fmt.Sprintf("%s", result)))
fmt.Println(output)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@spbsoluble spbsoluble changed the base branch from main to release-1.6 November 4, 2024 16:53
@spbsoluble spbsoluble changed the base branch from release-1.6 to ab#55467_sq November 4, 2024 19:39
@spbsoluble spbsoluble deleted the branch ab#55467_sq November 4, 2024 19:48
@spbsoluble spbsoluble closed this Nov 4, 2024
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.

2 participants