Skip to content
Open

wip #266

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions app/controllers/webhooks/github_events_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Webhooks::GithubEventsController < ApplicationController
skip_before_action :verify_authenticity_token

Check failure

Code scanning / CodeQL

CSRF protection weakened or disabled High

Potential CSRF vulnerability due to forgery protection being disabled or weakened.

Copilot Autofix

AI 7 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

skip_before_action :authenticate
skip_before_action :require_authentication

before_action :validate_signature

def create
github_event = GithubEvent.create!(
event: request.headers["X-GitHub-Event"],
payload: request.request_parameters.except("repository", "organization")
# contribution: Contribution.find_by!(github_resource_url: payload["pull_request"]["url"])
)

GithubEvents::CreateService.new(github_event:).call

head :ok
end

private

def validate_signature
signature = request.headers["X-Hub-Signature-256"]
head :unauthorized and return unless signature&.start_with?("sha256=")

secret = Rails.application.credentials.github.webhook_secret
expected = "sha256=" + OpenSSL::HMAC.hexdigest("sha256", secret, request.raw_post)

unless ActiveSupport::SecurityUtils.secure_compare(expected, signature)
Rails.logger.warn "Invalid GitHub webhook signature"
head :unauthorized

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Authentication Bypass: Malicious Webhooks Processed

After detecting an invalid webhook signature, validate_signature calls head :unauthorized but doesn't return, allowing execution to continue. This causes the webhook to be processed despite failing authentication, creating a GithubEvent record and executing the service logic with potentially malicious data.

Fix in Cursor Fix in Web

end
end
end
11 changes: 11 additions & 0 deletions app/models/github_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class GithubEvent < ApplicationRecord
belongs_to :contribution, optional: true
# validates :event, presence: true
# validates :payload, presence: true

enum :status, {
pending: "pending",
processed: "processed",
ignored: "ignored"
}
end
66 changes: 66 additions & 0 deletions app/services/github_events/create_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module GithubEvents
class CreateService
attr_reader :github_event

def initialize(github_event:)
@github_event = github_event
end

def call
case github_event.event
when "pull_request" # I should probably not use this one
handle_pull_request_event
when "pull_request_review"
handle_pull_request_review_event
else
ignore_event!
end
end

private

def handle_pull_request_event
ignore_event! unless github_action == "closed"

return if contribution.status == "validée"

contribution.update!(status: "rejetée")
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Event Ignored, Yet Processing Continues

The handle_pull_request_event method calls ignore_event! when github_action is not "closed" but doesn't return afterward. This causes execution to continue, attempting to access contribution and potentially updating it even after the event was marked as ignored. The method needs to return after calling ignore_event! to prevent further processing.

Fix in Cursor Fix in Web

Comment on lines +22 to +28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Control‑flow bug in handle_pull_request_event and missing status update

As written, non‑"closed" pull request actions will still execute the rest of the method after ignore_event!, meaning:

  • Contributions can be set to "rejetée" even when the event should be ignored.
  • For "closed" actions, the github_event status remains "pending" and is never marked "processed" or linked to the contribution.

This is both a correctness and observability issue.

A safer implementation that truly ignores non‑closed actions and marks processed closed events could be:

def handle_pull_request_event
-  ignore_event! unless github_action == "closed"
-
-  return if contribution.status == "validée"
-
-  contribution.update!(status: "rejetée")
+  unless github_action == "closed"
+    ignore_event!
+    return
+  end
+
+  return if contribution.status == "validée"
+
+  ActiveRecord::Base.transaction do
+    contribution.update!(status: "rejetée")
+    github_event.update!(contribution: contribution, status: "processed")
+  end
end

You can decide whether a "closed" event for an already "validée" contribution should also mark the event as "processed" or remain "pending".

🤖 Prompt for AI Agents
In app/services/github_events/create_service.rb around lines 22-28, the method
must stop executing after ignore_event! for non-"closed" actions and must mark
the github_event as processed and link it to the contribution for all handled
"closed" cases; change control flow so that if github_action != "closed" you
call ignore_event! then return immediately, and for "closed" events always
update the github_event (e.g. status: "processed" and associate the
contribution_id) — if contribution.status == "validée" still mark the
github_event as processed (but don't change the contribution), otherwise update
the contribution to "rejetée" and then mark the github_event processed; use bang
updates (update!) so failures raise and persist changes.


def handle_pull_request_review_event
case github_action
when "submitted"
case github_event.payload["review"]["state"]
when "changes_requested"
ActiveRecord::Base.transaction do
contribution.update!(status: "modifications demandées")
github_event.update!(contribution:, status: "processed")
end
when "approved" # actually it might be better to do so at the merge event
ActiveRecord::Base.transaction do
contribution.update!(status: "validée")
Osbl.create!(contribution.osbl_data)
github_event.update!(contribution:, status: "processed")
end
else
ignore_event!
end
else
ignore_event!
end
end

def contribution
@contribution ||= Contribution.find_by!(github_resource_url: github_event.payload["pull_request"]["html_url"])
end

def ignore_event!
github_event.update!(status: "ignored")
Rails.logger.info "GitHub event ignored: #{github_event.id}"
end

def github_action
github_event.payload["action"]
end
end
end
2 changes: 1 addition & 1 deletion config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1ac0XCWb7MwmmrVOD+aw7yjIuxj5bMXRFrukNTHK7ds21vyaANghbmjcIwUrL2nz81lNGVR6uUVLw9E/ahRneKepCVxW0psXLqQlIzsQEcuoRuiCLNkVE/prxN2VQ0JPk9rMy9vRrf+f+4y/TapKpFeSN6sPINl91Me7vPJEoHdDrsG6M74Y3wVDZN/JyImgel7NH/ntSNHeaNDQSip0BUPRtYEVLtGzMFhgwLhFJpMkHFIbjJ7UDXoh4i1sCDaZ9us37ourZ8odxifvbowLuAHVAgM0vKTCnf5LlTYjkQS6GPJSh9DQJe165jFFNhUpvOL8D4mQpEXtEwlE0UCKbk3PwdP8zRmo88ueLu7YTGqCoeXQDK8z3W/E6FfsyS0rxfX91Ag11IXjRVrYIAj6597x/R5adj8n1dSJ8PACAfRrPmvAxKOwDxi6dLviVl5VcaVcDqcLDV+q1pBU0FAFyi+lj0z8sxVVo2TLp67P+y+BnZna4tPu7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OvP6TiTr6Crx3cZKxIsAcAXY3qyvh7I7mMnBdA4bygZm/6CjuL0Vv+X+qPTj5UebpIc9xGYU9CGFEjiPsoae9vRTkf8gXXsxGpxVlHNyeAxf+X9fTgFzbNvt+kQO9yT0nF3vqPSPcJjfNc7tnhHJXDW4daGyjCRgnu0XVIufcxnwjCbUzG038wrMd7U/MXLt0yAhZ8gug5ivhQgrqzbiv4U0TEPypkdAvUZd9yUwhksvSA3bkYpPQpW02WTQwHSIQ2iLlSlsZ84Cta4xuG882WNd5UIA0KJam8a7IcSeqpbrhXYBR7QZIXJ+ymMjDT7WOB7FCjKABGnLZP4R7h3lHD2rJi9Q9/ltRxQK95iiT1ZDKVqf5o8wTrjgwwizgpTUNMlCPi3uthdRAmrPirR/O26DrNIPDgmdLpC2YIgEo2uISewHtZuy3gkXGRR5flQKG3lzhcOxkE9AvVLqYsSP6RNlmOjbnZGqvtJoaum/baLOxmERo+iEvRB2rm+JV9fPH0+ZPpdjYDma8bujRdj1Kky0n4Fgg3xzw/UQnxhtghud2Y9wj71FSTcMEDWfQhz5asahtbu7Trit7jAXVeAWBuCEmibd2JT1HCeFGsF4ZYYPThfF5rENr--FXzmVzKeSOHPa3D5--08W/g+J4EtERL68rHU6cqg==
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
get "mes-contributions/:id", to: "users/contributions#show", as: :my_contribution
get "mes-contributions/:id/modifier", to: "users/contributions#edit", as: :edit_my_contribution

resources :github_events, only: [:create], module: :webhooks

resources :contributions, only: [:show, :edit, :update]

resources :osbl_imports, only: [:create, :show]
Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20250403123232_create_github_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreateGithubEvent < ActiveRecord::Migration[8.0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Migration timestamp predates PR creation.

The migration timestamp 20250403123232 (April 3, 2025) is approximately 7.5 months before the PR creation date (November 16, 2025). This backwards-in-time timestamp could cause migration ordering issues, especially in teams where migrations are generated concurrently.

Regenerate the migration with the correct timestamp:

#!/bin/bash
# Verify if there are any migrations between April 2025 and November 2025
# that could conflict with this ordering
fd -e rb . db/migrate/ --exec basename | sort
🤖 Prompt for AI Agents
db/migrate/20250403123232_create_github_event.rb lines 1-1: The migration file
timestamp is older than the PR date which can break migration ordering;
regenerate this migration with a current timestamp: create a new migration using
Rails generator (rails generate migration CreateGithubEvent), copy the migration
body from the old file into the newly generated file, delete the old
20250403123232_* file, verify the new filename/timestamp is correct and the
class name matches, run git add/commit the new file and removal of the old one,
and run your migration status check to ensure ordering is correct before
pushing.

def change
create_table :github_events do |t|
t.string :event, null: false
t.json :payload, null: false
t.string :status, null: false, default: "pending"

t.references :contribution, foreign_key: true

t.timestamps
end
end
end
13 changes: 12 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading