Repository navigation
Add experimental crypto behavior taxonomy with contextual auth evidence - #494
n1ckl0sk0rtge wants to merge 67 commits into
Conversation
There was a problem hiding this comment.
Hi @n1ckl0sk0rtge,
The build fails due to a failing test RuleMemoizationEnforcementTest.everyStaticRulesMethodIsMemoized. The CI log is blurred with lots of log messages like
11:09:13.386 [main] INFO com.ibm.engine.language.java.JavaDetectionEngine -- Detected constructor definition has more then one argument to resolve. Redefine the rule to explicitly define the param to resolve
so it's hard to find. Is this still work in progress or is it ready merging?
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] RuleMemoizationEnforcementTest.everyStaticRulesMethodIsMemoized:119 [detection-rule classes whose static rules() is not memoized — wrap the body with Memoize.of(...) so shared subtrees are built once (see #476)]
Expecting empty but was: ["com.ibm.plugin.rules.detection.auth.PrincipalAuthRules",
"com.ibm.plugin.rules.detection.auth.JwtAuthRules",
"com.ibm.plugin.rules.detection.auth.MtlsAuthRules",
"com.ibm.plugin.rules.detection.auth.AuthDetectionRules",
"com.ibm.plugin.rules.detection.auth.SamlAuthRules",
"com.ibm.plugin.rules.detection.auth.ApiKeyAuthRules",
"com.ibm.plugin.rules.detection.auth.OAuthAuthRules"]
[INFO]
[ERROR] Tests run: 165, Failures: 1, Errors: 0, Skipped: 7
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for sonar-cryptography 2.0.0-SNAPSHOT:
[INFO]
[INFO] sonar-cryptography ................................. SUCCESS [ 0.646 s]
[INFO] common ............................................. SUCCESS [ 1.696 s]
[INFO] engine ............................................. SUCCESS [ 5.281 s]
[INFO] mapper ............................................. SUCCESS [ 6.105 s]
[INFO] output ............................................. SUCCESS [ 1.609 s]
[INFO] enricher ........................................... SUCCESS [ 0.999 s]
[INFO] rules .............................................. SUCCESS [ 0.545 s]
[INFO] java ............................................... FAILURE [ 10.387 s]
[INFO] python ............................................. SKIPPED
[INFO] go ................................................. SKIPPED
[INFO] sonar-cryptography-plugin .......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.490 s
[INFO] Finished at: 2026-07-20T11:09:14+02:00
[INFO] ------------------------------------------------------------------------
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…olish FIX 1: Move behaviour accumulation from add() forEach into createAlgorithmComponent() so TLS/cipher-suite constituent algorithms (reached via direct calls) now contribute their behaviours to metadata.component; add regression test (RED→GREEN). FIX 2: Relocate CryptoBehaviorTaxonomyTest to correctly-spelled cyclonedx package (git mv); add CryptoBehavior import now required from different package. FIX 3: Extend CryptoBehaviorMapperTest with 11 new cases covering Decrypt/Verify/ Digest/Tag/KeyGeneration operations, GenericKDF, AE/PKE/KEM/PRNG fallbacks, and non-Algorithm empty-return. FIX 4: Reference CryptoBehaviorMapper.BEHAVIOR_PROPERTY_NAME constant instead of inline string literal in CryptoBehaviorMetadataTest. FIX 5: Document METADATA_COMPONENT_NAME intentional simplification (spec §4.4). Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…neratesRandomValue) Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…sRandomValue) Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…unwrap-test comments - Add CryptoBehaviorMapperTest.decapsulateOnKeyWrapCipherYieldsWrapsKey() to verify Decapsulate functionality yields wrapsKey behavior on KeyWrap ciphers - Add clarifying comment on SECURE_RANDOM_NO_ARG probe key indirection (maps to generic PRNG) - Add comment on JcaCipherUnwrapTest scope noting end-to-end behavior validated elsewhere Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…ce signals Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…e enum Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…ehaviors Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…ixed output Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…ontext signals Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…eStore Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…CBOM output Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
The SecureRandom key-generation scaffolding removed from detection tests in this branch is restored, now that new SecureRandom()/getInstance is itself detected as a PRNG asset. Each restored construct is annotated with the expected PRNG finding, and every affected asserts() gains a PRNGContext guard so the extra finding is accounted for without disturbing the existing cipher assertions. findingId-keyed tests are renumbered for the interleaved PRNG findings. All 25 affected tests pass; full java suite green (162 tests, 7 skipped). Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…edes sidecar store) Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…d rule variants Extend AuthInterfaceTestFile with a bare Jwts.parser().build() (must not be detected) plus the previously unexercised variants: parseClaimsJws, JWSObject.verify, ReactiveJwtDecoder.decode, SSLSession.getPeerCertificates, and pac4j ParameterClient. Strengthen AuthInterfaceDetectionTest from kind-was-seen to exact per-kind finding counts so the parser-construction negative is actually asserted. Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…rypto Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
…ceEngine Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
40091e9 to
d8df295
Compare
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
|
A depending detection rule would only run when a parent crypto rule follows that argument. No other production rule currently references This intentionally expands detection: recognized SecureRandom construction/factory calls produce a PRNG component and contribute |
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
Signed-off-by: Nicklas Körtge <Nicklas.Koertge1@ibm.com>
This PR adds experimental security behavior annotations to CBOMs. It uses
security:cryptography:*values from the draft CycloneDX behavior taxonomy, such asencryptsData,wrapsKeyandvalidatesToken.The idea is to describe application behavior alongside the crypto inventory using a shared vocabulary. The annotations come from crypto operations and authentication APIs detected in source code.
Behavior instances are stored as JSON in the
cbomkit:behaviorsmetadata property, keeping the CBOM valid for CycloneDX 1.6. Each instance has a stable ID and references the application as its actor. Native blueprints and behavior graphs remain outside this PR.It also adds SecureRandom and key-unwrapping detection. Creating a SecureRandom is enough to add a random-generation behavior.
Design spec
Validation: 409 tests, seven skipped; Spotless and Checkstyle pass.