rails_template_18f 1.1.0 → 1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +57 -55
- data/README.md +102 -29
- data/exe/rails_template_18f +0 -21
- data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +2 -2
- data/lib/generators/rails_template18f/auditree/auditree_generator.rb +34 -3
- data/lib/generators/rails_template18f/auditree/templates/bin/auditree.tt +85 -11
- data/lib/generators/rails_template18f/auditree/templates/github/actions/auditree-cmd/action.yml.tt +17 -6
- data/lib/generators/rails_template18f/auditree/templates/github/workflows/auditree-validation.yml.tt +2 -6
- data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +13 -7
- data/lib/generators/rails_template18f/cloud_gov_config/cloud_gov_config_generator.rb +1 -1
- data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +0 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +25 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/assemble-ssp.yml.tt +12 -3
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/brakeman-analysis.yml +1 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml.tt +8 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml.tt +8 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/rspec.yml.tt +9 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/{validate-ssp.yml.tt → validate-ssp.yml} +1 -1
- data/lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb +12 -20
- data/lib/generators/rails_template18f/i18n_js/templates/app/javascript/i18n.js +11 -0
- data/lib/generators/rails_template18f/i18n_js/templates/config/i18n-js.yml +4 -0
- data/lib/generators/rails_template18f/i18n_js/templates/config/initializers/i18n_js.rb +5 -0
- data/lib/generators/rails_template18f/i18n_js/templates/lib/tasks/i18n.rake +8 -7
- data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +1 -1
- data/lib/generators/rails_template18f/oscal/oscal_generator.rb +14 -1
- data/lib/generators/rails_template18f/oscal/templates/bin/trestle.tt +4 -1
- data/lib/generators/rails_template18f/oscal/templates/github/actions/trestle-cmd/action.yml.tt +16 -0
- data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +136 -0
- data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +1 -1
- data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +2 -2
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/main.tf.tt +1 -1
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/run.sh.tt +2 -1
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt +1 -1
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +25 -5
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +22 -4
- data/lib/rails_template18f/generators/base.rb +7 -0
- data/lib/rails_template18f/generators/cloud_gov_options.rb +7 -27
- data/lib/rails_template18f/generators/cloud_gov_parsing.rb +41 -0
- data/lib/rails_template18f/generators.rb +1 -0
- data/lib/rails_template18f/version.rb +1 -1
- data/rails-template-18f.gemspec +3 -3
- data/railsrc +2 -0
- data/railsrc-hotwire +2 -0
- data/template.rb +19 -12
- data/templates/bin/ops/create_service_account.sh.tt +14 -2
- data/templates/bin/ops/destroy_service_account.sh.tt +0 -3
- data/templates/lib/tasks/scanning.rake +1 -1
- data/templates/manifest.yml.tt +1 -1
- metadata +19 -14
- data/lib/generators/rails_template18f/github_actions/templates/github/actions/trestle-cmd/action.yml +0 -20
- data/lib/rails_template18f/app_updater.rb +0 -19
- /data/lib/generators/rails_template18f/terraform/templates/terraform/production/{providers.tf.tt → providers.tf} +0 -0
- /data/lib/generators/rails_template18f/terraform/templates/terraform/staging/{providers.tf.tt → providers.tf} +0 -0
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
#! /usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
image="ghcr.io/gsa-tts/auditree"
|
|
4
|
+
tag="<%= docker_auditree_tag %>"
|
|
5
|
+
cwd=`pwd`
|
|
6
|
+
cdef="doc/compliance/oscal/component-definitions/devtools_cloud_gov/component-definition.json"
|
|
7
|
+
config="config/auditree.template.json"
|
|
8
|
+
email="<%= git_email %>"
|
|
9
|
+
|
|
2
10
|
usage="
|
|
3
|
-
$0: Run auditree docker image.
|
|
11
|
+
$0: Run auditree docker image: $image.
|
|
4
12
|
|
|
5
13
|
Usage:
|
|
6
14
|
$0 -h
|
|
7
|
-
$0
|
|
8
|
-
$0
|
|
9
|
-
$0
|
|
10
|
-
|
|
15
|
+
$0 [-a AUDITREE_CONFIG_TEMPLATE] [-c CDEF] [-v EXTRA_VOLUME] [-e GIT_EMAIL] [-t TAG] CMD
|
|
16
|
+
$0 [-a AUDITREE_CONFIG_TEMPLATE] init
|
|
17
|
+
$0 [-o] check
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
-h: show help and exit
|
|
21
|
+
-a: Auditree config. Given relative to \"$cwd\" Defaults to \"$config\". Location to write for init CMD
|
|
22
|
+
-c: component definition. Given relative to \"$cwd\" Defaults to \"$cdef\"
|
|
23
|
+
-v: volume to mount. Given as a docker -v argument except that the first part is relative to \"$cwd\"
|
|
24
|
+
-e: Git email. Defaults to \"$email\"
|
|
25
|
+
-t: Auditree docker tag. Defaults to \"$tag\"
|
|
26
|
+
-o: Write assessment results to \"$cwd/tmp/auditree/auditree.json\". Only applicable for \"check\"
|
|
27
|
+
CMD: The command to run. Defaults to \"bash\"
|
|
11
28
|
|
|
12
29
|
Notes:
|
|
13
30
|
The following environment variables will be passed through to the docker image:
|
|
@@ -16,14 +33,71 @@ The following environment variables will be passed through to the docker image:
|
|
|
16
33
|
* CF_PASSWORD - the cloud.gov password to fetch evidence from cloud.gov, only needed when running fetch script
|
|
17
34
|
"
|
|
18
35
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
ar_output=""
|
|
37
|
+
args_to_shift=0
|
|
38
|
+
declare -a volume_args
|
|
39
|
+
|
|
40
|
+
while getopts "ha:c:v:e:t:o" opt; do
|
|
41
|
+
case "$opt" in
|
|
42
|
+
a)
|
|
43
|
+
config=${OPTARG}
|
|
44
|
+
args_to_shift=$((args_to_shift + 2))
|
|
45
|
+
;;
|
|
46
|
+
c)
|
|
47
|
+
cdef=${OPTARG}
|
|
48
|
+
args_to_shift=$((args_to_shift + 2))
|
|
49
|
+
;;
|
|
50
|
+
v)
|
|
51
|
+
volume_args+=("-v" "$cwd/${OPTARG}")
|
|
52
|
+
args_to_shift=$((args_to_shift + 2))
|
|
53
|
+
;;
|
|
54
|
+
e)
|
|
55
|
+
email=${OPTARG}
|
|
56
|
+
args_to_shift=$((args_to_shift + 2))
|
|
57
|
+
;;
|
|
58
|
+
t)
|
|
59
|
+
tag=${OPTARG}
|
|
60
|
+
args_to_shift=$((args_to_shift + 2))
|
|
61
|
+
;;
|
|
62
|
+
o)
|
|
63
|
+
ar_output="$cwd/tmp/auditree"
|
|
64
|
+
args_to_shift=$((args_to_shift + 1))
|
|
65
|
+
;;
|
|
66
|
+
h)
|
|
67
|
+
echo "$usage"
|
|
68
|
+
exit 0
|
|
69
|
+
;;
|
|
70
|
+
esac
|
|
71
|
+
done
|
|
72
|
+
|
|
73
|
+
shift $args_to_shift
|
|
23
74
|
|
|
24
75
|
command="bash"
|
|
25
76
|
if [ "$1" != "" ]; then
|
|
26
|
-
command
|
|
77
|
+
command="$1"
|
|
78
|
+
shift 1
|
|
27
79
|
fi
|
|
28
80
|
|
|
29
|
-
|
|
81
|
+
if [ "$command" = "init" ]; then
|
|
82
|
+
docker run --rm $image:$tag init > "$config"
|
|
83
|
+
exit 0
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
volume_args+=("-v" "$cwd/$config":/app/auditree.template.json:ro)
|
|
87
|
+
volume_args+=("-v" "$cwd/$cdef":/app/cdef.json:ro)
|
|
88
|
+
if [ "$ar_output" != "" ]; then
|
|
89
|
+
mkdir -p "$ar_output"
|
|
90
|
+
chmod a+w "$ar_output"
|
|
91
|
+
volume_args+=("-v" "$ar_output":/tmp/auditree:rw)
|
|
92
|
+
if [ "$command" = "check" ]; then
|
|
93
|
+
command="check /tmp/auditree"
|
|
94
|
+
fi
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
if [ "$command" = "bash" ]; then
|
|
98
|
+
docker run -e GITHUB_TOKEN -e CF_USERNAME -e CF_PASSWORD -e GIT_EMAIL="$email" \
|
|
99
|
+
"${volume_args[@]}" -it --rm $image:$tag $command "$@"
|
|
100
|
+
else
|
|
101
|
+
docker run -e GITHUB_TOKEN -e CF_USERNAME -e CF_PASSWORD -e GIT_EMAIL="$email" \
|
|
102
|
+
"${volume_args[@]}" --rm $image:$tag $command "$@"
|
|
103
|
+
fi
|
data/lib/generators/rails_template18f/auditree/templates/github/actions/auditree-cmd/action.yml.tt
CHANGED
|
@@ -2,7 +2,7 @@ name: "Run an auditree-devtools command"
|
|
|
2
2
|
description: "Sets up workspace for running a single command in auditree-devtools"
|
|
3
3
|
inputs:
|
|
4
4
|
tag:
|
|
5
|
-
description: auditree-devtools tag to use.
|
|
5
|
+
description: auditree-devtools tag to use.
|
|
6
6
|
required: false
|
|
7
7
|
default: <%= docker_auditree_tag %>
|
|
8
8
|
cmd:
|
|
@@ -10,7 +10,8 @@ inputs:
|
|
|
10
10
|
required: true
|
|
11
11
|
email:
|
|
12
12
|
description: Git user email to attribute to evidence updates
|
|
13
|
-
required:
|
|
13
|
+
required: false
|
|
14
|
+
default: "<%= git_email %>"
|
|
14
15
|
config_template:
|
|
15
16
|
description: Auditree config file template
|
|
16
17
|
required: false
|
|
@@ -19,13 +20,23 @@ inputs:
|
|
|
19
20
|
description: OSCAL Component Definition being used as baseline for assessment results
|
|
20
21
|
required: false
|
|
21
22
|
default: doc/compliance/oscal/component-definitions/devtools_cloud_gov/component-definition.json
|
|
23
|
+
volume:
|
|
24
|
+
description: Freeform volume string to mount another file in the auditree image
|
|
25
|
+
required: false
|
|
26
|
+
default: ""
|
|
22
27
|
runs:
|
|
23
28
|
using: "composite"
|
|
24
29
|
steps:
|
|
25
30
|
- name: Run cmd
|
|
26
31
|
shell: bash
|
|
32
|
+
if: ${{ inputs.volume == '' }}
|
|
33
|
+
run:
|
|
34
|
+
bin/auditree -t ${{ inputs.tag }} -a ${{ inputs.config_template }} -c ${{ inputs.cdef }}
|
|
35
|
+
-e "${{ inputs.email }}" ${{ inputs.cmd }}
|
|
36
|
+
|
|
37
|
+
- name: Run cmd with volume
|
|
38
|
+
shell: bash
|
|
39
|
+
if: ${{ inputs.volume != '' }}
|
|
27
40
|
run:
|
|
28
|
-
|
|
29
|
-
-v $
|
|
30
|
-
-e GITHUB_TOKEN -e CF_USERNAME -e CF_PASSWORD -e GIT_EMAIL="${{inputs.email}}"
|
|
31
|
-
ghcr.io/gsa-tts/auditree:${{ inputs.tag }} ${{ inputs.cmd }}
|
|
41
|
+
bin/auditree -t ${{ inputs.tag }} -a ${{ inputs.config_template }} -c ${{ inputs.cdef }}
|
|
42
|
+
-e "${{ inputs.email }}" -v ${{ inputs.volume }} ${{ inputs.cmd }}
|
data/lib/generators/rails_template18f/auditree/templates/github/workflows/auditree-validation.yml.tt
CHANGED
|
@@ -23,20 +23,16 @@ jobs:
|
|
|
23
23
|
GITHUB_TOKEN: ${{ secrets.AUDITREE_GITHUB_TOKEN }}
|
|
24
24
|
with:
|
|
25
25
|
cmd: fetch
|
|
26
|
-
email: "<%= git_email %>"
|
|
27
26
|
|
|
28
27
|
- name: Check evidence
|
|
29
28
|
uses: ./.github/actions/auditree-cmd
|
|
30
29
|
env:
|
|
31
|
-
CF_USERNAME: ${{ secrets.CF_USERNAME }}
|
|
32
|
-
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
|
|
33
30
|
GITHUB_TOKEN: ${{ secrets.AUDITREE_GITHUB_TOKEN }}
|
|
34
31
|
with:
|
|
35
|
-
cmd: check
|
|
36
|
-
email: "<%= git_email %>"
|
|
32
|
+
cmd: -o check
|
|
37
33
|
|
|
38
34
|
- name: Save results
|
|
39
35
|
uses: actions/upload-artifact@v4
|
|
40
36
|
with:
|
|
41
37
|
name: auditree_assessment_results
|
|
42
|
-
path:
|
|
38
|
+
path: tmp/auditree/auditree.json
|
|
@@ -20,19 +20,16 @@ commands:
|
|
|
20
20
|
description: Set up environment for running docker-trestle commands
|
|
21
21
|
parameters:
|
|
22
22
|
tag:
|
|
23
|
-
description: docker-trestle tag to use.
|
|
23
|
+
description: docker-trestle tag to use.
|
|
24
24
|
type: string
|
|
25
25
|
default: latest
|
|
26
26
|
cmd:
|
|
27
27
|
description: Command to run within docker-trestle
|
|
28
28
|
type: string
|
|
29
29
|
steps:
|
|
30
|
-
- run:
|
|
31
|
-
name: Fix directory permissions
|
|
32
|
-
command: chmod -R a+w doc/compliance/oscal || true
|
|
33
30
|
- run:
|
|
34
31
|
name: Run trestle command
|
|
35
|
-
command: docker run -v $(pwd)/doc/compliance/oscal:/app/docs:rw ghcr.io/gsa-tts/trestle:<< parameters.tag >> << parameters.cmd >><% end %>
|
|
32
|
+
command: docker run -u "$(id -u):$(id -g)" -v $(pwd)/doc/compliance/oscal:/app/docs:rw ghcr.io/gsa-tts/trestle:<< parameters.tag >> << parameters.cmd >><% end %>
|
|
36
33
|
cg-deploy:
|
|
37
34
|
description: "Login to cloud foundry space with service account credentials
|
|
38
35
|
and push application using deployment configuration file."
|
|
@@ -74,6 +71,11 @@ commands:
|
|
|
74
71
|
-p ${<< parameters.cloudgov_password >>} \
|
|
75
72
|
-o << parameters.cloudgov_org >> \
|
|
76
73
|
-s << parameters.cloudgov_space >>
|
|
74
|
+
- run:
|
|
75
|
+
name: Set restricted egress
|
|
76
|
+
command: |
|
|
77
|
+
cf bind-security-group trusted_local_networks_egress << parameters.cloudgov_org >> \
|
|
78
|
+
--space << parameters.cloudgov_space >>
|
|
77
79
|
- run:
|
|
78
80
|
name: Push application with deployment vars
|
|
79
81
|
command: |
|
|
@@ -141,7 +143,7 @@ jobs:
|
|
|
141
143
|
steps:
|
|
142
144
|
- checkout
|
|
143
145
|
- trestle-cmd:
|
|
144
|
-
cmd:
|
|
146
|
+
cmd: validate-ssp-json
|
|
145
147
|
- trestle-cmd:
|
|
146
148
|
cmd: assemble-ssp-json 2> /dev/null | grep "^No changes to assembled ssp"
|
|
147
149
|
assemble_ssp:
|
|
@@ -151,8 +153,12 @@ jobs:
|
|
|
151
153
|
- checkout
|
|
152
154
|
- trestle-cmd:
|
|
153
155
|
cmd: trestle assemble -n <%= app_name %> system-security-plan
|
|
156
|
+
- trestle-cmd:
|
|
157
|
+
cmd: render-ssp
|
|
154
158
|
- store_artifacts:
|
|
155
159
|
path: doc/compliance/oscal/dist/system-security-plans/<%= app_name %>.json
|
|
160
|
+
- store_artifacts:
|
|
161
|
+
path: doc/compliance/oscal/ssp-render/<%= app_name %>_ssp.md
|
|
156
162
|
<% end %>
|
|
157
163
|
static_security_scans:
|
|
158
164
|
docker:
|
|
@@ -161,7 +167,7 @@ jobs:
|
|
|
161
167
|
- setup-project
|
|
162
168
|
- run:
|
|
163
169
|
name: Run Brakeman scan
|
|
164
|
-
command:
|
|
170
|
+
command: bin/brakeman --no-pager --ensure-ignore-notes
|
|
165
171
|
- run:
|
|
166
172
|
name: Bundle audit
|
|
167
173
|
command: bundle exec rake bundler:audit
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: bundler
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
open-pull-requests-limit: 10
|
|
8
|
+
- package-ecosystem: npm
|
|
9
|
+
directory: "/"
|
|
10
|
+
schedule:
|
|
11
|
+
interval: daily
|
|
12
|
+
open-pull-requests-limit: 10
|
|
13
|
+
- package-ecosystem: github-actions
|
|
14
|
+
directory: "/"
|
|
15
|
+
schedule:
|
|
16
|
+
interval: daily
|
|
17
|
+
open-pull-requests-limit: 10<% if terraform? %>
|
|
18
|
+
- package-ecosystem: terraform
|
|
19
|
+
directories:
|
|
20
|
+
- "/terraform/production"
|
|
21
|
+
- "/terraform/staging"
|
|
22
|
+
schedule:
|
|
23
|
+
interval: weekly
|
|
24
|
+
open-pull-requests-limit: 10
|
|
25
|
+
<% end %>
|
data/lib/generators/rails_template18f/github_actions/templates/github/workflows/assemble-ssp.yml.tt
CHANGED
|
@@ -4,8 +4,6 @@ on:
|
|
|
4
4
|
workflow_dispatch:
|
|
5
5
|
push:
|
|
6
6
|
branches: [ main ]
|
|
7
|
-
paths:
|
|
8
|
-
- "doc/compliance/oscal/**"
|
|
9
7
|
|
|
10
8
|
jobs:
|
|
11
9
|
assemble_ssp:
|
|
@@ -19,8 +17,19 @@ jobs:
|
|
|
19
17
|
with:
|
|
20
18
|
cmd: trestle assemble -n <%= app_name %> system-security-plan
|
|
21
19
|
|
|
20
|
+
- name: Render final SSPP
|
|
21
|
+
uses: ./.github/actions/trestle-cmd
|
|
22
|
+
with:
|
|
23
|
+
cmd: render-ssp
|
|
24
|
+
|
|
25
|
+
- name: Transform SSPP to PDF
|
|
26
|
+
run: docker run --rm -u "$(id -u):$(id -g)" -v "$GITHUB_WORKSPACE/doc/compliance/oscal/ssp-render:/data" pandoc/latex <%= app_name %>_ssp.md -o <%= app_name %>_ssp.pdf
|
|
27
|
+
|
|
22
28
|
- name: Save artifact
|
|
23
29
|
uses: actions/upload-artifact@v4
|
|
24
30
|
with:
|
|
25
31
|
name: <%= app_name %>_SSPP
|
|
26
|
-
path:
|
|
32
|
+
path: |
|
|
33
|
+
doc/compliance/oscal/dist/system-security-plans/<%= app_name %>.json
|
|
34
|
+
doc/compliance/oscal/ssp-render/<%= app_name %>_ssp.md
|
|
35
|
+
doc/compliance/oscal/ssp-render/<%= app_name %>_ssp.pdf
|
|
@@ -39,7 +39,7 @@ jobs:
|
|
|
39
39
|
- name: Scan
|
|
40
40
|
continue-on-error: true
|
|
41
41
|
run: |
|
|
42
|
-
|
|
42
|
+
bin/brakeman --no-pager --ensure-ignore-notes -f sarif -o output.sarif.json
|
|
43
43
|
|
|
44
44
|
# Upload the SARIF file generated in the previous step
|
|
45
45
|
- name: Upload SARIF
|
|
@@ -32,6 +32,14 @@ jobs:
|
|
|
32
32
|
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
|
|
33
33
|
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
|
|
34
34
|
<% end %>
|
|
35
|
+
- name: Set restricted egress
|
|
36
|
+
uses: cloud-gov/cg-cli-tools@main
|
|
37
|
+
with:
|
|
38
|
+
cf_username: ${{ secrets.CF_USERNAME }}
|
|
39
|
+
cf_password: ${{ secrets.CF_PASSWORD }}
|
|
40
|
+
cf_org: <%= cloud_gov_organization %>
|
|
41
|
+
cf_space: <%= cloud_gov_production_space %>
|
|
42
|
+
cf_command: bind-security-group trusted_local_networks_egress $INPUT_CF_ORG --space $INPUT_CF_SPACE
|
|
35
43
|
- name: Deploy app
|
|
36
44
|
uses: cloud-gov/cg-cli-tools@main
|
|
37
45
|
with:
|
|
@@ -32,6 +32,14 @@ jobs:
|
|
|
32
32
|
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
|
|
33
33
|
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
|
|
34
34
|
<% end %>
|
|
35
|
+
- name: Set restricted egress
|
|
36
|
+
uses: cloud-gov/cg-cli-tools@main
|
|
37
|
+
with:
|
|
38
|
+
cf_username: ${{ secrets.CF_USERNAME }}
|
|
39
|
+
cf_password: ${{ secrets.CF_PASSWORD }}
|
|
40
|
+
cf_org: <%= cloud_gov_organization %>
|
|
41
|
+
cf_space: <%= cloud_gov_staging_space %>
|
|
42
|
+
cf_command: bind-security-group trusted_local_networks_egress $INPUT_CF_ORG --space $INPUT_CF_SPACE
|
|
35
43
|
- name: Deploy app
|
|
36
44
|
uses: cloud-gov/cg-cli-tools@main
|
|
37
45
|
with:
|
data/lib/generators/rails_template18f/github_actions/templates/github/workflows/rspec.yml.tt
CHANGED
|
@@ -30,5 +30,13 @@ jobs:
|
|
|
30
30
|
|
|
31
31
|
- name: Run rspec
|
|
32
32
|
env:
|
|
33
|
-
DATABASE_URL: ${{ steps.setup.outputs.database_url }}
|
|
33
|
+
DATABASE_URL: ${{ steps.setup.outputs.database_url }}<% if oscal_dir_exists? %>
|
|
34
|
+
rspec_oscal_output: tmp<% end %>
|
|
34
35
|
run: bundle exec rspec
|
|
36
|
+
<% if oscal_dir_exists? %>
|
|
37
|
+
- name: Save assessment results
|
|
38
|
+
uses: actions/upload-artifact@v4
|
|
39
|
+
with:
|
|
40
|
+
name: <%= app_name %>_assessment
|
|
41
|
+
path: tmp/oscal
|
|
42
|
+
<% end %>
|
|
@@ -12,37 +12,29 @@ module RailsTemplate18f
|
|
|
12
12
|
Install and configure i18n-js gem to provide translations to JS code.
|
|
13
13
|
|
|
14
14
|
By default, will only export translations with keys that match `*.js.*`
|
|
15
|
+
|
|
16
|
+
To use, add the following to your js code:
|
|
17
|
+
|
|
18
|
+
1. `import { i18n } from './i18n';`
|
|
19
|
+
2. `i18n.t('path.to.translation.key')`
|
|
15
20
|
DESC
|
|
16
21
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
gem "
|
|
22
|
+
def install_gems
|
|
23
|
+
gem "i18n-js", "~> 4.2" unless gem_installed?("i18n-js")
|
|
24
|
+
gem "listen", "~> 3.9", group: :development unless gem_installed?("listen")
|
|
20
25
|
bundle_install do
|
|
21
26
|
run "yarn add i18n-js"
|
|
22
|
-
generate "i18n:js:config"
|
|
23
27
|
end
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def configure_translation_yaml
|
|
27
|
-
|
|
28
|
-
# remove `only` to include all translations
|
|
29
|
-
translations:
|
|
30
|
-
- file: "app/assets/builds/translations.js"
|
|
31
|
-
only: "*.js.*"
|
|
32
|
-
EOYAML
|
|
31
|
+
copy_file "config/i18n-js.yml"
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
def configure_asset_pipeline
|
|
36
35
|
copy_file "lib/tasks/i18n.rake"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<%= javascript_include_tag "i18n", "data-turbo-track": "reload" %>
|
|
40
|
-
<%= javascript_include_tag "translations", "data-turbo-track": "reload" %>
|
|
41
|
-
EOHTML
|
|
42
|
-
append_to_file "app/assets/config/manifest.js", <<~EOJS
|
|
43
|
-
//= link i18n.js
|
|
44
|
-
//= link translations.js
|
|
45
|
-
EOJS
|
|
36
|
+
copy_file "config/initializers/i18n_js.rb"
|
|
37
|
+
copy_file "app/javascript/i18n.js"
|
|
46
38
|
end
|
|
47
39
|
|
|
48
40
|
def ignore_generated_file
|
|
@@ -50,7 +42,7 @@ module RailsTemplate18f
|
|
|
50
42
|
append_to_file ".gitignore", <<~EOM
|
|
51
43
|
|
|
52
44
|
# Generated by i18n-js
|
|
53
|
-
/
|
|
45
|
+
/app/javascript/generated
|
|
54
46
|
EOM
|
|
55
47
|
end
|
|
56
48
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { I18n } from 'i18n-js';
|
|
2
|
+
import translations from './generated/translations.json';
|
|
3
|
+
|
|
4
|
+
const userLocale = document.documentElement.lang;
|
|
5
|
+
|
|
6
|
+
export const i18n = new I18n();
|
|
7
|
+
|
|
8
|
+
i18n.store(translations);
|
|
9
|
+
i18n.defaultLocale = "en";
|
|
10
|
+
i18n.enableFallback = true;
|
|
11
|
+
i18n.locale = userLocale;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# export translations as part of asset precompile
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Rake::Task["db:test:prepare"].enhance(["i18n:js:export"])
|
|
2
|
+
namespace "i18n:js" do
|
|
3
|
+
desc "Call the i18n-js export method"
|
|
4
|
+
task :export do
|
|
5
|
+
require "i18n-js"
|
|
6
|
+
I18nJS.call(config_file: "config/i18n-js.yml")
|
|
7
|
+
end
|
|
9
8
|
end
|
|
9
|
+
|
|
10
|
+
Rake::Task["javascript:build"].enhance(["i18n:js:export"])
|
|
@@ -10,6 +10,7 @@ module RailsTemplate18f
|
|
|
10
10
|
class_option :oscal_repo, desc: "GitHub Repo to store compliance documents within. Leave blank to check docs into the app repo"
|
|
11
11
|
class_option :tag, desc: "Which docker-trestle tag to use. Defaults to `latest`"
|
|
12
12
|
class_option :branch, desc: "Name of the branch to switch to when using a submodule. Defaults to `main`"
|
|
13
|
+
class_option :ci, desc: "Name of CI to generate files for. Defaults to system already in use"
|
|
13
14
|
|
|
14
15
|
desc <<~DESC
|
|
15
16
|
Description:
|
|
@@ -42,6 +43,12 @@ module RailsTemplate18f
|
|
|
42
43
|
template "doc/compliance/oscal/trestle-config.yaml"
|
|
43
44
|
end
|
|
44
45
|
|
|
46
|
+
def copy_github_actions
|
|
47
|
+
if use_github_actions?
|
|
48
|
+
directory "github", ".github"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
45
52
|
def update_readme
|
|
46
53
|
if file_content("README.md").match?("## Documentation")
|
|
47
54
|
insert_into_file "README.md", readme_contents, after: "## Documentation\n"
|
|
@@ -66,6 +73,8 @@ module RailsTemplate18f
|
|
|
66
73
|
# Trestle working files
|
|
67
74
|
doc/compliance/oscal/.trestle/_trash
|
|
68
75
|
doc/compliance/oscal/.trestle/cache
|
|
76
|
+
# Trestle renders
|
|
77
|
+
doc/compliance/oscal/ssp-render/#{app_name}_ssp.*
|
|
69
78
|
EOM
|
|
70
79
|
end
|
|
71
80
|
end
|
|
@@ -76,7 +85,11 @@ module RailsTemplate18f
|
|
|
76
85
|
end
|
|
77
86
|
|
|
78
87
|
def docker_trestle_tag
|
|
79
|
-
options[:tag].present? ? options[:tag] : "
|
|
88
|
+
options[:tag].present? ? options[:tag] : "20240912"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def use_github_actions?
|
|
92
|
+
options[:ci] == "github" || file_exists?(".github/workflows")
|
|
80
93
|
end
|
|
81
94
|
|
|
82
95
|
def readme_contents
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
#! /usr/bin/env bash
|
|
2
2
|
|
|
3
|
+
trestle_tag="<%= docker_trestle_tag %>"
|
|
4
|
+
|
|
3
5
|
command="bash"
|
|
4
6
|
if [ "$1" != "" ]; then
|
|
5
7
|
command=$1
|
|
8
|
+
shift 1
|
|
6
9
|
fi
|
|
7
10
|
|
|
8
11
|
oscal_location="$(dirname "$(realpath "$0")")/../doc/compliance/oscal"
|
|
9
12
|
|
|
10
|
-
docker run -it --rm -v $oscal_location:/app/docs:rw ghcr.io/gsa-tts/trestle
|
|
13
|
+
docker run -it --rm -v $oscal_location:/app/docs:rw ghcr.io/gsa-tts/trestle:$trestle_tag $command "$@"
|
data/lib/generators/rails_template18f/oscal/templates/github/actions/trestle-cmd/action.yml.tt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: "Run a docker-trestle command"
|
|
2
|
+
description: "Sets up workspace for running a single command in docker-trestle"
|
|
3
|
+
inputs:
|
|
4
|
+
tag:
|
|
5
|
+
description: docker-trestle tag to use.
|
|
6
|
+
required: false
|
|
7
|
+
default: <%= docker_trestle_tag %>
|
|
8
|
+
cmd:
|
|
9
|
+
description: Command to run within docker-trestle
|
|
10
|
+
required: true
|
|
11
|
+
runs:
|
|
12
|
+
using: "composite"
|
|
13
|
+
steps:
|
|
14
|
+
- name: Run cmd
|
|
15
|
+
shell: bash
|
|
16
|
+
run: docker run -u "$(id -u):$(id -g)" -v $GITHUB_WORKSPACE/doc/compliance/oscal:/app/docs:rw ghcr.io/gsa-tts/trestle:${{ inputs.tag }} ${{ inputs.cmd }}
|