rails_template_18f 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile.lock +85 -70
  4. data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +4 -3
  5. data/lib/generators/rails_template18f/auditree/auditree_generator.rb +36 -6
  6. data/lib/generators/rails_template18f/auditree/templates/gitlab/auditree.yml.tt +48 -0
  7. data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +6 -2
  8. data/lib/generators/rails_template18f/cloud_gov_config/cloud_gov_config_generator.rb +0 -8
  9. data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +6 -15
  10. data/lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb +13 -19
  11. data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +0 -4
  12. data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +16 -0
  13. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +4 -1
  14. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +4 -1
  15. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +4 -1
  16. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +4 -1
  17. data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +9 -18
  18. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/{node.yml.tt → node.yml} +1 -1
  19. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +11 -18
  20. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +80 -152
  21. data/lib/generators/rails_template18f/oscal/oscal_generator.rb +15 -1
  22. data/lib/generators/rails_template18f/oscal/templates/bin/trestle.tt +10 -1
  23. data/lib/generators/rails_template18f/oscal/templates/gitlab/trestle.yml.tt +29 -0
  24. data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +2 -2
  25. data/lib/generators/rails_template18f/sidekiq/templates/config/initializers/redis.rb +1 -1
  26. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/apply.sh +25 -0
  27. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/main.tf.tt +114 -0
  28. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/setup_shadowenv.sh +61 -0
  29. data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/templates/backend_config.tftpl +6 -0
  30. data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/users.auto.tfvars +5 -0
  31. data/lib/generators/rails_template18f/terraform/templates/{full_bootstrap → s3_bootstrap/full}/main.tf.tt +7 -27
  32. data/lib/generators/rails_template18f/terraform/templates/{sandbox_bootstrap → s3_bootstrap/sandbox}/main.tf.tt +6 -19
  33. data/lib/generators/rails_template18f/terraform/templates/terraform/.shadowenv.d/.gitignore +3 -0
  34. data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +41 -29
  35. data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +7 -6
  36. data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +16 -14
  37. data/lib/generators/rails_template18f/terraform/templates/terraform/{production.tfvars.tt → production.env.tfvars.tt} +0 -1
  38. data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +6 -8
  39. data/lib/generators/rails_template18f/terraform/templates/terraform/staging.env.tfvars.tt +7 -0
  40. data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +52 -18
  41. data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +15 -11
  42. data/lib/generators/rails_template18f/terraform/terraform_generator.rb +80 -6
  43. data/lib/rails_template18f/generators/cloud_gov_parsing.rb +2 -2
  44. data/lib/rails_template18f/version.rb +1 -1
  45. data/template.rb +33 -16
  46. data/templates/README.md.tt +1 -1
  47. metadata +23 -17
  48. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +0 -28
  49. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl +0 -8
  50. data/lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt +0 -8
  51. /data/lib/generators/rails_template18f/{github_actions → oscal}/templates/github/workflows/assemble-ssp.yml.tt +0 -0
  52. /data/lib/generators/rails_template18f/{github_actions → oscal}/templates/github/workflows/validate-ssp.yml +0 -0
  53. /data/lib/generators/rails_template18f/terraform/templates/{terraform/bootstrap → gitlab_bootstrap}/users.auto.tfvars +0 -0
  54. /data/lib/generators/rails_template18f/terraform/templates/{terraform/bootstrap → s3_bootstrap/common}/apply.sh +0 -0
  55. /data/lib/generators/rails_template18f/terraform/templates/{terraform/bootstrap → s3_bootstrap/common}/templates/bot_secrets.tftpl +0 -0
  56. /data/lib/generators/rails_template18f/terraform/templates/{full_bootstrap → s3_bootstrap/full}/imports.tf.tftpl +0 -0
  57. /data/lib/generators/rails_template18f/terraform/templates/{sandbox_bootstrap → s3_bootstrap/sandbox}/imports.tf.tftpl +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c98e855c8844d55ba478f2fe9a0bac27cea41e417e7f76b2be22f97c5363963c
