@ohos-graphics/stability-code-review 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -0
- package/SKILL.md +518 -0
- package/bin/install.js +165 -0
- package/config/rules.yaml +445 -0
- package/config/whitelist.yaml +52 -0
- package/package.json +40 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_001.md +275 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_002.md +273 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_003.md +305 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_004.md +350 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_005.md +301 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_006.md +320 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_007.md +432 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_008.md +394 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_009.md +425 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_010.md +472 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_011.md +204 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_012.md +210 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_013.md +226 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_014.md +222 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_015.md +256 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_016.md +269 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_017.md +222 -0
- package/references/BoundaryCondition/StabilityCodeReview_BoundaryCondition_018.md +336 -0
- package/references/ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_001.md +414 -0
- package/references/ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_002.md +335 -0
- package/references/ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_003.md +284 -0
- package/references/ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_004.md +313 -0
- package/references/ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_005.md +364 -0
- package/references/ExceptionHandling/StabilityCodeReview_ExceptionHandling_001.md +142 -0
- package/references/ExceptionHandling/StabilityCodeReview_ExceptionHandling_002.md +222 -0
- package/references/ExceptionHandling/StabilityCodeReview_ExceptionHandling_003.md +383 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_001.md +258 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_002.md +131 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_003.md +220 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_004.md +224 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_005.md +250 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_006.md +153 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_007.md +169 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_008.md +153 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_009.md +144 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_010.md +152 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_011.md +221 -0
- package/references/GraphicsStability/StabilityCodeReview_GraphicsStability_012.md +318 -0
- package/references/InitializationOrder/StabilityCodeReview_InitializationOrder_001.md +411 -0
- package/references/Lifecycle/StabilityCodeReview_Lifecycle_001.md +255 -0
- package/references/Lifecycle/StabilityCodeReview_Lifecycle_002.md +177 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_001.md +332 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_002.md +261 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_003.md +428 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_004.md +400 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_005.md +364 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_006.md +359 -0
- package/references/MemoryStability/StabilityCodeReview_MemoryStability_007.md +279 -0
- package/references/PROBLEM_TEMPLATE.md +65 -0
- package/references/PerformanceStability/StabilityCodeReview_PerformanceStability_001.md +380 -0
- package/references/PerformanceStability/StabilityCodeReview_PerformanceStability_002.md +437 -0
- package/references/REPORT_TEMPLATE.csv +5 -0
- package/references/REPORT_TEMPLATE.md +132 -0
- package/references/RULE_DEVELOPMENT_GUIDE.md +711 -0
- package/references/RULE_INDEX.md +101 -0
- package/references/RULE_TEMPLATE.md +192 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_001.md +334 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_002.md +425 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_003.md +420 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_004.md +409 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_005.md +445 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_006.md +384 -0
- package/references/ResourceManagement/StabilityCodeReview_ResourceManagement_007.md +395 -0
- package/scripts/add-rule.py +423 -0
package/bin/install.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { cp, mkdir, rm, stat } from 'node:fs/promises';
|
|
4
|
+
import { realpathSync } from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_SKILL_NAME = 'ohos-dev-graphics-stability-code-review';
|
|
10
|
+
|
|
11
|
+
const PAYLOAD_ENTRIES = [
|
|
12
|
+
'SKILL.md',
|
|
13
|
+
'README.md',
|
|
14
|
+
'config',
|
|
15
|
+
'references',
|
|
16
|
+
'scripts',
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function defaultTargetRoot()
|
|
20
|
+
{
|
|
21
|
+
return process.env.OPENCODE_SKILLS_DIR || path.join(os.homedir(), '.config', 'opencode', 'skills');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function pathExists(targetPath)
|
|
25
|
+
{
|
|
26
|
+
try {
|
|
27
|
+
await stat(targetPath);
|
|
28
|
+
return true;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error?.code === 'ENOENT') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function installSkill({
|
|
38
|
+
packageRoot,
|
|
39
|
+
targetRoot = defaultTargetRoot(),
|
|
40
|
+
skillName = DEFAULT_SKILL_NAME,
|
|
41
|
+
force = false,
|
|
42
|
+
quiet = false,
|
|
43
|
+
dryRun = false,
|
|
44
|
+
} = {})
|
|
45
|
+
{
|
|
46
|
+
if (!packageRoot) {
|
|
47
|
+
throw new Error('packageRoot is required');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const targetDir = path.join(targetRoot, skillName);
|
|
51
|
+
const exists = await pathExists(targetDir);
|
|
52
|
+
|
|
53
|
+
if (exists && !force) {
|
|
54
|
+
throw new Error(`Skill already exists at ${targetDir}. Re-run with --force to replace it.`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!dryRun) {
|
|
58
|
+
await mkdir(targetRoot, { recursive: true });
|
|
59
|
+
if (exists) {
|
|
60
|
+
await rm(targetDir, { recursive: true, force: true });
|
|
61
|
+
}
|
|
62
|
+
await mkdir(targetDir, { recursive: true });
|
|
63
|
+
|
|
64
|
+
for (const entry of PAYLOAD_ENTRIES) {
|
|
65
|
+
await cp(path.join(packageRoot, entry), path.join(targetDir, entry), {
|
|
66
|
+
recursive: true,
|
|
67
|
+
force: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!quiet) {
|
|
73
|
+
const action = dryRun ? 'Would install' : 'Installed';
|
|
74
|
+
console.log(`${action} ${DEFAULT_SKILL_NAME} to ${targetDir}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { targetDir, entries: [...PAYLOAD_ENTRIES] };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function printHelp()
|
|
81
|
+
{
|
|
82
|
+
console.log(`OpenHarmony stability code review skill installer
|
|
83
|
+
|
|
84
|
+
Usage:
|
|
85
|
+
ohos-stability-skill install [options]
|
|
86
|
+
npx @ohos-graphics/stability-code-review install [options]
|
|
87
|
+
|
|
88
|
+
Options:
|
|
89
|
+
--target <dir> Skills root directory. Defaults to ~/.config/opencode/skills
|
|
90
|
+
--name <name> Installed skill directory name. Defaults to ${DEFAULT_SKILL_NAME}
|
|
91
|
+
--force Replace an existing installed skill
|
|
92
|
+
--dry-run Print the target path without copying files
|
|
93
|
+
-h, --help Show this help
|
|
94
|
+
`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function parseArgs(argv)
|
|
98
|
+
{
|
|
99
|
+
const args = [...argv];
|
|
100
|
+
const options = {};
|
|
101
|
+
|
|
102
|
+
if (args[0] === 'install') {
|
|
103
|
+
args.shift();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
while (args.length > 0) {
|
|
107
|
+
const arg = args.shift();
|
|
108
|
+
if (arg === '-h' || arg === '--help') {
|
|
109
|
+
options.help = true;
|
|
110
|
+
} else if (arg === '--force') {
|
|
111
|
+
options.force = true;
|
|
112
|
+
} else if (arg === '--dry-run') {
|
|
113
|
+
options.dryRun = true;
|
|
114
|
+
} else if (arg === '--target') {
|
|
115
|
+
options.targetRoot = args.shift();
|
|
116
|
+
} else if (arg === '--name') {
|
|
117
|
+
options.skillName = args.shift();
|
|
118
|
+
} else {
|
|
119
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (options.targetRoot === undefined && argv.includes('--target')) {
|
|
124
|
+
throw new Error('--target requires a directory');
|
|
125
|
+
}
|
|
126
|
+
if (options.skillName === undefined && argv.includes('--name')) {
|
|
127
|
+
throw new Error('--name requires a skill directory name');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return options;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function main()
|
|
134
|
+
{
|
|
135
|
+
const options = parseArgs(process.argv.slice(2));
|
|
136
|
+
if (options.help) {
|
|
137
|
+
printHelp();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const binDir = path.dirname(fileURLToPath(import.meta.url));
|
|
142
|
+
const packageRoot = path.resolve(binDir, '..');
|
|
143
|
+
await installSkill({ ...options, packageRoot });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function isDirectRun()
|
|
147
|
+
{
|
|
148
|
+
if (!process.argv[1]) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
153
|
+
try {
|
|
154
|
+
return realpathSync(process.argv[1]) === currentFile;
|
|
155
|
+
} catch {
|
|
156
|
+
return path.resolve(process.argv[1]) === currentFile;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (isDirectRun()) {
|
|
161
|
+
main().catch((error) => {
|
|
162
|
+
console.error(error.message);
|
|
163
|
+
process.exitCode = 1;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
异常处理:
|
|
3
|
+
name: 异常处理
|
|
4
|
+
description: OpenHarmony 不允许使用异常处理机制,检测代码中的 try/catch/throw;异常分支处理不当、返回值校验缺失等稳定性问题
|
|
5
|
+
enabled: true
|
|
6
|
+
rules:
|
|
7
|
+
StabilityCodeReview_ExceptionHandling_001:
|
|
8
|
+
enabled: true
|
|
9
|
+
id: StabilityCodeReview_ExceptionHandling_001
|
|
10
|
+
name: 禁止异常处理机制
|
|
11
|
+
severity: MEDIUM
|
|
12
|
+
description: OpenHarmony 不允许使用 C++ 异常处理机制,检测代码中的 try/catch/throw
|
|
13
|
+
reference: ExceptionHandling/StabilityCodeReview_ExceptionHandling_001.md
|
|
14
|
+
StabilityCodeReview_ExceptionHandling_002:
|
|
15
|
+
enabled: true
|
|
16
|
+
id: StabilityCodeReview_ExceptionHandling_002
|
|
17
|
+
name: 异常分支应正确处理
|
|
18
|
+
severity: MEDIUM
|
|
19
|
+
description: 异常处理分支应该有合适的处理方式,不能静默忽略或遗漏return,否则可能导致程序继续执行后续逻辑引发更严重问题
|
|
20
|
+
reference: ExceptionHandling/StabilityCodeReview_ExceptionHandling_002.md
|
|
21
|
+
StabilityCodeReview_ExceptionHandling_003:
|
|
22
|
+
enabled: true
|
|
23
|
+
id: StabilityCodeReview_ExceptionHandling_003
|
|
24
|
+
name: 需校验函数返回值
|
|
25
|
+
severity: HIGH
|
|
26
|
+
description: 当函数的返回值表示操作成功与否时,必须校验返回值。忽略返回值可能导致错误未被发现,使用未初始化的输出参数,程序继续执行可能引发更严重的问题
|
|
27
|
+
reference: ExceptionHandling/StabilityCodeReview_ExceptionHandling_003.md
|
|
28
|
+
并发稳定性:
|
|
29
|
+
name: 并发稳定性
|
|
30
|
+
description: 检测并发相关的稳定性风险(死锁、线程池耗尽、任务堆积等)
|
|
31
|
+
enabled: true
|
|
32
|
+
rules:
|
|
33
|
+
StabilityCodeReview_ConcurrencyStability_001:
|
|
34
|
+
enabled: true
|
|
35
|
+
id: StabilityCodeReview_ConcurrencyStability_001
|
|
36
|
+
name: 多线程场景线程安全设计缺失
|
|
37
|
+
severity: HIGH
|
|
38
|
+
description: 在多线程场景下,共享数据的访问如果没有做好线程安全设计,会导致数据竞争、内存不一致等问题,引发程序崩溃、数据损坏等严重稳定性问题
|
|
39
|
+
reference: ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_001.md
|
|
40
|
+
StabilityCodeReview_ConcurrencyStability_002:
|
|
41
|
+
enabled: true
|
|
42
|
+
id: StabilityCodeReview_ConcurrencyStability_002
|
|
43
|
+
name: 智能指针线程安全问题
|
|
44
|
+
severity: HIGH
|
|
45
|
+
description: 智能指针不是线程安全的,对于同一个shared_ptr或sptr对象,允许多线程同时读,但是不允许多线程又读又写,否则会导致数据竞争、引用计数错误、内存泄漏或UAF
|
|
46
|
+
reference: ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_002.md
|
|
47
|
+
StabilityCodeReview_ConcurrencyStability_003:
|
|
48
|
+
enabled: true
|
|
49
|
+
id: StabilityCodeReview_ConcurrencyStability_003
|
|
50
|
+
name: std::atomic时序问题
|
|
51
|
+
severity: MEDIUM
|
|
52
|
+
description: std::atomic可以保证操作的原子性,但是不能保证时序,使用std::atomic需要检验代码的时序是否正确,配合适当的内存序(memory_order)使用
|
|
53
|
+
reference: ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_003.md
|
|
54
|
+
StabilityCodeReview_ConcurrencyStability_004:
|
|
55
|
+
enabled: true
|
|
56
|
+
id: StabilityCodeReview_ConcurrencyStability_004
|
|
57
|
+
name: 加锁后返回引用或裸指针
|
|
58
|
+
severity: HIGH
|
|
59
|
+
description: 加锁后返回引用类型或裸指针类型极易引入并发风险或内存风险,应避免使用。锁释放后,返回的引用或裸指针可能指向已被其他线程修改或释放的数据
|
|
60
|
+
reference: ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_004.md
|
|
61
|
+
StabilityCodeReview_ConcurrencyStability_005:
|
|
62
|
+
enabled: true
|
|
63
|
+
id: StabilityCodeReview_ConcurrencyStability_005
|
|
64
|
+
name: RenderNodeDrawable全局变量写入
|
|
65
|
+
severity: HIGH
|
|
66
|
+
description: RenderNodeDrawable中应避免写入全局变量,若必须使用则应加锁保护避免并发。全局变量在多线程环境下并发写入会导致数据竞争、状态不一致等问题
|
|
67
|
+
reference: ConcurrencyStability/StabilityCodeReview_ConcurrencyStability_005.md
|
|
68
|
+
性能稳定性:
|
|
69
|
+
name: 性能稳定性
|
|
70
|
+
description: 检测性能相关的稳定性风险(无限循环、大循环、递归深度等)
|
|
71
|
+
enabled: true
|
|
72
|
+
rules:
|
|
73
|
+
StabilityCodeReview_PerformanceStability_001:
|
|
74
|
+
enabled: true
|
|
75
|
+
id: StabilityCodeReview_PerformanceStability_001
|
|
76
|
+
name: 递归条件未考虑充分导致无限递归
|
|
77
|
+
severity: HIGH
|
|
78
|
+
description: 递归函数必须确保终止条件充分且正确,否则会导致无限递归,引发栈溢出崩溃。终止条件应覆盖所有可能的边界情况,确保递归能够正常终止
|
|
79
|
+
reference: PerformanceStability/StabilityCodeReview_PerformanceStability_001.md
|
|
80
|
+
StabilityCodeReview_PerformanceStability_002:
|
|
81
|
+
enabled: true
|
|
82
|
+
id: StabilityCodeReview_PerformanceStability_002
|
|
83
|
+
name: 间接递归风险
|
|
84
|
+
severity: HIGH
|
|
85
|
+
description: 间接递归(A调用B,B调用A)可能导致无限循环或栈溢出。与直接递归不同,间接递归更隐蔽,容易被忽视。长时间运行或深度递归会耗尽栈空间,引发程序崩溃
|
|
86
|
+
reference: PerformanceStability/StabilityCodeReview_PerformanceStability_002.md
|
|
87
|
+
资源管理:
|
|
88
|
+
name: 资源管理
|
|
89
|
+
description: 检测资源泄漏导致的稳定性风险(文件句柄、数据库连接、缓存等)
|
|
90
|
+
enabled: true
|
|
91
|
+
rules:
|
|
92
|
+
StabilityCodeReview_ResourceManagement_001:
|
|
93
|
+
enabled: true
|
|
94
|
+
id: StabilityCodeReview_ResourceManagement_001
|
|
95
|
+
name: 反序列化内存泄漏
|
|
96
|
+
severity: HIGH
|
|
97
|
+
description: 在反序列化过程中申请的内存在异常分支未及时释放,造成内存泄漏。反序列化代码中常见的模式是先申请内存,然后读取数据填充,如果读取过程中发生错误,需要正确释放已申请的内存
|
|
98
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_001.md
|
|
99
|
+
StabilityCodeReview_ResourceManagement_002:
|
|
100
|
+
enabled: true
|
|
101
|
+
id: StabilityCodeReview_ResourceManagement_002
|
|
102
|
+
name: dlopen需配对dlclose
|
|
103
|
+
severity: HIGH
|
|
104
|
+
description: 使用dlopen动态加载共享库函数后,需要使用dlclose进行关闭,否则存在资源泄露。未关闭的动态库会占用系统资源,多次加载但不关闭会导致资源累积,影响系统稳定性
|
|
105
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_002.md
|
|
106
|
+
StabilityCodeReview_ResourceManagement_003:
|
|
107
|
+
enabled: true
|
|
108
|
+
id: StabilityCodeReview_ResourceManagement_003
|
|
109
|
+
name: 禁止智能指针get初始化另一个智能指针
|
|
110
|
+
severity: CRITICAL
|
|
111
|
+
description: 禁止使用get初始化或赋值给另一个智能指针。从智能指针get()获取的裸指针再用来创建另一个智能指针,会导致两个智能指针管理同一个资源,析构时产生重复释放,造成程序崩溃
|
|
112
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_003.md
|
|
113
|
+
StabilityCodeReview_ResourceManagement_004:
|
|
114
|
+
enabled: true
|
|
115
|
+
id: StabilityCodeReview_ResourceManagement_004
|
|
116
|
+
name: 谨慎使用static_pointer_cast
|
|
117
|
+
severity: MEDIUM
|
|
118
|
+
description: 谨慎使用std::static_pointer_cast,子类转父类时几乎无需使用(shared_ptr支持隐式向上转换),父类转子类时必须要100%确定父类指针实际指向的是一个子类对象,否则会导致类型错误和未定义行为
|
|
119
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_004.md
|
|
120
|
+
StabilityCodeReview_ResourceManagement_005:
|
|
121
|
+
enabled: true
|
|
122
|
+
id: StabilityCodeReview_ResourceManagement_005
|
|
123
|
+
name: 文件描述符泄漏
|
|
124
|
+
severity: HIGH
|
|
125
|
+
description: 文件描述符fd资源需要确保申请和释放一一对应,遗漏释放会造成fd泄露,重复释放会造成double free。fd泄漏会导致系统资源耗尽,影响后续文件操作
|
|
126
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_005.md
|
|
127
|
+
StabilityCodeReview_ResourceManagement_006:
|
|
128
|
+
enabled: true
|
|
129
|
+
id: StabilityCodeReview_ResourceManagement_006
|
|
130
|
+
name: JSON对象未关闭泄漏
|
|
131
|
+
severity: MEDIUM
|
|
132
|
+
description: 使用json库相关操作完毕后应记得使用close释放内存,否则会造成内存泄漏。json对象占用的内存如果不及时释放,会导致内存资源累积
|
|
133
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_006.md
|
|
134
|
+
StabilityCodeReview_ResourceManagement_007:
|
|
135
|
+
enabled: true
|
|
136
|
+
id: StabilityCodeReview_ResourceManagement_007
|
|
137
|
+
name: 智能指针与裸指针混用
|
|
138
|
+
severity: CRITICAL
|
|
139
|
+
description: C++标准库智能指针、sptr、裸指针任意两两不能混用。混用会导致所有权混乱、重复释放、内存泄漏等问题。应统一使用同一种智能指针类型管理资源
|
|
140
|
+
reference: ResourceManagement/StabilityCodeReview_ResourceManagement_007.md
|
|
141
|
+
初始化顺序:
|
|
142
|
+
name: 初始化顺序
|
|
143
|
+
description: 检测静态初始化顺序问题和未初始化使用风险
|
|
144
|
+
enabled: true
|
|
145
|
+
rules:
|
|
146
|
+
StabilityCodeReview_InitializationOrder_001:
|
|
147
|
+
enabled: true
|
|
148
|
+
id: StabilityCodeReview_InitializationOrder_001
|
|
149
|
+
name: 类的数据成员需要显式初始化
|
|
150
|
+
severity: MEDIUM
|
|
151
|
+
description: 类的数据成员如果没有显式初始化,且该类型没有默认构造函数,可能导致未定义行为或程序崩溃。即使是POD类型(如int、指针等),不显式初始化也会导致成员值不确定,在后续使用时可能产生不可预期的结果
|
|
152
|
+
reference: InitializationOrder/StabilityCodeReview_InitializationOrder_001.md
|
|
153
|
+
边界条件:
|
|
154
|
+
name: 边界条件
|
|
155
|
+
description: 检测边界条件处理不当导致的稳定性风险(空容器、极端输入等)
|
|
156
|
+
enabled: true
|
|
157
|
+
rules:
|
|
158
|
+
StabilityCodeReview_BoundaryCondition_001:
|
|
159
|
+
enabled: true
|
|
160
|
+
id: StabilityCodeReview_BoundaryCondition_001
|
|
161
|
+
name: Parcel数据不可作为循环或递归条件
|
|
162
|
+
severity: CRITICAL
|
|
163
|
+
description: 从Parcel中读取的数据不可信,不能直接作为循环或递归的条件,必须进行上限保护处理。恶意构造的Parcel数据可能包含超大数值,导致死循环、栈溢出或拒绝服务攻击
|
|
164
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_001.md
|
|
165
|
+
StabilityCodeReview_BoundaryCondition_002:
|
|
166
|
+
enabled: true
|
|
167
|
+
id: StabilityCodeReview_BoundaryCondition_002
|
|
168
|
+
name: Parcel数据不可直接作为数组下标
|
|
169
|
+
severity: CRITICAL
|
|
170
|
+
description: 从Parcel中读取的不可信数据不可以直接作为固定大小数组的下标值访问,否则可能造成数组越界访问,导致内存破坏、程序崩溃或安全漏洞
|
|
171
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_002.md
|
|
172
|
+
StabilityCodeReview_BoundaryCondition_003:
|
|
173
|
+
enabled: true
|
|
174
|
+
id: StabilityCodeReview_BoundaryCondition_003
|
|
175
|
+
name: Parcel数据不可直接作为内存申请大小
|
|
176
|
+
severity: HIGH
|
|
177
|
+
description: 从Parcel中读取的数据不可信,不能直接作为内存申请大小的值,否则可能造成内存超大申请,导致内存耗尽、程序崩溃或拒绝服务攻击
|
|
178
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_003.md
|
|
179
|
+
StabilityCodeReview_BoundaryCondition_004:
|
|
180
|
+
enabled: true
|
|
181
|
+
id: StabilityCodeReview_BoundaryCondition_004
|
|
182
|
+
name: 容器size增长的对外接口应限制上限
|
|
183
|
+
severity: HIGH
|
|
184
|
+
description: 会导致容器size增大的对外接口,应该限制容器size的上限,防止外部恶意攻击申请过大内存。外部输入可能包含恶意构造的数据,导致容器无限增长,造成内存耗尽或拒绝服务
|
|
185
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_004.md
|
|
186
|
+
StabilityCodeReview_BoundaryCondition_005:
|
|
187
|
+
enabled: true
|
|
188
|
+
id: StabilityCodeReview_BoundaryCondition_005
|
|
189
|
+
name: Parcel整数转枚举需校验有效性
|
|
190
|
+
severity: MEDIUM
|
|
191
|
+
description: 从Parcel中读取的整数不能直接转化为枚举类,需要校验值的有效性。未经验证的枚举值转换可能导致未定义行为、程序逻辑错误或安全漏洞
|
|
192
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_005.md
|
|
193
|
+
StabilityCodeReview_BoundaryCondition_006:
|
|
194
|
+
enabled: true
|
|
195
|
+
id: StabilityCodeReview_BoundaryCondition_006
|
|
196
|
+
name: 除法和模运算需做除零保护
|
|
197
|
+
severity: CRITICAL
|
|
198
|
+
description: 除法运算和模运算需要做除零保护,除数为零会导致程序崩溃或未定义行为。从外部输入获取的除数必须在进行运算前进行非零检查
|
|
199
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_006.md
|
|
200
|
+
StabilityCodeReview_BoundaryCondition_007:
|
|
201
|
+
enabled: true
|
|
202
|
+
id: StabilityCodeReview_BoundaryCondition_007
|
|
203
|
+
name: Parcel序列化和反序列化必须匹配
|
|
204
|
+
severity: HIGH
|
|
205
|
+
description: Parcel的序列化和反序列化必须完全匹配,包括顺序、类型和数量。不匹配的序列化/反序列化会导致数据错误、内存越界读取或程序崩溃
|
|
206
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_007.md
|
|
207
|
+
StabilityCodeReview_BoundaryCondition_008:
|
|
208
|
+
enabled: true
|
|
209
|
+
id: StabilityCodeReview_BoundaryCondition_008
|
|
210
|
+
name: 容器erase后需正确更新迭代器
|
|
211
|
+
severity: HIGH
|
|
212
|
+
description: 容器erase后需要正确更新迭代器,避免使用失效的迭代器。erase操作会使当前迭代器失效,继续使用会导致未定义行为、程序崩溃或内存访问错误
|
|
213
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_008.md
|
|
214
|
+
StabilityCodeReview_BoundaryCondition_009:
|
|
215
|
+
enabled: true
|
|
216
|
+
id: StabilityCodeReview_BoundaryCondition_009
|
|
217
|
+
name: 外部数据类型转换需范围检查
|
|
218
|
+
severity: HIGH
|
|
219
|
+
description: 对外部数据进行类型转换前需要进行范围检查,避免整数溢出、整数回绕。不安全的类型转换可能导致数据截断、溢出或符号错误,造成程序逻辑错误或安全漏洞
|
|
220
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_009.md
|
|
221
|
+
StabilityCodeReview_BoundaryCondition_010:
|
|
222
|
+
enabled: true
|
|
223
|
+
id: StabilityCodeReview_BoundaryCondition_010
|
|
224
|
+
name: 容器find返回迭代器需校验有效性
|
|
225
|
+
severity: HIGH
|
|
226
|
+
description: 容器find返回的迭代器在使用前需要先校验有效性,直接使用可能为end()的迭代器会导致未定义行为、程序崩溃或内存访问错误
|
|
227
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_010.md
|
|
228
|
+
StabilityCodeReview_BoundaryCondition_011:
|
|
229
|
+
enabled: true
|
|
230
|
+
id: StabilityCodeReview_BoundaryCondition_011
|
|
231
|
+
name: 加减乘除运算应避免类型溢出
|
|
232
|
+
severity: HIGH
|
|
233
|
+
description: 加减乘除运算应避免类型溢出或回绕。整数运算溢出会导致结果错误、程序逻辑异常,甚至引发安全漏洞。应使用安全的运算方式或检查运算范围
|
|
234
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_011.md
|
|
235
|
+
StabilityCodeReview_BoundaryCondition_012:
|
|
236
|
+
enabled: true
|
|
237
|
+
id: StabilityCodeReview_BoundaryCondition_012
|
|
238
|
+
name: json库获取键值前需判断类型
|
|
239
|
+
severity: MEDIUM
|
|
240
|
+
description: 使用json库获取键值内容前应先判断类型是否匹配、键值是否存在。未判断类型直接获取可能导致类型错误、程序异常或崩溃
|
|
241
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_012.md
|
|
242
|
+
StabilityCodeReview_BoundaryCondition_013:
|
|
243
|
+
enabled: true
|
|
244
|
+
id: StabilityCodeReview_BoundaryCondition_013
|
|
245
|
+
name: json库类型转换前需校验参数类型
|
|
246
|
+
severity: MEDIUM
|
|
247
|
+
description: 使用json库获取键值后,在进行类型转换前应先校验参数类型。类型不匹配的转换会导致数据错误、程序异常或崩溃
|
|
248
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_013.md
|
|
249
|
+
StabilityCodeReview_BoundaryCondition_014:
|
|
250
|
+
enabled: true
|
|
251
|
+
id: StabilityCodeReview_BoundaryCondition_014
|
|
252
|
+
name: 类型强制转换需校验范围
|
|
253
|
+
severity: HIGH
|
|
254
|
+
description: 类型强制转换未校验,可能导致越界读。不安全的类型转换可能截断数据、改变符号或导致数值超出目标类型范围,造成程序错误或安全漏洞
|
|
255
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_014.md
|
|
256
|
+
StabilityCodeReview_BoundaryCondition_015:
|
|
257
|
+
enabled: true
|
|
258
|
+
id: StabilityCodeReview_BoundaryCondition_015
|
|
259
|
+
name: 数组下标计算需避免整数回绕
|
|
260
|
+
severity: HIGH
|
|
261
|
+
description: 数组下标的计算应避免整数回绕导致内存越界访问。整数回绕可能产生负数下标或超大下标,导致数组越界访问、内存破坏或程序崩溃
|
|
262
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_015.md
|
|
263
|
+
StabilityCodeReview_BoundaryCondition_016:
|
|
264
|
+
enabled: true
|
|
265
|
+
id: StabilityCodeReview_BoundaryCondition_016
|
|
266
|
+
name: 内存操作越界风险
|
|
267
|
+
severity: CRITICAL
|
|
268
|
+
description: 代码在执行内存拷贝、指针偏移、数组索引等内存操作时,长度、偏移或下标参数来自外部可控输入,未校验其是否在目标缓冲区的有效范围内,攻击者构造特定输入可触发越界读/写
|
|
269
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_016.md
|
|
270
|
+
StabilityCodeReview_BoundaryCondition_017:
|
|
271
|
+
enabled: true
|
|
272
|
+
id: StabilityCodeReview_BoundaryCondition_017
|
|
273
|
+
name: 返回值类型不匹配风险
|
|
274
|
+
severity: MEDIUM
|
|
275
|
+
description: 函数返回值类型与接收变量类型不匹配可能导致隐式类型转换、数值截断、符号扩展错误等问题,导致数据错误、逻辑异常
|
|
276
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_017.md
|
|
277
|
+
StabilityCodeReview_BoundaryCondition_018:
|
|
278
|
+
enabled: true
|
|
279
|
+
id: StabilityCodeReview_BoundaryCondition_018
|
|
280
|
+
name: JSON解析安全风险
|
|
281
|
+
severity: HIGH
|
|
282
|
+
description: JSON解析存在多种安全风险:解析深度过大导致栈溢出、超大JSON导致内存耗尽、未捕获解析异常、键不存在导致的空指针访问、类型不匹配导致的类型混淆
|
|
283
|
+
reference: BoundaryCondition/StabilityCodeReview_BoundaryCondition_018.md
|
|
284
|
+
生命周期:
|
|
285
|
+
name: 生命周期
|
|
286
|
+
description: 检测对象生命周期管理不当导致的稳定性风险
|
|
287
|
+
enabled: true
|
|
288
|
+
rules:
|
|
289
|
+
StabilityCodeReview_Lifecycle_001:
|
|
290
|
+
enabled: true
|
|
291
|
+
id: StabilityCodeReview_Lifecycle_001
|
|
292
|
+
name: 返回引用的函数返回局部变量
|
|
293
|
+
severity: CRITICAL
|
|
294
|
+
description: 返回值类型是引用的函数,不应该返回局部变量,否则存在UAF(Use-After-Free)产生未定义行为。当函数返回局部变量的引用时,由于局部变量在函数返回后即被销毁,调用者获取的引用将指向已释放的栈内存
|
|
295
|
+
reference: Lifecycle/StabilityCodeReview_Lifecycle_001.md
|
|
296
|
+
StabilityCodeReview_Lifecycle_002:
|
|
297
|
+
enabled: true
|
|
298
|
+
id: StabilityCodeReview_Lifecycle_002
|
|
299
|
+
name: 获取临时变量指针
|
|
300
|
+
severity: HIGH
|
|
301
|
+
description: 不建议获取临时变量的指针,容易出现未定义行为。临时变量(临时对象、右值)的生命周期通常很短,在表达式结束时即被销毁。获取临时变量的指针并在表达式结束后使用,会导致悬垂指针
|
|
302
|
+
reference: Lifecycle/StabilityCodeReview_Lifecycle_002.md
|
|
303
|
+
内存稳定性:
|
|
304
|
+
name: 内存稳定性
|
|
305
|
+
description: 检测内存相关的稳定性风险(内存泄漏、OOM、碎片化等)
|
|
306
|
+
enabled: true
|
|
307
|
+
rules:
|
|
308
|
+
StabilityCodeReview_MemoryStability_001:
|
|
309
|
+
enabled: true
|
|
310
|
+
id: StabilityCodeReview_MemoryStability_001
|
|
311
|
+
name: 内存分配失败判空检查
|
|
312
|
+
severity: CRITICAL
|
|
313
|
+
description: 内存分配函数(malloc、calloc、realloc、new)在内存不足时返回 nullptr,若未检查返回值直接解引用,将导致空指针解引用,引发进程崩溃或拒绝服务
|
|
314
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_001.md
|
|
315
|
+
StabilityCodeReview_MemoryStability_002:
|
|
316
|
+
enabled: true
|
|
317
|
+
id: StabilityCodeReview_MemoryStability_002
|
|
318
|
+
name: 指针解引用前判空
|
|
319
|
+
severity: CRITICAL
|
|
320
|
+
description: 对指针进行解引用操作(*ptr、ptr->、ptr[index])前未进行空指针检查,可能导致空指针解引用崩溃(SIGSEGV)。这是OpenHarmony系统中最常见的稳定性问题之一,会导致服务崩溃、用户数据丢失
|
|
321
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_002.md
|
|
322
|
+
StabilityCodeReview_MemoryStability_003:
|
|
323
|
+
enabled: true
|
|
324
|
+
id: StabilityCodeReview_MemoryStability_003
|
|
325
|
+
name: 异常分支内存未及时释放
|
|
326
|
+
severity: HIGH
|
|
327
|
+
description: 异常分支内存未及时释放导致内存泄漏。在异常处理分支(如return、break、continue)退出前,应确保已申请的内存被正确释放,否则会造成内存资源累积泄漏
|
|
328
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_003.md
|
|
329
|
+
StabilityCodeReview_MemoryStability_004:
|
|
330
|
+
enabled: true
|
|
331
|
+
id: StabilityCodeReview_MemoryStability_004
|
|
332
|
+
name: 多返回路径资源泄漏
|
|
333
|
+
severity: HIGH
|
|
334
|
+
description: 代码使用裸指针 new / malloc 或需显式关闭的资源(句柄、文件描述符、互斥锁)时,在函数存在多条返回路径时未在所有路径上释放,造成内存泄漏、句柄泄漏、锁未释放
|
|
335
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_004.md
|
|
336
|
+
StabilityCodeReview_MemoryStability_005:
|
|
337
|
+
enabled: true
|
|
338
|
+
id: StabilityCodeReview_MemoryStability_005
|
|
339
|
+
name: double-free问题
|
|
340
|
+
severity: CRITICAL
|
|
341
|
+
description: 同一指针在多条代码路径被多次释放,或释放后未置空导致后续再次释放,引发内存管理混乱、堆内存结构损坏
|
|
342
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_005.md
|
|
343
|
+
StabilityCodeReview_MemoryStability_006:
|
|
344
|
+
enabled: true
|
|
345
|
+
id: StabilityCodeReview_MemoryStability_006
|
|
346
|
+
name: use-after-free问题
|
|
347
|
+
severity: CRITICAL
|
|
348
|
+
description: 指针被释放后,后续代码仍对其进行解引用、成员访问或传递给其他函数,导致访问已释放的内存,可能引发崩溃或安全漏洞
|
|
349
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_006.md
|
|
350
|
+
StabilityCodeReview_MemoryStability_007:
|
|
351
|
+
enabled: true
|
|
352
|
+
id: StabilityCodeReview_MemoryStability_007
|
|
353
|
+
name: 函数返回指针未检查NULL
|
|
354
|
+
severity: CRITICAL
|
|
355
|
+
description: 函数返回指针类型时可能返回NULL表示错误或特殊情况,调用方未检查返回值直接使用会导致空指针解引用,引发程序崩溃或拒绝服务
|
|
356
|
+
reference: MemoryStability/StabilityCodeReview_MemoryStability_007.md
|
|
357
|
+
图形稳定性:
|
|
358
|
+
name: 图形稳定性
|
|
359
|
+
description: 检测图形系统相关的稳定性风险(GPU资源管理、线程访问限制、RS进程安全等)
|
|
360
|
+
enabled: true
|
|
361
|
+
rules:
|
|
362
|
+
StabilityCodeReview_GraphicsStability_001:
|
|
363
|
+
enabled: true
|
|
364
|
+
id: StabilityCodeReview_GraphicsStability_001
|
|
365
|
+
name: VulkanCleanUpHelper引用计数管理
|
|
366
|
+
severity: HIGH
|
|
367
|
+
description: MakeFromBackendTexture或BuildFromTexture创建资源时应正确使用VulkanCleanUpHelper管理引用计数,即首次传入cleanUpHelper,后续传入cleanUpHelper->ref(),这样才能正确维护底层VkImage的生命周期,避免GPU发生UAF问题
|
|
368
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_001.md
|
|
369
|
+
StabilityCodeReview_GraphicsStability_002:
|
|
370
|
+
enabled: true
|
|
371
|
+
id: StabilityCodeReview_GraphicsStability_002
|
|
372
|
+
name: VulkanCleanUpHelper与SharedContext引用计数混用
|
|
373
|
+
severity: HIGH
|
|
374
|
+
description: VulkanCleanUpHelper与SharedContext分属两套引用计数管理,不能混用。混用会导致引用计数混乱、GPU资源提前释放或泄漏,引发UAF或资源耗尽问题
|
|
375
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_002.md
|
|
376
|
+
StabilityCodeReview_GraphicsStability_003:
|
|
377
|
+
enabled: true
|
|
378
|
+
id: StabilityCodeReview_GraphicsStability_003
|
|
379
|
+
name: RS主线程禁止使用RenderNodeDrawable
|
|
380
|
+
severity: HIGH
|
|
381
|
+
description: RS主线程不能使用RenderNodeDrawable,只能产生RenderNodeDrawable。主线程使用RenderNodeDrawable会导致线程角色混乱、数据竞争等问题
|
|
382
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_003.md
|
|
383
|
+
StabilityCodeReview_GraphicsStability_004:
|
|
384
|
+
enabled: true
|
|
385
|
+
id: StabilityCodeReview_GraphicsStability_004
|
|
386
|
+
name: RSUniRenderThread禁止访问RenderNode
|
|
387
|
+
severity: HIGH
|
|
388
|
+
description: RSUniRenderThread类不能访问RenderNode。RSUniRenderThread类访问RenderNode会导致线程访问越界、数据竞争或崩溃问题
|
|
389
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_004.md
|
|
390
|
+
StabilityCodeReview_GraphicsStability_005:
|
|
391
|
+
enabled: true
|
|
392
|
+
id: StabilityCodeReview_GraphicsStability_005
|
|
393
|
+
name: RS主线程禁止GPU Context操作
|
|
394
|
+
severity: HIGH
|
|
395
|
+
description: RS主线程不能做任何与GPU Context相关的操作。主线程执行GPU操作会导致线程阻塞、渲染异常或崩溃
|
|
396
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_005.md
|
|
397
|
+
StabilityCodeReview_GraphicsStability_006:
|
|
398
|
+
enabled: true
|
|
399
|
+
id: StabilityCodeReview_GraphicsStability_006
|
|
400
|
+
name: Surface/Image跨线程跨Context操作风险
|
|
401
|
+
severity: HIGH
|
|
402
|
+
description: Surface/Image应尽量避免跨线程/跨Context操作,如果必须多线程访问,应首先考虑使用BackendTexture创建新的Surface/Image,否则必须要保证Surface/Image在同一把锁的保护范围内
|
|
403
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_006.md
|
|
404
|
+
StabilityCodeReview_GraphicsStability_007:
|
|
405
|
+
enabled: true
|
|
406
|
+
id: StabilityCodeReview_GraphicsStability_007
|
|
407
|
+
name: Surface/Image创建释放线程一致性
|
|
408
|
+
severity: HIGH
|
|
409
|
+
description: Surface/Image涉及GPU资源,创建和释放应处于同一线程。跨线程创建释放会导致GPU资源管理混乱、资源泄漏或UAF问题
|
|
410
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_007.md
|
|
411
|
+
StabilityCodeReview_GraphicsStability_008:
|
|
412
|
+
enabled: true
|
|
413
|
+
id: StabilityCodeReview_GraphicsStability_008
|
|
414
|
+
name: GetBackendTexture线程限制
|
|
415
|
+
severity: HIGH
|
|
416
|
+
description: Surface/Image只能在其创建的线程中使用GetBackendTexture。在其他线程调用GetBackendTexture会导致GPU资源访问越界、崩溃或数据损坏
|
|
417
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_008.md
|
|
418
|
+
StabilityCodeReview_GraphicsStability_009:
|
|
419
|
+
enabled: true
|
|
420
|
+
id: StabilityCodeReview_GraphicsStability_009
|
|
421
|
+
name: RSRenderNodeMap线程访问限制
|
|
422
|
+
severity: HIGH
|
|
423
|
+
description: RSRenderNodeMap只能在RS主线程访问,不允许在其它线程访问。其他线程访问RSRenderNodeMap会导致数据竞争、崩溃或渲染异常
|
|
424
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_009.md
|
|
425
|
+
StabilityCodeReview_GraphicsStability_010:
|
|
426
|
+
enabled: true
|
|
427
|
+
id: StabilityCodeReview_GraphicsStability_010
|
|
428
|
+
name: 回调函数执行进程限制
|
|
429
|
+
severity: HIGH
|
|
430
|
+
description: 应用进程传入的回调函数不能在RS进程中执行,只能在应用进程执行。在RS进程执行应用回调会导致进程隔离被破坏、权限越界或崩溃
|
|
431
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_010.md
|
|
432
|
+
StabilityCodeReview_GraphicsStability_011:
|
|
433
|
+
enabled: true
|
|
434
|
+
id: StabilityCodeReview_GraphicsStability_011
|
|
435
|
+
name: Vulkan信号量导出fd生命周期管理
|
|
436
|
+
severity: HIGH
|
|
437
|
+
description: 使用GetFenceFdFromSemaphore、vkGetSemaphoreFdKHR等接口从vulkan信号量中导出fd后,fd由调用方负责关闭。最佳实践是在判断fd合法后,立刻用sptr<SyncFence>智能指针包裹,由该智能指针接管fd生命周期,在智能指针释放时会自动关闭fd。若实在无法使用SyncFence类型,须非常谨慎处理每一处函数/作用域出口,确保手动释放fd,避免fd泄漏。
|
|
438
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_011.md
|
|
439
|
+
StabilityCodeReview_GraphicsStability_012:
|
|
440
|
+
enabled: true
|
|
441
|
+
id: StabilityCodeReview_GraphicsStability_012
|
|
442
|
+
name: SyncFence智能指针缓存管理
|
|
443
|
+
severity: HIGH
|
|
444
|
+
description: 使用GetFenceFdFromSemaphore、vkGetSemaphoreFdKHR等接口从vulkan信号量中导出的fd由智能指针sptr<SyncFence>接管生命周期后,需检验该智能指针是否被存于缓存中,若存在缓存逻辑,需确保缓存的释放逻辑完整且正确、释放时机合理,避免缓存遗漏清理导致内存泄漏与fd泄漏。
|
|
445
|
+
reference: GraphicsStability/StabilityCodeReview_GraphicsStability_012.md
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# OpenHarmony 稳定性扫描白名单配置
|
|
2
|
+
#
|
|
3
|
+
# 用途:
|
|
4
|
+
# 1. 全局路径白名单:跳过特定目录或文件
|
|
5
|
+
# 2. 规则级白名单:针对特定规则的误报排除
|
|
6
|
+
#
|
|
7
|
+
# 使用方式:
|
|
8
|
+
# 1. 修改本文件添加白名单路径/模式
|
|
9
|
+
# 2. 扫描时自动加载白名单配置
|
|
10
|
+
|
|
11
|
+
global:
|
|
12
|
+
# 全局路径白名单(包含这些路径的文件将被跳过)
|
|
13
|
+
paths:
|
|
14
|
+
- "test/"
|
|
15
|
+
- "tests/"
|
|
16
|
+
- "unittest/"
|
|
17
|
+
- "mock/"
|
|
18
|
+
- "mocks/"
|
|
19
|
+
- "example/"
|
|
20
|
+
- "examples/"
|
|
21
|
+
- "samples/"
|
|
22
|
+
- "build/"
|
|
23
|
+
- "out/"
|
|
24
|
+
- ".git/"
|
|
25
|
+
|
|
26
|
+
# 全局文件模式白名单
|
|
27
|
+
patterns:
|
|
28
|
+
- "*_test.cpp"
|
|
29
|
+
- "*_test.h"
|
|
30
|
+
- "*_unittest.cpp"
|
|
31
|
+
- "*_unittest.h"
|
|
32
|
+
- "*_fuzztest.cpp"
|
|
33
|
+
- "*_fuzztest.h"
|
|
34
|
+
- "*.pb.cc"
|
|
35
|
+
- "*.pb.h"
|
|
36
|
+
- "*.generated.*"
|
|
37
|
+
- "*.auto.*"
|
|
38
|
+
|
|
39
|
+
# 规则级白名单
|
|
40
|
+
# 格式:
|
|
41
|
+
# rules:
|
|
42
|
+
# RULE_ID:
|
|
43
|
+
# patterns:
|
|
44
|
+
# - "pattern1"
|
|
45
|
+
# - "pattern2"
|
|
46
|
+
#
|
|
47
|
+
# 示例:
|
|
48
|
+
# rules:
|
|
49
|
+
# StabilityCodeReview_ExceptionHandling_001:
|
|
50
|
+
# patterns:
|
|
51
|
+
# - "已知异常处理框架"
|
|
52
|
+
# - "第三方库catch块"
|