git历史提交记录脱敏

引子 最近写了个小项目,一直放在本地。写简历的时候俺觉得github有点少,于是俺决定将其放到github里去。蛋是,俺发现俺的大名在git的提交记录里面,俺又想保留提交记录,emmmm,于是有了这篇文章,目前仅有对用户名和邮箱的脱敏,因为俺只有这个地方比较敏感。至于代码中提交的系统文件绝对路径,俺倒是不在乎。 正文 原本使用git filter-branch,尝试运行后提示 WARNING: git-filter-branch has a glut of gotchas generating mangled history rewrites. Hit Ctrl-C before proceeding to abort, then use an alternative filtering tool such as 'git filter-repo' (https://github.com/newren/git-filter-repo/) instead. See the filter-branch manual page for more details; to squelch this warning, set FILTER_BRANCH_SQUELCH_WARNING=1. 于是俺就去看了看这个项目,本文会使用git-filter-repo对提交记录脱敏。 安装 pip安装 pip install git-filter-repo aur安装 yay -S git-filter-repo 对邮箱和用户名脱敏 mailmap 要对历史记录中的用户名和邮箱进行脱敏,需要用到mailmap文件 mailmap写法 username <email@addre.ss> <new@ema.il> <old1@ema.il> newusername <new@ema.il> <old2@ema.il> newusername <new@ema.il> oldusername<old3@ema.il> 修改用户名和邮箱的基础是原邮箱,所有的修改都是建立在匹配原邮箱的基础上做的 使用 编写mailmap文件 # 注意这个<>是必须的 username <new@ema.il> <email@addre.ss> 执行命令 git filter-repo --mailmap mailmapfile 缩写 --use-mailmap是--mailmap .mailmap的缩写 直接使用当前目录下的.mailmap文件 如果要将这个文件提交到git中。就使用第一个mailmap写法把,不要将oldemail放到里面了哦 参考 GitHub newren/git-filter-repo: Quickly rewrite git repository history (filter-branch replacement)

2024-04-22 · 1 分钟 · ziwindlu · 源笔记:04-Solutions/git历史提交记录脱敏.md

maven依赖检查

引子 在idea中编辑maven依赖文件时,发现了很多警告,定眼一看,原来是maven依赖的漏洞。于是决定找一个检查maven依赖的工具,以备不时之需 正文 命令行 安装 yay -S dependency-check-cli 安装后会提示这个 Users should be added to the 'dependencycheck' group to be able to perform vulnerability database updates. 需要将用户加到dependencycheck这个用户组里面去 使用 dependency-check -h用法查看 dependency-check -o . -s x.jar 注意,命令行工具需主机要对nvd.nist.gov访问流畅 maven插件方式 这里仅介绍一种开箱即用的方式 其他方式请查看链接 项目中引入仅生成html 在pom.xml中plugs中添加以下内容 <plugin> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> <version>8.4.0</version> <executions> <execution> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> 添加完成后导入依赖 运行mvn dependency-check:check即可在target中找到对应的报告了

2024-04-10 · 1 分钟 · ziwindlu · 源笔记:04-Solutions/maven依赖检查.md