rails_template_18f 0.8.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +58 -28
  4. data/README.md +5 -5
  5. data/Rakefile +12 -0
  6. data/SECURITY.md +18 -0
  7. data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +2 -9
  8. data/lib/generators/rails_template18f/active_storage/templates/oscal/component-definitions/active_storage/component-definition.json +69 -0
  9. data/lib/generators/rails_template18f/circleci/circleci_generator.rb +3 -3
  10. data/lib/generators/rails_template18f/circleci/templates/bin/ci-server-start +1 -1
  11. data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +59 -16
  12. data/lib/generators/rails_template18f/circleci/templates/docker-compose.ci.yml +1 -0
  13. data/lib/generators/rails_template18f/circleci/templates/oscal/component-definitions/circleci/component-definition.json.tt +310 -0
  14. data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +7 -12
  15. data/lib/generators/rails_template18f/github_actions/templates/github/actions/setup-languages/action.yml.tt +1 -1
  16. data/lib/generators/rails_template18f/github_actions/templates/github/actions/setup-project/action.yml.tt +1 -0
  17. data/lib/generators/rails_template18f/github_actions/templates/github/actions/trestle-cmd/action.yml +20 -0
  18. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/assemble-ssp.yml.tt +26 -0
  19. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/brakeman-analysis.yml +6 -2
  20. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/dependency-scans.yml +4 -4
  21. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml.tt +14 -25
  22. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml.tt +14 -25
  23. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-daily-scan.yml.tt +8 -3
  24. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-scan.yml.tt +4 -3
  25. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/pa11y.yml.tt +6 -2
  26. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/rspec.yml.tt +1 -1
  27. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +20 -58
  28. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +20 -58
  29. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml.tt +46 -0
  30. data/lib/generators/rails_template18f/github_actions/templates/oscal/component-definitions/github_actions/component-definition.json.tt +310 -0
  31. data/lib/generators/rails_template18f/i18n/i18n_generator.rb +7 -6
  32. data/lib/generators/rails_template18f/i18n/templates/config/locales/en.yml.tt +1 -0
  33. data/lib/generators/rails_template18f/i18n/templates/config/locales/es.yml +2 -0
  34. data/lib/generators/rails_template18f/i18n/templates/config/locales/fr.yml +2 -0
  35. data/lib/generators/rails_template18f/i18n/templates/config/locales/zh.yml +2 -0
  36. data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +2 -37
  37. data/lib/generators/rails_template18f/newrelic/templates/oscal/component-definitions/newrelic/component-definition.json.tt +113 -0
  38. data/lib/generators/rails_template18f/oscal/oscal_generator.rb +55 -17
  39. data/lib/generators/rails_template18f/oscal/templates/bin/trestle.tt +10 -0
  40. data/lib/generators/rails_template18f/oscal/templates/doc/compliance/oscal/trestle-config.yaml.tt +6 -0
  41. data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +2 -2
  42. data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +1 -1
  43. data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +4 -4
  44. data/lib/generators/rails_template18f/terraform/templates/terraform/production/providers.tf.tt +0 -1
  45. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +4 -4
  46. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/providers.tf.tt +0 -1
  47. data/lib/rails_template18f/generators/base.rb +9 -24
  48. data/lib/rails_template18f/generators/pipeline_options.rb +0 -172
  49. data/lib/rails_template18f/version.rb +1 -1
  50. data/rails-template-18f.gemspec +6 -6
  51. data/railsrc +1 -0
  52. data/railsrc-hotwire +1 -0
  53. data/template.rb +48 -44
  54. data/templates/Brewfile +2 -2
  55. data/templates/README.md.tt +3 -4
  56. data/templates/app/assets/stylesheets/uswds-components.scss +6 -0
  57. data/templates/app/assets/stylesheets/uswds-overrides/_index.scss +2 -0
  58. data/templates/app/assets/stylesheets/uswds-overrides/_override-usa-banner.scss +13 -0
  59. data/templates/app/assets/stylesheets/uswds-overrides/_override-usa-language-selector.scss +38 -0
  60. data/templates/app/views/application/_header.html.erb +6 -5
  61. data/templates/app/views/application/_language_selector.html.erb +35 -0
  62. data/templates/app/views/application/_usa_banner.html.erb +21 -16
  63. data/templates/bin/owasp-scan +3 -3
  64. data/templates/bin/pa11y-scan +1 -1
  65. data/templates/config/environments/ci.rb +1 -0
  66. data/templates/pa11y.js +12 -0
  67. data/templates/pa11yci.js +8 -0
  68. metadata +31 -16
  69. data/templates/pa11yci +0 -9
  70. /data/lib/generators/rails_template18f/circleci/templates/{Dockerfile.tt → Dockerfile.ci.tt} +0 -0
