-
Notifications
You must be signed in to change notification settings - Fork 555
[CI] Enable shellcheck for lint #2848
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: main
Are you sure you want to change the base?
Conversation
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.
Code Review
This pull request enables shellcheck for linting shell scripts and applies fixes to the codebase. The changes are generally good and improve code quality. I've identified a critical command injection vulnerability in the shellcheck.sh script itself that should be addressed. I've also suggested improvements for the .shellcheckrc configuration to avoid globally disabling important checks, and a refactoring in one of the scripts to better align with shellcheck's recommendations.
tools/shellcheck.sh
Outdated
| find . -path ./.git -prune -o -name "*.sh" -print0 \ | ||
| | xargs -0 -I {} sh -c 'git check-ignore -q "{}" || shellcheck -s bash "{}"' |
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.
The current xargs command is vulnerable to command injection if a filename contains special characters like backticks or dollar signs. It's much safer to pass filenames as positional parameters to the sh -c script, rather than embedding them into the script string. This prevents the shell from interpreting any special characters in the filename.
| find . -path ./.git -prune -o -name "*.sh" -print0 \ | |
| | xargs -0 -I {} sh -c 'git check-ignore -q "{}" || shellcheck -s bash "{}"' | |
| find . -path ./.git -prune -o -name "*.sh" -print0 \ | |
| | xargs -0 -I {} sh -c 'git check-ignore -q "$1" || shellcheck -s bash "$1"' sh {} |
| # SC2155 (warning): Declare and assign separately to avoid masking return values. | ||
| # SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails. | ||
| # | ||
| disable=SC1091,SC2004,SC2129,SC2155,SC2164 |
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.
Disabling SC2155 and SC2164 globally is discouraged as they can hide potential bugs.
SC2155: Warns about masking return values in assignments likeVAR=$(command). Ifcommandfails, the script might not exit as expected, even withset -e. It's safer to declare and assign separately, or handle the error immediately.SC2164: Warns about unsafecdcommands. A failedcdcan cause subsequent commands to execute in the wrong directory, which can be very dangerous. It's better to usecd ... || exit.
Instead of disabling these checks globally, it would be better to address the warnings in the code, or disable them on a case-by-case basis using shellcheck disable=... comments where they are confirmed to be false positives.
disable=SC1091,SC2004,SC2129
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Signed-off-by: wangli <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2848 +/- ##
==========================================
+ Coverage 74.76% 75.39% +0.62%
==========================================
Files 150 155 +5
Lines 20891 21123 +232
==========================================
+ Hits 15620 15925 +305
+ Misses 5271 5198 -73
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
What this PR does / why we need it?
This pr purpose to enable shellcheck for pre-commit and make the corresponding clean code
Does this PR introduce any user-facing change?
How was this patch tested?