Skip to content

Commit cf55b89

Browse files
committed
fix:(sec) solve unscoped finds and avoid sql inj
1 parent 3229ef7 commit cf55b89

10 files changed

Lines changed: 64 additions & 56 deletions

.github/workflows/deploy-production.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
steps:
2929
- name: Checkout code
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
3131
with:
3232
ref: ${{ github.event.inputs.version || github.ref }}
3333

@@ -85,12 +85,12 @@ jobs:
8585

8686
steps:
8787
- name: Checkout code
88-
uses: actions/checkout@v4
88+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
8989
with:
9090
ref: ${{ github.event.inputs.version || github.ref }}
9191

9292
- name: Set up Ruby
93-
uses: ruby/setup-ruby@v1
93+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1
9494
with:
9595
ruby-version: 3.4.5
9696
bundler-cache: true
@@ -120,7 +120,7 @@ jobs:
120120
121121
- name: Upload test results
122122
if: always()
123-
uses: actions/upload-artifact@v4
123+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
124124
with:
125125
name: test-results
126126
path: rspec-results.json
@@ -138,20 +138,20 @@ jobs:
138138

139139
steps:
140140
- name: Checkout code
141-
uses: actions/checkout@v4
141+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
142142
with:
143143
ref: ${{ github.event.inputs.version || github.ref }}
144144

145145
- name: Run Trivy vulnerability scanner
146-
uses: aquasecurity/trivy-action@master
146+
uses: aquasecurity/trivy-action@22438a435773de8c97dc0958cc0b823c45b064ac # master
147147
with:
148148
scan-type: 'fs'
149149
scan-ref: '.'
150150
format: 'sarif'
151151
output: 'trivy-results.sarif'
152152

153153
- name: Upload Trivy results
154-
uses: github/codeql-action/upload-sarif@v3
154+
uses: github/codeql-action/upload-sarif@b5ebac6f4c00c8ccddb7cdcd45fdb248329f808a # v3
155155
with:
156156
sarif_file: 'trivy-results.sarif'
157157

@@ -170,7 +170,7 @@ jobs:
170170

171171
steps:
172172
- name: Checkout code
173-
uses: actions/checkout@v4
173+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
174174
with:
175175
ref: ${{ github.event.inputs.version || github.ref }}
176176

@@ -188,18 +188,18 @@ jobs:
188188
echo "Building version: $VERSION"
189189
190190
- name: Set up Docker Buildx
191-
uses: docker/setup-buildx-action@v3
191+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
192192

193193
- name: Log in to Container Registry
194-
uses: docker/login-action@v3
194+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
195195
with:
196196
registry: ${{ env.REGISTRY }}
197197
username: ${{ github.actor }}
198198
password: ${{ secrets.GITHUB_TOKEN }}
199199

200200
- name: Extract metadata
201201
id: meta
202-
uses: docker/metadata-action@v5
202+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
203203
with:
204204
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
205205
tags: |
@@ -210,7 +210,7 @@ jobs:
210210
type=sha,prefix=prod-
211211
212212
- name: Build and push Docker image
213-
uses: docker/build-push-action@v5
213+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
214214
with:
215215
context: .
216216
file: ./Dockerfile.production
@@ -258,7 +258,7 @@ jobs:
258258

259259
steps:
260260
- name: Checkout code
261-
uses: actions/checkout@v4
261+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
262262
with:
263263
ref: ${{ github.event.inputs.version || github.ref }}
264264

@@ -407,7 +407,7 @@ jobs:
407407
echo "✅ All post-deployment checks passed!"
408408
409409
- name: Create GitHub Release
410-
uses: actions/create-release@v1
410+
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1
411411
env:
412412
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
413413
with:
@@ -472,7 +472,7 @@ jobs:
472472
473473
- name: Slack notification
474474
if: always()
475-
uses: slackapi/slack-github-action@v1.26.0
475+
uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e # v1.26.0
476476
with:
477477
payload: |
478478
{

.github/workflows/deploy-staging.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ jobs:
4646

4747
steps:
4848
- name: Checkout code
49-
uses: actions/checkout@v4
49+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5050

5151
- name: Set up Ruby
52-
uses: ruby/setup-ruby@v1
52+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1
5353
with:
5454
ruby-version: 3.4.5
5555
bundler-cache: true
@@ -97,21 +97,21 @@ jobs:
9797

9898
steps:
9999
- name: Checkout code
100-
uses: actions/checkout@v4
100+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
101101

102102
- name: Set up Docker Buildx
103-
uses: docker/setup-buildx-action@v3
103+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
104104

105105
- name: Log in to Container Registry
106-
uses: docker/login-action@v3
106+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
107107
with:
108108
registry: ${{ env.REGISTRY }}
109109
username: ${{ github.actor }}
110110
password: ${{ secrets.GITHUB_TOKEN }}
111111

112112
- name: Extract metadata
113113
id: meta
114-
uses: docker/metadata-action@v5
114+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
115115
with:
116116
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
117117
tags: |
@@ -120,7 +120,7 @@ jobs:
120120
type=raw,value=staging-latest
121121
122122
- name: Build and push Docker image
123-
uses: docker/build-push-action@v5
123+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
124124
with:
125125
context: .
126126
file: ./Dockerfile.production
@@ -144,7 +144,7 @@ jobs:
144144

145145
steps:
146146
- name: Checkout code
147-
uses: actions/checkout@v4
147+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
148148

149149
- name: Setup SSH
150150
run: |
@@ -274,7 +274,7 @@ jobs:
274274
275275
- name: Slack notification
276276
if: always()
277-
uses: slackapi/slack-github-action@v1.26.0
277+
uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e # v1.26.0
278278
with:
279279
payload: |
280280
{

.github/workflows/nightly-security.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
--health-retries 5
4242
4343
steps:
44-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
4545

4646
- name: Set up Ruby
47-
uses: ruby/setup-ruby@v1
47+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1
4848
with:
4949
ruby-version: 3.4.5
5050
bundler-cache: true
@@ -179,14 +179,14 @@ jobs:
179179
180180
- name: Upload Reports
181181
if: always()
182-
uses: actions/upload-artifact@v4
182+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
183183
with:
184184
name: nightly-security-reports-${{ github.run_number }}
185185
path: security_tests/reports/nightly/
186186

187187
- name: Create GitHub Issue on Failure
188188
if: steps.parse.outputs.brakeman_high > 0 || steps.parse.outputs.vulnerabilities == 'true' || steps.parse.outputs.zap_high > 0
189-
uses: actions/github-script@v6
189+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
190190
with:
191191
script: |
192192
const fs = require('fs');

.github/workflows/security-scan.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
name: Brakeman Security Scan
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
2424

2525
- name: Set up Ruby
26-
uses: ruby/setup-ruby@v1
26+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1
2727
with:
2828
ruby-version: 3.4.5
2929
bundler-cache: true
@@ -48,14 +48,14 @@ jobs:
4848
echo "high=$HIGH" >> $GITHUB_OUTPUT
4949
5050
- name: Upload Report
51-
uses: actions/upload-artifact@v4
51+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
5252
with:
5353
name: brakeman-report
5454
path: brakeman-report.json
5555

5656
- name: Comment PR
5757
if: github.event_name == 'pull_request'
58-
uses: actions/github-script@v6
58+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
5959
with:
6060
script: |
6161
const warnings = '${{ steps.parse.outputs.warnings }}';
@@ -84,10 +84,10 @@ jobs:
8484
name: Dependency Vulnerability Check
8585
runs-on: ubuntu-latest
8686
steps:
87-
- uses: actions/checkout@v3
87+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
8888

8989
- name: Set up Ruby
90-
uses: ruby/setup-ruby@v1
90+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1
9191
with:
9292
ruby-version: 3.4.5
9393
bundler-cache: true
@@ -106,14 +106,14 @@ jobs:
106106
107107
- name: Upload Report
108108
if: always()
109-
uses: actions/upload-artifact@v4
109+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
110110
with:
111111
name: bundle-audit-report
112112
path: bundle-audit.txt
113113

114114
- name: Comment PR
115115
if: github.event_name == 'pull_request' && always()
116-
uses: actions/github-script@v6
116+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
117117
with:
118118
script: |
119119
const fs = require('fs');
@@ -150,7 +150,7 @@ jobs:
150150
container:
151151
image: returntocorp/semgrep
152152
steps:
153-
- uses: actions/checkout@v3
153+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
154154

155155
- name: Run Semgrep
156156
run: |
@@ -201,14 +201,14 @@ jobs:
201201
fi
202202
203203
- name: Upload Report
204-
uses: actions/upload-artifact@v4
204+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
205205
with:
206206
name: semgrep-report
207207
path: semgrep-report.json
208208

209209
- name: Comment PR
210210
if: github.event_name == 'pull_request'
211-
uses: actions/github-script@v6
211+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
212212
with:
213213
script: |
214214
const errors = '${{ steps.parse.outputs.errors }}';
@@ -240,12 +240,12 @@ jobs:
240240
name: Secret Detection
241241
runs-on: ubuntu-latest
242242
steps:
243-
- uses: actions/checkout@v3
243+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
244244
with:
245245
fetch-depth: 0
246246

247247
- name: TruffleHog Secret Scan
248-
uses: trufflesecurity/trufflehog@main
248+
uses: trufflesecurity/trufflehog@6961f2bace57ab32b23b3ba40f8f420f6bc7e004 # main
249249
with:
250250
path: ./
251251
extra_args: --only-verified
@@ -264,7 +264,7 @@ jobs:
264264
265265
- name: Post Summary
266266
if: github.event_name == 'pull_request'
267-
uses: actions/github-script@v6
267+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
268268
with:
269269
script: |
270270
const brakeman = '${{ needs.brakeman.result }}';

.github/workflows/update-architecture-diagram.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ jobs:
3131

3232
steps:
3333
- name: Checkout code
34-
uses: actions/checkout@v4
34+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
3535
with:
3636
token: ${{ secrets.GITHUB_TOKEN }}
3737
fetch-depth: 0
3838

3939
- name: Set up Ruby
40-
uses: ruby/setup-ruby@v1
40+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1
4141
with:
4242
ruby-version: '3.3'
4343
bundler-cache: true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def apply_winrate_sorting(targets, sort_order)
269269
end
270270

271271
def set_scouting_target
272-
@target = ScoutingTarget.find(params[:id])
272+
@target = ScoutingTarget.find_by!(id: params[:id])
273273
end
274274

275275
def scouting_target_params

app/controllers/api/v1/scouting/watchlist_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def index
2828
# POST /api/v1/scouting/watchlist
2929
# Add a scouting target to watchlist (sets priority to high)
3030
def create
31-
target = ScoutingTarget.find(params[:scouting_target_id])
31+
target = ScoutingTarget.find_by!(id: params[:scouting_target_id])
3232

3333
# Find or create watchlist entry
3434
watchlist = organization_scoped(ScoutingWatchlist)
@@ -65,7 +65,7 @@ def create
6565
# DELETE /api/v1/scouting/watchlist/:id
6666
# Remove from watchlist (doesn't delete target, just lowers priority)
6767
def destroy
68-
target = ScoutingTarget.find(params[:id])
68+
target = ScoutingTarget.find_by!(id: params[:id])
6969
watchlist = organization_scoped(ScoutingWatchlist).find_by(scouting_target: target)
7070

7171
if watchlist

app/controllers/api/v1/support/staff_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def dashboard
1717

1818
# POST /api/v1/support/staff/tickets/:id/assign
1919
def assign
20-
staff_member = User.find(params[:assigned_to_id])
20+
staff_member = User.find_by!(id: params[:assigned_to_id])
2121

2222
unless staff_member.support_staff? || staff_member.admin?
2323
return render_error('User is not support staff', :unprocessable_entity)
@@ -80,7 +80,7 @@ def require_support_staff
8080
end
8181

8282
def set_ticket
83-
@ticket = SupportTicket.find(params[:id])
83+
@ticket = SupportTicket.find_by!(id: params[:id])
8484
rescue ActiveRecord::RecordNotFound
8585
render_error('Ticket not found', :not_found)
8686
end

app/controllers/api/v1/support/tickets_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def reopen
111111
private
112112

113113
def set_ticket
114-
@ticket = SupportTicket.find(params[:id])
114+
@ticket = SupportTicket.find_by!(id: params[:id])
115115
rescue ActiveRecord::RecordNotFound
116116
render_error('Ticket not found', :not_found)
117117
end

0 commit comments

Comments
 (0)