GSA / data-strategy

Federal data strategy website
https://strategy.data.gov/
Other
21 stars 18 forks source link

Fix code scanning alert no. 1: Incomplete string escaping or encoding #328

Closed btylerburton closed 1 month ago

btylerburton commented 1 month ago

Fixes https://github.com/GSA/data-strategy/security/code-scanning/1

To fix the problem, we need to ensure that backslashes in the id variable are properly escaped before it is used in the query selector. This can be done by modifying the id.replace method to also escape backslashes. We will use a regular expression with the global flag to replace all occurrences of backslashes and double quotes.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

btylerburton commented 1 month ago

Hat tip to Github Copilot for this one. @FuhuXia I think we can leave off updating USWDS for now since this fixed the vulnerability.

btylerburton commented 1 month ago

Related to: