From 8181032528fb97b575ffb4df543edc4c1eb7f0f5 Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Thu, 13 Dec 2018 10:51:19 -0500 Subject: [PATCH 1/8] Publish Brakeman HTML report --- Jenkinsfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fdb2aece..81674f9a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ #!/usr/bin/env groovy pipeline { - agent none + agent { label 'vocab-ruby' } options { timeout(time: 120, unit: 'MINUTES') @@ -8,8 +8,6 @@ pipeline { stages { stage('Run Tests') { - agent { label 'vocab-ruby' } - steps { updateSlack('#FFFF00', 'Started tests') @@ -107,9 +105,13 @@ pipeline { } } - stage('Build for Dev Env') { - agent any + stage('Publish Results') { + steps { + publishBrakeman 'reports/brakeman.html' + } + } + stage('Build for Dev Env') { when { branch 'development' } From ee7240a357953af07ddc52b662f2fd68f96a0e31 Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Thu, 13 Dec 2018 15:26:39 -0500 Subject: [PATCH 2/8] Publish cucumber test report --- Jenkinsfile | 1 + lib/tasks/cucumber.rake | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 81674f9a..a72c3c09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -108,6 +108,7 @@ pipeline { stage('Publish Results') { steps { publishBrakeman 'reports/brakeman.html' + cucumber 'reports/cucumber.json' } } diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index d10a4f8e..ca75ce67 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -27,7 +27,7 @@ begin t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. t.fork = true # You may get faster startup if you set this to false t.profile = 'default' - t.cucumber_opts = ["--format rerun --out rerun.txt"] + t.cucumber_opts = ["--format rerun --out rerun.txt --format json --out reports/cucumber.json"] end Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t| From 864921c8571eb3e12175f06c07c212353cd5c96b Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Fri, 14 Dec 2018 11:35:15 -0500 Subject: [PATCH 3/8] Publish RuboCop reports to Jenkins --- .rubocop.yml | 2 ++ Gemfile | 1 + Gemfile.lock | 3 +++ Jenkinsfile | 5 +++++ Rakefile | 11 ++++++++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 94cd161d..402c9853 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +require: +- rubocop/formatter/checkstyle_formatter inherit_from: .rubocop_todo.yml AllCops: TargetRubyVersion: 2.2 diff --git a/Gemfile b/Gemfile index cd3585ed..09dc9259 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ gem 'axlsx_rails' group :development, :test do gem 'fakeweb', '~> 1.3' gem 'rubocop', '~> 0.49.0', require: false + gem 'rubocop-checkstyle_formatter', require: false # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'axe-matchers' gem 'byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 66e80a1a..da741d35 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -385,6 +385,8 @@ GEM rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-checkstyle_formatter (0.4.0) + rubocop (>= 0.35.1) ruby-graphviz (1.2.3) ruby-ole (1.2.12.1) ruby-progressbar (1.9.0) @@ -513,6 +515,7 @@ DEPENDENCIES roo (~> 2.4.0) roo-xls (~> 1.0.0) rubocop (~> 0.49.0) + rubocop-checkstyle_formatter scss_lint selenium-webdriver simplecov diff --git a/Jenkinsfile b/Jenkinsfile index a72c3c09..3e656d7e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -109,6 +109,11 @@ pipeline { steps { publishBrakeman 'reports/brakeman.html' cucumber 'reports/cucumber.json' + checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', + pattern: 'reports/rubocop-checkstyle-result.xml', unHealthy: '' + publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, keepAll: false, + reportDir: 'reports/rubocop', reportFiles: 'index.html', reportName: 'RuboCop Report', + reportTitles: '']) } } diff --git a/Rakefile b/Rakefile index e58cea27..693585e5 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,16 @@ Rails.application.load_tasks if Rails.env != 'production' require 'rubocop/rake_task' - RuboCop::RakeTask.new + RuboCop::RakeTask.new(:rubocop) do |t| + t.options = ['--format', + 'RuboCop::Formatter::CheckstyleFormatter', + '-o', + 'reports/rubocop-checkstyle-result.xml', + '--format', + 'html', + '-o', + 'reports/rubocop/index.html'] + end task default: [:create_reports_dir, :rubocop, 'brakeman:run', 'bundle_audit:run', 'javascript:test', 'javascript:lint', 'erd:test', 'swagger:validate', 'cucumber'] end From 99bcb42ed2335dace8ebacd8eef1fe7591d096f8 Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Fri, 14 Dec 2018 16:02:38 -0500 Subject: [PATCH 4/8] Added Twistlock scanning to pipeline --- Jenkinsfile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3e656d7e..35ec5982 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -140,6 +140,46 @@ pipeline { } } } + + stage('Scan Image') { + agent { label 'docker' } + when { + branch 'development' + } + + steps { + echo "Pulling SDP-V container image for scanning..." + sh 'set +x; docker -H localhost:2375 login -u serviceaccount -p $(oc whoami -t) docker-registry.default.svc.cluster.local:5000' + sh 'docker -H localhost:2375 pull docker-registry.default.svc.cluster.local:5000/sdp/vocabulary:latest' + + echo "Scanning image with Twistlock..." + twistlockScan ca: '', + cert: '', + compliancePolicy: 'critical', + dockerAddress: 'tcp://localhost:2375', + gracePeriodDays: 7, + ignoreImageBuildTime: true, + repository: '', + image: 'docker-registry.default.svc.cluster.local:5000/sdp/vocabulary:latest', + tag: '', + key: '', + logLevel: 'true', + policy: 'critical', + requirePackageUpdate: true, + timeout: 10 + + echo "Publishing results..." + twistlockPublish ca: '', + cert: '', + dockerAddress: 'tcp://localhost:2375', + gracePeriodDays: 7, + ignoreImageBuildTime: true, + image: 'docker-registry.default.svc.cluster.local:5000/sdp/vocabulary:latest', + key: '', + logLevel: 'true', + timeout: 10 + } + } } } From 5e655f1081646379916f201af123c051ee1ecdb6 Mon Sep 17 00:00:00 2001 From: Andrew Pellitieri Date: Fri, 21 Dec 2018 07:20:13 -0700 Subject: [PATCH 5/8] Exact match with improvements --- app/serializers/es_response_set_serializer.rb | 1 + docs/elastic_search_schema.json | 11 ++++++++--- lib/sdp/elastic_search.rb | 11 ++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/serializers/es_response_set_serializer.rb b/app/serializers/es_response_set_serializer.rb index a10d3a05..c1e1ece8 100644 --- a/app/serializers/es_response_set_serializer.rb +++ b/app/serializers/es_response_set_serializer.rb @@ -3,6 +3,7 @@ class ESResponseSetSerializer < ActiveModel::Serializer attribute :id attribute :name + attribute :oid attribute :version_independent_id attribute :version attribute :status diff --git a/docs/elastic_search_schema.json b/docs/elastic_search_schema.json index 9ea8f8c5..3485d36d 100644 --- a/docs/elastic_search_schema.json +++ b/docs/elastic_search_schema.json @@ -35,11 +35,13 @@ "tokenizer": { "sdp": { "type": "edge_ngram", - "min_gram": 3, - "max_gram": 10, + "min_gram": 2, + "max_gram": 20, "token_chars": [ "letter", - "digit" + "digit", + "punctuation", + "symbol" ] } }, @@ -825,6 +827,9 @@ "id": { "type": "text" }, + "oid": { + "type": "text" + }, "mostRecent": { "type": "boolean" }, diff --git a/lib/sdp/elastic_search.rb b/lib/sdp/elastic_search.rb index 0c69cdcd..09383e3a 100644 --- a/lib/sdp/elastic_search.rb +++ b/lib/sdp/elastic_search.rb @@ -85,6 +85,13 @@ def self.search(type, query_string, page, query_size = 10, must_filters = {}, cu must_body = if query_string.blank? {} + elsif query_string.include?('"') + # If the string has double quotes it should be exact match + { query_string: { query: query_string, fields: [ + 'name', 'description', 'codes.code', 'codes.codeSystem', 'codes.displayName', + 'tag_list', 'category', 'subcategory', 'createdBy.email', 'createdBy.name', + 'status', 'content_stage', 'oid', 'version_independent_id' + ] } } else { dis_max: { queries: [ { match: { name: { query: query_string, boost: 9 } } }, @@ -98,7 +105,9 @@ def self.search(type, query_string, page, query_size = 10, must_filters = {}, cu { match: { 'createdBy.email': { query: query_string } } }, { match: { 'createdBy.name': { query: query_string } } }, { match: { status: { query: query_string } } }, - { match: { content_stage: { query: query_string } } } + { match: { content_stage: { query: query_string } } }, + { match: { oid: { query: query_string } } }, + { match: { version_independent_id: { query: query_string } } } ] } } end From 90bf456334da7b912a9d9f565b3197a58af8d783 Mon Sep 17 00:00:00 2001 From: Andrew Pellitieri Date: Fri, 21 Dec 2018 07:23:13 -0700 Subject: [PATCH 6/8] Linter fix --- lib/sdp/elastic_search.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sdp/elastic_search.rb b/lib/sdp/elastic_search.rb index 09383e3a..e4cae89e 100644 --- a/lib/sdp/elastic_search.rb +++ b/lib/sdp/elastic_search.rb @@ -88,9 +88,9 @@ def self.search(type, query_string, page, query_size = 10, must_filters = {}, cu elsif query_string.include?('"') # If the string has double quotes it should be exact match { query_string: { query: query_string, fields: [ - 'name', 'description', 'codes.code', 'codes.codeSystem', 'codes.displayName', - 'tag_list', 'category', 'subcategory', 'createdBy.email', 'createdBy.name', - 'status', 'content_stage', 'oid', 'version_independent_id' + 'name', 'description', 'codes.code', 'codes.codeSystem', 'codes.displayName', + 'tag_list', 'category', 'subcategory', 'createdBy.email', 'createdBy.name', + 'status', 'content_stage', 'oid', 'version_independent_id' ] } } else { dis_max: { queries: [ From 46c902613a631fb32f20cabe6c64bf106b132f7d Mon Sep 17 00:00:00 2001 From: Andrew Pellitieri Date: Fri, 4 Jan 2019 03:10:50 -0700 Subject: [PATCH 7/8] Imporved Epi Info paging --- .../_epi_info_question_field.xml.erb | 4 +- .../sections/_epi_info_section_field.xml.erb | 63 +++++++++++++++++-- .../sections/_epi_info_section_page.xml.erb | 4 +- app/views/surveys/epi_info.xml.erb | 18 ++---- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/app/views/questions/_epi_info_question_field.xml.erb b/app/views/questions/_epi_info_question_field.xml.erb index b38800d6..7a012953 100644 --- a/app/views/questions/_epi_info_question_field.xml.erb +++ b/app/views/questions/_epi_info_question_field.xml.erb @@ -1,6 +1,6 @@ <% if sni.nested_section %> <%= render partial: "sections/epi_info_section_field.xml", - locals: {section: sni.nested_section, page_id: page_id, position: position, left: left + 0.01, height: sni.nested_section.calculate_section_height, page_name: page_name } %> + locals: {section: sni.nested_section, left: left + 0.01, height: sni.nested_section.calculate_section_height, page_name: page_name } %> <% else %> <%= render partial: "questions/epi_info_question_field.xml", - locals: {section: section, sni: sni, page_id: page_id, position: position, left: left + 0.01, page_name: page_name } %> + locals: {section: section, sni: sni, left: left + 0.01, page_name: page_name } %> + <% if @top > 0.75 %> + <% @top = -0.03 %> + <% left = 0.01 %> + + + + <% end %> <% end %> <% end %> diff --git a/app/views/sections/_epi_info_section_page.xml.erb b/app/views/sections/_epi_info_section_page.xml.erb index b3722cfd..56fb8715 100644 --- a/app/views/sections/_epi_info_section_page.xml.erb +++ b/app/views/sections/_epi_info_section_page.xml.erb @@ -1,5 +1,5 @@ - + <% left = 0.01 %> <%= render partial: "sections/epi_info_section_field.xml", - locals: {section: section, page_id: page_id, position: position, left: left, height: 1, page_name: 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') } %> + locals: {section: section, left: left, height: 1, page_name: 'Page' + section.name.parameterize.underscore.camelize.truncate(40, omission: '') } %> diff --git a/app/views/surveys/epi_info.xml.erb b/app/views/surveys/epi_info.xml.erb index 8ee089cc..24bf5253 100644 --- a/app/views/surveys/epi_info.xml.erb +++ b/app/views/surveys/epi_info.xml.erb @@ -1,21 +1,11 @@