fix: decrypt CRM regulatory_fields + related_parties PII#320
Conversation
Lerian Library Version Check
1 outdated | 3 current | 1 skipped | 0 unknown
|
🔍 PR Validation Summary✅ PR Mergeable — no blocking failures
|
📝 WalkthroughWalkthroughWalkthroughCRM nested decryption now handles ChangesCRM nested decryption
Sequence Diagram(s)sequenceDiagram
participant decryptNestedFields
participant decryptRegulatoryFields
participant decryptRelatedParties
participant decryptFieldValue
decryptNestedFields->>decryptRegulatoryFields: decrypt regulatory_fields.participant_document
decryptRegulatoryFields->>decryptFieldValue: decrypt participant_document
decryptNestedFields->>decryptRelatedParties: decrypt related_parties[].document
decryptRelatedParties->>decryptFieldValue: decrypt each document
✨ Finishing Touches✨ Simplify code
Comment |
📊 Unit Test Coverage Report:
|
| Metric | Value |
|---|---|
| Overall Coverage | 87.4% ✅ PASS |
| Threshold | 80% |
Coverage by Package
| Package | Coverage |
|---|---|
github.com/LerianStudio/fetcher/v2/components/worker/internal/services |
90.0% |
Generated by Go PR Analysis workflow
🔒 Security Scan Results —
|
| Stage | Status | Blocking? |
|---|---|---|
| Filesystem Scan | ✅ Clean | — |
| Docker Image Scan | 🔴 Yes | |
| Docker Hub Health Score | ✅ Clean | — |
| Pre-release Version Check | ✅ Clean | — |
Trivy
Filesystem Scan
✅ No vulnerabilities or secrets found.
Docker Image Scan
| Severity | Vulnerability | Title |
|---|---|---|
| LOW | CVE-2026-56852 | Infinite loop on invalid input in golang.org/x/text |
Docker Hub Health Score Compliance
✅ Policies — 4/4 met
| Policy | Status |
|---|---|
| Default non-root user | ✅ Passed |
| No fixable critical/high CVEs | ✅ Passed |
| No high-profile vulnerabilities | ✅ Passed |
| No AGPL v3 licenses | ✅ Passed |
Pre-release Version Check
✅ No unstable version pins found.
📊 Unit Test Coverage Report:
|
| Metric | Value |
|---|---|
| Overall Coverage | 89.7% ✅ PASS |
| Threshold | 80% |
Coverage by Package
| Package | Coverage |
|---|---|
github.com/LerianStudio/fetcher/v2/components/manager/cmd/huma-spec |
33.4% |
github.com/LerianStudio/fetcher/v2/components/manager/internal/adapters/cache |
100.0% |
github.com/LerianStudio/fetcher/v2/components/manager/internal/adapters/http/in |
89.4% |
github.com/LerianStudio/fetcher/v2/components/manager/internal/services/command |
92.8% |
github.com/LerianStudio/fetcher/v2/components/manager/internal/services/query |
96.4% |
Generated by Go PR Analysis workflow
🔒 Security Scan Results —
|
| Stage | Status | Blocking? |
|---|---|---|
| Filesystem Scan | ✅ Clean | — |
| Docker Image Scan | 🔴 Yes | |
| Docker Hub Health Score | ✅ Clean | — |
| Pre-release Version Check | ✅ Clean | — |
Trivy
Filesystem Scan
✅ No vulnerabilities or secrets found.
Docker Image Scan
| Severity | Vulnerability | Title |
|---|---|---|
| LOW | CVE-2026-56852 | Infinite loop on invalid input in golang.org/x/text |
Docker Hub Health Score Compliance
✅ Policies — 4/4 met
| Policy | Status |
|---|---|
| Default non-root user | ✅ Passed |
| No fixable critical/high CVEs | ✅ Passed |
| No high-profile vulnerabilities | ✅ Passed |
| No AGPL v3 licenses | ✅ Passed |
Pre-release Version Check
✅ No unstable version pins found.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/worker/internal/services/extract_crm_data.go`:
- Around line 635-643: Rename the loop-local type-assertion boolean from ok to
isParty in the relatedParties loop in
components/worker/internal/services/extract_crm_data.go:635-643, updating its
conditional use. Apply the same rename in the assertion loop in
components/worker/internal/services/extract_crm_data_test.go:2555-2561.
- Around line 607-610: Malformed sensitive document values bypass fail-closed
validation. In extract_crm_data.go at lines 607-610, validate regulatory
participant_document values as non-empty strings before decrypting; at lines
646-649, apply the same validation to related-party documents and include the
document index in errors. Add empty and non-string regulatory cases in
extract_crm_data_test.go lines 2398-2429 and corresponding related-party cases
in lines 2669-2695.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 200a55cf-f4e4-4e6d-a090-964742a4ba5a
📒 Files selected for processing (2)
components/worker/internal/services/extract_crm_data.gocomponents/worker/internal/services/extract_crm_data_test.go
Back-merge the 3.0.x hotfix line (CRM regulatory_fields decryption, #320) and release chores (3.0.1, 3.0.2) into the 3.1.0-beta line so release-candidate promotes to main without conflicts. Resolutions: go.mod/go.sum kept from release-candidate (newer, CI-green dependency pair); pkg/engine/CHANGELOG.md unioned to preserve both stable (1.1.1/1.1.0) and beta (1.1.0-beta.x) entries. Claude-Session: https://claude.ai/code/session_01WscfYUmQmJ7KWNGE18mXNB
Description
Fixes CCS-0011: the CRM extraction path was passing
regulatory_fields.participant_documentandrelated_parties[].documentthrough as raw AES-GCM ciphertext instead of decrypting them. This addsdecryptRegulatoryFields(map-shaped) anddecryptRelatedParties(slice-shaped) to the existingdecryptNestedFieldspath, reusing the same*libCrypto.Cryptoinstance already used forbanking_details.account.Fail-closed by design: an undecryptable value returns a wrapped error (naming the field/index, never echoing the raw value) rather than silently passing ciphertext through.
Type of Change
fix: Bug fixBreaking Changes
None.
Testing
make testpasses (36 decrypt tests pass — real crypto round-trip, not mocks)Covers: happy-path decryption via the production entrypoint, all no-op/shape-drift branches (absent, nil, wrong-type, non-map elements), and fail-closed errors (invalid base64, tampered ciphertext, correct index reporting, fail-fast).
Architectural Checklist
panic()in production paths%wRelated Issues
Closes #