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

refactor: [M3-7277] - SAST Scan Findings: Path Traversal Vulnerability v2 #11914

Conversation

bill-akamai
Copy link
Contributor

@bill-akamai bill-akamai commented Mar 24, 2025

Description 📝

This PR addresses path traversal vulnerabilities identified by SAST security scanning.

Changes 🔄

  • Fixed path traversal vulnerabilities in manager/scripts/ directory
  • Used path.sep for cross-platform compatibility

Preview 📷

Before After

Prerequisites

  • Install semgrep if not already installed with pip install semgrep

Verification steps

  • Ensure the semgrep Path Traversal Vulnerability tests pass. In your terminal, run semgrep --config=p/default scripts/changelog/utils/constants.mjs scripts/changelog/utils/deleteChangesets.mjs scripts/changelog/generate-changelogs.mjs scripts/package-versions/index.js - the output should say "Findings: 0 (0 blocking)".
  • Confirm the generate-changelog script still works as expected. Run pnpm run generate-changelogs and you should see an added CHANGELOG.md file added and existing changeset files in .changeset/ directories are deleted.
  • Confirm creating a single changeset still works as expected.
  • Confirm the package-versions script still works as expected. Run pnpm run package-versions and look for package info output in terminal.
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@bill-akamai bill-akamai self-assigned this Mar 25, 2025
@bill-akamai bill-akamai force-pushed the M3-7277-sast-scan-findings-path-traversal-vulnerability branch from 4a30223 to 0b72d9b Compare March 25, 2025 19:11
@bill-akamai bill-akamai force-pushed the M3-7277-sast-scan-findings-path-traversal-vulnerability branch from 0b72d9b to 5f13994 Compare March 25, 2025 19:13
// Logic to parse the changeset file and generate the changelog content
const filePath = path.join(changesetDirectory(linodePackage), file);
const filePath = changesetDirectory(linodePackage) + path.sep + file;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Semgrep specifically flags the use of path.join() with variables at runtime, however this approach should still be safe since changesetDirectory() returns pre-validated paths created at initialization. path.sep is used for cross-platform compatibility for path constructions b/t Windows vs Unix.

@bill-akamai bill-akamai marked this pull request as ready for review March 25, 2025 20:32
@bill-akamai bill-akamai requested a review from a team as a code owner March 25, 2025 20:32
@bill-akamai bill-akamai requested review from dwiley-akamai, bnussman-akamai and cpathipa and removed request for a team March 25, 2025 20:32
@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 533 passing tests on test run #5 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing533 Passing4 Skipped99m 0s

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Code review ✅
semgrep Path Traversal Vulnerability tests pass ✅

Screenshot 2025-03-27 at 2 34 19 PM

generate-changelog script still works as expected ✅
Creating a single changeset still works as expected ✅
package-versions script still works as expected ✅

@bill-akamai bill-akamai merged commit f3fdfa9 into linode:develop Mar 27, 2025
25 checks passed
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.

4 participants