gitlab使用webhook向jenkins发送请求,报错 Requests to the local network are not allowed

 

以下是官方给出解释:

链接:https://docs.gitlab.com/ee/security/webhooks.html

 

If you have non-GitLab web services running on your GitLab server or within its local network, these may be vulnerable to exploitation via Webhooks.

With Webhooks, you and your project maintainers and owners can set up URLs to be triggered when specific things happen to projects. Normally, these requests are sent to external web services specifically set up for this purpose, that process the request and its attached data in some appropriate way.

Things get hairy, however, when a Webhook is set up with a URL that doesn't point to an external, but to an internal service, that may do something completely unintended when the webhook is triggered and the POST request is sent.

Because Webhook requests are made by the GitLab server itself, these have complete access to everything running on the server (http://localhost:123) or within the server's local network (http://192.168.1.12:345), even if these services are otherwise protected and inaccessible from the outside world.

If a web service does not require authentication, Webhooks can be used to trigger destructive commands by getting the GitLab server to make POST requests to endpoints like "http://localhost:123/some-resource/delete".

To prevent this type of exploitation from happening, starting with GitLab 10.6, all Webhook requests to the current GitLab instance server address and/or in a private network will be forbidden by default. That means that all requests made to 127.0.0.1, ::1 and 0.0.0.0, as well as IPv4 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and IPv6 site-local (ffc0::/10) addresses won't be allowed.

This behavior can be overridden by enabling the option "Allow requests to the local network from hooks and services" in the "Outbound requests" section inside the Admin area under Settings (/admin/application_settings):

 

大致意思 gitlab 10.6 版本以后为了安全,不允许向本地网络发送webhook请求,如果想向本地网络发送webhook请求,则需要使用管理员帐号登录,默认管理员帐号是admin@example.com,密码就是你gitlab搭建好之后第一次输入的密码,登录之后, 点击Configure Gitlab ,如下图所示

 

即可进入Admin area,在Admin area中,在settings标签下面,找到OutBound Request,勾选上Allow requests to the local network from hooks and services ,保存更改即可解决问题

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要配置GitLab webhookJenkins的集成,请按照以下步骤进行操作: 1. 打开Jenkins的管理界面,点击左侧的"系统管理"。 2. 在系统管理页面中,找到"系统设置"并点击打开。 3. 向下滚动页面,找到"GitLab"部分。 4. 在GitLab部分,找到"GitLab server"字段,点击"Add"按钮添加一个GitLab服务器。 5. 在出现的表单中,填写GitLab服务器的URL和凭证信息(用户名和访问令牌或密码),然后点击保存。 6. 返回到系统设置页面,向下滚动,找到"GitLab Connection Configuration"部分。 7. 在"Connection name"字段中,输入一个连接名称(如"GitLab")。 8. 在"Project naming strategy"字段中,选择一个适合你的命名策略。 9. 在"Webhook"部分,勾选"Enable authentication for webhook callbacks"选项以启用身份验证。 10. 在"Secret token"字段中,输入一个用于验证Webhook请求的密钥(可以是任意字符串)。 11. 点击保存。 现在你已经成功配置了GitLab webhookJenkins的集成。接下来,在GitLab中设置Webhook来触发Jenkins构建: 1. 打开你的GitLab仓库页面,点击左侧的"Settings"。 2. 在Settings页面中,选择"Webhooks"选项卡。 3. 点击"Add webhook"按钮。 4. 在URL字段中,输入Jenkins服务器的URL,后面加上`/project/<jenkins项目名称>/gitlab/build_now` (例如:`http://jenkins.example.com/project/my-project/gitlab/build_now`)。 5. 在Secret Token字段中,输入之前在Jenkins中设置的密钥。 6. 选择你希望触发Webhook的事件(例如Push事件)。 7. 点击保存。 现在,当你的GitLab仓库中的相关事件发生时,GitLab发送Webhook请求Jenkins,并触发相应的构建操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值