Skip to content

Commit 266dcdd

Browse files
authored
Merge branch 'main' into enhancement/message-notifications
2 parents e6b575f + a70d800 commit 266dcdd

File tree

68 files changed

+844
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+844
-133
lines changed

.github/workflows/brakeman.yml

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow integrates Brakeman with GitHub's Code Scanning feature
7-
# Brakeman is a static analysis security vulnerability scanner for Ruby on Rails applications
8-
91
name: Brakeman Scan
102

113
on:
124
push:
135
branches: [ "main" ]
146
pull_request:
15-
# The branches below must be a subset of the branches above
167
branches: [ "main" ]
178
schedule:
189
- cron: '26 3 * * 0'
@@ -22,37 +13,38 @@ permissions:
2213

2314
jobs:
2415
brakeman-scan:
25-
permissions:
26-
contents: read # for actions/checkout to fetch code
27-
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
28-
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
2916
name: Brakeman Scan
17+
# Option A: stay on latest (24.04) – requires up-to-date setup-ruby
3018
runs-on: ubuntu-latest
19+
# Option B (fallback): force older image if you prefer
20+
# runs-on: ubuntu-22.04
21+
22+
permissions:
23+
contents: read
24+
security-events: write
25+
actions: read
26+
3127
steps:
32-
# Checkout the repository to the GitHub Actions runner
33-
- name: Checkout
34-
uses: actions/checkout@v3
35-
36-
# Customize the ruby version depending on your needs
37-
- name: Setup Ruby
38-
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
39-
with:
40-
ruby-version: '3.2'
41-
42-
- name: Setup Brakeman
43-
env:
44-
BRAKEMAN_VERSION: '4.10' # SARIF support is provided in Brakeman version 4.10+
45-
run: |
46-
gem install brakeman --version $BRAKEMAN_VERSION
47-
48-
# Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis
49-
- name: Scan
50-
continue-on-error: true
51-
run: |
52-
brakeman -f sarif -o output.sarif.json .
53-
54-
# Upload the SARIF file generated in the previous step
55-
- name: Upload SARIF
56-
uses: github/codeql-action/upload-sarif@v2
57-
with:
58-
sarif_file: output.sarif.json
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Ruby
32+
# Use the rolling v1 tag so you get fixes for new runner images
33+
uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: '3.2' # or your exact patch, e.g. '3.2.2'
36+
# bundler-cache not needed since we install brakeman directly
37+
38+
- name: Setup Brakeman
39+
run: |
40+
gem install brakeman
41+
42+
- name: Scan (SARIF)
43+
continue-on-error: true
44+
run: |
45+
brakeman -f sarif -o output.sarif.json .
46+
47+
- name: Upload SARIF
48+
uses: github/codeql-action/upload-sarif@v3
49+
with:
50+
sarif_file: output.sarif.json

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
# Initializes the CodeQL tools for scanning.
5252
- name: Initialize CodeQL
53-
uses: github/codeql-action/init@v2
53+
uses: github/codeql-action/init@v3
5454
with:
5555
languages: ${{ matrix.language }}
5656
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -64,7 +64,7 @@ jobs:
6464
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
6565
# If this step fails, then you should remove it and run the build manually (see below)
6666
- name: Autobuild
67-
uses: github/codeql-action/autobuild@v2
67+
uses: github/codeql-action/autobuild@v3
6868

6969
# ℹ️ Command-line programs to run using the OS shell.
7070
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -77,6 +77,6 @@ jobs:
7777
# ./location_of_script_within_repo/buildscript.sh
7878

7979
- name: Perform CodeQL Analysis
80-
uses: github/codeql-action/analyze@v2
80+
uses: github/codeql-action/analyze@v3
8181
with:
8282
category: "/language:${{matrix.language}}"

.github/workflows/rubyonrails.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
- ruby: '3.4.4'
1414
rails: '7.1.5.1'
1515
allowed_failure: false # ✅ required
16-
- ruby: '3.4.4'
17-
rails: '7.2'
18-
allowed_failure: true # ⚠️ allowed to fail
16+
# - ruby: '3.4.4'
17+
# rails: '7.2'
18+
# allowed_failure: true # ⚠️ allowed to fail
1919
- ruby: '3.4.4'
2020
rails: '8.0'
2121
allowed_failure: true # ⚠️ allowed to fail

AGENTS.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# AGENTS.md
22

3+
Instructions for GitHub Copilot and other automated contributors working in this repository.
4+
35
## Project
46
- Ruby: 3.4.4 (installed via rbenv in setup)
57
- Rails: 7.1
@@ -13,18 +15,17 @@
1315
- Databases:
1416
- development: `community_engine_development`
1517
- test: `community_engine_test`
16-
- Use `DATABASE_URL` to connect (overrides fallback host in database.yml).
18+
- Use `DATABASE_URL` to connect (overrides fallback host in `config/database.yml`).
1719

1820
## Commands
19-
- Run tests: `bin/ci`
21+
- **Tests:** `bin/ci`
2022
(Equivalent: `cd spec/dummy && bundle exec rspec`)
21-
- Lint: `bundle exec rubocop`
22-
- Security: `bundle exec brakeman -q -w2` and `bundle exec bundler-audit --update`
23+
- **Lint:** `bundle exec rubocop`
24+
- **Security:** `bundle exec brakeman -q -w2` and `bundle exec bundler-audit --update`
25+
- **Style:** `bin/codex_style_guard`
2326

2427
## Conventions
2528
- Make incremental changes with passing tests.
2629
- Avoid introducing new external services in tests; stub where possible.
27-
28-
## Code Style
29-
- Always run `bin/codex_style_guard` before proposing a patch.
30-
- If RuboCop reports offenses after autocorrect, update the changes until it passes.
30+
- If RuboCop reports offenses after autocorrect, update and rerun until clean.
31+
- Keep commit messages and PR descriptions concise and informative.

