diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 4f807eae..6ca59601 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -233,3 +233,26 @@ Feature: Site configuration Then the _site directory should exist And I should see "Whatever" in "_site/index.html" And I should see "this is a test" in "_site/test.txt" + + Scenario: Add an empty whitelist to restrict all gems + Given I have an "index.html" file that contains "Whatever" + And I have a configuration file with: + | key | value | + | gems | [jekyll_test_plugin] | + | whitelist | [] | + When I run jekyll in safe mode + Then the _site directory should exist + And I should see "Whatever" in "_site/index.html" + And the "_site/test.txt" file should not exist + + Scenario: Add a whitelist to restrict some gems but allow others + Given I have an "index.html" file that contains "Whatever" + And I have a configuration file with: + | key | value | + | gems | [jekyll_test_plugin, jekyll_test_plugin_malicious] | + | whitelist | [jekyll_test_plugin] | + When I run jekyll in safe mode + Then the _site directory should exist + And I should see "Whatever" in "_site/index.html" + And the "_site/test.txt" file should exist + And I should see "this is a test" in "_site/test.txt" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 7a74486b..5f8f93fc 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -126,6 +126,10 @@ When /^I run jekyll$/ do run_jekyll end +When /^I run jekyll in safe mode$/ do + run_jekyll(:safe => true) +end + When /^I run jekyll with drafts$/ do run_jekyll(:drafts => true) end diff --git a/features/support/env.rb b/features/support/env.rb index 5ccbab98..5fcacc8a 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -15,6 +15,7 @@ def run_jekyll(opts = {}) command = JEKYLL_PATH.clone command << " build" command << " --drafts" if opts[:drafts] + command << " --safe" if opts[:safe] command << " >> /dev/null 2>&1" if opts[:debug].nil? system command end @@ -50,7 +51,7 @@ def seconds_agnostic_datetime(datetime = Time.now) pieces = datetime.to_s.split(" ") if pieces.size == 6 # Ruby 1.8.7 date = pieces[0..2].join(" ") - time = seconds_agnostic_time(pieces[3]) + time = seconds_agnostic_time(pieces[3]) zone = pieces[4..5].join(" ") else # Ruby 1.9.1 or greater date, time, zone = pieces