4
- data.tar.gz: 5eeb6079ee3d68350ee473aec5156fd54f2f47d837a1230ac62080b223960220
3
+ metadata.gz: c3ca664ff6618dfdbbd5253b5a58ed43487d7a268cce07bded46840c96353cf6
4
+ data.tar.gz: 27084955f39ced3910a073008f14fec6630c11607429cdbf9cd1b6f61af0b9f7
5
5
  SHA512:
6
- metadata.gz: 24df2ba12417ab9754e851406fc9c77b21c23b21206f7760dd0ba23d0793f25b3fad5c8a57fbf2c5f9743cb8e0edd2bbe6a89b4f8603342f9ec893f3a28bdb34
7
- data.tar.gz: 681823d0918b7ddacde8372051d85f8636954b92aa97467655b89e7d5ac3580768b31d1b7e12d27cd8d2a296c92769ae065b578dbb1b143aa8dbb15e9927fcde
6
+ metadata.gz: 9fb5460862865efea3faeb5cf6e1f220e725b57e83c0eb4b3178d486169be2e6e5f6cc3185a621c05ac50a9cdda068e11eb3ae9efba2ae17ce2041fe64e9a41f
7
+ data.tar.gz: f5826c6d647d2c0285b0399fccb74e91c2ff4c832f9b4d5ab9f89d89dc81302a7c1880aab76076a7fc81dcc906e45536261b0d5b367284581ff51a9c0751ec03
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.3.0] - 2025-11-25
4
+
5
+ - Updates to Gitlab CI and Terraform generators for better workshop.cloud.gov support
6
+
7
+ ## [2.2.0] - 2025-06-27
8
+
9
+ - Prevent non-compliant hostnames by replacing underscores with dashes
10
+ - use shadowenv for configuring terraform backend secrets
11
+ - use GitLab http backend for terraform state storage whenever configuring both terraform and GitLab CI
12
+ - Create GitLabCI jobs for oscal and auditree generators
13
+ - fixes for deploying to the sandbox-gsa cloug.gov org
14
+
3
15
  ## [2.1.0] - 2025-04-29
4
16
 
5
17
  - Terraform generator updates to remove the old cloudfoundy-community provider and reduce the need for cloud.gov service accounts
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_template_18f (2.1.0)
4
+ rails_template_18f (2.3.0)
5
5
  activesupport (~> 8.0.1)
6
6
  colorize (~> 1.1)
7
7
  railties (~> 8.0.1)
@@ -10,9 +10,9 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actionpack (8.0.1)
14
- actionview (= 8.0.1)
15
- activesupport (= 8.0.1)
13
+ actionpack (8.0.4)
14
+ actionview (= 8.0.4)
15
+ activesupport (= 8.0.4)
16
16
  nokogiri (>= 1.8.5)
17
17
  rack (>= 2.2.4)
18
18
  rack-session (>= 1.0.1)
@@ -20,13 +20,13 @@ GEM
20
20
  rails-dom-testing (~> 2.2)
21
21
  rails-html-sanitizer (~> 1.6)
22
22
  useragent (~> 0.16)
23
- actionview (8.0.1)
24
- activesupport (= 8.0.1)
23
+ actionview (8.0.4)
24
+ activesupport (= 8.0.4)
25
25
  builder (~> 3.1)
26
26
  erubi (~> 1.11)
27
27
  rails-dom-testing (~> 2.2)
28
28
  rails-html-sanitizer (~> 1.6)
29
- activesupport (8.0.1)
29
+ activesupport (8.0.4)
30
30
  base64
31
31
  benchmark (>= 0.3)
32
32
  bigdecimal
@@ -43,140 +43,155 @@ GEM
43
43
  activesupport (>= 3.0)
44
44
  railties (>= 3.0)
45
45
  rspec-rails (>= 2.2)
46
- ast (2.4.2)
47
- base64 (0.2.0)
48
- benchmark (0.4.0)
49
- bigdecimal (3.1.9)
46
+ ast (2.4.3)
47
+ base64 (0.3.0)
48
+ benchmark (0.5.0)
49
+ bigdecimal (3.3.1)
50
50
  builder (3.3.0)
51
- byebug (11.1.3)
51
+ byebug (12.0.0)
52
52
  colorize (1.1.0)
53
- concurrent-ruby (1.3.4)
54
- connection_pool (2.4.1)
53
+ concurrent-ruby (1.3.5)
54
+ connection_pool (2.5.4)
55
55
  crass (1.0.6)
56
- date (3.4.1)
57
- diff-lcs (1.5.1)
58
- drb (2.2.1)
56
+ date (3.5.0)
57
+ diff-lcs (1.6.2)
58
+ drb (2.2.3)
59
+ erb (6.0.0)
59
60
  erubi (1.13.1)
60
- i18n (1.14.6)
61
+ i18n (1.14.7)
61
62
  concurrent-ruby (~> 1.0)
62
- io-console (0.8.0)
63
- irb (1.14.3)
63
+ io-console (0.8.1)
64
+ irb (1.15.3)
65
+ pp (>= 0.6.0)
64
66
  rdoc (>= 4.0.0)
65
67
  reline (>= 0.4.2)
66
- json (2.9.1)
67
- language_server-protocol (3.17.0.3)
68
+ json (2.16.0)
69
+ language_server-protocol (3.17.0.5)
68
70
  lint_roller (1.1.0)
69
- logger (1.6.4)
70
- loofah (2.23.1)
71
+ logger (1.7.0)
72
+ loofah (2.24.1)
71
73
  crass (~> 1.0.2)
72
74
  nokogiri (>= 1.12.0)
73
- minitest (5.25.4)
74
- nokogiri (1.18.8-arm64-darwin)
75
+ minitest (5.26.2)
76
+ nokogiri (1.18.10-arm64-darwin)
75
77
  racc (~> 1.4)
76
- nokogiri (1.18.8-x86_64-darwin)
78
+ nokogiri (1.18.10-x86_64-darwin)
77
79
  racc (~> 1.4)
78
- nokogiri (1.18.8-x86_64-linux-gnu)
80
+ nokogiri (1.18.10-x86_64-linux-gnu)
79
81
  racc (~> 1.4)
80
- parallel (1.26.3)
81
- parser (3.3.6.0)
82
+ parallel (1.27.0)
83
+ parser (3.3.10.0)
82
84
  ast (~> 2.4.1)
83
85
  racc
84
- psych (5.2.2)
86
+ pp (0.6.3)
87
+ prettyprint
88
+ prettyprint (0.2.0)
89
+ prism (1.6.0)
90
+ psych (5.2.6)
85
91
  date
86
92
  stringio
87
93
  racc (1.8.1)
88
- rack (3.1.12)
89
- rack-session (2.0.0)
94
+ rack (3.2.4)
95
+ rack-session (2.1.1)
96
+ base64 (>= 0.1.0)
90
97
  rack (>= 3.0.0)
91
98
  rack-test (2.2.0)
92
99
  rack (>= 1.3)
93
100
  rackup (2.2.1)
94
101
  rack (>= 3)
95
- rails-dom-testing (2.2.0)
102
+ rails-dom-testing (2.3.0)
96
103
  activesupport (>= 5.0.0)
97
104
  minitest
98
105
  nokogiri (>= 1.6)
99
106
  rails-html-sanitizer (1.6.2)
100
107
  loofah (~> 2.21)
101
108
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
102
- railties (8.0.1)
103
- actionpack (= 8.0.1)
104
- activesupport (= 8.0.1)
109
+ railties (8.0.4)
110
+ actionpack (= 8.0.4)
111
+ activesupport (= 8.0.4)
105
112
  irb (~> 1.13)
106
113
  rackup (>= 1.0.0)
107
114
  rake (>= 12.2)
108
115
  thor (~> 1.0, >= 1.2.2)
116
+ tsort (>= 0.2)
109
117
  zeitwerk (~> 2.6)
110
118
  rainbow (3.1.1)
111
- rake (13.2.1)
112
- rdoc (6.10.0)
119
+ rake (13.3.1)
120
+ rdoc (6.15.1)
121
+ erb
113
122
  psych (>= 4.0.0)
