-
Notifications
You must be signed in to change notification settings - Fork 21
feat(flex-linux-setup): location of policy store file #2442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c3b8ee
feat(flex-linux-setup): location of policy store file
devrimyatar b97c38a
fix(flex-linux-setup): check existence of policy file as suggested by…
devrimyatar b3e68a2
fix(flex-linux-setup): validate json format of policy store file as s…
devrimyatar 03230a3
fix(flex-linux-setup): replace hostname
devrimyatar 50ccce5
fix(flex-linux-setup): typo
devrimyatar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add integrity verification for the security-critical policy store file.
The policy store file controls authorization policies for Admin UI and is downloaded from an external source without any checksum or signature verification. This poses a security risk if the source is compromised or subject to man-in-the-middle attacks.
Consider implementing one of the following:
Example implementation for checksum verification:
Alternatively, modify the URL to pin to a specific commit:
Based on learnings (audit context should include policy store URL).
🤖 Prompt for AI Agents
🧩 Analysis chain
Verify the policy store URL is accessible and consider using an immutable reference.
The policy store is downloaded from the
mainbranch, which is mutable and can lead to non-reproducible builds. For stability and security, consider using a specific git tag or commit hash in the URL path instead ofrefs/heads/main.Additionally, verify that the URL is accessible and that the filename hash
2fb50e468d9dfefa142d1fce4fa9747efbd3a0f08de5is correct (it appears to be 44 characters, which is an unusual hash length).Run the following script to verify URL accessibility:
🏁 Script executed:
Length of output: 438
🏁 Script executed:
Length of output: 8404
🏁 Script executed:
Length of output: 1464
🏁 Script executed:
Length of output: 142
🏁 Script executed:
Length of output: 6205
Address missing error handling and inconsistent branch reference for policy store.
The policy store URL is hardcoded to the mutable
mainbranch, unlike other downloads which use configurable branches (JANS_BRANCH,FLEX_BRANCH). More critically, if the download fails, line 576 will executerenderTemplateInOut()on a non-existent file without validation, causing the setup to crash.Recommendations:
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai This file https://raw.githubusercontent.com/GluuFederation/GluuFlexAdminUIPolicyStore/refs/heads/main/2fb50e468d9dfefa142d1fce4fa9747efbd3a0f08de5.json is updated occasionally and not static, therefor we don't (and can't) have a checksum hash for that file. Additionally, we should download from main branch since all commits are meged into main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devrimyatar, thank you for the clarification! I understand that the policy store needs to be fetched from
mainsince it's regularly updated, and static checksums aren't feasible for a living configuration file.I notice the code already has a good safeguard at line 576 with
if os.path.exists(self.policy_store_path):to handle cases where the file doesn't exist, which addresses the concern about rendering a non-existent file.Given the dynamic nature of this file, here are a couple of optional suggestions to consider for robustness:
These are optional enhancements for better visibility when issues occur, but the current implementation with the existence check is already reasonably safe.
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai
base.download()(see https://github.com/JanssenProject/jans/blob/main/jans-linux-setup/jans_setup/setup_app/utils/base.py#L342-L374)b3e68a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 955
@devrimyatar, thank you for the clarification and for implementing the JSON validation!
You're absolutely right on both points:
Error handling: I see that
base.download()already includes comprehensive error handling with retries and proper exception management. I wasn't aware of that implementation detail - thank you for the reference.JSON validation: Perfect! I can see from the commit that you've added exactly the validation I suggested:
json.load()JSONDecodeErrorThe implementation now has multiple layers of protection:
base.download()os.path.exists()This looks solid and handles the dynamic nature of the policy store file appropriately. The setup will gracefully continue even if the policy store is temporarily unavailable or corrupted, which is the right behavior.
✏️ Learnings added
🧠 Learnings used