Skip to content

feat: add Go crypto/x509 detection rules#420

Closed
Godzilaa wants to merge 1 commit into
cbomkit:mainfrom
Godzilaa:feat/go-crypto-x509
Closed

feat: add Go crypto/x509 detection rules#420
Godzilaa wants to merge 1 commit into
cbomkit:mainfrom
Godzilaa:feat/go-crypto-x509

Conversation

@Godzilaa
Copy link
Copy Markdown

Closes #418

Adds detection rules for Go's crypto/x509 package to detect certificate and key-related cryptographic assets.

New file: go/src/main/java/com/ibm/plugin/rules/detection/gocrypto/GoCryptoX509.java
Detects 13 functions across certificate, CSR, public key, and private key operations.

Modified: GoDetectionRules.java — registered GoCryptoX509, removed TODO placeholder
Modified: README.md — updated coverage footnote

Add detection rules for all major crypto/x509 APIs including:
- Certificate parsing and creation (ParseCertificate, ParseCertificates,
  CreateCertificate)
- CSR parsing and creation (ParseCertificateRequest, CreateCertificateRequest)
- Public key parsing and marshaling (ParsePKIXPublicKey, MarshalPKIXPublicKey)
- Private key parsing and marshaling for PKCS1, PKCS8, and EC formats

Fixes cbomkit#418
Copilot AI review requested due to automatic review settings May 21, 2026 11:40
@Godzilaa Godzilaa requested a review from a team as a code owner May 21, 2026 11:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Go crypto/x509 detection rules to the Sonar Cryptography Plugin and wires them into the Go detection rule registry, updating docs to reflect coverage.

Changes:

  • Introduces GoCryptoX509 with detection rules for common crypto/x509 certificate/key parsing & marshaling APIs
  • Registers GoCryptoX509 rules in GoDetectionRules
  • Updates README note to reflect crypto/x509 coverage

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
go/src/main/java/com/ibm/plugin/rules/detection/gocrypto/GoCryptoX509.java New rule set covering crypto/x509 APIs (parse/create/marshal)
go/src/main/java/com/ibm/plugin/rules/detection/GoDetectionRules.java Adds GoCryptoX509 rules to the aggregated Go rule list
README.md Updates documentation note indicating crypto/x509 is covered

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +55
@SuppressWarnings("java:S1192")
public final class GoCryptoX509 {
Comment on lines +67 to +69
.shouldBeDetectedAs(new ValueActionFactory<>("X509"))
.withMethodParameter("[]byte")
.buildForContext(new KeyContext(Map.of("kind", "X509")))
Comment on lines +39 to +51
* <li>x509.ParseCertificate(der) - parses a single DER-encoded certificate
* <li>x509.ParseCertificates(der) - parses a sequence of DER-encoded certificates
* <li>x509.CreateCertificate(rand, tmpl, parent, pub, priv) - creates a new certificate
* <li>x509.ParseCertificateRequest(der) - parses a DER-encoded CSR
* <li>x509.CreateCertificateRequest(rand, tmpl, priv) - creates a new CSR
* <li>x509.ParsePKIXPublicKey(der) - parses a DER-encoded PKIX public key
* <li>x509.MarshalPKIXPublicKey(pub) - marshals a public key to DER-encoded PKIX format
* <li>x509.ParsePKCS1PrivateKey(der) - parses a PKCS#1-encoded private key
* <li>x509.MarshalPKCS1PrivateKey(key) - marshals a private key to PKCS#1 DER format
* <li>x509.ParsePKCS8PrivateKey(der) - parses an unencrypted PKCS#8 private key
* <li>x509.MarshalPKCS8PrivateKey(key) - marshals a private key to PKCS#8 DER format
* <li>x509.ParseECPrivateKey(der) - parses an EC private key
* <li>x509.MarshalECPrivateKey(key) - marshals an EC private key to DER format
@san-zrl
Copy link
Copy Markdown
Contributor

san-zrl commented May 26, 2026

New Version #434.

@san-zrl san-zrl closed this May 26, 2026
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.

Add Go crypto/x509 detection rules

3 participants