Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Validates CSS path before loading the file #155

Merged
merged 5 commits into from
Feb 23, 2024
Merged

Conversation

janicklas-ralph
Copy link
Collaborator

Validates CSS path to ensure the right CSS files are loaded

Comment on lines 44 to 45
const relative = path.relative(basePath, currentPath);
return relative && !relative.startsWith('..') && !path.isAbsolute(relative);
Copy link
Contributor

@alan-agius4 alan-agius4 Feb 8, 2024

Choose a reason for hiding this comment

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

path.relative does not return an absolute path.

I believe the below should cover all the cases.

Suggested change
const relative = path.relative(basePath, currentPath);
return relative && !relative.startsWith('..') && !path.isAbsolute(relative);
return !path.relative(basePath, currentPath).startsWith('..');

@janicklas-ralph janicklas-ralph requested a review from kara February 13, 2024 00:26
Base automatically changed from security-fixes to main February 23, 2024 22:36
@janicklas-ralph janicklas-ralph merged commit 2e8cbe8 into main Feb 23, 2024
3 checks passed
@janicklas-ralph janicklas-ralph deleted the security-fixes2 branch February 23, 2024 22:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants