Skip to content

feat(cpp): implement CxxSecretKeyContextTranslator for KeySize and KeyAction mappings#428

Open
Divyateja2709 wants to merge 5 commits into
cbomkit:mainfrom
Divyateja2709:feat/cpp-secretkey-translator
Open

feat(cpp): implement CxxSecretKeyContextTranslator for KeySize and KeyAction mappings#428
Divyateja2709 wants to merge 5 commits into
cbomkit:mainfrom
Divyateja2709:feat/cpp-secretkey-translator

Conversation

@Divyateja2709
Copy link
Copy Markdown

@Divyateja2709 Divyateja2709 commented May 23, 2026

Hi @san-zrl @n1ckl0sk0rtge,

Following your feedback on my previous PRs, I've shifted direction completely.

My previous PRs (#398, #399, #402, #403, #404, #408, #409, #411) used an
ANTLR-based approach with custom grammars and AST types — which differs from
the maintainers' preferred direction in PR #377.

I've now worked directly on top of PR #377's branch (Sonar-native C/C++
approach) and made a small focused contribution:

  • Implemented CxxSecretKeyContextTranslator (was a TODO)
  • Maps KeySize (bytes) → KeyLength (bits)
  • Maps KeyAction → KeyGeneration / KeyDerivation / Encapsulate

This is built directly on top of PR #377's approach, not my previous ANTLR work.
Happy to add unit tests as a follow-up.

Thank you, looking forward to contributing more.

chmodshubham and others added 5 commits April 10, 2026 23:26
Adds a new `cpp` Maven module enabling SonarQube analysis of C/C++ source
code via the sonar-cxx community plugin (v2.2.2).

- engine: add CxxDetectionEngine, CxxLanguageSupport, CxxSemantic,
  CxxLanguageTranslation, and CxxScanContext for AST-based detection
- cpp module: add CxxCheckRegistrar, CxxScannerRuleDefinition,
  CxxAggregator, CxxRuleList, and CxxInventoryRule for SonarQube
  integration
- translation: add context translators for cipher, digest, key, MAC,
  KDF, signature, key agreement, PRNG, and protocol
- detection base: add CxxBaseDetectionRule and CxxDetectionRules
  aggregator
- test infra: add CxxVerifier and TestBase
- build: register cpp module in root pom.xml, add sonar-cxx dependency,
  extend plugin with C/C++ file extensions (cxx, cpp, c, h, hpp)
- ci: update workflow action versions and add C/C++ to README

Signed-off-by: Shubham Kumar <chmodshubham@gmail.com>
Adds full OpenSSL detection rules for the C/C++ module and new mapper
models for post-quantum and hybrid key exchange algorithms introduced
in OpenSSL 3.x.

OpenSSL detection rules (cpp module):
- EVP API: ciphers (EvpCipher, EvpCipherFetch), message digests, MACs,
  KDFs, key agreement, key generation, and signatures
- Legacy API: RSA, DSA, EC, DH, cipher, digest, and MAC functions
- SSL/TLS: version detection via OpenSSLLibssl and OpenSSLVersionValue
- PRNG: RAND_bytes and related functions

New mapper algorithm models:
- SLH-DSA (FIPS 205): stateless hash-based digital signature algorithm
- X25519MLKEM768, X448MLKEM1024: X25519/X448 + ML-KEM hybrid key exchange
- SecP256r1MLKEM768, SecP384r1MLKEM1024: ECDH + ML-KEM hybrid key exchange

Mapper fixes:
- SSLVersionMapper: anchor TLS version regex with ^ to prevent DTLS
  strings from matching as TLS versions
- BcMessageSignerMapper: replace legacy Dilithium/SPHINCSPlus references
  with standardized MLDSA/SLHDSA names

Signed-off-by: Shubham Kumar <chmodshubham@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shubham Kumar <chmodshubham@gmail.com>
Signed-off-by: Shubham Kumar <chmodshubham@gmail.com>
Signed-off-by: Shubham Kumar <chmodshubham@gmail.com>
@Divyateja2709 Divyateja2709 requested a review from a team as a code owner May 23, 2026 02:13
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