chore: 新增签名凭据 pre-commit 拦截钩子,防止 signingConfigs 入库
This commit is contained in:
@@ -33,12 +33,38 @@ hvigorw assembleHap --mode module -p product=default -p buildMode=release
|
||||
|
||||
## 签名 Signing
|
||||
|
||||
`build-profile.json5` 里 `signingConfigs` 目前为**空**,且 `products[].signingConfig` 引用了 `"default"` —— **签名尚未配置**。
|
||||
### 现状与原则
|
||||
|
||||
- `build-profile.json5` 里 `signingConfigs` 在**仓库中必须保持为空 `[]`**(`products[].signingConfig` 仍引用 `"default"`)——签名是机器相关的,禁止入库。
|
||||
- 真正的密钥物料(`.p12` / `.cer` / `.p7b`)由 DevEco 生成在 `~/.ohos/config/` 下,**本来就在仓库外**;`build-profile.json5` 里只有「文件路径 + 加密后的密码」,但同样属敏感信息,不得提交。
|
||||
|
||||
### 本地配置签名(不入库)
|
||||
|
||||
要跑真机/模拟器需先配置签名:
|
||||
- DevEco Studio → File → Project Structure → Signing Configs → 勾选自动签名(登录华为账号)。
|
||||
- 或手动配置 `.p12` + `.cer` / `.p7b`。
|
||||
|
||||
> 该文件的签名部分属于 **Agent 禁止修改** 范围(见 `AGENTS.md`)。
|
||||
DevEco 自动签名会把凭据写进 `build-profile.json5`,这属于**本地未提交状态**,不要 `git add` 它。
|
||||
|
||||
### 防泄露:pre-commit 钩子
|
||||
|
||||
仓库内置了 pre-commit 钩子 `scripts/git-hooks/pre-commit`:只要暂存区的 `build-profile.json5` 出现 `keyPassword` / `storePassword` / `certpath` 等签名字段,就**拒绝提交**。
|
||||
|
||||
每个克隆启用一次:
|
||||
|
||||
```bash
|
||||
git config core.hooksPath scripts/git-hooks
|
||||
```
|
||||
|
||||
验证:临时在 `build-profile.json5` 里塞一个 `"keyPassword"` 再 `git add build-profile.json5 && git commit`,应被拦截。
|
||||
|
||||
> 确需临时绕过时用 `git commit --no-verify`(仅应急,不建议)。
|
||||
|
||||
### 彻底外部化(可选)
|
||||
|
||||
若想连本地也不出现凭据,可走「动态配置签名」:用 `hvigorfile.ts` 从 gitignore 的本地文件或环境变量读取签名注入,让 `build-profile.json5` 始终保持空。参考华为官方《基于动态配置签名的多人协同开发应用签名解决方案》。
|
||||
|
||||
> `build-profile.json5` 的签名部分属于 **Agent 禁止修改** 范围(见 `AGENTS.md`)。
|
||||
|
||||
## 产品与构建模式 Products & Build Modes
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ git push -u origin hotfix/xxx
|
||||
2. **PR 合入前过 lint + 相关测试**,见 `docs/testing.md` 的「改动后验证」。
|
||||
3. **feature 合并后删除分支**,保持分支列表干净。
|
||||
4. **提交信息必须走 Conventional Commits**,不合规的提交在 PR 中 squash 掉。
|
||||
5. **签名信息永不入库**——`build-profile.json5` 的 `signingConfigs` 必须保持空 `[]`,已由 pre-commit 钩子兜底,见 `docs/build-deploy.md` 的「签名管理」。
|
||||
|
||||
## 仓库设置 Repo Settings(一次性)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user