green-code-initiative/creedengo-rules-specifications

GitHub: green-code-initiative/creedengo-rules-specifications

基于 SonarQube 的多语言静态代码分析插件集合,旨在帮助开发者识别和消除导致能源浪费与环境足迹增加的代码模式。

Stars: 210 | Forks: 106

Creedengo logo

A Green Code Initiative project

_creedengo_ 是一个旨在降低软件在代码层面环境足迹的集体项目。该项目的目标是提供一系列静态代码分析器,以突显可能产生负面生态影响的代码结构:能源和资源过度消耗、“臃肿软件”、缩短终端寿命等。 _creedengo_ 基于针对各种技术的不断演进的[最佳实践](docs/rules)目录。SonarQube 插件随后将这些目录实现为扫描您项目的规则。 **警告**:这仍处于非常早期的阶段项目。任何反馈或贡献都将受到高度赞赏。请参阅贡献部分。 [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CODE_OF_CONDUCT.md) ## 🌿 SonarQube 插件 目前 creedengo 支持 7 种技术: - “标准”插件: - [Java 插件](https://github.com/green-code-initiative/creedengo-java) - [JavaScript 插件](https://github.com/green-code-initiative/creedengo-javascript) - [PHP 插件](https://github.com/green-code-initiative/creedengo-php) - [Python 插件](https://github.com/green-code-initiative/creedengo-python) - [C# 插件](https://github.com/green-code-initiative/creedengo-csharp) - 移动端插件: - [Android 插件](https://github.com/green-code-initiative/ecoCode-android) - [iOS 插件](https://github.com/green-code-initiative/creedengo-ios) ![截图](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/dd7b00fd30011924.jpg) ### 生态设计 SonarQube 插件 ![Ekko logo](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/1ace04383b011927.png) 有两种类型的插件: - 一种用于 Web / backoffice(PHP、Python、Java、JavaScript),使用 2015 年 9 月发布的仓库第二版中描述的坏味道。 您可以[在此(法语)](https://docs.google.com/spreadsheets/d/1nujR4EnajnR0NSXjvBW3GytOopDyTfvl3eTk2XGLh5Y/edit#gid=1386834576)找到所有规则。 当前仓库用于 Web / backOffice - 一种用于移动端,使用由 Dr. Olivier Le Goaër 理论化的[一组代码坏味道](https://github.com/cnumr/best-practices-mobile)。 您可以在[此处](https://github.com/green-code-initiative/ecoCode-android)的仓库中找到此插件。 ### SonarQube 插件的工作原理 代码被解析以转换为 AST。AST 将允许您访问代码的一个或多个节点。 例如,您将能够访问所有的 `for` 循环,以探索内容等。 为了更好地理解 AST 结构,您可以使用 [AST Explorer](https://astexplorer.net/)。 ### creedengo 规则规范仓库 此项目包含所有语言的所有 creedengo 规范。 #### 结构 规则根据其在[根规则文件夹](src/main/rules)中的 ID 按文件夹组织。 这些文件夹中的每一个都包含一个带有规则元数据的文件,以及按语言划分的描述。 元数据文件使用 [SonarSource Analyzers Commons](https://github.com/SonarSource/sonar-analyzer-commons/tree/master/commons) 库支持的格式。 要了解可以在其中放入哪些值,我们建议您使用官方 [SonarQube 文档](https://docs.sonarsource.com/sonarqube/latest/user-guide/rules/overview/),并参考现有的文件。 以下是一个示例: ``` src/main/rules ├── GCI104 │ ├── java │ │ ├── GCI104.asciidoc │ │ ├── GCI104.json │ ├── php │ │ ├── GCI104.asciidoc │ ├── python │ │ ├── GCI104.asciidoc │ └── GCI104.json ├── ... ``` 要为特定语言指定元数据(例如仅针对单一语言弃用某个规则),可以在语言文件夹中创建一个 json 文件,这将在构建期间与公共文件合并。特定文件中的键具有优先级,可以添加新键,但不能从全局文件中删除它们。 #### 描述语言 规则的描述使用 ASCIIDOC 格式(具有 [Markdown 兼容性](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#markdown-compatibility)),以便允许包含其他页面(此功能在标准 Markdown 中不可用)。 参见: - [AsciiDoc 语法快速参考](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/) - [比较 AsciiDoc 与 Markdown](https://docs.asciidoctor.org/asciidoc/latest/asciidoc-vs-markdown/) ## 🚀 快速入门 您可以使用 Docker 快速探索 Creedengo 插件。有关详细说明,请参阅每个插件的“Getting Started”部分: - [Java 插件](https://github.com/green-code-initiative/creedengo-java?tab=readme-ov-file#-getting-started) - [PHP 插件](https://github.com/green-code-initiative/creedengo-php?tab=readme-ov-file#-getting-started) - [Python 插件](https://github.com/green-code-initiative/creedengo-python?tab=readme-ov-file#-getting-started) - [C# 插件](https://github.com/green-code-initiative/creedengo-csharp?tab=readme-ov-file#-getting-started) - [Android Java 插件](https://github.com/green-code-initiative/ecoCode-android?tab=readme-ov-file#-quickstart) ## 🛒 发行 获取 Creedengo 插件的主要方式是通过 SonarQube Marketplace,可在管理部分访问。或者,您可以直接从 GitHub releases 下载它们。 我们于 2023 年 12 月将插件仓库 `creedengo` 拆分为每个插件一个仓库。 因此,根据您想要的版本,插件版本可在 2 个仓库中找到: - Java 插件: - 从 0.x 到 1.4.3:[creedengo 仓库](https://github.com/green-code-initiative/creedengo-rules-specifications/releases) - 自 1.5.0 起:[creedengo-java 仓库](https://github.com/green-code-initiative/creedengo-java/releases) - PHP 插件: - 从 0.x 到 1.3.1:[creedengo 仓库](https://github.com/green-code-initiative/creedengo-rules-specifications/releases) - 自 1.4.0 起:[creedengo-php 仓库](https://github.com/green-code-initiative/creedengo-php/releases) - Python 插件: - 从 0.x 到 1.3.1:[creedengo 仓库](https://github.com/green-code-initiative/creedengo-rules-specifications/releases) - 自 1.4.0 起:[creedengo-python 仓库](https://github.com/green-code-initiative/creedengo-python/releases) - Javascript 插件: - 从 0.x 到 1.3.0:[creedengo 仓库](https://github.com/green-code-initiative/creedengo-rules-specifications/releases) - 自 1.4.0 起:[creedengo-javascript 仓库](https://github.com/green-code-initiative/creedengo-javascript/releases) - C# 插件: - 自 0.x 起:[creedengo 仓库](https://github.com/green-code-initiative/creedengo-csharp/releases) - Android 插件:[creedengo-android 仓库](https://github.com/green-code-initiative/ecoCode-android/releases) - iOS 插件:[creedengo-ios 仓库](https://github.com/green-code-initiative/creedengo-ios/releases) ## 🧩 插件版本兼容性(旧 `ecocode` 插件) | 插件版本 | SonarQube 版本 | Java 版本 | |---------------------|-----------------------------|--------------| | 1.4+ | SonarQube 9.4.+ LTS to 10.1 | 11 / 17 | | 1.2.x, 1.3.x | SonarQube 9.4.+ LTS to 10.0 | 11 / 17 | | 0.2.x, 1.0.x, 1.1.x | SonarQube 9.4.+ LTS to 9.9 | 11 / 17 | | 0.1.x | SonarQube 8.9.+ LTS to 9.3 | 11 / 17 |
标签:Android, CMS安全, CSharp, DSL, Green IT, Homebrew安装, JavaScript, JS文件枚举, Kafka, LNA, OpenVAS, PHP, Python, SonarQube插件, 代码规则, 可持续发展, 域名枚举, 域名枚举, 安全专业人员, 插件开发, 数据可视化, 无后门, 环保编程, 环境足迹, 绿色计算, 绿色软件工程, 能耗优化, 自动化payload嵌入, 请求拦截, 资源节约, 软件碳足迹, 逆向工具, 错误基检测, 静态代码分析