-
Notifications
You must be signed in to change notification settings - Fork 1
[EnforceAuth] Add policy: EA Financial Global SSO #18
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||
| # METADATA | ||||||||||||||
| # title: EA Financial Global SSO | ||||||||||||||
| # description: Global unified access policy for all systems across the global entities of EA Financial | ||||||||||||||
| package ea_financial_global_sso | ||||||||||||||
|
|
||||||||||||||
| import rego.v1 | ||||||||||||||
|
|
||||||||||||||
| default allow = false | ||||||||||||||
|
|
||||||||||||||
| # Allow Rule | ||||||||||||||
| allow if { | ||||||||||||||
| input.subject.id contains "EAID" | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix critical syntax error with The pipeline failure confirms that the contains(input.subject.id, "EAID")🐛 Proposed fix for the syntax error- input.subject.id contains "EAID"
+ contains(input.subject.id, "EAID")🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies/ failed: rego_parse_error: unexpected contains keyword: expected \n or ; or }. Parse error at: input.subject.id contains "EAID". 🤖 Prompt for AI AgentsSubstring matching creates a critical security vulnerability. Using
For production financial authorization, use exact prefix matching or exact ID validation instead. 🛡️ Proposed fix using prefix matching- input.subject.id contains "EAID"
+ startswith(input.subject.id, "EAID-")Or for exact validation: - input.subject.id contains "EAID"
+ regex.match(`^EAID-[0-9]+$`, input.subject.id)📝 Committable suggestion
Suggested change
Suggested change
🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies/ failed: rego_parse_error: unexpected contains keyword: expected \n or ; or }. Parse error at: input.subject.id contains "EAID". 🤖 Prompt for AI Agents🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Examine how OPA input is constructed and what field names are used
# Check opaService.ts for input construction patterns
echo "=== Input construction in opaService.ts ==="
rg -n -A 10 -B 2 'n\.user\s*=' projects/consumer-accounts-internal-api/src/services/opaService.ts
# Check all Rego policies for input field usage patterns
echo -e "\n=== Input field patterns used in existing policies ==="
rg -n 'input\.(user|subject)\.' infra/opa/policies/ --type rego -C 2Repository: EnforceAuth/ea-financial Length of output: 213 🏁 Script executed: # Find opaService.ts
find . -type f -name "opaService.ts" | head -20Repository: EnforceAuth/ea-financial Length of output: 136 🏁 Script executed: # Find the Rego policy files mentioned
find . -type f -name "*sso.rego" -o -name "ea_financial_global_sso.rego" | head -20Repository: EnforceAuth/ea-financial Length of output: 178 🏁 Script executed: # List all Rego files to understand structure
find . -type f -name "*.rego" | head -30Repository: EnforceAuth/ea-financial Length of output: 1786 🏁 Script executed: cat -n projects/consumer-accounts-internal-api/src/services/opaService.ts | head -100Repository: EnforceAuth/ea-financial Length of output: 3492 🏁 Script executed: cat -n infra/opa/policies/ea_financial_global_sso.regoRepository: EnforceAuth/ea-financial Length of output: 448 🏁 Script executed: cat -n infra/opa/policies/ea_financial/identity_provider/sso.regoRepository: EnforceAuth/ea-financial Length of output: 2323 🏁 Script executed: grep -n "\.sub" projects/consumer-accounts-internal-api/src/services/opaService.tsRepository: EnforceAuth/ea-financial Length of output: 50 🏁 Script executed: # Check if sub is added to the user object elsewhere
grep -rn "user.*sub" projects/consumer-accounts-internal-api/src/services/ --include="*.ts"Repository: EnforceAuth/ea-financial Length of output: 50 🏁 Script executed: # Check all Rego files for what fields they actually use from input.user
grep -n "input\.user\." infra/opa/policies/ -r --include="*.rego" | head -30Repository: EnforceAuth/ea-financial Length of output: 1042 🏁 Script executed: # Check if groups or sub fields are added to user object in opaService.ts
cat -n projects/consumer-accounts-internal-api/src/services/opaService.ts | tail -50Repository: EnforceAuth/ea-financial Length of output: 1690 🏁 Script executed: # Search for any transformation or mapping of user data in the service
grep -n "user\|sub\|groups" projects/consumer-accounts-internal-api/src/services/opaService.ts | head -40Repository: EnforceAuth/ea-financial Length of output: 2029 🏁 Script executed: # Check if there's a test or example showing actual input structure
find . -name "*opa*test*" -o -name "*opa*spec*" | head -20Repository: EnforceAuth/ea-financial Length of output: 50 Incorrect input field path—policy will always deny. The policy references The correct field path is 🔧 Suggested fix- input.subject.id contains "EAID"
+ input.user.id contains "EAID"📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies/ failed: rego_parse_error: unexpected contains keyword: expected \n or ; or }. Parse error at: input.subject.id contains "EAID". 🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Verify that main.rego doesn't import the new policy
echo "=== Checking imports in main.rego ==="
rg -n 'import.*ea_financial_global_sso' infra/opa/policies/main.rego
echo -e "\n=== Current import structure in main.rego ==="
rg -n '^import data\.' infra/opa/policies/main.rego
echo -e "\n=== Checking allow rules that delegate to sub-policies ==="
rg -n -A 3 '^allow' infra/opa/policies/main.regoRepository: EnforceAuth/ea-financial Length of output: 8175 🏁 Script executed: #!/bin/bash
# Check the package declaration in the policy file
echo "=== Package declaration in ea_financial_global_sso.rego ==="
head -5 infra/opa/policies/ea_financial_global_sso.rego
# Check OPA config entry point
echo -e "\n=== OPA Config entry point ==="
cat infra/opa/opa-config-ea.yaml | grep -A 2 -B 2 "entrypoint\|decision"
# Check if ea_financial_global_sso is referenced anywhere in the codebase
echo -e "\n=== References to ea_financial_global_sso ==="
rg 'ea_financial_global_sso' infra/opa/policies/Repository: EnforceAuth/ea-financial Length of output: 544 🏁 Script executed: #!/bin/bash
# Search for OPA config files
echo "=== OPA config files in the repo ==="
find infra/opa -name "*.yaml" -o -name "*.yml" -o -name "*config*" | head -20
# Also check if there are any Kubernetes manifests or other config references
echo -e "\n=== Files in infra/opa directory ==="
ls -la infra/opa/
# Check for any references to main.allow in the codebase
echo -e "\n=== References to main.allow ==="
rg 'main\.allow' infra/Repository: EnforceAuth/ea-financial Length of output: 997 🏁 Script executed: #!/bin/bash
# Read the actual OPA config file
echo "=== OPA Config Entry Point ==="
cat infra/opa/config/opa-config-ea.yaml | grep -A 5 -B 5 "query"
# Double-check main.rego to see if there's any way ea_financial_global_sso is indirectly referenced
echo -e "\n=== Check for any data flow to ea_financial_global_sso ==="
rg 'global.*sso|global_sso' infra/opa/policies/
# List all allow rules in main.rego to confirm pattern
echo -e "\n=== Count of allow rules in main.rego ==="
rg -c '^allow if {' infra/opa/policies/main.regoRepository: EnforceAuth/ea-financial Length of output: 733 🏁 Script executed: #!/bin/bash
# Count allow rules more carefully
echo "=== Allow rules in main.rego (checking pattern) ==="
rg 'allow if' infra/opa/policies/main.rego | wc -l
# Verify the import pattern suggested in review would be correct
echo -e "\n=== Verify import pattern consistency ==="
rg 'import data\.' infra/opa/policies/main.rego | grep 'as.*sso'Repository: EnforceAuth/ea-financial Length of output: 220 Policy is unreachable—missing integration with main.rego. This policy won't be evaluated by OPA because:
To integrate this policy, add the following import to import data.ea_financial_global_sso as global_ssoThen add an allow if {
global_sso.allow
}🧰 Tools🪛 GitHub Actions: Path-based Testing[error] 12-12: opa fmt --diff policies/ failed: rego_parse_error: unexpected contains keyword: expected \n or ; or }. Parse error at: input.subject.id contains "EAID". 🤖 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.
🛑 Security Vulnerability: Replace substring check with prefix validation. The
containsoperator allows any ID with "EAID" anywhere in the string (e.g., "malicious-EAID-user", "FAKEEAID123"), enabling unauthorized access.1Footnotes
CWE-625: Permissive Regular Expression - https://cwe.mitre.org/data/definitions/625.html ↩