Skip to content

fix: prevent stale configPath and CA ID exposure in root certificate API#6201

Merged
vitormattos merged 4 commits intomainfrom
fix/filter-ca-id-and-config-path-in-api
Dec 15, 2025
Merged

fix: prevent stale configPath and CA ID exposure in root certificate API#6201
vitormattos merged 4 commits intomainfrom
fix/filter-ca-id-and-config-path-in-api

Conversation

@vitormattos
Copy link
Copy Markdown
Member

Filter configPath from API response when certificate is not generated to prevent form pre-population with outdated generation numbers that cause validation errors.

Filter CA ID (libresign-ca-id:*) from OrganizationalUnit field to prevent users from submitting stale generation values that conflict with certificate validation.

Refactor toArray() method by extracting logic into dedicated methods:

  • getConfigPathForApi(): Returns empty string for non-generated certificates
  • removeCaIdFromOrganizationalUnit(): Filters CA IDs from OU arrays

Filter configPath from API response when certificate is not generated to prevent
form pre-population with outdated generation numbers that cause validation errors.

Filter CA ID (libresign-ca-id:*) from OrganizationalUnit field to prevent users
from submitting stale generation values that conflict with certificate validation.

Refactor toArray() method by extracting logic into dedicated methods:
- getConfigPathForApi(): Returns empty string for non-generated certificates
- removeCaIdFromOrganizationalUnit(): Filters CA IDs from OU arrays

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos added this to the Next Major (33) milestone Dec 15, 2025
@vitormattos vitormattos self-assigned this Dec 15, 2025
@github-project-automation github-project-automation Bot moved this to 0. Needs triage in Roadmap Dec 15, 2025
@vitormattos
Copy link
Copy Markdown
Member Author

/backport to stable32

@vitormattos
Copy link
Copy Markdown
Member Author

/backport to stable31

Prevent test state pollution by ensuring config_path is deleted
in setUp(). This fixes failures in OpenSslHandlerTest where the
temporary config path from AEngineHandlerTest was persisting
through the shared appConfig mock, causing tests that expect
properly formatted PKI directory names to fail.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The CA ID (libresign-ca-id:...) in OrganizationalUnit should only be
filtered out when the certificate is not generated (isSetupOk() returns
false). When the certificate is successfully generated, the CA ID must
be preserved in the API response.

This ensures:
- Generated certificates: CA ID is visible (expected behavior)
- Failed/not generated: CA ID is filtered to prevent stale data in form

Integration tests validated:
- features/account/signature.feature:2 (OpenSSL)
- features/account/signature.feature:23 (CFSSL)
- features/admin/certificate_openssl.feature:2
- features/admin/certificate_openssl.feature:35

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos force-pushed the fix/filter-ca-id-and-config-path-in-api branch 4 times, most recently from 679a33b to 139f8a6 Compare December 15, 2025 21:56
- Add reset() method to AppConfigOverwrite that clears overWrite and deleted arrays and returns self
- Integrate reset() directly into getMockAppConfig() to ensure clean state on every call
- All tests now automatically get clean AppConfig state without explicit reset calls
- Prevents state pollution across test suites by resetting at the source
- Simplifies test code by removing need for separate reset wrapper method

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos force-pushed the fix/filter-ca-id-and-config-path-in-api branch from 139f8a6 to 54f73ed Compare December 15, 2025 22:11
@vitormattos vitormattos merged commit 2f1e10b into main Dec 15, 2025
65 checks passed
@vitormattos vitormattos deleted the fix/filter-ca-id-and-config-path-in-api branch December 15, 2025 22:20
@github-project-automation github-project-automation Bot moved this from 0. Needs triage to 4. to release in Roadmap Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant