feat(cloud-native): use admin-ui policy store from cjar file by iromli · Pull Request #13604 · JanssenProject/jans (original) (raw)

Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docker-jans-config-api/scripts/plugins.py`:
- Around line 115-124: The code reads hostname via
self.manager.config.get("hostname") and then calls policy.replace(..., hostname)
which will TypeError if hostname is None (or silently corrupt if empty); update
the block that handles policy_file (variables: hostname, policy_file,
src_archive_path, tmp_archive_path, policy) to validate hostname before doing
the replace: ensure hostname is a non-empty string (e.g., if not hostname or not
isinstance(hostname, str) -> log an error via the manager/logger and either
raise an exception or skip/abort the archive modification), and only call
policy.replace when the hostname is valid so replace() always receives a str.
- Around line 120-127: Track whether the expected policy file (policy_file,
e.g., "trusted-issuers/GluuFlexAdminUI.json") was encountered while iterating
src_archive.infolist(); set a found_policy flag when item.filename ==
policy_file and after the loop, if not found, emit a clear warning/error log
including src_archive_path and policy_file so missing-replacement cases are
visible at runtime; update the ZipFile block that writes to tmp_archive (uses
src_archive_path, tmp_archive_path, policy_file, hostname) to perform this check
and log.
- Around line 127-130: The code uses tmp_archive.writestr(item, data) which
defaults to ZIP_STORED and can drop compression; update the write logic to
preserve each entry's original compression by reusing the source entry's
ZipInfo.compress_type (e.g., obtain the original ZipInfo for the given item from
the opened source ZipFile and either pass that ZipInfo into tmp_archive.writestr
or set its compress_type to the original value) before writing to tmp_archive,
so the final archive moved to src_archive_path retains the same compression
method as the source archive.