fix(weaver): avoid temp file authz risks in corda sdk
Summary
Fix the Corda Weaver credentials extractor so certificate PEM content is serialized in memory instead of being written to temporary filesystem paths first.
Changes
- replace file-based PEM round-tripping with in-memory PEM encoding
- remove temporary certificate directory creation and cleanup from
CredentialsExtractor - keep the extracted config output shape unchanged while removing the flagged improper resource access pattern
Verification
- Reviewed the affected code path in
weaver/sdks/cordaend-to-end - Attempted local Gradle verification, but this machine does not currently have a Java runtime installed, so GitHub CI is the authoritative validation for this PR
Fixes #2768
Maintainer note: this addresses issue #2768 by removing the file-system round trip in CredentialsExtractor and encoding PEM data directly in memory, so the flagged improper resource access path is no longer exercised.
Verification attempted locally in an isolated worktree, but this machine does not currently have a Java runtime installed, so I could not start the module's Gradle tasks here. GitHub CI is therefore the authoritative validation for this PR.
Thanks for this fix. It looks good to me, but I want to ensure that the relevant tests are passing. @sandeepnRES can you check the CI and ensure that Weaver Corda SDK changes are covered by the tests that are enabled and which have passed?
Thanks for this fix. It looks good to me, but I want to ensure that the relevant tests are passing. @sandeepnRES can you check the CI and ensure that Weaver Corda SDK changes are covered by the tests that are enabled and which have passed?
The CI does run it, but those generated certs aren't used I think. @malsomesh9 can you please confirm by running following test:
-
Run end to end data sharing test from documentation page: https://hyperledger-cacti.github.io/cacti/weaver/getting-started/test-network/setup-local/, then go on to ledger initialization and testing both data-sharing and asset-transfer. Post the logs of both runs here (just the final CLI output completing the flow).
-
Then do a
git diff weaver/samples/corda/corda-simple-application/clients/src/main/resources/config/credentialsand share the reponse here.
`Thanks. I can address the two code-level review points in CredentialsExtractor:
switch the failure check from configObj to nodeConfigObj after getNodeIdCertChain(...) guard alias handling with ks.isKeyEntry(alias) plus null/length checks on getCertificateChain(alias)