114
- regexp_parser (2.10.0)
115
- reline (0.6.0)
123
+ tsort
124
+ regexp_parser (2.11.3)
125
+ reline (0.6.3)
116
126
  io-console (~> 0.5)
117
- rspec (3.13.0)
127
+ rspec (3.13.2)
118
128
  rspec-core (~> 3.13.0)
119
129
  rspec-expectations (~> 3.13.0)
120
130
  rspec-mocks (~> 3.13.0)
121
- rspec-core (3.13.2)
131
+ rspec-core (3.13.6)
122
132
  rspec-support (~> 3.13.0)
123
- rspec-expectations (3.13.3)
133
+ rspec-expectations (3.13.5)
124
134
  diff-lcs (>= 1.2.0, < 2.0)
125
135
  rspec-support (~> 3.13.0)
126
- rspec-mocks (3.13.2)
136
+ rspec-mocks (3.13.7)
127
137
  diff-lcs (>= 1.2.0, < 2.0)
128
138
  rspec-support (~> 3.13.0)
129
- rspec-rails (7.1.0)
130
- actionpack (>= 7.0)
131
- activesupport (>= 7.0)
132
- railties (>= 7.0)
139
+ rspec-rails (8.0.2)
140
+ actionpack (>= 7.2)
141
+ activesupport (>= 7.2)
142
+ railties (>= 7.2)
133
143
  rspec-core (~> 3.13)
134
144
  rspec-expectations (~> 3.13)
135
145
  rspec-mocks (~> 3.13)
136
146
  rspec-support (~> 3.13)
137
- rspec-support (3.13.2)
138
- rubocop (1.69.2)
147
+ rspec-support (3.13.6)
148
+ rubocop (1.80.2)
139
149
  json (~> 2.3)
140
- language_server-protocol (>= 3.17.0)
150
+ language_server-protocol (~> 3.17.0.2)
151
+ lint_roller (~> 1.1.0)
141
152
  parallel (~> 1.10)
142
153
  parser (>= 3.3.0.2)
143
154
  rainbow (>= 2.2.2, < 4.0)
144
155
  regexp_parser (>= 2.9.3, < 3.0)
145
- rubocop-ast (>= 1.36.2, < 2.0)
156
+ rubocop-ast (>= 1.46.0, < 2.0)
146
157
  ruby-progressbar (~> 1.7)
147
158
  unicode-display_width (>= 2.4.0, < 4.0)
148
- rubocop-ast (1.37.0)
149
- parser (>= 3.3.1.0)
150
- rubocop-performance (1.23.0)
151
- rubocop (>= 1.48.1, < 2.0)
152
- rubocop-ast (>= 1.31.1, < 2.0)
159
+ rubocop-ast (1.48.0)
160
+ parser (>= 3.3.7.2)
161
+ prism (~> 1.4)
162
+ rubocop-performance (1.25.0)
163
+ lint_roller (~> 1.1)
164
+ rubocop (>= 1.75.0, < 2.0)
165
+ rubocop-ast (>= 1.38.0, < 2.0)
153
166
  ruby-progressbar (1.13.0)
154
167
  securerandom (0.4.1)
155
- standard (1.43.0)
168
+ standard (1.51.1)
156
169
  language_server-protocol (~> 3.17.0.2)
157
170
  lint_roller (~> 1.0)
158
- rubocop (~> 1.69.1)
171
+ rubocop (~> 1.80.2)
159
172
  standard-custom (~> 1.0.0)
160
- standard-performance (~> 1.6)
173
+ standard-performance (~> 1.8)
161
174
  standard-custom (1.0.2)
162
175
  lint_roller (~> 1.0)
163
176
  rubocop (~> 1.50)
164
- standard-performance (1.6.0)
177
+ standard-performance (1.8.0)
165
178
  lint_roller (~> 1.1)
166
- rubocop-performance (~> 1.23.0)
167
- stringio (3.1.2)
168
- thor (1.3.2)
179
+ rubocop-performance (~> 1.25.0)
180
+ stringio (3.1.8)
181
+ thor (1.4.0)
182
+ tsort (0.2.0)
169
183
  tzinfo (2.0.6)
