Skip to content

Commit 62bfa29

Browse files
chore: add webhook API urls and project API urls for Gitlab (#84)
1 parent a9adfd7 commit 62bfa29

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,20 @@ inbound:
125125

126126
Under the hood, this config adds these allowlist items:
127127

128+
- DELETE `https://gitlab.example.com/api/v4/groups/:namespace/hooks/:hook`
129+
- DELETE `https://gitlab.example.com/api/v4/projects/:project/hooks/:hook`
130+
- GET `https://gitlab.example.com/api/v4/groups/:namespace/hooks`
128131
- GET `https://gitlab.example.com/api/v4/namespaces/:namespace`
129132
- GET `https://gitlab.example.com/api/v4/projects/:project`
133+
- GET `https://gitlab.example.com/api/v4/projects/:project/members/all/:user`
130134
- GET `https://gitlab.example.com/api/v4/projects/:project/merge_requests`
131135
- GET `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/versions`
132136
- GET `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions`
137+
- GET `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions/:discussion/notes/:note/award_emoji`
133138
- GET `https://gitlab.example.com/api/v4/projects/:project/repository/branches`
134139
- GET `https://gitlab.example.com/api/v4/:entity_type/:namespace/projects`
140+
- POST `https://gitlab.example.com/api/v4/groups/:namespace/hooks`
141+
- POST `https://gitlab.example.com/api/v4/projects/:project/hooks`
135142
- POST `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions`
136143
- POST `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions/:discussion/notes`
137144
- PUT `https://gitlab.example.com/api/v4/projects/:project/merge_requests/:number/discussions/:discussion/notes/:note`
@@ -141,6 +148,8 @@ And if `allowCodeAccess` is set, additionally:
141148

142149
- GET `https://gitlab.example.com/api/v4/projects/:project/repository/files/:filepath`
143150
- GET `https://gitlab.example.com/api/v4/projects/:project/repository/commits`
151+
- GET `https://gitlab.example.com/api/v4/projects/:project/repository/compare`
152+
- POST `https://gitlab.example.com/api/v4/projects/:project/statuses/:commit`
144153

145154
### Bitbucket
146155

pkg/config.go

+46
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,17 @@ func LoadConfig(configFiles []string, deploymentId int) (*Config, error) {
436436
}
437437

438438
config.Inbound.Allowlist = append(config.Inbound.Allowlist,
439+
// Group webhooks
440+
AllowlistItem{
441+
URL: gitLabBaseUrl.JoinPath("/groups/:namespace/hooks").String(),
442+
Methods: ParseHttpMethods([]string{"GET", "POST"}),
443+
SetRequestHeaders: headers,
444+
},
445+
AllowlistItem{
446+
URL: gitLabBaseUrl.JoinPath("/groups/:namespace/hooks/:hook").String(),
447+
Methods: ParseHttpMethods([]string{"DELETE"}),
448+
SetRequestHeaders: headers,
449+
},
439450
// Group info
440451
AllowlistItem{
441452
URL: gitLabBaseUrl.JoinPath("/namespaces/:namespace").String(),
@@ -448,6 +459,23 @@ func LoadConfig(configFiles []string, deploymentId int) (*Config, error) {
448459
Methods: ParseHttpMethods([]string{"GET"}),
449460
SetRequestHeaders: headers,
450461
},
462+
// Repo webhooks
463+
AllowlistItem{
464+
URL: gitLabBaseUrl.JoinPath("/projects/:project/hooks").String(),
465+
Methods: ParseHttpMethods([]string{"POST"}),
466+
SetRequestHeaders: headers,
467+
},
468+
AllowlistItem{
469+
URL: gitLabBaseUrl.JoinPath("/projects/:project/hooks/:hook").String(),
470+
Methods: ParseHttpMethods([]string{"DELETE"}),
471+
SetRequestHeaders: headers,
472+
},
473+
// Get a repo member
474+
AllowlistItem{
475+
URL: gitLabBaseUrl.JoinPath("/projects/:project/members/all/:user").String(),
476+
Methods: ParseHttpMethods([]string{"GET"}),
477+
SetRequestHeaders: headers,
478+
},
451479
// MR info
452480
AllowlistItem{
453481
URL: gitLabBaseUrl.JoinPath("/projects/:project/merge_requests").String(),
@@ -496,6 +524,12 @@ func LoadConfig(configFiles []string, deploymentId int) (*Config, error) {
496524
Methods: ParseHttpMethods([]string{"PUT"}),
497525
SetRequestHeaders: headers,
498526
},
527+
// Get reactions to comments
528+
AllowlistItem{
529+
URL: gitLabBaseUrl.JoinPath("/projects/:project/merge_requests/:number/discussions/:discussion/notes/:note/award_emoji").String(),
530+
Methods: ParseHttpMethods([]string{"GET"}),
531+
SetRequestHeaders: headers,
532+
},
499533
)
500534

501535
if config.Inbound.GitLab.AllowCodeAccess {
@@ -512,6 +546,18 @@ func LoadConfig(configFiles []string, deploymentId int) (*Config, error) {
512546
Methods: ParseHttpMethods([]string{"GET"}),
513547
SetRequestHeaders: headers,
514548
},
549+
// Compare branches
550+
AllowlistItem{
551+
URL: gitLabBaseUrl.JoinPath("/projects/:project/repository/compare").String(),
552+
Methods: ParseHttpMethods([]string{"GET"}),
553+
SetRequestHeaders: headers,
554+
},
555+
// Update commit status
556+
AllowlistItem{
557+
URL: gitLabBaseUrl.JoinPath("/projects/:project/statuses/:commit").String(),
558+
Methods: ParseHttpMethods([]string{"GET"}),
559+
SetRequestHeaders: headers,
560+
},
515561
)
516562
}
517563
}

0 commit comments

Comments
 (0)