bro_hub 0.2.0 → 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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +175 -165
  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 +2 -2
  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 +5 -19
  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/audit_event.rb +2 -6
  38. data/app/models/bro_hub/cache/audit_event.rb +15 -0
  39. data/app/models/bro_hub/env/audit_event.rb +72 -0
  40. data/app/models/bro_hub/safe/command.rb +22 -0
  41. data/app/models/bro_hub/safe/review.rb +22 -0
  42. data/app/models/bro_hub/safe/session.rb +57 -0
  43. data/app/models/bro_hub/safe/unlock.rb +15 -0
  44. data/app/views/bro_hub/apm/deploys/index.html.erb +21 -0
  45. data/app/views/bro_hub/apm/endpoints/index.html.erb +27 -0
  46. data/app/views/bro_hub/apm/errors/index.html.erb +22 -0
  47. data/app/views/bro_hub/apm/errors/not_found.html.erb +3 -0
  48. data/app/views/bro_hub/apm/errors/show.html.erb +43 -0
  49. data/app/views/bro_hub/apm/findings/index.html.erb +24 -0
  50. data/app/views/bro_hub/apm/overview/show.html.erb +59 -0
  51. data/app/views/bro_hub/apm/queries/index.html.erb +37 -0
  52. data/app/views/bro_hub/apm/shared/_page_styles.html.erb +15 -0
  53. data/app/views/bro_hub/apm/status/show.html.erb +47 -0
  54. data/app/views/bro_hub/audit_events/index.html.erb +1 -1
  55. data/app/views/bro_hub/cache/audit_events/index.html.erb +39 -0
  56. data/app/views/bro_hub/cache/audit_events/show.html.erb +48 -0
  57. data/app/views/bro_hub/cache/flushes/new.html.erb +19 -0
  58. data/app/views/bro_hub/cache/keys/index.html.erb +36 -0
  59. data/app/views/bro_hub/cache/keys/show.html.erb +57 -0
  60. data/app/views/bro_hub/cache/purges/new.html.erb +17 -0
  61. data/app/views/bro_hub/cache/purges/preview.html.erb +37 -0
  62. data/app/views/bro_hub/cache/shared/_store_tabs.html.erb +9 -0
  63. data/app/views/bro_hub/cache/shared/unsupported.html.erb +3 -0
  64. data/app/views/bro_hub/env/audit/index.html.erb +31 -0
  65. data/app/views/bro_hub/env/home/index.html.erb +25 -0
  66. data/app/views/bro_hub/env/proposals/_new_key_row.html.erb +7 -0
  67. data/app/views/bro_hub/env/proposals/new.html.erb +99 -0
  68. data/app/views/bro_hub/env/reviews/new.html.erb +29 -0
  69. data/app/views/bro_hub/env/reviews/show.html.erb +122 -0
  70. data/app/views/bro_hub/env/shared/_page_styles.html.erb +57 -0
  71. data/app/views/bro_hub/env/shared/_script.html.erb +114 -0
  72. data/app/views/bro_hub/env/shared/not_ready.html.erb +17 -0
  73. data/app/views/bro_hub/safe/flagged_commands/index.html.erb +22 -0
  74. data/app/views/bro_hub/safe/rules/show.html.erb +59 -0
  75. data/app/views/bro_hub/safe/sessions/index.html.erb +51 -0
  76. data/app/views/bro_hub/safe/sessions/show.html.erb +92 -0
  77. data/app/views/bro_hub/safe/unlocks/index.html.erb +25 -0
  78. data/app/views/bro_hub/shared/schema_missing.html.erb +25 -0
  79. data/app/views/layouts/bro_hub/application.html.erb +1 -1
  80. data/config/routes/apm.rb +10 -0
  81. data/config/routes/cache.rb +17 -0
  82. data/config/routes/env.rb +10 -0
  83. data/config/routes/safe.rb +10 -0
  84. data/config/routes.rb +9 -4
  85. data/db/migrate/20261129000000_create_bro_hub_tables.rb +85 -0
  86. data/lib/bro_hub/apm/api.rb +88 -0
  87. data/lib/bro_hub/apm/configuration.rb +58 -0
  88. data/lib/bro_hub/apm/local_status.rb +49 -0
  89. data/lib/bro_hub/apm.rb +28 -0
  90. data/lib/bro_hub/audit.rb +2 -9
  91. data/lib/bro_hub/cache/audit.rb +15 -0
  92. data/lib/bro_hub/cache/configuration.rb +105 -0
  93. data/lib/bro_hub/cache/errors.rb +26 -0
  94. data/lib/bro_hub/cache/redis_store.rb +220 -0
  95. data/lib/bro_hub/cache.rb +38 -0
  96. data/lib/bro_hub/configuration.rb +19 -4
  97. data/lib/bro_hub/controller_base.rb +3 -6
  98. data/lib/bro_hub/engine.rb +60 -1
  99. data/lib/bro_hub/env/audit.rb +17 -0
  100. data/lib/bro_hub/env/configuration.rb +72 -0
  101. data/lib/bro_hub/env/credentials.rb +135 -0
  102. data/lib/bro_hub/env/deployments.rb +45 -0
  103. data/lib/bro_hub/env/differ.rb +58 -0
  104. data/lib/bro_hub/env/editor.rb +104 -0
  105. data/lib/bro_hub/env/encrypted_blob.rb +18 -0
  106. data/lib/bro_hub/env/environment.rb +74 -0
  107. data/lib/bro_hub/env.rb +36 -0
  108. data/lib/bro_hub/features.rb +13 -0
  109. data/lib/bro_hub/layout.rb +2 -5
  110. data/lib/bro_hub/safe/cipher.rb +46 -0
  111. data/lib/bro_hub/safe/commands.rb +25 -0
  112. data/lib/bro_hub/safe/configuration.rb +191 -0
  113. data/lib/bro_hub/safe/encrypted_type.rb +16 -0
  114. data/lib/bro_hub/safe/errors.rb +48 -0
  115. data/lib/bro_hub/safe/executor.rb +142 -0
  116. data/lib/bro_hub/safe/guards/const_guard.rb +42 -0
  117. data/lib/bro_hub/safe/guards/credentials_guard.rb +31 -0
  118. data/lib/bro_hub/safe/guards/env_guard.rb +90 -0
  119. data/lib/bro_hub/safe/guards/file_guard.rb +28 -0
  120. data/lib/bro_hub/safe/guards/guarded.rb +51 -0
  121. data/lib/bro_hub/safe/guards/irb_context.rb +23 -0
  122. data/lib/bro_hub/safe/guards/method_guard.rb +32 -0
  123. data/lib/bro_hub/safe/guards/network_guard.rb +98 -0
  124. data/lib/bro_hub/safe/guards/sql_guard.rb +26 -0
  125. data/lib/bro_hub/safe/parsed_command.rb +66 -0
  126. data/lib/bro_hub/safe/recorder.rb +82 -0
  127. data/lib/bro_hub/safe/shield.rb +83 -0
  128. data/lib/bro_hub/safe/supervisor.rb +81 -0
  129. data/lib/bro_hub/safe/terminal.rb +55 -0
  130. data/lib/bro_hub/safe/trail.rb +24 -0
  131. data/lib/bro_hub/safe/validator.rb +74 -0
  132. data/lib/bro_hub/safe.rb +134 -0
  133. data/lib/bro_hub/schema.rb +36 -0
  134. data/lib/bro_hub/section.rb +7 -13
  135. data/lib/bro_hub/testing.rb +23 -6
  136. data/lib/bro_hub/version.rb +1 -1
  137. data/lib/bro_hub.rb +31 -6
  138. data/lib/generators/bro_hub/install/install_generator.rb +89 -71
  139. data/lib/generators/bro_hub/install/templates/bro_hub.rb.tt +115 -0
  140. data/lib/generators/bro_hub/uninstall/templates/drop_bro_hub_tables.rb.tt +16 -0
  141. data/lib/generators/bro_hub/uninstall/uninstall_generator.rb +57 -0
  142. data/lib/tasks/bro_hub.rake +9 -0
  143. metadata +148 -13
  144. data/db/migrate/20261116000000_create_bro_hub_audit_events.rb +0 -35
  145. data/lib/bro_hub/root_middleware.rb +0 -17
  146. data/lib/generators/bro_hub/install/templates/bro_hub.rb +0 -11
  147. data/lib/generators/bro_hub/installable.rb +0 -63
