govuk_app_config 9.6.0 → 9.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c15ac7d4a7297bc830a60b2877bc36d0e1b046fe2a498a0006b29b58ce9a0fec
4
- data.tar.gz: 323f249a17a7806f176e88d060e7c99ac0eb54f0244815534056e2820e70f9e0
3
+ metadata.gz: 87265c446c96df0dfc6e7ce62e6e7f645c76af7b335426adc7db55bb5426ef5d
4
+ data.tar.gz: a78f518813885bf16b6e78c9351102c6b2dc5eb896c23a0913bb870a05bc2118
5
5
  SHA512:
6
- metadata.gz: 8d514827abb88965374c9213b700ba05f9fdb3f65098f403d4e583581da768ebb6aa512b8b38adeae4818e839186443a011dfc3dd9ee7e1fc101363cd2721f3d
7
- data.tar.gz: 319470197ea8a8ead9e29ba6e01b347215c62d472be68d94eaf58223a0e4b350a1046cee03c2aafef5d8e3828a34e802400eb60ea2322c93e6c5da277230d856
6
+ metadata.gz: 2ca052131a146360a268ccc50762f8482342df275e0540b42b36eae8f5a87c9e4daaa403e24b4258bd2a67104b5426af29f0d5b1ec7213bec1c43518a802d068
7
+ data.tar.gz: b9301f60612daed32d37c6ed82d7f20250dacb9de5e68a270c9c9b1834801ffaf739f5c84219debd016728f9e78882494853e914abcb1556dd32491793d06041
@@ -11,6 +11,16 @@ on:
11
11
  type: string
12
12
 
13
13
  jobs:
14
+ codeql-sast:
15
+ name: CodeQL SAST scan
16
+ uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main
17
+ permissions:
18
+ security-events: write
19
+
20
+ dependency-review:
21
+ name: Dependency Review scan
22
+ uses: alphagov/govuk-infrastructure/.github/workflows/dependency-review.yml@main
23
+
14
24
  # Run the test suite against multiple Ruby and Rails versions
15
25
  test_matrix:
16
26
  strategy:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 9.7.0
2
+
3
+ * Enable adding custom LogStasher fields from apps ([#327](https://github.com/alphagov/govuk_app_config/pull/327))
4
+
1
5
  # 9.6.0
2
6
 
3
7
  * Allow YouTube thumbnails from https://i.ytimg.com in the global Content Security Policy ([#328](https://github.com/alphagov/govuk_app_config/pull/328))
data/README.md CHANGED
@@ -149,6 +149,20 @@ allow JSON format logs and `Govuk-Request-Id` to be visible.
149
149
  For development logs, in order to see the production style logs, developers should
150
150
  set `GOVUK_RAILS_JSON_LOGGING`in `govuk-docker` -> `docker-compose` files.
151
151
 
152
+ ### Logger configuration
153
+
154
+ To include additional custom fields in your Rails logs, you can declare them
155
+ within a `GovukJsonLogging.configure` block in a `config/initializers/` file.
156
+
157
+ Example of adding a key/value to log entries based on a request header:
158
+
159
+ ```ruby
160
+ GovukJsonLogging.configure do
161
+ add_custom_fields do |fields|
162
+ fields[:govuk_custom_field] = request.headers["GOVUK-Custom-Header"]
163
+ end
164
+ end
165
+ ```
152
166
 
153
167
  ## Content Security Policy generation
154
168
 
@@ -3,7 +3,23 @@ require "logstasher"
3
3
  require "action_controller"
4
4
 
5
5
  module GovukJsonLogging
6
- def self.configure
6
+ class Configuration
7
+ def initialize
8
+ @custom_fields_block = proc {}
9
+ end
10
+
11
+ attr_reader :custom_fields_block
12
+
13
+ def add_custom_fields(&block)
14
+ @custom_fields_block = block if block_given?
15
+ end
16
+ end
17
+
18
+ def self.configure(&block)
19
+ configuration = Configuration.new
20
+
21
+ configuration.instance_eval(&block) if block_given?
22
+
7
23
  # We disable buffering, so that logs aren't lost on crash or delayed
8
24
  # indefinitely while troubleshooting.
9
25
  $stdout.sync = true
@@ -31,6 +47,8 @@ module GovukJsonLogging
31
47
  fields[:govuk_request_id] = request.headers["GOVUK-Request-Id"]
32
48
  fields[:varnish_id] = request.headers["X-Varnish"]
33
49
  fields[:govuk_app_config] = GovukAppConfig::VERSION
50
+
51
+ instance_exec(fields, &configuration.custom_fields_block) if block_given?
34
52
  end
35
53
 
36
54
  Rails.application.config.logstasher.enabled = true
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "9.6.0".freeze
2
+ VERSION = "9.7.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.6.0
4
+ version: 9.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-17 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstasher