mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-20 02:33:31 +08:00
Warn when using read without -r
This commit is contained in:
@@ -206,6 +206,7 @@ nodeChecks = [
|
|||||||
,checkReturn
|
,checkReturn
|
||||||
,checkMaskedReturns
|
,checkMaskedReturns
|
||||||
,checkInjectableFindSh
|
,checkInjectableFindSh
|
||||||
|
,checkReadWithoutR
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -3453,6 +3454,13 @@ checkInjectableFindSh _ = checkCommand "find" (const check)
|
|||||||
when ("{}" `isInfixOf` arg) $
|
when ("{}" `isInfixOf` arg) $
|
||||||
warn id 2156 "Injecting filenames is fragile and insecure. Use parameters."
|
warn id 2156 "Injecting filenames is fragile and insecure. Use parameters."
|
||||||
|
|
||||||
|
prop_checkReadWithoutR1 = verify checkReadWithoutR "read -a foo"
|
||||||
|
prop_checkReadWithoutR2 = verifyNot checkReadWithoutR "read -ar foo"
|
||||||
|
checkReadWithoutR _ t@(T_SimpleCommand {}) | t `isUnqualifiedCommand` "read" =
|
||||||
|
unless ("r" `elem` map snd (getAllFlags t)) $
|
||||||
|
info (getId t) 2162 "read without -r will mangle backslashes."
|
||||||
|
checkReadWithoutR _ _ = return ()
|
||||||
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||||
|
Reference in New Issue
Block a user