@@ -0,0 +1,43 @@
1
+ <% apm_styles %>
2
+ <% bro_hub_crumb "Errors", "##{params[:id]}" %>
3
+ <% content_for :bro_hub_crumb_actions do %><%= bro_hub_crumb_link "← All errors", apm_errors_path %><% end %>
4
+ <% if @error %>
5
+ <%= bro_hub_hero eyebrow: "Exceptions", title: "Error ##{params[:id]}", tone: :red %>
6
+ <%= apm_error_notice(@error) %>
7
+ <% else %>
8
+ <% e = @error_issue %>
9
+ <%= bro_hub_hero eyebrow: "Exception", title: e["exception_class"] || "Error", subtitle: "× #{apm_int(e["occurrences"])}", tone: :red, lead: e["message"] %>
10
+ <section class="bh-block">
11
+ <dl class="bh-dl">
12
+ <dt>Top frame</dt><dd><code><%= e["top_frame"].presence || "-" %></code></dd>
13
+ <dt>First seen</dt><dd><%= apm_time(e["first_seen_at"]) %></dd>
14
+ <dt>Last seen</dt><dd><%= apm_time(e["last_seen_at"]) %></dd>
15
+ </dl>
16
+ </section>
17
+ <section class="bh-block">
18
+ <div class="bh-block-head"><h2 class="bh-h2">Affected endpoints</h2></div>
19
+ <% if e["affected_endpoints"].blank? %>
20
+ <div class="bh-empty">No endpoint data for this error.</div>
21
+ <% else %>
22
+ <div class="bh-table-wrap"><div class="bh-table dbh-cols-top">
23
+ <div class="bh-row is-head"><span>Endpoint</span><span>Hits</span><span></span></div>
24
+ <% e["affected_endpoints"].each do |a| %>
25
+ <div class="bh-row"><span class="bh-cell-strong"><%= a["endpoint"] %></span><span><%= apm_int(a["hits"]) %></span><span></span></div>
26
+ <% end %>
27
+ </div></div>
28
+ <% end %>
29
+ </section>
30
+ <section class="bh-block">
31
+ <div class="bh-block-head"><h2 class="bh-h2">Recent occurrences</h2></div>
32
+ <% if e["recent_occurrences"].blank? %>
33
+ <div class="bh-empty">None available.</div>
34
+ <% else %>
35
+ <div class="bh-table-wrap"><div class="bh-table dbh-cols-errors">
36
+ <div class="bh-row is-head"><span>Request</span><span>Duration</span><span>When</span><span></span></div>
37
+ <% e["recent_occurrences"].each do |r| %>
38
+ <div class="bh-row"><span><span class="bh-cell-strong"><%= r["endpoint"] %></span><br><span class="bh-cell-muted"><%= r["path"] %></span></span><span><%= apm_ms(r["duration_ms"]) %></span><span class="bh-cell-muted"><%= apm_time(r["at"]) %></span><span></span></div>
39
+ <% end %>
40
+ </div></div>
41
+ <% end %>
42
+ </section>
43
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <% apm_styles %>
2
+ <% bro_hub_crumb "Findings" %>
3
+ <% findings = @data && @data["findings"] %>
4
+ <%= bro_hub_hero eyebrow: "What to fix", title: (findings ? findings.size.to_s : "-"), subtitle: (params[:status] == "all" ? "findings" : "open findings"), tone: :amber,
5
+ lead: "Problems DeadBro keeps tracking, ranked by how much time they cost." %>
6
+ <div class="bh-filters"><span><%= apm_chips(:status, %w[active all], params[:status] == "all" ? "all" : "active") %></span></div>
7
+ <% if @error %>
8
+ <%= apm_error_notice(@error) %>
9
+ <% elsif findings.empty? %>
10
+ <div class="bh-table-wrap"><div class="bh-empty">Nothing to fix right now.</div></div>
11
+ <% else %>
12
+ <div class="bh-table-wrap"><div class="bh-table dbh-cols-findings">
13
+ <div class="bh-row is-head"><span>Finding</span><span>Kind</span><span>Status</span><span>Impact</span><span>Last seen</span></div>
14
+ <% findings.each do |f| %>
15
+ <div class="bh-row">
16
+ <span><span class="bh-cell-strong"><%= f["title"] %></span><% if f["recommendation"].present? %><br><span class="bh-cell-muted"><%= truncate(f["recommendation"], length: 180) %></span><% end %></span>
17
+ <span><%= apm_tag(f["kind"].to_s.humanize.downcase) %></span>
18
+ <span><%= apm_tag(f["status"].to_s.humanize.downcase, { "open" => "is-amber", "regressed" => "is-red", "resolved" => "is-green" }[f["status"]]) %></span>
19
+ <span><% if f["kind"] == "memory_heavy_endpoint" %><%= (f.dig("impact", "mb_per_day") || 0).to_f.round(1) %> MB/day<% else %><%= apm_ms(f["impact_ms_per_day"]) %>/day<% end %></span>
20
+ <span class="bh-cell-muted"><%= apm_time(f["last_seen_at"]) %></span>
21
+ </div>
22
+ <% end %>
23
+ </div></div>
24
+ <% end %>
@@ -0,0 +1,59 @@
1
+ <% apm_styles %>
2
+ <% bro_hub_crumb "Overview" %>
3
+ <% o = @overview %>
4
+ <% stats = o && o["stats_24h"] %>
5
+ <% if @error %>
6
+ <%= bro_hub_hero eyebrow: "DeadBro", title: "Overview", tone: :violet, lead: "The last 24 hours of this app, from DeadBro." %>
7
+ <%= apm_error_notice(@error) %>
8
+ <% else %>
9
+ <%= bro_hub_hero eyebrow: "#{o.dig("application", "name")} · #{o.dig("application", "environment")}",
10
+ title: stats ? apm_int(stats["total_requests"]) : "-", subtitle: "requests in 24h", tone: :violet,
11
+ lead: (o["last_request_at"] ? safe_join([ "Last request seen ", apm_time(o["last_request_at"]), "." ]) : "DeadBro has not received a request from this app yet."),
12
+ stats: stats ? [
13
+ [ apm_pct(stats["error_rate_pct"]), "error rate", apm_error_rate_tone(stats["error_rate_pct"]) ],
14
+ [ apm_int(stats["error_count"]), "errors" ],
15
+ [ apm_pct(stats["slow_rate_pct"]), "slow requests", (:amber if stats["slow_rate_pct"].to_f >= 10) ],
16
+ [ apm_int(o["active_findings"]), "open findings", (:amber if o["active_findings"].to_i.positive?) ]
17
+ ] : [] %>
18
+
19
+ <% unless stats %>
20
+ <div class="bh-alert bh-alert-error">Request statistics are temporarily unavailable from DeadBro.</div>
21
+ <% end %>
22
+
23
+ <section class="bh-block">
24
+ <div class="bh-block-head"><h2 class="bh-h2">Throughput, per hour</h2></div>
25
+ <%= apm_bars((o["hourly"] || []).map { |b| b["calls"] }) %>
26
+ <p class="dbh-sub">p95 response time per hour</p>
27
+ <%= apm_bars((o["hourly"] || []).map { |b| b["p95_ms"] }, tone: "var(--bh-amber)") %>
28
+ </section>
29
+
30
+ <section class="bh-block">
31
+ <div class="bh-block-head">
32
+ <h2 class="bh-h2">Slowest endpoints (7 days)</h2>
33
+ <%= link_to "All endpoints →", apm_endpoints_path, class: "bh-link-quiet" %>
34
+ </div>
35
+ <% if o["slowest_endpoints"].blank? %>
36
+ <div class="bh-empty">No endpoints with enough samples yet.</div>
37
+ <% else %>
38
+ <div class="bh-table-wrap"><div class="bh-table dbh-cols-top">
39
+ <div class="bh-row is-head"><span>Endpoint</span><span>Mean</span><span>Samples</span></div>
40
+ <% o["slowest_endpoints"].each do |e| %>
41
+ <div class="bh-row"><span class="bh-cell-strong"><%= e["name"] %></span><span><%= apm_ms(e["mean_duration_ms"]) %></span><span class="bh-cell-muted"><%= apm_int(e["samples"]) %></span></div>
42
+ <% end %>
43
+ </div></div>
44
+ <% end %>
45
+ </section>
46
+
47
+ <section class="bh-block">
48
+ <div class="bh-block-head"><h2 class="bh-h2">Latest deploy</h2><%= link_to "All deploys →", apm_deploys_path, class: "bh-link-quiet" %></div>
49
+ <% if (d = o["latest_deploy"]) %>
50
+ <dl class="bh-dl">
51
+ <dt>Revision</dt><dd><code><%= d["revision"] %></code></dd>
52
+ <dt>Deployed</dt><dd><%= apm_time(d["deployed_at"]) %></dd>
53
+ <dt>Errors since</dt><dd><%= apm_int(d["error_count"]) %></dd>
54
+ </dl>
55
+ <% else %>
56
+ <div class="bh-empty">No deploys recorded.</div>
57
+ <% end %>
58
+ </section>
59
+ <% end %>
@@ -0,0 +1,37 @@
1
+ <% apm_styles %>
2
+ <% bro_hub_crumb "SQL queries" %>
3
+ <%= bro_hub_hero eyebrow: "Database", title: "SQL queries", tone: :violet,
4
+ lead: "Normalized statements (values replaced by ?), ranked across all requests." %>
5
+ <div class="bh-filters">
6
+ <%= form_with url: apm_queries_path, method: :get, class: "dbh-search" do %>
7
+ <%= hidden_field_tag :window, params[:window] if params[:window].present? %>
8
+ <%= hidden_field_tag :sort, params[:sort] if params[:sort].present? %>
9
+ <%= search_field_tag :search, params[:search], placeholder: "table or keyword", class: "bh-input" %>
10
+ <%= submit_tag "Search", name: nil, class: "bh-chip" %>
11
+ <% end %>
12
+ <span><%= apm_chips(:window, %w[24h 7d 30d], @data&.fetch("window", nil) || "7d") %></span>
13
+ <span><%= apm_chips(:sort, %w[total_time executions p95 max], @data&.fetch("sort", nil) || "total_time", label_for: ->(s) { s.humanize.downcase }) %></span>
14
+ </div>
15
+ <% if @error %>
16
+ <%= apm_error_notice(@error) %>
17
+ <% elsif @data["queries"].empty? %>
18
+ <div class="bh-table-wrap"><div class="bh-empty">No queries match.</div></div>
19
+ <% else %>
20
+ <div class="bh-table-wrap"><div class="bh-table dbh-cols-queries">
21
+ <div class="bh-row is-head"><span>Statement</span><span>Runs</span><span>Total</span><span>Avg</span><span>Max</span><span>p95 request</span></div>
22
+ <% @data["queries"].each do |q| %>
23
+ <div class="bh-row">
24
+ <span><span class="dbh-sql"><%= truncate(q["sql"].to_s, length: 400) %></span><br>
25
+ <%= apm_tag(q["query_type"]) if q["query_type"].present? %>
26
+ <% Array(q["tables"]).first(4).each do |table| %><%= apm_tag(table) %><% end %>
27
+ <%= apm_tag("#{q["n_plus_one_requests"]} N+1", "is-amber") if q["n_plus_one_requests"].to_i.positive? %></span>
28
+ <span><%= apm_int(q["executions"]) %></span>
29
+ <span><%= apm_ms(q["total_duration_ms"]) %></span>
30
+ <span><%= apm_ms(q["avg_duration_ms"]) %></span>
31
+ <span class="bh-cell-muted"><%= apm_ms(q["max_duration_ms"]) %></span>
32
+ <span class="bh-cell-muted"><%= apm_ms(q["p95_request_ms"]) %></span>
33
+ </div>
34
+ <% end %>
35
+ </div></div>
36
+ <%= apm_pager(@data["queries"].size, BroHub::Apm::QueriesController::PER_PAGE, @offset) %>
37
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%# What the apm pages need on top of BroHub's shared styles. %>
2
+ <style<%= %( nonce="#{content_security_policy_nonce}").html_safe if content_security_policy_nonce %>>
3
+ .bh-main code { font: 500 .92em var(--bh-mono); color: var(--bh-text); overflow-wrap: anywhere; }
4
+ .dbh-cols-endpoints { --cols: minmax(220px, 1.6fr) 90px 100px 90px 80px 90px; --min: 720px; }
5
+ .dbh-cols-errors { --cols: minmax(220px, 1.6fr) 90px 150px 150px; --min: 680px; }
6
+ .dbh-cols-queries { --cols: minmax(280px, 2.4fr) 90px 100px 100px 100px 100px; --min: 880px; }
7
+ .dbh-cols-findings { --cols: minmax(240px, 2fr) 130px 110px 110px 150px; --min: 760px; }
8
+ .dbh-cols-deploys { --cols: minmax(180px, 1.4fr) 150px 120px 100px 110px; --min: 680px; }
9
+ .dbh-cols-top { --cols: minmax(220px, 1fr) 100px 100px; --min: 420px; }
10
+ .dbh-sql { font: 500 12px/1.5 var(--bh-mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--bh-text); }
11
+ .dbh-bars { display: block; margin-top: 8px; }
12
+ .dbh-sub { margin: 4px 0 0; font: 400 12px var(--bh-mono); color: var(--bh-muted); }
13
+ .bh-chip.is-on { border-color: var(--bh-violet); background: var(--bh-violet); }
14
+ .dbh-search { display: flex; gap: 8px; }
15
+ </style>
@@ -0,0 +1,47 @@
1
+ <% apm_styles %>
2
+ <% bro_hub_crumb "Status" %>
3
+ <% l = @local %>
4
+ <% problem = l[:enabled] == false || !l[:api_key_set] || l[:sending_paused_until] || l.dig(:circuit_breaker, :state).to_s == "open" || @error&.kind == :unauthorized %>
5
+ <%= bro_hub_hero eyebrow: "The gem, in this process", title: (problem ? "Needs attention" : "Healthy"), tone: (problem ? :amber : :green),
6
+ lead: "Whether dead_bro is on, sending and in sync with DeadBro, and the settings DeadBro hands it." %>
7
+
8
+ <% if @error %><%= apm_error_notice(@error) %><% end %>
9
+
10
+ <div class="bh-split">
11
+ <div class="bh-split-main">
12
+ <section class="bh-block">
13
+ <div class="bh-block-head"><h2 class="bh-h2">In this app</h2></div>
14
+ <dl class="bh-dl">
15
+ <dt>dead_bro version</dt><dd><%= l[:gem_version] %></dd>
16
+ <dt>Tracking</dt><dd><%= apm_yes_no(l[:enabled], yes: "enabled", no: "disabled") %></dd>
17
+ <dt>API key</dt><dd><%= l[:api_key_set] ? apm_tag("set", "is-green") : apm_tag("missing", "is-red") %></dd>
18
+ <dt>Sending to</dt><dd><code><%= l[:endpoint] %></code></dd>
19
+ <dt>Rails env</dt><dd><%= l[:environment] || "-" %></dd>
20
+ <dt>Deploy revision</dt><dd><code><%= l[:deploy_revision] || "-" %></code></dd>
21
+ <dt>Paused until</dt><dd><%= l[:sending_paused_until] ? "#{l[:sending_paused_until]} (account limit reached)" : "not paused" %></dd>
22
+ <dt>Settings received</dt><dd><%= apm_time(l[:settings_received_at]) %></dd>
23
+ <dt>Last heartbeat</dt><dd><%= apm_time(l[:last_heartbeat_at]) %></dd>
24
+ <dt>Circuit breaker</dt>
25
+ <dd><% if (cb = l[:circuit_breaker]) %><%= apm_tag(cb[:state].to_s, cb[:state].to_s == "closed" ? "is-green" : "is-red") %> <span class="bh-cell-muted"><%= cb[:failures] %> failures · last success <%= apm_time(cb[:last_success_at]) %></span><% else %>-<% end %></dd>
26
+ <dt>Dropped payloads</dt><dd><%= apm_int(l[:dropped_payloads]) %> <span class="bh-cell-muted">(queue full)</span></dd>
27
+ <dt>Unserializable</dt><dd><%= apm_int(l[:unserializable_payloads]) %></dd>
28
+ </dl>
29
+ </section>
30
+ </div>
31
+ <div class="bh-split-aside">
32
+ <section class="bh-block">
33
+ <div class="bh-block-head"><h2 class="bh-h2">From DeadBro</h2></div>
34
+ <% if @remote %>
35
+ <dl class="bh-dl">
36
+ <dt>Last gem version seen</dt><dd><%= @remote["gem_version"] || "-" %></dd>
37
+ <dt>Settings changed</dt><dd><%= apm_time(@remote["settings_updated_at"]) %></dd>
38
+ <% @remote["settings"].each do |key, value| %>
39
+ <dt><%= key %></dt><dd><%= value.is_a?(Hash) || value.is_a?(Array) ? (value.blank? ? "-" : value.to_json) : value.to_s %></dd>
40
+ <% end %>
41
+ </dl>
42
+ <% else %>
43
+ <div class="bh-empty">Not available.</div>
44
+ <% end %>
45
+ </section>
46
+ </div>
47
+ </div>
@@ -23,7 +23,7 @@
23
23
  <div class="bh-table" style="--cols: 150px 150px 110px 150px minmax(220px,1fr) 70px; --min: 900px">
