Skip to content

feat(cpp): add foundational C/C++ AST expression tree nodes#404

Open
Divyateja2709 wants to merge 11 commits into
cbomkit:mainfrom
Divyateja2709:pr5
Open

feat(cpp): add foundational C/C++ AST expression tree nodes#404
Divyateja2709 wants to merge 11 commits into
cbomkit:mainfrom
Divyateja2709:pr5

Conversation

@Divyateja2709
Copy link
Copy Markdown

Summary

This PR adds foundational AST expression tree node implementations for the new C/C++ language support in the Sonar Cryptography Plugin.

The added nodes model core C/C++ expressions that are required for OpenSSL cryptographic API detection and future detection-engine traversal.

Added Tree Nodes

  • CppLiteralTree

    • Represents string and numeric literals

    • Examples:

      • "AES-256-CBC"
      • "SHA256"
      • 2048
  • CppIdentifierTree

    • Represents identifiers such as variable names, function names, and constants

    • Examples:

      • ctx
      • EVP_aes_256_cbc
      • RSA_PKCS1_PADDING
  • CppMemberAccessTree

    • Represents member access expressions using -> and .

    • Examples:

      • ctx->cipher
      • params->key_len
      • config.algorithm

Purpose

These nodes provide the foundational expression-level AST representation required by the upcoming C/C++ detection engine implementation.

In particular:

  • CppIdentifierTree enables function and variable name matching
  • CppLiteralTree captures cryptographic constants and algorithm names
  • CppMemberAccessTree supports object-type and struct-member resolution for OpenSSL APIs

This PR contains only AST data model additions and introduces no detection logic yet.

Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
Signed-off-by: Divyateja Indrakanti <indrakantidivyateja@gmail.com>
@Divyateja2709 Divyateja2709 requested a review from a team as a code owner May 7, 2026 05:47
@san-zrl
Copy link
Copy Markdown
Contributor

san-zrl commented May 20, 2026

Hi @Divyateja2709,

Thank you for your PR and for the time and effort you put into contributing to CBOMkit—we truly appreciate your interest.

You may have noticed that we are already working on adding C/C++ support to sonar-cryptography in PR #377. This approach differs from yours, as it relies on Sonar’s native C/C++ support package rather than ANTLR, similar to how the existing Java module is implemented.

Work on PR #377 is already quite advanced, and at this stage we are leaning toward this approach because we expect it to provide stronger support for cross-file symbol tracing through the Sonar infrastructure.

That said, we will keep your PR open for now until a final decision is made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants