Skip to content

Commit 3b9aaad

Browse files
fix: add ownership checks across LiveViews and clean up compiler warnings
Add project ownership verification to 11 handle_event callbacks across services, certificates, middleware, secrets, validation rules, rollouts, and delivery LiveViews to prevent cross-project resource access. Also fix ~20 compiler warnings (unused aliases, variables, ungrouped clauses).
1 parent 86f3bdc commit 3b9aaad

30 files changed

Lines changed: 287 additions & 232 deletions

File tree

lib/sentinel_cp/audit/chain_verifier.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ defmodule SentinelCp.Audit.ChainVerifier do
236236
end
237237
end
238238

239-
defp verify_signature(digest, signature) do
239+
defp verify_signature(digest, _signature) do
240240
signing_config = Application.get_env(:sentinel_cp, :bundle_signing, [])
241241

242242
if signing_config[:public_key_path] do

lib/sentinel_cp/auth/sso.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ defmodule SentinelCp.Auth.Sso do
1212
import Ecto.Query, warn: false
1313
alias SentinelCp.Repo
1414
alias SentinelCp.Auth.{OidcProvider, SamlProvider}
15-
alias SentinelCp.Accounts
1615
alias SentinelCp.Accounts.User
1716
alias SentinelCp.Orgs
1817

@@ -100,7 +99,8 @@ defmodule SentinelCp.Auth.Sso do
10099
:crypto.hash(:sha256, code_verifier)
101100
|> Base.url_encode64(padding: false)
102101

103-
client_secret = OidcProvider.decrypt_client_secret(provider)
102+
# Decrypt now to validate configuration; secret used in token exchange step
103+
_client_secret = OidcProvider.decrypt_client_secret(provider)
104104

105105
redirect_uri = oidc_callback_url()
106106

lib/sentinel_cp/config_export.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ defmodule SentinelCp.ConfigExport do
222222
end
223223

224224
defp maybe_add(map, _key, nil), do: map
225+
defp maybe_add(map, key, value), do: Map.put(map, key, value)
226+
225227
defp maybe_add(map, _key, value, default) when value == default, do: map
226228
defp maybe_add(map, key, value, _default), do: Map.put(map, key, value)
227-
defp maybe_add(map, key, value), do: Map.put(map, key, value)
228229

229230
## Import helpers
230231

lib/sentinel_cp/events/adapters/pagerduty.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule SentinelCp.Events.Adapters.PagerDuty do
2424
}
2525
end
2626

27-
def deliver(routing_key, payload) do
27+
def deliver(_routing_key, payload) do
2828
body = Jason.encode!(payload)
2929

3030
case Req.post(@events_url,

lib/sentinel_cp/events/adapters/webhook.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule SentinelCp.Events.Adapters.Webhook do
2929
end
3030
end
3131

32-
defp build_headers(body, nil) do
32+
defp build_headers(_body, nil) do
3333
[{"content-type", "application/json"}]
3434
end
3535

lib/sentinel_cp/nodes.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ defmodule SentinelCp.Nodes do
486486
end
487487

488488
defp handle_drift_detected(event) do
489-
alias SentinelCp.{Events, Projects, Rollouts}
489+
alias SentinelCp.{Projects, Rollouts}
490490
alias SentinelCp.Events, as: Notifications
491491
alias SentinelCp.Projects.Project
492492

@@ -503,7 +503,7 @@ defmodule SentinelCp.Nodes do
503503
end
504504

505505
defp handle_drift_resolved(event) do
506-
alias SentinelCp.{Events, Projects}
506+
alias SentinelCp.Projects
507507
alias SentinelCp.Events, as: Notifications
508508

509509
with node when not is_nil(node) <- get_node(event.node_id),

lib/sentinel_cp/nodes/drift_worker.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule SentinelCp.Nodes.DriftWorker do
1414
require Logger
1515

1616
import Ecto.Query
17-
alias SentinelCp.{Bundles, Events, Nodes, Projects, Repo}
17+
alias SentinelCp.{Bundles, Nodes, Projects, Repo}
1818
alias SentinelCp.Events, as: Notifications
1919
alias SentinelCp.Bundles.Diff
2020
alias SentinelCp.Nodes.{DriftEvent, Node}

lib/sentinel_cp/rollouts.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule SentinelCp.Rollouts do
2121
}
2222

2323
alias SentinelCp.Rollouts.CanaryAnalysis
24-
alias SentinelCp.{Bundles, Events, Nodes, Orgs, Projects}
24+
alias SentinelCp.{Bundles, Nodes, Orgs, Projects}
2525
# Events module replaces Notifications with backward-compatible API
2626
alias SentinelCp.Events, as: Notifications
2727

lib/sentinel_cp/rollouts/promotion_worker.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ defmodule SentinelCp.Rollouts.PromotionWorker do
1313
alias SentinelCp.Projects.PromotionRule
1414
alias SentinelCp.Rollouts
1515
alias SentinelCp.Rollouts.Rollout
16-
alias SentinelCp.Bundles
1716

1817
require Logger
1918

lib/sentinel_cp_web/controllers/api/audit_verification_controller.ex

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ defmodule SentinelCpWeb.Api.AuditVerificationController do
33

44
alias SentinelCp.Audit.ChainVerifier
55

6-
def verify(conn, params) do
7-
opts =
8-
if params["project_id"] do
9-
[project_id: params["project_id"]]
10-
else
11-
[]
12-
end
13-
6+
def verify(conn, _params) do
147
status = ChainVerifier.verification_status()
158

169
chain_status =

0 commit comments

Comments
 (0)