Fix RiskEngine IP novelty query binding to restore accurate simulation scoring#3
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/MuzakirLone/Sentinel/sessions/19caed56-024f-4ac3-8eed-d62227ceb56c Co-authored-by: MuzakirLone <156284213+MuzakirLone@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
MuzakirLone
May 11, 2026 17:00
View session
There was a problem hiding this comment.
Pull request overview
Fixes a bind-parameter mismatch in RiskEngine::buildContext() that could cause the “known IP for user” novelty query to misbehave during simulations, restoring accurate context and downstream simulation risk scoring.
Changes:
- Corrected the bound parameter key for the known-IP novelty query to use
ip_id(matching:ip_id). - Added a unit test that exercises the
buildContext()known-IP query path and validates the presence ofip_idin bound parameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/Engine/RiskEngine.php | Fixes the bind parameter key to match the SQL placeholder in the IP novelty detection query. |
| tests/Unit/Engine/RiskEngineTest.php | Adds a regression test to ensure the known-IP query binds ip_id as expected. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (str_contains($sql, 'ip_address_id = :ip_id') && str_contains($sql, 'id != :event_id')) { | ||
| if (!array_key_exists('ip_id', $params)) { | ||
| throw new \InvalidArgumentException('Missing ip_id bind parameter'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Risk scoring during simulations could be skewed by a bind-parameter mismatch in the IP novelty path inside
RiskEngine::buildContext(). The SQL used:ip_id, but the parameter array providedip_address_id, causing that check to fail or behave incorrectly.Root cause
app/Engine/RiskEngine.phphad a placeholder/key mismatch in the known-IP query for user novelty detection.Code change
ip_id(matching:ip_id) when querying prior events byip_address_id.is_new_ip_for_usercomputation aligned with intended rule context, improving downstream risk score correctness for simulation events.Regression coverage
tests/Unit/Engine/RiskEngineTest.phpthat exercises the known-IP query path and assertsip_idis present in bound parameters.