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
3.7.x: EntryFilter#filter symlink fix #7224
Merged
+68
−8
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a679e7
Add failing tests for symlink check.
parkr a8b91de
EntryFilter#filter: reject all symlinks, even if included
parkr 2c088e2
Update tests for EntryFilter#filter fix and add comments for it
parkr 35219a8
Fix fmt errors.
parkr f5cd15c
Run this branch.
parkr 7f1faea
LayoutReader: skip tests if Windows
parkr 2025d12
Revert "Run this branch."
parkr File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/etc/passwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,17 @@ class TestEntryFilter < JekyllUnitTest | |
refute_equal [], site.pages | ||
refute_equal [], site.static_files | ||
end | ||
|
||
should "include only safe symlinks in safe mode even when included" do | ||
# no support for symlinks on Windows | ||
skip_if_windows "Jekyll does not currently support symlinks on Windows." | ||
|
||
site = Site.new(site_configuration("safe" => true, "include" => ["symlinked-file-outside-source"])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a helper for this.. site = fixture_site(
:safe => true,
:include => ["filename"]
) |
||
site.reader.read_directories("symlink-test") | ||
|
||
assert_equal %w(main.scss symlinked-file).length, site.pages.length | ||
refute_includes site.static_files.map(&:name), "symlinked-file-outside-source" | ||
end | ||
end | ||
|
||
context "#glob_include?" do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,46 @@ class TestLayoutReader < JekyllUnitTest | |
assert_equal LayoutReader.new(@site).layout_directory, source_dir("blah/_layouts") | ||
end | ||
end | ||
|
||
context "when a layout is a symlink" do | ||
setup do | ||
FileUtils.ln_sf("/etc/passwd", source_dir("_layouts", "symlink.html")) | ||
@site.config = @site.config.merge({ | ||
"safe" => true, | ||
"include" => ["symlink.html"], | ||
}) | ||
end | ||
|
||
teardown do | ||
FileUtils.rm(source_dir("_layouts", "symlink.html")) | ||
end | ||
|
||
should "only read the layouts which are in the site" do | ||
layouts = LayoutReader.new(@site).read | ||
|
||
refute layouts.keys.include?("symlink"), "Should not read the symlinked layout" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer using |
||
end | ||
end | ||
|
||
context "with a theme" do | ||
setup do | ||
FileUtils.ln_sf("/etc/passwd", theme_dir("_layouts", "theme-symlink.html")) | ||
@site.config = @site.config.merge({ | ||
"include" => ["theme-symlink.html"], | ||
"theme" => "test-theme", | ||
"safe" => true, | ||
}) | ||
end | ||
|
||
teardown do | ||
FileUtils.rm(theme_dir("_layouts", "theme-symlink.html")) | ||
end | ||
|
||
should "not read a symlink'd theme" do | ||
layouts = LayoutReader.new(@site).read | ||
|
||
refute layouts.keys.include?("theme-symlink"), "Should not read symlinked layout from theme" | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parkr For knowledge purposes, can you pleas explain what these two lines mean..?
Thanks =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We first check for symlinks and directly go to next entry if true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment!