Skip to content

Commit 9aa776a

Browse files
authored
fix(api): check name pattern on postProjectIntegrationHandler (#6169)
1 parent 8872d84 commit 9aa776a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

engine/api/project_integration.go

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (api *API) putProjectIntegrationHandler() service.Handler {
7575
return sdk.WithStack(sdk.ErrForbidden)
7676
}
7777

78+
projectIntegration.Name = ppDB.Name
7879
projectIntegration.ID = ppDB.ID
7980

8081
for kkBody := range projectIntegration.Config {
@@ -210,6 +211,11 @@ func (api *API) postProjectIntegrationHandler() service.Handler {
210211
return sdk.WrapError(err, "Cannot read body")
211212
}
212213

214+
regexp := sdk.NamePatternRegex
215+
if !regexp.MatchString(pp.Name) {
216+
return sdk.NewErrorFrom(sdk.ErrWrongRequest, "name %q do not respect pattern %s", pp.Name, sdk.NamePattern)
217+
}
218+
213219
pp.ProjectID = p.ID
214220
if pp.IntegrationModelID == 0 {
215221
pp.IntegrationModelID = pp.Model.ID

engine/api/project_integration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestAddUpdateAndDeleteProjectIntegration(t *testing.T) {
4545
assert.Equal(t, 200, w.Code)
4646

4747
// UPDATE integration
48-
pp.Name = "kafkaTest2"
48+
pp.Name = "kafkaTest"
4949
pp.ProjectID = proj.ID
5050

5151
vars = map[string]string{}

0 commit comments

Comments
 (0)