sdl-security-develop/技术研究/SEI.CERT.C.Coding.Standard....

2.8 KiB
Raw Blame History

SEI CERT C Coding Standard 介绍

SEI CERT C Coding Standard的最新版本于在2016年发布。提供了C语言安全编码相关的规则和建议。

其目标是通过C语言安全编码标准的规则和建议开发安全、可靠、稳固的软件系统。

遵循这些规则是用c语言开发一个安全、可靠、稳固的软件系统的必要条件。

规则编号

CERT C的规则由3位英文缩写、两位数编号、字母C组成

  • 3位英文缩写标识规则的分类和章节
  • 两位数编号范围00-99表示规则编号00-29为编程建议保留30-99为编程规则保留。
  • 最后的字母C表示这是一个C语言规则。

示例:

编号PRE30-C表示这是预编译类型的编程规则编号30预编译类的第一条规则该规则是一条C语言规则。

编号PRE00-C表示这是预编译类型的编程建议编号00预编译类的第一条建议该建议是一条C语言建议。

规则类型

CERT C 最新标准一共将规则分为17类规则类型其中Rule 01-14类为通用类型Rule 48类为杂项Rule 50、51是专用规则类型

Rule 01. Preprocessor (PRE)
预处理
Rule 02. Declarations and Initialization (DCL)
声明和初始化
Rule 03. Expressions (EXP)
表达式
Rule 04. Integers (INT)
整数
Rule 05. Floating Point (FLP)
浮点数
Rule 06. Arrays (ARR)
数组
Rule 07. Characters and Strings (STR)
字符和字符串
Rule 08. Memory Management (MEM)
内存管理
Rule 09. Input Output (FIO)
输入输出
Rule 10. Environment (ENV)
环境
Rule 11. Signals (SIG)
信号
Rule 12. Error Handling (ERR)
错误处理
Rule 13. Application Programming Interfaces (API)
应用编程接口
Rule 14. Concurrency (CON)
并发性
Rule 48. Miscellaneous (MSC)
杂项
Rule 50. POSIX (POS)
可移植操作系统接口标准
Rule 51. Microsoft Windows (WIN)
微软

编程规则

规则编号 规则内容 备注
PRE30-C Do not create a universal character name through concatenation
不要通过连接创建通用字符名称
PRE31-C Avoid side effects in arguments to unsafe macros
PRE32-C Do not use preprocessor directives in invocations of function-like macros
DCL30-C Declare objects with appropriate storage durations
DCL31-C Declare identifiers before using them
DCL36-C Do not declare an identifier with conflicting linkage classifications
DCL37-C Do not declare or define a reserved identifier
DCL38-C Use the correct syntax when declaring a flexible array member
DCL39-C Avoid information leakage when passing a structure across a trust boundary
DCL40-C Do not create incompatible declarations of the same function or object

编程建议