fix(alibabacloud): implement ram_password_policy_number and fix cs weekly check loading#11683
Conversation
…ekly check loading
|
✅ All necessary |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new Alibaba Cloud RAM check evaluates whether the password policy requires numbers, returns PASS or FAIL accordingly, adds unit tests for both outcomes, and records the change in the changelog. ChangesRAM Password Policy Number Check
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/providers/alibabacloud/services/ram/ram_password_policy_number/ram_password_policy_number_test.py (1)
8-68: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAdd the required
test_no_resourcescase (len == 0).This suite has PASS/FAIL tests but is missing the mandatory no-resources test for this check.
Proposed fix
class TestRamPasswordPolicyNumber: + def test_no_resources(self): + ram_client = mock.MagicMock() + ram_client.audited_account = "1234567890" + ram_client.region = "cn-hangzhou" + ram_client.password_policy = None + + with ( + mock.patch( + "prowler.providers.common.provider.Provider.get_global_provider", + return_value=set_mocked_alibabacloud_provider(), + ), + mock.patch( + "prowler.providers.alibabacloud.services.ram.ram_password_policy_number.ram_password_policy_number.ram_client", + new=ram_client, + ), + ): + from prowler.providers.alibabacloud.services.ram.ram_password_policy_number.ram_password_policy_number import ( + ram_password_policy_number, + ) + + result = ram_password_policy_number().execute() + assert len(result) == 0 + def test_numbers_not_required_fails(self):As per path instructions, "Every check needs test_no_resources (len==0), pass (PASS) and fail (FAIL)."
🤖 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 `@tests/providers/alibabacloud/services/ram/ram_password_policy_number/ram_password_policy_number_test.py` around lines 8 - 68, Add the missing no-resources coverage for ram_password_policy_number by introducing a test_no_resources case that asserts execute() returns an empty result list. Update the existing TestRamPasswordPolicyNumber suite to include this third scenario alongside test_numbers_not_required_fails and test_numbers_required_passes, using the same ram_password_policy_number check and mocked provider/client setup.Source: Path instructions
🤖 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
`@prowler/providers/alibabacloud/services/ram/ram_password_policy_number/ram_password_policy_number.py`:
- Line 8: Add a Google-style docstring to the public `execute()` method in
`ram_password_policy_number.py` so it documents what the method does, its return
value, and any relevant behavior; place it directly above `execute()` and keep
the style consistent with the existing Prowler class/method documentation
guidelines.
---
Outside diff comments:
In
`@tests/providers/alibabacloud/services/ram/ram_password_policy_number/ram_password_policy_number_test.py`:
- Around line 8-68: Add the missing no-resources coverage for
ram_password_policy_number by introducing a test_no_resources case that asserts
execute() returns an empty result list. Update the existing
TestRamPasswordPolicyNumber suite to include this third scenario alongside
test_numbers_not_required_fails and test_numbers_required_passes, using the same
ram_password_policy_number check and mocked provider/client setup.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a5bb292b-0e15-4015-8350-f8333e84fed1
📒 Files selected for processing (4)
prowler/providers/alibabacloud/services/cs/cs_kubernetes_cluster_check_weekly/__init__.pyprowler/providers/alibabacloud/services/ram/ram_password_policy_number/ram_password_policy_number.pytests/providers/alibabacloud/services/ram/ram_password_policy_number/__init__.pytests/providers/alibabacloud/services/ram/ram_password_policy_number/ram_password_policy_number_test.py
🔒 Container Security ScanImage: ✅ No Vulnerabilities DetectedThe container image passed all security checks. No known CVEs were found.📋 Resources:
|
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Context
Two Alibaba Cloud checks shipped in the repository with their metadata but never actually loaded or ran:
As a result, prowler alibabacloud --list-checks reported 61 loadable checks while 63 metadata files existed on disk — the two dead checks accounted for the gap.
Description
After these changes, all metadata-defined Alibaba Cloud checks load: --list-checks now reports 63 (was 61), matching the number of metadata files.
Steps to review
Please add a detailed description of how to review this PR.
Checklist
Community Checklist
SDK/CLI
UI
API
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Summary by CodeRabbit