Skip to content

Potential fix for code scanning alert no. 292: Uncontrolled data used in path expression#282

Merged
JensKrumsieck merged 2 commits into
mainfrom
alert-autofix-292
May 29, 2026
Merged

Potential fix for code scanning alert no. 292: Uncontrolled data used in path expression#282
JensKrumsieck merged 2 commits into
mainfrom
alert-autofix-292

Conversation

@JensKrumsieck
Copy link
Copy Markdown
Member

Potential fix for https://github.com/fairagro/sciwin/security/code-scanning/292

General fix: ensure filesystem operations use a canonicalized path that is guaranteed to remain inside a trusted base directory, instead of using partially validated raw PathBuf.

Best targeted fix in packages/core/src/project.rs:

  1. In verify_relative_to_cwd, after validating parent for non-existing paths, canonicalize the parent and rebuild path as canonical_parent.join(file_name) so the returned path is always anchored to canonical parent under canonical CWD.
  2. Keep (and effectively apply to both branches) the starts_with(cwd) and file-type checks on the final path.
  3. This preserves current behavior (creating directories relative to CWD) while making the returned path deterministic and safer for create_dir_all.

No new dependencies are required (uses existing dunce and std APIs already in file).

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

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

@JensKrumsieck JensKrumsieck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Comment thread packages/core/src/project.rs Fixed
Comment thread packages/core/src/project.rs Fixed
@JensKrumsieck JensKrumsieck marked this pull request as ready for review May 29, 2026 09:37
@JensKrumsieck JensKrumsieck merged commit f04f518 into main May 29, 2026
20 checks passed
@JensKrumsieck JensKrumsieck deleted the alert-autofix-292 branch May 29, 2026 09:37
@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
packages/util/src 5%
packages/gui/src/components/graph 0%
packages/core/src 72%
packages/cli/src 58%
packages/cli/src/commands 57%
packages/repository/src 98%
packages/remote_execution/src/reana 0%
packages/reana/src 78%
packages/gui/src/components/files 10%
packages/test_utils 67%
packages/gui/src/components 2%
packages/core/src/parser 92%
packages/gui/src/components/layout 0%
packages/gui/src 23%
packages/remote_execution/src 0%
Summary 53% (2463 / 4655)

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