AoU: ETAS_RTACAR_SM_OS_197

The ETAS_RTACAR_SM_OS_197 AoU provides a list of OS API functions not allowed to be called from Idle Hook function implementations.

The relevant functions are declared as:

Os_Cbk_Idle()

Rationale for the validation

The validation process follows these steps:

  1. Generation of the base code call graph

    1. Collection of source code files to be analyzed, as specified by the compile_commands.json file.

    2. Generation of the Abstract Syntax Tree (AST) for each source file.

    3. Processing of the AST to identify function implementations and related calls.

    4. Resolution of all the calls to the linkable target implementation.

  2. Inspection of relevant functions within the source code files.

  3. Inspection of the call graph contained within the relevant function to verify that do not call process OS API functions.

    1. Identify all function calls within the relevant function.

    2. Check each function call against the list of prohibited calls.

If the analysis process encounters a call to a function for which the implementation is not available, it is considered a potential violation of the AoU.

Known Limitations

During the generation of the call graph and the collection of source code files to be analyzed, files with the following extensions are ignored:

  • .cpp

  • .hpp

  • .s

  • .S

  • .asm

  • .inc

The generation of the call graph is based on static analysis of the source code. This means that the tool analyzes the code without executing it, which can lead to certain limitations:

  • It may not capture all dynamic behaviors, such as those resulting from runtime conditions or external inputs.

  • It cannot account for all possible execution paths, especially in the presence of complex control flows.

  • The accuracy of the call graph is dependent on the completeness and correctness of the source code being analyzed.

Important

Link Os as external library functions

This behavior is important for maintaining the integrity of the analysis process. The tool expects that the functions implementing the OS are linked as external library functions, and therefore does not expect the source code for these functions to be available within the analyzed base code.

Note

Os function names prefix

Function names generated by adding the “Os_” prefix to the names in the given list of allowed or disallowed OS API functions are also considered part of the original list.

The tool’s ability to detect function calls is limited by the information available from the source code, and it’s possible that the tool encounters limitations:

Important

Handling of External Functions

The tool may be unable to resolve function calls if their implementations are not available in the analyzed source code, such as functions provided by the OS, RTE, or external libraries.

Important

Analysis Limitations

The tool’s static analysis may not detect all function calls, particularly in cases involving complex code structures or the use of function pointers.

When the tool detects a limitation in its analysis, it shall report the issue to the user for manual review, indicating the specific code section that requires attention. Please refer to the OS reviews section for more information on how to handle such cases.

.. @startuml

start
:acquire the
CmdLine arguments;
    note left
        The command specifies the sources to be analyzed
    end note

if (command acquisition was successful) then (yes)
    :use the Compile Command Service service to
    list all the files to be analyzed;

    note left
        The service is responsible for identifying
        and loading the source code files to be analyzed
        from the compilation database.
    end note

    if (source collected successfully) then (yes)
        repeat :sourceFile
            if (compilation error using clang?) then (yes)
                #white/SandyBrown:mark the sourceFile as error
                report it on the list of the files that need user review;
            else (no)
                :collect functions defined into source file
                parsing the AST;
            endif
        repeat while (more sources?) is (yes)

        note
            Generate the list of all the available functions
            by parsing the AST.
        end note

        repeat :relevantContext
            note
                A relevant context could be a function definition, a macro, etc.
                in which the check is focusing to validate the related AoU.
            end note

            :evaluate the relevant context;
            note right
                the context evaluation process analyzes the relevant
                pieces of code and detects not admitted statements
                (e.g. call to prohibited functions)
            end note

            switch (result?)
            case ( restricted call found )
                #white/red:add the instance to the list of the
                violations;
            case ( not supported pattern found )
                #white/SandyBrown:add the instance to the list of the
                ones that need user review;
            case ( validated )
                #white/PaleGreen:add the instance to the list of the
                 validated ones;
            endSwitch
        repeat while (more contexts?) is (yes)

    else (no)
        #white/SandyBrown:generate a open result for the rule;
    endif
else (no)
    #white/SandyBrown:generate a open result for the rule;
endif
end

.. @enduml

Rule Id

ETAS_RTACAR_SM_OS_197

Title

Os_Cbk_Idle implementation must not call prohibited functions.

Description

This rule verifies that no prohibited functions are called within the implementation of the ‘Os_Cbk_Idle’ function.

Message Description

Id

id_000

Message

The rule cannot be evaluated due to an internal exception during the analysis execution. Please refer to the log file for more detailed information.

Kind

Open

Level

None

Description

An internal exception occurred during the execution. This can happen if there are insufficient resources available on the host machine. For more details, please consult the RTA-SQF log file.

How To Fix

Restart the command to exclude any internal exceptions. Alternatively, please contact ETAS GmbH support for assistance. When reporting the error, include a sample configuration and command line that reproduces the issue.

Id

id_001

Message

No ‘Os_Cbk_Idle’ implementation is found in the analyzed file artifacts.

Kind

Pass

Level

None

Description

No ‘Os_Cbk_Idle’ implementation is detected in the analyzed files. The check is limited to the scenario(s) documented in the RTA-SQF User Manual. Please refer to the manual for more information.

How To Fix

Everything is in order. No action is required.

Id

id_002

Message

No prohibited function calls has been found in the analyzed artifacts.

Kind

Pass

Level

None

Description

No prohibited function calls have been detected in the analyzed artifacts. The check is limited to the scenario(s) documented in the RTA-SQF User Manual. Please refer to the manual for more information.

How To Fix

Everything is in order. No action is required.

Id

id_003

Message

The analysis of the ‘Os_Cbk_Idle’ implementation revealed that the ‘{0}’ prohibited function is called.

Kind

Fail

Level

Error

Description

The analysis of the ‘Os_Cbk_Idle’ implementation indicates that a prohibited function is being called. The check is limited to the scenario(s) documented in the RTA-SQF User Manual. Please refer to the manual for more information.

How To Fix

Please review the ‘Os_Cbk_Idle’ implementation and remove any prohibited function calls, if present.

Id

id_004

Message

The analysis of the ‘Os_Cbk_Idle’ implementation was not fully completed due to the presence of an unexpected code pattern.

Kind

Review

Level

None

Description

During the analysis of the ‘Os_Cbk_Idle’ implementation (and the call flow), an unexpected code pattern was encountered. The analysis of the implementation was not fully completed and requires manual review. The check is limited to the scenario(s) documented in the RTA-SQF User Manual. Please refer to the manual for more information.

How To Fix

Please review the ‘Os_Cbk_Idle’ implementation to ensure it is free of any prohibited function calls.