-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: check kill()
input
#1339
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
fix: check kill()
input
#1339
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.
Pull Request Overview
This PR adds input validation to the kill()
function to ensure it only accepts valid process IDs. The function now validates that the PID is a valid positive integer, rejecting empty strings, non-numeric values, floats, and other invalid inputs.
- Adds input validation to reject invalid PID formats
- Updates type signature to accept string numbers alongside numeric PIDs
- Includes comprehensive test coverage for various invalid input scenarios
Reviewed Changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/core.ts | Adds PID validation logic and updates function signature |
src/log.ts | Updates LogEntry type to accept string number PIDs |
test/core.test.js | Adds test cases for invalid PID validation |
build/core.cjs | Compiled JavaScript output with validation logic |
.size-limit.json | Updates bundle size limits to account for added validation code |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pid = (pid + '') as `${number}` | ||
if (!/^\d+$/.test(pid)) throw new Fail(`Invalid pid: ${pid}`) | ||
|
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 type assertion as \
${number}`is misleading since the validation hasn't occurred yet. At this point,
pid + ''` could be any string (e.g., 'null', 'undefined', '[object Object]'). Consider moving the type assertion after the validation or using a different approach.
pid = (pid + '') as `${number}` | |
if (!/^\d+$/.test(pid)) throw new Fail(`Invalid pid: ${pid}`) | |
const pidStr = pid + ''; | |
if (!/^\d+$/.test(pidStr)) throw new Fail(`Invalid pid: ${pidStr}`); | |
pid = pidStr as `${number}`; |
Copilot uses AI. Check for mistakes.
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.
Pull Request Overview
Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
* refactor: strengthen `kill` input check continues #1339 * ci: check tag with pkg version
closes #1337