-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
✨ feat: support vertex ai #4487
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4487 +/- ##
==========================================
+ Coverage 92.48% 92.53% +0.05%
==========================================
Files 511 512 +1
Lines 36614 36867 +253
Branches 3388 3387 -1
==========================================
+ Hits 33862 34115 +253
Misses 2752 2752
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
👍 @arvinxx Thank you for raising your pull request and contributing to our Community |
const sensenovaAccessKeySecret = apiKeyManager.pick( | ||
payload?.sensenovaAccessKeySecret || SENSENOVA_ACCESS_KEY_SECRET, | ||
); |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 7 days ago
To fix the problem, we need to replace the use of Math.random()
with a cryptographically secure random number generator. In Node.js, the crypto
module provides a method crypto.randomInt
that can be used to generate cryptographically secure random integers. This method will be used to securely select an index for the API keys.
- General Fix: Replace
Math.random()
withcrypto.randomInt
to ensure the randomness is cryptographically secure. - Detailed Fix: Modify the
pick
method insrc/server/modules/AgentRuntime/apiKeyManager.ts
to usecrypto.randomInt
instead ofMath.random()
. - Specific Changes:
- Import the
crypto
module. - Replace the line using
Math.random()
with a call tocrypto.randomInt
.
- Import the
-
Copy modified line R2 -
Copy modified line R41
@@ -1,2 +1,3 @@ | ||
import { getLLMConfig } from '@/config/llm'; | ||
import { randomInt } from 'crypto'; | ||
|
||
@@ -39,3 +40,3 @@ | ||
if (this._mode === 'turn') index = store.index++ % store.keyLen; | ||
if (this._mode === 'random') index = Math.floor(Math.random() * store.keyLen); | ||
if (this._mode === 'random') index = randomInt(store.keyLen); | ||
|
@@ -100,6 +102,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [ | |||
Ai360Provider, | |||
TaichuProvider, | |||
SiliconCloudProvider, | |||
VertexAIProvider, |
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.
这个地方也应该放到google下面
9a2487c
to
05754da
Compare
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
📝 补充信息 | Additional Information