Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: disallow wildcard in VCS branch filter (#2311)
Danny Xu2bba3c7ffd81
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vueindex 7c55a428f9..5636152336 100644--- a/frontend/src/components/RepositoryForm.vue+++ b/frontend/src/components/RepositoryForm.vue@@ -56,9 +56,6 @@placeholder="e.g. master":disabled="!allowEdit"/>- <div v-if="vcsType == 'GITLAB_SELF_HOST'" class="mt-2 textinfolabel">- {{ $t("repository.branch-specify-tip") }}- </div></div><div><div class="textlabel">{{ $t("repository.base-directory") }}</div>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 00ae019612..8a4ef87d98 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -877,7 +877,6 @@},"repository": {"branch-observe-file-change": "The branch where Bytebase observes the file change.",- "branch-specify-tip": "Tip: You can also use wildcard like \"feature/*\"","base-directory": "Base directory","base-directory-description": "The root directory where Bytebase observes the file change. If empty, then it observes the entire repository.","file-path-template": "File path template",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 23e00d1eb7..61f0fb792d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -878,7 +878,6 @@},"repository": {"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",- "branch-specify-tip": "诀窍: 可以使用诸如 \"feature/*\" 这样的通配符","base-directory": "根目录","base-directory-description": "Bytebase 跟踪文件变更的根目录。如果为空,则他会跟踪整个仓库。","file-path-template": "文件路径模版",diff --git a/frontend/src/types/repository.ts b/frontend/src/types/repository.tsindex da6d593572..d074cc491b 100644--- a/frontend/src/types/repository.ts+++ b/frontend/src/types/repository.ts@@ -81,14 +81,6 @@ export type ExternalRepositoryInfo = {export function baseDirectoryWebUrl(repository: Repository): string {if (repository.vcs.type == "GITLAB_SELF_HOST") {- // If branchFilter is empty (default branch) or branch filter contains wildcard,- // then we can't locate to the exact branch name, thus we will just return the repository web url- if (- isEmpty(repository.branchFilter) ||- repository.branchFilter.includes("*")- ) {- return repository.webUrl;- }let url = `${repository.webUrl}/-/tree/${repository.branchFilter}`;if (!isEmpty(repository.baseDirectory)) {url += `/${repository.baseDirectory}`;diff --git a/server/project.go b/server/project.goindex 5a24c8a269..6feffaae25 100644--- a/server/project.go+++ b/server/project.go@@ -199,6 +199,10 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, "Malformed create linked repository request").SetInternal(err)}+ if strings.Contains(repositoryCreate.BranchFilter, "*") {+ return echo.NewHTTPError(http.StatusBadRequest, "Wildcard isn't supported for branch setting")+ }+project, err := s.store.GetProjectByID(ctx, projectID)if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project ID: %v", projectID)).SetInternal(err)@@ -343,6 +347,10 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {if err := jsonapi.UnmarshalPayload(c.Request().Body, repoPatch); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformed patch linked repository request").SetInternal(err)}+ if repoPatch.BranchFilter != nil && strings.Contains(*repoPatch.BranchFilter, "*") {+ return echo.NewHTTPError(http.StatusBadRequest, "Wildcard isn't supported for branch setting")+ }+project, err := s.store.GetProjectByID(ctx, projectID)if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project ID: %v", projectID)).SetInternal(err)