-
Notifications
You must be signed in to change notification settings - Fork 0
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
seonghobae
wants to merge
6
commits into
master
from
sentinel/fix-readline-validation-4440585761582741023
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cc7b756
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt
seonghobae c5a1929
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt
seonghobae f6338fb
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt
seonghobae dfed0c2
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt
seonghobae efadf16
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt
seonghobae 8a5b268
๐ก๏ธ Sentinel: [CRITICAL] Fix weak regex validation in interactive prompt
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,6 @@ | |
| ^\.jules(/.*)?$ | ||
| ^\.trivyignore\.yaml$ | ||
| ^trivy\.yaml$ | ||
| ^.semgrepignore$ | ||
| ^test_dummy\.R$ | ||
| ^test_validation\.R$ | ||
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| library(testthat) | ||
| library(mockery) | ||
|
|
||
| test_that("autoFIPC validates interactive readline correctly with strict regex", { | ||
| # We source the code directly to bypass pkgload/namespace export issues | ||
| # in this mocked environment test | ||
|
|
||
| # Ensure we mock interactive prompt paths, without modifying logic | ||
| mockery::stub(autoFIPC, 'interactive', TRUE) | ||
|
|
||
| # Mock mirt.model as it is called early for generating model syntax | ||
| mockery::stub(autoFIPC, 'mirt::mirt.model', function(...) stop('forced failure')) | ||
|
|
||
| # Test with valid inputs (1 or 2) | ||
| # Needs to handle multiple readlines if it passes the first one | ||
| mockery::stub(autoFIPC, 'readline', mockery::mock('1', '1', '1', '1')) | ||
|
|
||
| expect_error( | ||
| autoFIPC( | ||
| newformXData = data.frame(A=1), | ||
| oldformYData = data.frame(A=2), | ||
| newformCommonItemNames = c('A'), | ||
| oldformCommonItemNames = c('A') | ||
| ), | ||
| "forced failure|Please write down pairs correctly|Too many invalid common item confirmation attempts" | ||
| ) | ||
|
|
||
| # Test with malicious inputs (large numbers that cause NA coercions if unhandled) | ||
| # It should fail validation 3 times and throw the "Too many invalid" error | ||
| mockery::stub(autoFIPC, 'readline', mockery::mock('9999999999999999', '9999999999999999', '9999999999999999')) | ||
| expect_error( | ||
| autoFIPC( | ||
| newformXData = data.frame(A=1), | ||
| oldformYData = data.frame(A=2), | ||
| newformCommonItemNames = c('A'), | ||
| oldformCommonItemNames = c('A') | ||
| ), | ||
| "Please write down pairs correctly|forced failure|Too many invalid common item confirmation attempts" | ||
| ) | ||
| }) | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ฏ Functional Correctness | ๐ก Minor | โก Quick win
expect_error()์ ์ค๋ฅ ์กฐ๊ฑด์ ์ ํํ ์ ํํ์ธ์.์ ํจ ์ ๋ ฅ ํ ์คํธ๊ฐ
"Too many invalid common item confirmation attempts"์"Please write down pairs correctly"๋ ํ์ฉํฉ๋๋ค. ๋ฐ๋ผ์^[12]$๊ฐ1์ ๊ฑฐ๋ถํด๋ ํ ์คํธ๊ฐ ํต๊ณผํ ์ ์์ต๋๋ค. ์ ํจ ์ ๋ ฅ ๊ฒฝ๋ก์์๋mirt::mirt.model์คํ ์"forced failure"๋ง ์์ํ์ธ์. ํฐ ์ซ์ ์ ๋ ฅ ๊ฒฝ๋ก์์๋"Too many invalid common item confirmation attempts"๋ง ์์ํ์ธ์.์์ ์์
Also applies to: 31-38
๐ค Prompt for AI Agents