-
Notifications
You must be signed in to change notification settings - Fork 13k
Disallow and suppress unsafe assignment #19736
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
Changes from 4 commits
072c26d
d5f56e2
99e4159
21749c3
5012409
028102f
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 |
|---|---|---|
|
|
@@ -451,6 +451,7 @@ Return a JSON object with: | |
| '--limit', | ||
| String(limit), | ||
| ]); | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| const issues: Issue[] = JSON.parse(stdout); | ||
|
Comment on lines
+454
to
455
Contributor
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. Directly casting the result of |
||
| if (issues.length === 0) { | ||
| setState((s) => ({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -371,6 +371,7 @@ export function setPendingSettingValue( | |||||||
| pendingSettings: Settings, | ||||||||
| ): Settings { | ||||||||
| const path = key.split('.'); | ||||||||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||||||||
| const newSettings = JSON.parse(JSON.stringify(pendingSettings)); | ||||||||
|
Comment on lines
+374
to
375
Contributor
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. Instead of using
Suggested change
|
||||||||
| setNestedValue(newSettings, path, value); | ||||||||
| return newSettings; | ||||||||
|
|
||||||||
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.
Assigning the result of
JSON.parsetoloadedMetadatawithout runtime validation is unsafe, as the data from GCS might not conform to the expected shape. This could lead to runtime errors when properties like_contextIdare accessed later. Since Zod is already used in the project, I recommend defining a Zod schema for the metadata and usingschema.parse()orschema.safeParse()to validate the data after parsing. This will ensure type safety and prevent potential crashes.