170
184
  concurrent-ruby (~> 1.0)
171
- unicode-display_width (3.1.3)
172
- unicode-emoji (~> 4.0, >= 4.0.4)
173
- unicode-emoji (4.0.4)
174
- uri (1.0.3)
185
+ unicode-display_width (3.2.0)
186
+ unicode-emoji (~> 4.1)
187
+ unicode-emoji (4.1.0)
188
+ uri (1.1.1)
175
189
  useragent (0.16.11)
176
- zeitwerk (2.7.1)
190
+ zeitwerk (2.7.3)
177
191
 
178
192
  PLATFORMS
179
193
  arm64-darwin-23
194
+ arm64-darwin-24
180
195
  x86_64-darwin-20
181
196
  x86_64-darwin-21
182
197
  x86_64-linux
@@ -20,12 +20,13 @@ module RailsTemplate18f
20
20
  environment "config.active_storage.service = :local", env: "ci"
21
21
  append_to_file "config/storage.yml", <<~EOYAML
22
22
 
23
+ <% cgc = CloudGovConfig.new %>
23
24
  amazon:
24
25
  service: S3
25
- access_key_id: <%= CloudGovConfig.dig(:s3, :credentials, :access_key_id) %>
26
- secret_access_key: <%= CloudGovConfig.dig(:s3, :credentials, :secret_access_key) %>
26
+ access_key_id: <%= cgc.dig(:s3, :credentials, :access_key_id) %>
27
+ secret_access_key: <%= cgc.dig(:s3, :credentials, :secret_access_key) %>
27
28
  region: us-gov-west-1
28
- bucket: <%= CloudGovConfig.dig(:s3, :credentials, :bucket) %>
29
+ bucket: <%= cgc.dig(:s3, :credentials, :bucket) %>
29
30
  EOYAML
30
31
  end
31
32
 
@@ -41,7 +41,7 @@ module RailsTemplate18f
41
41
  plant-helper -f /tmp/rspec.json -c assessment-plans -d "RSpec run assessment plan"
42
42
  -t 31536000 -l #{auditree_evidence_locker}
43
43
 
44
- - name: Plan assessment results in evidence locker
44
+ - name: Plant assessment results in evidence locker
45
45
  uses: ./.github/actions/auditree-cmd
46
46
  env:
47
47
  GITHUB_TOKEN: ${{ secrets.AUDITREE_GITHUB_TOKEN }}
@@ -54,6 +54,19 @@ PLANT_HELPER_STEPS
54
54
  end
55
55
  end
56
56
 
57
+ def copy_gitlab_actions
58
+ if file_exists? ".gitlab-ci.yml"
59
+ directory "gitlab", ".gitlab"
60
+ insert_into_file ".gitlab-ci.yml", " - local: \".gitlab/auditree.yml\"\n", after: /^include:\n/
61
+ insert_into_file ".gitlab-ci.yml", " AUDITREE_VERSION: #{docker_auditree_tag}\n", after: /^variables:\n/
62
+ insert_into_file ".gitlab-ci.yml", <<EOY, after: /^\s+- bundle exec rspec\n/
63
+ artifacts:
64
+ paths:
65
+ - tmp/oscal/**/*
66
+ EOY
67
+ end
68
+ end
69
+
57
70
  def update_readme
58
71
  if file_content("README.md").match?("## Documentation")
59
72
  insert_into_file "README.md", readme_contents, after: "## Documentation\n"
@@ -74,7 +87,7 @@ PLANT_HELPER_STEPS
74
87
  end
75
88
 
76
89
  def auditree_evidence_locker
77
- options[:evidence_locker].present? ? options[:evidence_locker] : "https://github.com/GSA-TTS/TKTK_#{app_name}_evidence"
90
+ options[:evidence_locker].present? ? options[:evidence_locker] : "REPLACE_THIS_WITH_YOUR_EVIDENCE_LOCKER_REPO"
78
91
  end
79
92
 
80
93
  def git_email
