Skip to content

Prioritize CERT C sections for translating to Rust safety-critical coding guidelines #152

@PLeVasseur

Description

@PLeVasseur

CERT C sections, prioritized

(below is @PLeVasseur's biased take, needs refinement with group)

  1. Rule 04. Integers (INT)
  2. Rule 05. Floating Point (FLP)
  3. Rule 06. Arrays (ARR)
  4. Rule 07. Characters and Strings (STR)
  5. Rule 02. Declarations and Initialization (DCL)
  6. Rule 12. Error Handling (ERR)
  7. ...

Uncategorized list of CERT C sections to make creating prioritized list easier later

Below are a bit more speculative, but should be investigated:

Mapping from CERT C => FLS

CERT C Section FLS Chapter FLS Paragraph ID Notes
Rule 01. Preprocessor (PRE) no equivalent no equivalent Determined based on a quick read-through, subject to refinement
Rule 02. Declarations and Initialization (DCL) Ownership and Destruction todo Determined based on a quick read-through, subject to refinement
Rule 03. Expressions (EXP) Expressions
possibly
Unsafety
as well
todo Determined based on a quick read-through, subject to refinement

Does seem to focus primarily on those things which
are either not possible or must be done using unsafe in Rust
Rule 04. Integers (INT) Types and Traits 4.3.3.2. Integer Types
Rule 05. Floating Point (FLP) Types and Traits 4.3.3.1. Floating Point Types
Rule 06. Arrays (ARR) Unsafety possibly todo Determined based on a quick read-through, subject to refinement

Does seem to focus primarily on those things which
are either not possible or must be done using unsafe in Rust
Rule 07. Characters and Strings (STR) FFI possibly todo Determined based on a quick read-through, subject to refinement

Could be a fit in the FFI portion, due to the emphasis
on ensuring safe CString and CStr handling
Rule 08. Memory Management (MEM) Unsafety todo Determined based on a quick read-through, subject to refinement

Safe-subset Rust is not concerned with the level of detail gone
into here, but certainly unsafe Rust could be
Rule 09. Input Output (FIO) Unsafety
&
FFI
possibly

Note there are some safe parts of Rust which could be misused we should call out:

FIO32-C. Do not perform operations on devices that are only appropriate for files
is a perfect example of applicability to a part of the standard library which is marked as safe, though it could be misused:
/proc/self/mem and similar OS features
todo Determined based on a quick read-through, subject to refinement
Rule 10. Environment (ENV) Unsafety
&
FFI
possibly
todo Determined based on a quick read-through, subject to refinement

But in general we should probably encourage usage of safe ways
of interacting with the environment which may not have a clear
1 <=> 1 with the FLS
Rule 11. Signals (SIG) Unsafety
&
FFI
possibly
todo Determined based on a quick read-through, subject to refinement

But in general we should probably encourage usage of safe ways
of interacting with signals which may not have a clear
1 <=> 1 with the FLS
Rule 12. Error Handling (ERR) Exceptions and Errors

FFI possibly
todo Determined based on a quick read-through, subject to refinement
Rule 13. Application Programming Interfaces (API) todo todo Currently empty section of CERT C

We could still offer up some Rust coding guidelines for APIs,
but it'd not link to anything CERT C-specific
Rule 14. Concurrency (CON) Concurrency
&
Unsafety possibly
todo Determined based on a quick read-through, subject to refinement

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions