env_bro 0.2.1 → 0.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/README.md +9 -5
- data/app/controllers/env_bro/application_controller.rb +1 -3
- data/app/models/env_bro/audit_event.rb +12 -6
- data/lib/env_bro/audit.rb +8 -8
- data/lib/env_bro/deployments.rb +1 -1
- data/lib/env_bro/engine.rb +2 -1
- data/lib/env_bro/version.rb +1 -1
- data/lib/generators/env_bro/install/install_generator.rb +1 -5
- metadata +3 -5
- data/app/models/env_bro/application_record.rb +0 -5
- data/db/migrate/20261029000000_create_env_bro_audit_events.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c31bb36f32504a7d7d2ae7514f1de54f23b44f50595f121543a23ed2788687ec
|
|
4
|
+
data.tar.gz: bc89126160634f6062a9b2189a3b6d816e30d07d0bc8976e317005b6009834a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: add4697c318c35fe3b18e97d3ca7891df73586ee9764d723268b361341651d5250376c121e6745d9822222d2052b2f82425ec48a7bc465dee5e7852c2d0c1106
|
|
7
|
+
data.tar.gz: 1da84b41c088acf2d37b384c73296603dd1517cf8908c473bc0359c3efa10f54926efc998608d711ae3f3eee4f0cb6501e07d2f32ec05bd13a76f77ff0e2f0c5
|
data/README.md
CHANGED
|
@@ -21,8 +21,9 @@ The encryption key never leaves the server, and EnvBro never writes to the crede
|
|
|
21
21
|
compared against. Encrypted files can't be merged, so a stale file would undo other people's changes.
|
|
22
22
|
- **Not built with EnvBro:** shown when the file has no metadata. It may have been edited by hand,
|
|
23
23
|
or it may be an older valid copy that someone is replaying.
|
|
24
|
-
4. **Audit:** proposals, reviews and every value reveal are stored in
|
|
25
|
-
|
|
24
|
+
4. **Audit:** proposals, reviews and every value reveal are stored in BroHub's shared audit table
|
|
25
|
+
(`bro_hub_audit_events`, `EnvBro::AuditEvent` is EnvBro's slice of it) with key names only. Rows are append-only,
|
|
26
|
+
and they also show up in BroHub's combined audit log for people allowed to review.
|
|
26
27
|
5. **Deployment tracking:** Rails reads credentials at boot, so on boot EnvBro checks whether the
|
|
27
28
|
running file came from a proposal and records a `proposal_deployed` event. The audit log then shows
|
|
28
29
|
each proposal as *live since …*, *deployed, replaced since*, *superseded* or *not deployed yet*.
|
|
@@ -39,7 +40,7 @@ gem "env_bro", git: "https://github.com/rubydevro/env_bro.git"
|
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
```sh
|
|
42
|
-
bin/rails generate env_bro:install # BroHub (mount + initializer), then EnvBro's initializer
|
|
43
|
+
bin/rails generate env_bro:install # BroHub (mount + initializer), then EnvBro's initializer. The audit table is BroHub's migration. --mount-path=/bro_hub skips the question
|
|
43
44
|
bin/rails db:migrate
|
|
44
45
|
```
|
|
45
46
|
|
|
@@ -60,8 +61,11 @@ Run `bin/rails generate bro_hub:install --remove-direct-mounts`: it mounts BroHu
|
|
|
60
61
|
(EnvBro then shows its own section in the same shell), so you can upgrade in two steps. Two things change in the UI:
|
|
61
62
|
the home page is now an environments overview instead of a redirect, and the layout comes from BroHub.
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
### Upgrading from 0.2.x
|
|
65
|
+
|
|
66
|
+
EnvBro 0.3 needs **bro_hub 0.2** and writes its audit trail to BroHub's one shared table instead of `env_bro_audit_events`.
|
|
67
|
+
Nothing is copied over: run `bundle update env_bro`, `bin/rails g bro_hub:install`, `bin/rails db:migrate`, and drop the old
|
|
68
|
+
table whenever you like (`drop_table :env_bro_audit_events` in a migration). EnvBro no longer ships migrations of its own.
|
|
65
69
|
|
|
66
70
|
Then set the permissions in `config/initializers/env_bro.rb`. Everything is denied by default:
|
|
67
71
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
module EnvBro
|
|
2
2
|
class ApplicationController < EnvBro.config.parent_controller.constantize
|
|
3
|
-
include BroHub::
|
|
3
|
+
include BroHub::ControllerBase
|
|
4
4
|
bro_hub_section :env_bro
|
|
5
5
|
|
|
6
|
-
protect_from_forgery with: :exception
|
|
7
|
-
|
|
8
6
|
before_action :env_bro_require_ssl
|
|
9
7
|
before_action :env_bro_no_store
|
|
10
8
|
before_action { @environment = Environment.current }
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
module EnvBro
|
|
2
2
|
# Who proposed, reviewed or revealed what, and when proposals went live.
|
|
3
3
|
# Holds key names only, never values.
|
|
4
|
-
|
|
4
|
+
# The rows live in BroHub's one audit table; this is EnvBro's slice of it.
|
|
5
|
+
class AuditEvent < BroHub::AuditEvent
|
|
6
|
+
SOURCE = "env_bro".freeze
|
|
5
7
|
EVENTS = %w[proposal_created proposal_deployed review_viewed values_revealed].freeze
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
has_one :deployment, -> { where(event: "proposal_deployed") }, class_name: "EnvBro::AuditEvent", foreign_key: :proposal_id
|
|
9
|
+
default_scope { where(source: SOURCE) }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
# A proposal's row keeps the id embedded in its file's metadata and the SHA-256 of the file handed out.
|
|
12
|
+
alias_attribute :proposal_token, :reference
|
|
13
|
+
alias_attribute :file_digest, :digest
|
|
14
|
+
|
|
15
|
+
# A deployment row points back at the proposal it put live (BroHub's `parent`).
|
|
16
|
+
belongs_to :proposal, class_name: "EnvBro::AuditEvent", foreign_key: :parent_id, optional: true
|
|
17
|
+
has_one :deployment, -> { where(event: "proposal_deployed") }, class_name: "EnvBro::AuditEvent", foreign_key: :parent_id
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
validates :event, inclusion: { in: EVENTS }
|
|
14
20
|
scope :proposals, -> { where(event: "proposal_created") }
|
|
15
21
|
scope :deployments, -> { where(event: "proposal_deployed") }
|
|
16
22
|
|
data/lib/env_bro/audit.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module EnvBro
|
|
2
|
-
# Records who did what
|
|
2
|
+
# Records who did what, through BroHub's audit table. Never records secret values, only key names.
|
|
3
3
|
module Audit
|
|
4
4
|
module_function
|
|
5
5
|
|
|
6
|
-
# columns:
|
|
6
|
+
# columns: proposal_token and file_digest (stored as BroHub's reference and digest) and proposal (the row a
|
|
7
|
+
# deployment belongs to).
|
|
7
8
|
def record(event, user:, columns: {}, **details)
|
|
8
|
-
|
|
9
|
-
event: event
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
details
|
|
13
|
-
**columns
|
|
9
|
+
BroHub::Audit.record(
|
|
10
|
+
source: EnvBro::AuditEvent::SOURCE, model: EnvBro::AuditEvent, event: event,
|
|
11
|
+
user: user.is_a?(String) ? user : EnvBro.config.user_label.call(user).to_s,
|
|
12
|
+
reference: columns[:proposal_token], digest: columns[:file_digest], parent: columns[:proposal],
|
|
13
|
+
**details
|
|
14
14
|
)
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/env_bro/deployments.rb
CHANGED
|
@@ -26,7 +26,7 @@ module EnvBro
|
|
|
26
26
|
modified = proposal.present?
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
return if proposal.nil? || AuditEvent.deployments.exists?(
|
|
29
|
+
return if proposal.nil? || AuditEvent.deployments.exists?(parent_id: proposal.id)
|
|
30
30
|
|
|
31
31
|
Audit.record(:proposal_deployed, user: "deploy",
|
|
32
32
|
columns: { proposal: proposal, file_digest: digest },
|
data/lib/env_bro/engine.rb
CHANGED
|
@@ -26,4 +26,5 @@ end
|
|
|
26
26
|
# Showing a section is navigation only: every EnvBro controller still authorizes each request.
|
|
27
27
|
BroHub.register :env_bro, name: "EnvBro", label: "EnvBro · config", accent: :green,
|
|
28
28
|
engine: "EnvBro::Engine", order: 20, items: EnvBro::BRO_HUB_ITEMS,
|
|
29
|
-
visible_to: ->(user) { EnvBro.config.allows?(user, :propose) || EnvBro.config.allows?(user, :review) }
|
|
29
|
+
visible_to: ->(user) { EnvBro.config.allows?(user, :propose) || EnvBro.config.allows?(user, :review) },
|
|
30
|
+
audit_visible_to: ->(user) { EnvBro.config.allows?(user, :review) }
|
data/lib/env_bro/version.rb
CHANGED
|
@@ -10,16 +10,12 @@ module EnvBro
|
|
|
10
10
|
|
|
11
11
|
source_root File.expand_path("templates", __dir__)
|
|
12
12
|
|
|
13
|
-
desc "Sets up the BroHub dashboard, adds the EnvBro initializer
|
|
13
|
+
desc "Sets up the BroHub dashboard, adds the EnvBro initializer. The audit table comes with BroHub."
|
|
14
14
|
|
|
15
15
|
def copy_initializer
|
|
16
16
|
copy_config_once "env_bro.rb", "config/initializers/env_bro.rb"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def copy_migrations
|
|
20
|
-
rails_command "env_bro:install:migrations", inline: true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
19
|
def next_steps
|
|
24
20
|
say <<~TEXT
|
|
25
21
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: env_bro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ruby Dev SRL
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.2.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.2.0
|
|
40
40
|
description: 'A mountable Rails engine: team members with permission build a re-encrypted
|
|
41
41
|
credentials file with their changes and open a PR; reviewers upload the file and
|
|
42
42
|
see a masked diff.'
|
|
@@ -55,7 +55,6 @@ files:
|
|
|
55
55
|
- app/controllers/env_bro/proposals_controller.rb
|
|
56
56
|
- app/controllers/env_bro/reviews_controller.rb
|
|
57
57
|
- app/helpers/env_bro/application_helper.rb
|
|
58
|
-
- app/models/env_bro/application_record.rb
|
|
59
58
|
- app/models/env_bro/audit_event.rb
|
|
60
59
|
- app/views/env_bro/audit/index.html.erb
|
|
61
60
|
- app/views/env_bro/home/index.html.erb
|
|
@@ -68,7 +67,6 @@ files:
|
|
|
68
67
|
- app/views/env_bro/shared/forbidden.html.erb
|
|
69
68
|
- app/views/env_bro/shared/not_ready.html.erb
|
|
70
69
|
- config/routes.rb
|
|
71
|
-
- db/migrate/20261029000000_create_env_bro_audit_events.rb
|
|
72
70
|
- lib/env_bro.rb
|
|
73
71
|
- lib/env_bro/audit.rb
|
|
74
72
|
- lib/env_bro/configuration.rb
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
class CreateEnvBroAuditEvents < ActiveRecord::Migration[7.1]
|
|
2
|
-
def change
|
|
3
|
-
create_table :env_bro_audit_events do |t|
|
|
4
|
-
t.string :event, null: false
|
|
5
|
-
t.string :user_label
|
|
6
|
-
t.string :environment, null: false
|
|
7
|
-
# No column default: MySQL rejects defaults on JSON columns. Audit.record always sets it.
|
|
8
|
-
t.json :details, null: false
|
|
9
|
-
|
|
10
|
-
# proposal_created: the id embedded in the file's metadata and the SHA-256 of the file handed out.
|
|
11
|
-
# proposal_deployed: the SHA-256 of the file found running.
|
|
12
|
-
t.string :proposal_token
|
|
13
|
-
t.string :file_digest
|
|
14
|
-
|
|
15
|
-
# proposal_deployed: the proposal that went live.
|
|
16
|
-
t.references :proposal, foreign_key: { to_table: :env_bro_audit_events }, index: { unique: true }
|
|
17
|
-
|
|
18
|
-
t.datetime :created_at, null: false
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
add_index :env_bro_audit_events, :created_at
|
|
22
|
-
add_index :env_bro_audit_events, :proposal_token
|
|
23
|
-
add_index :env_bro_audit_events, :file_digest
|
|
24
|
-
end
|
|
25
|
-
end
|