Skip to content

Commit 75d00b1

Browse files
committed
fix: solve semgrep warnings
1 parent a7ffe58 commit 75d00b1

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

app/controllers/api/v1/admin/players_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,10 @@ def require_admin_access
308308
end
309309

310310
def set_player
311-
# Admin finds players across ALL orgs — must bypass OrganizationScoped default_scope
312-
@player = Player.unscoped.find(params[:id])
311+
# Admin finds players across ALL orgs — must bypass OrganizationScoped default_scope.
312+
# Access control is enforced by require_admin_access before_action on every action
313+
# that calls set_player. Unscoped is intentional and safe in this admin context.
314+
@player = Player.unscoped.find(params[:id]) # nosemgrep: ruby.rails.security.brakeman.check-unscoped-find.check-unscoped-find
313315
rescue ActiveRecord::RecordNotFound
314316
render_error(
315317
message: 'Player not found',

app/mailers/user_mailer.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ class UserMailer < ApplicationMailer
44
def password_reset(user, reset_token)
55
@user = user
66
@reset_token = reset_token
7-
@reset_url = "#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/reset-password?token=#{reset_token.token}"
7+
frontend_url = ENV.fetch('FRONTEND_URL', 'http://localhost:3000')
8+
parsed_uri = URI.parse(frontend_url)
9+
unless parsed_uri.is_a?(URI::HTTP)
10+
raise ArgumentError, "FRONTEND_URL must use http or https scheme (got: #{parsed_uri.scheme.inspect})"
11+
end
12+
13+
@reset_url = "#{frontend_url}/reset-password?token=#{reset_token.token}"
814
@expires_in = ((reset_token.expires_at - Time.current) / 60).to_i # minutes
915

1016
mail(

app/modules/meta_intelligence/controllers/builds_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def apply_filters(scope)
123123
end
124124

125125
def build_create_params
126+
# nosemgrep: ruby.lang.security.model-attr-accessible.model-attr-accessible
127+
# :role is the LoL champion role (adc/jungle/mid/etc.), not a user authorization role.
128+
# SavedBuild has no admin/banned/account_id fields — mass assignment risk does not apply.
126129
params.require(:build).permit(
127130
:champion, :role, :patch_version, :title, :notes, :is_public,
128131
:primary_rune_tree, :secondary_rune_tree,

app/views/user_mailer/password_reset.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<p>Click the button below to reset your password:</p>
88

99
<p style="text-align: center;">
10+
<%# nosemgrep: ruby.rails.security.audit.xss.templates.var-in-href.var-in-href
11+
@reset_url is validated in UserMailer#password_reset to be http/https only (URI::HTTP check) %>
1012
<a href="<%= @reset_url %>" class="button">Reset Password</a>
1113
</p>
1214

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# Setting force_ssl = true would cause redirect loops.
3838
#
3939
# Security: We trust X-Forwarded-Proto header from Traefik to detect HTTPS
40-
config.force_ssl = false
40+
config.force_ssl = false # nosemgrep: ruby.lang.security.force-ssl-false.force-ssl-false
4141
config.ssl_options = { redirect: { exclude: ->(request) { request.path.start_with?('/health') } } }
4242

4343
# Trust all proxies (Traefik, Cloudflare)

0 commit comments

Comments
 (0)