代码之家  ›  专栏  ›  技术社区  ›  Arunkumar

预接收钩子文件,在执行钩子时显示不需要的消息

  •  0
  • Arunkumar  · 技术社区  · 7 年前

    GitLab版本- 9.3.6

    最近我添加了 pre-receive 用于阻止二进制文件推送的钩子。我可以在我的gitlab测试服务器机器上获得预期的结果(下图)

    Testing Server side displaying message

    我在live server机器上添加了相同的钩子文件。但我在显示消息时又多了一行(如下)。

    Live server side displaying message

    实际上,我的钩子工作正常。但消息中显示了额外的一行。我确信,我的钩子文件上没有额外的打印语句。

    我的提交消息是

    remote: hooks/pre-receive:3: warning: Insecure world writable dir /opt/gitlab/embedded/libexec in PATH, mode 040777        
    
    remote: Hello there! We have restricted the binary files (.exe, .dll, .zip, .7z, .deb, .cab, .gz, .pkg, .iso) that are pushed into GitLab.        
    remote: Your changes contain following file(s) from origin commit c7a151fb to a4e7c31c. Kindly remove the following file(s) and try again.        
    remote:     NewTest.dll        
    

    如何删除该行 hooks/pre-receive:3: warning: Insecure world writable dir /opt/gitlab/embedded/libexec in PATH, mode 040777 从那条消息行?

    2 回复  |  直到 7 年前
        1
  •  3
  •   mmlr    7 年前

    警告表明 /opt/gitlab/embedded/libexec 是世界可写的。这是一个安全问题,因为它是挂钩运行的路径环境的一部分。这意味着任何有权访问服务器的人都可以将可执行文件放入该目录,可能会用恶意命令隐藏合法命令。如果在钩子中使用这些命令,任何人都可以获得运行钩子的用户的权限。

    要解决此问题,应使指示的libexec目录不可全局写入:

    chmod o-w /opt/gitlab/embedded/libexec
    
        2
  •  0
  •   Arunkumar    7 年前

    我通过使用 sudo chmod go-w /opt/gitlab , sudo chmod go-w /opt/gitlab/embedded/bin sudo chmod go-w /opt/gitlab/embedded

    我在错误中显示的路径中授予写入权限。最后,它的工作。