From dd9e3e31538e209baed4f6633a5d19ee411685a5 Mon Sep 17 00:00:00 2001 From: bsmith-n4 Date: Thu, 26 Oct 2017 15:06:47 +0200 Subject: [PATCH 1/2] run ruibocop --- lib/extensions/definition_block.rb | 2 +- lib/extensions/requirement_appendix.rb | 10 +++++----- lib/extensions/requirement_block.rb | 2 +- test/definition_block.rb | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/extensions/definition_block.rb b/lib/extensions/definition_block.rb index c1fa4bf..8d95619 100644 --- a/lib/extensions/definition_block.rb +++ b/lib/extensions/definition_block.rb @@ -20,7 +20,7 @@ # " = " # & = & downcased_title = attrs['title'].downcase.tr(' ', '_').gsub('"', '"') - san_title = attrs['title'].gsub(/&/, '&').gsub(/\`/, '').gsub(/\'/, '').gsub(/\*/, '') + san_title = attrs['title'].gsub(/&/, '&').delete('`').delete("'").delete('*') rescue Exception => msg puts msg # If no title exists on the Def block, throw an exception diff --git a/lib/extensions/requirement_appendix.rb b/lib/extensions/requirement_appendix.rb index a074045..54c4e17 100644 --- a/lib/extensions/requirement_appendix.rb +++ b/lib/extensions/requirement_appendix.rb @@ -30,14 +30,14 @@ def trim(s) adoc_files.each do |f| inc = false commented = false -i = 0 + i = 0 File.read(f).each_line do |li| i += 1 incommentblock ^= true if li[CommentBlockRx] commented = true if li[CommentLineRx] inc = true if li[/published: false/] - doctitle = /(?<=title:\s).+/.match(li) if li[/^title:\s+\w.+/] if i < 8 + doctitle = /(?<=title:\s).+/.match(li) if i < 8 && li[/^title:\s+\w.+/] chapter = /(?<=chapter:\s).+/.match(li) if li[/^chapter:\s+\w.+/] if li[/\[\s*req\s*,\s*id\s*=\s*\w+-?[0-9]+\s*,.*/] @@ -83,9 +83,9 @@ def trim(s) i = 0 reqs.each do |req, f, title, chapter, doctitle| i += 1 - # TODO - find better solution for sanitized titles: - title = title.gsub(/\`/, '').gsub(/\'/, '').gsub(/\*/, '') - + # TODO: - find better solution for sanitized titles: + title = title.delete('`').delete("'").delete('*') + id = /[^,]*\s*id\s*=\s*(\w+-?[0-9]+)\s*,.*/.match(req)[1] version = /(?<=version=)\d+/.match(req) diff --git a/lib/extensions/requirement_block.rb b/lib/extensions/requirement_block.rb index d84115a..c6cd65d 100644 --- a/lib/extensions/requirement_block.rb +++ b/lib/extensions/requirement_block.rb @@ -22,7 +22,7 @@ # " = " # & = & downcased_title = attrs['title'].downcase.tr(' ', '_').gsub('"', '"') - san_title = attrs['title'].gsub(/&/, '&').gsub(/\`/, '').gsub(/\'/, '').gsub(/\*/, '') + san_title = attrs['title'].gsub(/&/, '&').delete('`').delete("'").delete('*') rescue Exception => msg puts msg # If no title exists on the Req block, throw an exception diff --git a/test/definition_block.rb b/test/definition_block.rb index 09f53c4..32d244a 100644 --- a/test/definition_block.rb +++ b/test/definition_block.rb @@ -2,7 +2,7 @@ require 'asciidoctor' require_relative '../lib/extensions/requirement_block' -class TestRequirementBlock < Test::Unit::TestCase +class TestDefinitionBlock < Test::Unit::TestCase def test_delimited_with_title input = "\n.Roundness\n[def]\n--\nRoundness is the measure of how closely the shape of an object approaches that of a mathematically perfect circle.\n--\n" From 81106850d75655dbe5f6f7cedd4804ee4c0c92ab Mon Sep 17 00:00:00 2001 From: bsmith-n4 Date: Thu, 26 Oct 2017 15:46:38 +0200 Subject: [PATCH 2/2] Add bundler audit --- Gemfile.lock | 9 +++++++-- Rakefile | 12 ++++++++++++ jekyll_aspec.gemspec | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f4c2ab1..746329e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,16 +8,21 @@ GEM remote: https://rubygems.org/ specs: asciidoctor (1.5.6.1) - power_assert (1.1.0) - rake (12.1.0) + bundler-audit (0.6.0) + bundler (~> 1.2) + thor (~> 0.18) + power_assert (1.1.1) + rake (12.2.1) test-unit (3.2.6) power_assert + thor (0.20.0) PLATFORMS ruby DEPENDENCIES bundler (>= 1.15.4) + bundler-audit (>= 0.6.0) jekyll_aspec! rake (>= 12.1.0) test-unit (>= 3.2.6) diff --git a/Rakefile b/Rakefile index 454d2c7..54fad97 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,9 @@ +require 'bundler/audit/task' require 'bundler/gem_tasks' require 'test/unit' +Bundler::Audit::Task.new + task default: :test task :test do @@ -13,3 +16,12 @@ task :rubocop do sh 'rubocop' sh 'htmlproofer test' end + +task audit: 'bundle:audit' + +desc 'Run tests, perform security audit of dependencies and ruby style check' +task :full do + Rake::Task["test"].invoke + Rake::Task["audit"].invoke + Rake::Task["rubocop"].invoke +end diff --git a/jekyll_aspec.gemspec b/jekyll_aspec.gemspec index e75323a..e5139f7 100644 --- a/jekyll_aspec.gemspec +++ b/jekyll_aspec.gemspec @@ -30,5 +30,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '>= 1.15.4' spec.add_development_dependency 'rake', '>= 12.1.0' spec.add_development_dependency 'test-unit', '>=3.2.6' + spec.add_development_dependency 'bundler-audit', '>= 0.6.0' spec.add_runtime_dependency 'asciidoctor', '>= 1.5.0' end