Skip to content

Fix EST upgrade script, and add profile.configuration.managed switch to be able to disable adding profiles under CM - #5388

Merged
edewata merged 1 commit into
dogtagpki:masterfrom
parrishjd:master
Aug 3, 2026
Merged

Fix EST upgrade script, and add profile.configuration.managed switch to be able to disable adding profiles under CM#5388
edewata merged 1 commit into
dogtagpki:masterfrom
parrishjd:master

Conversation

@parrishjd

@parrishjd parrishjd commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Add ability to turn off adding profiles to a CA with CM Managed Profiles

Check the CS.cfg for a new item profile.configuration.managed and default to false. If Profiles are under CM Management "true" skip adding files to the ca/profiles/ca for the instances but perform all other actions such as updating the registry for new entries, and new defaults for CS.cfg etc.
manageprofiles = subsystem.config.get('profile.configuration.managed', False)

01 EST Script does not check if a profile exists before attempting to update resulting in CA start failure if a profile does not exist.

Summary by CodeRabbit

  • Bug Fixes

    • Safer profile upgrades with existence checks, file backups, and selective ACL updates (avoids redundant changes when already applied).
    • Profile installation and updates now respect centrally managed configuration flags to skip unnecessary work.
  • Refactor

    • Upgrade flow reorganized so ML-DSA profile creation/updates run only when not centrally managed, while key configuration updates are applied consistently.
    • Split and restructure upgrade logic for clearer, more reliable handling of profile lists and settings.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2211773f-2f91-4565-a4e3-0c985c322462

📥 Commits

Reviewing files that changed from the base of the PR and between f903099 and e65ab5b.

📒 Files selected for processing (2)
  • base/server/upgrade/11.9.0/01-EnableEST.py
  • base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py
  • base/server/upgrade/11.9.0/01-EnableEST.py

📝 Walkthrough

Walkthrough

Two upgrade scripts now conditionally gate profile management operations on a profile.configuration.managed subsystem configuration flag. EST profile installation includes improved defensive checks for file existence and ACL idempotency. ML-DSA profile addition is refactored into dedicated methods for clarity.

Changes

Profile Management Configuration and Refactoring

Layer / File(s) Summary
EST profile conditional installation and ACL idempotency
base/server/upgrade/11.9.0/01-EnableEST.py
upgrade_subsystem() now checks profile.configuration.managed before enabling EST profiles. update_internal_profiles() adds file-existence checks and continues to the next profile if the Enterprise EST Administrators ACL group is already present; otherwise backs up and updates the profile with the new group.
ML-DSA profile conditional management and refactoring
base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py
upgrade_subsystem() conditionally performs profile updates and additions when profile.configuration.managed is false; otherwise logs a skip. New add_mldsa_profiles() method extracts ML-DSA profile creation logic including profile.list updates. New config_updates() method handles default-setting and backup-save operations invoked unconditionally.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • dogtagpki/pki#5371: Both PRs modify base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py's UpdateMLDSAProfiles.upgrade_subsystem logic around updating and adding ML-DSA profiles.

Suggested reviewers

  • fmarco76

Poem

🐰 I checked the flags before I hopped to install,
EST and ML-DSA now listen when configs call.
I backup the files and skip what's already done,
A rabbit's small refactor for upgrades neatly spun. 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: fixing the EST upgrade script (adding profile existence checks) and introducing a profile.configuration.managed switch to control profile addition behavior during CM deployments.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces conditional checks to skip profile installation and updates when profile configuration is managed (profile.configuration.managed). It also refactors 04-UpdateMLDSAProfiles.py into smaller helper methods and adds file existence checks in 01-EnableEST.py. The review feedback highlights two critical issues: first, subsystem.config.get may return string values (like "false") which are truthy in Python, so they must be parsed explicitly to booleans; second, using return instead of continue inside the profile update loop in 01-EnableEST.py will prematurely abort the update process for subsequent profiles.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread base/server/upgrade/11.9.0/01-EnableEST.py Outdated
Comment thread base/server/upgrade/11.9.0/01-EnableEST.py Outdated
Comment thread base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py (1)

96-113: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Existing profile files should still reconcile profile.list and profile.<id>.class_id.

The continue at Line 97 skips config reconciliation when the file already exists. On reruns/partial upgrades, this can leave profile metadata incomplete even though files are present.

Proposed fix
-            if os.path.exists(path):
-                continue
-            logger.info('Adding profile %s', file_name)
-
-            instance.copyfile(
-                '/usr/share/pki/ca/profiles/ca/{}'.format(file_name),
-                path,
-                exist_ok=True,
-                force=False)
+            if not os.path.exists(path):
+                logger.info('Adding profile %s', file_name)
+                instance.copyfile(
+                    '/usr/share/pki/ca/profiles/ca/{}'.format(file_name),
+                    path,
+                    exist_ok=True,
+                    force=False)
+            else:
+                logger.info('Profile file %s already exists; reconciling config only', file_name)
 
             if profile not in profile_list:
                 # Add new profiles to profile.list
                 logger.info('Adding %s to profile.list', profile)
                 profile_list.append(profile)
🤖 Prompt for 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.

In `@base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py` around lines 96 - 113,
The code currently skips reconciliation when the profile file exists due to the
"if os.path.exists(path): continue" path check; remove the early continue (or
restructure so existence only skips the copyfile call) and ensure the subsequent
logic that appends to profile_list and calls
subsystem.set_config('profile.{}.class_id'.format(profile), 'caEnrollImpl')
always runs regardless of file existence; keep the copy operation guarded by
exist_ok/force but move or duplicate the profile-list and class_id
reconciliation (references: path, instance.copyfile, profile_list, profile,
subsystem.set_config) so reruns/partial upgrades update profile.list and
profile.<id>.class_id even when files already exist.
🤖 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 `@base/server/upgrade/11.9.0/01-EnableEST.py`:
- Around line 31-32: The code reads
subsystem.config.get('profile.configuration.managed', False) into manageprofiles
and branches on it directly, which treats string values like "false" as truthy;
update both scripts (01-EnableEST.py and 04-UpdateMLDSAProfiles.py) to normalize
that config value first by replacing the direct usage with a small
normalization: if the retrieved value is a bool keep it, if it's a string
interpret common truthy values (e.g. "true","1","yes") as True and everything
else as False, then assign the normalized boolean back to manageprofiles before
any if not manageprofiles checks so downstream logic uses a real boolean.
- Around line 109-111: In update_internal_profiles(), do not return when
encountering an already-updated internal profile; instead skip that profile and
continue processing the rest — replace the early "return" (inside the loop where
it checks if 'group="Enterprise EST Administrators"' in config['authz.acl'])
with logic to log the already-updated state and continue to the next profile so
all internal profiles are checked/updated (keep the logger.info message but
remove the return/exit behavior).

---

Outside diff comments:
In `@base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py`:
- Around line 96-113: The code currently skips reconciliation when the profile
file exists due to the "if os.path.exists(path): continue" path check; remove
the early continue (or restructure so existence only skips the copyfile call)
and ensure the subsequent logic that appends to profile_list and calls
subsystem.set_config('profile.{}.class_id'.format(profile), 'caEnrollImpl')
always runs regardless of file existence; keep the copy operation guarded by
exist_ok/force but move or duplicate the profile-list and class_id
reconciliation (references: path, instance.copyfile, profile_list, profile,
subsystem.set_config) so reruns/partial upgrades update profile.list and
profile.<id>.class_id even when files already exist.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25fbf59a-8bce-4f98-b7a3-400e4f7d206d

📥 Commits

Reviewing files that changed from the base of the PR and between 49e4f1c and 0ac08b5.

📒 Files selected for processing (2)
  • base/server/upgrade/11.9.0/01-EnableEST.py
  • base/server/upgrade/11.9.0/04-UpdateMLDSAProfiles.py

Comment thread base/server/upgrade/11.9.0/01-EnableEST.py Outdated
Comment thread base/server/upgrade/11.9.0/01-EnableEST.py Outdated
@sonarqubecloud

Copy link
Copy Markdown

Check if profile exists before trying to update to prevent it from causeing CA to fail to start.

@edewata edewata left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Sorry for the delay. I'll merge this. Thanks!

@edewata
edewata merged commit 93a2d11 into dogtagpki:master Aug 3, 2026
201 of 206 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants