보안/시큐어코딩

[CERT C 시큐어코딩표준-02] 선언과 초기화(DCL)

오픈이지 2013. 12. 13. 10:49

제안


DCL00-C. 변하지 않는 객체는 const로 보장한다.

DCL01-C. 내부 스코프에서 변수 이름을 재사용하지 않는다.

DCL02-C. 시각적으로 구별되는 식별자를 사용한다.

DCL03-C. 상수 수식의 값을 테스트 할때 정적 assertion을 사용한다.

DCL04-C. 한번에 여러 변수를 선언하지 않는다.

DCL05-C. 비 포인터 형식의 typedefs만 사용한다.

DCL06-C. 프로그램 로직상의 고정적인 값을 나타낼 때는 의미 있는 심볼릭 상수를 사용한다.

DCL07-C. 함수 선언시 적절한 타입 정보를 포함 시킨다.

DCL08-C. 함수 정의에서는 상수 간의 관계가 적절하게 나타나도록 정의한다.

DCL09-C. errno 에러코드를 반환하는 함수의 반환 타입을 errno_t로 정의한다.

DCL10-C. 가변 인자를 가진 함수에서는 함수 작성자와 함수 사용자 간의 약속이 지켜져야 한다.

DCL11-C. 가변 인자 함수와 연관된 타입 문제를 파악하고 있어야 한다.

DCL12-C. 불투명한 타입을 사용해 추상 데이터 타입을 구현한다.

DCL13-C. 함수에 의해 바뀌지 않을 값에 대한 포인터를 함수의 매개변수로 사용할 때는 const로 정의한다.

DCL15-C. 정적 외부 링크를 필요로하지 않는 파일 범위 개체 또는 함수를 선언한다.

DCL17-C. volatile-qualified variables이 잘못 컴파일 되는것을 주의한다.

DCL18-C. Do not begin integer constants with 0 when specifying a decimal value

DCL19-C. Minimize the scope of variables and functions

DCL20-C. Explicitly specify void when a function accepts no arguments

DCL21-C. Understand the storage of compound literals

DCL22-C. Use volatile for data that cannot be cached

DCL23-C. Guarantee that mutually visible identifiers are unique


규칙


DCL30-C. 객체를 선언할 때 적절한 지속 공간을 지정한다.

DCL31-C.  식별자를 사용하기 전에 먼저 선언한다.

DCL36-C. 링크 분류에서 충돌되는 식별자를 선언하지 않는다.

DCL37-C. Do not declare or define a reserved identifier

DCL38-C. Use the correct syntax when declaring flexible array members

DCL39-C. Avoid information leak in structure padding

DCL40-C. Do not create incompatible declarations of the same function or object

DCL41-C. Do not declare variables inside a switch statement before the first case label


위험평가요약



Rule

Severity

Likelihood

Remediation Cost

Priority

Level

DCL00-C

Low

Unlikely

High

P1

L3

DCL01-C

Low

Unlikely

Medium

P2

L3

DCL02-C

Low

Unlikely

Medium

P2

L3

DCL03-C

Low

Unlikely

High

P1

L3

DCL04-C

Low

Unlikely

Low

P3

L3

DCL05-C

Low

Unlikely

Medium

P2

L3

DCL06-C

Low

Unlikely

Medium

P2

L3

DCL07-C

Low

Unlikely

Low

P3

L3

DCL08-C

Low

Unlikely

High

P1

L3

DCL09-C

Low

Unlikely

Low

P3

L3

DCL10-C

High

Probable

High

P6

L2

DCL11-C

High

Probable

High

P6

L2

DCL12-C

Low

Unlikely

High

P1

L3

DCL13-C

Low

Unlikely

Low

P3

L3

DCL15-C

Low

Unlikely

Low

P3

L3

DCL16-C

Low

Unlikely

Low

P3

L3

DCL17-C

Medium

Probable

High

P4

L3

DCL18-C

Low

Unlikely

Low

P3

L3

DCL19-C

Low

Unlikely

Medium

P2

L3

DCL20-C

Medium

Probable

Low

P12

L1

DCL21-C

Low

Unlikely

Medium

P2

L3

DCL22-C

Low

Probable

High

P2

L3

DCL23-C

Medium

Unlikely

Low

P6

L2

DCL30-C

High

Probable

High

P6

L2

DCL31-C

Low

Unlikely

Low

P3

L3

DCL36-C

Medium

Probable

Medium

P8

L2

DCL37-C

Low

Unlikely

Low

P3

L3

DCL38-C

Low

Unlikely

Low

P3

L3

DCL39-C

Low

Unlikely

High

P1

L3

DCL40-C

Low

Unlikely

Medium

P2

L3

DCL41-C

Medium

Unlikely

Medium

P4

L3