Skip to content

Conversation

@atodorov
Copy link
Member

@atodorov atodorov commented May 26, 2025

Cherry-picks some of the initial work in #3985 and refactors it to better fit the existing code style and how we do things in Kiwi TCMS.

First batch of work focuses on the UI first.

ohurst and others added 6 commits May 26, 2025 21:39
make the button more square-ish which looks better with the rest of the
buttons. The fa-code-fork icon is very narrow and doesn't look good.

Also update button text to just the action -> "Clone"
will always point to the existing clone URL which will later be modified
to handle multiple arguments via query string
makes more sense to alert inside the function instead of delegating this
to the caller. This is how selectedCheckboxes() works too and this
function is kind of a duplicate almost!
@atodorov atodorov marked this pull request as draft May 26, 2025 19:23
return false
}

window.location.assign(`/plan/0/clone/?p=${selectedTestPlans.join('&p=')}`)

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium test

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 5 months ago

To fix the issue, we need to sanitize or escape the DOM text before using it in the URL. The escapeHTML utility function, which is already imported in the file, can be used to escape special characters in the extracted text. This ensures that any malicious input is neutralized before being included in the URL. The fix involves applying escapeHTML to the id values returned by getChildRows before they are added to the tpIds array.


Suggested changeset 1
tcms/testplans/static/testplans/js/search.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tcms/testplans/static/testplans/js/search.js b/tcms/testplans/static/testplans/js/search.js
--- a/tcms/testplans/static/testplans/js/search.js
+++ b/tcms/testplans/static/testplans/js/search.js
@@ -252,3 +252,3 @@
     const parentRow = $('#resultsTable').DataTable().row($(parentRowId).closest('tr'))
-    const id = $(parentRowId).closest('tr').find('td:nth-child(3)').text().trim()
+    const id = escapeHTML($(parentRowId).closest('tr').find('td:nth-child(3)').text().trim())
     const children = hiddenChildRows[id]
EOF
@@ -252,3 +252,3 @@
const parentRow = $('#resultsTable').DataTable().row($(parentRowId).closest('tr'))
const id = $(parentRowId).closest('tr').find('td:nth-child(3)').text().trim()
const id = escapeHTML($(parentRowId).closest('tr').find('td:nth-child(3)').text().trim())
const children = hiddenChildRows[id]
Copilot is powered by AI and may make mistakes. Always verify output.
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