Gemfile.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,19 @@ GEM
167167
unf
168168
ast (2.4.3)
169169
aws-eventstream (1.4.0)
170-
aws-partitions (1.1139.0)
171-
aws-sdk-core (3.228.0)
170+
aws-partitions (1.1142.0)
171+
aws-sdk-core (3.229.0)
172172
aws-eventstream (~> 1, >= 1.3.0)
173173
aws-partitions (~> 1, >= 1.992.0)
174174
aws-sigv4 (~> 1.9)
175175
base64
176176
bigdecimal
177177
jmespath (~> 1, >= 1.6.1)
178178
logger
179-
aws-sdk-kms (1.109.0)
179+
aws-sdk-kms (1.110.0)
180180
aws-sdk-core (~> 3, >= 3.228.0)
181181
aws-sigv4 (~> 1.5)
182-
aws-sdk-s3 (1.195.0)
182+
aws-sdk-s3 (1.196.1)
183183
aws-sdk-core (~> 3, >= 3.228.0)
184184
aws-sdk-kms (~> 1)
185185
aws-sigv4 (~> 1.5)
@@ -407,7 +407,7 @@ GEM
407407
rdoc (>= 4.0.0)
408408
reline (>= 0.4.2)
409409
jmespath (1.6.2)
410-
json (2.13.0)
410+
json (2.13.2)
411411
json-schema (5.1.1)
412412
addressable (~> 2.8)
413413
bigdecimal (~> 3.1)
@@ -493,7 +493,7 @@ GEM
493493
optimist (3.2.1)
494494
orm_adapter (0.5.0)
495495
parallel (1.27.0)
496-
parser (3.3.8.0)
496+
parser (3.3.9.0)
497497
ast (~> 2.4.1)
498498
racc
499499
pg (1.6.1-aarch64-linux)
@@ -604,7 +604,7 @@ GEM
604604
reform-rails (0.2.6)
605605
activemodel (>= 5.0)
606606
reform (>= 2.3.1, < 3.0.0)
607-
regexp_parser (2.10.0)
607+
regexp_parser (2.11.0)
608608
reline (0.6.2)
609609
io-console (~> 0.5)
610610
representable (3.2.0)
@@ -658,18 +658,18 @@ GEM
658658
rswag-ui (2.16.0)
659659
actionpack (>= 5.2, < 8.1)
660660
railties (>= 5.2, < 8.1)
661-
rubocop (1.78.0)
661+
rubocop (1.79.2)
662662
json (~> 2.3)
663663
language_server-protocol (~> 3.17.0.2)
664664
lint_roller (~> 1.1.0)
665665
parallel (~> 1.10)
666666
parser (>= 3.3.0.2)
667667
rainbow (>= 2.2.2, < 4.0)
668668
regexp_parser (>= 2.9.3, < 3.0)
669-
rubocop-ast (>= 1.45.1, < 2.0)
669+
rubocop-ast (>= 1.46.0, < 2.0)
670670
ruby-progressbar (~> 1.7)
671671
unicode-display_width (>= 2.4.0, < 4.0)
672-
rubocop-ast (1.45.1)
672+
rubocop-ast (1.46.0)
673673
parser (>= 3.3.7.2)
674674
prism (~> 1.4)
675675
rubocop-capybara (2.22.1)
@@ -741,7 +741,7 @@ GEM
741741
simplecov_json_formatter (~> 0.1)
742742
simplecov-html (0.13.1)
743743
simplecov_json_formatter (0.1.4)
744-
spring (4.3.0)
744+
spring (4.4.0)
745745
spring-watcher-listen (2.1.0)
746746
listen (>= 2.7, < 4.0)
747747
spring (>= 4)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module BetterTogether
4+
module Metrics
5+
class SearchQueriesController < ApplicationController # rubocop:todo Style/Documentation
6+
def create
7+
query = params[:query]
8+
results_count = params[:results_count]
9+
locale = I18n.locale.to_s
10+
11+
if query.blank? || results_count.blank?
12+
render json: { error: I18n.t('metrics.search_queries.invalid_parameters') },
13+
status: :unprocessable_entity and return
14+
end
15+
16+
BetterTogether::Metrics::TrackSearchQueryJob.perform_later(query, results_count.to_i, locale)
17+
18+
render json: { success: true }, status: :ok
19+
end
20+
end
21+
end
22+
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
module BetterTogether
4+
class PersonBlocksController < ApplicationController # rubocop:todo Style/Documentation
5+
before_action :set_person_block, only: :destroy
6+
after_action :verify_authorized
7+
8+
def index
9+
authorize PersonBlock
10+
@blocked_people = current_person.blocked_people
11+
end
12+
13+
def create
14+
@person_block = current_person.person_blocks.new(person_block_params)
15+
authorize @person_block
16+
17+
if @person_block.save
18+
redirect_to blocks_path, notice: 'Person was successfully blocked.'
19+
else
20+
redirect_to blocks_path, alert: @person_block.errors.full_messages.to_sentence
21+
end
22+
end
23+
24+
def destroy
25+
authorize @person_block
26+
@person_block.destroy
27+
redirect_to blocks_path, notice: 'Person was successfully unblocked.'
28+
end
29+
30+
private
31+
32+
def current_person
33+
current_user.person
34+
end
35+
36+
def set_person_block
37+
@person_block = current_person.person_blocks.find(params[:id])
38+
end
39+
40+
def person_block_params
41+
params.require(:person_block).permit(:blocked_id)
42+
end
43+
end
44+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
module BetterTogether
4+
# CRUD for BetterTogether::Post
5+
class PostsController < FriendlyResourceController
6+
protected
7+
8+
def resource_class
9+
::BetterTogether::Post
10+
end
11+
12+
def resource_params
13+
super.tap do |attrs|
14+
attrs[:creator_id] = helpers.current_person&.id if action_name == 'create'
15+
end
16+
end
17+
end
18+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
module BetterTogether
4+
class ReportsController < ApplicationController # rubocop:todo Style/Documentation
5+
after_action :verify_authorized
6+
7+
def create
8+
@report = current_person.reports_made.new(report_params)
9+
authorize @report
10+
11+
if @report.save
12+
redirect_back fallback_location: root_path, notice: 'Report was successfully submitted.'
13+
else
14+
redirect_back fallback_location: root_path, alert: @report.errors.full_messages.to_sentence
15+
end
16+
end
17+
18+
private
19+
20+
def current_person
21+
current_user.person
22+
end
23+
24+
def report_params
25+
params.require(:report).permit(:reportable_id, :reportable_type, :reason)
26+
end
27+
end
28+
end

app/controllers/better_together/search_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ def search # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
1818
o['text']
1919
end
2020
end.flatten
21+
22+
BetterTogether::Metrics::TrackSearchQueryJob.perform_later(
23+
@query,
24+
search_results.length,
25+
I18n.locale.to_s
26+
)
2127
end
2228

2329
# Use Kaminari for pagination

0 commit comments

Comments
 (0)