@@ -16,4 +16,6 @@ fr:
16
16
  demo_banner: SITE DE TEST - N’utilisez pas de véritables données personnelles (il s’agit d’une démonstration seulement) - SITE DE TEST
17
17
  menu: Menu
18
18
  primary: Navigation primaire
19
+ languages:
20
+ selector: Langages
19
21
  skip_link: Passer au contenu principal
@@ -13,4 +13,6 @@ zh:
13
13
  us_flag: 美国国旗
14
14
  header:
15
15
  primary: 主导航
16
+ languages:
17
+ selector: 语言
16
18
  skip_link: 跳转到主要内容
@@ -24,7 +24,7 @@ module RailsTemplate18f
24
24
 
25
25
  def install_gem
26
26
  return if gem_installed?("newrelic_rpm")
27
- gem "newrelic_rpm", "~> 8.4"
27
+ gem "newrelic_rpm", "~> 9.10"
28
28
  bundle_install
29
29
  end
30
30
 
@@ -58,42 +58,7 @@ EOB
58
58
  end
59
59
 
60
60
  def update_oscal_doc
61
- if oscal_dir_exists?
62
- insert_into_oscal "si-4.md", <<~EOS, after: "## Implementation a.\n"
63
- New Relic is used for the purposes of monitoring and analyzing #{app_name} application data. New Relic monitors each application within #{app_name} for
64
- basic container utilization (CPU, memory, disk) as a baseline of provided metrics. New Relic dashboards are used by #{app_name} operations to obtain
65
- near real-time views into the metrics obtained from each application. New Relic provides application metrics that give insight into request/response rates,
66
- failure rates, etc. New Relic uses this data to detect anomalies (such as potential unauthorized activity) and alerts the #{app_name} team via <<INSERT NOTIFICATION CHANNEL>>
67
- in the GSA Slack. Example: a spike in failed requests may indicate an unauthorized user has entered the system and is attempting to phish for PII.
68
-
69
- 1. A subset of relevant specific metrics #{app_name} is constantly monitoring include:
70
- * Abnormal cpu, memory, and disk utilization (defined in New Relic alerting rules)
71
- * Number of incoming requests
72
- * Request response time
73
- * Application crashes (for any reason)
74
- * Response status codes (high numbers of failing requests would be abnormal)
75
- * Applications (by name)
76
- * Abnormally high request rates
77
- 1. Metrics that can be audited within #{app_name} include:
78
- * SSH Sessions (disabled in production under normal circumstances)
79
- 1. A subset of relevant incidents #{app_name} will use these metrics to protect against include:
80
- * Unauthorized Access / Intrusion to #{app_name} as an Administrator
81
- * Denial of Service (DoS)
82
- * Improper Usage
83
- * Malicious Code
84
- * System Uptime
85
- * High Resource Usage
86
-
87
- When suspicious activity is encountered #{app_name} Operations audit the event through the cloud.gov logs provided at logs.fr.cloud.gov
88
- (a Kibana instance allowing users to access, filter, and search their cloud.gov logs. These logs are retained automatically by cloud.gov for 180 days after creation.
89
- EOS
90
- insert_into_oscal "si-4.md", "The #{app_name} application logs events to stdout and stderr which are ingested by cloud.gov and New Relic.", after: "## Implementation c.\n"
91
- insert_into_oscal "si-4.md", "#{app_name} Operations are responsible for monitoring the New Relic dashboards that report on specific application events and performing follow-up investigations where necessary.", after: "## Implementation d.\n"
92
- insert_into_oscal "si-4.2.md", <<~EOS
93
- #{app_name} is monitored using New Relic Application Performance Monitoring (APM),
94
- Synthetics and Logs, which detects and alerts on abnormal responses from #{app_name} applications.
95
- EOS
96
- end
61
+ copy_oscal_component "newrelic"
97
62
  end
98
63
 
99
64
  no_tasks do
@@ -0,0 +1,113 @@
1
+ {
2
+ "component-definition": {
3
+ "uuid": "7bbcdbff-c3d8-497f-a0fc-3ec96f4acc2d",
4
+ "metadata": {
5
+ "title": "New Relic System Monitoring Component Definition.",
6
+ "last-modified": "2024-06-11T12:51:11.662524+00:00",
7
+ "version": "0.0.1",
8
+ "oscal-version": "1.1.2"
9
+ },
10
+ "components": [
11
+ {
12
+ "uuid": "8eb58925-2761-4de3-86cb-72af189fe378",
13
+ "type": "service",
14
+ "title": "New Relic",
15
+ "description": "New Relic Application Performance Monitoring",
16
+ "props": [
17
+ {
18
+ "name": "Rule_Id",
19
+ "value": "properly-configured",
20
+ "remarks": "rule-config"
21
+ },
22
+ {
23
+ "name": "Rule_Description",
24
+ "value": "System Owner has configured the system to properly utilize New Relic",
25
+ "remarks": "rule-config"
26
+ }
27
+ ],
28
+ "control-implementations": [
29
+ {
30
+ "uuid": "7ba2642f-5cfa-431c-a030-afffc4e6a8d4",
31
+ "source": "trestle://profiles/lato/profile.json",
32
+ "description": "",
33
+ "implemented-requirements": [
34
+ {
35
+ "uuid": "fae8766e-7bf2-4d77-9c88-db5b2e9a8bfd",
36
+ "control-id": "si-4",
37
+ "description": "REPLACE_ME",
38
+ "props": [
39
+ {
40
+ "name": "implementation-status",
41
+ "value": "planned"
42
+ }
43
+ ],
44
+ "statements": [
45
+ {
46
+ "statement-id": "si-4_smt.a",
47
+ "uuid": "850fcb05-724a-46a3-9faf-2574624ef1ee",
48
+ "description": "New Relic is used for the purposes of monitoring and analyzing <%= app_name %> application data. New Relic monitors each application within <%= app_name %> for basic container utilization (CPU, memory, disk) as a baseline of provided metrics. New Relic dashboards are used by <%= app_name %> operations to obtain near real-time views into the metrics obtained from each application. New Relic provides application metrics that give insight into request/response rates, failure rates, etc. New Relic uses this data to detect anomalies (such as potential unauthorized activity) and alerts the <%= app_name %> team via <<INSERT NOTIFICATION CHANNEL>> in the GSA Slack. Example: a spike in failed requests may indicate an unauthorized user has entered the system and is attempting to phish for PII.\n\n1. A subset of relevant specific metrics <%= app_name %> is constantly monitoring include:\n* Abnormal cpu, memory, and disk utilization (defined in New Relic alerting rules)\n* Number of incoming requests\n* Request response time\n* Application crashes (for any reason)\n* Response status codes (high numbers of failing requests would be abnormal)\n* Applications (by name)\n* Abnormally high request rates\n1. Metrics that can be audited within <%= app_name %> include:\n* SSH Sessions (disabled in production under normal circumstances)\n1. A subset of relevant incidents <%= app_name %> will use these metrics to protect against include:\n* Unauthorized Access / Intrusion to <%= app_name %> as an Administrator\n* Denial of Service (DoS)\n* Improper Usage\n* Malicious Code\n* System Uptime\n* High Resource Usage\n\nWhen suspicious activity is encountered <%= app_name %> Operations audit the event through the cloud.gov logs provided at logs.fr.cloud.gov\n(a Kibana instance allowing users to access, filter, and search their cloud.gov logs. These logs are retained automatically by cloud.gov for 180 days after creation.",
49
+ "props": [
50
+ {
51
+ "name": "Rule_Id",
52
+ "value": "properly-configured"
53
+ },
54
+ {
55
+ "name": "implementation-status",
56
+ "value": "implemented"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "statement-id": "si-4_smt.c",
62
+ "uuid": "dddcc80f-f715-4ee8-acf0-e4d9df3576c5",
63
+ "description": "The <%= app_name %> application logs events to stdout and stderr which are ingested by cloud.gov and New Relic.",
64
+ "props": [
65
+ {
66
+ "name": "Rule_Id",
67
+ "value": "properly-configured"
68
+ },
69
+ {
70
+ "name": "implementation-status",
71
+ "value": "implemented"
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "statement-id": "si-4_smt.d",
77
+ "uuid": "017e8dab-cbd3-4054-9185-cf24d6dcd6b9",
78
+ "description": "\\<%= app_name %> Operations are responsible for monitoring the New Relic dashboards that report on specific application events and performing follow-up investigations where necessary.",
79
+ "props": [
80
+ {
81
+ "name": "Rule_Id",
82
+ "value": "properly-configured"
83
+ },
84
+ {
85
+ "name": "implementation-status",
86
+ "value": "implemented"
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "uuid": "fc6a4cb3-5160-4792-a835-bfdf92d97a33",
94
+ "control-id": "si-4.2",
95
+ "description": "\\<%= app_name %> is monitored using New Relic Application Performance Monitoring (APM), Synthetics and Logs, which detects and alerts on abnormal responses from <%= app_name %> applications in real time.",
96
+ "props": [
97
+ {
98
+ "name": "Rule_Id",
99
+ "value": "properly-configured"
100
+ },
101
+ {
102
+ "name": "implementation-status",
103
+ "value": "implemented"
104
+ }
105
+ ]
106
+ }
107
+ ]
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ }
@@ -7,35 +7,41 @@ module RailsTemplate18f
7
7
  class OscalGenerator < ::Rails::Generators::Base
8
8
  include Base
9
9
 
10
- class_option :oscal_repo, required: true, desc: "GitHub Repo containing Compliance-Template fork"
11
- class_option :detach, type: :boolean, default: false, desc: "Copy OSCAL files into repo, rather than using a submodule"
12
- class_option :branch, desc: "Name of the branch to switch to when using a submodule. Defaults to `app_name`"
10
+ class_option :oscal_repo, desc: "GitHub Repo to store compliance documents within. Leave blank to check docs into the app repo"
11
+ class_option :tag, desc: "Which docker-trestle tag to use. Defaults to `latest`"
12
+ class_option :branch, desc: "Name of the branch to switch to when using a submodule. Defaults to `main`"
13
13
 
14
14
  desc <<~DESC
15
15
  Description:
16
- Add a fork of https://github.com/GSA-TTS/compliance-template.git as a
17
- submodule for documenting security controls.
16
+ Set up doc/compliance/oscal as a working directory for use with https://github.com/GSA-TTS/docker-trestle.
18
17
 
19
18
  This generator is still experimental.
20
19
 
21
- Prerequisite:
20
+ Optional Prerequisite:
22
21
 
23
- Fork the compliance-template repo for your own use. Updates to the documentation
22
+ Set up a separate private repository to store the compliance documentation in if access control needs to be
23
+ tighter than for the code. This generator will set up the directory as a submodule so developers with access
24
+ can easily update documentation alongside code. Updates to the documentation
24
25
  will be pushed to this fork, not the rails app repository.
25
26
  DESC
26
27
 
27
- def copy_template_files
28
- if detach?
29
- git clone: "#{options[:oscal_repo]} doc/compliance/oscal"
30
- remove_dir "doc/compliance/oscal/.git"
31
- else
28
+ def configure_compliance_files
29
+ if use_submodule?
32
30
  git submodule: "add #{options[:oscal_repo]} doc/compliance/oscal"
33
31
  inside "doc/compliance/oscal" do
34
32
  git switch: "-c #{branch_name}"
35
33
  end
34
+ else
35
+ create_file "doc/compliance/oscal/.keep"
36
36
  end
37
37
  end
38
38
 
39
+ def copy_templates
40
+ template "bin/trestle"
41
+ chmod "bin/trestle", 0o755
42
+ template "doc/compliance/oscal/trestle-config.yaml"
43
+ end
44
+
39
45
  def update_readme
40
46
  if file_content("README.md").match?("## Documentation")
41
47
  insert_into_file "README.md", readme_contents, after: "## Documentation\n"
@@ -45,7 +51,7 @@ module RailsTemplate18f
45
51
  end
46
52
 
47
53
  def configure_submodule
48
- unless detach?
54
+ if use_submodule?
49
55
  git config: "-f .gitmodules submodule.\"doc/compliance/oscal\".branch #{branch_name}"
50
56
  git config: "diff.submodule log"
51
57
  git config: "status.submodulesummary 1"
@@ -53,9 +59,24 @@ module RailsTemplate18f
53
59
  end
54
60
  end
55
61
 
62
+ def configure_gitignore
63
+ unless skip_git? || use_submodule?
64
+ append_to_file ".gitignore", <<~EOM
65
+
66
+ # Trestle working files
67
+ doc/compliance/oscal/.trestle/_trash
68
+ doc/compliance/oscal/.trestle/cache
69
+ EOM
70
+ end
71
+ end
72
+
56
73
  no_tasks do
57
74
  def branch_name
58
- options[:branch].present? ? options[:branch] : app_name
75
+ options[:branch].present? ? options[:branch] : "main"
76
+ end
77
+
78
+ def docker_trestle_tag
79
+ options[:tag].present? ? options[:tag] : "latest"
59
80
  end
60
81
 
61
82
  def readme_contents
@@ -64,8 +85,25 @@ module RailsTemplate18f
64
85
  ### Compliance Documentation
65
86
 
66
87
  Security Controls should be documented within doc/compliance/oscal.
88
+
89
+ * Run `bin/trestle` to start the trestle CLI.
90
+ * Run `bin/trestle SCRIPT_NAME` to run a single trestle script
91
+
92
+ #### Initial trestle setup.
93
+
94
+ These steps must happen once per project.
95
+
96
+ 1. Docker desktop must be running
97
+ 1. Start the trestle cli with `bin/trestle`
98
+ 1. Copy the `cloud_gov` component to the local workspace with `copy-component -n cloud_gov`
99
+ 1. Generate the initial markdown with `generate-ssp-markdown`
100
+
101
+ #### Ongoing use
102
+
103
+ See the [docker-trestle README](https://github.com/gsa-tts/docker-trestle) for help with the workflow
104
+ for using those scripts for editing the SSP.
67
105
  README
68
- return content if detach?
106
+ return content unless use_submodule?
69
107
  <<~README
70
108
  #{content}
71
109
 
@@ -94,8 +132,8 @@ module RailsTemplate18f
94
132
  README
95
133
  end
96
134
 
97
- def detach?
98
- options[:detach]
135
+ def use_submodule?
136
+ options[:oscal_repo].present?
99
137
  end
100
138
  end
101
139
  end
@@ -0,0 +1,10 @@
1
+ #! /usr/bin/env bash
2
+
3
+ command="bash"
4
+ if [ "$1" != "" ]; then
5
+ command=$1
6
+ fi
7
+
8
+ oscal_location="$(dirname "$(realpath "$0")")/../doc/compliance/oscal"
9
+
10
+ docker run -it --rm -v $oscal_location:/app/docs:rw ghcr.io/gsa-tts/trestle:<%= docker_trestle_tag %> $command
@@ -0,0 +1,6 @@
1
+ # docker-trestle configuration file
2
+ # for ease of future rails_template18f generator use, keep the components list last in this file
3
+ system-name: "<%= app_name %>"
4
+ profile: lato
5
+ components:
6
+ - cloud_gov
@@ -14,7 +14,7 @@ module RailsTemplate18f
14
14
 
15
15
  def install_gem
16
16
  return if gem_installed?("sidekiq")
17
- gem "sidekiq", "~> 6.4"
17
+ gem "sidekiq", "~> 7.2"
18
18
  bundle_install
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ module RailsTemplate18f
24
24
  # queue for sidekiq jobs
25
25
  brew "redis"
26
26
  EOB
27
- insert_into_file "README.md", indent("* [redis]()\n"), after: /\* Install homebrew dependencies: `brew bundle`\n/
27
+ insert_into_file "README.md", indent("* [redis](https://redis.io/)\n"), after: /\* Install homebrew dependencies: `brew bundle`\n/
28
28
  end
29
29
 
30
30
  def configure_server_runner
@@ -89,7 +89,7 @@ The below steps rely on you first configuring access to the Terraform state in s
89
89
 
90
90
  1. Run terraform from your new environment directory with
91
91
  ```bash
92
- terraform init
92
+ terraform init -backend-config="profile=<%= app_name %>-terraform-backend"
93
93
  terraform plan
94
94
  ```
95
95
 
@@ -1,8 +1,8 @@
1
1
  locals {
2
- cf_org_name = "<%= cloud_gov_organization %>"
3
- cf_space_name = "<%= cloud_gov_production_space %>"
4
- env = "production"
5
- app_name = "<%= app_name %>"
2
+ cf_org_name = "<%= cloud_gov_organization %>"
3
+ cf_space_name = "<%= cloud_gov_production_space %>"
4
+ env = "production"
5
+ app_name = "<%= app_name %>"
6
6
  }
7
7
 
8
8
  module "database" {
@@ -12,7 +12,6 @@ terraform {
12
12
  key = "terraform.tfstate.prod"
13
13
  encrypt = "true"
14
14
  region = "us-gov-west-1"
15
- profile = "<%= app_name %>-terraform-backend"
16
15
  }
17
16
  }
18
17
 
@@ -1,8 +1,8 @@
1
1
  locals {
2
- cf_org_name = "<%= cloud_gov_organization %>"
3
- cf_space_name = "<%= cloud_gov_staging_space %>"
4
- env = "staging"
5
- app_name = "<%= app_name %>"
2
+ cf_org_name = "<%= cloud_gov_organization %>"
3
+ cf_space_name = "<%= cloud_gov_staging_space %>"
4
+ env = "staging"
5
+ app_name = "<%= app_name %>"
6
6
  }
7
7
 
8
8
  module "database" {
@@ -12,7 +12,6 @@ terraform {
12
12
  key = "terraform.tfstate.stage"
13
13
  encrypt = "true"
14
14
  region = "us-gov-west-1"
15
- profile = "<%= app_name %>-terraform-backend"
16
15
  }
17
16
  }
18
17
 
@@ -18,7 +18,6 @@ module RailsTemplate18f
18
18
 
19
19
  included do
20
20
  self.source_path = RailsTemplate18f::Generators.const_source_location(name).first
21
- class_option :oscal_profile, desc: "Name of the OSCAL profile to populate. Only needed if multiple folders are present in doc/compliance/oscal/dist/system-security-plans"
22
21
  end
23
22
 
24
23
  private
@@ -60,33 +59,19 @@ module RailsTemplate18f
60
59
  Dir.exist? file_path("doc/compliance/oscal")
61
60
  end
62
61
 
63
- def insert_into_oscal(filename, content, after: "## What is the solution and how is it implemented?\n")
64
- content = <<~EOS
65
-
66
- ### #{app_name}
67
-
68
- #{content}
69
- EOS
70
- begin
71
- insert_into_file File.join(oscal_path, filename), content, after: after
72
- rescue Thor::Error => ex
73
- warn ex.message
62
+ def copy_oscal_component(component_name)
63
+ template "oscal/component-definitions/#{component_name}/component-definition.json",
64
+ File.join(oscal_component_path, component_name, "component-definition.json")
65
+ if oscal_dir_exists?
66
+ insert_into_file "doc/compliance/oscal/trestle-config.yaml", " - #{component_name}\n"
74
67
  end
75
68
  end
76
69
 
77
- def oscal_path
78
- @oscal_path ||= if options[:oscal_profile].present?
79
- file_path(File.join("doc/compliance/oscal/dist/system-security-plans", options[:oscal_profile]))
70
+ def oscal_component_path
71
+ if oscal_dir_exists?
72
+ file_path("doc/compliance/oscal/component-definitions")
80
73
  else
81
- ssp_dir = file_path("doc/compliance/oscal/dist/system-security-plans")
82
- profiles = Dir.children(ssp_dir).select { |f| File.directory?(File.join(ssp_dir, f)) }
83
- if profiles.empty?
84
- fail "No OSCAL profiles found. Please run `make generate` from the `doc/compliance/oscal` folder"
85
- elsif profiles.count > 1
86
- fail "Multiple OSCAL profiles found. Please specify which one to update by passing the `--oscal-profile` option"
87
- else
88
- File.join(ssp_dir, profiles.first)
89
- end
74
+ file_path("doc/compliance/oscal-component-definitions")
90
75
  end
91
76
  end
92
77
 
@@ -13,178 +13,6 @@ module RailsTemplate18f
13
13
  def terraform?
14
14
  options[:terraform].nil? ? terraform_dir_exists? : options[:terraform]
15
15
  end
16
-
17
- def update_cicd_oscal_docs(ci_name)
18
- if oscal_dir_exists?
19
- update_ca7_oscal_doc
20
- update_cm2_oscal_doc(ci_name)
21
- update_cm3_oscal_doc(ci_name)
22
- update_ra5_oscal_doc
23
- update_sa11_oscal_doc(ci_name)
24
- update_sa22_oscal_doc
25
- update_sc281_oscal_doc(ci_name)
26
- update_si2_oscal_doc
27
- update_si10_oscal_doc
28
- update_sr3_oscal_doc(ci_name)
29
- end
30
- end
31
-
32
- private
33
-
34
- def update_ca7_oscal_doc
35
- insert_into_oscal "ca-7.md", <<~EOS, after: "## Implementation a.\n"
36
- * #{app_name} DevOps staff review OWASP and Dependency scans every build, or at least weekly.
37
- * #{app_name} DevOps staff and the GSA ISSO review Web Application vulnerability scans on a weekly basis.
38
- * #{app_name} Administrators and DevOps staff review changes for potential security impact and engage the #{app_name} ISSO and ISSM who will review or engage assessment staff as needed.
39
- EOS
40
- end
41
-
42
- def update_cm2_oscal_doc(ci)
43
- insert_into_oscal "cm-2.2.md", <<~EOS
44
- The #{app_name} team develops, documents, and maintains a current baseline for the #{app_name} application
45
- components under configuration control, managed via git and github.com, and orchestrated using #{ci}
46
- and the cloud.gov Cloud Foundry CLI.
47
-
48
- Note: All cloud.gov brokered services (including databases) are fully managed by the cloud.gov platform.
49
- Due to this, the configuration and security of these services are not included in the #{app_name} configuration baseline.
50
- EOS
51
- end
52
-
53
- def update_cm3_oscal_doc(ci)
54
- insert_into_oscal "cm-3.1.md", <<~EOS, after: "## Implementation (f)\n"
55
- #{app_name} employs #{ci} to execute proposed changes to the information system.
56
- #{app_name} Administrators and #{app_name} Developers are automatically notified of
57
- the success or failure of the change execution via the GitHub notification system.
58
- EOS
59
- end
60
-
61
- def update_ra5_oscal_doc
62
- insert_into_oscal "ra-5.md", <<~EOS, after: "## Implementation a.\n"
63
- Any vulnerabilities in #{app_name} would have to be introduced at time of deployment because #{app_name}
64
- is a set of cloud.gov managed applications with SSH disabled in Production. #{app_name} monitors for
65
- vulnerabilities by ensuring that scans for vulnerabilities in the information system and hosted applications occur
66
- daily and when new code is deployed.
67
-
68
- OWASP ZAP scans are built into the #{app_name} CI/CD pipeline and runs a series of web vulnerability scans before
69
- a successful deploy can be made to cloud.gov. Any issues or alerts caused by the scan are documented by #{app_name}
70
- Operations and cause the deployment to fail. Issues are tracked in GitHub. The issue posted will provide information
71
- on which endpoints are vulnerable and the level of vulnerability, ranging from **False Positive** to **High**.
72
- The issue also provides a detailed report formatted in html, json, and markdown.
73
-
74
- #{app_name} Administrators are responsible for reporting any new vulnerabilities reported by the OWASP ZAP scan to the #{app_name} ISSO.
75
- EOS
76
- insert_into_oscal "ra-5.md", <<~EOS, after: "## Implementation b.\n"
77
- 1. Alerts from each ZAP vulnerability scan are automatically reported in GitHub as an issue on the #{app_name} repository.
78
- This issue will enumerate each finding and detail the type and severity of the vulnerability. #{app_name} Developers and
79
- #{app_name} Administrators receive automated alerts via GitHub of the issues to remediate. Scan results are sent to the
80
- #{app_name} System Owner by #{app_name} Administrators. The vulnerabilities are analyzed and prioritized within GitHub
81
- based on input from the #{app_name} System Owner and ISSO.
82
- 1. The ZAP report contains vulnerabilities grouped by type and by risk level. The report also provides a detailed report
83
- formatted in html, json, and markdown. The reported issues also include the CVE item associated with the vulnerability.
84
- 1. Vulnerabilities are classified by ZAP under a level range from **False Positive** to **High**. The impact level is
85
- used to drive the priority of the effort to remediate.
86
- EOS
87
- insert_into_oscal "ra-5.md", <<~EOS, after: "## Implementation c.\n"
88
- The ZAP vulnerability report contains information about how the attack was made and suggested solutions for each vulnerability found.
89
- Any static code analysis findings identified during automation as part of the GitHub pull request process must be reviewed, analyzed,
90
- and resolved by the #{app_name} Developer before the team can merge the pull request.
91
- EOS
92
- end
93
-
94
- def update_sa11_oscal_doc(ci)
95
- insert_into_oscal "sa-11.md", <<~EOS, after: "## Implementation a.\n"
96
- The CI/CD pipeline utilizes multiple tools to perform static code analysis for security and privacy:
97
-
98
- * **Brakeman** is a static code scanner designed to find security issues in Ruby on Rails code. It can flag potential SQL injection,
99
- Command Injection, open redirects, and other common vulnerabilities.
100
- * **bundle-audit** checks Ruby dependencies against a database of known CVE numbers.
101
- * **yarn audit** checks Javascript dependencies against a database of known CVE numbers.
102
- * **OWASP ZAP** is a dynamic security scanner that can simulate actual attacks on a running server.
103
-
104
- An additional RAILS_ENV has been created called ci. It inherits from production to ensure that the system being tested is as close as possible to production while allowing for overrides such as bypassing authentication in a secure way.
105
- EOS
106
- insert_into_oscal "sa-11.md", <<~EOS, after: "## Implementation b.\n"
107
- #{ci} runs rspec tests for unit, integration, and regression testing at every code push to github.com and every Pull Request.
108
- EOS
109
- insert_into_oscal "sa-11.md", <<~EOS, after: "## Implementation c.\n"
110
- Test and scan results can be viewed from within #{ci} for every run of the pipeline.
111
-
112
- When #{ci} is run as a result of a Pull Request, the status of the tests and scans are automatically reported as part of the Pull Request.
113
- EOS
114
- end
115
-
116
- def update_sa22_oscal_doc
117
- insert_into_oscal "sa-22.md", <<~EOS, after: "## Implementation a.\n"
118
- The #{app_name} application is built and supported by the #{app_name} DevOps staff.
119
-
120
- #{app_name} utilizes public open source Ruby and NodeJS components.
121
-
122
- #{app_name} utilizes dependency scanning tools Bundle Audit and Yarn Audit to find vulnerable or insecure dependencies.
123
-
124
- If a vulnerable or insecure dependency is found it will be upgraded or replaced. Additionally the #{app_name} team code
125
- review processes include a review of the health (up to date, supported, many individuals involved) of direct open source dependencies.
126
- EOS
127
- insert_into_oscal "sa-22.md", <<~EOS, after: "## Implementation b.\n"
128
- There are currently no unsupported system components within #{app_name}. In case an unsupported system component is required
129
- to maintain #{app_name}, the #{app_name} System Owner will be consulted to make a determination in coordination with the #{app_name} ISSO and ISSM.
130
- EOS
131
- end
132
-
133
- def update_sc281_oscal_doc(ci)
134
- insert_into_oscal "sc-28.1.md", <<~EOS
135
- As an additional layer of protection, all PII data is encrypted using [Active Record Encryption — Ruby on Rails Guides](https://guides.rubyonrails.org/active_record_encryption.html).
136
- This encryption is implemented in a using non-deterministic AES-256-GCM through Ruby's openssl library with a 256-bit key and a random initialization vector {rails crypto module}.
137
-
138
- The Data Encryption Key is stored in the credentials.yml file in an encrypted format by Ruby's openssl library using the AES-128-GCM cipher,
139
- and is built into the application package.
140
-
141
- The credentials.yml decryption key is stored in #{ci} and injected into the running application as an environmental variable. The application then uses this key
142
- to decrypt the credentials.yml file and obtain the Data Encryption Key.
143
-
144
- A backup of the key is stored by the Lead Developer and System Owner within a keepass database stored in Google Drive.
145
- EOS
146
- end
147
-
148
- def update_si2_oscal_doc
149
- insert_into_oscal "si-2.md", <<~EOS, after: "Implementation a.\n"
150
- Flaw and vulnerability checks are built into the #{app_name} CI/CD pipeline and automated to ensure compliance.
151
- Dynamic vulnerability scans are performed against #{app_name} before a successful deployment and reports issues after every scan.
152
- Compliance is documented in sections SA-11 and RA-5. The #{app_name} DevOps team uses GitHub as the Product Backlog to
153
- track and prioritize issues related to system flaws.
154
-
155
- The responsibility of remediating flaws and vulnerabilities (once a remediation is available) falls on the #{app_name} Developer,
156
- who updates the #{app_name} code and deploys fixes as part of the normal development and CI/CD process.
157
- EOS
158
- insert_into_oscal "si-2.md", <<~EOS, after: "Implementation b.\n"
159
- Any flaws or vulnerabilities resolved in #{app_name} result in a GitHub issue for triage via the #{app_name} CM Configuration Control
160
- process described in CM-2(2). After resolving a vulnerability or flaw in #{app_name}, unit tests and integration tests are updated to
161
- prevent further inclusion of similar flaws.
162
-
163
- * All GitHub tickets have accompanying Acceptance Criteria that are used to create unit tests.
164
- * Unit tests are run on the Development environment when new code is pushed.
165
- * Integration tests are run on the Test environment when the remediation is deployed via the CI/CD process to ensure that the production
166
- environment does not suffer from any side effects of the vulnerability remediation.
167
- * Integration tests are run on the Prod environment when the remediation is deployed via the CI/CD process to validate the remediation and application functionality.
168
- * All findings that are not remediated immediately are tracked in the #{app_name} Plan of Action and Milestones (POAM) by #{app_name} Operations and the #{app_name} ISSO.
169
- EOS
170
- end
171
-
172
- def update_si10_oscal_doc
173
- insert_into_oscal "si-10.md", <<~EOS
174
- All inputs from the end user are parameterized prior to use to avoid potential sql injection.
175
-
176
- #{app_name} utilizes Brakeman scanner as part of the CI/CD pipeline which further identifies coding practices
177
- that may lead to application vulnerabilities that are a result of improper input validation.
178
- EOS
179
- end
180
-
181
- def update_sr3_oscal_doc(ci)
182
- insert_into_oscal "sr-3.md", <<~EOS, after: "Implementation b.\n"
183
- A complete Software Bill of Materials (SBOM) for all Ruby dependencies is automatically
184
- generated by #{ci} on each push to GitHub as well as on a nightly basis. These can be downloaded
185
- from the applicable artifact section for each CI job.
186
- EOS
187
- end
188
16
  end
189
17
  end
190
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTemplate18f
4
- VERSION = "0.8.2"
4
+ VERSION = "1.0.0"
5
5
  end