diver-osint-ctf/clilint

GitHub: diver-osint-ctf/clilint

一个基于 Go 的 CTF 挑战 YAML 配置文件校验工具,集成 GitHub Actions 实现自动 lint 并在 PR 上发布结果评论。

Stars: 1 | Forks: 0

# clilint - CTF 挑战 YAML Linter 一个基于 Go 的 linter,用于检查 [ctfcli](https://github.com/CTFd/ctfcli) 的 challenge.yml 文件,集成了 GitHub Actions 并支持自动在 PR 上发表评论。 ## 功能 - ✅ **YAML 格式验证**:确保 YAML 语法有效 - ✅ **文件存在性检查**:验证 `files` 字段中列出的文件是否存在 - ✅ **文件大小**:检查 `files[]` 中的所有文件是否小于或等于 1.00 MB - ✅ **Welcome 要求**:验证非 welcome 挑战的 welcome 依赖项 - ✅ **字段验证**:检查 `image`、`state`、`version` 和 `tags` 字段 - 🚀 **GitHub 集成**:自动检测 PR 并发表评论 - 🎯 **智能检测**:仅处理发生更改的目录 ## GitHub Actions 用法 ### 快速设置 1. 将此 workflow 添加至 [`.github/workflows/lint.yml`](./.github/workflows/lint.yml): 2. linter 将自动: - ✅ 检测包含 `challenge.yml` 文件的已更改目录 - ✅ 仅对受影响的挑战进行 lint - ✅ 将详细结果作为 PR 评论发布 - ✅ 在 PR 发生更改或出现 `@github clilint` 评论时触发 ## 验证规则 | 规则 | 描述 | | ---------------------- | --------------------------------------------------------------------- | | **YAML 格式** | 必须是有效的 YAML 语法 | | **文件存在性** | `files[]` 中的所有文件必须存在 | | **文件大小** | `files[]` 中的所有文件必须小于或等于 1.00 MB | | **Welcome 依赖** | 非 welcome 挑战必须在 `requirements[]` 中包含 "welcome" | | **Image 字段** | 必须为 `null` | | **State 字段** | 必须为 `"visible"` | | **Version 字段** | 必须为 `"0.1"` | | **Tags 字段** | 必须仅包含以下之一:`beginner`、`easy`、`medium`、`hard` | ## 示例 challenge.yml ``` name: "web_challenge" author: "author_name" category: "web" description: "Challenge description with **markdown** support" flags: ["flag{example}"] tags: ["medium"] files: ["public/challenge.zip"] requirements: ["welcome"] value: 500 type: dynamic extra: initial: 500 decay: 100 minimum: 100 image: null host: null state: visible version: "0.1" ``` ## 示例 lintrc.yaml [lintrc.yaml](./lintrc.yaml) ``` tags: condition: and patterns: - type: regex values: - "author: *" - type: static values: - easy - medium - hard ``` ## PR 评论示例 linter 会发布丰富的 markdown 评论: ``` ## 🎉 CTF Challenges YAML Linting 结果 ✅ All affected challenge.yml files passed linting! ### 📋 本 PR 中已检查的 Challenges: #### 🚩 **web_challenge** (`web/chall1/challenge.yml`) Challenge description with **markdown** support --- ✨ Great job! All challenge.yml files follow the required format. ```
标签:EVTX分析, GitHub Actions, Go, Ruby工具, SOC Prime, YAML, 代码检查工具, 安全库, 开发工具, 日志审计, 自动笔记