-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [HIGH] Fix integer coercion crash vulnerability in interactive prompts #292
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,7 +141,7 @@ autoFIPC <- | |
| } | ||
| for (attempt in seq_len(3)) { | ||
| n <- readline(prompt = "Is it correct? (1: Yes 2: No) : ") | ||
| if (grepl("^[0-9]+$", n)) { | ||
| if (grepl("^[12]$", n)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π― Functional Correctness | π‘ Minor | β‘ Quick win π Supported by static analysisπ Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- repository conventions ---'
for f in /tmp/coderabbit-repo-knowledge/contextualwisdomlab-afipc-649c8ab4/*/*.md; do
[ -f "$f" ] || continue
case "$f" in
*contextual*/*) head -120 "$f" ;;
esac
done
printf '%s\n' '--- changed regions ---'
sed -n '110,190p' R/aFIPC.R
sed -n '360,410p' R/aFIPC.R
printf '%s\n' '--- relevant tests ---'
for f in tests/testthat/test-autoFIPC.R tests/testthat/test-sentinel-validation.R; do
if [ -f "$f" ]; then
printf '\n### %s\n' "$f"
cat -n "$f"
fi
done
printf '%s\n' '--- helper definitions and callers ---'
rg -n -C 8 'checkCorrect|checkoldformBILOGprior|checknewformBILOGprior|readline\\(' R/aFIPC.R tests/testthatRepository: ContextualWisdomLab/aFIPC Length of output: 16243 π Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- diff summary ---'
git diff --stat
printf '%s\n' '--- diff for reviewed implementation and tests ---'
git diff -- R/aFIPC.R tests/testthat
printf '%s\n' '--- function boundaries and validation setup ---'
rg -n -C 3 '^[[:space:]]*autoFIPC[[:space:]]*<-|checkCorrect|checkoldformBILOGprior|checknewformBILOGprior|readline' R/aFIPC.R
printf '%s\n' '--- testthat dependencies and mocking conventions ---'
rg -n -C 3 'mock|local_mocked_bindings|with_mock|testthat|interactive|readline' DESCRIPTION tests RRepository: ContextualWisdomLab/aFIPC Length of output: 7041 μΈ λνν μ λ ₯ κ²½λ‘μ νκ· ν μ€νΈλ₯Ό μΆκ°νμΈμ. νμ¬ ν
μ€νΈλ λΉλνν μΈμ
μ€λ₯μ λ
Όλ¦¬ν μΈμλ§ νμΈν©λλ€. π€ Prompt for AI AgentsSource: Coding guidelines |
||
| return(as.integer(n)) | ||
| } | ||
| } | ||
|
|
@@ -171,7 +171,7 @@ autoFIPC <- | |
| readline( | ||
| prompt = "Do you want to use default BILOG-MG priors for oldform Data? (1: Yes 2: No) : " | ||
| ) | ||
| if (grepl("^[0-9]+$", n)) { | ||
| if (grepl("^[12]$", n)) { | ||
| return(as.integer(n)) | ||
| } | ||
| } | ||
|
|
@@ -390,7 +390,7 @@ autoFIPC <- | |
| readline( | ||
| prompt = "Do you want to use default BILOG-MG priors for newform Data? (1: Yes 2: No) : " | ||
| ) | ||
| if (grepl("^[0-9]+$", n)) { | ||
| if (grepl("^[12]$", n)) { | ||
| return(as.integer(n)) | ||
| } | ||
| } | ||
|
|
||
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.
π Info: Out-of-range digits now retried instead of erroring immediately
^[12]$no longer accepts out-of-range digits like3or0; they are retried up to three times before stopping, whereas^[0-9]+$returned them immediately to theconfirm != 1check at aFIPC.R. A minor UX change that correctly closes theas.integer()NA-coercion path.Was this helpful? React with π or π to provide feedback.