bro_hub 0.1.2 → 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.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +204 -87
  4. data/app/controllers/bro_hub/apm/application_controller.rb +26 -0
  5. data/app/controllers/bro_hub/apm/deploys_controller.rb +7 -0
  6. data/app/controllers/bro_hub/apm/endpoints_controller.rb +8 -0
  7. data/app/controllers/bro_hub/apm/errors_controller.rb +15 -0
  8. data/app/controllers/bro_hub/apm/findings_controller.rb +8 -0
  9. data/app/controllers/bro_hub/apm/overview_controller.rb +7 -0
  10. data/app/controllers/bro_hub/apm/queries_controller.rb +11 -0
  11. data/app/controllers/bro_hub/apm/status_controller.rb +9 -0
  12. data/app/controllers/bro_hub/application_controller.rb +16 -0
  13. data/app/controllers/bro_hub/audit_events_controller.rb +56 -0
  14. data/app/controllers/bro_hub/cache/application_controller.rb +55 -0
  15. data/app/controllers/bro_hub/cache/audit_events_controller.rb +40 -0
  16. data/app/controllers/bro_hub/cache/flushes_controller.rb +34 -0
  17. data/app/controllers/bro_hub/cache/keys_controller.rb +41 -0
  18. data/app/controllers/bro_hub/cache/purges_controller.rb +40 -0
  19. data/app/controllers/bro_hub/env/application_controller.rb +27 -0
  20. data/app/controllers/bro_hub/env/audit_controller.rb +10 -0
  21. data/app/controllers/bro_hub/env/home_controller.rb +6 -0
  22. data/app/controllers/bro_hub/env/proposals_controller.rb +86 -0
  23. data/app/controllers/bro_hub/env/reviews_controller.rb +72 -0
  24. data/app/controllers/bro_hub/feature_controller.rb +21 -0
  25. data/app/controllers/bro_hub/safe/application_controller.rb +24 -0
  26. data/app/controllers/bro_hub/safe/flagged_commands_controller.rb +14 -0
  27. data/app/controllers/bro_hub/safe/reviews_controller.rb +39 -0
  28. data/app/controllers/bro_hub/safe/rules_controller.rb +18 -0
  29. data/app/controllers/bro_hub/safe/sessions_controller.rb +63 -0
  30. data/app/controllers/bro_hub/safe/unlocks_controller.rb +14 -0
  31. data/app/helpers/bro_hub/apm/application_helper.rb +104 -0
  32. data/app/helpers/bro_hub/application_helper.rb +28 -18
  33. data/app/helpers/bro_hub/cache/application_helper.rb +63 -0
  34. data/app/helpers/bro_hub/env/application_helper.rb +67 -0
  35. data/app/helpers/bro_hub/safe/application_helper.rb +59 -0
  36. data/app/jobs/bro_hub/safe/purge_job.rb +10 -0
  37. data/app/models/bro_hub/application_record.rb +5 -0
  38. data/app/models/bro_hub/audit_event.rb +40 -0
  39. data/app/models/bro_hub/cache/audit_event.rb +15 -0
  40. data/app/models/bro_hub/env/audit_event.rb +72 -0
  41. data/app/models/bro_hub/safe/command.rb +22 -0
  42. data/app/models/bro_hub/safe/review.rb +22 -0
  43. data/app/models/bro_hub/safe/session.rb +57 -0
  44. data/app/models/bro_hub/safe/unlock.rb +15 -0
  45. data/app/views/bro_hub/apm/deploys/index.html.erb +21 -0
  46. data/app/views/bro_hub/apm/endpoints/index.html.erb +27 -0
  47. data/app/views/bro_hub/apm/errors/index.html.erb +22 -0
  48. data/app/views/bro_hub/apm/errors/not_found.html.erb +3 -0
  49. data/app/views/bro_hub/apm/errors/show.html.erb +43 -0
  50. data/app/views/bro_hub/apm/findings/index.html.erb +24 -0
  51. data/app/views/bro_hub/apm/overview/show.html.erb +59 -0
  52. data/app/views/bro_hub/apm/queries/index.html.erb +37 -0
  53. data/app/views/bro_hub/apm/shared/_page_styles.html.erb +15 -0
  54. data/app/views/bro_hub/apm/status/show.html.erb +47 -0
  55. data/app/views/bro_hub/audit_events/index.html.erb +38 -0
  56. data/app/views/bro_hub/audit_events/show.html.erb +54 -0
  57. data/app/views/bro_hub/cache/audit_events/index.html.erb +39 -0
  58. data/app/views/bro_hub/cache/audit_events/show.html.erb +48 -0
  59. data/app/views/bro_hub/cache/flushes/new.html.erb +19 -0
  60. data/app/views/bro_hub/cache/keys/index.html.erb +36 -0
  61. data/app/views/bro_hub/cache/keys/show.html.erb +57 -0
  62. data/app/views/bro_hub/cache/purges/new.html.erb +17 -0
  63. data/app/views/bro_hub/cache/purges/preview.html.erb +37 -0
  64. data/app/views/bro_hub/cache/shared/_store_tabs.html.erb +9 -0
  65. data/app/views/bro_hub/cache/shared/unsupported.html.erb +3 -0
  66. data/app/views/bro_hub/env/audit/index.html.erb +31 -0
  67. data/app/views/bro_hub/env/home/index.html.erb +25 -0
  68. data/app/views/bro_hub/env/proposals/_new_key_row.html.erb +7 -0
  69. data/app/views/bro_hub/env/proposals/new.html.erb +99 -0
  70. data/app/views/bro_hub/env/reviews/new.html.erb +29 -0
  71. data/app/views/bro_hub/env/reviews/show.html.erb +122 -0
  72. data/app/views/bro_hub/env/shared/_page_styles.html.erb +57 -0
  73. data/app/views/bro_hub/env/shared/_script.html.erb +114 -0
  74. data/app/views/bro_hub/env/shared/not_ready.html.erb +17 -0
  75. data/app/views/bro_hub/safe/flagged_commands/index.html.erb +22 -0
  76. data/app/views/bro_hub/safe/rules/show.html.erb +59 -0
  77. data/app/views/bro_hub/safe/sessions/index.html.erb +51 -0
  78. data/app/views/bro_hub/safe/sessions/show.html.erb +92 -0
  79. data/app/views/bro_hub/safe/unlocks/index.html.erb +25 -0
  80. data/app/views/bro_hub/shared/schema_missing.html.erb +25 -0
  81. data/app/views/layouts/bro_hub/application.html.erb +11 -2
  82. data/config/routes/apm.rb +10 -0
  83. data/config/routes/cache.rb +17 -0
  84. data/config/routes/env.rb +10 -0
  85. data/config/routes/safe.rb +10 -0
  86. data/config/routes.rb +12 -3
  87. data/db/migrate/20261129000000_create_bro_hub_tables.rb +85 -0
  88. data/lib/bro_hub/apm/api.rb +88 -0
  89. data/lib/bro_hub/apm/configuration.rb +58 -0
  90. data/lib/bro_hub/apm/local_status.rb +49 -0
  91. data/lib/bro_hub/apm.rb +28 -0
  92. data/lib/bro_hub/audit.rb +41 -0
  93. data/lib/bro_hub/cache/audit.rb +15 -0
  94. data/lib/bro_hub/cache/configuration.rb +105 -0
  95. data/lib/bro_hub/cache/errors.rb +26 -0
  96. data/lib/bro_hub/cache/redis_store.rb +220 -0
  97. data/lib/bro_hub/cache.rb +38 -0
  98. data/lib/bro_hub/configuration.rb +19 -4
  99. data/lib/bro_hub/controller_base.rb +3 -6
  100. data/lib/bro_hub/engine.rb +60 -1
  101. data/lib/bro_hub/env/audit.rb +17 -0
  102. data/lib/bro_hub/env/configuration.rb +72 -0
  103. data/lib/bro_hub/env/credentials.rb +135 -0
  104. data/lib/bro_hub/env/deployments.rb +45 -0
  105. data/lib/bro_hub/env/differ.rb +58 -0
  106. data/lib/bro_hub/env/editor.rb +104 -0
  107. data/lib/bro_hub/env/encrypted_blob.rb +18 -0
  108. data/lib/bro_hub/env/environment.rb +74 -0
  109. data/lib/bro_hub/env.rb +36 -0
  110. data/lib/bro_hub/features.rb +13 -0
  111. data/lib/bro_hub/layout.rb +2 -5
  112. data/lib/bro_hub/registry.rb +5 -0
  113. data/lib/bro_hub/safe/cipher.rb +46 -0
  114. data/lib/bro_hub/safe/commands.rb +25 -0
  115. data/lib/bro_hub/safe/configuration.rb +191 -0
  116. data/lib/bro_hub/safe/encrypted_type.rb +16 -0
  117. data/lib/bro_hub/safe/errors.rb +48 -0
  118. data/lib/bro_hub/safe/executor.rb +142 -0
  119. data/lib/bro_hub/safe/guards/const_guard.rb +42 -0
  120. data/lib/bro_hub/safe/guards/credentials_guard.rb +31 -0
  121. data/lib/bro_hub/safe/guards/env_guard.rb +90 -0
  122. data/lib/bro_hub/safe/guards/file_guard.rb +28 -0
  123. data/lib/bro_hub/safe/guards/guarded.rb +51 -0
  124. data/lib/bro_hub/safe/guards/irb_context.rb +23 -0
  125. data/lib/bro_hub/safe/guards/method_guard.rb +32 -0
  126. data/lib/bro_hub/safe/guards/network_guard.rb +98 -0
  127. data/lib/bro_hub/safe/guards/sql_guard.rb +26 -0
  128. data/lib/bro_hub/safe/parsed_command.rb +66 -0
  129. data/lib/bro_hub/safe/recorder.rb +82 -0
  130. data/lib/bro_hub/safe/shield.rb +83 -0
  131. data/lib/bro_hub/safe/supervisor.rb +81 -0
  132. data/lib/bro_hub/safe/terminal.rb +55 -0
  133. data/lib/bro_hub/safe/trail.rb +24 -0
  134. data/lib/bro_hub/safe/validator.rb +74 -0
  135. data/lib/bro_hub/safe.rb +134 -0
  136. data/lib/bro_hub/schema.rb +36 -0
  137. data/lib/bro_hub/section.rb +14 -10
  138. data/lib/bro_hub/testing.rb +62 -0
  139. data/lib/bro_hub/version.rb +1 -1
  140. data/lib/bro_hub.rb +32 -6
  141. data/lib/generators/bro_hub/install/install_generator.rb +93 -69
  142. data/lib/generators/bro_hub/install/templates/bro_hub.rb.tt +115 -0
  143. data/lib/generators/bro_hub/uninstall/templates/drop_bro_hub_tables.rb.tt +16 -0
  144. data/lib/generators/bro_hub/uninstall/uninstall_generator.rb +57 -0
  145. data/lib/tasks/bro_hub.rake +9 -0
  146. metadata +155 -10
  147. data/lib/bro_hub/root_middleware.rb +0 -17
  148. data/lib/generators/bro_hub/install/templates/bro_hub.rb +0 -11
  149. data/lib/generators/bro_hub/installable.rb +0 -63
@@ -0,0 +1,115 @@
1
+ BroHub.configure do |config|
2
+ config.features = %i[ <%= features.join(" ") %> ]<% unless features.include?(:apm) %> # add :apm to see DeadBro stats (needs gem "dead_bro")<% end %>
3
+
4
+ # Who is signed in. The default calls current_user, then Current.user.
5
+ # config.current_user = ->(controller) { controller.current_user }
6
+
7
+ # What to show at the top right.
8
+ # config.user_label = ->(user) { user.email } # Rails 8 auth generator: user.email_address (also tried by default)
9
+
10
+ # Which controller the dashboard's own pages inherit from (so your authentication runs).
11
+ # config.parent_controller = "::ApplicationController"
12
+
13
+ # Reject plain HTTP (secret values and cache contents travel through the browser).
14
+ # config.require_ssl = Rails.env.production?
15
+
16
+ # --- EnvBro: propose and review credentials changes ------------------------------------------
17
+ # People propose changes to this environment's encrypted credentials without holding the key.
18
+ # Who may do what. Each lambda gets the signed in user (nil when signed out). Everything is denied by default.
19
+ <%= feature_line :env, "config.env.can_review = ->(user) { user.try(:admin?) }" %> # upload a proposal and see what changed
20
+ # config.env.can_create = ->(user) { user.try(:developer?) } # propose new keys
21
+ # config.env.can_update = ->(user) { user.try(:developer?) } # propose new values for existing keys
22
+ # config.env.can_destroy = ->(user) { user.try(:developer?) } # propose removing keys
23
+ # config.env.can_reveal = ->(user) { user.try(:admin?) } # see actual values in a review (audited)
24
+ # Higher includes lower: review includes create/update/destroy, reveal includes everything.
25
+ # config.env.can_propose = ->(user) { ... } sets create, update and destroy in one go.
26
+
27
+ # Top-level credentials key holding proposal metadata. nil disables it, along with the outdated-base
28
+ # warning and deployment tracking by proposal id.
29
+ # config.env.metadata_key = "env_bro"
30
+
31
+ # Record on boot when the running credentials came from an EnvBro proposal.
32
+ # config.env.track_deployments = true
33
+
34
+ # --- SafeBro: audit production console sessions ----------------------------------------------
35
+ # Nobody may review sessions until you say so. Who is signed in comes from config.current_user.
36
+ <%= feature_line :safe, "config.safe.can_audit = ->(user) { user.try(:admin?) }" %>
37
+ # config.safe.allow_self_audit = false
38
+ # Reviewers can't approve their own sessions, matched by the name they use at the console. That is what
39
+ # username_resolver returns (CONSOLE_USER, e.g. "jane"), not user_label (usually an email), so map it:
40
+ # until you do, self review isn't prevented and the SafeBro Rules page says so.
41
+ # config.safe.console_username = ->(user) { user.console_name }
42
+
43
+ # Consoles started in these environments are recorded and guarded.
44
+ # config.safe.protected_environments = %w[ production ]
45
+
46
+ # How SafeBro learns who is at the console. Set it where you can trust it: with SSH,
47
+ # `environment="CONSOLE_USER=jane"` on the key in authorized_keys. A SetEnv from the
48
+ # client can be set to anything.
49
+ # config.safe.username_resolver = -> { ENV["CONSOLE_USER"] }
50
+ # config.safe.ask_for_username_if_empty = false
51
+
52
+ # Where the person connected from, stored with the session. Default: CONSOLE_CLIENT_IP, then SSH_CLIENT.
53
+ # Inside a container pass it in, e.g. `docker run -e CONSOLE_CLIENT_IP="${SSH_CLIENT%% *}" ...`.
54
+ # config.safe.client_ip_resolver = -> { ENV["CONSOLE_CLIENT_IP"] }
55
+
56
+ # What is protected until someone runs unlock!
57
+ # config.safe.protected_resources = %i[ encrypted_data credentials env files network ]
58
+ # config.safe.protected_urls = [ "redis://cache.internal:6379", "https://search.internal:9200" ]
59
+ # config.safe.protected_env_patterns += [ /STRIPE/ ]
60
+ # config.safe.protected_file_patterns += [ %r{config/.*\.pem\z} ]
61
+
62
+ # Guardrails
63
+ # config.safe.forbidden_methods += [ "Kernel#open" ]
64
+ # config.safe.suspicious_terms += [ "DROP TABLE" ]
65
+
66
+ # Sessions older than this are removed by BroHub::Safe::PurgeJob (schedule it) or
67
+ # `bin/rails bro_hub:safe:purge`. Flagged sessions are kept. nil keeps everything.
68
+ # config.safe.retention = 90.days
69
+ # config.safe.keep_flagged = true
70
+
71
+ # Also record `rails runner` invocations as sessions.
72
+ # config.safe.audit_runner = false
73
+
74
+ # --- CacheBro: browse, inspect and purge the Redis cache -------------------------------------
75
+ # Who may do what. Each lambda gets the signed in user (nil when signed out). Everything is denied by default.
76
+ <%= feature_line :cache, "config.cache.can_view_keys = ->(user) { user.try(:admin?) }" %> # open CacheBro, search keys, see TTL and size
77
+ # config.cache.can_view_values = ->(user) { user.try(:admin?) } # reveal what a key holds (audited). Values can hold personal data
78
+ # config.cache.can_delete = ->(user) { user.try(:admin?) } # delete one key
79
+ # config.cache.can_purge = ->(user) { user.try(:admin?) } # delete every key matching a pattern
80
+ # config.cache.can_flush = ->(user) { user.try(:admin?) } # delete everything in the store's namespace
81
+ # config.cache.can_audit = ->(user) { user.try(:admin?) } # read the audit log
82
+ # Higher includes lower: flush includes purge and delete, purge includes delete, and all of them include
83
+ # view_keys. view_values and audit stand alone.
84
+
85
+ # Which cache stores to manage. The name shows in the UI and the audit log. Only Rails' :redis_cache_store
86
+ # is supported, and it should have a `namespace:` so CacheBro stays out of keys that aren't the cache's.
87
+ # config.cache.stores = { "Rails.cache" => -> { Rails.cache } }
88
+ # config.cache.stores = { "App cache" => -> { Rails.cache }, "Sessions" => -> { MySessionCache } }
89
+
90
+ # Destructive actions that need a typed reason (kept in the audit log): any of :reveal, :delete, :purge, :flush.
91
+ # config.cache.reason_required_for = %i[ purge flush ]
92
+
93
+ # A single purge deletes at most this many keys, then stops (run it again for more).
94
+ # config.cache.max_purge_keys = 100_000
95
+
96
+ # --- DeadBro: performance stats from the dead_bro gem ----------------------------------------
97
+ # Reads with the API key the dead_bro gem already uses, so there is nothing to configure except who may look.
98
+ # The pages show SQL statements, exception messages and request paths, so keep it to people who can already
99
+ # see that. Needs gem "dead_bro" and :apm in config.features.
100
+ <%= feature_line :apm, "config.apm.can_view = ->(user) { user.try(:admin?) }" %>
101
+
102
+ # Seconds a response from DeadBro is cached in Rails.cache (0 = off).
103
+ # config.apm.cache_ttl = 30
104
+
105
+ # Only if you need to override what the dead_bro gem uses:
106
+ # config.apm.api_key = ENV["DEAD_BRO_API_KEY"]
107
+ # config.apm.base_url = "https://www.deadbro.com"
108
+ end
109
+
110
+ # Get told when a console session needs attention (events: session_started, unlocked, command_flagged,
111
+ # session_flagged):
112
+ #
113
+ # ActiveSupport::Notifications.subscribe("command_flagged.bro_hub_safe") do |*, payload|
114
+ # SecurityMailer.console_flag(payload[:session], payload[:reason]).deliver_later
115
+ # end
@@ -0,0 +1,16 @@
1
+ class DropBroHubTables < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ # Children first. This deletes BroHub's audit history and console sessions.
3
+ def up
4
+ drop_table :bro_hub_console_commands, if_exists: true
5
+ drop_table :bro_hub_console_reviews, if_exists: true
6
+ drop_table :bro_hub_console_unlocks, if_exists: true
7
+ drop_table :bro_hub_console_sessions, if_exists: true
8
+ drop_table :bro_hub_audit_events, if_exists: true
9
+ end
10
+
11
+ # Brings the tables back empty, using the migration that ships with the bro_hub gem (so the gem must still be installed to roll back).
12
+ def down
13
+ require BroHub::Schema::MIGRATION
14
+ CreateBroHubTables.new.migrate(:up)
15
+ end
16
+ end
@@ -0,0 +1,57 @@
1
+ require "rails/generators"
2
+ require "rails/generators/active_record"
3
+
4
+ module BroHub
5
+ module Generators
6
+ # bin/rails generate bro_hub:uninstall
7
+ #
8
+ # Writes a migration that drops BroHub's tables, removes the initializer and unmounts the dashboard.
9
+ class UninstallGenerator < Rails::Generators::Base
10
+ include Rails::Generators::Migration
11
+
12
+ source_root File.expand_path("templates", __dir__)
13
+
14
+ desc "Writes a migration dropping BroHub's tables, removes its initializer and unmounts the dashboard."
15
+
16
+ WARNING = "This deletes BroHub's audit history and console sessions when the migration runs."
17
+
18
+ class_option :force, type: :boolean, default: false, desc: "Skip the confirmation"
19
+
20
+ def self.next_migration_number(dirname)
21
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
22
+ end
23
+
24
+ def confirm_uninstall
25
+ say WARNING, :red
26
+ return if options[:force] || options[:pretend]
27
+
28
+ raise Thor::Error, "Not a terminal, so nothing was changed. Run again with --force to uninstall." unless interactive?
29
+ raise Thor::Error, "Aborted, nothing was changed." unless ask("Continue? (y/N)").to_s.strip.downcase.start_with?("y")
30
+ end
31
+
32
+ def copy_drop_migration
33
+ migration_template "drop_bro_hub_tables.rb.tt", "db/migrate/drop_bro_hub_tables.rb"
34
+ end
35
+
36
+ def remove_initializer
37
+ remove_file "config/initializers/bro_hub.rb"
38
+ end
39
+
40
+ def remove_mount
41
+ path = File.join(destination_root, "config/routes.rb")
42
+ return unless File.exist?(path)
43
+
44
+ gsub_file "config/routes.rb", /^[ \t]*mount BroHub::Engine => .*\n/, ""
45
+ end
46
+
47
+ def next_steps
48
+ say "\nNow run bin/rails db:migrate, then remove gem \"bro_hub\" from your Gemfile.\n"
49
+ end
50
+
51
+ private
52
+ def interactive?
53
+ $stdin.tty?
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,9 @@
1
+ namespace :bro_hub do
2
+ namespace :safe do
3
+ desc "Delete console sessions older than config.safe.retention (flagged ones are kept unless keep_flagged is off)"
4
+ task purge: :environment do
5
+ deleted = BroHub::Safe::Session.purge!
6
+ puts "BroHub: purged #{deleted} console session#{'s' unless deleted == 1}"
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bro_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby Dev SRL
@@ -23,39 +23,182 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '7.1'
26
- description: 'BroHub is the shared admin shell: one mount point, one layout, one sidebar
27
- and one place to configure who is signed in. Each Bro gem registers its pages and
28
- shows up as a section. Sections only appear for people who may use them.'
26
+ - !ruby/object:Gem::Dependency
27
+ name: irb
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '1.13'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '1.13'
40
+ description: 'BroHub is one Rails engine with four opt-in features: EnvBro (propose
41
+ and review encrypted credentials changes), SafeBro (audited, guarded production
42
+ console sessions), CacheBro (browse, inspect and purge the Redis cache) and DeadBro
43
+ (performance stats from the dead_bro gem). One mount point, one sidebar, one audit
44
+ log. Built by the DeadBro team.'
29
45
  email:
30
46
  - office@rubydev.ro
31
47
  executables: []
32
48
  extensions: []
33
49
  extra_rdoc_files: []
34
50
  files:
51
+ - CHANGELOG.md
35
52
  - MIT-LICENSE
36
53
  - README.md
37
54
  - Rakefile
55
+ - app/controllers/bro_hub/apm/application_controller.rb
56
+ - app/controllers/bro_hub/apm/deploys_controller.rb
57
+ - app/controllers/bro_hub/apm/endpoints_controller.rb
58
+ - app/controllers/bro_hub/apm/errors_controller.rb
59
+ - app/controllers/bro_hub/apm/findings_controller.rb
60
+ - app/controllers/bro_hub/apm/overview_controller.rb
61
+ - app/controllers/bro_hub/apm/queries_controller.rb
62
+ - app/controllers/bro_hub/apm/status_controller.rb
38
63
  - app/controllers/bro_hub/application_controller.rb
64
+ - app/controllers/bro_hub/audit_events_controller.rb
65
+ - app/controllers/bro_hub/cache/application_controller.rb
66
+ - app/controllers/bro_hub/cache/audit_events_controller.rb
67
+ - app/controllers/bro_hub/cache/flushes_controller.rb
68
+ - app/controllers/bro_hub/cache/keys_controller.rb
69
+ - app/controllers/bro_hub/cache/purges_controller.rb
70
+ - app/controllers/bro_hub/env/application_controller.rb
71
+ - app/controllers/bro_hub/env/audit_controller.rb
72
+ - app/controllers/bro_hub/env/home_controller.rb
73
+ - app/controllers/bro_hub/env/proposals_controller.rb
74
+ - app/controllers/bro_hub/env/reviews_controller.rb
75
+ - app/controllers/bro_hub/feature_controller.rb
39
76
  - app/controllers/bro_hub/home_controller.rb
77
+ - app/controllers/bro_hub/safe/application_controller.rb
78
+ - app/controllers/bro_hub/safe/flagged_commands_controller.rb
79
+ - app/controllers/bro_hub/safe/reviews_controller.rb
80
+ - app/controllers/bro_hub/safe/rules_controller.rb
81
+ - app/controllers/bro_hub/safe/sessions_controller.rb
82
+ - app/controllers/bro_hub/safe/unlocks_controller.rb
83
+ - app/helpers/bro_hub/apm/application_helper.rb
40
84
  - app/helpers/bro_hub/application_helper.rb
85
+ - app/helpers/bro_hub/cache/application_helper.rb
86
+ - app/helpers/bro_hub/env/application_helper.rb
87
+ - app/helpers/bro_hub/safe/application_helper.rb
88
+ - app/jobs/bro_hub/safe/purge_job.rb
89
+ - app/models/bro_hub/application_record.rb
90
+ - app/models/bro_hub/audit_event.rb
91
+ - app/models/bro_hub/cache/audit_event.rb
92
+ - app/models/bro_hub/env/audit_event.rb
93
+ - app/models/bro_hub/safe/command.rb
94
+ - app/models/bro_hub/safe/review.rb
95
+ - app/models/bro_hub/safe/session.rb
96
+ - app/models/bro_hub/safe/unlock.rb
97
+ - app/views/bro_hub/apm/deploys/index.html.erb
98
+ - app/views/bro_hub/apm/endpoints/index.html.erb
99
+ - app/views/bro_hub/apm/errors/index.html.erb
100
+ - app/views/bro_hub/apm/errors/not_found.html.erb
101
+ - app/views/bro_hub/apm/errors/show.html.erb
102
+ - app/views/bro_hub/apm/findings/index.html.erb
103
+ - app/views/bro_hub/apm/overview/show.html.erb
104
+ - app/views/bro_hub/apm/queries/index.html.erb
105
+ - app/views/bro_hub/apm/shared/_page_styles.html.erb
106
+ - app/views/bro_hub/apm/status/show.html.erb
107
+ - app/views/bro_hub/audit_events/index.html.erb
108
+ - app/views/bro_hub/audit_events/show.html.erb
109
+ - app/views/bro_hub/cache/audit_events/index.html.erb
110
+ - app/views/bro_hub/cache/audit_events/show.html.erb
111
+ - app/views/bro_hub/cache/flushes/new.html.erb
112
+ - app/views/bro_hub/cache/keys/index.html.erb
113
+ - app/views/bro_hub/cache/keys/show.html.erb
114
+ - app/views/bro_hub/cache/purges/new.html.erb
115
+ - app/views/bro_hub/cache/purges/preview.html.erb
116
+ - app/views/bro_hub/cache/shared/_store_tabs.html.erb
117
+ - app/views/bro_hub/cache/shared/unsupported.html.erb
118
+ - app/views/bro_hub/env/audit/index.html.erb
119
+ - app/views/bro_hub/env/home/index.html.erb
120
+ - app/views/bro_hub/env/proposals/_new_key_row.html.erb
121
+ - app/views/bro_hub/env/proposals/new.html.erb
122
+ - app/views/bro_hub/env/reviews/new.html.erb
123
+ - app/views/bro_hub/env/reviews/show.html.erb
124
+ - app/views/bro_hub/env/shared/_page_styles.html.erb
125
+ - app/views/bro_hub/env/shared/_script.html.erb
126
+ - app/views/bro_hub/env/shared/not_ready.html.erb
127
+ - app/views/bro_hub/safe/flagged_commands/index.html.erb
128
+ - app/views/bro_hub/safe/rules/show.html.erb
129
+ - app/views/bro_hub/safe/sessions/index.html.erb
130
+ - app/views/bro_hub/safe/sessions/show.html.erb
131
+ - app/views/bro_hub/safe/unlocks/index.html.erb
41
132
  - app/views/bro_hub/shared/_hero.html.erb
42
133
  - app/views/bro_hub/shared/forbidden.html.erb
134
+ - app/views/bro_hub/shared/schema_missing.html.erb
43
135
  - app/views/layouts/bro_hub/application.html.erb
44
136
  - config/routes.rb
137
+ - config/routes/apm.rb
138
+ - config/routes/cache.rb
139
+ - config/routes/env.rb
140
+ - config/routes/safe.rb
141
+ - db/migrate/20261129000000_create_bro_hub_tables.rb
45
142
  - lib/bro_hub.rb
143
+ - lib/bro_hub/apm.rb
144
+ - lib/bro_hub/apm/api.rb
145
+ - lib/bro_hub/apm/configuration.rb
146
+ - lib/bro_hub/apm/local_status.rb
147
+ - lib/bro_hub/audit.rb
148
+ - lib/bro_hub/cache.rb
149
+ - lib/bro_hub/cache/audit.rb
150
+ - lib/bro_hub/cache/configuration.rb
151
+ - lib/bro_hub/cache/errors.rb
152
+ - lib/bro_hub/cache/redis_store.rb
46
153
  - lib/bro_hub/configuration.rb
47
154
  - lib/bro_hub/controller_base.rb
48
155
  - lib/bro_hub/engine.rb
156
+ - lib/bro_hub/env.rb
157
+ - lib/bro_hub/env/audit.rb
158
+ - lib/bro_hub/env/configuration.rb
159
+ - lib/bro_hub/env/credentials.rb
160
+ - lib/bro_hub/env/deployments.rb
161
+ - lib/bro_hub/env/differ.rb
162
+ - lib/bro_hub/env/editor.rb
163
+ - lib/bro_hub/env/encrypted_blob.rb
164
+ - lib/bro_hub/env/environment.rb
165
+ - lib/bro_hub/features.rb
49
166
  - lib/bro_hub/layout.rb
50
167
  - lib/bro_hub/registry.rb
51
- - lib/bro_hub/root_middleware.rb
168
+ - lib/bro_hub/safe.rb
169
+ - lib/bro_hub/safe/cipher.rb
170
+ - lib/bro_hub/safe/commands.rb
171
+ - lib/bro_hub/safe/configuration.rb
172
+ - lib/bro_hub/safe/encrypted_type.rb
173
+ - lib/bro_hub/safe/errors.rb
174
+ - lib/bro_hub/safe/executor.rb
175
+ - lib/bro_hub/safe/guards/const_guard.rb
176
+ - lib/bro_hub/safe/guards/credentials_guard.rb
177
+ - lib/bro_hub/safe/guards/env_guard.rb
178
+ - lib/bro_hub/safe/guards/file_guard.rb
179
+ - lib/bro_hub/safe/guards/guarded.rb
180
+ - lib/bro_hub/safe/guards/irb_context.rb
181
+ - lib/bro_hub/safe/guards/method_guard.rb
182
+ - lib/bro_hub/safe/guards/network_guard.rb
183
+ - lib/bro_hub/safe/guards/sql_guard.rb
184
+ - lib/bro_hub/safe/parsed_command.rb
185
+ - lib/bro_hub/safe/recorder.rb
186
+ - lib/bro_hub/safe/shield.rb
187
+ - lib/bro_hub/safe/supervisor.rb
188
+ - lib/bro_hub/safe/terminal.rb
189
+ - lib/bro_hub/safe/trail.rb
190
+ - lib/bro_hub/safe/validator.rb
191
+ - lib/bro_hub/schema.rb
52
192
  - lib/bro_hub/section.rb
53
193
  - lib/bro_hub/skull.png
54
194
  - lib/bro_hub/styles.css
195
+ - lib/bro_hub/testing.rb
55
196
  - lib/bro_hub/version.rb
56
197
  - lib/generators/bro_hub/install/install_generator.rb
57
- - lib/generators/bro_hub/install/templates/bro_hub.rb
58
- - lib/generators/bro_hub/installable.rb
198
+ - lib/generators/bro_hub/install/templates/bro_hub.rb.tt
199
+ - lib/generators/bro_hub/uninstall/templates/drop_bro_hub_tables.rb.tt
200
+ - lib/generators/bro_hub/uninstall/uninstall_generator.rb
201
+ - lib/tasks/bro_hub.rake
59
202
  homepage: https://www.rubydev.ro
60
203
  licenses:
61
204
  - MIT
@@ -72,14 +215,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
215
  requirements:
73
216
  - - ">="
74
217
  - !ruby/object:Gem::Version
75
- version: '3.2'
218
+ version: '3.3'
76
219
  required_rubygems_version: !ruby/object:Gem::Requirement
77
220
  requirements:
78
221
  - - ">="
79
222
  - !ruby/object:Gem::Version
80
223
  version: '0'
81
224
  requirements: []
82
- rubygems_version: 4.0.10
225
+ rubygems_version: 4.0.22
83
226
  specification_version: 4
84
- summary: One dashboard shell for the Bro gems (EnvBro, SafeBro, ...).
227
+ summary: 'One mountable dashboard for Rails: EnvBro (credentials changes), SafeBro
228
+ (console audit), CacheBro (Redis cache) and DeadBro (APM stats). Built by the DeadBro
229
+ team.'
85
230
  test_files: []
@@ -1,17 +0,0 @@
1
- module BroHub
2
- # Runs as the hub's engine is called, when SCRIPT_NAME is still the hub's own mount point.
3
- # Engines mounted under the hub (and the shell's layout) read it from here.
4
- class RootMiddleware
5
- def initialize(app)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env["bro_hub.root"] ||= env["SCRIPT_NAME"].to_s.delete_suffix("/")
11
- response = @app.call(env)
12
- # Nothing here matched and the host router will try its next route: this was not a hub request after all.
13
- env.delete("bro_hub.root") if response[1]["X-Cascade"] == "pass"
14
- response
15
- end
16
- end
17
- end
@@ -1,11 +0,0 @@
1
- BroHub.configure do |config|
2
- # How to find the signed-in user. The default calls `current_user` on the controller when it has one,
3
- # and falls back to `Current.user` (Rails 8 authentication generator).
4
- # config.current_user = ->(controller) { controller.current_user }
5
-
6
- # What to show at the top right.
7
- # config.user_label = ->(user) { user.email } # Rails 8 auth generator: user.email_address (also tried by default)
8
-
9
- # Which controller the dashboard's own pages inherit from (so your authentication runs).
10
- # config.parent_controller = "::ApplicationController"
11
- end
@@ -1,63 +0,0 @@
1
- require "rails/generators"
2
- require "generators/bro_hub/install/install_generator"
3
-
4
- module BroHub
5
- module Generators
6
- # The rule for a Bro gem's own installer: set up BroHub first, then yourself.
7
- #
8
- # class SafeBro::Generators::InstallGenerator < Rails::Generators::Base
9
- # include BroHub::Generators::Installable # first line, so BroHub's step runs first
10
- #
11
- # def copy_initializer ... end
12
- # end
13
- #
14
- # `rails g safe_bro:install` then mounts BroHub (once, whatever else is installed) and installs SafeBro.
15
- # `rails g bro_hub:install` installs every Bro gem in the bundle by running their installers with
16
- # --skip-bro-hub, since it has just done that step itself.
17
- module Installable
18
- extend ActiveSupport::Concern
19
-
20
- included do
21
- class_option :mount_path, type: :string,
22
- desc: "Where to mount the BroHub dashboard (asked interactively when omitted, default #{BroHub::Generators::InstallGenerator::DEFAULT_MOUNT_PATH})"
23
- class_option :remove_direct_mounts, type: :boolean, default: nil,
24
- desc: "Comment out old `mount SafeBro::Engine`-style lines, since BroHub mounts the gems itself"
25
- class_option :skip_bro_hub, type: :boolean, default: false, hide: true,
26
- desc: "BroHub is already set up (used by bro_hub:install)"
27
-
28
- # Defined here, not in the module body, so Thor registers it as the first command of the generator.
29
- def install_bro_hub
30
- return if options[:skip_bro_hub]
31
-
32
- forward = { install_gems: false }.merge(bro_hub_conflict_options)
33
- forward[:mount_path] = options[:mount_path] if options[:mount_path].present?
34
- forward[:remove_direct_mounts] = options[:remove_direct_mounts] unless options[:remove_direct_mounts].nil?
35
- invoke "bro_hub:install", [], forward
36
- end
37
- end
38
-
39
- private
40
- # --skip / --force / --pretend / --quiet must reach the generators we invoke, or a nested
41
- # installer would fall back to asking about conflicts (and with no terminal, overwrite).
42
- def bro_hub_conflict_options
43
- options.slice(:force, :skip, :pretend, :quiet).to_h.symbolize_keys.select { |_, value| value }
44
- end
45
-
46
- # Copies a config file once. An existing file is yours: it is never replaced, even with --force.
47
- def copy_config_once(source, destination)
48
- if File.exist?(File.join(destination_root, destination))
49
- say_status :skip, "#{destination} already exists, leaving it alone", :yellow
50
- else
51
- copy_file source, destination
52
- end
53
- end
54
-
55
- # Where BroHub ended up, read back from the routes (it may have been mounted before).
56
- def bro_hub_path
57
- routes = File.join(destination_root, "config/routes.rb")
58
- mounted = File.read(routes)[/mount BroHub::Engine => "([^"]+)"/, 1] if File.exist?(routes)
59
- mounted || BroHub::Generators::InstallGenerator::DEFAULT_MOUNT_PATH
60
- end
61
- end
62
- end
63
- end