24
24
  <div class="bh-row is-head"><span>When</span><span>User</span><span>Gem</span><span>Event</span><span>Target</span><span>Count</span></div>
25
25
  <% @events.each do |event| %>
26
- <%= link_to audit_event_path(event), class: "bh-row" do %>
26
+ <%= link_to audit_event_path(event), class: "bh-row bh-event" do %>
27
27
  <span class="bh-tone-violet"><%= bro_hub_time(event.created_at) %></span>
28
28
  <span class="bh-cell-strong"><%= event.user_label %></span>
29
29
  <span class="bh-cell-muted"><%= event.source_name %></span>
@@ -0,0 +1,39 @@
1
+ <% bro_hub_crumb "Audit log" %>
2
+ <% content_for :bro_hub_crumb_actions do %>
3
+ <% [ [ "All", nil ], *BroHub::Cache::AuditEvent::EVENTS.map { |event| [ cache_event_label(event), event ] } ].each do |label, event| %>
4
+ <%= bro_hub_crumb_link label, cache_audit_path(@filter.merge(event: event).compact), active: @filter[:event] == event %>
5
+ <% end %>
6
+ <% end %>
7
+
8
+ <%= bro_hub_hero eyebrow: "Audit log", title: @total, subtitle: @total == 1 ? "event" : "events",
9
+ lead: "Who revealed, deleted or purged what. Entries can't be changed. Keys and patterns are recorded, never values.",
10
+ stats: [ [ @counts.fetch("value_viewed", 0), "reveals", :amber ], [ %w[ key_deleted keys_purged store_flushed ].sum { |event| @counts.fetch(event, 0) }, "deletions", :red ] ] %>
11
+
12
+ <%= form_with url: cache_audit_path, method: :get, class: "bh-filters" do %>
13
+ <%= hidden_field_tag :event, @filter[:event] if @filter[:event] %>
14
+ <%= text_field_tag :q, @filter[:q], placeholder: "Search keys and patterns", class: "bh-input is-strong", "aria-label": "Search keys and patterns" %>
15
+ <%= text_field_tag :user, @filter[:user], placeholder: "User", class: "bh-input", "aria-label": "User" %>
16
+ <% if BroHub.config.cache.store_names.size > 1 %>
17
+ <%= select_tag :store, options_for_select([ [ "Any store", "" ], *BroHub.config.cache.store_names ], @filter[:store]), class: "bh-select", "aria-label": "Store" %>
18
+ <% end %>
19
+ <%= submit_tag "Filter", name: nil, class: "bh-chip" %>
20
+ <%= link_to "Reset", cache_audit_path(event: @filter[:event]), class: "bh-link-quiet" %>
21
+ <% end %>
22
+
23
+ <div class="bh-table-wrap">
24
+ <div class="bh-table" style="--cols: 150px 150px 100px 120px minmax(220px,1fr) 80px; --min: 900px">
25
+ <div class="bh-row is-head"><span>When</span><span>User</span><span>Action</span><span>Store</span><span>Key or pattern</span><span>Keys</span></div>
26
+ <% @events.each do |event| %>
27
+ <%= link_to cache_audit_event_path(event), class: [ "bh-row", ("bh-edge-red" unless event.event == "value_viewed") ] do %>
28
+ <span class="bh-tone-violet"><%= cache_time(event.created_at) %></span>
29
+ <span class="bh-cell-strong"><%= event.user_label %></span>
30
+ <span><%= cache_event_tag(event.event) %></span>
31
+ <span class="bh-cell-muted"><%= event.store %></span>
32
+ <span class="bh-cell-text" style="overflow-wrap:anywhere"><%= truncate(event.target.to_s, length: 90) %></span>
33
+ <span><%= event.count %></span>
34
+ <% end %>
35
+ <% end %>
36
+ <% if @events.empty? %><div class="bh-empty">Nothing recorded.</div><% end %>
37
+ <%= cache_audit_pager(total: @total, page: @page) %>
38
+ </div>
39
+ </div>
@@ -0,0 +1,48 @@
1
+ <% bro_hub_crumb "Audit log", "##{@event.id}" %>
2
+ <% content_for :bro_hub_crumb_actions do %>
3
+ <%= bro_hub_crumb_link "← Audit log", cache_audit_path %>
4
+ <% end %>
5
+
6
+ <%= bro_hub_hero eyebrow: "#{@event.store} · #{@event.environment}", title: cache_event_label(@event.event),
7
+ subtitle: ("#{cache_count(@event.count, "key")}" if @event.count),
8
+ lead: safe_join([ content_tag(:strong, @event.user_label), " at #{@event.created_at.utc.strftime("%Y-%m-%d %H:%M UTC")}" ]) %>
9
+
10
+ <div class="bh-split">
11
+ <section class="bh-split-main">
12
+ <div class="bh-block-head"><h2 class="bh-h2"><%= @event.event == "keys_purged" ? "Pattern" : "Key" %></h2></div>
13
+ <% if @event.target.present? %>
14
+ <pre class="bh-cmd-code" style="white-space:pre-wrap;overflow-wrap:anywhere"><%= @event.target %></pre>
15
+ <% else %>
16
+ <p class="bh-hint">The whole namespace.</p>
17
+ <% end %>
18
+
19
+ <% if @event.sample.any? %>
20
+ <div class="bh-block-head" style="margin-top:24px">
21
+ <h2 class="bh-h2">Keys deleted</h2>
22
+ <span class="bh-meta">a sample of <%= @event.sample.size %><%= " (more were deleted)" if @event.count.to_i > @event.sample.size %></span>
23
+ </div>
24
+ <div class="bh-log">
25
+ <% @event.sample.each do |key| %>
26
+ <div class="bh-cmd"><pre class="bh-cmd-code" style="white-space:pre-wrap;overflow-wrap:anywhere"><%= key %></pre></div>
27
+ <% end %>
28
+ </div>
29
+ <% end %>
30
+ </section>
31
+
32
+ <div class="bh-split-aside">
33
+ <section class="bh-block">
34
+ <h2 class="bh-h2">Details</h2>
35
+ <dl class="bh-dl">
36
+ <dt>User</dt><dd><%= @event.user_label %></dd>
37
+ <dt>Action</dt><dd><%= cache_event_tag(@event.event) %></dd>
38
+ <dt>When</dt><dd><%= cache_time(@event.created_at) %></dd>
39
+ <dt>Store</dt><dd><%= @event.store %></dd>
40
+ <dt>Environment</dt><dd><%= @event.environment %></dd>
41
+ <dt>Keys</dt><dd><%= @event.count || "-" %></dd>
42
+ <dt>Reason</dt><dd><%= @event.reason.presence || "none given" %></dd>
43
+ <% if @event.details["completed"] == false %><dt>Outcome</dt><dd class="bh-tone-red">failed part way: only the keys counted here were deleted</dd><% end %>
44
+ <% if @event.truncated? %><dt>Limit</dt><dd class="bh-tone-amber">stopped at the per-purge limit</dd><% end %>
45
+ </dl>
46
+ </section>
47
+ </div>
48
+ </div>
@@ -0,0 +1,19 @@
1
+ <% bro_hub_crumb "Flush" %>
2
+ <%= render "bro_hub/cache/shared/store_tabs", path: ->(name) { cache_flush_path(store: name) } %>
3
+
4
+ <%= bro_hub_hero eyebrow: cache_current_store.name, title: "Flush", tone: :red,
5
+ lead: "Delete everything in this cache store's namespace. Every cached page, fragment and value is rebuilt on demand, which can load your database. Recorded in the audit log." %>
6
+
7
+ <% if cache_current_store.namespaced? %>
8
+ <%= form_with url: cache_flush_path, method: :post, class: "bh-filters" do %>
9
+ <%= hidden_field_tag :store, cache_current_store.name %>
10
+ <label class="bh-field">Type <strong><%= cache_current_store.name %></strong> to confirm
11
+ <%= text_field_tag :confirm, nil, class: "bh-input", autocomplete: "off", required: true %>
12
+ </label>
13
+ <%= cache_reason_field(:flush) %>
14
+ <%= submit_tag "Flush #{cache_current_store.name}", name: nil, class: "bh-btn is-auto", style: "background:var(--bh-red)" %>
15
+ <% end %>
16
+ <p class="bh-hint" style="padding:0 var(--bh-pad)">Only keys under the namespace <code><%= cache_current_store.namespace %></code> are deleted.</p>
17
+ <% else %>
18
+ <div class="bh-alert bh-alert-error">This store has no namespace, so flushing it would delete keys that aren't the cache's. Set <code>namespace:</code> on the cache store to enable this. You can still purge by pattern.</div>
19
+ <% end %>
@@ -0,0 +1,36 @@
1
+ <% bro_hub_crumb "Keys" %>
2
+ <%= render "bro_hub/cache/shared/store_tabs", path: ->(name) { cache_root_path(store: name) } %>
3
+
4
+ <%= bro_hub_hero eyebrow: [ cache_current_store.name, (cache_current_store.namespace ? "namespace #{cache_current_store.namespace}" : "no namespace") ].join(" · "),
5
+ title: @listing.entries.size,
6
+ subtitle: @listing.more? ? "keys so far" : (@listing.entries.size == 1 ? "key" : "keys"),
7
+ lead: "Search what is in the cache. Plain text matches anywhere in the key; use * and ? for a pattern. " \
8
+ "Redis is walked in small steps, so on a big cache a page may show only part of the matches: keep looking to continue." %>
9
+
10
+ <% unless cache_current_store.namespaced? %>
11
+ <div class="bh-alert bh-alert-error">This cache store has no namespace, so it shares its Redis database with whatever else lives there. Set <code>namespace:</code> on the cache store to keep CacheBro to the cache's own keys.</div>
12
+ <% end %>
13
+
14
+ <%= form_with url: cache_root_path, method: :get, class: "bh-filters" do %>
15
+ <%= hidden_field_tag :store, cache_current_store.name %>
16
+ <%= text_field_tag :q, @query, placeholder: "Search keys, e.g. posts/ or views/*/show*", class: "bh-input is-strong", "aria-label": "Search keys", autofocus: true %>
17
+ <%= submit_tag "Search", name: nil, class: "bh-chip" %>
18
+ <%= link_to "Reset", cache_root_path(store: cache_current_store.name), class: "bh-link-quiet" %>
19
+ <% end %>
20
+
21
+ <div class="bh-table-wrap">
22
+ <div class="bh-table" style="--cols: minmax(260px,1fr) 150px 100px; --min: 560px">
23
+ <div class="bh-row is-head"><span>Key</span><span>Expires</span><span>Size</span></div>
24
+ <% @listing.entries.each do |entry| %>
25
+ <%= link_to cache_key_path(store: cache_current_store.name, key: entry.key), class: "bh-row" do %>
26
+ <span class="bh-cell-strong" style="overflow-wrap:anywhere"><%= entry.key %></span>
27
+ <span class="bh-cell-muted"><%= cache_ttl(entry.ttl) %></span>
28
+ <span class="bh-cell-muted"><%= cache_size(entry.size) %></span>
29
+ <% end %>
30
+ <% end %>
31
+ <% if @listing.entries.empty? %>
32
+ <div class="bh-empty"><%= @listing.more? ? "Nothing here yet." : "No keys." %></div>
33
+ <% end %>
34
+ <%= cache_pager(@listing, query: @query) %>
35
+ </div>
36
+ </div>
@@ -0,0 +1,57 @@
1
+ <% bro_hub_crumb "Keys", @key.truncate(60) %>
2
+ <% content_for :bro_hub_crumb_actions do %>
3
+ <%= bro_hub_crumb_link "← All keys", cache_root_path(store: cache_current_store.name) %>
4
+ <% end %>
5
+
6
+ <%= bro_hub_hero eyebrow: "#{cache_current_store.name} · #{cache_ttl(@entry.ttl)} · #{cache_size(@entry.size)}",
7
+ title: "Key", lead: @key %>
8
+
9
+ <div class="bh-split">
10
+ <section class="bh-split-main">
11
+ <div class="bh-block-head"><h2 class="bh-h2">Value</h2></div>
12
+ <% if @value %>
13
+ <% if @value.error %>
14
+ <div class="bh-alert bh-alert-error">This value could not be read: <%= @value.error %></div>
15
+ <% else %>
16
+ <p class="bh-meta"><%= @value.klass %><%= " · shown up to #{number_with_delimiter(BroHub.config.cache.value_preview_length)} characters" if @value.truncated %></p>
17
+ <pre class="bh-cmd-code" style="white-space:pre-wrap;overflow-wrap:anywhere"><%= @value.preview %></pre>
18
+ <% end %>
19
+ <p class="bh-hint">This reveal was recorded in the audit log.</p>
20
+ <% elsif cache_allows?(:view_values) %>
21
+ <p class="bh-hint">Values can hold personal data. Revealing one is recorded: who, which key, when.</p>
22
+ <%= form_with url: cache_reveal_key_path, method: :post do %>
23
+ <%= hidden_field_tag :store, cache_current_store.name %>
24
+ <%= hidden_field_tag :key, @key %>
25
+ <%= cache_reason_field(:reveal) %>
26
+ <%= submit_tag "Reveal value", name: nil, class: "bh-btn is-auto", style: "margin-top:14px" %>
27
+ <% end %>
28
+ <% else %>
29
+ <p class="bh-hint">You may see that this key exists, not what it holds.</p>
30
+ <% end %>
31
+ </section>
32
+
33
+ <div class="bh-split-aside">
34
+ <section class="bh-block">
35
+ <h2 class="bh-h2">Details</h2>
36
+ <dl class="bh-dl">
37
+ <dt>Store</dt><dd><%= cache_current_store.name %></dd>
38
+ <dt>Key</dt><dd><%= @key %></dd>
39
+ <dt>Expires</dt><dd><%= cache_ttl(@entry.ttl) %></dd>
40
+ <dt>Size</dt><dd><%= cache_size(@entry.size) %> serialized</dd>
41
+ </dl>
42
+ </section>
43
+
44
+ <% if cache_allows?(:delete) %>
45
+ <section class="bh-block">
46
+ <h2 class="bh-h2">Delete</h2>
47
+ <p class="bh-hint">The next request that needs it will rebuild it. Recorded in the audit log.</p>
48
+ <%= form_with url: cache_key_path, method: :delete do %>
49
+ <%= hidden_field_tag :store, cache_current_store.name %>
50
+ <%= hidden_field_tag :key, @key %>
51
+ <%= cache_reason_field(:delete) %>
52
+ <%= submit_tag "Delete key", name: nil, class: "bh-btn is-auto", style: "margin-top:14px;background:var(--bh-red)" %>
53
+ <% end %>
54
+ </section>
55
+ <% end %>
56
+ </div>
57
+ </div>
@@ -0,0 +1,17 @@
1
+ <% bro_hub_crumb "Purge" %>
2
+ <%= render "bro_hub/cache/shared/store_tabs", path: ->(name) { cache_purge_path(store: name) } %>
3
+
4
+ <%= bro_hub_hero eyebrow: cache_current_store.name, title: "Purge", tone: :red,
5
+ lead: "Delete every key that matches a pattern. You see how many match before anything is deleted, and the purge is recorded." %>
6
+
7
+ <% unless cache_current_store.namespaced? %>
8
+ <div class="bh-alert bh-alert-error">This cache store has no namespace: a pattern can match keys that aren't the cache's. Check the preview carefully.</div>
9
+ <% end %>
10
+
11
+ <%= form_with url: cache_purge_preview_path, method: :post, class: "bh-filters" do %>
12
+ <%= hidden_field_tag :store, cache_current_store.name %>
13
+ <%= text_field_tag :pattern, nil, placeholder: "Pattern, e.g. posts/* or views/posts/*", class: "bh-input is-strong", "aria-label": "Pattern", required: true, autofocus: true, autocomplete: "off" %>
14
+ <%= cache_reason_field(:purge) %>
15
+ <%= submit_tag "Preview", name: nil, class: "bh-chip" %>
16
+ <% end %>
17
+ <p class="bh-hint" style="padding:0 var(--bh-pad)">The pattern is used as typed: <code>posts/*</code> means keys starting with <code>posts/</code>. <code>*</code> is any run of characters, <code>?</code> is one.</p>
@@ -0,0 +1,37 @@
1
+ <% bro_hub_crumb "Purge", "Confirm" %>
2
+ <% content_for :bro_hub_crumb_actions do %>
3
+ <%= bro_hub_crumb_link "← Change pattern", cache_purge_path(store: cache_current_store.name) %>
4
+ <% end %>
5
+
6
+ <%= bro_hub_hero eyebrow: "#{cache_current_store.name} · #{@pattern}",
7
+ title: "#{number_with_delimiter(@matches.count)}#{"+" if @matches.truncated}",
8
+ subtitle: @matches.count == 1 ? "key matches" : "keys match", tone: (@matches.count.zero? ? nil : :red),
9
+ lead: @matches.count.zero? ? "Nothing matches. Nothing to delete." : "Nothing has been deleted yet." %>
10
+
11
+ <% if @matches.count.positive? %>
12
+ <div class="bh-split">
13
+ <section class="bh-split-main">
14
+ <div class="bh-block-head"><h2 class="bh-h2">For example</h2></div>
15
+ <div class="bh-log">
16
+ <% @matches.sample.each do |key| %>
17
+ <div class="bh-cmd"><pre class="bh-cmd-code" style="white-space:pre-wrap;overflow-wrap:anywhere"><%= key %></pre></div>
18
+ <% end %>
19
+ </div>
20
+ <% if @matches.truncated %>
21
+ <p class="bh-hint is-error">More than <%= number_with_delimiter(BroHub.config.cache.max_purge_keys) %> keys match. One purge deletes at most that many, so run it again for the rest.</p>
22
+ <% end %>
23
+ </section>
24
+ <div class="bh-split-aside">
25
+ <section class="bh-block">
26
+ <h2 class="bh-h2">Delete them</h2>
27
+ <p class="bh-hint">The count can change by the time you confirm. What is deleted is recorded, with this pattern<%= " and your reason" if @reason %>.</p>
28
+ <%= form_with url: cache_purge_path, method: :post do %>
29
+ <%= hidden_field_tag :store, cache_current_store.name %>
30
+ <%= hidden_field_tag :pattern, @pattern %>
31
+ <%= hidden_field_tag :reason, @reason %>
32
+ <%= submit_tag "Purge #{cache_count(@matches.count, "key")}#{"+" if @matches.truncated}", name: nil, class: "bh-btn is-auto", style: "margin-top:14px;background:var(--bh-red)" %>
33
+ <% end %>
34
+ </section>
35
+ </div>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <%# Tabs on the right of the breadcrumb bar when there is more than one cache store. `path` builds the link for a store name. %>
2
+ <% if BroHub.config.cache.store_names.size > 1 %>
3
+ <% current = params[:store].presence || BroHub.config.cache.store_names.first %>
4
+ <% content_for :bro_hub_crumb_actions do %>
5
+ <% BroHub.config.cache.store_names.each do |name| %>
6
+ <%= bro_hub_crumb_link name, path.call(name), active: name == current %>
7
+ <% end %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% bro_hub_crumb "Unsupported store" %>
2
+ <%= render "bro_hub/cache/shared/store_tabs", path: ->(name) { cache_root_path(store: name) } %>
3
+ <%= bro_hub_hero eyebrow: "Cache", title: "Can't manage this store", tone: :amber, lead: @unsupported %>
@@ -0,0 +1,31 @@
1
+ <% env_styles %>
2
+ <% bro_hub_crumb "Audit log" %>
3
+ <%= bro_hub_hero eyebrow: "Audit log · #{@environment.name}", title: @events.size.to_s, subtitle: (@events.size == 1 ? "event" : "events"), tone: :green,
4
+ lead: "Who proposed, reviewed or revealed what, and when proposals went live. Key names only, never values." %>
5
+
6
+ <% if @events.empty? %>
7
+ <div class="bh-table-wrap"><div class="bh-empty">Nothing recorded yet.</div></div>
8
+ <% else %>
9
+ <div class="bh-table-wrap">
10
+ <div class="bh-table eb-cols-audit">
11
+ <div class="bh-row is-head"><span>When</span><span>Who</span><span>Event</span><span>Keys</span><span>Status</span></div>
12
+ <% @events.each do |event| %>
13
+ <div class="bh-row">
14
+ <span class="bh-cell-muted" title="<%= event.created_at.utc.iso8601 %>"><%= env_time(event.created_at) %></span>
15
+ <span class="bh-cell-strong"><%= event.user_label %></span>
16
+ <span><span class="bh-tag"><%= event.event.humanize %></span></span>
17
+ <span><%= safe_join(event.keys, tag.br) %></span>
18
+ <span>
19
+ <% if event.event == "proposal_created" %>
20
+ <%= env_deployment_badge(event, @live_proposal) %>
21
+ <% elsif event.event == "credentials_deployed" %>
22
+ <span class="bh-tag is-amber" title="The running file is not from an EnvBro proposal (edited by hand, say).">not from a proposal</span>
23
+ <% elsif event.modified_after_review? %>
24
+ <span class="bh-tag is-amber" title="The deployed file is not the one EnvBro built. It was re-encrypted after review.">modified after review</span>
25
+ <% end %>
26
+ </span>
27
+ </div>
28
+ <% end %>
29
+ </div>
30
+ </div>
31
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <% env_styles %>
2
+ <% bro_hub_crumb "Environments" %>
3
+ <%= bro_hub_hero eyebrow: "Encrypted credentials", title: "1", subtitle: "environment", tone: :green,
4
+ lead: "Pick an environment to propose a change. Existing values stay hidden." %>
5
+
6
+ <div class="bh-table-wrap">
7
+ <div class="bh-table eb-cols-envs">
8
+ <div class="bh-row is-head"><span>File</span><span>Keys</span><span>Groups</span><span>Last change</span><span>By</span></div>
9
+ <% credentials = (@environment.current_credentials if @environment.ready?) %>
10
+ <% meta = credentials&.metadata %>
11
+ <% meta = nil unless meta.is_a?(Hash) %>
12
+ <%= link_to (env_can?(:propose) ? env_new_proposal_path : env_new_review_path), class: "bh-row eb-env-row" do %>
13
+ <span class="eb-env-name"><%= @environment.name %><small>.yml.enc</small></span>
14
+ <% if credentials %>
15
+ <span><%= credentials.key_paths.size %></span>
16
+ <span><%= credentials.outline.count(&:group) %></span>
17
+ <span class="bh-cell-muted"><%= meta&.fetch("proposed_at", nil).presence || "-" %></span>
18
+ <span><%= meta&.fetch("proposed_by", nil).presence || "-" %></span>
19
+ <% else %>
20
+ <span class="bh-cell-muted">-</span><span class="bh-cell-muted">-</span>
21
+ <span><%= env_environment_badge(@environment.status) %></span><span></span>
22
+ <% end %>
23
+ <% end %>
24
+ </div>
25
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="newkey-row" data-new-key-row>
2
+ <input type="text" name="new_keys[<%= index %>][key]" value="<%= change.key %>" placeholder="stripe.publishable_key"
3
+ autocomplete="off" spellcheck="false" aria-label="New key" class="mono" data-track>
4
+ <textarea name="new_keys[<%= index %>][secret_value]" rows="1" placeholder="Value"
5
+ autocomplete="off" spellcheck="false" aria-label="Value" data-track data-autogrow><%= change.value %></textarea>
6
+ <button type="button" class="icon-btn" data-remove-new-key title="Remove" aria-label="Remove this new key">×</button>
7
+ </div>