mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 06:57:55 +00:00
refactor(agent): centralize sandbox allowedDomains default in prisma schema
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "sandboxes" ALTER COLUMN "allowedDomains" SET DEFAULT ARRAY['npmjs.org', '*.npmjs.org', 'registry.npmjs.org', 'registry.yarnpkg.com', 'pypi.org', '*.pypi.org', 'github.com', '*.github.com', 'api.github.com', 'raw.githubusercontent.com']::TEXT[];
|
||||
@@ -226,7 +226,7 @@ model Team {
|
||||
|
||||
model Sandbox {
|
||||
id String @id @default(ulid())
|
||||
allowedDomains String[] @default(["github.com", "api.github.com", "raw.githubusercontent.com"])
|
||||
allowedDomains String[] @default(["npmjs.org", "*.npmjs.org", "registry.npmjs.org", "registry.yarnpkg.com", "pypi.org", "*.pypi.org", "github.com", "*.github.com", "api.github.com", "raw.githubusercontent.com"])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
|
||||
@@ -172,11 +172,7 @@ export class AgentExecutor {
|
||||
})
|
||||
|
||||
const sandbox = await this.getSandbox(teamId)
|
||||
const allowedDomains = sandbox?.allowedDomains || [
|
||||
'github.com',
|
||||
'api.github.com',
|
||||
'raw.githubusercontent.com',
|
||||
]
|
||||
const allowedDomains = sandbox?.allowedDomains || []
|
||||
|
||||
const piDir = path.join(process.cwd(), '.pi')
|
||||
if (!fs.existsSync(piDir)) fs.mkdirSync(piDir, { recursive: true })
|
||||
|
||||
@@ -26,6 +26,7 @@ export class TeamService {
|
||||
enablePublicSignup: true,
|
||||
transcode: { videoStrategy: 'disable', imageStrategy: 'disable' },
|
||||
},
|
||||
sandbox: { create: {} },
|
||||
},
|
||||
})
|
||||
await providerService.initBuiltinProviders(team.id)
|
||||
@@ -42,6 +43,7 @@ export class TeamService {
|
||||
name: req.name,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
settings: {} as any,
|
||||
sandbox: { create: {} },
|
||||
},
|
||||
})
|
||||
|
||||
@@ -208,11 +210,7 @@ export class TeamService {
|
||||
where: { teamId },
|
||||
})
|
||||
return {
|
||||
allowedDomains: sandbox?.allowedDomains || [
|
||||
'github.com',
|
||||
'api.github.com',
|
||||
'raw.githubusercontent.com',
|
||||
],
|
||||
allowedDomains: sandbox?.allowedDomains || [],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user