-
Notifications
You must be signed in to change notification settings - Fork 4
Revert 292 ritm1344510 #298
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Signed-off-by: Kedar M <kedar.moghe@gsa.gov>
Feature/ogpweb 17405
| </script> | ||
| {% endif %} | ||
|
|
||
| <script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript"></script> |
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source Medium
| //console.log("Total results are : " + totalResults); | ||
|
|
||
| document.getElementById('search-params').innerHTML = encodeHTML(urlParams.get('query')); | ||
| document.getElementById("search-keyword").innerHTML = urlParams.get("query"); |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, the user-provided value from urlParams.get("query") must be sanitized or encoded before being assigned to innerHTML. The best approach is to use a contextual output encoding function, such as encodeHTML, to ensure that any potentially malicious characters are escaped. This prevents the execution of scripts embedded in the query parameter.
Steps to fix:
- Apply the
encodeHTMLfunction to sanitize theurlParams.get("query")value before assigning it toinnerHTMLon line 45. - Ensure that the
encodeHTMLfunction is defined and properly escapes HTML special characters.
-
Copy modified line R45
| @@ -44,3 +44,3 @@ | ||
| document.getElementById('search-params').innerHTML = encodeHTML(urlParams.get('query')); | ||
| document.getElementById("search-keyword").innerHTML = urlParams.get("query"); | ||
| document.getElementById("search-keyword").innerHTML = encodeHTML(urlParams.get("query")); | ||
| document.getElementById("results-count").innerHTML = totalResults; |
|
|
||
| pagerLinks += '<div class="usa-footer__contact-info grid-row grid-gap"><div class="grid-col-auto"><p class="margin-top-0">Powered by <strong>Search.gov</strong></p></div></div>'; | ||
|
|
||
| pager.innerHTML = pagerLinks; |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, we need to ensure that any user-controlled input is properly sanitized or encoded before being inserted into the DOM. The best approach here is to use the encodeHTML function (already defined in the code) to escape special characters in the page parameter and any other user-controlled data before concatenating it into pagerLinks. This will prevent malicious scripts from being executed.
Specifically:
- Use
encodeHTMLto sanitize thepageparameter and any other user-controlled values before they are added topagerLinks. - Replace all instances where
pageor other user-controlled data is directly concatenated into HTML strings with their sanitized versions.
-
Copy modified line R104 -
Copy modified line R113 -
Copy modified line R116 -
Copy modified line R120 -
Copy modified line R128
| @@ -103,3 +103,3 @@ | ||
| if (page > 1){ | ||
| pagerLinks += '<a href="' + getLinkToPage(1) + '" aria-label="First page" class="pager-button">First</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(1)) + '" aria-label="First page" class="pager-button">First</a>'; | ||
| } | ||
| @@ -112,6 +112,6 @@ | ||
| for (var i = start; i < page; i++) { | ||
| pagerLinks += '<a href="' + getLinkToPage(i) + '" aria-label="Page ' + i + '" class="pager-button">' + i + '</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(i)) + '" aria-label="Page ' + encodeHTML(i.toString()) + '" class="pager-button">' + encodeHTML(i.toString()) + '</a>'; | ||
| } | ||
|
|
||
| pagerLinks += '<span class="margin-2, pager-button-current">Page ' + page + " of " + totalPages + "</span>"; | ||
| pagerLinks += '<span class="margin-2, pager-button-current">Page ' + encodeHTML(page.toString()) + " of " + encodeHTML(totalPages.toString()) + "</span>"; | ||
|
|
||
| @@ -119,3 +119,3 @@ | ||
| for (var j = (1*page) + 1; j <= end; j++) { | ||
| pagerLinks += '<a href="' + getLinkToPage(j) + '" aria-label="Page ' + j + '" class="pager-button">' + j + '</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(j)) + '" aria-label="Page ' + encodeHTML(j.toString()) + '" class="pager-button">' + encodeHTML(j.toString()) + '</a>'; | ||
| } | ||
| @@ -127,3 +127,3 @@ | ||
| if( totalPages > 1 && page < totalPages){ | ||
| pagerLinks += '<a href="' + getLinkToPage(totalPages) + '" aria-label="Last page" class="pager-button">Last</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(totalPages)) + '" aria-label="Last page" class="pager-button">Last</a>'; | ||
| } |
| //console.log("Total results are : " + totalResults); | ||
|
|
||
| document.getElementById('search-params').innerHTML = encodeHTML(urlParams.get('query')); | ||
| document.getElementById("search-keyword").innerHTML = urlParams.get("query"); |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, the user-provided input (urlParams.get("query")) must be sanitized or encoded before being inserted into the DOM. The best approach is to use a function that performs contextual output encoding to ensure that any special characters in the input are properly escaped. This prevents malicious scripts from being executed.
The fix involves:
- Introducing a utility function,
encodeHTML, to encode special characters in the input. - Replacing the direct use of
urlParams.get("query")ininnerHTMLwith the encoded version of the input.
Changes are required in the file search/index.html:
- Add the
encodeHTMLfunction. - Update line 48 to use
encodeHTML(urlParams.get("query")).
-
Copy modified lines R15-R21 -
Copy modified line R55
| @@ -14,2 +14,9 @@ | ||
|
|
||
| function encodeHTML(str) { | ||
| return str.replace(/&/g, "&") | ||
| .replace(/</g, "<") | ||
| .replace(/>/g, ">") | ||
| .replace(/"/g, """) | ||
| .replace(/'/g, "'"); | ||
| } | ||
|
|
||
| @@ -47,3 +54,3 @@ | ||
| document.getElementById('search-params').innerHTML = encodeHTML(urlParams.get('query')); | ||
| document.getElementById("search-keyword").innerHTML = urlParams.get("query"); | ||
| document.getElementById("search-keyword").innerHTML = encodeHTML(urlParams.get("query")); | ||
| document.getElementById("results-count").innerHTML = totalResults; |
|
|
||
| pagerLinks += '<div class="usa-footer__contact-info grid-row grid-gap"><div class="grid-col-auto"><p class="margin-top-0">Powered by <strong>Search.gov</strong></p></div></div>'; | ||
|
|
||
| pager.innerHTML = pagerLinks; |
Check failure
Code scanning / CodeQL
Client-side cross-site scripting High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, we need to sanitize or encode any user-controlled input before inserting it into the DOM. Specifically:
- Use the
encodeHTMLfunction to sanitize thepagevariable and any other user-controlled data before appending it topagerLinks. - Ensure that all dynamic content added to
pagerLinksis properly encoded to prevent XSS.
The changes will involve:
- Applying
encodeHTMLto thepagevariable and other user-controlled data in theupdate_pagerfunction. - Ensuring that all HTML content constructed in
pagerLinksis safe.
-
Copy modified line R116 -
Copy modified line R119 -
Copy modified line R123 -
Copy modified line R131
| @@ -115,6 +115,6 @@ | ||
| for (var i = start; i < page; i++) { | ||
| pagerLinks += '<a href="' + getLinkToPage(i) + '" aria-label="Page ' + i + '" class="pager-button">' + i + '</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(i)) + '" aria-label="Page ' + encodeHTML(i.toString()) + '" class="pager-button">' + encodeHTML(i.toString()) + '</a>'; | ||
| } | ||
|
|
||
| pagerLinks += '<span class="margin-2, pager-button-current">Page ' + page + " of " + totalPages + "</span>"; | ||
| pagerLinks += '<span class="margin-2, pager-button-current">Page ' + encodeHTML(page.toString()) + " of " + encodeHTML(totalPages.toString()) + "</span>"; | ||
|
|
||
| @@ -122,3 +122,3 @@ | ||
| for (var j = (1*page) + 1; j <= end; j++) { | ||
| pagerLinks += '<a href="' + getLinkToPage(j) + '" aria-label="Page ' + j + '" class="pager-button">' + j + '</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(j)) + '" aria-label="Page ' + encodeHTML(j.toString()) + '" class="pager-button">' + encodeHTML(j.toString()) + '</a>'; | ||
| } | ||
| @@ -130,3 +130,3 @@ | ||
| if( totalPages > 1 && page < totalPages){ | ||
| pagerLinks += '<a href="' + getLinkToPage(totalPages) + '" aria-label="Last page" class="pager-button">Last</a>'; | ||
| pagerLinks += '<a href="' + encodeHTML(getLinkToPage(totalPages)) + '" aria-label="Last page" class="pager-button">Last</a>'; | ||
| } |
No description provided.