@@ -98,10 +111,9 @@ PLANT_HELPER_STEPS
98
111
  1. Docker desktop must be running
99
112
  1. Initialize the config file with `bin/auditree init`
100
113
  1. Create an evidence locker repository with a default or blank README
101
- 1. Create a github personal access token to interact with the code repo and evidence locker and set as `AUDITREE_GITHUB_TOKEN` secret within your Github Actions secrets.
102
- 1. Update `config/auditree.template.json` with the repo addresses for your locker and code repos
103
- #{(options[:evidence_locker].blank? && file_exists?(".github/workflows/rspec.yml")) ? "1. Update `.github/workflows/rspec.yml` with the locker repository URL" : ""}
104
- 1. Copy the `devtools_cloud_gov` component definition into the project with the latest docker-trestle
114
+ 1. Update `config/auditree.template.json` with the repo address for your locker
115
+ #{ci_readme_contents.chomp}
116
+ 1. Copy the `devtools_cloud_gov` component definition into the project with the latest docker-trestle after [setting up docker-trestle](#initial-trestle-setup)
105
117
 
106
118
  #### Ongoing use
107
119
 
@@ -109,6 +121,24 @@ PLANT_HELPER_STEPS
109
121
  auditree and using new checks.
110
122
  README
111
123
  end
124
+
125
+ def ci_readme_contents
126
+ if file_exists? ".gitlab-ci.yml"
127
+ <<~README
128
+ 1. Remove the `repo_integrity` section of `config/auditree.template.json`
129
+ 1. Create a gitlab personal access token with `write_repository` scope to interact with the code repo and evidence locker and set as `AUDITREE_GITLAB_TOKEN` secret within your CI/CD variables.
130
+ #{"1. Update `.gitlab/auditree.yml` with the locker repository URL" if options[:evidence_locker].blank?}
131
+ README
132
+ elsif file_exists? ".github/workflows"
133
+ <<~README
134
+ 1. Update `config/auditree.template.json` with the repo address for your code repos
135
+ 1. Create a github personal access token to interact with the code repo and evidence locker and set as `AUDITREE_GITHUB_TOKEN` secret within your Github Actions secrets.
136
+ #{"1. Update `.github/workflows/rspec.yml` with the locker repository URL" if options[:evidence_locker].blank?}
137
+ README
138
+ else
139
+ ""
140
+ end
141
+ end
112
142
  end
113
143
  end
114
144
  end
@@ -0,0 +1,48 @@
1
+ .auditree:setup:
2
+ inherit:
3
+ default: false
4
+ image: "ghcr.io/gsa-tts/auditree:${AUDITREE_VERSION}"
5
+ variables:
6
+ CDEF: "${CI_PROJECT_DIR}/doc/compliance/oscal/component-definitions/devtools_cloud_gov/component-definition.json"
7
+ AUDITREE_CONFIG: "${CI_PROJECT_DIR}/config/auditree.template.json"
8
+ before_script:
9
+ - git config --global user.name "$GITLAB_USER_NAME"
10
+ - git config --global user.email "$GITLAB_USER_EMAIL"
11
+ - cf api api.fr.cloud.gov
12
+ - cd $HOME
13
+ - export GITLAB_TOKEN="auditree-gitlab-token:${AUDITREE_GITLAB_TOKEN}"
14
+
15
+ auditree:
16
+ extends: .auditree:setup
17
+ stage: scan
18
+ script:
19
+ - fetch -c "$CDEF" -t "$AUDITREE_CONFIG"
20
+ - check -c "$CDEF" -t "$AUDITREE_CONFIG" -o "$CI_PROJECT_DIR"
21
+ artifacts:
22
+ paths:
23
+ - auditree.json
24
+ rules:
25
+ - if: $CI_PIPELINE_SOURCE == "schedule"
26
+
27
+ rspec:plant:
28
+ extends: .auditree:setup
29
+ stage: test
30
+ needs: ["rspec"]
31
+ variables:
32
+ PLAN_FILE: "${CI_PROJECT_DIR}/tmp/oscal/assessment-plans/rspec/assessment-plan.json"
33
+ RESULT_FILE: "${CI_PROJECT_DIR}/tmp/oscal/assessment-results/rspec/assessment-results.json"
34
+ script:
35
+ - |
36
+ if [ -f "$PLAN_FILE" ]; then
37
+ plant-helper -f "$PLAN_FILE" -c assessment-plans -d "RSpec run assessment plan" -t 31536000 -l "<%= auditree_evidence_locker %>"
38
+ else
39
+ echo "No plan file, skipping plant"
40
+ fi
41
+ - |
42
+ if [ -f "$RESULT_FILE" ]; then
43
+ plant-helper -f "$RESULT_FILE" -c assessment-results -d "RSpec run assessment results" -t 31536000 -l "<%= auditree_evidence_locker %>"
44
+ else
45
+ echo "No result file, skipping plant"
46
+ fi
47
+ rules:
48
+ - if: $CI_PIPELINE_SOURCE != "schedule"
@@ -319,8 +319,10 @@ jobs:
319
319
  CF_USER: "$CF_USERNAME"
320
320
  path: terraform
321
321
  out: staging.out
322
- var_file: staging.tfvars
322
+ var_file: staging.env.tfvars
323
323
  var: >-
324
+ environment_type="staging",
325
+ environment_slug="staging",
324
326
  rails_master_key="$RAILS_MASTER_KEY",
325
327
  cf_user="$CF_USERNAME",
326
328
  - persist_to_workspace:
@@ -368,8 +370,10 @@ jobs:
368
370
  CF_USER: "$CF_USERNAME"
369
371
  path: terraform
370
372
  out: production.out
371
- var_file: production.tfvars
373
+ var_file: production.env.tfvars
372
374
  var: >-
375
+ environment_type="production",
376
+ environment_slug="production",
373
377
  rails_master_key="$PRODUCTION_RAILS_MASTER_KEY",
374
378
  cf_user="$CF_USERNAME",
375
379
  - persist_to_workspace:
@@ -12,14 +12,6 @@ module RailsTemplate18f
12
12
  Install a helper class to retrieve configuration from ENV["VCAP_SERVICES"]
13
13
  DESC
14
14
 
15
- def install_climate_control
16
- return if gem_installed?("climate_control")
17
- gem_group :test do
18
- gem "climate_control", "~> 1.2"
19
- end
20
- bundle_install
21
- end
22
-
23
15
  def install_model_and_test
24
16
  copy_file "app/models/cloud_gov_config.rb"
25
17
  copy_file "spec/models/cloud_gov_config_spec.rb"
@@ -1,23 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class CloudGovConfig
4
- ENV_VARIABLE = "VCAP_SERVICES"
4
+ attr_reader :vcap_services
5
5
 
6
- def self.dig(*path)
7
- return nil if ENV[ENV_VARIABLE].blank?
8
- first, *rest = path
9
- vcap_services[first]&.first&.dig(*rest)
10
- end
11
-
12
- def self.vcap_services
13
- if Rails.env.test?
14
- parse_env
15
- else
16
- @vcap_services ||= parse_env
17
- end
6
+ def initialize(env = ENV["VCAP_SERVICES"])
7
+ @vcap_services = env.blank? ? {} : JSON.parse(env).with_indifferent_access
18
8
  end
19
9
 
20
- private_class_method def self.parse_env
21
- JSON.parse(ENV[ENV_VARIABLE]).with_indifferent_access
10
+ def dig(*path)
11
+ first, *rest = path
12
+ vcap_services[first]&.first&.dig(*rest)
22
13
  end
23
14
  end
@@ -3,35 +3,29 @@
3
3
  require "rails_helper"
4
4
 
5
5
  RSpec.describe CloudGovConfig, type: :model do
6
- subject { described_class }
7
-
8
- describe ".dig" do
9
- context "VCAP_SERVICES is blank" do
10
- it "returns nil" do
11
- expect(subject.dig(:s3, :credentials, :bucket)).to be_nil
6
+ describe "#dig" do
7
+ [nil, "", "{}"].each do |blank|
8
+ context "VCAP_SERVICES is #{blank.inspect}" do
9
+ subject { described_class.new blank }
10
+ it "returns nil" do
11
+ expect(subject.dig(:s3, :credentials, :bucket)).to be_nil
12
+ end
12
13
  end
13
14
  end
14
15
 
15
16
  context "VCAP_SERVICES is set" do
17
+ subject { described_class.new vcap }
16
18
  let(:bucket_name) { "bucket-name" }
17
19
  let(:vcap) {
18
20
  {
19
- s3: [
20
- {
21
- credentials: {
22
- bucket: bucket_name
23
- }
21
+ s3: [{
22
+ credentials: {
23
+ bucket: bucket_name
24
24
  }
25
- ]
26
- }
25
+ }]
26
+ }.to_json
27
27
  }
28
28
 
29
- around do |example|
30
- ClimateControl.modify VCAP_SERVICES: vcap.to_json do
31
- example.run
32
- end
33
- end
34
-
35
29
  it "can find a path" do
36
30
  expect(subject.dig(:s3, :credentials, :bucket)).to eq bucket_name
37
31
  end
@@ -17,10 +17,6 @@ module RailsTemplate18f
17
17
 
18
18
  def install_actions
19
19
  directory "github", ".github"
20
- if !oscal_dir_exists?
21
- remove_file ".github/workflows/validate-ssp.yml"
22
- remove_file ".github/workflows/assemble-ssp.yml"
23
- end
24
20
  if !terraform_manage_spaces?
25
21
  remove_file ".github/workflows/terraform-production.yml"
26
22
  remove_file ".github/workflows/deploy-production.yml"
@@ -2,11 +2,27 @@ version: 2
2
2
  updates:
3
3
  - package-ecosystem: bundler
4
4
  directory: "/"
5
+ groups:
6
+ minor-and-patch:
7
+ patterns:
8
+ - "*"
9
+ exclude-patterns:
10
+ - "rails"
11
+ update-types:
12
+ - "minor"
13
+ - "patch"
5
14
  schedule:
6
15
  interval: daily
7
16
  open-pull-requests-limit: 10
8
17
  - package-ecosystem: npm
9
18
  directory: "/"
19
+ groups:
20
+ minor-and-patch:
21
+ patterns:
22
+ - "*"
23
+ update-types:
24
+ - "minor"
25
+ - "patch"
10
26
  schedule:
11
27
  interval: daily
12
28
  open-pull-requests-limit: 10
@@ -57,7 +57,10 @@ jobs:
57
57
  apt-get install -y zip
58
58
  with:
59
59
  path: terraform
60
- var_file: terraform/production.tfvars
60
+ var_file: terraform/production.env.tfvars
61
+ variables: |
62
+ environment_type="production"
63
+ environment_slug="production"
61
64
  backend_config: >
62
65
  access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
63
66
  secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
@@ -57,7 +57,10 @@ jobs:
57
57
  apt-get install -y zip
58
58
  with:
59
59
  path: terraform
60
- var_file: terraform/staging.tfvars
60
+ var_file: terraform/staging.env.tfvars
61
+ variables: |
62
+ environment_type="staging"
63
+ environment_slug="staging"
61
64
  backend_config: >
62
65
  access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
63
66
  secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
@@ -67,7 +67,10 @@ jobs:
67
67
  apt-get install -y zip
68
68
  with:
69
69
  path: terraform
70
- var_file: terraform/production.tfvars
70
+ var_file: terraform/production.env.tfvars
71
+ variables: |
72
+ environment_type="production"
73
+ environment_slug="production"
71
74
  add_github_comment: changes-only
72
75
  backend_config: >
73
76
  access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
@@ -67,7 +67,10 @@ jobs:
67
67
  apt-get install -y zip
68
68
  with:
69
69
  path: terraform
70
- var_file: terraform/staging.tfvars
70
+ var_file: terraform/staging.env.tfvars
71
+ variables: |
72
+ environment_type="staging"
73
+ environment_slug="staging"
71
74
  add_github_comment: changes-only
72
75
  backend_config: >
73
76
  access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}