CaseyLabs/kc-secure-repo-template
GitHub: CaseyLabs/kc-secure-repo-template
一个为 GitHub 项目提供开箱即用安全加固的仓库模板,集成漏洞扫描、密钥检测、供应链防护和自动化依赖更新,帮助团队从项目创建之初建立安全基线。
Stars: 5 | Forks: 0
# kc-secure-repo-template
**一个为新的 GitHub 项目提供安全加固的仓库模板。**
- [功能](#features)
- [示例输出](#example-output)
- [要求](#requirements)
- [快速开始](#quick-start)
- [设置](#setup)
- [使用方法](#usage)
- [仓库结构](#repository-layout)
- [文档](#documentation)
- [仓库选项](#repo-options)
- [Kubernetes 支持](#kubernetes-k8s-support)
- [AI 代理命令](#ai-agents-commands)
- [依赖项更新](#dependency-updates)
- [安全扫描器](#security-scanners)
## 功能
此仓库模板开箱即包含以下默认选项:
### 安全性
- 扫描漏洞、配置错误以及泄露的 secrets(包括 Git 历史)
- 使用固定的 SHA 校验和进行可重复构建,以帮助防止供应链攻击 [[1]](https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions)
### 开发者工作流
- 用于本地开发和 CI 的 Nonroot 容器
- GitHub Actions CI 工作流模板
- 自动化依赖项更新检查
- AI 代理编码模板
### 基础设施
- 可选的 Terraform 和 Kubernetes Helm 脚手架
## 示例输出
```
> make example
==> Build summary
Image: kc-secure-template-example:local
Project config: ./config/project.cfg
Source Code: ./src
Results:
Container build: passed
App build: passed
Lint: passed
Tests: passed
Run: passed
Security scan: passed
```
## 要求
- 终端 Shell(Linux、MacOS 或 WSL)
- Docker
## 快速开始
在终端中,运行以下命令:
```
git clone --depth 1 https://github.com/CaseyLabs/kc-secure-repo-template
cd kc-secure-repo-template
make example # Builds/tests/runs an example container
```
### 设置
- 将你的源代码放入 `src/` 文件夹
- 然后自定义以下文件以适应你的项目/代码库:
- `config/project.cfg`
- `Dockerfile`
- `scripts/*.sh`
### 使用方法
```
# Main Commands
make build # builds the project as a container image
make test # run code linters, tests, and source build in the container image
make run # runs the container
make stop # stops the contaner
# Misc Commands
make clean # Removes all previously running containers
make shell # Opens a shell in the running container
make status # show the local image and running containers
make logs # show logs from running containers
make scan # run security and secret scanning
make update # Updates the pinned SHA checksums in `./config/lockfile.cfg`
make renovate # Runs self-hosted Renovate for this repository
make dist # build release artifacts to `./dist`
make k8s # lint/render/package Helm chart in `./config/k8s/chart`
make k8s-test-local # server-side dry-run using a pinned kubectl image and your kubeconfig
make infra # build/test/plan Terraform config from `./config/infra`
```
## 仓库结构
```
.
├── AGENTS.md # Repo-specific AI agent guidance
├── CLAUDE.md # Claude Code shim that imports AGENTS.md
├── Makefile # For all `make` commands
├── Dockerfile # Default nonroot dev/CI container image
├── docs/ # Project documentation
├── src/ # Project source code (built into a container)
├── scripts/ # Scripts used by the Makefile
├── config/
│ ├── project.cfg # Project configuration
│ ├── lockfile.cfg # Pinned SHA checksums for project tooling
│ ├── k8s/ # Optional Kubernetes Helm scaffold
│ └── infra/ # Terraform example for GitHub repo hardening
├── .github/
│ └── workflows/ # GitHub Actions workflows
└── .agents/
├── code_review.md # Repo-specific AI agent `/review` checklist
└── skills/ # Repo-specific AI agent skills templates
```
## 文档
- [模板概述](docs/README.md)
- [自定义模板](docs/customize-template.md)
- [构建命令](docs/build-commands.md)
- [安全模型](docs/security-model.md)
- [Github Actions CI/CD](docs/github-ci.md)
- [发布与打包](docs/release-and-packaging.md)
- [依赖项更新](docs/dependency-updates.md)
- [AI 代理支持](docs/ai-agent-support.md)
- [Terraform 支持](docs/terraform.md)
- [Kubernetes 支持](docs/k8s.md)
## 仓库选项
### Kubernetes (`k8s`) 支持
用法:
```
make k8s # lint/render/package Helm chart in `./config/k8s/chart`
```
- 将 Kubernetes 拥有的静态资产保留在 `config/k8s/` 中
### AI 代理命令
本项目包含可由 AI CLI 工具(如 Codex CLI、Claude Code 等)使用的代理命令和技能。
示例命令:
```
# 基于 `.agents/code_review.md` 中的清单执行 code review:
/review
# Perform a security audit of the repo, using `.agents/skills/security-review`:
$security-review
```
### 依赖项更新
此模板还使用第三方工具通过 Pull Request 自动更新项目镜像/工具/依赖项:
- [dependabot](https://docs.github.com/en/code-security/tutorials/secure-your-dependencies/dependabot-quickstart-guide):
- `.github/dependabot.yml`
- [renovate](https://github.com/renovatebot/renovate):将更新 `config/project.cfg` 中列出的任何工具
- `.github/renovate.json`
- `.github/workflows/renovate.yml`
_注意_:Renovate 需要安装 GitHub App 才能运行。要创建一个,请运行:
.github/renovate/setup-github-app.sh
- 如果你不想在你的仓库中使用 Renovate:
- 在 `config/project.cfg` 中设置 `DEV_SCAN_ENABLE_RENOVATE=false`。
### 安全扫描器
本项目使用以下开源工具作为其安全扫描工作流的一部分:
- [actionlint](https://github.com/rhysd/actionlint):对 GitHub Actions 工作流文件进行代码检查。
- [gitleaks](https://github.com/gitleaks/gitleaks):扫描仓库(包括可用的 Git 历史),以查找泄露的 secrets。
- [grype](https://github.com/anchore/grype):在发布构建期间扫描生成的 SBOM 以查找已知漏洞。
- [syft](https://github.com/anchore/syft):为发布构件生成 SBOM 输出。
- [trivy](https://github.com/aquasecurity/trivy):扫描仓库中的 Dockerfile 配置错误。
标签:AI代理, AI编码, CI/CD安全, Cutter, DevSecOps, Docker, ECS, GitHub Actions, GitHub模板, Git历史扫描, Helm, Llama, SHA校验, SMB, StruQ, Terraform, Web截图, 上游代理, 代码安全, 依赖更新, 可复现构建, 子域名突变, 安全基架, 安全基线, 安全工程, 安全开发工作流, 安全模板, 安全脚手架, 安全防御评估, 容器安全, 密钥泄露检测, 搜索语句(dork), 教学环境, 漏洞枚举, 结构化查询, 自动化安全, 自动笔记, 请求拦截, 错误配置检测, 防供应链攻击, 非root容器