feat: add config for workflow domain (#1847)

This commit is contained in:
Zhj
2025-08-27 17:04:42 +08:00
committed by GitHub
parent 5562800958
commit 77e1931494
12 changed files with 135 additions and 48 deletions

View File

@@ -26,10 +26,12 @@ import (
"golang.org/x/exp/maps"
code2 "github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/convert"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
@@ -107,15 +109,6 @@ var pythonBuiltinBlacklist = map[string]struct{}{
"tty": {},
}
// pythonThirdPartyWhitelist is the whitelist of python third-party modules,
// see: https://www.coze.cn/open/docs/guides/code_node#7f41f073
// If you want to use other third-party libraries, you can add them to this whitelist.
// And you also need to install them in `/scripts/setup/python.sh` and `/backend/Dockerfile` via `pip install`.
var pythonThirdPartyWhitelist = map[string]struct{}{
"httpx": {},
"numpy": {},
}
type Config struct {
Code string
Language coderunner.Language
@@ -192,6 +185,9 @@ func validatePythonImports(code string) error {
imports := parsePythonImports(code)
importErrors := make([]string, 0)
pythonThirdPartyWhitelist := slices.ToMap(wf.GetRepository().GetNodeOfCodeConfig().GetSupportThirdPartModules(), func(e string) (string, bool) {
return e, true
})
var blacklistedModules []string
var nonWhitelistedModules []string
for _, imp := range imports {