Skip to content

Conversation

@fugerit79
Copy link
Member

Potential fix for https://github.com/fugerit-org/fj-doc/security/code-scanning/114

To fix this, we need to ensure that every time user input is used to construct a file or folder path, it is validated to prevent traversals and keep the output within authorized boundaries. The most robust approach is to check that the resolved/normalized path is strictly within a designated base directory (e.g., the created project temp folder).

Specifically:

  • In FeatureFacade.copyFlavourList and the downstream methods (copyResourcesList, copyFile, insureParent), ensure that the baseFolder and all resulting file operations are within an authorized area.
  • In FeatureFacade.copyFile, before creating any directories or files, resolve the file (output location) and check that it still resides in (is a descendant of) baseFolder (or projectFolder), after normalization.
  • If not, throw an exception and abort.

Implementation:

  • Add a helper method (e.g., checkIfInBaseFolder(File baseFolder, File file)).
  • Use Java's Path#normalize and Path#toAbsolutePath, and check that file is a descendant of baseFolder.
  • Call this validation in copyFile and/or insureParent (or both, for clarity), before actual creation or writing.

Affected file and methods:

  • fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/FeatureFacade.java: add helper method, call validation in copyFile and insureParent.

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

fugerit79 and others added 2 commits October 21, 2025 12:25
… in path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@sonarqubecloud
Copy link

@fugerit79 fugerit79 requested a review from mttfranci October 21, 2025 13:12
@fugerit79 fugerit79 self-assigned this Oct 21, 2025
@fugerit79 fugerit79 added the enhancement New feature or request label Oct 21, 2025
@fugerit79 fugerit79 marked this pull request as ready for review October 21, 2025 13:13
@fugerit79 fugerit79 merged commit a08debf into main Oct 21, 2025
7 checks passed
@fugerit79 fugerit79 deleted the alert-autofix-114 branch October 21, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants