feat:[NEXT-625] Added Tagging Policy for AWS AMI#2375
Conversation
WalkthroughIntroduces a new AWS AMI tagging policy with associated cf_PolicyTable and cf_PolicyParams entries, updates descriptions and resolution URLs for an existing GCP VM disk cleanup policy, adjusts an EBS snapshot policy UUID, and standardizes multiple policy parameter rows by setting encrypt=false, all within DB_Policy.sql. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Scheduler
participant PolicyEngine as Policy Engine
participant Cloud as AWS APIs
participant DB as Policy Tables
rect rgba(230,245,255,0.6)
note right of DB: New policy: taggingRule_version-1_aws_ami
Scheduler->>PolicyEngine: Trigger (cron 0 0/12 * * ? *)
PolicyEngine->>DB: Load policy config + params
DB-->>PolicyEngine: Metadata (mandatoryTags, policyKey, splitterChar)
PolicyEngine->>Cloud: List AMIs (targetType: aws_ami)
Cloud-->>PolicyEngine: AMI inventory with tags
alt Missing mandatory tags
PolicyEngine->>PolicyEngine: Flag non-compliant AMIs
PolicyEngine-->>Scheduler: Findings (severity/category)
else All tags present
PolicyEngine-->>Scheduler: No findings
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
✨ Finishing Touches🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
installer/resources/pacbot_app/files/DB_Policy.sql(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Analyze (java)
- GitHub Check: SonarCloud-Build
🔇 Additional comments (4)
installer/resources/pacbot_app/files/DB_Policy.sql (4)
612-612: Confirm the updated GCP resolution URL anchor is stable/correctThe anchor looks opaque (#articleTOC_104). Consider switching to a semantic anchor (e.g., #delete-unused-vm-disk) if available, to avoid future link rot.
Would you like me to scan the repo/wiki references and propose the exact canonical anchor?
2434-2436: Params for new AMI tagging policy look correct; keep them in sync with JSON payloadDefinitions for mandatoryTags, policyKey, and splitterChar match the policyParams JSON.
After fixing the alexaKeyword/threadsafety in the JSON (Line 610), confirm if any corresponding cf_PolicyParams rows are needed for UI controls (e.g., severity). If yes, add them to avoid drift.
614-614: No action needed: policyUUID update aligns with intended EBS snapshot policy
The update at line 614 replaces the incorrect default UUID withdeny_public_access_to_ebs_snapshot, matching the policy’s name, description, and resolution URL.
2439-2441: No encrypted parameters found for these policyIDs—bulk clear is safe. Ran a scan of allINSERT IGNORE INTO \cf_PolicyParams`statements for the listed policyIDs and found noencrypt='true'orencrypt=1` entries.
| INSERT IGNORE INTO cf_PolicyTable (policyId, policyUUID, policyName, policyDisplayName, policyDesc, resolution, resolutionUrl, targetType, assetGroup, alexaKeyword, policyParams, policyFrequency, policyExecutable, policyRestUrl, policyType, policyArn, severity, category, autoFixAvailable, autoFixEnabled, allowList, waitingTime, maxEmailNotification, templateName, templateColumns, fixType, warningMailSubject, fixMailSubject, warningMessage, fixMessage, violationMessage, elapsedTime, userId, createdDate, modifiedDate, status) VALUES ('remove_unused_scale_set','remove_unused_scale_set',' Delete Unused Scale Set',' Delete Unused Scale Set','Identify any empty virtual machine scale sets available within your Microsoft Azure cloud account and delete them in order to eliminate unnecessary costs and meet compliance requirements when it comes to unused resources.','Every empty virtual machine scale set should be removed for cost optimization and better management of your cloud resources.','','virtualmachinescaleset','azure','remove_unused_scale_set','{"params":[{"encrypt":false,"value":"check-for-unused-Virtual-machine-scale-set","key":"policyKey"},{"encrypt":false,"value":",","key":"splitterChar"},{"encrypt":false,"value":"Application,Environment,Stack,Role","key":"mandatoryTags","isMandatory":true,"description":"Assets should have these mandatory tags","defaultVal":"Application,Environment,Stack,Role","displayName":"Mandatory tags"},{"encrypt":false,"value":"low","key":"severity"},{"encrypt":false,"value":"security","key":"policyCategory"},{"encrypt":false,"value":"","key":"policyOwner"}],"environmentVariables":[],"policyId":"remove_unused_scale_set","autofix":false,"alexaKeyword":"remove_unused_scale_set","policyRestUrl":"","targetType":"virtualmachinescaleset","pac_ds":"azure","assetGroup":"azure","policyUUID":"remove_unused_scale_set","policyType":"ManagePolicy"}','0 0/6 * * ? *','','','ManagePolicy','arn:aws:events:us-east-1:***REMOVED***:rule/remove_unused_scale_set','high','cost','false','false',NULL,24,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,24,'ASGC','2023-07-19','2023-07-19','ENABLED'); | ||
|
|
||
| INSERT IGNORE INTO cf_PolicyTable (policyId, policyUUID, policyName, policyDisplayName, policyDesc, resolution, resolutionUrl, targetType, assetGroup, alexaKeyword, policyParams, policyFrequency, policyExecutable, policyRestUrl, policyType, policyArn, severity, category, autoFixAvailable, autoFixEnabled, allowList, waitingTime, maxEmailNotification, templateName, templateColumns, fixType, warningMailSubject, fixMailSubject, warningMessage, fixMessage, violationMessage, elapsedTime, userId, createdDate, modifiedDate, status) VALUES ('delete_unused_vm_disk','delete_unused_vm_disk',' Delete Unused VM Disk','Delete Unused VM Disk','Identify any unattached (unused) Gcp virtual machine disk volumes available within yourcloud account and delete them in order to lower the cost of your monthly bill and reduce the risk of sensitive data leakage.','Every unused virtual machine disk should be removed for cost optimization and better management of your cloud resources.','','gcpdisks','gcp','delete_unused_vm_disk','{"params":[{"encrypt":false,"value":"delete-unused-vm-disk","key":"policyKey"},{"encrypt":false,"value":",","key":"splitterChar"},{"encrypt":false,"value":"Application,Environment,Stack,Role","key":"mandatoryTags","isMandatory":true,"description":"Assets should have these mandatory tags","defaultVal":"Application,Environment,Stack,Role","displayName":"Mandatory tags"},{"encrypt":false,"value":"high","key":"severity"},{"encrypt":false,"value":"cost","key":"policyCategory"},{"encrypt":false,"value":"","key":"policyOwner"}],"environmentVariables":[],"policyId":"delete_unused_vm_disk","autofix":false,"alexaKeyword":"delete_unused_vm_disk","policyRestUrl":"","targetType":"gcpdisks","pac_ds":"gcp","assetGroup":"gcp","policyUUID":"delete_unused_vm_disk","policyType":"ManagePolicy"}','0 0/6 * * ? *','','','ManagePolicy','arn:aws:events:us-east-1:***REMOVED***:rule/delete_unused_vm_disk','high','cost','false','false',NULL,24,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,24,'ASGC','2023-07-19','2023-07-19','ENABLED'); | ||
| INSERT IGNORE INTO cf_PolicyTable (policyId, policyUUID, policyName, policyDisplayName, policyDesc, resolution, resolutionUrl, targetType, assetGroup, alexaKeyword, policyParams, policyFrequency, policyExecutable, policyRestUrl, policyType, policyArn, severity, category, autoFixAvailable, autoFixEnabled, allowList, waitingTime, maxEmailNotification, templateName, templateColumns, fixType, warningMailSubject, fixMailSubject, warningMessage, fixMessage, violationMessage, elapsedTime, userId, createdDate, modifiedDate, status) VALUES ('taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','Assign Mandatory Tags to AWS AMI','Assigning mandatory tags to AMI is important for identifying resources, allocating costs, automation, security, and compliance purposes. Mandatory tags ensure consistency, manageability, cost-effectiveness, security, and compliance across your aws infrastructure.','Add the mandatory tags to the assets,Follow the Cloud Asset Tagging guidelines.','https://github.com/PaladinCloud/CE/wiki/AWS-Policy#Assign-Mandatory-Tags-to-AWS-AMI','ami','aws','awsamitaggingrule','{\"params\":[{\"encrypt\":false,\"value\":\",\",\"key\":\"splitterChar\"},{\"encrypt\":false,\"value\":\"check-for-missing-mandatory-tags\",\"key\":\"policyKey\"},{\"encrypt\":false,\"value\":\"high\",\"key\":\"severity\"},{\"encrypt\":false,\"value\":\"Application,Environment,Stack,Role\",\"key\":\"mandatoryTags\",\"isMandatory\":true,\"description\":\"Assets should have these mandatory tags\",\"defaultVal\":\"Application,Environment,Stack,Role\",\"displayName\":\"Mandatory tags\"},{\"isValueNew\":true,\"encrypt\":false,\"value\":\"tagging\",\"key\":\"policyCategory\"}],\"environmentVariables\":[],\"policyId\":\"taggingRule_version-1_aws_ami\",\"autofix\":false,\"alexaKeyword\":\"amitagginrule\",\"policyRestUrl\":\"\",\"targetType\":\"ami\",\"pac_ds\":\"aws\",\"assetGroup\":\"aws\",\"policyUUID\":\"taggingRule_version-1_aws_ami\",\"policyType\":\"ManagePolicy\"}','0 0/12 * * ? *','','','ManagePolicy','arn:aws:events:us-east-1:***REMOVED***:rule/taggingRule_version-1_aws_ami','high','tagging','false','false',NULL,24,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,24,'ASGC','2025-08-28','2025-08-28','ENABLED'); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Fix inconsistencies and typos in new AWS AMI tagging policy row; align naming and params
- policyName should be human-readable (consistent with other rows).
- resolution has punctuation/spacing issues.
- resolutionUrl likely needs a lowercase GitHub anchor.
- JSON alexaKeyword has a typo and disagrees with the table column.
- Add threadsafe param for consistency with other policies.
Apply this diff:
-INSERT IGNORE INTO cf_PolicyTable (policyId, policyUUID, policyName, policyDisplayName, policyDesc, resolution, resolutionUrl, targetType, assetGroup, alexaKeyword, policyParams, policyFrequency, policyExecutable, policyRestUrl, policyType, policyArn, severity, category, autoFixAvailable, autoFixEnabled, allowList, waitingTime, maxEmailNotification, templateName, templateColumns, fixType, warningMailSubject, fixMailSubject, warningMessage, fixMessage, violationMessage, elapsedTime, userId, createdDate, modifiedDate, status) VALUES ('taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','Assign Mandatory Tags to AWS AMI','Assigning mandatory tags to AMI is important for identifying resources, allocating costs, automation, security, and compliance purposes. Mandatory tags ensure consistency, manageability, cost-effectiveness, security, and compliance across your aws infrastructure.','Add the mandatory tags to the assets,Follow the Cloud Asset Tagging guidelines.','https://github.com/PaladinCloud/CE/wiki/AWS-Policy#Assign-Mandatory-Tags-to-AWS-AMI','ami','aws','awsamitaggingrule','{\"params\":[{\"encrypt\":false,\"value\":\",\",\"key\":\"splitterChar\"},{\"encrypt\":false,\"value\":\"check-for-missing-mandatory-tags\",\"key\":\"policyKey\"},{\"encrypt\":false,\"value\":\"high\",\"key\":\"severity\"},{\"encrypt\":false,\"value\":\"Application,Environment,Stack,Role\",\"key\":\"mandatoryTags\",\"isMandatory\":true,\"description\":\"Assets should have these mandatory tags\",\"defaultVal\":\"Application,Environment,Stack,Role\",\"displayName\":\"Mandatory tags\"},{\"isValueNew\":true,\"encrypt\":false,\"value\":\"tagging\",\"key\":\"policyCategory\"}],\"environmentVariables\":[],\"policyId\":\"taggingRule_version-1_aws_ami\",\"autofix\":false,\"alexaKeyword\":\"amitagginrule\",\"policyRestUrl\":\"\",\"targetType\":\"ami\",\"pac_ds\":\"aws\",\"assetGroup\":\"aws\",\"policyUUID\":\"taggingRule_version-1_aws_ami\",\"policyType\":\"ManagePolicy\"}','0 0/12 * * ? *','','','ManagePolicy','arn:aws:events:us-east-1:***REMOVED***:rule/taggingRule_version-1_aws_ami','high','tagging','false','false',NULL,24,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,24,'ASGC','2025-08-28','2025-08-28','ENABLED');
+INSERT IGNORE INTO cf_PolicyTable (policyId, policyUUID, policyName, policyDisplayName, policyDesc, resolution, resolutionUrl, targetType, assetGroup, alexaKeyword, policyParams, policyFrequency, policyExecutable, policyRestUrl, policyType, policyArn, severity, category, autoFixAvailable, autoFixEnabled, allowList, waitingTime, maxEmailNotification, templateName, templateColumns, fixType, warningMailSubject, fixMailSubject, warningMessage, fixMessage, violationMessage, elapsedTime, userId, createdDate, modifiedDate, status) VALUES ('taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','Assign Mandatory Tags to AWS AMI','Assign Mandatory Tags to AWS AMI','Assigning mandatory tags to AMI is important for identifying resources, allocating costs, automation, security, and compliance purposes. Mandatory tags ensure consistency, manageability, cost-effectiveness, security, and compliance across your AWS infrastructure.','Add the mandatory tags to the assets. Follow the Cloud Asset Tagging guidelines.','https://github.com/PaladinCloud/CE/wiki/AWS-Policy#assign-mandatory-tags-to-aws-ami','ami','aws','awsamitaggingrule','{\"params\":[{\"encrypt\":false,\"value\":\"true\",\"key\":\"threadsafe\"},{\"encrypt\":false,\"value\":\",\",\"key\":\"splitterChar\"},{\"encrypt\":false,\"value\":\"check-for-missing-mandatory-tags\",\"key\":\"policyKey\"},{\"encrypt\":false,\"value\":\"high\",\"key\":\"severity\"},{\"encrypt\":false,\"value\":\"Application,Environment,Stack,Role\",\"key\":\"mandatoryTags\",\"isMandatory\":true,\"description\":\"Assets should have these mandatory tags\",\"defaultVal\":\"Application,Environment,Stack,Role\",\"displayName\":\"Mandatory tags\"},{\"isValueNew\":true,\"encrypt\":false,\"value\":\"tagging\",\"key\":\"policyCategory\"}],\"environmentVariables\":[],\"policyId\":\"taggingRule_version-1_aws_ami\",\"autofix\":false,\"alexaKeyword\":\"awsamitaggingrule\",\"policyRestUrl\":\"\",\"targetType\":\"ami\",\"pac_ds\":\"aws\",\"assetGroup\":\"aws\",\"policyUUID\":\"taggingRule_version-1_aws_ami\",\"policyType\":\"ManagePolicy\"}','0 0/12 * * ? *','','','ManagePolicy','arn:aws:events:us-east-1:***REMOVED***:rule/taggingRule_version-1_aws_ami','high','tagging','false','false',NULL,24,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,24,'ASGC','2025-08-28','2025-08-28','ENABLED');📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| INSERT IGNORE INTO cf_PolicyTable (policyId, policyUUID, policyName, policyDisplayName, policyDesc, resolution, resolutionUrl, targetType, assetGroup, alexaKeyword, policyParams, policyFrequency, policyExecutable, policyRestUrl, policyType, policyArn, severity, category, autoFixAvailable, autoFixEnabled, allowList, waitingTime, maxEmailNotification, templateName, templateColumns, fixType, warningMailSubject, fixMailSubject, warningMessage, fixMessage, violationMessage, elapsedTime, userId, createdDate, modifiedDate, status) VALUES ('taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','taggingRule_version-1_aws_ami','Assign Mandatory Tags to AWS AMI','Assigning mandatory tags to AMI is important for identifying resources, allocating costs, automation, security, and compliance purposes. Mandatory tags ensure consistency, manageability, cost-effectiveness, security, and compliance across your aws infrastructure.','Add the mandatory tags to the assets,Follow the Cloud Asset Tagging guidelines.','https://github.com/PaladinCloud/CE/wiki/AWS-Policy#Assign-Mandatory-Tags-to-AWS-AMI','ami','aws','awsamitaggingrule','{\"params\":[{\"encrypt\":false,\"value\":\",\",\"key\":\"splitterChar\"},{\"encrypt\":false,\"value\":\"check-for-missing-mandatory-tags\",\"key\":\"policyKey\"},{\"encrypt\":false,\"value\":\"high\",\"key\":\"severity\"},{\"encrypt\":false,\"value\":\"Application,Environment,Stack,Role\",\"key\":\"mandatoryTags\",\"isMandatory\":true,\"description\":\"Assets should have these mandatory tags\",\"defaultVal\":\"Application,Environment,Stack,Role\",\"displayName\":\"Mandatory tags\"},{\"isValueNew\":true,\"encrypt\":false,\"value\":\"tagging\",\"key\":\"policyCategory\"}],\"environmentVariables\":[],\"policyId\":\"taggingRule_version-1_aws_ami\",\"autofix\":false,\"alexaKeyword\":\"amitagginrule\",\"policyRestUrl\":\"\",\"targetType\":\"ami\",\"pac_ds\":\"aws\",\"assetGroup\":\"aws\",\"policyUUID\":\"taggingRule_version-1_aws_ami\",\"policyType\":\"ManagePolicy\"}','0 0/12 * * ? *','','','ManagePolicy','arn:aws:events:us-east-1:***REMOVED***:rule/taggingRule_version-1_aws_ami','high','tagging','false','false',NULL,24,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,24,'ASGC','2025-08-28','2025-08-28','ENABLED'); | |
| INSERT IGNORE INTO cf_PolicyTable ( | |
| policyId, | |
| policyUUID, | |
| policyName, | |
| policyDisplayName, | |
| policyDesc, | |
| resolution, | |
| resolutionUrl, | |
| targetType, | |
| assetGroup, | |
| alexaKeyword, | |
| policyParams, | |
| policyFrequency, | |
| policyExecutable, | |
| policyRestUrl, | |
| policyType, | |
| policyArn, | |
| severity, | |
| category, | |
| autoFixAvailable, | |
| autoFixEnabled, | |
| allowList, | |
| waitingTime, | |
| maxEmailNotification, | |
| templateName, | |
| templateColumns, | |
| fixType, | |
| warningMailSubject, | |
| fixMailSubject, | |
| warningMessage, | |
| fixMessage, | |
| violationMessage, | |
| elapsedTime, | |
| userId, | |
| createdDate, | |
| modifiedDate, | |
| status | |
| ) VALUES ( | |
| 'taggingRule_version-1_aws_ami', | |
| 'taggingRule_version-1_aws_ami', | |
| 'Assign Mandatory Tags to AWS AMI', | |
| 'Assign Mandatory Tags to AWS AMI', | |
| 'Assigning mandatory tags to AMI is important for identifying resources, allocating costs, automation, security, and compliance purposes. Mandatory tags ensure consistency, manageability, cost-effectiveness, security, and compliance across your AWS infrastructure.', | |
| 'Add the mandatory tags to the assets. Follow the Cloud Asset Tagging guidelines.', | |
| 'https://github.com/PaladinCloud/CE/wiki/AWS-Policy#assign-mandatory-tags-to-aws-ami', | |
| 'ami', | |
| 'aws', | |
| 'awsamitaggingrule', | |
| '{"params":[{"encrypt":false,"value":"true","key":"threadsafe"},{"encrypt":false,"value":",","key":"splitterChar"},{"encrypt":false,"value":"check-for-missing-mandatory-tags","key":"policyKey"},{"encrypt":false,"value":"high","key":"severity"},{"encrypt":false,"value":"Application,Environment,Stack,Role","key":"mandatoryTags","isMandatory":true,"description":"Assets should have these mandatory tags","defaultVal":"Application,Environment,Stack,Role","displayName":"Mandatory tags"},{"isValueNew":true,"encrypt":false,"value":"tagging","key":"policyCategory"}],"environmentVariables":[],"policyId":"taggingRule_version-1_aws_ami","autofix":false,"alexaKeyword":"awsamitaggingrule","policyRestUrl":"","targetType":"ami","pac_ds":"aws","assetGroup":"aws","policyUUID":"taggingRule_version-1_aws_ami","policyType":"ManagePolicy"}', | |
| '0 0/12 * * ? *', | |
| '', | |
| '', | |
| 'ManagePolicy', | |
| 'arn:aws:events:us-east-1:***REMOVED***:rule/taggingRule_version-1_aws_ami', | |
| 'high', | |
| 'tagging', | |
| 'false', | |
| 'false', | |
| NULL, | |
| 24, | |
| 1, | |
| NULL, | |
| NULL, | |
| NULL, | |
| NULL, | |
| NULL, | |
| NULL, | |
| NULL, | |
| NULL, | |
| 24, | |
| 'ASGC', | |
| '2025-08-28', | |
| '2025-08-28', | |
| 'ENABLED' | |
| ); |
🤖 Prompt for AI Agents
In installer/resources/pacbot_app/files/DB_Policy.sql around line 610, the new
AWS AMI tagging policy row contains naming/format inconsistencies and typos:
change policyName to a human-readable string consistent with other rows; fix the
resolution text punctuation and spacing; update resolutionUrl to use the
lowercase GitHub anchor; correct the JSON alexaKeyword typo so it matches the
table column name and ensure the JSON is valid; and add the threadsafe parameter
(set consistently with other policy rows). Make only these edits in that row so
the row’s columns align with the rest of the table.
feat:NEXT-625 Added Tagging Policy for AWS AMI
Summary by CodeRabbit
New Features
Chores