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

Potential fix for code scanning alert no. 2: Use of externally-controlled format string #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

qtips
Copy link
Contributor

@qtips qtips commented Mar 17, 2025

Potential fix for https://github.com/navikt/ung-sak/security/code-scanning/2

To fix the problem, we need to ensure that the format string used in String.format is not influenced by user input. Instead of using basePath directly as the format string, we should use a constant format string and pass basePath as an argument. This way, any format specifiers in basePath will be treated as plain text.

  • Change the String.format call in the genererLenke method to use a constant format string.
  • Pass basePath as an argument to the format string to ensure it is treated as plain text.

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

…lled format string

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@qtips qtips marked this pull request as ready for review March 17, 2025 18:30
@qtips qtips requested a review from a team as a code owner March 17, 2025 18:30
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.

1 participant