Repository navigation
fix(security): replace Math.random with crypto.randomUUID and fix URL hostname check #2489
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 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -86,10 +86,10 @@ export abstract class CloudAgentBase { | |||||
| } | ||||||
|
|
||||||
| protected generateTaskId(): string { | ||||||
| return `task_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`; | ||||||
| return `task_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`; | ||||||
| } | ||||||
|
|
||||||
| protected generateActivityId(): string { | ||||||
| return `act_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`; | ||||||
| return `act_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`; | ||||||
|
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. Similar to the
Suggested change
|
||||||
| } | ||||||
|
Comment on lines
88
to
94
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. According to the Repository Style Guide (Rule 9), production code changes must include corresponding tests. The current PR modifies References
|
||||||
| } | ||||||
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.
In Node.js environments,
cryptois not available as a global variable (unlikeMath). Usingcrypto.randomUUID()directly will result in aReferenceErrorat runtime. To fix this, you should either useglobalThis.crypto.randomUUID()(available in Node.js 19+) or import thecryptomodule fromnode:cryptoat the top of the file.