feat: add Go crypto/x509 detection rules#420
Closed
Godzilaa wants to merge 1 commit into
Closed
Conversation
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
There was a problem hiding this comment.
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
GoCryptoX509with detection rules for commoncrypto/x509certificate/key parsing & marshaling APIs - Registers
GoCryptoX509rules inGoDetectionRules - Updates README note to reflect
crypto/x509coverage
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 |
Contributor
|
New Version #434. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #418
Adds detection rules for Go's
crypto/x509package to detect certificate and key-related cryptographic assets.New file:
go/src/main/java/com/ibm/plugin/rules/detection/gocrypto/GoCryptoX509.javaDetects 13 functions across certificate, CSR, public key, and private key operations.
Modified:
GoDetectionRules.java— registered GoCryptoX509, removed TODO placeholderModified:
README.md— updated coverage footnote