
CREATE TABLE IF NOT EXISTS public.recommendation_rule_metadata (
    rule_name       text PRIMARY KEY,
    category        text NOT NULL,
    title           text NOT NULL,
    description     text,
    service_name    text,
    recommendations jsonb DEFAULT '[]'::jsonb,
    mitigations     jsonb DEFAULT '[]'::jsonb,
    compliances     jsonb DEFAULT '[]'::jsonb,
    "references"    jsonb DEFAULT '[]'::jsonb,
    created_at      timestamptz NOT NULL DEFAULT now(),
    updated_at      timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX idx_recommendation_rule_metadata_category ON public.recommendation_rule_metadata (category);

CREATE TRIGGER set_recommendation_rule_metadata_updated_at
    BEFORE UPDATE ON public.recommendation_rule_metadata
    FOR EACH ROW
    EXECUTE FUNCTION set_current_timestamp_updated_at();

-- Seed recommendation_rule_metadata with data from data.tsx
-- Total entries: 531

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('aws_tags', 'Configuration', 'AWS Resources Should Have Tags', 'As your AWS cloud environment is becoming more and more complex, it requires better management strategies. Using a tagging schema will help you gain visibility over your cloud resources and organize them more efficiently. You can use tags for different scenarios such as tracking resources owners and their stack level, identify which resources are incurring the highest costs, and filter available resources based on particular deployment stage.', '', '["Ensure that user-defined tags (metadata) are being used for labeling, collecting, and organizing resources available within your AWS cloud environment. It is recommended that you tag your resources with appropriate metadata to help you manage and organize your resources.\n                It is recommended to have tags like Name, Environment, Owner and Role to have better track of resources."]'::jsonb, '["", "aws ec2 create-tags --resources {{recommendation.instance_id}} --tags Key=Name,Value=Prod-Web-Server Key=Role,Value=Web-Tier Key=Environment,Value=Production Key=Owner,Value=DevOps-Team", ""]'::jsonb, '["APRA", "MAS", "NIST4"]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html"]'::jsonb),
  ('aws_ec2_instance_auto_termination', 'Configuration', 'EC2 Instance Termination Protection Should Be Enabled', 'By default, the EBS volumes associated with the Amazon EC2 instances are deleted when these are terminated (when the DeletionOnTermination attribute value is set to true). With Termination Protection feature enabled, you have the guarantee that your EC2 instances can''t be terminated accidentally and make sure that your data remains safe.', 'AmazonEC2', '["\n        Ensure that the Amazon EC2 instances provisioned outside the Auto Scaling Groups (ASGs) have Termination Protection safety feature enabled in order to protect them from being accidentally terminated.\n        For Amazon EC2 instances provisioned manually, once the Termination Protection feature is enabled you will not be able to terminate your EC2 instances using the AWS Management Console, the AWS API, or the AWS CLI until the Termination Protection has been disabled. However, this will not prevent your instances from getting terminated if these have set the Shutdown Behavior flag to ''Terminate'' when an OS-level shutdown is performed. To make sure your EC2 instances cannot be accidentally terminated, you need to set first the instance Shutdown Behavior value to ''Stop'' (which sets the InstanceInitiatedShutdownBehavior attribute value to ''stop'') then enable Termination Protection safety feature (which sets the DisableApiTermination attribute value to true).\n        For Amazon EC2 instances provisioned automatically via AWS CloudFormation, once the Termination Protection feature is enabled, you will not be able to delete the stack containing the instance until the feature has been disabled (which sets the DisableApiTermination attribute value to false) in your CloudFormation template.\n        "]'::jsonb, '["Run modify-instance-attribute command (OSX/Linux/UNIX) using the ID of the Amazon EC2 instance that you want to protect against accidental termination as the identifier parameter, to enable the Termination Protection safety feature for the selected EC2 instance (if successful, the command does not produce an output): \n\\", "\\", "\\", "\n", "**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_ChangingDisableAPITermination.html"]'::jsonb),
  ('aws_eks_logging', 'Configuration', 'Enable CloudTrail Logging for Kubernetes API Calls', 'Enabling CloudTrail logging for Amazon EKS clusters is vital for security monitoring, compliance adherence, incident investigation, and operational insights. It provides a detailed audit trail of API calls, enabling proactive detection of unauthorized access, ensuring regulatory compliance, facilitating incident response, and optimizing cluster performance and change management.', 'AmazonEKS', '["Ensure that CloudTrail logging is enabled for Amazon Elastic Kubernetes Service (EKS) clusters in order to record all Kubernetes API calls. Amazon CloudTrail records and documents all activities performed on EKS clusters. Whenever operations such as \"CreateCluster,\" \"ListClusters,\" or \"DeleteCluster\" are executed, corresponding records are generated in the CloudTrail trail log files. Each event or log entry includes details about the IAM identity responsible for the request and the credentials utilized."]'::jsonb, '["Update your cluster''s control plane log export configuration with the following AWS CLI command:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/eks/latest/userguide/control-plane-logs.html"]'::jsonb),
  ('aws_ecr_tag_immutable', 'Configuration', 'Ecr Image Tags should be immutable', 'ECR images should be set to IMMUTABLE to prevent code injection through image mutation. This can be done by setting image_tab_mutability to IMMUTABLE', 'AmazonECR', '["ECR images should be set to IMMUTABLE to prevent code injection through image mutation. This can be done by setting image_tab_mutability to IMMUTABLE"]'::jsonb, '["AWS CLI command to set image tag mutability to IMMUTABLE:\n\\", "\\", "\\", "\n", "**Terraform configuration file (.tf):**\n \\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-tag-mutability.html"]'::jsonb),
  ('aws_lambda_dead_letter_queue', 'Configuration', 'Enable Dead Letter Queue for Lambda Functions', 'Ensure there is a Dead Letter Queue configured for each Lambda function available in your AWS account.', 'AWSLambda', '["When an event fails all attempts or stays in the asynchronous invocation queue for too long, Amazon Lambda service discards it. Enabling Dead Letter Queues (DLQs) for your Amazon Lambda functions can make your serverless application more resilient by capturing and storing unprocessed events from asynchronous invocations for further analysis or reprocessing. Configuring Dead Letter Queues for Amazon Lambda functions will give you more control over message handling for all asynchronous invocations, including those delivered via AWS service events (S3, SNS, IoT, etc.)."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Dead Letter Queue for Lambda function:\nCreate a Dead Letter Queue (DLQ) in Amazon SQS:\n\n\\", "\\", "\\", "\n\n\n        Update the Lambda function configuration to use the Dead Letter Queue:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/about-aws/whats-new/2016/12/aws-lambda-supports-dead-letter-queues/"]'::jsonb),
  ('aws_lambda_provisioned_concurrency', 'Configuration', 'Enable and Configure Provisioned Concurrency', 'When you are using Lambda functions for your serverless application, you are not provisioning hardware or networks, runtimes and operating systems, but you are able to enable and configure features such as provisioned concurrency which can directly affect your application''s performance. Functions configured with provisioned concurrency can execute with consistent start-up latency, making them ideal for building interactive web and mobile back-ends, latency sensitive microservices, and synchronously invoked APIs.', 'AWSLambda', '["Ensure that the Provisioned Concurrency performance feature is enabled for your Amazon Lambda functions in order to help your functions to scale without fluctuations in latency. Provisioned concurrency runs continuously and has a separate pricing plan for concurrency and execution duration."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Provisioned Concurrency for Lambda function:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html"]'::jsonb),
  ('aws_lambda_reserved_concurrency', 'Configuration', 'Enable and Configure Reserved Concurrency For Lambda Functions', 'Reserved concurrency in Amazon Lambda allows you to set a limit on the number of concurrent executions for a specific Lambda function, ensuring it doesn''t exceed that limit even during spikes in traffic. Setting a concurrent execution limit at the Lambda function level ensures predictable scaling, prevents excessive resource usage, and enhances cost control and performance.', 'AWSLambda', '["Ensure that the Reserved Concurrency feature is enabled and configured for your Amazon Lambda functions. Enabling reserved concurrency ensures predictable performance and cost control for your Lambda functions by limiting the number of concurrent executions."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Reserved Concurrency for Lambda function:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html"]'::jsonb),
  ('aws_lambda_deprecated_runtime', 'Configuration', 'Lambda Using Supported Runtime Environment', 'When you execute your Lambda functions using a supported version of the implemented runtime environment, you ensure your function is not at risk of reaching end of support from AWS. To benefit from new features and enhancements, better security, performance and reliability, it is recommended to update to the latest environment version.', 'AWSLambda', '["Ensure that your Amazon Lambda function always uses a supported environment version, in order to avoid end of support timeframes from AWS. AWS Phase 1 Deprecation means Lambda functions no longer receive security patches or other updates to the runtime. You can no longer create functions that use the runtime, but you can continue to update existing functions. This includes updating the runtime, and rolling back to the previous runtime. Note that functions that use a deprecated runtime are no longer eligible for technical support. It is recommended to updated to the latest version to adhere to AWS cloud best practices and receive the newest software features, get the latest security patches and bug fixes, and benefit from better performance and reliability. A Lambda runtime (execution) environment is a container build based on the configuration settings that you provide when you create your Lambda function. Amazon Lambda serverless architecture supports several runtime environments such as Node.js, Edge Node.js, Java, Python and .NET Core (C#) that you can use to run your functions."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to update the Runtime Environment Version for Lambda function:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html"]'::jsonb),
  ('aws_lambda_tracing', 'Configuration', 'Tracing Enabled for Lambda Functions', 'AWS X-Ray can provide tracing and monitoring capabilities for your Lambda functions. With active tracing mode enabled, you can save time and effort debugging and operating your functions as the X-Ray service support allows you to rapidly diagnose errors, identify bottlenecks, slowdowns and timeouts, by breaking down the latency for your Lambda functions.', 'AWSLambda', '["Ensure that active tracing is enabled for your Amazon Lambda functions in order to gain visibility into the execution and performance of the functions. With the tracing feature enabled, Amazon activates Lambda support for AWS X-Ray, a service that collects data about requests that your functions perform, which provides tools that you can use to view, filter, and gain insights into the collected data in order to identify issues and opportunities for optimization."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Active Tracing for Lambda function:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html", "https://docs.aws.amazon.com/lambda/latest/operatorguide/trace-requests.html"]'::jsonb),
  ('aws_rds_reservedinstance_configured', 'Configuration', 'Reserved Instances Should Be Configured for RDS', 'Amazon RDS Reserved Instances give you the option to reserve a DB instance for a one or three year term and in turn receive a significant discount compared to the On-Demand Instance pricing for the DB instance.
    You can choose between three payment options when you purchase a Reserved Instance. With the All Upfront option, you pay for the entire Reserved Instance with one upfront payment. This option provides you with the largest discount compared to On-Demand Instance pricing. With the Partial Upfront option, you make a low upfront payment and are then charged a discounted hourly rate for the instance for the duration of the Reserved Instance term. The No Upfront option does not require any upfront payment and provides a discounted hourly rate for the duration of the term.
    All Reserved Instance types are available for Aurora, MySQL, MariaDB, PostgreSQL, Oracle and SQL Server database engines.', 'AmazonRDS', '["Reserve an Amazon RDS instance to save costs. Reserved Instances provide you with a significant discount (up to 75%) compared to On-Demand Instance pricing. You can reserve a DB instance for a one or three year term and in turn receive a significant discount compared to the On-Demand Instance pricing for the DB instance. You can choose between three payment options when you purchase a Reserved Instance. With the All Upfront option, you pay for the entire Reserved Instance with one upfront payment. This option provides you with the largest discount compared to On-Demand Instance pricing. With the Partial Upfront option, you make a low upfront payment and are then charged a discounted hourly rate for the instance for the duration of the Reserved Instance term. The No Upfront option does not require any upfront payment and provides a discounted hourly rate for the duration of the term."]'::jsonb, '[]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/rds/reserved-instances/"]'::jsonb),
  ('aws_rds_instance_reserved', 'Configuration', 'Reserved Instance should be used for RDS Instance', 'When an AWS RDS Reserved Instance is not in use (i.e. does not have an active corresponding instance) the investment made is not exploited. For example, if you reserve a db.m3.medium RDS instance within US West (Oregon) region and you don''t provision a database instance with the same class/type, in the same region of the same AWS account or in any other linked AWS accounts within your AWS Organization, the specified RDS RI is considered unused and your investment has a negative return.', 'AmazonRDS', '["Ensure that all your AWS RDS Reserved Instances (RI) have corresponding database instances running within the same account or within any AWS accounts members of an AWS Organization (if any). A corresponding database instance is a running RDS instance that matches the reservation parameters such as Region and Instance Type."]'::jsonb, '["\n        AWS CLI and API -\n        - Use the describe-reserved-db-instances-offerings to list the Reserved DB Instance offerings available for purchase.\n        - Use the purchase-reserved-db-instances-offering command to purchase RIs for an account.\n        - Use the describe-reserved-db-instances command to list the existing RIs for an account.\n        "]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/rds/reserved-instances/"]'::jsonb),
  ('aws_rds_delete_protection', 'Configuration', 'Deletion Protection For RDS Instances', 'Deletion protection prevents any existing or new provisioned databases clusters from being terminated by a root or an IAM user, using the AWS Management Console, AWS CLI, or AWS API, unless the feature is explicitly disabled. With Deletion Protection safety feature enabled, you have the certainty that your database clusters can''t be accidentally deleted and make sure that your data remains safe.', 'AmazonRDS', '["\n        Ensure that all your provisioned Amazon Aurora database clusters are protected from accidental deletion by having the Deletion Protection feature enabled at the Aurora cluster level.\n        "]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Deletion Protection for Aurora Cluster:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/about-aws/whats-new/2018/09/amazon-rds-now-provides-database-deletion-protection/"]'::jsonb),
  ('aws_rds_storage_autoscaling', 'Configuration', 'Enable Instance Storage AutoScaling for RDS Instances', 'With the Storage AutoScaling feature enabled, when Amazon RDS detects that your database instance is running out of disk space, it automatically scales up your instance storage. For example, you can use this feature for a new mobile application that users are adopting rapidly. In this case, a rapidly increasing workload might exceed the available database storage. To avoid having to manually scale up database storage, enable Amazon RDS Storage AutoScaling.', 'AmazonRDS', '["Ensure that the Storage AutoScaling feature is enabled for your Amazon RDS database instances in order to provide dynamic scaling support for the database''s storage based on your RDS application needs. Enabling Storage AutoScaling will allow the database instance storage to increase once the configured threshold is exceeded."]'::jsonb, '["\n        **Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "\n        AWS CLI command to enable Storage AutoScaling for RDS instance:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIOPS.StorageTypes.html"]'::jsonb),
  ('aws_rds_auto_minor_upgrade', 'Configuration', 'Auto Minor Version Upgrade For RDS', 'Amazon RDS will occasionally deprecate minor engine versions and provide new ones for upgrade. When the last version number within the release is replaced (e.g. 5.6.26 to 5.6.27), the version changed is considered minor. With the Auto Minor Version Upgrade feature enabled, the version upgrades will occur automatically during the specified maintenance window and your database instances will get the new features, the bug fixes, and the security patches for their database engines.', 'AmazonRDS', '["\n        Ensure that your Amazon RDS database instances have the Auto Minor Version Upgrade flag enabled in order to receive automatically minor engine upgrades during the specified maintenance window. Each version upgrade is available only after is tested and approved by AWS.\n        "]'::jsonb, '["\n        **Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "\n        AWS CLI command to enable Auto Minor Version Upgrade for RDS instance:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Upgrading.html"]'::jsonb),
  ('aws_rds_performance_insights', 'Configuration', 'Performance Insights Should Be Enabled for RDS Instances', 'The Performance Insights feature provides you instant visibility into the nature of the workloads on your Amazon RDS databases and helps you find the cause of any performance issue found on your databases.', 'AmazonRDS', '["\n        Ensure that your Amazon RDS MySQL and PostgreSQL database instances have the Performance Insights feature enabled in order to allow you to obtain a better overview of your databases performance as well as help you to identify potential performance issues. Performance Insights is a performance monitoring tool that helps you to evaluate the load on your MySQL/PostgreSQL databases and determine when and where to take action. The feature allows you to detect performance bottlenecks with an easy-to-understand dashboard that visualizes database load in real time. For example, with Performance Insights feature enabled, when the load of your database is high, you can easily determine the type of bottleneck such as high CPU consumption, lock waits or I/O latency, and see which SQL queries are creating the bottleneck. Performance Insights is currently available for the following database engines: Amazon Aurora (MySQL and PostgreSQL-compatible editions), RDS MySQL, and RDS PostgreSQL.\n        "]'::jsonb, '["\n        **Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Performance Insights for RDS instance:\n\\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.html"]'::jsonb),
  ('aws_rds_backup_enabled', 'Configuration', 'Automated Backups Enabled for RDS Instances', 'Creating point-in-time database instance snapshots periodically will allow you to handle efficiently your data restoration process in the event of a user error on the source database or to save data before making a major change to the instance database such as changing the structure of a table.', 'AmazonRDS', '["Ensure that your Amazon RDS database instances have automated backups enabled for point-in-time recovery. To back up your database instances, Amazon RDS takes automatically a full daily snapshot of your data (with transactions logs) during the specified backup window and keeps the backups for a specified period of time (known as retention period)."]'::jsonb, '["\n        **Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable Automated Backups for RDS instance:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/rds/features/backup/"]'::jsonb),
  ('aws_rds_backupservice_enabled', 'Configuration', 'AWS Backup Service in Use for Amazon RDS', 'With Amazon Backup, you can centrally configure backup policies and rules, and monitor backup activity for AWS RDS database instances. The Backup service automates and consolidates backup tasks previously performed service-by-service, removing the need to create custom scripts such as Lambda functions and manual processes.', 'AmazonRDS', '["\n        Ensure that Amazon Backup is integrated with Amazon Relational Database Service (RDS) in order to manage RDS database instance snapshots and improve the reliability of your backup strategy. Amazon Backup is a fully managed service that creates, restores and deletes backups on your behalf.\n        "]'::jsonb, '["\n        Create Backup Plan for RDS Database Instance:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/rds/features/backup/"]'::jsonb),
  ('aws_rds_copy_tags_to_snapshots', 'Configuration', 'Enable Copy Tags to Snapshots for RDS Instances', 'Copying your Amazon Aurora database cluster tags to any automated or manual snapshots taken from your database clusters allows you to easily set metadata (including access policies) on your snapshots in order to match the parent clusters.', 'AmazonRDS', '["Ensure that your Amazon Aurora database clusters make use of Copy Tags to Snapshots feature in order to allow tags set on your Aurora database clusters to be automatically copied to any automated or manual snapshots that are created from these clusters. Once the feature is enabled, tags can be copied to all future copies of an Amazon Aurora snapshots, including cross-region snapshots."]'::jsonb, '["\n        **Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "\n        AWS CLI command to enable Copy Tags to Snapshots for RDS Cluster:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html"]'::jsonb),
  ('aws_s3_versioning', 'Configuration', 'Bucket Versioning should be enabled for S3 Buckets', 'Versioning-enabled Amazon S3 buckets will allow you to preserve, retrieve, and restore every version of an S3 object. S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten by AWS users or applications and archiving previous versions of objects to Amazon S3 Glacier for long-term low-cost storage. With S3 versioning, you can easily recover from both unintended user actions and application failures.', 'AmazonS3', '["Ensure that S3 object versioning is enabled for your Amazon S3 buckets in order to preserve and recover overwritten and deleted S3 objects as an extra layer of data protection and/or data retention."]'::jsonb, '["\n        **Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "\n        AWS CLI command to enable Versioning for S3 bucket:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html"]'::jsonb),
  ('aws_s3_lifecycle', 'Configuration', 'Lifecycle Configuration Enabled for S3 Buckets', 'With an S3 lifecycle configuration, you can enable Amazon S3 to downgrade the storage class for your objects, archive or delete S3 objects during their lifecycle. For example, you can define S3 lifecycle configuration rules to achieve compliance (with the law, with your organization standards or business requirements) by automatically transitioning your objects to S3 Standard-Infrequent Access (S3 Standard-IA) storage class one month after creation, or archive S3 objects with Amazon S3 Glacier using Glacier or Glacier Deep Archive storage class one year after creation. You can also implement lifecycle configuration rules to expire (delete) objects based on your retention requirements or clean up incomplete multipart uploads in order to optimize your Amazon S3 costs.', 'AmazonS3', '["Ensure that your Amazon S3 buckets are using lifecycle configurations for security and cost optimization purposes. An S3 lifecycle configuration is a set of one or more rules, where each rule defines an action (transition or expiration action) for Amazon S3 to apply to a group of objects. A lifecycle configuration is used to manage Amazon S3 data during its lifetime."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", " AWS CLI command to enable Lifecycle Configuration for S3 bucket:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html"]'::jsonb),
  ('aws_elasticache_auto_minor_upgrade', 'Configuration', 'Minor Version Upgrade Enabled for ElastiCache Clusters', 'Amazon ElasticCache will occasionally deprecate minor engine versions and provide new ones for upgrade. When the last version number within the release is replaced (e.g. 5.6.26 to 5.6.27), the version changed is considered minor. With the Auto Minor Version Upgrade feature enabled, the version upgrades will occur automatically during the specified maintenance window and your database instances will get the new features, the bug fixes, and the security patches for their database engines.', 'AmazonElastiCache', '["\n        Ensure that your Amazon ElasticCache cluster instances have the Auto Minor Version Upgrade flag enabled in order to receive automatically minor engine upgrades during the specified maintenance window. Each version upgrade is available only after is tested and approved by AWS.\n        "]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n        ", "\n        AWS CLI command to enable Auto Minor Version Upgrade for ElastiCache cluster:\n        \\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/VersionManagement.html"]'::jsonb),
  ('aws_fargate_service_min_healthy_percent_low', 'Configuration', 'Fargate Service Minimum Healthy Percent Too Low', 'The Fargate service minimum healthy percent is below 50%, which may impact availability during deployments.', 'AWSFargate', '["Set minimum healthy percent to at least 50% for services with multiple tasks to maintain availability during rolling deployments."]'::jsonb, '["minimumHealthyPercent"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_fargate_service_min_healthy_percent_too_low_for_single_task', 'Configuration', 'Single-Task Fargate Service Minimum Healthy Percent Below 100%', 'For a single-task service, minimum healthy percent less than 100% can cause downtime during updates.', 'AWSFargate', '["Set minimum healthy percent to 100% for single-task services to avoid downtime during deployments."]'::jsonb, '["minimumHealthyPercent"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_fargate_service_max_percent_non_standard', 'Configuration', 'Fargate Service Maximum Percent Non-Standard', 'The maximum percent deployment configuration is not set to the standard 200%.', 'AWSFargate', '["Review if the non-standard maximum percent is intentional. Standard is 200% to allow rolling deployments."]'::jsonb, '["maximumPercent"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_fargate_service_health_check_grace_period_zero', 'Configuration', 'Fargate Service Health Check Grace Period Is Zero', 'The health check grace period is set to 0, which may cause tasks to be terminated before they finish starting up.', 'AWSFargate', '["Set a health check grace period that gives tasks enough time to start up and pass health checks."]'::jsonb, '["healthCheckGracePeriodSeconds"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_fargate_service_exec_enabled', 'Configuration', 'Fargate Service ECS Exec Is Enabled', 'ECS Exec is enabled on this Fargate service. This feature allows interactive shell access to running containers and should be disabled in production.', 'AWSFargate', '["Disable ECS Exec on production services to reduce the attack surface. Only enable it for debugging when needed."]'::jsonb, '["enableExecuteCommand"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html"]'::jsonb),
  ('aws_fargate_task_definition_cpu_undefined', 'Configuration', 'Fargate Task Definition CPU Not Defined', 'The Fargate task definition does not have CPU units defined, which can lead to unpredictable resource allocation.', 'AWSFargate', '["Define CPU units in the task definition to ensure predictable resource allocation."]'::jsonb, '["cpu"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_fargate_task_definition_memory_undefined', 'Configuration', 'Fargate Task Definition Memory Not Defined', 'The Fargate task definition does not have memory defined, which can lead to unpredictable resource allocation.', 'AWSFargate', '["Define memory in the task definition to ensure predictable resource allocation."]'::jsonb, '["memory"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_fargate_task_definition_missing_task_role', 'Configuration', 'Fargate Task Definition Missing Task Role', 'The task definition does not have an IAM task role assigned. Without a task role, containers cannot securely access AWS services.', 'AWSFargate', '["Assign an IAM task role to the task definition following the principle of least privilege."]'::jsonb, '["taskRoleArn"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html"]'::jsonb),
  ('aws_fargate_task_definition_image_latest_tag', 'Configuration', 'Fargate Task Definition Using Latest Image Tag', 'The container image uses the :latest tag, which makes deployments non-deterministic and harder to rollback.', 'AWSFargate', '["Use specific image tags or digests instead of :latest to ensure reproducible deployments."]'::jsonb, '["Update the container definition to use a specific image tag (e.g., v1.2.3 or a SHA digest)."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_fargate_task_definition_logging_not_configured', 'Configuration', 'Fargate Task Definition Logging Not Configured', 'The container does not have logging configured, which makes it difficult to troubleshoot issues.', 'AWSFargate', '["Configure a log driver (e.g., awslogs) for all containers in the task definition."]'::jsonb, '["logConfiguration"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html"]'::jsonb),
  ('aws_fargate_task_definition_health_check_not_configured', 'Configuration', 'Fargate Task Definition Health Check Not Configured', 'The container does not have a health check configured, which means unhealthy containers may not be detected.', 'AWSFargate', '["Configure a health check for containers to enable automatic detection and replacement of unhealthy tasks."]'::jsonb, '["healthCheck"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_healthcheck"]'::jsonb),
  ('aws_redshift_audit_logging', 'Configuration', 'Redshift Audit Logging Should Be Enabled', 'Amazon Redshift audit logging provides information about connections and user activities in your cluster.', 'AmazonRedshift', '["Enable audit logging for your Redshift cluster to track database activity for security and compliance purposes."]'::jsonb, '["aws redshift modify-cluster --cluster-identifier {{recommendation.cluster_id}} --logging-properties BucketName=my-bucket"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html"]'::jsonb),
  ('aws_redshift_snapshot_retention', 'Configuration', 'Redshift Snapshot Retention Period Should Be Configured', 'The Redshift cluster snapshot retention period should be set to ensure backups are maintained for an adequate period.', 'AmazonRedshift', '["Configure an appropriate snapshot retention period for your Redshift cluster."]'::jsonb, '["aws redshift modify-cluster --cluster-identifier {{recommendation.cluster_id}} --automated-snapshot-retention-period 7"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-snapshots.html"]'::jsonb),
  ('aws_guardduty_enabled', 'Configuration', 'GuardDuty Should Be Enabled', 'Amazon GuardDuty is a threat detection service that continuously monitors for malicious activity and unauthorized behavior.', 'AmazonGuardDuty', '["Enable GuardDuty in all regions to detect threats across your AWS environment."]'::jsonb, '["\n**Enable GuardDuty:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_settingup.html"]'::jsonb),
  ('aws_guardduty_detector_active', 'Configuration', 'GuardDuty Detector Should Be Active', 'The GuardDuty detector exists but is not in an active state, meaning threats are not being monitored.', 'AmazonGuardDuty', '["Ensure the GuardDuty detector is active to continuously monitor for threats."]'::jsonb, '["\n**Activate the detector:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_settingup.html"]'::jsonb),
  ('aws_guardduty_s3_logs_enabled', 'Configuration', 'GuardDuty S3 Protection Should Be Enabled', 'GuardDuty S3 Protection monitors S3 data access events to detect suspicious activity.', 'AmazonGuardDuty', '["Enable S3 Protection in GuardDuty to monitor S3 bucket access for threats."]'::jsonb, '["Update the detector to enable S3 logs data source."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/guardduty/latest/ug/s3-protection.html"]'::jsonb),
  ('aws_guardduty_k8s_audit_logs_enabled', 'Configuration', 'GuardDuty Kubernetes Audit Logs Should Be Enabled', 'GuardDuty EKS Protection monitors Kubernetes audit logs for suspicious activity in EKS clusters.', 'AmazonGuardDuty', '["Enable Kubernetes audit log monitoring in GuardDuty for EKS cluster threat detection."]'::jsonb, '["Update the detector to enable Kubernetes data source."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/guardduty/latest/ug/kubernetes-protection.html"]'::jsonb),
  ('aws_es_dedicated_master', 'Configuration', 'Elasticsearch Dedicated Master Nodes Should Be Enabled', 'Dedicated master nodes improve cluster stability by offloading cluster management tasks from data nodes.', 'AmazonES', '["Enable dedicated master nodes for production Elasticsearch domains to improve stability."]'::jsonb, '["Update the domain configuration to enable dedicated master nodes with at least 3 instances."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/opensearch-service/latest/developerguide/managedomains-dedicatedmasternodes.html"]'::jsonb),
  ('aws_es_audit_logs_enabled', 'Configuration', 'Elasticsearch Audit Logs Should Be Enabled', 'Audit logs capture user activity in your Elasticsearch domain for security monitoring and compliance.', 'AmazonES', '["Enable audit logs for your Elasticsearch domain to track user activity."]'::jsonb, '["Update the domain log publishing options to enable audit logs."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/opensearch-service/latest/developerguide/audit-logs.html"]'::jsonb),
  ('aws_es_slow_logs_enabled', 'Configuration', 'Elasticsearch Slow Logs Should Be Enabled', 'Slow logs help identify performance bottlenecks in your Elasticsearch domain.', 'AmazonES', '["Enable slow logs to identify and troubleshoot query and indexing performance issues."]'::jsonb, '["Update the domain log publishing options to enable slow logs."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createdomain-configure-slow-logs.html"]'::jsonb),
  ('aws_directconnect_connection_down', 'Configuration', 'Direct Connect Connection Is Down', 'The Direct Connect connection is not in an available state, which may impact network connectivity.', 'AWSDirectConnect', '["Investigate and resolve the Direct Connect connection issue to restore connectivity."]'::jsonb, '["Check the AWS Direct Connect console for connection status and contact AWS Support if needed."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/WorkingWithConnections.html"]'::jsonb),
  ('aws_directconnect_no_redundancy', 'Configuration', 'Direct Connect Has No Redundancy', 'The Direct Connect setup does not have redundant connections, creating a single point of failure.', 'AWSDirectConnect', '["Set up redundant Direct Connect connections for high availability."]'::jsonb, '["Create a second Direct Connect connection at a different location for redundancy."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/getting_started.html"]'::jsonb),
  ('aws_directconnect_no_virtual_interfaces', 'Configuration', 'Direct Connect Has No Virtual Interfaces', 'The Direct Connect connection has no virtual interfaces configured.', 'AWSDirectConnect', '["Configure virtual interfaces on the Direct Connect connection to establish connectivity."]'::jsonb, '["Create a virtual interface on the Direct Connect connection."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/WorkingWithVirtualInterfaces.html"]'::jsonb),
  ('aws_directconnect_lag_below_minimum', 'Configuration', 'Direct Connect LAG Below Minimum Connections', 'The Link Aggregation Group has fewer active connections than the minimum threshold.', 'AWSDirectConnect', '["Ensure the LAG has sufficient active connections for required bandwidth."]'::jsonb, '["Add more connections to the LAG or reduce the minimum links threshold."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/lags.html"]'::jsonb),
  ('aws_directconnect_lag_down', 'Configuration', 'Direct Connect LAG Is Down', 'The Direct Connect Link Aggregation Group is not operational.', 'AWSDirectConnect', '["Investigate and resolve the LAG issue to restore connectivity."]'::jsonb, '["Check the LAG status and ensure member connections are active."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/lags.html"]'::jsonb),
  ('aws_directconnect_vif_down', 'Configuration', 'Direct Connect Virtual Interface Is Down', 'The Direct Connect virtual interface is not in an available state.', 'AWSDirectConnect', '["Investigate and resolve the virtual interface issue."]'::jsonb, '["Check the VIF status and ensure BGP session is established."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/WorkingWithVirtualInterfaces.html"]'::jsonb),
  ('aws_directconnect_bgp_peer_down', 'Configuration', 'Direct Connect BGP Peer Is Down', 'The BGP peer on the Direct Connect virtual interface is not established.', 'AWSDirectConnect', '["Investigate the BGP peer issue and restore the session."]'::jsonb, '["Verify BGP configuration on both sides and check for network issues."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/directconnect/latest/UserGuide/WorkingWithVirtualInterfaces.html"]'::jsonb),
  ('aws_elb_cross_zone_balancing', 'Configuration', 'ELB Cross-Zone Load Balancing Should Be Enabled', 'Cross-zone load balancing distributes traffic evenly across all registered instances in all enabled Availability Zones.', 'AmazonELB', '["Enable cross-zone load balancing to ensure even traffic distribution across AZs."]'::jsonb, '["aws elb modify-load-balancer-attributes --load-balancer-name {{resource_name}} --load-balancer-attributes \"{\"CrossZoneLoadBalancing\":{\"Enabled\":true}}\""]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html"]'::jsonb),
  ('aws_elb_connection_draining', 'Configuration', 'ELB Connection Draining Should Be Enabled', 'Connection draining ensures that the load balancer completes in-flight requests before deregistering instances.', 'AmazonELB', '["Enable connection draining to allow in-flight requests to complete during instance deregistration."]'::jsonb, '["Enable connection draining with an appropriate timeout value."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('aws_elb_access_logs', 'Configuration', 'ELB Access Logs Should Be Enabled', 'Access logs capture detailed information about requests sent to your load balancer for analysis and troubleshooting.', 'AmazonELB', '["Enable access logging for your load balancer to capture request details."]'::jsonb, '["Enable access logs and configure an S3 bucket to store them."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/access-log-collection.html"]'::jsonb),
  ('aws_elb_no_listeners', 'Configuration', 'ELB Has No Listeners Configured', 'The load balancer has no listeners configured, meaning it cannot route any traffic.', 'AmazonELB', '["Configure at least one listener on the load balancer."]'::jsonb, '["Add a listener with appropriate protocol and port configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html"]'::jsonb),
  ('aws_ec2_instance_termination_protection_disabled', 'Configuration', 'EC2 Instance Termination Protection Disabled', 'The EC2 instance does not have termination protection enabled, making it vulnerable to accidental termination.', 'AmazonEC2', '["Enable termination protection for important EC2 instances."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_ChangingDisableAPITermination.html"]'::jsonb),
  ('aws_ec2_instance_terminates_on_os_shutdown', 'Configuration', 'EC2 Instance Terminates on OS Shutdown', 'The instance is configured to terminate when an OS-level shutdown is performed instead of stopping.', 'AmazonEC2', '["Set the instance shutdown behavior to \"stop\" instead of \"terminate\"."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/terminating-instances.html#Using_ChangingInstanceInitiatedShutdownBehavior"]'::jsonb),
  ('aws_ec2_detailed_monitoring_disabled', 'Configuration', 'EC2 Detailed Monitoring Disabled', 'Detailed monitoring provides 1-minute CloudWatch metrics instead of the default 5-minute intervals.', 'AmazonEC2', '["Enable detailed monitoring for better visibility into instance performance."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch-new.html"]'::jsonb),
  ('aws_route53_query_logging_disabled', 'Configuration', 'Route 53 Query Logging Disabled', 'DNS query logging is not enabled for this hosted zone.', 'AmazonRoute53', '["Enable query logging to monitor DNS queries for troubleshooting and security analysis."]'::jsonb, '["Create a query logging configuration for the hosted zone."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/query-logs.html"]'::jsonb),
  ('aws_route53_dnssec_disabled', 'Configuration', 'Route 53 DNSSEC Not Enabled', 'DNSSEC signing is not enabled for this hosted zone, leaving it vulnerable to DNS spoofing attacks.', 'AmazonRoute53', '["Enable DNSSEC signing to protect against DNS spoofing and cache poisoning attacks."]'::jsonb, '["Enable DNSSEC signing in the Route 53 console or CLI."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-configure-dnssec.html"]'::jsonb),
  ('aws_route53_empty_hosted_zone', 'Configuration', 'Route 53 Empty Hosted Zone', 'The hosted zone has no record sets beyond the default NS and SOA records.', 'AmazonRoute53', '["Review if this hosted zone is needed. Empty hosted zones incur costs."]'::jsonb, '["Delete the hosted zone if it is no longer needed, or add appropriate DNS records."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-working-with.html"]'::jsonb),
  ('aws_route53_unhealthy_health_check', 'Configuration', 'Route 53 Unhealthy Health Check', 'A Route 53 health check is reporting an unhealthy status.', 'AmazonRoute53', '["Investigate and resolve the unhealthy health check to ensure proper DNS failover."]'::jsonb, '["Check the target endpoint health and update the health check configuration if needed."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/health-checks-types.html"]'::jsonb),
  ('aws_route53_health_check_no_alarm', 'Configuration', 'Route 53 Health Check Has No CloudWatch Alarm', 'The health check does not have a CloudWatch alarm configured for failure notifications.', 'AmazonRoute53', '["Create a CloudWatch alarm for the health check to receive notifications on failures."]'::jsonb, '["HealthCheckStatus"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/health-checks-monitor-view-status.html"]'::jsonb),
  ('aws_stepfunctions_high_failure_rate', 'Configuration', 'Step Functions High Failure Rate', 'The Step Functions state machine has a high execution failure rate.', 'AWSStepFunctions', '["Investigate the root cause of failures and implement error handling."]'::jsonb, '["Add Catch and Retry blocks to handle transient failures in your state machine definition."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html"]'::jsonb),
  ('aws_stepfunctions_logging_disabled', 'Configuration', 'Step Functions Logging Disabled', 'Logging is disabled for this state machine, making it difficult to troubleshoot execution issues.', 'AWSStepFunctions', '["Enable CloudWatch Logs for the state machine to track execution details."]'::jsonb, '["Update the state machine to include a logging configuration with a CloudWatch Logs log group."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/step-functions/latest/dg/cw-logs.html"]'::jsonb),
  ('aws_stepfunctions_logging_not_configured', 'Configuration', 'Step Functions Logging Not Configured', 'The state machine does not have a logging configuration defined.', 'AWSStepFunctions', '["Configure logging for the state machine."]'::jsonb, '["Add a logging configuration with appropriate log level (ALL, ERROR, or FATAL)."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/step-functions/latest/dg/cw-logs.html"]'::jsonb),
  ('aws_stepfunctions_xray_tracing_disabled', 'Configuration', 'Step Functions X-Ray Tracing Disabled', 'X-Ray tracing is not enabled for this state machine.', 'AWSStepFunctions', '["Enable X-Ray tracing to gain insights into execution performance and bottlenecks."]'::jsonb, '["Update the state machine to enable X-Ray tracing."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/step-functions/latest/dg/concepts-xray-tracing.html"]'::jsonb),
  ('aws_stepfunctions_express_not_utilized', 'Configuration', 'Step Functions Express Workflow Not Utilized', 'The state machine could benefit from using Express Workflows for high-volume, short-duration executions.', 'AWSStepFunctions', '["Consider using Express Workflows for workloads with high execution rates and short durations."]'::jsonb, '["Create a new Express state machine if the workload pattern is suitable."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/step-functions/latest/dg/concepts-standard-vs-express.html"]'::jsonb),
  ('aws_stepfunctions_large_definition', 'Configuration', 'Step Functions Large State Machine Definition', 'The state machine definition is unusually large, which may indicate it should be broken into smaller machines.', 'AWSStepFunctions', '["Consider breaking large state machines into smaller, composable state machines."]'::jsonb, '["Refactor the state machine into nested workflows or separate state machines."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/step-functions/latest/dg/limits-overview.html"]'::jsonb),
  ('aws_msk_enhanced_monitoring', 'Configuration', 'MSK Enhanced Monitoring Should Be Enabled', 'Enhanced monitoring provides additional broker-level metrics for better visibility into cluster performance.', 'AmazonMSK', '["Enable enhanced monitoring for your MSK cluster."]'::jsonb, '["Update the cluster to use PER_BROKER or PER_TOPIC_PER_BROKER monitoring level."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/msk/latest/developerguide/monitoring.html"]'::jsonb),
  ('aws_msk_cloudwatch_logs', 'Configuration', 'MSK CloudWatch Logs Should Be Enabled', 'Broker logs should be sent to CloudWatch Logs for monitoring and troubleshooting.', 'AmazonMSK', '["Enable CloudWatch Logs for MSK broker logs."]'::jsonb, '["Update the cluster logging configuration to enable CloudWatch Logs."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/msk/latest/developerguide/msk-logging.html"]'::jsonb),
  ('aws_cfn_drift_detection_check', 'Configuration', 'CloudFormation Drift Detection Check', 'CloudFormation stack drift should be checked regularly to detect manual changes to managed resources.', 'AWSCloudFormation', '["Run drift detection periodically to identify resources that have been modified outside of CloudFormation."]'::jsonb, '["\n**Run drift detection:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html"]'::jsonb),
  ('aws_cfn_stack_drifted', 'Configuration', 'CloudFormation Stack Has Drifted', 'The CloudFormation stack has drifted from its template, meaning resources have been modified outside of CloudFormation.', 'AWSCloudFormation', '["Resolve drift by updating the template or reverting manual changes."]'::jsonb, '["Update the stack to match the current template or import the drifted resources."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-drift.html"]'::jsonb),
  ('aws_cfn_termination_protection', 'Configuration', 'CloudFormation Termination Protection Should Be Enabled', 'Termination protection prevents the stack from being accidentally deleted.', 'AWSCloudFormation', '["Enable termination protection for important CloudFormation stacks."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-protect-stacks.html"]'::jsonb),
  ('aws_cfn_stack_policy', 'Configuration', 'CloudFormation Stack Policy Should Be Configured', 'A stack policy prevents unintentional updates to stack resources.', 'AWSCloudFormation', '["Set a stack policy to protect critical resources from unintentional updates."]'::jsonb, '["aws cloudformation set-stack-policy --stack-name {{resource_name}} --stack-policy-body file://policy.json"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html"]'::jsonb),
  ('aws_cloudtrail_multi_region', 'Configuration', 'CloudTrail Multi-Region Logging Should Be Enabled', 'CloudTrail should be configured to log events from all AWS regions.', 'AWSCloudTrail', '["Enable multi-region logging to capture API activity across all regions."]'::jsonb, '["\n**Update the trail to enable multi-region:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html"]'::jsonb),
  ('aws_cloudtrail_log_validation', 'Configuration', 'CloudTrail Log File Validation Should Be Enabled', 'Log file validation ensures that CloudTrail log files have not been tampered with after delivery.', 'AWSCloudTrail', '["Enable log file validation to detect unauthorized modifications to log files."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-validation-intro.html"]'::jsonb),
  ('aws_cloudtrail_cloudwatch_integration', 'Configuration', 'CloudTrail Should Be Integrated with CloudWatch', 'Integrating CloudTrail with CloudWatch Logs enables real-time monitoring of API activity.', 'AWSCloudTrail', '["Configure CloudTrail to send logs to a CloudWatch Logs group for real-time monitoring and alerting."]'::jsonb, '["Update the trail to specify a CloudWatch Logs log group and IAM role."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/send-cloudtrail-events-to-cloudwatch-logs.html"]'::jsonb),
  ('aws_cloudtrail_logging_enabled', 'Configuration', 'CloudTrail Logging Should Be Enabled', 'CloudTrail logging is not enabled, meaning API calls are not being recorded.', 'AWSCloudTrail', '["Enable CloudTrail logging to record API calls for security and compliance."]'::jsonb, '["\n**Start logging:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-turning-off-logging.html"]'::jsonb),
  ('aws_cloudtrail_eds_retention', 'Configuration', 'CloudTrail Event Data Store Retention Period', 'The CloudTrail Event Data Store retention period should be configured appropriately.', 'AWSCloudTrail', '["Set an appropriate retention period for the event data store based on compliance requirements."]'::jsonb, '["Update the event data store retention period."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-event-data-store.html"]'::jsonb),
  ('aws_cloudtrail_no_multi_region_trail', 'Configuration', 'No Multi-Region CloudTrail Trail Exists', 'No multi-region trail is configured, meaning API activity may not be captured in all regions.', 'AWSCloudTrail', '["Create a multi-region trail to capture API calls across all AWS regions."]'::jsonb, '["aws cloudtrail create-trail --name {{resource_name}} --s3-bucket-name my-bucket --is-multi-region-trail"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html"]'::jsonb),
  ('aws_dynamodb_pitr_enabled', 'Configuration', 'DynamoDB Point-in-Time Recovery Should Be Enabled', 'Point-in-time recovery provides continuous backups of your DynamoDB table data.', 'AmazonDynamoDB', '["Enable point-in-time recovery to protect against accidental data loss."]'::jsonb, '["aws dynamodb update-continuous-backups --table-name {{resource_name}} --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery.html"]'::jsonb),
  ('aws_elasticbeanstalk_single_instance', 'Configuration', 'Elastic Beanstalk Single Instance Environment', 'The environment is running on a single instance without load balancing, which is not suitable for production workloads.', 'AWSElasticBeanstalk', '["Use a load-balanced environment for production workloads to ensure high availability."]'::jsonb, '["Rebuild the environment with a load-balanced configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-types.html"]'::jsonb),
  ('aws_elasticbeanstalk_enhanced_health_disabled', 'Configuration', 'Elastic Beanstalk Enhanced Health Reporting Disabled', 'Enhanced health reporting provides detailed health information about instances and the environment.', 'AWSElasticBeanstalk', '["Enable enhanced health reporting for better visibility into environment health."]'::jsonb, '["Update the environment to enable enhanced health reporting in the configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced.html"]'::jsonb),
  ('aws_codeartifact_repository_policy', 'Configuration', 'CodeArtifact Repository Policy Should Be Configured', 'The CodeArtifact repository does not have a resource policy configured to control access.', 'AWSCodeArtifact', '["Configure a resource policy on the repository to control access."]'::jsonb, '["Set a repository permissions policy using the AWS CLI or console."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/codeartifact/latest/ug/repo-policies.html"]'::jsonb),
  ('aws_cloudwatch_log_group_retention', 'Configuration', 'CloudWatch Log Group Retention Should Be Configured', 'Log groups without a retention policy will retain logs indefinitely, increasing storage costs.', 'AmazonCloudWatch', '["Set a retention period for CloudWatch log groups to manage costs."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html"]'::jsonb),
  ('aws_backup_plan_rule_lifecycle', 'Configuration', 'Backup Plan Rule Lifecycle Should Be Configured', 'The backup plan rule does not have a lifecycle configuration for transitioning or expiring backups.', 'AWSBackup', '["Configure lifecycle rules to transition backups to cold storage and expire old backups."]'::jsonb, '["Update the backup plan rule to include lifecycle settings."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/aws-backup/latest/devguide/creating-a-backup-plan.html"]'::jsonb),
  ('aws_backup_plan_has_rules', 'Configuration', 'Backup Plan Should Have Rules', 'The backup plan does not have any backup rules configured.', 'AWSBackup', '["Add at least one backup rule to the backup plan."]'::jsonb, '["Update the backup plan to include backup rules with appropriate schedules."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/aws-backup/latest/devguide/creating-a-backup-plan.html"]'::jsonb),
  ('aws_cloudfront_access_logging', 'Configuration', 'CloudFront Access Logging Should Be Enabled', 'Access logging provides detailed information about every user request that CloudFront receives.', 'AmazonCloudFront', '["Enable access logging for your CloudFront distribution."]'::jsonb, '["Update the distribution to enable logging and specify an S3 bucket for log storage."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html"]'::jsonb),
  ('aws_cloudfront_geo_restriction', 'Configuration', 'CloudFront Geo-Restriction Should Be Configured', 'Geo-restriction allows you to control which countries can access your content.', 'AmazonCloudFront', '["Configure geo-restrictions if your content should only be accessible from specific countries."]'::jsonb, '["Update the distribution to add geo-restriction rules."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/georestrictions.html"]'::jsonb),
  ('aws_xray_sampling_rules_exist', 'Configuration', 'X-Ray Sampling Rules Should Be Configured', 'Custom sampling rules help control the volume of trace data collected.', 'AWSX-Ray', '["Configure sampling rules to control trace data volume and costs."]'::jsonb, '["Create custom sampling rules based on your application needs."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html"]'::jsonb),
  ('aws_ecs_container_insights_disabled', 'Configuration', 'ECS Container Insights Disabled', 'Container Insights provides detailed performance metrics for ECS clusters and services.', 'AmazonECS', '["Enable Container Insights for better visibility into ECS performance."]'::jsonb, '["aws ecs update-cluster-settings --cluster {{recommendation.cluster_name}} --settings name=containerInsights,value=enabled"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-container-insights.html"]'::jsonb),
  ('aws_ecs_avoid_default_cluster', 'Configuration', 'ECS Should Not Use Default Cluster', 'Using the default ECS cluster makes resource management and access control more difficult.', 'AmazonECS', '["Create dedicated ECS clusters for different environments and workloads."]'::jsonb, '["Create a new cluster and migrate services from the default cluster."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create_cluster.html"]'::jsonb),
  ('aws_ecs_service_min_healthy_percent_low', 'Configuration', 'ECS Service Minimum Healthy Percent Too Low', 'The ECS service minimum healthy percent is below 50%, which may impact availability during deployments.', 'AmazonECS', '["Set minimum healthy percent to at least 50% for services with multiple tasks."]'::jsonb, '["minimumHealthyPercent"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_ecs_service_min_healthy_percent_too_low_for_single_task', 'Configuration', 'Single-Task ECS Service Minimum Healthy Percent Below 100%', 'For a single-task service, minimum healthy percent less than 100% can cause downtime during updates.', 'AmazonECS', '["Set minimum healthy percent to 100% for single-task services."]'::jsonb, '["minimumHealthyPercent"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_ecs_service_max_percent_non_standard', 'Configuration', 'ECS Service Maximum Percent Non-Standard', 'The maximum percent deployment configuration is not set to the standard 200%.', 'AmazonECS', '["Review if the non-standard maximum percent is intentional."]'::jsonb, '["maximumPercent"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_ecs_service_health_check_grace_period_zero', 'Configuration', 'ECS Service Health Check Grace Period Is Zero', 'The health check grace period is set to 0, which may cause tasks to be terminated before they finish starting up.', 'AmazonECS', '["Set an appropriate health check grace period."]'::jsonb, '["healthCheckGracePeriodSeconds"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service_definition_parameters.html"]'::jsonb),
  ('aws_ecs_service_exec_logging_disabled', 'Configuration', 'ECS Exec Logging Disabled', 'ECS Exec logging is not configured, meaning exec sessions are not being audited.', 'AmazonECS', '["Enable ECS Exec logging to audit interactive shell sessions."]'::jsonb, '["Configure execute command logging in the cluster settings."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html"]'::jsonb),
  ('aws_ecs_service_connect_disabled', 'Configuration', 'ECS Service Connect Disabled', 'ECS Service Connect is not enabled, which provides simplified service-to-service communication.', 'AmazonECS', '["Consider enabling ECS Service Connect for simplified service mesh capabilities."]'::jsonb, '["Update the service to enable Service Connect with appropriate configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-connect.html"]'::jsonb),
  ('aws_ecs_fargate_task_definition_cpu_undefined', 'Configuration', 'ECS Fargate Task Definition CPU Not Defined', 'The task definition does not have CPU units defined at the task level.', 'AmazonECS', '["Define CPU units in the task definition."]'::jsonb, '["cpu"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_ecs_fargate_task_definition_memory_undefined', 'Configuration', 'ECS Fargate Task Definition Memory Not Defined', 'The task definition does not have memory defined at the task level.', 'AmazonECS', '["Define memory in the task definition."]'::jsonb, '["memory"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_ecs_task_definition_missing_task_role', 'Configuration', 'ECS Task Definition Missing Task Role', 'The task definition does not have an IAM task role assigned.', 'AmazonECS', '["Assign an IAM task role following the principle of least privilege."]'::jsonb, '["taskRoleArn"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html"]'::jsonb),
  ('aws_ecs_task_definition_image_latest_tag', 'Configuration', 'ECS Task Definition Using Latest Image Tag', 'The container image uses the :latest tag, making deployments non-deterministic.', 'AmazonECS', '["Use specific image tags or digests instead of :latest."]'::jsonb, '["Update the container definition to use a specific image tag."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('aws_ecs_task_definition_logging_not_configured', 'Configuration', 'ECS Task Definition Logging Not Configured', 'The container does not have a log driver configured.', 'AmazonECS', '["Configure logging for all containers in the task definition."]'::jsonb, '["logConfiguration"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html"]'::jsonb),
  ('aws_ecs_task_definition_health_check_not_configured', 'Configuration', 'ECS Task Definition Health Check Not Configured', 'The container does not have a health check configured.', 'AmazonECS', '["Configure health checks for containers."]'::jsonb, '["healthCheck"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_healthcheck"]'::jsonb),
  ('aws_ecs_service_review_autoscaling', 'Configuration', 'ECS Service Should Review Autoscaling Configuration', 'The ECS service autoscaling configuration should be reviewed to ensure it meets workload demands.', 'AmazonECS', '["Review and configure autoscaling policies for the ECS service."]'::jsonb, '["Set up Application Auto Scaling with appropriate target tracking or step scaling policies."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html"]'::jsonb),
  ('aws_efs_lifecycle_policy', 'Configuration', 'EFS Lifecycle Policy Should Be Configured', 'A lifecycle policy automatically moves files to the Infrequent Access storage class to reduce costs.', 'AmazonEFS', '["Configure a lifecycle policy to move infrequently accessed files to IA storage."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/efs/latest/ug/lifecycle-management-efs.html"]'::jsonb),
  ('aws_sns_delivery_status_logging', 'Configuration', 'SNS Topic Delivery Status Logging Should Be Enabled', 'Delivery status logging helps track the delivery status of messages published to the topic.', 'AmazonSNS', '["Enable delivery status logging for the SNS topic."]'::jsonb, '["Configure delivery status logging attributes on the SNS topic."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sns/latest/dg/sns-topic-attributes.html"]'::jsonb),
  ('aws_ses_identity_dkim', 'Configuration', 'SES Identity DKIM Should Be Configured', 'DKIM signing adds a digital signature to outgoing emails, improving deliverability and authentication.', 'AmazonSES', '["Enable DKIM signing for all SES identities."]'::jsonb, '["\n**Configure DKIM for the identity:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/ses/latest/dg/send-email-authentication-dkim.html"]'::jsonb),
  ('aws_ses_identity_mail_from_domain', 'Configuration', 'SES Identity Mail From Domain Should Be Configured', 'Configuring a custom MAIL FROM domain improves email deliverability and sender reputation.', 'AmazonSES', '["Configure a custom MAIL FROM domain for the SES identity."]'::jsonb, '["Set the MAIL FROM domain in the SES identity configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/ses/latest/dg/mail-from.html"]'::jsonb),
  ('aws_ses_identity_notifications', 'Configuration', 'SES Identity Notifications Should Be Configured', 'Notification configuration ensures you are alerted about bounces, complaints, and delivery issues.', 'AmazonSES', '["Configure SNS notifications for bounces and complaints on SES identities."]'::jsonb, '["Set up notification topics for the SES identity."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/ses/latest/dg/monitor-sending-activity.html"]'::jsonb),
  ('aws_ses_configset_event_destinations', 'Configuration', 'SES Configuration Set Should Have Event Destinations', 'Event destinations allow you to publish email sending events to CloudWatch, Kinesis, or SNS.', 'AmazonSES', '["Configure event destinations for your SES configuration sets."]'::jsonb, '["Add event destinations to the configuration set."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/ses/latest/dg/event-publishing.html"]'::jsonb),
  ('aws_config_recorder_not_recording', 'Configuration', 'AWS Config Recorder Not Recording', 'The AWS Config recorder is not actively recording resource changes.', 'AWSConfig', '["Start the Config recorder to track resource configuration changes."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/stop-start-recorder.html"]'::jsonb),
  ('aws_config_no_delivery_channel', 'Configuration', 'AWS Config No Delivery Channel', 'No delivery channel is configured for AWS Config, so configuration snapshots cannot be delivered.', 'AWSConfig', '["Create a delivery channel for AWS Config."]'::jsonb, '["Configure a delivery channel with an S3 bucket."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/manage-delivery-channel.html"]'::jsonb),
  ('aws_config_not_recording_all_resources', 'Configuration', 'AWS Config Not Recording All Resources', 'AWS Config is not configured to record all resource types.', 'AWSConfig', '["Configure the Config recorder to record all supported resource types."]'::jsonb, '["Update the recording group to include all resource types."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/select-resources.html"]'::jsonb),
  ('aws_config_rule_non_compliant', 'Configuration', 'AWS Config Rule Non-Compliant', 'One or more AWS Config rules have non-compliant resources.', 'AWSConfig', '["Review and remediate non-compliant resources."]'::jsonb, '["Review the non-compliant resources and apply remediation actions."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config.html"]'::jsonb),
  ('aws_config_rule_evaluation_error', 'Configuration', 'AWS Config Rule Evaluation Error', 'An AWS Config rule has evaluation errors, meaning it cannot properly assess compliance.', 'AWSConfig', '["Investigate and fix the rule evaluation error."]'::jsonb, '["Check the rule permissions and configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config.html"]'::jsonb),
  ('aws_config_conformance_pack_non_compliant', 'Configuration', 'AWS Config Conformance Pack Non-Compliant', 'A Config conformance pack has non-compliant rules.', 'AWSConfig', '["Review and remediate non-compliant rules in the conformance pack."]'::jsonb, '["Address the specific non-compliant rules within the conformance pack."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/conformance-packs.html"]'::jsonb),
  ('aws_config_not_enabled', 'Configuration', 'AWS Config Not Enabled', 'AWS Config is not enabled in this region. AWS Config provides a detailed inventory of your AWS resources and their configurations, records configuration changes, and evaluates resource configurations against desired settings for compliance auditing.', 'AWSConfig', '["Enable AWS Config to track resource configuration changes and compliance."]'::jsonb, '["Set up AWS Config with a recorder, delivery channel, and appropriate rules."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/config/latest/developerguide/getting-started.html"]'::jsonb),
  ('aws_sqs_dlq_configured', 'Configuration', 'SQS Dead Letter Queue Should Be Configured', 'A dead letter queue captures messages that cannot be processed successfully for later analysis.', 'AmazonSQS', '["Configure a dead letter queue for your SQS queues to handle failed messages."]'::jsonb, '["RedrivePolicy", "maxReceiveCount"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html"]'::jsonb),
  ('aws_bedrock_invocation_logging_check_failed', 'Configuration', 'Bedrock Invocation Logging Check Failed', 'Unable to verify if invocation logging is enabled for Amazon Bedrock.', 'AmazonBedrock', '["Verify that invocation logging is properly configured for Bedrock."]'::jsonb, '["Configure invocation logging in the Bedrock console or via API."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html"]'::jsonb),
  ('aws_bedrock_invocation_logging_enabled', 'Configuration', 'Bedrock Invocation Logging Should Be Enabled', 'Invocation logging captures details about model invocations for auditing and debugging.', 'AmazonBedrock', '["Enable invocation logging for Amazon Bedrock to track model usage."]'::jsonb, '["Configure invocation logging with S3 or CloudWatch Logs as the destination."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html"]'::jsonb),
  ('aws_ssm_instance_offline', 'Configuration', 'SSM Managed Instance Offline', 'The SSM-managed instance is not reporting to Systems Manager.', 'AWSSystemsManager', '["Investigate why the instance is not communicating with Systems Manager."]'::jsonb, '["Verify the SSM agent is running and the instance has appropriate IAM permissions and network connectivity."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/systems-manager/latest/userguide/fleet-manager.html"]'::jsonb),
  ('aws_ssm_missing_patches', 'Configuration', 'SSM Instance Has Missing Patches', 'The instance has patches that have not been applied per the patch baseline.', 'AWSSystemsManager', '["Apply missing patches to maintain security compliance."]'::jsonb, '["\n**Run a patch operation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/systems-manager/latest/userguide/patch-manager.html"]'::jsonb),
  ('aws_ssm_no_associations', 'Configuration', 'SSM Instance Has No Associations', 'The instance has no SSM State Manager associations configured.', 'AWSSystemsManager', '["Configure SSM associations for automated management tasks."]'::jsonb, '["Create associations for patch management, inventory collection, or other management tasks."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-associations.html"]'::jsonb),
  ('aws_ssm_outdated_agent', 'Configuration', 'SSM Agent Is Outdated', 'The SSM agent on the instance is not the latest version.', 'AWSSystemsManager', '["Update the SSM agent to the latest version."]'::jsonb, '["\n**Update via SSM:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html"]'::jsonb),
  ('aws_ssm_maintenance_window_disabled', 'Configuration', 'SSM Maintenance Window Disabled', 'The maintenance window is disabled, so scheduled tasks will not execute.', 'AWSSystemsManager', '["Enable the maintenance window if scheduled maintenance tasks are needed."]'::jsonb, '["Enable the maintenance window via console or CLI."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-maintenance.html"]'::jsonb),
  ('gcp_gke_no_labels', 'Configuration', 'GKE Cluster Has No Labels', 'The GKE cluster does not have labels for resource organization and cost tracking.', 'GKE', '["Add labels to GKE clusters for better organization, cost allocation, and management."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/creating-managing-labels"]'::jsonb),
  ('gcp_gke_no_autoscaling', 'Configuration', 'GKE Node Pool Autoscaling Disabled', 'The GKE node pool does not have autoscaling enabled.', 'GKE', '["Enable cluster autoscaler to automatically adjust the number of nodes based on workload."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler"]'::jsonb),
  ('gcp_gke_no_binary_authorization', 'Configuration', 'GKE Binary Authorization Disabled', 'Binary Authorization is not enabled, so container image deployments are not verified.', 'GKE', '["Enable Binary Authorization to ensure only trusted container images are deployed."]'::jsonb, '["Enable Binary Authorization in the cluster configuration."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/binary-authorization/docs/overview"]'::jsonb),
  ('gcp_gke_no_network_policy', 'Configuration', 'GKE Network Policy Disabled', 'Network policy enforcement is not enabled on the GKE cluster.', 'GKE', '["Enable network policy enforcement to control pod-to-pod communication."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/network-policy"]'::jsonb),
  ('gcp_gke_no_maintenance_window', 'Configuration', 'GKE No Maintenance Window Configured', 'No maintenance window is configured for the GKE cluster.', 'GKE', '["Configure a maintenance window to control when cluster upgrades occur."]'::jsonb, '["\n**Set a maintenance window:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/maintenance-windows-and-exclusions"]'::jsonb),
  ('gcp_gke_no_workload_identity', 'Configuration', 'GKE Workload Identity Disabled', 'Workload Identity is not enabled, which is the recommended way for pods to access Google Cloud services.', 'GKE', '["Enable Workload Identity for secure pod-to-GCP-service authentication."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity"]'::jsonb),
  ('gcp_gke_logging_disabled', 'Configuration', 'GKE Logging Disabled', 'Cloud Logging is not enabled for this GKE cluster. Without logging, critical cluster events, pod logs, and system component logs are not captured, making troubleshooting and security monitoring impossible.', 'GKE', '["Enable Cloud Logging for the GKE cluster for monitoring and troubleshooting."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/logging"]'::jsonb),
  ('gcp_gke_monitoring_disabled', 'Configuration', 'GKE Monitoring Disabled', 'Cloud Monitoring is not enabled for the GKE cluster.', 'GKE', '["Enable Cloud Monitoring for the GKE cluster for performance insights."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/monitoring"]'::jsonb),
  ('gcp_function_no_labels', 'Configuration', 'Cloud Function Has No Labels', 'The Cloud Function does not have labels for organization and cost tracking.', 'CloudFunctions', '["Add labels to Cloud Functions for better resource management."]'::jsonb, '["Update the function with labels via console or CLI."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/functions/docs/configuring"]'::jsonb),
  ('gcp_pubsub_no_dead_letter', 'Configuration', 'Pub/Sub Subscription Has No Dead Letter Topic', 'The subscription does not have a dead letter topic configured for handling undeliverable messages.', 'CloudPubSub', '["Configure a dead letter topic to capture messages that cannot be processed."]'::jsonb, '["Update the subscription to add a dead letter policy."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/pubsub/docs/dead-letter-topics"]'::jsonb),
  ('gcp_pubsub_long_retention', 'Configuration', 'Pub/Sub Subscription Has Long Retention Period', 'The subscription has an unusually long message retention period which may increase costs.', 'CloudPubSub', '["Review if the long retention period is necessary and reduce if possible."]'::jsonb, '["Update the subscription retention duration."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/pubsub/docs/subscriber"]'::jsonb),
  ('gcp_pubsub_retain_acked', 'Configuration', 'Pub/Sub Subscription Retains Acknowledged Messages', 'The subscription is configured to retain acknowledged messages, increasing storage costs.', 'CloudPubSub', '["Review if retaining acknowledged messages is necessary."]'::jsonb, '["Disable retain_acked_messages if not needed."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/pubsub/docs/subscriber"]'::jsonb),
  ('gcp_bigquery_dataset_no_labels', 'Configuration', 'BigQuery Dataset Has No Labels', 'The BigQuery dataset does not have labels for organization and cost tracking.', 'BigQuery', '["Add labels to BigQuery datasets for better resource management."]'::jsonb, '["Update the dataset with labels via console or CLI."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/adding-labels"]'::jsonb),
  ('gcp_bigquery_table_no_labels', 'Configuration', 'BigQuery Table Has No Labels', 'The BigQuery table does not have labels applied. Labels are key-value pairs used for organizing, filtering, and tracking costs across Google Cloud resources.', 'BigQuery', '["Add labels to BigQuery tables for organization."]'::jsonb, '["Update the table with labels."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/adding-labels"]'::jsonb),
  ('gcp_bigquery_table_no_expiration', 'Configuration', 'BigQuery Table Has No Expiration', 'The table does not have an expiration time set, which may lead to accumulating unused data.', 'BigQuery', '["Set a table expiration for temporary or time-limited data."]'::jsonb, '["\nSet the table expiration using\n\\", "\\", "\\", "\n.\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/table-expiration-times"]'::jsonb),
  ('gcp_bigquery_dataset_no_default_expiration', 'Configuration', 'BigQuery Dataset Has No Default Table Expiration', 'The dataset does not have a default table expiration configured.', 'BigQuery', '["Set a default table expiration for the dataset to automatically clean up old tables."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/table-expiration-times"]'::jsonb),
  ('gcp_bigquery_table_no_partitioning', 'Configuration', 'BigQuery Table Not Partitioned', 'The table is not partitioned, which can lead to higher query costs and slower performance.', 'BigQuery', '["Use table partitioning to improve query performance and reduce costs."]'::jsonb, '["Recreate the table with partitioning (e.g., by ingestion time or a date column)."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/partitioned-tables"]'::jsonb),
  ('gcp_bigquery_table_no_clustering', 'Configuration', 'BigQuery Table Not Clustered', 'The table is not clustered, which can lead to less efficient queries.', 'BigQuery', '["Use clustering on frequently filtered or aggregated columns to improve performance."]'::jsonb, '["Recreate the table with clustering on appropriate columns."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/clustered-tables"]'::jsonb),
  ('gcp_run_no_labels', 'Configuration', 'Cloud Run Service Has No Labels', 'The Cloud Run service does not have labels for organization.', 'CloudRun', '["Add labels to Cloud Run services for better management."]'::jsonb, '["Update the service with labels."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/run/docs/configuring/labels"]'::jsonb),
  ('gcp_run_always_on', 'Configuration', 'Cloud Run Service Always On', 'The service has minimum instances set above 0, meaning it is always running and incurring costs.', 'CloudRun', '["Review if always-on is necessary. Set min instances to 0 if cold starts are acceptable."]'::jsonb, '["Update the service to set min instances to 0 for cost savings."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/run/docs/configuring/cpu-allocation"]'::jsonb),
  ('gcp_run_not_ready', 'Configuration', 'Cloud Run Service Not Ready', 'The Cloud Run service is not in a ready state. This may indicate deployment failures, container startup issues, or configuration problems that prevent the service from handling traffic.', 'CloudRun', '["Investigate why the service is not ready and resolve deployment issues."]'::jsonb, '["Check service logs and deployment status for errors."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/run/docs/managing/services"]'::jsonb),
  ('gcp_compute_no_labels', 'Configuration', 'Compute Instance Has No Labels', 'The Compute Engine instance does not have labels for organization.', 'ComputeEngine', '["Add labels to instances for resource management and cost tracking."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/compute/docs/labeling-resources"]'::jsonb),
  ('gcp_sql_no_labels', 'Configuration', 'Cloud SQL Instance Has No Labels', 'The Cloud SQL instance does not have labels applied. Labels help organize resources, track costs, and enforce governance policies across your GCP environment.', 'CloudSQL', '["Add labels for organization and cost tracking."]'::jsonb, '["Update the instance with labels via console or CLI."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/label-instance"]'::jsonb),
  ('gcp_sql_no_backup', 'Configuration', 'Cloud SQL Automated Backup Disabled', 'Automated backups are not enabled for the Cloud SQL instance.', 'CloudSQL', '["Enable automated backups to protect against data loss."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/backup-recovery/backups"]'::jsonb),
  ('gcp_sql_no_ha', 'Configuration', 'Cloud SQL High Availability Disabled', 'The Cloud SQL instance does not have high availability configured.', 'CloudSQL', '["Enable high availability for production databases."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/high-availability"]'::jsonb),
  ('gcp_lb_backend_no_health_check', 'Configuration', 'Load Balancer Backend Has No Health Check', 'The backend service does not have a health check configured.', 'LoadBalancing', '["Configure a health check for the backend service."]'::jsonb, '["Create and attach a health check to the backend service."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/load-balancing/docs/health-check-concepts"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('gcp_lb_backend_no_backends', 'Configuration', 'Load Balancer Backend Has No Backend Instances', 'The backend service has no backend instance groups or NEGs attached.', 'LoadBalancing', '["Attach backend instances to the backend service."]'::jsonb, '["Add instance groups or network endpoint groups to the backend service."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/load-balancing/docs/backend-service"]'::jsonb),
  ('gcp_lb_no_labels', 'Configuration', 'Load Balancer Forwarding Rule Has No Labels', 'The GCP load balancer forwarding rule does not have labels applied. Labels help identify and organize networking resources for cost tracking and governance.', 'LoadBalancing', '["Add labels for resource organization."]'::jsonb, '["Update the forwarding rule with labels."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/compute/docs/labeling-resources"]'::jsonb),
  ('gcp_storage_no_labels', 'Configuration', 'Cloud Storage Bucket Has No Labels', 'The storage bucket does not have labels for organization.', 'CloudStorage', '["Add labels to buckets for better management and cost tracking."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/tags-and-labels"]'::jsonb),
  ('gcp_storage_no_versioning', 'Configuration', 'Cloud Storage Versioning Disabled', 'Object versioning is not enabled, so deleted or overwritten objects cannot be recovered.', 'CloudStorage', '["Enable versioning to protect against accidental deletion or overwrite."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/object-versioning"]'::jsonb),
  ('gcp_storage_no_lifecycle', 'Configuration', 'Cloud Storage No Lifecycle Policy', 'The bucket does not have a lifecycle policy to manage object lifecycle.', 'CloudStorage', '["Configure lifecycle rules to automatically delete or transition old objects."]'::jsonb, '["\nSet lifecycle rules via console or\n\\", "\\", "\\", "\n.\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/lifecycle"]'::jsonb),
  ('gcp_storage_no_logging', 'Configuration', 'Cloud Storage Access Logging Disabled', 'Access logging is not enabled for the storage bucket.', 'CloudStorage', '["Enable access logging to track bucket access for auditing."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/access-logs"]'::jsonb),
  ('azure_missing_tags', 'Configuration', 'Azure Resource Missing Tags', 'The Azure resource does not have tags for organization, cost tracking, and management.', 'Azure', '["Add tags to all resources for better organization and cost management."]'::jsonb, '["\n**Add tags via Azure CLI:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources"]'::jsonb),
  ('azure_monitor_alert_rule_disabled', 'Configuration', 'Azure Monitor Alert Rule Disabled', 'An Azure Monitor alert rule is disabled and will not trigger alerts.', 'AzureMonitor', '["Enable the alert rule or remove it if no longer needed."]'::jsonb, '["Enable the alert rule via Azure portal or CLI."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-manage-alert-rules"]'::jsonb),
  ('azure_monitor_alert_no_action_group', 'Configuration', 'Azure Monitor Alert Has No Action Group', 'The alert rule does not have an action group configured for notifications.', 'AzureMonitor', '["Attach an action group to receive notifications when the alert fires."]'::jsonb, '["Update the alert rule to include an action group."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_monitor_action_group_disabled', 'Configuration', 'Azure Monitor Action Group Disabled', 'The action group is disabled and will not send notifications.', 'AzureMonitor', '["Enable the action group or remove it if no longer needed."]'::jsonb, '["Enable the action group via Azure portal."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_monitor_action_group_no_receivers', 'Configuration', 'Azure Monitor Action Group Has No Receivers', 'The action group does not have any notification receivers configured.', 'AzureMonitor', '["Add at least one receiver (email, SMS, webhook, etc.) to the action group."]'::jsonb, '["Update the action group to add notification receivers."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_monitor_no_action_groups', 'Configuration', 'No Azure Monitor Action Groups Configured', 'No action groups are configured in the subscription for alert notifications.', 'AzureMonitor', '["Create action groups to receive alert notifications."]'::jsonb, '["Create an action group with appropriate notification receivers."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_monitor_no_alert_rules', 'Configuration', 'No Azure Monitor Alert Rules Configured', 'No Azure Monitor alert rules are configured. Without alert rules, critical issues such as high CPU, memory pressure, or service failures will not trigger notifications.', 'AzureMonitor', '["Create alert rules to monitor critical resources and metrics."]'::jsonb, '["Set up alert rules for important metrics and log conditions."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-overview"]'::jsonb),
  ('azure_cosmosdb_automatic_failover_disabled', 'Configuration', 'Cosmos DB Automatic Failover Disabled', 'Automatic failover is not enabled for the Cosmos DB account.', 'AzureCosmosDB', '["Enable automatic failover for high availability."]'::jsonb, '["Enable automatic failover in the Cosmos DB account settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/cosmos-db/high-availability"]'::jsonb),
  ('azure_cosmosdb_single_region', 'Configuration', 'Cosmos DB Single Region Deployment', 'The Cosmos DB account is deployed in a single region without geo-replication.', 'AzureCosmosDB', '["Add additional read regions for high availability and disaster recovery."]'::jsonb, '["Add geo-replicated regions in the Cosmos DB account configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/cosmos-db/distribute-data-globally"]'::jsonb),
  ('azure_recovery_vault_soft_delete_disabled', 'Configuration', 'Recovery Vault Soft Delete Disabled', 'Soft delete is not enabled, so deleted backup data cannot be recovered.', 'AzureRecoveryServices', '["Enable soft delete to protect against accidental deletion of backups."]'::jsonb, '["Enable soft delete in the Recovery Services vault settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/backup/backup-azure-security-feature-cloud"]'::jsonb),
  ('azure_recovery_vault_lrs_storage', 'Configuration', 'Recovery Vault Using LRS Storage', 'The Recovery Services vault is using Locally Redundant Storage instead of Geo-Redundant Storage.', 'AzureRecoveryServices', '["Consider using GRS for production vaults to protect against regional outages."]'::jsonb, '["Update the vault storage replication type to GRS."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/backup/backup-create-recovery-services-vault"]'::jsonb),
  ('azure_sql_geo_redundant_backups_disabled', 'Configuration', 'Azure SQL Geo-Redundant Backups Disabled', 'Geo-redundant backups are not enabled for the SQL database.', 'AzureSQL', '["Enable geo-redundant backups for disaster recovery."]'::jsonb, '["Update the database backup settings to enable geo-redundancy."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/automated-backups-overview"]'::jsonb),
  ('azure_sql_long_term_retention_not_configured', 'Configuration', 'Azure SQL Long-Term Retention Not Configured', 'Long-term backup retention is not configured for the SQL database.', 'AzureSQL', '["Configure long-term retention to keep backups beyond the default retention period."]'::jsonb, '["Set up long-term retention policies in the database backup configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/long-term-retention-overview"]'::jsonb),
  ('azure_sql_storage_auto_growth_disabled', 'Configuration', 'Azure SQL Storage Auto-Growth Disabled', 'Automatic storage growth is not enabled, which may cause the database to run out of space.', 'AzureSQL', '["Enable automatic storage growth for the database."]'::jsonb, '["Enable auto-grow in the database server configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/resource-limits-logical-server"]'::jsonb),
  ('azure_postgres_backup_disabled', 'Configuration', 'Azure PostgreSQL Backup Disabled', 'Backup is not properly configured for the PostgreSQL server.', 'AzurePostgreSQL', '["Ensure backups are enabled and configured with appropriate retention."]'::jsonb, '["Configure backup settings for the PostgreSQL server."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-backup-restore"]'::jsonb),
  ('azure_postgres_server_stopped', 'Configuration', 'Azure PostgreSQL Server Stopped', 'The Azure Database for PostgreSQL server is in a stopped state. Stopped servers still incur storage charges. If the server is no longer needed, consider deleting it to eliminate costs.', 'AzurePostgreSQL', '["Review if the server should be running. Stopped servers may still incur storage costs."]'::jsonb, '["Start the server if needed, or delete it if no longer required."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-stop-start-server-portal"]'::jsonb),
  ('azure_mysql_backup_disabled', 'Configuration', 'Azure MySQL Backup Disabled', 'Backup is not properly configured for the MySQL server.', 'AzureMySQL', '["Ensure backups are enabled with appropriate retention."]'::jsonb, '["Configure backup settings for the MySQL server."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/mysql/flexible-server/concepts-backup-restore"]'::jsonb),
  ('azure_mysql_server_stopped', 'Configuration', 'Azure MySQL Server Stopped', 'The Azure Database for MySQL server is in a stopped state. Stopped servers still incur storage charges. If the server is no longer needed, consider deleting it to eliminate costs.', 'AzureMySQL', '["Review if the server should be running."]'::jsonb, '["Start the server or delete it if no longer required."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-stop-start-server"]'::jsonb),
  ('azure_mariadb_backup_disabled', 'Configuration', 'Azure MariaDB Backup Disabled', 'Backup is not properly configured for the MariaDB server.', 'AzureMariaDB', '["Ensure backups are enabled with appropriate retention."]'::jsonb, '["Configure backup settings for the MariaDB server."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/mariadb/concepts-backup"]'::jsonb),
  ('azure_mariadb_server_stopped', 'Configuration', 'Azure MariaDB Server Stopped', 'The Azure Database for MariaDB server is in a stopped state. Stopped servers still incur storage charges. If the server is no longer needed, consider deleting it.', 'AzureMariaDB', '["Review if the server should be running."]'::jsonb, '["Start the server or delete it if no longer required."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/mariadb/howto-stop-start-server"]'::jsonb),
  ('azure_load_balancer_no_health_probes', 'Configuration', 'Azure Load Balancer Has No Health Probes', 'The load balancer does not have health probes configured.', 'AzureLoadBalancer', '["Configure health probes to detect unhealthy backend instances."]'::jsonb, '["Add health probes to the load balancer configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-custom-probe-overview"]'::jsonb),
  ('azure_load_balancer_no_outbound_rules', 'Configuration', 'Azure Load Balancer Has No Outbound Rules', 'The load balancer does not have outbound rules for SNAT.', 'AzureLoadBalancer', '["Configure outbound rules for backend pool outbound connectivity."]'::jsonb, '["Add outbound rules to the load balancer."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/load-balancer/outbound-rules"]'::jsonb),
  ('azure_load_balancer_basic_sku', 'Configuration', 'Azure Load Balancer Using Basic SKU', 'The load balancer is using the Basic SKU which has limited features and will be retired.', 'AzureLoadBalancer', '["Upgrade to Standard SKU for better features and SLA."]'::jsonb, '["Migrate to a Standard SKU load balancer."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/load-balancer/skus"]'::jsonb),
  ('azure_vmss_automatic_instance_repairs_disabled', 'Configuration', 'VMSS Automatic Instance Repairs Disabled', 'Automatic instance repairs are not enabled for the VM scale set.', 'AzureVMSS', '["Enable automatic instance repairs to replace unhealthy instances automatically."]'::jsonb, '["Enable the automatic repairs policy on the scale set."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-automatic-instance-repairs"]'::jsonb),
  ('azure_vmss_not_zone_redundant', 'Configuration', 'VMSS Not Zone Redundant', 'The VM scale set is not deployed across availability zones.', 'AzureVMSS', '["Deploy across availability zones for high availability."]'::jsonb, '["Recreate the scale set with zone distribution."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-availability-zones"]'::jsonb),
  ('azure_vmss_boot_diagnostics_disabled', 'Configuration', 'VMSS Boot Diagnostics Disabled', 'Boot diagnostics is not enabled for the VM scale set.', 'AzureVMSS', '["Enable boot diagnostics for troubleshooting VM startup issues."]'::jsonb, '["Enable boot diagnostics in the scale set configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/boot-diagnostics"]'::jsonb),
  ('azure_vmss_automatic_os_upgrade_disabled', 'Configuration', 'VMSS Automatic OS Upgrade Disabled', 'Automatic OS image upgrades are not enabled for this VM Scale Set. Without automatic upgrades, VMSS instances may run outdated OS images with known vulnerabilities.', 'AzureVMSS', '["Enable automatic OS upgrades to keep instances up to date."]'::jsonb, '["Enable the automatic OS upgrade policy on the scale set."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-automatic-upgrade"]'::jsonb),
  ('azure_vmss_manual_upgrade_policy', 'Configuration', 'VMSS Using Manual Upgrade Policy', 'The VM scale set uses a manual upgrade policy, requiring manual intervention for updates.', 'AzureVMSS', '["Consider using automatic or rolling upgrade policy for smoother updates."]'::jsonb, '["Update the scale set upgrade policy to Rolling or Automatic."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-policy"]'::jsonb),
  ('azure_vmss_application_health_extension_missing', 'Configuration', 'VMSS Application Health Extension Missing', 'The application health extension is not installed on the VM scale set.', 'AzureVMSS', '["Install the application health extension for health monitoring."]'::jsonb, '["Add the application health extension to the scale set model."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-health-extension"]'::jsonb),
  ('azure_policy_assignment_not_enforced', 'Configuration', 'Azure Policy Assignment Not Enforced', 'The policy assignment enforcement mode is set to DoNotEnforce.', 'AzurePolicy', '["Set the enforcement mode to Default for production environments."]'::jsonb, '["Update the policy assignment enforcement mode."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/governance/policy/concepts/assignment-structure"]'::jsonb),
  ('azure_policy_no_assignments', 'Configuration', 'No Azure Policy Assignments', 'No policy assignments are configured in the subscription.', 'AzurePolicy', '["Create policy assignments to enforce governance standards."]'::jsonb, '["Assign built-in or custom policies to enforce compliance."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/governance/policy/overview"]'::jsonb),
  ('azure_arc_machine_disconnected', 'Configuration', 'Azure Arc Machine Disconnected', 'The Azure Arc-enabled machine is disconnected from Azure.', 'AzureArc', '["Investigate why the machine is disconnected and restore connectivity."]'::jsonb, '["Check the Azure Connected Machine agent status on the machine."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-arc/servers/troubleshoot-agent-onboard"]'::jsonb),
  ('azure_arc_outdated_agent', 'Configuration', 'Azure Arc Agent Outdated', 'The Azure Connected Machine agent is not the latest version.', 'AzureArc', '["Update the agent to the latest version."]'::jsonb, '["Update the agent using the built-in update mechanism."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-arc/servers/manage-agent"]'::jsonb),
  ('azure_arc_machine_stale_status', 'Configuration', 'Azure Arc Machine Has Stale Status', 'The Azure Arc-enabled machine has not reported its status recently. This may indicate network connectivity issues, agent problems, or that the machine has been decommissioned.', 'AzureArc', '["Investigate the machine connectivity and agent health."]'::jsonb, '["Check the machine network connectivity and restart the agent if needed."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-arc/servers/manage-agent"]'::jsonb),
  ('aws_ecr_public_tag_immutable', 'Configuration', 'ECR Public Repository Image Tags Should Be Immutable', 'Amazon ECR Public repository image tags should be configured as immutable to prevent image tags from being overwritten. Immutable tags ensure that each image tag uniquely identifies a specific image version, preventing supply chain attacks through tag manipulation.', 'AmazonECR', '["Enable image tag immutability for all ECR Public repositories to prevent image tags from being overwritten. This ensures that once an image is pushed with a specific tag, the tag cannot be reassigned to a different image digest."]'::jsonb, '["Update the ECR Public repository to enable image tag immutability:\n\\", "\\", "\\", "\n\nAlternatively, recreate the repository with immutable tags enabled:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://docs.aws.amazon.com/AmazonECR/latest/public/public-repository-edit.html"]'::jsonb),
  ('aws_ecs_service_autoscaling_disabled', 'Configuration', 'ECS Service Auto Scaling Should Be Enabled', 'Amazon ECS services should have auto scaling configured to automatically adjust the desired count of tasks in response to demand changes. Without auto scaling, services cannot dynamically respond to traffic patterns, potentially leading to over-provisioning (wasted cost) or under-provisioning (degraded performance).', 'AmazonECS', '["Configure Application Auto Scaling for the ECS service to automatically adjust task count based on CloudWatch metrics such as CPU utilization, memory utilization, or custom metrics. Set appropriate minimum and maximum capacity limits."]'::jsonb, '["Register the ECS service as a scalable target and create a scaling policy:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html"]'::jsonb),
  ('azure_activity_log_alert_broad_scope', 'Configuration', 'Azure Activity Log Alert Has Overly Broad Scope', 'The Activity Log Alert is scoped to the entire subscription rather than specific resource groups, which may generate excessive noise.', 'ActivityLogAlerts', '["The Activity Log Alert is scoped to the entire subscription rather than specific resource groups, which may generate excessive noise."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log"]'::jsonb),
  ('azure_activity_log_alert_disabled', 'Configuration', 'Azure Activity Log Alert Is Disabled', 'An Activity Log Alert is disabled and will not trigger notifications for matching events.', 'ActivityLogAlerts', '["An Activity Log Alert is disabled and will not trigger notifications for matching events."]'::jsonb, '["Enable Activity Log Alert through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log"]'::jsonb),
  ('azure_activity_log_alert_empty_condition', 'Configuration', 'Azure Activity Log Alert Has Empty Condition', 'The Activity Log Alert has no conditions configured, making it ineffective at filtering events.', 'ActivityLogAlerts', '["The Activity Log Alert has no conditions configured, making it ineffective at filtering events."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log"]'::jsonb),
  ('azure_activity_log_alert_missing_tags', 'Configuration', 'Azure Activity Log Alert Should Have Tags', 'The Activity Log Alert has no tags for organization and cost tracking.', 'ActivityLogAlerts', '["The Activity Log Alert has no tags for organization and cost tracking."]'::jsonb, '["Configure Activity Log Alert Tags through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["APRA", "MAS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources"]'::jsonb),
  ('azure_activity_log_alert_no_action_group', 'Configuration', 'Azure Activity Log Alert Has No Action Group', 'The Activity Log Alert has no action group configured, so no notifications will be sent when triggered.', 'ActivityLogAlerts', '["The Activity Log Alert has no action group configured, so no notifications will be sent when triggered."]'::jsonb, '["Configure Activity Log Alert Action Group through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_activity_log_alert_no_conditions', 'Configuration', 'Azure Activity Log Alert Has No Conditions', 'The Activity Log Alert has no filter conditions, meaning it will match all events.', 'ActivityLogAlerts', '["The Activity Log Alert has no filter conditions, meaning it will match all events."]'::jsonb, '["Configure Activity Log Alert Conditions through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log"]'::jsonb),
  ('azure_activity_log_alert_no_scopes', 'Configuration', 'Azure Activity Log Alert Has No Scopes', 'The Activity Log Alert has no scopes defined, making it inactive.', 'ActivityLogAlerts', '["The Activity Log Alert has no scopes defined, making it inactive."]'::jsonb, '["Configure Activity Log Alert Scopes through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log"]'::jsonb),
  ('azure_appgateway_http2_disabled', 'Configuration', 'Azure Application Gateway HTTP/2 Should Be Enabled', 'HTTP/2 is not enabled on the Application Gateway, missing performance improvements.', 'ApplicationGateway', '["HTTP/2 is not enabled on the Application Gateway, missing performance improvements."]'::jsonb, '["Enable Application Gateway HTTP/2 through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/application-gateway/configuration-listeners"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('azure_container_app_low_min_replicas', 'Configuration', 'Azure Container App Minimum Replicas Should Be Increased', 'The Container App has very low minimum replicas, which may cause cold start latency during scale-up.', 'ContainerApps', '["The Container App has very low minimum replicas, which may cause cold start latency during scale-up."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-apps/scale-app"]'::jsonb),
  ('azure_container_app_missing_tags', 'Configuration', 'Azure Container App Should Have Tags', 'The Container App has no tags for organization and cost tracking.', 'ContainerApps', '["The Container App has no tags for organization and cost tracking."]'::jsonb, '["Configure Container App Tags through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["APRA", "MAS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources"]'::jsonb),
  ('azure_container_registry_soft_delete_disabled', 'Configuration', 'Azure Container Registry Soft Delete Should Be Enabled', 'Soft delete is not enabled, meaning deleted artifacts cannot be recovered.', 'ContainerRegistry', '["Soft delete is not enabled, meaning deleted artifacts cannot be recovered."]'::jsonb, '["Enable Container Registry Soft Delete through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-soft-delete-policy"]'::jsonb),
  ('azure_container_registry_zone_redundancy_disabled', 'Configuration', 'Azure Container Registry Zone Redundancy Should Be Enabled', 'Zone redundancy is not enabled, making the registry vulnerable to zonal outages.', 'ContainerRegistry', '["Zone redundancy is not enabled, making the registry vulnerable to zonal outages."]'::jsonb, '["Enable Container Registry Zone Redundancy through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/zone-redundancy"]'::jsonb),
  ('azure_devops_no_pipelines', 'Configuration', 'Azure DevOps Project Has No Pipelines', 'The Azure DevOps project has no CI/CD pipelines configured.', 'AzureDevOps', '["The Azure DevOps project has no CI/CD pipelines configured."]'::jsonb, '["Configure DevOps Project Pipelines through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/pipelines/get-started/what-is-azure-pipelines"]'::jsonb),
  ('azure_devops_project_no_description', 'Configuration', 'Azure DevOps Project Has No Description', 'The project lacks a description, making it harder for team members to understand its purpose.', 'AzureDevOps', '["The project lacks a description, making it harder for team members to understand its purpose."]'::jsonb, '["Configure DevOps Project Description through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/organizations/projects/create-project"]'::jsonb),
  ('azure_devops_repository_disabled', 'Configuration', 'Azure DevOps Repository Is Disabled', 'A repository in the project is disabled and not accessible.', 'AzureDevOps', '["A repository in the project is disabled and not accessible."]'::jsonb, '["Enable DevOps Repository through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/repos/git/manage-repos"]'::jsonb),
  ('azure_devops_repository_large_size', 'Configuration', 'Azure DevOps Repository Size Is Very Large', 'The repository size is unusually large, which may impact clone and fetch performance.', 'AzureDevOps', '["The repository size is unusually large, which may impact clone and fetch performance."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/repos/git/manage-large-files"]'::jsonb),
  ('azure_eventgrid_resource_failed_provisioning', 'Configuration', 'Azure Event Grid Resource Has Failed Provisioning', 'An Event Grid resource is in a failed provisioning state.', 'EventGrid', '["An Event Grid resource is in a failed provisioning state."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/event-grid/troubleshoot-issues"]'::jsonb),
  ('azure_expressroute_enable_global_reach', 'Configuration', 'Azure ExpressRoute Global Reach Should Be Enabled', 'Global Reach is not enabled, preventing direct communication between on-premises networks through ExpressRoute.', 'ExpressRoute', '["Global Reach is not enabled, preventing direct communication between on-premises networks through ExpressRoute."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/expressroute/expressroute-global-reach"]'::jsonb),
  ('azure_files_smb_not_enabled', 'Configuration', 'Azure Files SMB Protocol Is Not Enabled', 'SMB protocol is not enabled on this storage account for Azure Files.', 'AzureFiles', '["SMB protocol is not enabled on this storage account for Azure Files."]'::jsonb, '["Enable Files SMB Protocol Is Not Enabled through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/files/storage-files-introduction"]'::jsonb),
  ('azure_firewall_enable_dns_proxy', 'Configuration', 'Azure Firewall DNS Proxy Should Be Enabled', 'DNS proxy is not enabled on the firewall, which is required for FQDN filtering.', 'AzureFirewall', '["DNS proxy is not enabled on the firewall, which is required for FQDN filtering."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/firewall/dns-settings"]'::jsonb),
  ('azure_frontdoor_profile_no_endpoints', 'Configuration', 'Azure Front Door Profile Has No Endpoints', 'The Front Door profile has no endpoints configured, making it non-functional.', 'FrontDoor', '["The Front Door profile has no endpoints configured, making it non-functional."]'::jsonb, '["Configure Front Door Profile Endpoints through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/frontdoor/front-door-overview"]'::jsonb),
  ('azure_logic_app_no_actions', 'Configuration', 'Azure Logic App Has No Actions', 'The Logic App workflow has no actions defined, making it non-functional.', 'LogicApps', '["The Logic App workflow has no actions defined, making it non-functional."]'::jsonb, '["Configure Logic App Actions through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-overview"]'::jsonb),
  ('azure_logic_app_no_triggers', 'Configuration', 'Azure Logic App Has No Triggers', 'The Logic App has no triggers configured, so it will never execute.', 'LogicApps', '["The Logic App has no triggers configured, so it will never execute."]'::jsonb, '["Configure Logic App Triggers through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-overview"]'::jsonb),
  ('azure_logic_app_workflow_disabled', 'Configuration', 'Azure Logic App Workflow Is Disabled', 'The Logic App workflow is disabled and will not execute.', 'LogicApps', '["The Logic App workflow is disabled and will not execute."]'::jsonb, '["Enable Logic App Workflow through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/logic-apps/manage-logic-apps-with-azure-portal"]'::jsonb),
  ('azure_metric_alert_auto_mitigation_disabled', 'Configuration', 'Azure Metric Alert Auto-Mitigation Should Be Enabled', 'Auto-mitigation is disabled, so the alert will not automatically resolve when the condition clears.', 'MetricAlerts', '["Auto-mitigation is disabled, so the alert will not automatically resolve when the condition clears."]'::jsonb, '["Enable Metric Alert Auto-Mitigation through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-metric-overview"]'::jsonb),
  ('azure_metric_alert_broad_scope', 'Configuration', 'Azure Metric Alert Has Overly Broad Scope', 'The metric alert is scoped to the entire subscription, which may generate excessive notifications.', 'MetricAlerts', '["The metric alert is scoped to the entire subscription, which may generate excessive notifications."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-metric-overview"]'::jsonb),
  ('azure_metric_alert_disabled', 'Configuration', 'Azure Metric Alert Is Disabled', 'A metric alert is disabled and will not trigger notifications.', 'MetricAlerts', '["A metric alert is disabled and will not trigger notifications."]'::jsonb, '["Enable Metric Alert through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-metric-overview"]'::jsonb),
  ('azure_metric_alert_inefficient_evaluation', 'Configuration', 'Azure Metric Alert Has Inefficient Evaluation Frequency', 'The alert evaluation frequency may be too high or too low for the metric type.', 'MetricAlerts', '["The alert evaluation frequency may be too high or too low for the metric type."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-metric-overview"]'::jsonb),
  ('azure_metric_alert_missing_tags', 'Configuration', 'Azure Metric Alert Should Have Tags', 'The Azure Monitor metric alert has no tags applied. Tags help organize alerts, track ownership, and enable cost allocation across your Azure environment.', 'MetricAlerts', '["The metric alert has no tags for organization."]'::jsonb, '["Configure Metric Alert Tags through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["APRA", "MAS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources"]'::jsonb),
  ('azure_metric_alert_no_action_group', 'Configuration', 'Azure Metric Alert Has No Action Group', 'No action group is configured, so no notifications will be sent.', 'MetricAlerts', '["No action group is configured, so no notifications will be sent."]'::jsonb, '["Configure Metric Alert Action Group through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_operationalinsights_workspace_low_retention', 'Configuration', 'Azure Log Analytics Workspace Retention Is Too Low', 'The Log Analytics workspace retention period is very low, which may impact compliance and troubleshooting capabilities.', 'LogAnalytics', '["The Log Analytics workspace retention period is very low, which may impact compliance and troubleshooting capabilities."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/logs/data-retention-configure"]'::jsonb),
  ('azure_pipeline_build_failed', 'Configuration', 'Azure Pipeline Build Has Failed', 'An Azure DevOps pipeline build has failed and requires investigation. Persistent build failures can block deployments and indicate code quality or infrastructure issues.', 'AzurePipelines', '["A pipeline build has failed and needs attention."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/pipelines/troubleshooting/troubleshooting"]'::jsonb),
  ('azure_pipeline_build_no_branch', 'Configuration', 'Azure Pipeline Build Has No Branch Configuration', 'The pipeline build has no branch configuration specified.', 'AzurePipelines', '["The pipeline build has no branch configuration specified."]'::jsonb, '["Configure Pipeline Build Branch Configuration through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git"]'::jsonb),
  ('azure_pipeline_high_failure_rate', 'Configuration', 'Azure Pipeline Has High Failure Rate', 'The pipeline has a high failure rate, indicating reliability issues.', 'AzurePipelines', '["The pipeline has a high failure rate, indicating reliability issues."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/pipelines/reports/pipelinereport"]'::jsonb),
  ('azure_policy_assignment_no_description', 'Configuration', 'Azure Policy Assignment Has No Description', 'The policy assignment lacks a description explaining its purpose.', 'AzurePolicy', '["The policy assignment lacks a description explaining its purpose."]'::jsonb, '["Configure Policy Assignment Description through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/governance/policy/overview"]'::jsonb),
  ('azure_policy_custom_definition_no_metadata', 'Configuration', 'Azure Custom Policy Definition Has No Metadata', 'The custom policy definition lacks metadata for categorization.', 'AzurePolicy', '["The custom policy definition lacks metadata for categorization."]'::jsonb, '["Configure Custom Policy Definition Metadata through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure"]'::jsonb),
  ('azure_policy_definition_no_category', 'Configuration', 'Azure Policy Definition Has No Category', 'The policy definition is not categorized, making it harder to organize.', 'AzurePolicy', '["The policy definition is not categorized, making it harder to organize."]'::jsonb, '["Configure Policy Definition Category through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure"]'::jsonb),
  ('azure_scheduled_query_rule_auto_mitigation_disabled', 'Configuration', 'Azure Scheduled Query Rule Auto-Mitigation Disabled', 'Auto-mitigation is disabled on this scheduled query alert rule. Without auto-mitigation, alerts will remain active even after the triggering condition resolves.', 'ScheduledQueryRules', '["Auto-mitigation is disabled on this alert rule."]'::jsonb, '["Enable Scheduled Query Rule Auto-Mitigation Disabled through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-log"]'::jsonb),
  ('azure_scheduled_query_rule_disabled', 'Configuration', 'Azure Scheduled Query Rule Is Disabled', 'A scheduled query alert rule is disabled and will not trigger notifications. Disabled rules may leave monitoring gaps for the resources they are configured to watch.', 'ScheduledQueryRules', '["A scheduled query alert rule is disabled."]'::jsonb, '["Enable Scheduled Query Rule through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-log"]'::jsonb),
  ('azure_scheduled_query_rule_empty_query', 'Configuration', 'Azure Scheduled Query Rule Has Empty Query', 'The scheduled query rule has no KQL query defined. Without a query, the alert rule cannot evaluate conditions and will never trigger.', 'ScheduledQueryRules', '["The query rule has no query defined."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-log"]'::jsonb),
  ('azure_scheduled_query_rule_missing_tags', 'Configuration', 'Azure Scheduled Query Rule Should Have Tags', 'The scheduled query alert rule has no tags applied. Tags help organize alerts, track ownership, and enable filtering across your Azure monitoring configuration.', 'ScheduledQueryRules', '["The query rule has no tags."]'::jsonb, '["Configure Scheduled Query Rule Tags through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["APRA", "MAS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources"]'::jsonb),
  ('azure_scheduled_query_rule_no_action_group', 'Configuration', 'Azure Scheduled Query Rule Has No Action Group', 'No action group is configured for this scheduled query rule. Without an action group, triggered alerts will not send notifications to operators.', 'ScheduledQueryRules', '["No action group is configured for notifications."]'::jsonb, '["Configure Scheduled Query Rule Action Group through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups"]'::jsonb),
  ('azure_scheduled_query_rule_no_scopes', 'Configuration', 'Azure Scheduled Query Rule Has No Scopes', 'The scheduled query rule has no scopes defined, making it unable to target any resources for evaluation.', 'ScheduledQueryRules', '["The query rule has no scopes defined."]'::jsonb, '["Configure Scheduled Query Rule Scopes through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-log"]'::jsonb),
  ('azure_sentinel_incident_no_owner', 'Configuration', 'Azure Sentinel Incident Has No Owner', 'A Sentinel security incident has no owner assigned for investigation.', 'Sentinel', '["A Sentinel security incident has no owner assigned for investigation."]'::jsonb, '["Configure Sentinel Incident Owner through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/sentinel/investigate-cases"]'::jsonb),
  ('azure_sentinel_stale_incident', 'Configuration', 'Azure Sentinel Incident Is Stale', 'A Sentinel incident has been open for an extended period without progress.', 'Sentinel', '["A Sentinel incident has been open for an extended period without progress."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/sentinel/investigate-cases"]'::jsonb),
  ('azure_storage_geo_redundant_storage_disabled', 'Configuration', 'Azure Storage Geo-Redundant Replication Should Be Enabled', 'This storage account does not use geo-redundant storage (GRS). Without geo-redundancy, data is only replicated within a single region. A regional outage could result in data loss.', 'StorageAccounts', '["Upgrade storage account redundancy to GRS or RA-GRS for cross-region data protection."]'::jsonb, '["Enable geo-redundant storage:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "APRA"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-redundancy"]'::jsonb),
  ('azure_storage_logging_for_delete_access_disabled', 'Configuration', 'Azure Storage Delete Access Logging Should Be Enabled', 'Storage Analytics logging for delete operations is not enabled. Without delete logging, accidental or malicious data deletion cannot be tracked.', 'StorageAccounts', '["Enable Storage Analytics logging for delete operations."]'::jsonb, '["Enable delete logging:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-analytics-logging"]'::jsonb),
  ('azure_storage_logging_for_read_access_disabled', 'Configuration', 'Azure Storage Read Access Logging Should Be Enabled', 'Storage Analytics logging for read operations is not enabled. Without logging, read access to storage resources cannot be audited, making it difficult to detect unauthorized data access.', 'StorageAccounts', '["Enable Storage Analytics logging for read operations on blob, queue, and table services."]'::jsonb, '["Enable read logging:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-analytics-logging"]'::jsonb),
  ('azure_storage_logging_for_write_access_disabled', 'Configuration', 'Azure Storage Write Access Logging Should Be Enabled', 'Storage Analytics logging for write operations is not enabled. Without write logging, modifications to storage data cannot be audited.', 'StorageAccounts', '["Enable Storage Analytics logging for write operations."]'::jsonb, '["Enable write logging:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-analytics-logging"]'::jsonb),
  ('azure_storage_missing_tags', 'Configuration', 'Azure Storage Account Should Have Tags', 'This storage account has no tags applied. Tags enable cost tracking, resource organization, and governance enforcement across Azure resources.', 'StorageAccounts', '["Apply tags to the storage account for cost tracking, ownership identification, and environment classification."]'::jsonb, '["Add tags to the storage account:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources"]'::jsonb),
  ('azure_storage_soft_delete_disabled', 'Configuration', 'Azure Storage Soft Delete Should Be Enabled', 'Soft delete is not enabled on this storage account. Without soft delete, accidentally or maliciously deleted data cannot be recovered.', 'StorageAccounts', '["Enable blob soft delete and container soft delete with an appropriate retention period."]'::jsonb, '["Enable soft delete:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/blobs/soft-delete-blob-overview"]'::jsonb),
  ('azure_storage_versioning_disabled', 'Configuration', 'Azure Storage Blob Versioning Should Be Enabled', 'Blob versioning is not enabled. Without versioning, previous versions of blobs are lost when overwritten, making it impossible to recover from accidental overwrites or corruption.', 'StorageAccounts', '["Enable blob versioning to maintain previous versions of blobs for data protection and recovery."]'::jsonb, '["Enable blob versioning:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/blobs/versioning-overview"]'::jsonb),
  ('azure_vm_accelerated_networking_disabled', 'Configuration', 'Azure VM Accelerated Networking Should Be Enabled', 'Accelerated Networking enables single root I/O virtualization (SR-IOV) to a VM, greatly improving networking performance. This high-performance path bypasses the host from the datapath, reducing latency, jitter, and CPU utilization.', 'VirtualMachines', '["Enable Accelerated Networking on the VM''s network interface. This is supported on most general-purpose and compute-optimized VM sizes with 2 or more vCPUs."]'::jsonb, '["Enable accelerated networking (requires VM to be deallocated):\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview"]'::jsonb),
  ('azure_vm_auto_shutdown_disabled', 'Configuration', 'Azure VM Auto-Shutdown Should Be Configured', 'Auto-shutdown is not configured for this VM. For non-production workloads (dev/test environments), auto-shutdown can significantly reduce costs by automatically deallocating VMs during off-hours when they are not needed.', 'VirtualMachines', '["Configure auto-shutdown for non-production VMs to automatically deallocate them during off-hours. Set appropriate notification settings to alert users before shutdown."]'::jsonb, '["Configure auto-shutdown for the VM:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/auto-shutdown-vm"]'::jsonb),
  ('azure_vm_automatic_os_upgrade_disabled', 'Configuration', 'Azure VM Automatic OS Upgrade Should Be Enabled', 'Automatic OS upgrades help keep VMs secure by automatically applying the latest OS patches. Without automatic upgrades, VMs may run with known vulnerabilities, increasing the attack surface.', 'VirtualMachines', '["Enable automatic OS image upgrades for the VM to ensure timely application of security patches and updates."]'::jsonb, '["Enable automatic OS upgrades via Azure Policy or during VM creation. For existing VMs, update the OS upgrade policy:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/automatic-vm-guest-patching"]'::jsonb),
  ('azure_vm_backup_disabled', 'Configuration', 'Azure VM Backup Should Be Enabled', 'Azure Virtual Machine backup is not configured. Azure Backup provides independent and isolated backups to guard against unintended data destruction. Without backup, data loss from accidental deletion, corruption, or ransomware cannot be recovered.', 'VirtualMachines', '["Enable Azure Backup for this VM using a Recovery Services vault with an appropriate backup policy. Configure retention policies that meet your organization''s RPO and RTO requirements."]'::jsonb, '["Enable backup for the VM using Azure CLI:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/backup/backup-azure-vms-first-look-arm"]'::jsonb),
  ('azure_vm_boot_diagnostics_disabled', 'Configuration', 'Azure VM Boot Diagnostics Should Be Enabled', 'Boot diagnostics is a debugging feature for Azure VMs that captures serial console output and screenshots to help diagnose VM startup issues. Without boot diagnostics, troubleshooting boot failures becomes significantly more difficult.', 'VirtualMachines', '["Enable boot diagnostics for this VM to capture serial console output and VM screenshots for troubleshooting purposes."]'::jsonb, '["Enable boot diagnostics with managed storage:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/boot-diagnostics"]'::jsonb),
  ('azure_vm_guest_level_diagnostics_missing', 'Configuration', 'Azure VM Guest-Level Diagnostics Should Be Enabled', 'Guest-level diagnostics collects OS-level metrics (memory, disk I/O, process info) from within the VM. Without guest diagnostics, you can only see host-level metrics and miss critical insights for troubleshooting and capacity planning.', 'VirtualMachines', '["Enable guest-level diagnostics by installing the Azure Diagnostics extension to collect OS-level performance counters and logs."]'::jsonb, '["Enable diagnostics using the Azure Monitor Agent:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-overview"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('azure_vm_monitor_agent_missing', 'Configuration', 'Azure VM Monitor Agent Should Be Installed', 'The Azure Monitor Agent is not installed on this VM. Without the monitoring agent, Azure Monitor cannot collect guest OS metrics, logs, and traces, limiting observability and alerting capabilities.', 'VirtualMachines', '["Install the Azure Monitor Agent to enable collection of guest OS metrics and logs for monitoring, alerting, and diagnostics."]'::jsonb, '["Install the Azure Monitor Agent:\n\\", "\\", "\\", "\n\nFor Windows VMs:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-manage"]'::jsonb),
  ('azure_vm_unmanaged_disk', 'Configuration', 'Azure VM Should Use Managed Disks', 'This VM is using unmanaged disks (VHD files in storage accounts). Managed disks provide better reliability, scalability, and security features including built-in encryption, RBAC support, and snapshot capabilities.', 'VirtualMachines', '["Migrate from unmanaged disks to Azure Managed Disks for improved reliability, simplified management, and enhanced security features."]'::jsonb, '["Convert the VM to use managed disks:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview"]'::jsonb),
  ('azure_vmss_accelerated_networking_disabled', 'Configuration', 'Azure VMSS Accelerated Networking Should Be Enabled', 'Accelerated Networking is not enabled on this VM Scale Set. Enabling it provides lower latency, reduced jitter, and decreased CPU utilization for network-intensive workloads.', 'VirtualMachineScaleSets', '["Enable Accelerated Networking on the VMSS network interface configuration for improved network performance."]'::jsonb, '["Update the VMSS network configuration:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview"]'::jsonb),
  ('azure_vmss_overprovision_disabled', 'Configuration', 'Azure VMSS Overprovisioning Should Be Enabled', 'Overprovisioning is disabled on this VM Scale Set. With overprovisioning enabled, Azure provisions more VMs than requested during scale-out, then deletes the extras. This reduces deployment failures and improves scale-out speed at no additional cost.', 'VirtualMachineScaleSets', '["Enable overprovisioning to improve scale-out reliability. Azure does not charge for the extra provisioned VMs."]'::jsonb, '["Enable overprovisioning:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-design-overview"]'::jsonb),
  ('azure_vnet_address_space_overprovisioned', 'Configuration', 'Azure VNet Address Space Is Over-Provisioned', 'The VNet has a very large address space that may not be necessary.', 'VirtualNetworks', '["The VNet has a very large address space that may not be necessary."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview"]'::jsonb),
  ('azure_vnet_custom_dns_not_configured', 'Configuration', 'Azure VNet Custom DNS Is Not Configured', 'The VNet uses default Azure DNS instead of custom DNS servers.', 'VirtualNetworks', '["The VNet uses default Azure DNS instead of custom DNS servers."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances"]'::jsonb),
  ('azure_vnet_empty_no_subnets', 'Configuration', 'Azure VNet Has No Subnets', 'The VNet has no subnets configured, making it non-functional.', 'VirtualNetworks', '["The VNet has no subnets configured, making it non-functional."]'::jsonb, '["Configure VNet Subnets through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-subnet"]'::jsonb),
  ('azure_vnet_gateway_transit_not_optimized', 'Configuration', 'Azure VNet Gateway Transit Is Not Optimized', 'VNet peering gateway transit is not optimally configured.', 'VirtualNetworks', '["VNet peering gateway transit is not optimally configured."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview"]'::jsonb),
  ('aws_lambda_function_url', 'Security', 'Check Lambda Function URL Not in Use', 'A function URL is a dedicated HTTP(S) endpoint created for your Amazon Lambda function. You can use a function URL to invoke your Lambda function through a browser, curl, Postman, or an HTTP client. However, a function URL should be used with caution, and should only be applied on functions with relevant and secure access control, otherwise you risk exposing your application to the public.', 'AWSLambda', '["Check whether your Amazon Lambda functions are configured with function URLs for HTTP(S) endpoints. A function URL creates a direct HTTP(S) endpoint to your function and this may pose a security risk depending on the security configuration and intention of the function."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html"]'::jsonb),
  ('aws_elasticache_encryption', 'Security', 'At Rest Encryption Should be enabled for ElastiCache Clusters', 'When working with production and confidential data it is strongly recommended to implement encryption in order to protect your data from unauthorized access and fulfill compliance requirements for data-at-rest and in-transit encryption within your organization. For example, a compliance requirement is to protect sensitive data that could potentially identify a specific individual such as Personally Identifiable Information (PII), usually used in Financial Services, Healthcare, and Telecommunications sectors.', 'AmazonElastiCache', '["Ensure that your Amazon ElastiCache Redis cache clusters are encrypted in order to meet security and compliance requirements. Encryption helps prevent unauthorized users from reading sensitive data available on your Redis cache clusters and their associated cache storage systems. This includes data saved to persistent media, known as data at-rest, and data that can be intercepted as it travels through the network, between clients and cache servers, known as data in-transit."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "\n        AWS CLI command to enable In-Transit Encryption for ElastiCache cluster:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/at-rest-encryption.html"]'::jsonb),
  ('aws_elasticache_encryption_intransit', 'Security', 'At Transit Encryption Should be enabled for ElastiCache Clusters', 'When working with production and confidential data it is strongly recommended to implement encryption in order to protect your data from unauthorized access and fulfill compliance requirements for data-at-rest and in-transit encryption within your organization. For example, a compliance requirement is to protect sensitive data that could potentially identify a specific individual such as Personally Identifiable Information (PII), usually used in Financial Services, Healthcare, and Telecommunications sectors.', 'AmazonElastiCache', '["Ensure that your Amazon ElastiCache Redis cache clusters are encrypted in order to meet security and compliance requirements. Encryption helps prevent unauthorized users from reading sensitive data available on your Redis cache clusters and their associated cache storage systems. This includes data saved to persistent media, known as data at-rest, and data that can be intercepted as it travels through the network, between clients and cache servers, known as data in-transit."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to enable In-Transit Encryption for ElastiCache cluster:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/in-transit-encryption.html"]'::jsonb),
  ('aws_ec2_ebs_encrypt', 'Security', 'Ec2 EBS Volumes Should be Encrypted', 'When working with production and confidential data it is strongly recommended to implement encryption in order to protect your data from unauthorized access and fulfill compliance requirements for data-at-rest and in-transit encryption within your organization. For example, a compliance requirement is to protect sensitive data that could potentially identify a specific individual such as Personally Identifiable Information (PII), usually used in Financial Services, Healthcare, and Telecommunications sectors.', 'AmazonEC2', '["Ensure that your EBS Volumes are encrypted in order to meet security and compliance requirements. Encryption helps prevent unauthorized users from reading sensitive data available on your Ec2 Instance. This includes data saved to persistent media, known as data at-rest, and data that can be intercepted as it travels through the network, between clients and cache servers, known as data in-transit."]'::jsonb, '["**By Default Enable Encryption for EBS Volumes**\n\\", "\\", "\\", "\n", "**Enable Encryption for Existing EBS Volumes**\n        1. Create a snapshot of the EBS volume\n        2. Copy snapshot (unencrypted) to an encrypted copy using AWS Managed Key\n        3. Create a new EBS volume from the encrypted snapshot in the same Availability Zone as your EC2 instance\n        4. Attach the new (encrypted) volume to the Amazon EC2 instance on a different device\n        5. Restart the encrypted EC2 instance\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/ebs/latest/userguide/ebs-encryption.html"]'::jsonb),
  ('aws_ec2_instance_public_ip', 'Security', 'Disable Public IP Address Assignment for EC2 Instances', 'Amazon EC2 instances should not get public IP addresses at launch in order to enhance security by reducing the attack surface. Instead, they should be placed in private VPC subnets and accessed through the associated load balancer. This setup ensures that incoming traffic is tightly controlled and monitored.', 'AmazonEC2', '["Ensure that Amazon EC2 instances such as backend instances are not using public IP addresses in order to prevent Internet exposure. Backend instances are EC2 instances that run behind a load balancer and do not need direct access to the Internet, therefore do not require public IP addresses."]'::jsonb, '["**Launch Command Without Public IP Address**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html"]'::jsonb),
  ('aws_ec2_instance_public_subnet', 'Security', 'EC2 Instances Should Not Be Launched in Public Subnets', 'By provisioning Amazon EC2 instances within a private subnet (logically isolated section of VPC) you will prevent your instances from receiving inbound traffic initiated by someone on the Internet, therefore have the guarantee that no malicious requests can reach your backend instances.', 'AmazonEC2', '["Ensure that no backend Amazon EC2 instances are provisioned in public subnets in order to protect them from exposure to the Internet. Backend instances are EC2 instances that do not require direct access to the public internet such as database, API, or caching servers. To follow cloud security best practices, all Amazon EC2 instances that are not Internet-facing should run within a private subnet, behind a NAT gateway that allows downloading software updates and implementing security patches or accessing other AWS services like SQS and SNS."]'::jsonb, '["To move your backend Amazon EC2 instances from public subnets to private subnets, you must re-create these instances within private VPC subnets.\n         - Run create-image command (OSX/Linux/UNIX) to create an image from the source, non-compliant backend EC2 instance. Include the --no-reboot command parameter to guarantee the file system integrity for your new AMI\n         - Execute run-instances command (OSX/Linux/UNIX) to launch a new backend Amazon EC2 instance from the AMI created at the previous steps. Use the information returned at step no. 2 for the instance configuration parameters. Configure the --subnet-id command parameter with the ID of your private VPC subnet and include the --no-associate-public-ip-address parameter in the command request to avoid assigning automatically a public IPv4 address to the new EC2 instance         \n\\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html"]'::jsonb),
  ('aws_ec2_instance_generation_upgrade', 'Security', 'Ec2 Instance generation Upgrade', 'Using the current (latest) generation of EC2 instance types instead of the previous generation has multiple advantages such as better hardware performance (faster CPUs, increased memory and network throughput), better virtualization technology (HVM), and lower costs.', 'AmazonEC2', '["Ensure that all your Amazon EC2 instances are using the latest generation of instance types in order to get the best performance with lower costs."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "AWS CLI command to upgrade EC2 instance generation:\n\n        - Run stop-instances command (OSX/Linux/UNIX) to stop the Amazon EC2 instance that you want to reconfigure:\n\\", "\\", "\\", "\n\n        - Run modify-instance-attribute command (OSX/Linux/UNIX) to change the instance type of the stopped Amazon EC2 instance to the latest generation:\n\\", "\\", "\\", "\n\n        - Run start-instances command (OSX/Linux/UNIX) to start the Amazon EC2 instance with the new instance type:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html"]'::jsonb),
  ('aws_ecr_pushscan_enabled', 'Security', 'Enable Scan on Push for ECR Container Images', 'For the security and compliance status of your applications it is crucial to detect and respond to Amazon ECR container image vulnerabilities in the early stages of deployment. When Scan on Push security feature is enabled, your container images are automatically scanned after being pushed to your Amazon ECR repository. If Scan on Push is disabled on your repository, then each image scan must be manually started to get scan results.', 'AmazonECR', '["Ensure that all your Amazon ECR container images are automatically scanned for security vulnerabilities and expenses after being pushed to a repository. Scan on Push for Amazon ECR is an automated vulnerability assessment feature that helps you improve the security of your ECR container images by scanning them for a broad range of Operating System (OS) vulnerabilities after being pushed to an ECR repository. The security feature uses the Common Vulnerabilities and Exposures (CVEs) database from Clair, an open source project designed for static analysis of security issues in appc and docker containers."]'::jsonb, '["**AWS CLI command to enable Scan on Push for ECR repository:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECR/latest/userguide/encryption-at-rest.html"]'::jsonb),
  ('aws_eks_public_access', 'Security', 'EKS Cluster Endpoint Public Access', 'When launching a cluster on Amazon EKS, an endpoint is automatically generated for the Kubernetes API server. This endpoint allows you to interact with your newly created cluster. By default, this API server endpoint is publicly accessible, meaning any machine on the internet can potentially connect to your EKS cluster using its public endpoint. This exposes your cluster to a higher risk of malicious activities and attacks. Restricting public access to the Kubernetes API endpoint managed by the EKS cluster is a security best practice that helps protect your cluster from unauthorized access and potential security threats. By not allowing public access to the cluster''s Kubernetes API endpoint, you ensure that only authorized entities can interact with your Amazon EKS cluster.', 'AmazonEKS', '["Ensure that your Amazon EKS cluster''s Kubernetes API server endpoint is not publicly accessible from the Internet in order to avoid exposing private data and minimizing security risks. The level of access to your Kubernetes API server endpoints depends on your EKS application use cases, however, for most use cases Cloud Conformity recommends that the API server endpoints should be accessible only from within your AWS Virtual Private Cloud (VPC)."]'::jsonb, '["***AWS CLI command to restrict public access to EKS cluster endpoint:***\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html"]'::jsonb),
  ('aws_eks_secret_encryption', 'Security', 'Enable Envelope Encryption for EKS Kubernetes Secrets', 'When working with security-critical data, it is strongly recommended to enable encryption of Kubernetes secrets in order to protect your data from unauthorized access and fulfill compliance requirements for data-at-rest encryption within your organization. For example, a compliance requirement is to protect sensitive data that could potentially identify a specific individual such as Personally Identifiable Information (PII), usually used for financial processing systems and healthcare services.', 'AmazonEKS', '["Use AWS Key Management Service (KMS) keys to provide envelope encryption of Kubernetes secrets stored in Amazon Elastic Kubernetes Service (EKS), in order to meet security and compliance requirements. Implementing envelope encryption of Kubernetes secrets is considered a security best practice for applications that store sensitive and confidential data. Set up your own AWS KMS Customer Master Key (CMK) and associate the key with your Amazon EKS cluster. When secrets are stored using the Kubernetes secrets API, they are encrypted with a Kubernetes-generated data encryption key, which is then further encrypted using the associated KMS CMK that you have created."]'::jsonb, '["**AWS CLI command to enable Envelope Encryption for EKS Kubernetes Secrets:**\n\\", "\\", "\\", "\n\n**Enable For Existing Cluster:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/eks/latest/userguide/enable-kms.html"]'::jsonb),
  ('aws_lambda_environment_variable_encryption', 'Security', 'Enable Encryption in Transit for Environment Variables', 'When dealing with Lambda function environment variables that hold sensitive and critical data, it is highly recommended to implement encryption in order to protect the data that you dynamically pass to your functions (usually access information) from unauthorized access.', 'AWSLambda', '["Ensure that all Amazon Lambda function environment variables that store sensitive information such as passwords, tokens and access keys are encrypted in order to meet security and compliance requirements. The environment variables defined for your Lambda functions are key-value pairs that are used to store configuration settings without the need to change function code. By default, all Lambda environment variables with the key (name) set to \"pass\", \"password\", \"*token*\" (i.e. any key that has \"token\" string in it), \"api\", \"API\", \"Key\", \"KEY\", \"key\" are encrypted"]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html"]'::jsonb),
  ('aws_rds_public_access', 'Security', 'RDS Should Not Be Publicly Accessible', 'When the security group associated with an Amazon RDS database instance allows unrestricted access (i.e. 0.0.0.0/0), everyone and everything on the Internet can establish a connection to your database instance and this can increase the opportunity for malicious activities such as brute-force attacks, SQL injection or DDoS attacks.', 'AmazonRDS', '["Check for any public-facing Amazon RDS database instances provisioned within your AWS cloud account and restrict unauthorized access in order to minimize security risks. To restrict access to a publicly accessible database instance, you must disable the PubliclyAccessible configuration flag, and update the security group associated with the database instance."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "**AWS CLI command to disable Public Access for RDS instance:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_CommonTasks.Connect.html"]'::jsonb),
  ('aws_rds_storage_encrypted', 'Security', 'RDS Encryption Enabled', 'When dealing with production databases that hold sensitive and critical data, it is highly recommended to implement encryption in order to protect your data from unauthorized access. With Amazon RDS encryption enabled, the data stored on the instance underlying storage, the automated backups, Read Replicas, and snapshots, become all encrypted. The RDS encryption keys implement AES-256 algorithm and are entirely managed and protected by the AWS key management infrastructure through Amazon Key Management Service (KMS).', 'AmazonRDS', '["Ensure that your Amazon RDS database instances are encrypted to fulfill compliance requirements for data-at-rest encryption. The data encryption and decryption process is handled transparently and does not require any additional action from you or your application."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "**AWS CLI command to enable Encryption at Rest for RDS instance:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.html"]'::jsonb),
  ('aws_rds_instance_public_subnet', 'Security', 'RDS Instance Should Not Be Launched in Public Subnets', 'By provisioning your Amazon RDS instances within private subnets (logically isolated sections of AWS VPC), you will prevent these resources from receiving inbound traffic from the public Internet, therefore you can have the guarantee that no malicious requests can reach your database instances from the Internet.', 'AmazonRDS', '["Ensure that no Amazon RDS database instances are provisioned inside VPC public subnets in order to protect them from direct exposure to the Internet. Because database instances are not Internet-facing and their management (running software updates, implementing security patches, etc) is performed by AWS, the database instances should run only in private subnets."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "**AWS CLI command to move RDS instance from public to private subnet:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html"]'::jsonb),
  ('aws_rds_snapshot_encryption', 'Security', 'RDS snapshots should be encrypted', 'When working with production databases that hold sensitive and critical data, it is strongly recommended to implement encryption at rest and protect your data from attackers or unauthorized personnel.', 'AmazonRDS', '["Ensure that your manual Amazon RDS database snapshots are encrypted in order to achieve compliance for data-at-rest encryption within your organization. The Amazon RDS snapshot encryption and decryption process is handled transparently and does not require any additional action from you or your application. The keys used for database snapshot encryption can be entirely managed and protected by the AWS key management infrastructure or fully managed by the AWS customer through Amazon KMS Customer Master Keys (CMKs)."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "**AWS CLI command to enable Encryption for RDS snapshot:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.html"]'::jsonb),
  ('aws_s3_public_access_acl', 'Security', 'S3 Bucket Public ''READ_ACP'' Access', 'Granting public READ_ACP access to your Amazon S3 buckets can enable the unauthorized users to see who controls your S3 objects and how. Malicious users can use this information to find S3 objects with misconfigured permissions and try probing techniques to facilitate access to your Amazon S3 data. To meet security and compliance requirements, avoid granting READ_ACP (VIEW) permissions to the "Everyone (public access)" grantee in production.', 'AmazonS3', '["Ensure that the content permissions of your Amazon S3 buckets can''t be viewed by anonymous users in order to protect your S3 data against unauthorized access. An Amazon S3 bucket that grants public READ_ACP (VIEW) access can allow everyone on the Internet to examine your Access Control List (ACL) configuration and find permission vulnerabilities."]'::jsonb, '["**AWS CLI command to remove public READ_ACP access from S3 bucket:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html"]'::jsonb),
  ('aws_s3_public_access_policy', 'Security', 'S3 Bucket Public Access Via Policy', 'Granting public access to your Amazon S3 buckets via bucket policies can allow malicious users to view, get, upload, modify, and delete S3 objects, which can lead to data breaches, data loss and unexpected charges on your AWS monthly bill.', 'AmazonS3', '["Ensure that your Amazon S3 buckets are not publicly accessible to the Internet via bucket policies in order to protect against unauthorized access. Allowing unrestricted access through bucket policies gives everyone the ability to list the objects within the bucket (ListBucket), download objects (GetObject), upload/delete objects (PutObject, DeleteObject), view objects permissions (GetBucketAcl), edit objects permissions (PutBucketAcl) and more. Trend Micro Cloud One™ – Conformity strongly recommends using bucket policies to limit the access to a trusted entity, such as an authorized AWS account, instead of providing access to everyone on the Internet."]'::jsonb, '["**AWS CLI command to remove public access via bucket policy:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html"]'::jsonb),
  ('aws_fargate_task_definition_secrets_not_used', 'Security', 'Fargate Task Definition Not Using Secrets', 'The container has environment variables with sensitive values instead of using secrets from Secrets Manager or SSM.', 'AWSFargate', '["Use AWS Secrets Manager or SSM Parameter Store for sensitive values instead of environment variables."]'::jsonb, '["secrets"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html"]'::jsonb),
  ('aws_fargate_task_definition_privileged_container', 'Security', 'Fargate Task Definition Running Privileged Container', 'The container is configured to run in privileged mode, which provides unrestricted host access.', 'AWSFargate', '["Disable privileged mode unless absolutely necessary."]'::jsonb, '["privileged"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_fargate_task_definition_readonly_root_fs_disabled', 'Security', 'Fargate Task Definition Read-Only Root Filesystem Disabled', 'The container root filesystem is writable, increasing the attack surface.', 'AWSFargate', '["Enable read-only root filesystem and use volumes for writable paths."]'::jsonb, '["readonlyRootFilesystem"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_redshift_encryption_at_rest', 'Security', 'Redshift Encryption at Rest Should Be Enabled', 'The Redshift cluster does not have encryption at rest enabled.', 'AmazonRedshift', '["Enable encryption at rest for the Redshift cluster to protect data."]'::jsonb, '["\n**Enable encryption via:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-db-encryption.html"]'::jsonb),
  ('aws_redshift_public_access', 'Security', 'Redshift Cluster Should Not Be Publicly Accessible', 'The Redshift cluster is publicly accessible, exposing it to potential unauthorized access.', 'AmazonRedshift', '["Disable public accessibility for the Redshift cluster."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/redshift/latest/mgmt/managing-clusters-vpc.html"]'::jsonb),
  ('aws_redshift_enhanced_vpc_routing', 'Security', 'Redshift Enhanced VPC Routing Should Be Enabled', 'Enhanced VPC routing forces all COPY and UNLOAD traffic to go through the VPC.', 'AmazonRedshift', '["Enable enhanced VPC routing to keep data traffic within the VPC."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/redshift/latest/mgmt/enhanced-vpc-routing.html"]'::jsonb),
  ('aws_es_encryption_at_rest', 'Security', 'Elasticsearch Encryption at Rest Should Be Enabled', 'The Elasticsearch domain does not have encryption at rest enabled.', 'AmazonES', '["Enable encryption at rest to protect stored data."]'::jsonb, '["Update the domain configuration to enable encryption at rest."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/opensearch-service/latest/developerguide/encryption-at-rest.html"]'::jsonb),
  ('aws_es_node_to_node_encryption', 'Security', 'Elasticsearch Node-to-Node Encryption Should Be Enabled', 'Node-to-node encryption is not enabled for the Elasticsearch domain.', 'AmazonES', '["Enable node-to-node encryption to protect data in transit within the cluster."]'::jsonb, '["Update the domain configuration to enable node-to-node encryption."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ntn.html"]'::jsonb),
  ('aws_ec2_instance_imds_token_optional', 'Security', 'EC2 Instance IMDSv2 Not Required', 'The instance metadata service allows IMDSv1 which is vulnerable to SSRF attacks.', 'AmazonEC2', '["Require IMDSv2 (token-based) to protect against SSRF attacks."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html"]'::jsonb),
  ('aws_ec2_stopped_instance_incurring_storage_cost', 'Security', 'Stopped EC2 Instance Still Incurring Storage Costs', 'The EC2 instance is stopped but its EBS volumes continue to incur charges.', 'AmazonEC2', '["Delete the instance and its volumes if no longer needed, or create snapshots and terminate."]'::jsonb, '["Terminate the instance or detach and delete unnecessary volumes."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html"]'::jsonb),
  ('aws_msk_encryption_in_transit', 'Security', 'MSK Encryption in Transit Should Be Enabled', 'Data in transit between MSK brokers is not encrypted.', 'AmazonMSK', '["Enable TLS encryption for data in transit between brokers and clients."]'::jsonb, '["Update the cluster encryption settings to enable in-transit encryption."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/msk/latest/developerguide/msk-encryption.html"]'::jsonb),
  ('aws_msk_encryption_at_rest', 'Security', 'MSK Encryption at Rest Should Be Enabled', 'Data at rest is not encrypted with a CMK for the MSK cluster.', 'AmazonMSK', '["Enable encryption at rest using a CMK for the MSK cluster."]'::jsonb, '["Encryption at rest can only be set at cluster creation time."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/msk/latest/developerguide/msk-encryption.html"]'::jsonb),
  ('aws_msk_public_access_disabled', 'Security', 'MSK Public Access Should Be Disabled', 'Public access is enabled for the MSK cluster, exposing it to the internet.', 'AmazonMSK', '["Disable public access to the MSK cluster."]'::jsonb, '["Update the cluster connectivity settings to disable public access."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/msk/latest/developerguide/public-access.html"]'::jsonb),
  ('aws_cloudtrail_encryption_cmk', 'Security', 'CloudTrail Should Use CMK Encryption', 'CloudTrail logs are not encrypted with a customer managed KMS key.', 'AWSCloudTrail', '["Encrypt CloudTrail logs with a CMK for enhanced security."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html"]'::jsonb),
  ('aws_cloudtrail_eds_encryption_cmk', 'Security', 'CloudTrail Event Data Store Should Use CMK Encryption', 'The CloudTrail event data store is not encrypted with a CMK.', 'AWSCloudTrail', '["Encrypt the event data store with a CMK."]'::jsonb, '["Update the event data store encryption settings."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html"]'::jsonb),
  ('aws_ecrpublic_tag_immutable', 'Security', 'ECR Public Image Tags Should Be Immutable', 'The ECR Public repository does not have image tag immutability enabled.', 'AmazonECR', '["Enable image tag immutability to prevent image tags from being overwritten."]'::jsonb, '["Update the repository to enable image tag immutability."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-tag-mutability.html"]'::jsonb),
  ('aws_dynamodb_sse_cmk', 'Security', 'DynamoDB Should Use CMK Encryption', 'The DynamoDB table is not encrypted with a customer managed KMS key.', 'AmazonDynamoDB', '["Use CMK encryption for DynamoDB tables storing sensitive data."]'::jsonb, '["Update the table SSE specification to use a CMK."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/EncryptionAtRest.html"]'::jsonb),
  ('aws_cloudwatch_log_group_encryption_cmk', 'Security', 'CloudWatch Log Group Should Use CMK Encryption', 'The log group is not encrypted with a customer managed KMS key.', 'AmazonCloudWatch', '["Encrypt CloudWatch log groups with a CMK for enhanced security."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html"]'::jsonb),
  ('aws_backup_vault_encryption_cmk', 'Security', 'Backup Vault Should Use CMK Encryption', 'The backup vault is not encrypted with a customer managed KMS key.', 'AWSBackup', '["Use CMK encryption for backup vaults storing sensitive data."]'::jsonb, '["Create a new vault with CMK encryption (cannot be changed after creation)."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/aws-backup/latest/devguide/encryption.html"]'::jsonb),
  ('aws_backup_vault_access_policy_exists', 'Security', 'Backup Vault Should Have an Access Policy', 'The backup vault does not have a resource policy to control access.', 'AWSBackup', '["Configure a resource policy on the backup vault."]'::jsonb, '["Set a vault access policy to control who can access the backups."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/aws-backup/latest/devguide/vaults.html"]'::jsonb),
  ('aws_backup_vault_lock_enabled', 'Security', 'Backup Vault Lock Should Be Enabled', 'Vault Lock is not enabled, so backup policies can be modified or deleted.', 'AWSBackup', '["Enable Vault Lock for compliance and immutability requirements."]'::jsonb, '["Put a vault lock configuration on the backup vault."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/aws-backup/latest/devguide/vault-lock.html"]'::jsonb),
  ('aws_cloudfront_waf_integration', 'Security', 'CloudFront Should Have WAF Integration', 'The CloudFront distribution does not have a WAF web ACL associated.', 'AmazonCloudFront', '["Associate a WAF web ACL with the distribution to protect against web exploits."]'::jsonb, '["Associate a WAF web ACL with the CloudFront distribution."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-awswaf.html"]'::jsonb),
  ('aws_cloudfront_viewer_protocol_https', 'Security', 'CloudFront Should Enforce HTTPS', 'The distribution allows HTTP connections, which transmit data unencrypted.', 'AmazonCloudFront', '["Configure the distribution to redirect HTTP to HTTPS or require HTTPS only."]'::jsonb, '["redirect-to-https", "https-only"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https-viewers-to-cloudfront.html"]'::jsonb),
  ('aws_cloudfront_origin_access_control', 'Security', 'CloudFront Should Use Origin Access Control', 'The distribution does not use Origin Access Control (OAC) to restrict S3 access.', 'AmazonCloudFront', '["Use Origin Access Control to ensure S3 content is only accessible through CloudFront."]'::jsonb, '["Create an OAC and associate it with the distribution origin."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html"]'::jsonb),
  ('aws_vpc_unallocated_elastic_ip', 'Security', 'Unallocated Elastic IP Address', 'The Elastic IP address is not associated with any instance or network interface, incurring unnecessary costs.', 'AmazonVPC', '["Release unused Elastic IPs to avoid unnecessary charges."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('aws_xray_encryption_cmk', 'Security', 'X-Ray Should Use CMK Encryption', 'X-Ray trace data is not encrypted with a customer managed KMS key.', 'AWSX-Ray', '["Encrypt X-Ray data with a CMK for enhanced security."]'::jsonb, '["Update the X-Ray encryption configuration to use a CMK."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/xray/latest/devguide/xray-console-encryption.html"]'::jsonb),
  ('aws_ecs_cluster_fargate_fips_disabled', 'Security', 'ECS Fargate FIPS Compliance Disabled', 'FIPS 140-2 compliance is not enabled for the Fargate capacity provider.', 'AmazonECS', '["Enable FIPS compliance if required by regulatory standards."]'::jsonb, '["Update the cluster Fargate capacity provider to enable FIPS."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-fips-compliance.html"]'::jsonb),
  ('aws_ecs_task_definition_secrets_not_used', 'Security', 'ECS Task Definition Not Using Secrets', 'The container uses hardcoded environment variables instead of secrets references.', 'AmazonECS', '["Use secrets from Secrets Manager or SSM Parameter Store."]'::jsonb, '["secrets"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html"]'::jsonb),
  ('aws_ecs_task_definition_privileged_container', 'Security', 'ECS Task Definition Running Privileged Container', 'The ECS task definition runs containers in privileged mode, granting full access to the host system. Privileged containers bypass security boundaries and increase the blast radius of container compromise.', 'AmazonECS', '["Disable privileged mode unless absolutely necessary."]'::jsonb, '["privileged"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_ecs_task_definition_readonly_root_fs_disabled', 'Security', 'ECS Task Definition Read-Only Root Filesystem Disabled', 'The ECS task definition does not use a read-only root filesystem. A writable root filesystem allows attackers to modify binaries or install malware if a container is compromised.', 'AmazonECS', '["Enable read-only root filesystem."]'::jsonb, '["readonlyRootFilesystem"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html"]'::jsonb),
  ('aws_efs_encryption_at_rest', 'Security', 'EFS Encryption at Rest Should Be Enabled', 'The EFS file system does not have encryption at rest enabled.', 'AmazonEFS', '["Enable encryption at rest for EFS file systems."]'::jsonb, '["Encryption can only be enabled at creation time. Create a new encrypted file system and migrate data."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/efs/latest/ug/encryption-at-rest.html"]'::jsonb),
  ('aws_kms_key_rotation_enabled', 'Security', 'KMS Key Rotation Should Be Enabled', 'Automatic key rotation is not enabled for the KMS key.', 'AWSKMS', '["Enable automatic key rotation for KMS keys."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html"]'::jsonb),
  ('aws_sns_sse_enabled_cmk', 'Security', 'SNS Topic Should Use CMK Encryption', 'The SNS topic is not encrypted with a customer managed KMS key.', 'AmazonSNS', '["Encrypt SNS topics with a CMK."]'::jsonb, '["KmsMasterKeyId"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html"]'::jsonb),
  ('aws_sns_topic_no_public_access', 'Security', 'SNS Topic Should Not Allow Public Access', 'The SNS topic resource policy allows public access, enabling any AWS account or anonymous user to publish or subscribe. This can lead to data exfiltration or unauthorized message injection.', 'AmazonSNS', '["Restrict the SNS topic policy to authorized principals only."]'::jsonb, '["Update the topic policy to remove public access."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html"]'::jsonb),
  ('aws_sqs_sse_enabled', 'Security', 'SQS Server-Side Encryption Should Be Enabled', 'The SQS queue does not have server-side encryption enabled.', 'AmazonSQS', '["Enable SSE for SQS queues."]'::jsonb, '["SqsManagedSseEnabled", "KmsMasterKeyId"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html"]'::jsonb),
  ('aws_sagemaker_notebook_no_direct_internet', 'Security', 'SageMaker Notebook Should Not Have Direct Internet Access', 'The SageMaker notebook instance has direct internet access enabled.', 'AmazonSageMaker', '["Disable direct internet access and use VPC endpoints for connectivity."]'::jsonb, '["DirectInternetAccess"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-notebook-and-internet-access.html"]'::jsonb),
  ('aws_sagemaker_notebook_root_access_disabled', 'Security', 'SageMaker Notebook Root Access Should Be Disabled', 'Root access is enabled for the SageMaker notebook instance.', 'AmazonSageMaker', '["Disable root access to reduce the attack surface."]'::jsonb, '["Update the notebook instance to disable root access."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-root-access.html"]'::jsonb),
  ('aws_sagemaker_notebook_encryption_cmk', 'Security', 'SageMaker Notebook Should Use CMK Encryption', 'The notebook instance is not encrypted with a customer managed KMS key.', 'AmazonSageMaker', '["Use CMK encryption for SageMaker notebook instances."]'::jsonb, '["Recreate the notebook with a KMS key specified."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sagemaker/latest/dg/encryption-at-rest.html"]'::jsonb),
  ('aws_sagemaker_endpoint_data_capture', 'Security', 'SageMaker Endpoint Data Capture Should Be Enabled', 'Data capture is not enabled for the SageMaker endpoint.', 'AmazonSageMaker', '["Enable data capture for model monitoring and auditing."]'::jsonb, '["Update the endpoint configuration to enable data capture."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html"]'::jsonb),
  ('aws_bedrock_custom_model_output_encryption_cmk', 'Security', 'Bedrock Custom Model Should Use CMK Encryption', 'The custom model output is not encrypted with a CMK.', 'AmazonBedrock', '["Use CMK encryption for Bedrock custom model outputs."]'::jsonb, '["Specify a KMS key when creating the custom model."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/bedrock/latest/userguide/encryption-customer-managed-keys.html"]'::jsonb),
  ('aws_inspector_not_enabled', 'Security', 'AWS Inspector Not Enabled', 'Amazon Inspector is not enabled in this account/region.', 'AmazonInspector', '["Enable Inspector for automated vulnerability management."]'::jsonb, '["Enable Inspector via the console or CLI."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/getting_started_tutorial.html"]'::jsonb),
  ('aws_inspector_ec2_not_enabled', 'Security', 'Inspector EC2 Scanning Not Enabled', 'EC2 instance scanning is not enabled in Inspector.', 'AmazonInspector', '["Enable EC2 scanning to detect vulnerabilities in instances."]'::jsonb, '["Enable EC2 scanning in the Inspector configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/enable-disable-scanning-ec2.html"]'::jsonb),
  ('aws_inspector_ecr_not_enabled', 'Security', 'Inspector ECR Scanning Not Enabled', 'ECR container image scanning is not enabled in Inspector.', 'AmazonInspector', '["Enable ECR scanning to detect vulnerabilities in container images."]'::jsonb, '["Enable ECR scanning in the Inspector configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/enable-disable-scanning-ecr.html"]'::jsonb),
  ('aws_inspector_lambda_not_enabled', 'Security', 'Inspector Lambda Scanning Not Enabled', 'Lambda function scanning is not enabled in Inspector.', 'AmazonInspector', '["Enable Lambda scanning to detect vulnerabilities in function code."]'::jsonb, '["Enable Lambda scanning in the Inspector configuration."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/enable-disable-scanning-lambda.html"]'::jsonb),
  ('aws_inspector_critical_finding', 'Security', 'Inspector Critical Finding', 'A critical vulnerability has been found by Amazon Inspector.', 'AmazonInspector', '["Address critical findings immediately to reduce security risk."]'::jsonb, '["Apply patches or updates to remediate the vulnerability."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/findings-understanding.html"]'::jsonb),
  ('aws_inspector_old_finding', 'Security', 'Inspector Finding Is Old', 'An Inspector finding has been open for an extended period without remediation.', 'AmazonInspector', '["Review and remediate old findings or suppress if accepted risk."]'::jsonb, '["Apply remediation or update the finding status."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/findings-understanding.html"]'::jsonb),
  ('aws_inspector_no_coverage', 'Security', 'Inspector Has No Coverage', 'No EC2 instances, ECR repositories, or Lambda functions are being scanned by Amazon Inspector. Without coverage, vulnerabilities in your workloads go undetected.', 'AmazonInspector', '["Ensure Inspector is scanning your resources."]'::jsonb, '["Enable resource types for scanning in Inspector."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/inspector/latest/user/monitoring_coverage.html"]'::jsonb),
  ('aws_secretsmanager_unused_secret', 'Security', 'Secrets Manager Secret Is Unused', 'The secret has not been accessed recently, suggesting it may be unused.', 'AWSSecretsManager', '["Review and delete unused secrets to reduce the attack surface."]'::jsonb, '["Delete the secret if confirmed unused."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_delete-secret.html"]'::jsonb),
  ('aws_secretsmanager_rotation_enabled', 'Security', 'Secrets Manager Rotation Should Be Enabled', 'Automatic rotation is not enabled for this Secrets Manager secret. Long-lived secrets increase the risk of credential compromise. Enable automatic rotation with an appropriate rotation schedule.', 'AWSSecretsManager', '["Enable automatic rotation for secrets to enhance security."]'::jsonb, '["Configure rotation with a Lambda function."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets.html"]'::jsonb),
  ('aws_secretsmanager_encryption_cmk', 'Security', 'Secrets Manager Should Use CMK Encryption', 'The secret is not encrypted with a customer managed KMS key.', 'AWSSecretsManager', '["Use CMK encryption for secrets containing sensitive data."]'::jsonb, '["Update the secret to use a CMK for encryption."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/secretsmanager/latest/userguide/security-encryption.html"]'::jsonb),
  ('aws_ssm_parameter_not_encrypted', 'Security', 'SSM Parameter Not Encrypted', 'The SSM parameter is stored as plaintext instead of SecureString.', 'AWSSystemsManager', '["Use SecureString type for parameters containing sensitive data."]'::jsonb, '["Recreate the parameter as SecureString type with KMS encryption."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-securestring.html"]'::jsonb),
  ('aws_waf_logging_disabled', 'Security', 'WAF Logging Disabled', 'Logging is not enabled for the AWS WAF web ACL. Without logging, blocked and allowed requests cannot be audited, making it difficult to tune rules and investigate security incidents.', 'AWSWAF', '["Enable logging to capture web ACL traffic for analysis."]'::jsonb, '["Enable logging with a Kinesis Data Firehose, S3, or CloudWatch Logs destination."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/waf/latest/developerguide/logging.html"]'::jsonb),
  ('aws_waf_webacl_not_associated', 'Security', 'WAF Web ACL Not Associated with Resources', 'The WAF web ACL is not associated with any resources.', 'AWSWAF', '["Associate the web ACL with CloudFront, ALB, or API Gateway resources."]'::jsonb, '["Associate the web ACL with the appropriate resource."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-associating-aws-resource.html"]'::jsonb),
  ('aws_waf_no_rules', 'Security', 'WAF Web ACL Has No Rules', 'The WAF web ACL does not have any rules configured.', 'AWSWAF', '["Add rules to the web ACL to protect against common web exploits."]'::jsonb, '["Add managed rule groups or custom rules to the web ACL."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-rules.html"]'::jsonb),
  ('aws_waf_no_rate_limiting', 'Security', 'WAF Has No Rate Limiting', 'The WAF web ACL does not include rate-based rules.', 'AWSWAF', '["Add rate-based rules to protect against DDoS and brute force attacks."]'::jsonb, '["Add a rate-based rule to the web ACL."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-type-rate-based.html"]'::jsonb),
  ('aws_waf_no_managed_rules', 'Security', 'WAF Has No AWS Managed Rules', 'The WAF web ACL does not use any AWS managed rule groups.', 'AWSWAF', '["Add AWS managed rule groups for protection against common vulnerabilities."]'::jsonb, '["Add the AWS managed rules for common threats (e.g., AWSManagedRulesCommonRuleSet)."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups.html"]'::jsonb),
  ('aws_waf_empty_ipset', 'Security', 'WAF IP Set Is Empty', 'A WAF IP set has no addresses, which may indicate misconfiguration.', 'AWSWAF', '["Review the IP set and add addresses or remove if unused."]'::jsonb, '["Add IP addresses to the set or delete it if not needed."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/waf/latest/developerguide/waf-ip-set-managing.html"]'::jsonb),
  ('gcp_function_public_access', 'Security', 'Cloud Function Allows Public Access', 'The Cloud Function is accessible without authentication.', 'CloudFunctions', '["Restrict access to authenticated users only unless public access is intended."]'::jsonb, '["Remove the allUsers or allAuthenticatedUsers IAM binding from the function."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/functions/docs/securing/managing-access-iam"]'::jsonb),
  ('gcp_bigquery_dataset_no_cmek', 'Security', 'BigQuery Dataset Not Using CMEK', 'The BigQuery dataset is not encrypted with a customer-managed encryption key.', 'BigQuery', '["Use CMEK for datasets containing sensitive data."]'::jsonb, '["Set the default encryption configuration on the dataset."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/customer-managed-encryption"]'::jsonb),
  ('gcp_run_public_ingress', 'Security', 'Cloud Run Service Allows Public Ingress', 'The Cloud Run service allows traffic from the public internet.', 'CloudRun', '["Restrict ingress to internal traffic only if public access is not required."]'::jsonb, '["Update the service ingress setting to internal or internal-and-cloud-load-balancing."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/run/docs/securing/ingress"]'::jsonb),
  ('gcp_sql_no_ssl', 'Security', 'Cloud SQL SSL Not Required', 'The Cloud SQL instance does not require SSL connections.', 'CloudSQL', '["Require SSL connections to encrypt data in transit."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/authorize-ssl"]'::jsonb),
  ('gcp_storage_public_access', 'Security', 'Cloud Storage Bucket Has Public Access', 'The GCP Cloud Storage bucket is publicly accessible, allowing anyone on the internet to read its contents. Public buckets are a leading cause of cloud data breaches.', 'CloudStorage', '["Remove public access unless the bucket is intended to serve public content."]'::jsonb, '["Remove allUsers and allAuthenticatedUsers IAM bindings."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/public-access-prevention"]'::jsonb),
  ('gcp_storage_no_cmek', 'Security', 'Cloud Storage Not Using CMEK', 'The bucket is not encrypted with a customer-managed encryption key.', 'CloudStorage', '["Use CMEK for buckets containing sensitive data."]'::jsonb, '["Set the default KMS key for the bucket."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/encryption/customer-managed-keys"]'::jsonb),
  ('gcp_storage_no_ubla', 'Security', 'Cloud Storage Uniform Bucket-Level Access Disabled', 'Uniform bucket-level access is not enabled, allowing both ACLs and IAM policies.', 'CloudStorage', '["Enable uniform bucket-level access for simplified and consistent access management."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/uniform-bucket-level-access"]'::jsonb),
  ('azure_defender_free_tier', 'Security', 'Azure Defender Using Free Tier', 'Microsoft Defender for Cloud is using the free tier with limited security capabilities.', 'AzureDefender', '["Upgrade to the Standard tier for enhanced threat protection."]'::jsonb, '["Enable the Standard pricing tier for Defender plans."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/defender-for-cloud/defender-for-cloud-introduction"]'::jsonb),
  ('azure_defender_unhealthy_assessment', 'Security', 'Azure Defender Unhealthy Security Assessment', 'Microsoft Defender has identified an unhealthy security assessment.', 'AzureDefender', '["Remediate the unhealthy assessment to improve security posture."]'::jsonb, '["Review and apply the recommended remediation steps."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/defender-for-cloud/managing-and-responding-alerts"]'::jsonb),
  ('azure_defender_auto_provision_disabled', 'Security', 'Azure Defender Auto-Provisioning Disabled', 'Automatic provisioning of security agents is disabled.', 'AzureDefender', '["Enable auto-provisioning to automatically install security agents on new VMs."]'::jsonb, '["Enable auto-provisioning in Defender settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/defender-for-cloud/monitoring-components"]'::jsonb),
  ('azure_defender_no_security_contacts', 'Security', 'Azure Defender No Security Contacts Configured', 'No security contact email addresses are configured for alert notifications.', 'AzureDefender', '["Configure security contacts to receive alert notifications."]'::jsonb, '["Add security contact email addresses in Defender settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/defender-for-cloud/configure-email-notifications"]'::jsonb),
  ('azure_storage_https_only_disabled', 'Security', 'Azure Storage HTTPS Only Disabled', 'The storage account allows HTTP connections, transmitting data unencrypted.', 'AzureStorage', '["Enable HTTPS-only transfer to encrypt data in transit."]'::jsonb, '["\n**Enable HTTPS-only:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-require-secure-transfer"]'::jsonb),
  ('azure_storage_minimum_tls_version', 'Security', 'Azure Storage Minimum TLS Version Not Set', 'The storage account allows connections with older TLS versions.', 'AzureStorage', '["Set minimum TLS version to 1.2."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/transport-layer-security-configure-minimum-version"]'::jsonb),
  ('azure_storage_blob_public_access_enabled', 'Security', 'Azure Storage Blob Public Access Enabled', 'Public access is enabled for blob containers in the storage account.', 'AzureStorage', '["Disable blob public access unless specifically needed."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/blobs/anonymous-read-access-configure"]'::jsonb),
  ('azure_storage_shared_key_access_enabled', 'Security', 'Azure Storage Shared Key Access Enabled', 'Shared key authorization is enabled, which is less secure than Azure AD authentication.', 'AzureStorage', '["Disable shared key access and use Azure AD authentication."]'::jsonb, '["Disable shared key access in the storage account configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/shared-key-authorization-prevent"]'::jsonb),
  ('azure_storage_infrastructure_encryption_disabled', 'Security', 'Azure Storage Infrastructure Encryption Disabled', 'Infrastructure encryption (double encryption) is not enabled.', 'AzureStorage', '["Enable infrastructure encryption for additional data protection."]'::jsonb, '["Infrastructure encryption can only be enabled at creation time."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/infrastructure-encryption-enable"]'::jsonb),
  ('azure_storage_firewall_not_configured', 'Security', 'Azure Storage Firewall Not Configured', 'The storage account does not have network rules configured.', 'AzureStorage', '["Configure firewall rules to restrict access to trusted networks."]'::jsonb, '["\n**Configure network rules:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-network-security"]'::jsonb),
  ('azure_sql_public_network_access_enabled', 'Security', 'Azure SQL Public Network Access Enabled', 'The SQL server allows connections from the public internet.', 'AzureSQL', '["Disable public network access and use private endpoints."]'::jsonb, '["Disable public access in the SQL server firewall settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/connectivity-settings"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('azure_sql_entra_id_admin_not_configured', 'Security', 'Azure SQL Entra ID Admin Not Configured', 'No Azure Entra ID (AAD) administrator is configured for the SQL server.', 'AzureSQL', '["Configure an Entra ID admin for Azure AD authentication support."]'::jsonb, '["Set an Entra ID admin in the SQL server configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure"]'::jsonb),
  ('azure_sql_transparent_data_encryption_disabled', 'Security', 'Azure SQL Transparent Data Encryption Disabled', 'Transparent Data Encryption (TDE) is not enabled for this Azure SQL database. TDE encrypts data at rest to protect against offline access to the database files.', 'AzureSQL', '["Enable TDE to encrypt data at rest."]'::jsonb, '["Enable TDE in the database security settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/transparent-data-encryption-tde-overview"]'::jsonb),
  ('azure_sql_advanced_data_security_disabled', 'Security', 'Azure SQL Advanced Data Security Disabled', 'Advanced data security features are not enabled for this Azure SQL resource. Advanced data security provides vulnerability assessment and advanced threat protection capabilities.', 'AzureSQL', '["Enable advanced data security for threat detection and vulnerability assessment."]'::jsonb, '["Enable advanced data security in the SQL server settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/azure-defender-for-sql"]'::jsonb),
  ('azure_aks_rbac_disabled', 'Security', 'AKS RBAC Disabled', 'Kubernetes RBAC is not enabled on the AKS cluster.', 'AzureAKS', '["Enable RBAC for fine-grained access control."]'::jsonb, '["RBAC can only be enabled at cluster creation time. Recreate the cluster with RBAC enabled."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/aks/manage-azure-rbac"]'::jsonb),
  ('azure_aks_network_policy_disabled', 'Security', 'AKS Network Policy Disabled', 'Network policy is not enabled on this AKS cluster. Without network policies, all pods can communicate freely, violating the principle of least privilege and increasing lateral movement risk.', 'AzureAKS', '["Enable network policy for pod-to-pod traffic control."]'::jsonb, '["Enable network policy (Azure or Calico) in the cluster configuration."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/aks/use-network-policies"]'::jsonb),
  ('azure_aks_azure_policy_disabled', 'Security', 'AKS Azure Policy Addon Disabled', 'The Azure Policy addon is not enabled on the AKS cluster.', 'AzureAKS', '["Enable Azure Policy addon for governance and compliance."]'::jsonb, '["\n**Enable the Azure Policy addon:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/aks/use-azure-policy"]'::jsonb),
  ('azure_app_service_https_only_disabled', 'Security', 'App Service HTTPS Only Disabled', 'The Azure App Service allows unencrypted HTTP connections. All traffic should be redirected to HTTPS to protect data in transit from interception.', 'AzureAppService', '["Enable HTTPS only to encrypt all traffic."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/app-service/configure-ssl-bindings"]'::jsonb),
  ('azure_function_https_only_disabled', 'Security', 'Azure Function HTTPS Only Disabled', 'The Azure Function app allows unencrypted HTTP connections. Enforce HTTPS-only to ensure all traffic is encrypted in transit.', 'AzureFunctions', '["Enable HTTPS only for the function app."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-functions/security-concepts"]'::jsonb),
  ('azure_function_authentication_disabled', 'Security', 'Azure Function Authentication Disabled', 'Authentication is not enabled for the function app.', 'AzureFunctions', '["Enable authentication to protect the function app."]'::jsonb, '["Enable authentication in the function app settings."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-functions/security-concepts"]'::jsonb),
  ('azure_keyvault_soft_delete_disabled', 'Security', 'Key Vault Soft Delete Disabled', 'Soft delete is not enabled for this Azure Key Vault. Without soft delete, accidentally deleted vaults, keys, secrets, and certificates cannot be recovered.', 'AzureKeyVault', '["Enable soft delete to protect against accidental deletion."]'::jsonb, '["Enable soft delete in the Key Vault properties."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/key-vault/general/soft-delete-overview"]'::jsonb),
  ('azure_keyvault_purge_protection_disabled', 'Security', 'Key Vault Purge Protection Disabled', 'Purge protection is not enabled, allowing permanent deletion of keys during the retention period.', 'AzureKeyVault', '["Enable purge protection for Key Vaults storing critical keys."]'::jsonb, '["Enable purge protection (cannot be disabled once enabled)."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/key-vault/general/soft-delete-overview"]'::jsonb),
  ('azure_sentinel_alert_rule_disabled', 'Security', 'Sentinel Alert Rule Disabled', 'A Microsoft Sentinel analytics rule is disabled and will not detect threats. Disabled rules create gaps in security monitoring coverage.', 'AzureSentinel', '["Enable the rule or remove if no longer needed."]'::jsonb, '["Enable the alert rule in Sentinel."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/sentinel/detect-threats-built-in"]'::jsonb),
  ('azure_sentinel_no_automation_rules', 'Security', 'Sentinel Has No Automation Rules', 'No automation rules are configured for incident response.', 'AzureSentinel', '["Create automation rules to speed up incident response."]'::jsonb, '["Configure automation rules for common incident types."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/sentinel/automate-incident-handling-with-automation-rules"]'::jsonb),
  ('azure_sentinel_no_data_connectors', 'Security', 'Sentinel Has No Data Connectors', 'No data connectors are configured to ingest security data.', 'AzureSentinel', '["Connect data sources to enable threat detection."]'::jsonb, '["Configure data connectors for your security data sources."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/sentinel/connect-data-sources"]'::jsonb),
  ('azure_container_registry_admin_user_enabled', 'Security', 'Container Registry Admin User Enabled', 'The admin user is enabled, which provides unrestricted access.', 'AzureContainerRegistry', '["Disable the admin user and use Azure AD authentication."]'::jsonb, '["\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication"]'::jsonb),
  ('azure_container_registry_public_network_access_enabled', 'Security', 'Container Registry Public Network Access Enabled', 'The registry is accessible from the public internet.', 'AzureContainerRegistry', '["Disable public access and use private endpoints."]'::jsonb, '["Configure network rules to restrict access."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-private-link"]'::jsonb),
  ('azure_entra_id_overly_permissive_role', 'Security', 'Entra ID Overly Permissive Role Assignment', 'A user or service principal has an overly permissive directory role.', 'AzureEntraID', '["Review role assignments and apply the principle of least privilege."]'::jsonb, '["Remove unnecessary role assignments and use more targeted roles."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/best-practices"]'::jsonb),
  ('azure_entra_id_service_principal_credentials_expired', 'Security', 'Entra ID Service Principal Credentials Expired', 'An Azure Entra ID service principal has expired credentials. Expired credentials can cause authentication failures for applications and automated processes that depend on this identity.', 'AzureEntraID', '["Rotate the expired credentials immediately."]'::jsonb, '["Generate new credentials for the service principal."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-certificates-for-federated-single-sign-on"]'::jsonb),
  ('azure_entra_id_service_principal_credentials_expiring_soon', 'Security', 'Entra ID Service Principal Credentials Expiring Soon', 'A service principal has credentials that will expire soon.', 'AzureEntraID', '["Rotate credentials before they expire to prevent service disruptions."]'::jsonb, '["Generate new credentials and update dependent applications."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-certificates-for-federated-single-sign-on"]'::jsonb),
  ('azure_frontdoor_enable_waf', 'Security', 'Front Door WAF Should Be Enabled', 'Web Application Firewall (WAF) is not enabled on the Azure Front Door profile. WAF provides protection against common web exploits such as SQL injection and cross-site scripting.', 'AzureFrontDoor', '["Enable WAF to protect against web application attacks."]'::jsonb, '["Create and associate a WAF policy with the Front Door endpoint."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/web-application-firewall/afds/afds-overview"]'::jsonb),
  ('azure_appgateway_waf_disabled', 'Security', 'Application Gateway WAF Disabled', 'Web Application Firewall (WAF) is not enabled on this Azure Application Gateway. WAF protects web applications from common attacks and vulnerabilities.', 'AzureAppGateway', '["Enable WAF for web application protection."]'::jsonb, '["Upgrade to WAF v2 SKU and enable WAF."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/web-application-firewall/ag/ag-overview"]'::jsonb),
  ('azure_nsg_overly_permissive_inbound', 'Security', 'NSG Has Overly Permissive Inbound Rule', 'A Network Security Group has an inbound rule that allows traffic from any source.', 'AzureNSG', '["Restrict inbound rules to specific source IP ranges."]'::jsonb, '["Update the NSG rule to restrict source addresses."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview"]'::jsonb),
  ('azure_vnet_ddos_protection_disabled', 'Security', 'VNet DDoS Protection Disabled', 'DDoS protection is not enabled for the virtual network.', 'AzureVNet', '["Enable DDoS protection for production virtual networks."]'::jsonb, '["Associate a DDoS protection plan with the virtual network."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/ddos-protection/ddos-protection-overview"]'::jsonb),
  ('azure_vnet_subnet_without_nsg', 'Security', 'VNet Subnet Without NSG', 'A subnet does not have a Network Security Group associated.', 'AzureVNet', '["Associate an NSG with every subnet for traffic filtering."]'::jsonb, '["Create and associate an NSG with the subnet."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview"]'::jsonb),
  ('gcp_native_iam_policy', 'Security', 'GCP IAM Policy Recommendation', 'Google Cloud recommends changes to IAM policies to follow the principle of least privilege.', 'GCPIAM', '["Review and apply the recommended IAM policy changes to reduce over-permissioned roles."]'::jsonb, '["Apply the recommended IAM policy adjustments in the GCP Console or via gcloud CLI."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_cloudsql_instance_security', 'Security', 'GCP Cloud SQL Security Recommendation', 'Google Cloud has identified a security recommendation for your Cloud SQL instance.', 'CloudSQL', '["Review and apply the security recommendation to improve your Cloud SQL instance security posture."]'::jsonb, '["Apply the recommended security settings in the Cloud SQL console."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/best-practices"]'::jsonb),
  ('azure_native_advisor_security', 'Security', 'Azure Advisor Security Recommendation', 'Azure Advisor has identified a security improvement opportunity for your resources.', 'AzureAdvisor', '["Review and implement the Azure Advisor security recommendation."]'::jsonb, '["Follow the remediation steps provided in the Azure Advisor recommendation details."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/advisor/advisor-security-recommendations"]'::jsonb),
  ('aws_elasticache_encryption_at_rest', 'Security', 'ElastiCache Encryption at Rest Should Be Enabled', 'Amazon ElastiCache clusters should have encryption at rest enabled to protect sensitive data stored in cache. Encryption at rest uses AWS KMS keys to encrypt the data on disk, backups, and replicas, ensuring compliance with data protection regulations.', 'AmazonElastiCache', '["Enable encryption at rest for ElastiCache clusters. Note that encryption at rest can only be enabled during cluster creation \\u2014 existing clusters without encryption must be recreated with encryption enabled."]'::jsonb, '["Create a new ElastiCache cluster with encryption at rest enabled:\n\\", "\\", "\\", "\n\nMigrate data from the unencrypted cluster to the new encrypted cluster, then update your application configuration to point to the new cluster."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/at-rest-encryption.html"]'::jsonb),
  ('aws_elasticache_encryption_in_transit', 'Security', 'ElastiCache Encryption in Transit Should Be Enabled', 'Amazon ElastiCache clusters should have encryption in transit (TLS) enabled to protect data as it moves between clients and the cache cluster. Without encryption in transit, data including credentials and sensitive application data can be intercepted.', 'AmazonElastiCache', '["Enable encryption in transit for ElastiCache clusters to ensure all communication between clients and the cache is encrypted using TLS. Update client applications to connect using TLS-enabled endpoints."]'::jsonb, '["Create a new ElastiCache cluster with encryption in transit enabled:\n\\", "\\", "\\", "\n\nUpdate application connection strings to use the TLS endpoint and port 6380."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/in-transit-encryption.html"]'::jsonb),
  ('aws_guardduty_not_enabled', 'Security', 'AWS GuardDuty Should Be Enabled', 'Amazon GuardDuty is a threat detection service that continuously monitors for malicious activity and unauthorized behavior. It analyzes CloudTrail events, VPC Flow Logs, and DNS logs to identify threats such as compromised instances, reconnaissance, and account compromise.', 'AmazonGuardDuty', '["Enable Amazon GuardDuty in all AWS regions to ensure comprehensive threat detection coverage. Configure GuardDuty to send findings to a central security account for aggregated monitoring."]'::jsonb, '["Enable GuardDuty in the current region:\n\\", "\\", "\\", "\n\nTo enable in all regions:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "APRA", "MAS"]'::jsonb, '["https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_settingup.html"]'::jsonb),
  ('azure_aks_enable_rbac', 'Security', 'Azure AKS RBAC Should Be Enabled', 'RBAC is not enabled on this AKS cluster. Without RBAC, all authenticated users have full cluster admin access.', 'AKS', '["RBAC is not enabled on this AKS cluster. Without RBAC, all authenticated users have full cluster admin access."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/aks/manage-azure-rbac"]'::jsonb),
  ('azure_app_service_client_cert_disabled', 'Security', 'Azure App Service Client Certificate Should Be Required', 'Client certificate authentication is not enabled, meaning any client can access the service without presenting a certificate.', 'AppService', '["Client certificate authentication is not enabled, meaning any client can access the service without presenting a certificate."]'::jsonb, '["Enable App Service Client Certificate Should Be Required through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/app-service/app-service-web-configure-tls-mutual-auth"]'::jsonb),
  ('azure_bot_service_managed_identity_disabled', 'Security', 'Azure Bot Service Managed Identity Should Be Enabled', 'Managed identity is not configured for this Bot Service, requiring credentials to be stored in configuration.', 'BotService', '["Managed identity is not configured for this Bot Service, requiring credentials to be stored in configuration."]'::jsonb, '["Enable Bot Service Managed Identity through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-authentication-managed-identity"]'::jsonb),
  ('azure_bot_service_public_network_access_enabled', 'Security', 'Azure Bot Service Public Network Access Should Be Restricted', 'Public network access is enabled, exposing the Bot Service to the internet.', 'BotService', '["Public network access is enabled, exposing the Bot Service to the internet."]'::jsonb, '["Disable or restrict Bot Service Public Network Access through the Azure Portal or using Azure CLI. Refer to the documentation for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/bot-service/dl-network-isolation-concept"]'::jsonb),
  ('azure_container_app_insecure_ingress', 'Security', 'Azure Container App Ingress Should Require HTTPS', 'The Container App allows HTTP traffic. All traffic should be encrypted using HTTPS.', 'ContainerApps', '["The Container App allows HTTP traffic. All traffic should be encrypted using HTTPS."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-apps/ingress-overview"]'::jsonb),
  ('azure_container_app_no_managed_identity', 'Security', 'Azure Container App Should Use Managed Identity', 'Managed identity is not configured, requiring credentials to be stored in configuration or environment variables.', 'ContainerApps', '["Managed identity is not configured, requiring credentials to be stored in configuration or environment variables."]'::jsonb, '["Configure Container App Should Use Managed Identity through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-apps/managed-identity"]'::jsonb),
  ('azure_container_app_public_ingress_no_auth', 'Security', 'Azure Container App Public Ingress Has No Authentication', 'The Container App is publicly accessible without authentication configured.', 'ContainerApps', '["The Container App is publicly accessible without authentication configured."]'::jsonb, '["Configure Container App Public Ingress Authentication through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-apps/authentication"]'::jsonb),
  ('azure_container_app_secrets_not_keyvault', 'Security', 'Azure Container App Secrets Should Reference Key Vault', 'Container App secrets are stored directly instead of referencing Azure Key Vault, increasing the risk of secret exposure.', 'ContainerApps', '["Container App secrets are stored directly instead of referencing Azure Key Vault, increasing the risk of secret exposure."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-apps/manage-secrets"]'::jsonb),
  ('azure_container_registry_arm_token_auth_enabled', 'Security', 'Azure Container Registry ARM Token Auth Should Be Disabled', 'ARM audience token authentication is enabled, which is less secure than AAD token authentication.', 'ContainerRegistry', '["ARM audience token authentication is enabled, which is less secure than AAD token authentication."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication"]'::jsonb),
  ('azure_container_registry_cmk_encryption_disabled', 'Security', 'Azure Container Registry Should Use CMK Encryption', 'Customer-managed key encryption is not enabled on this container registry.', 'ContainerRegistry', '["Customer-managed key encryption is not enabled on this container registry."]'::jsonb, '["Enable Container Registry Should Use CMK Encryption through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-customer-managed-keys"]'::jsonb),
  ('azure_container_registry_no_ip_rules', 'Security', 'Azure Container Registry Should Have IP Rules', 'No IP access rules are configured, allowing connections from any network.', 'ContainerRegistry', '["No IP access rules are configured, allowing connections from any network."]'::jsonb, '["Configure Container Registry IP Rules through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-access-selected-networks"]'::jsonb),
  ('azure_container_registry_no_managed_identity', 'Security', 'Azure Container Registry Should Use Managed Identity', 'Managed identity is not configured for this container registry.', 'ContainerRegistry', '["Managed identity is not configured for this container registry."]'::jsonb, '["Configure Container Registry Should Use Managed Identity through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication-managed-identity"]'::jsonb),
  ('azure_container_registry_no_private_endpoints', 'Security', 'Azure Container Registry Should Use Private Endpoints', 'No private endpoints are configured, meaning traffic goes over the public internet.', 'ContainerRegistry', '["No private endpoints are configured, meaning traffic goes over the public internet."]'::jsonb, '["Configure Container Registry Should Use Private Endpoints through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/container-registry-private-link"]'::jsonb),
  ('azure_container_registry_trusted_ms_disabled', 'Security', 'Azure Container Registry Trusted Microsoft Services Should Be Allowed', 'Trusted Microsoft services are not allowed to bypass network restrictions.', 'ContainerRegistry', '["Trusted Microsoft services are not allowed to bypass network restrictions."]'::jsonb, '["Enable Container Registry Trusted Microsoft Services Should Be Allowed through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/container-registry/allow-access-trusted-services"]'::jsonb),
  ('azure_ddos_protection_no_plan', 'Security', 'Azure DDoS Protection Plan Should Be Created', 'No DDoS Protection Plan exists in this subscription. DDoS Protection Standard provides enhanced mitigation capabilities.', 'DDoSProtection', '["No DDoS Protection Plan exists in this subscription. DDoS Protection Standard provides enhanced mitigation capabilities."]'::jsonb, '["Configure DDoS Protection Plan Should Be Created through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/ddos-protection/ddos-protection-overview"]'::jsonb),
  ('azure_ddos_protection_plan_no_vnets', 'Security', 'Azure DDoS Protection Plan Has No Associated VNets', 'The DDoS Protection Plan exists but has no virtual networks associated with it.', 'DDoSProtection', '["The DDoS Protection Plan exists but has no virtual networks associated with it."]'::jsonb, '["Configure DDoS Protection Plan Associated VNets through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/ddos-protection/manage-ddos-protection"]'::jsonb),
  ('azure_ddos_protection_public_ip_disabled', 'Security', 'Azure DDoS Protection Public IP Not Protected', 'A public IP address is not protected by DDoS Protection.', 'DDoSProtection', '["A public IP address is not protected by DDoS Protection."]'::jsonb, '["Enable DDoS Protection Public IP Not Protected through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/ddos-protection/manage-ddos-protection"]'::jsonb),
  ('azure_ddos_protection_public_ip_not_protected', 'Security', 'Azure Public IP Without DDoS Protection', 'A public IP resource is not covered by any DDoS Protection Plan.', 'DDoSProtection', '["A public IP resource is not covered by any DDoS Protection Plan."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/ddos-protection/manage-ddos-protection"]'::jsonb),
  ('azure_ddos_protection_vnet_not_protected', 'Security', 'Azure VNet Not Protected by DDoS Protection', 'A virtual network is not associated with any DDoS Protection Plan.', 'DDoSProtection', '["A virtual network is not associated with any DDoS Protection Plan."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/ddos-protection/manage-ddos-protection"]'::jsonb),
  ('azure_devops_project_public_visibility', 'Security', 'Azure DevOps Project Should Not Be Public', 'The project is publicly visible, potentially exposing source code and work items.', 'AzureDevOps', '["The project is publicly visible, potentially exposing source code and work items."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/devops/organizations/projects/make-project-public"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('azure_disk_public_network_access_enabled', 'Security', 'Azure Managed Disk Public Access Should Be Disabled', 'Public network access is enabled for disk export/import operations.', 'ManagedDisks', '["Public network access is enabled for disk export/import operations."]'::jsonb, '["Disable or restrict Managed Disk Public Access through the Azure Portal or using Azure CLI. Refer to the documentation for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-private-links-for-import-export-portal"]'::jsonb),
  ('azure_disk_unattached_cmk_missing', 'Security', 'Azure Unattached Disk Should Use CMK Encryption', 'An unattached disk is not encrypted with customer-managed keys.', 'ManagedDisks', '["An unattached disk is not encrypted with customer-managed keys."]'::jsonb, '["Configure Unattached Disk Should Use CMK Encryption through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption"]'::jsonb),
  ('azure_disk_unattached_unencrypted', 'Security', 'Azure Unattached Disk Is Not Encrypted', 'An unattached disk is not encrypted, potentially exposing data at rest.', 'ManagedDisks', '["An unattached disk is not encrypted, potentially exposing data at rest."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption-overview"]'::jsonb),
  ('azure_dns_add_caa_record', 'Security', 'Azure DNS Zone Should Have CAA Records', 'No CAA records are configured, allowing any CA to issue certificates for the domain.', 'DNS', '["No CAA records are configured, allowing any CA to issue certificates for the domain."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/dns/dns-faq"]'::jsonb),
  ('azure_entra_id_guest_with_privileged_role', 'Security', 'Azure Entra ID Guest Users Should Not Have Privileged Roles', 'Guest users have been assigned privileged roles, which could lead to unauthorized access.', 'EntraID', '["Guest users have been assigned privileged roles, which could lead to unauthorized access."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/security-planning"]'::jsonb),
  ('azure_entra_id_service_principal_certificates_expired', 'Security', 'Azure Service Principal Certificate Has Expired', 'A service principal''s certificate has expired, potentially causing authentication failures.', 'EntraID', '["A service principal''s certificate has expired, potentially causing authentication failures."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity-platform/certificate-credentials"]'::jsonb),
  ('azure_entra_id_service_principal_certificates_expiring_soon', 'Security', 'Azure Service Principal Certificate Expiring Soon', 'A service principal''s certificate will expire soon and should be renewed.', 'EntraID', '["A service principal''s certificate will expire soon and should be renewed."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity-platform/certificate-credentials"]'::jsonb),
  ('azure_eventgrid_domain_local_auth_enabled', 'Security', 'Azure Event Grid Domain Local Auth Should Be Disabled', 'Local authentication is enabled, which is less secure than Azure AD authentication.', 'EventGrid', '["Local authentication is enabled, which is less secure than Azure AD authentication."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/event-grid/authenticate-with-access-keys-shared-access-signatures"]'::jsonb),
  ('azure_eventgrid_domain_public_access_enabled', 'Security', 'Azure Event Grid Domain Public Access Should Be Restricted', 'Public network access is enabled on the Event Grid domain.', 'EventGrid', '["Public network access is enabled on the Event Grid domain."]'::jsonb, '["Disable or restrict Event Grid Domain Public Access through the Azure Portal or using Azure CLI. Refer to the documentation for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/event-grid/configure-firewall"]'::jsonb),
  ('azure_eventgrid_topic_no_managed_identity', 'Security', 'Azure Event Grid Topic Should Use Managed Identity', 'Managed identity is not configured for this Event Grid topic.', 'EventGrid', '["Managed identity is not configured for this Event Grid topic."]'::jsonb, '["Configure Event Grid Topic Should Use Managed Identity through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/event-grid/managed-service-identity"]'::jsonb),
  ('azure_eventgrid_topic_public_access_no_ip_filter', 'Security', 'Azure Event Grid Topic Public Access Without IP Filter', 'Public access is enabled without IP filtering, allowing connections from any network.', 'EventGrid', '["Public access is enabled without IP filtering, allowing connections from any network."]'::jsonb, '["Configure Event Grid Topic Public Access Without IP Filter through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/event-grid/configure-firewall"]'::jsonb),
  ('azure_files_enable_smb_encryption', 'Security', 'Azure Files SMB Encryption Should Be Enabled', 'SMB encryption is not enabled for Azure Files, leaving data in transit unencrypted.', 'AzureFiles', '["SMB encryption is not enabled for Azure Files, leaving data in transit unencrypted."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/files/storage-files-smb-multichannel-performance"]'::jsonb),
  ('azure_firewall_enable_threat_intel', 'Security', 'Azure Firewall Threat Intelligence Should Be Enabled', 'Threat intelligence-based filtering is not enabled, missing automatic blocking of known malicious IPs.', 'AzureFirewall', '["Threat intelligence-based filtering is not enabled, missing automatic blocking of known malicious IPs."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/firewall/threat-intel"]'::jsonb),
  ('azure_frontdoor_enable_https_redirect', 'Security', 'Azure Front Door HTTPS Redirect Should Be Enabled', 'HTTP to HTTPS redirect is not configured, allowing unencrypted connections.', 'FrontDoor', '["HTTP to HTTPS redirect is not configured, allowing unencrypted connections."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/frontdoor/front-door-how-to-redirect-https"]'::jsonb),
  ('azure_mariadb_ssl_disabled', 'Security', 'Azure MariaDB SSL Enforcement Should Be Enabled', 'SSL enforcement is disabled, allowing unencrypted database connections.', 'MariaDB', '["SSL enforcement is disabled, allowing unencrypted database connections."]'::jsonb, '["Enable MariaDB SSL Enforcement through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/mariadb/concepts-ssl-connection-security"]'::jsonb),
  ('azure_ml_workspace_hbi_not_enabled', 'Security', 'Azure ML Workspace High Business Impact Should Be Enabled', 'High business impact mode is not enabled, which provides additional data isolation.', 'MachineLearning', '["High business impact mode is not enabled, which provides additional data isolation."]'::jsonb, '["Enable ML Workspace High Business Impact through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/machine-learning/concept-data-encryption"]'::jsonb),
  ('azure_ml_workspace_managed_identity_disabled', 'Security', 'Azure ML Workspace Managed Identity Should Be Enabled', 'Managed identity is not configured for the ML workspace.', 'MachineLearning', '["Managed identity is not configured for the ML workspace."]'::jsonb, '["Enable ML Workspace Managed Identity through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/machine-learning/how-to-identity-based-service-authentication"]'::jsonb),
  ('azure_ml_workspace_public_network_access_enabled', 'Security', 'Azure ML Workspace Public Network Access Should Be Disabled', 'Public network access is enabled on the ML workspace.', 'MachineLearning', '["Public network access is enabled on the ML workspace."]'::jsonb, '["Disable or restrict ML Workspace Public Network Access through the Azure Portal or using Azure CLI. Refer to the documentation for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/machine-learning/how-to-configure-private-link"]'::jsonb),
  ('azure_redis_enable_non_ssl_port', 'Security', 'Azure Redis Non-SSL Port Should Be Disabled', 'The non-SSL port (6379) is enabled, allowing unencrypted connections.', 'RedisCache', '["The non-SSL port (6379) is enabled, allowing unencrypted connections."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-configure"]'::jsonb),
  ('azure_redis_non_ssl_port_enabled', 'Security', 'Azure Redis Cache Non-SSL Port Is Enabled', 'Non-SSL port is enabled on this Redis Cache instance, exposing data in transit.', 'RedisCache', '["Non-SSL port is enabled on this Redis Cache instance, exposing data in transit."]'::jsonb, '["Disable or restrict Redis Cache Non-SSL Port Is Enabled through the Azure Portal or using Azure CLI. Refer to the documentation for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-configure"]'::jsonb),
  ('azure_redis_old_tls_version', 'Security', 'Azure Redis Cache TLS Version Should Be Updated', 'The Redis Cache uses an older TLS version with known vulnerabilities.', 'RedisCache', '["The Redis Cache uses an older TLS version with known vulnerabilities."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-remove-tls-10-11"]'::jsonb),
  ('azure_redis_public_network_access', 'Security', 'Azure Redis Cache Public Network Access Should Be Restricted', 'Public network access is enabled on this Redis Cache.', 'RedisCache', '["Public network access is enabled on this Redis Cache."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-private-link"]'::jsonb),
  ('azure_sentinel_no_threat_intel', 'Security', 'Azure Sentinel Threat Intelligence Not Configured', 'Threat intelligence indicators are not configured in Sentinel.', 'Sentinel', '["Threat intelligence indicators are not configured in Sentinel."]'::jsonb, '["Configure Sentinel Threat Intelligence Not Configured through the Azure Portal or using Azure CLI. Refer to the documentation link below for detailed configuration steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/sentinel/understand-threat-intelligence"]'::jsonb),
  ('azure_storage_anonymous_access_enabled', 'Security', 'Azure Storage Account Anonymous Access Should Be Disabled', 'Anonymous (public) access is enabled on this storage account, allowing unauthenticated users to read data from containers. This can lead to data exposure and is a common source of cloud data breaches.', 'StorageAccounts', '["Disable anonymous access on the storage account and all containers. Use SAS tokens or Azure AD authentication for authorized access."]'::jsonb, '["Disable anonymous access:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/blobs/anonymous-read-access-prevent"]'::jsonb),
  ('azure_storage_cmk_disabled', 'Security', 'Azure Storage Should Use Customer-Managed Keys', 'This storage account uses Microsoft-managed keys for encryption. Customer-managed keys (CMK) provide additional control over encryption keys, including rotation, revocation, and audit capabilities.', 'StorageAccounts', '["Configure customer-managed keys stored in Azure Key Vault for storage account encryption."]'::jsonb, '["Configure CMK encryption:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/customer-managed-keys-overview"]'::jsonb),
  ('azure_storage_minimum_tls_version_not_set_to_1_2', 'Security', 'Azure Storage Minimum TLS Version Should Be 1.2', 'This storage account allows connections using TLS versions older than 1.2. Older TLS versions (1.0, 1.1) have known vulnerabilities and should be disabled to protect data in transit.', 'StorageAccounts', '["Set the minimum TLS version to 1.2 for the storage account."]'::jsonb, '["Update minimum TLS version:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/transport-layer-security-configure-minimum-version"]'::jsonb),
  ('azure_storage_public_network_access_enabled', 'Security', 'Azure Storage Public Network Access Should Be Disabled', 'Public network access is enabled on this storage account, allowing connections from any IP address on the internet. Restricting network access to specific VNets and IP ranges reduces the attack surface.', 'StorageAccounts', '["Disable public network access and use private endpoints or VNet service endpoints for secure connectivity."]'::jsonb, '["Disable public network access:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-network-security"]'::jsonb),
  ('azure_storage_secure_transfer_disabled', 'Security', 'Azure Storage Secure Transfer Should Be Required', 'Secure transfer (HTTPS only) is not required for this storage account. Without this setting, data can be transmitted over unencrypted HTTP connections.', 'StorageAccounts', '["Secure transfer required"]'::jsonb, '["Enable secure transfer:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-require-secure-transfer"]'::jsonb),
  ('azure_storage_shared_key_authorization_enabled', 'Security', 'Azure Storage Shared Key Authorization Should Be Disabled', 'Shared key authorization is enabled, allowing access using storage account keys. Shared keys are long-lived credentials that, if compromised, provide unrestricted access. Azure AD authentication is the recommended alternative.', 'StorageAccounts', '["Disable shared key access and use Azure AD authentication or SAS tokens with limited scope and expiration."]'::jsonb, '["Disable shared key access:\n\\", "\\", "\\", "\n\nEnsure all applications are updated to use Azure AD authentication before disabling."]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/shared-key-authorization-prevent"]'::jsonb),
  ('azure_vm_boot_disk_encryption_disabled', 'Security', 'Azure VM OS Disk Encryption Should Be Enabled', 'The OS disk of this Azure VM is not encrypted with Azure Disk Encryption (ADE) or server-side encryption with customer-managed keys. Disk encryption protects data at rest and helps meet organizational security and compliance requirements.', 'VirtualMachines', '["Enable Azure Disk Encryption on the OS disk using either platform-managed keys (default SSE) or customer-managed keys (CMK) stored in Azure Key Vault for enhanced control."]'::jsonb, '["Enable Azure Disk Encryption on the VM:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption-overview"]'::jsonb),
  ('azure_vm_confidential_computing_disabled', 'Security', 'Azure VM Confidential Computing Should Be Enabled', 'Azure Confidential Computing protects data in use by using hardware-based Trusted Execution Environments (TEEs). This ensures that data remains encrypted in memory and is protected from the cloud operator, making it suitable for highly sensitive workloads.', 'VirtualMachines', '["Consider deploying confidential computing VMs (DCsv2, DCsv3, or DCdsv3 series) for workloads that process highly sensitive data requiring protection from cloud operators."]'::jsonb, '["Deploy a confidential computing VM:\n\\", "\\", "\\", ""]'::jsonb, '["NIST4", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/confidential-computing/overview"]'::jsonb),
  ('azure_vm_data_disk_encryption_disabled', 'Security', 'Azure VM Data Disk Encryption Should Be Enabled', 'One or more data disks attached to this Azure VM are not encrypted. Data disk encryption protects sensitive data at rest and is required for many compliance frameworks.', 'VirtualMachines', '["Enable encryption on all data disks attached to the VM using Azure Disk Encryption or server-side encryption with customer-managed keys."]'::jsonb, '["Enable encryption on all disks (OS and data):\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA", "PCI-DSS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption-overview"]'::jsonb),
  ('azure_vm_disk_encryption_cmk_missing', 'Security', 'Azure VM Disk Should Use Customer-Managed Keys', 'Azure VM disks are encrypted with platform-managed keys by default, but customer-managed keys (CMK) provide additional control over the encryption keys, including the ability to rotate, disable, and audit key usage through Azure Key Vault.', 'VirtualMachines', '["Configure disk encryption with customer-managed keys stored in Azure Key Vault for enhanced encryption key management and compliance."]'::jsonb, '["Create a disk encryption set with a CMK and apply it:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2", "HIPAA"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption"]'::jsonb),
  ('azure_vm_endpoint_protection_missing', 'Security', 'Azure VM Endpoint Protection Should Be Installed', 'Endpoint protection (antimalware) is not installed on this VM. Without endpoint protection, the VM is vulnerable to malware, viruses, and other malicious software that could compromise data and workloads.', 'VirtualMachines', '["Install and configure Microsoft Antimalware or a supported third-party endpoint protection solution on the VM."]'::jsonb, '["Install Microsoft Antimalware extension:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/iaas-antimalware-windows"]'::jsonb),
  ('azure_vm_entra_id_authentication_disabled', 'Security', 'Azure VM Should Use Entra ID Authentication', 'Microsoft Entra ID (formerly Azure AD) authentication for VMs provides centralized identity management, conditional access policies, and MFA support. Using local accounts increases the risk of credential theft and makes access auditing difficult.', 'VirtualMachines', '["Enable Microsoft Entra ID login for the VM to leverage centralized identity management, conditional access policies, and audit logging."]'::jsonb, '["Install the AAD login extension:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/devices/howto-vm-sign-in-azure-ad-linux"]'::jsonb),
  ('azure_vm_jit_access_disabled', 'Security', 'Azure VM Just-In-Time Access Should Be Enabled', 'Just-in-time (JIT) VM access reduces exposure to attacks by locking down inbound traffic to Azure VMs and providing time-limited access when needed. Without JIT, management ports (RDP/SSH) may be permanently open, increasing the attack surface.', 'VirtualMachines', '["Enable JIT VM access through Microsoft Defender for Cloud to restrict management port access and require time-limited, approved access requests."]'::jsonb, '["Enable JIT access via Azure Portal: Navigate to Microsoft Defender for Cloud > Workload protections > Just-in-time VM access > Enable JIT on the VM.\n\nOr via CLI:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/defender-for-cloud/just-in-time-access-usage"]'::jsonb),
  ('azure_vm_ssh_password_authentication_enabled', 'Security', 'Azure VM SSH Password Authentication Should Be Disabled', 'SSH password authentication is enabled on this Linux VM. Password-based SSH authentication is vulnerable to brute-force attacks. SSH key-based authentication provides stronger security and should be used instead.', 'VirtualMachines', '["Disable SSH password authentication and use SSH key-based authentication instead. Ensure SSH keys are properly configured before disabling password authentication."]'::jsonb, '["Disable password authentication in the VM''s SSH configuration:\n\\", "\\", "\\", "\n\nThen SSH into the VM and disable password auth:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys"]'::jsonb),
  ('azure_vm_system_assigned_identity_disabled', 'Security', 'Azure VM System-Assigned Managed Identity Should Be Enabled', 'System-assigned managed identity provides an automatically managed identity in Microsoft Entra ID for the VM. It eliminates the need to store credentials in code and enables secure access to Azure resources through Azure RBAC.', 'VirtualMachines', '["Enable system-assigned managed identity for the VM to allow secure, credential-free access to Azure services like Key Vault, Storage, and SQL Database."]'::jsonb, '["Enable system-assigned managed identity:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/qs-configure-cli-windows-vm"]'::jsonb),
  ('azure_vm_trusted_launch_disabled', 'Security', 'Azure VM Trusted Launch Should Be Enabled', 'Trusted Launch protects Azure VMs against advanced and persistent attack techniques by providing Secure Boot, vTPM, and boot integrity monitoring. Without Trusted Launch, VMs are more susceptible to rootkits and boot-level malware.', 'VirtualMachines', '["Enable Trusted Launch for new VM deployments to protect against boot-level attacks with Secure Boot and vTPM capabilities."]'::jsonb, '["Create a new VM with Trusted Launch enabled:\n\\", "\\", "\\", "\n\nNote: Existing VMs cannot be upgraded to Trusted Launch. A new VM must be created."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/trusted-launch"]'::jsonb),
  ('azure_vmss_instance_public_ip_assigned', 'Security', 'Azure VMSS Instances Should Not Have Public IPs', 'VMSS instances have public IP addresses assigned directly, exposing them to the internet. This increases the attack surface and makes instances vulnerable to unauthorized access attempts.', 'VirtualMachineScaleSets', '["Remove public IP configurations from VMSS instances. Use Azure Load Balancer, Application Gateway, or Azure Bastion for controlled access."]'::jsonb, '["Remove public IP from VMSS configuration:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-networking"]'::jsonb),
  ('azure_vmss_system_assigned_identity_disabled', 'Security', 'Azure VMSS System-Assigned Identity Should Be Enabled', 'System-assigned managed identity is not enabled on this VMSS. Managed identities eliminate the need to store credentials in code and enable secure access to Azure resources.', 'VirtualMachineScaleSets', '["Enable system-assigned managed identity for the VMSS to allow credential-free access to Azure services."]'::jsonb, '["Enable system-assigned identity:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4", "SOC2"]'::jsonb, '["https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/qs-configure-cli-windows-vmss"]'::jsonb),
  ('azure_vmss_trusted_launch_disabled', 'Security', 'Azure VMSS Trusted Launch Should Be Enabled', 'Trusted Launch is not enabled on this VMSS. Trusted Launch protects against boot-level attacks with Secure Boot and vTPM capabilities.', 'VirtualMachineScaleSets', '["Enable Trusted Launch for new VMSS deployments to protect against boot-level threats."]'::jsonb, '["Create a new VMSS with Trusted Launch:\n\\", "\\", "\\", ""]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/trusted-launch"]'::jsonb),
  ('azure_vnet_service_endpoints_not_configured', 'Security', 'Azure VNet Service Endpoints Should Be Configured', 'Service endpoints are not configured, meaning traffic to Azure services goes over the public internet.', 'VirtualNetworks', '["Service endpoints are not configured, meaning traffic to Azure services goes over the public internet."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-service-endpoints-overview"]'::jsonb),
  ('azure_vnet_vm_protection_disabled', 'Security', 'Azure VNet VM Protection Is Disabled', 'VM protection is not enabled on this Azure Virtual Network. VM protection prevents accidental deletion of VMs within the VNet by requiring explicit override.', 'VirtualNetworks', '["VM protection is not enabled on the VNet."]'::jsonb, '["Enable VNet VM Protection through the Azure Portal or using Azure CLI/Terraform. Refer to the documentation link below for detailed steps."]'::jsonb, '["CIS", "NIST4"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview"]'::jsonb),
  ('aws_elasticache_engine_version', 'InfraUpgrade', 'Use latest ElastiCache Engine Version', 'When your Amazon ElastiCache clusters are configured with the latest version of Redis/Memcached cache engine, you can benefit from new features and enhancements, better performance, better memory management, bug fixes and security patches. For example, upgrading your Redis cache clusters version to 3.2.6 will get you all the improvements that come with the Redis engine version 3 (data partitioning, geospatial indexing, online cluster resizing, replica scaling, etc) plus the ones added by AWS such as support for newer cache node types, in-transit and at-rest encryption, and support for HIPAA compliance. For Memcached cache clusters, upgrading the engine version to 1.4.34 will add several bug fixes, systemd service hardening, improved support for large items over 1MB and the ability to dynamically increase the amount of memory available to the engine without having to restart the cache cluster.', 'AmazonElastiCache', '["Ensure that your Amazon ElastiCache clusters are using the stable latest version of Redis/Memcached cache engine in order to adhere to AWS cloud best practices, benefit from better security by having the most recent vulnerability patches, receive the latest Redis and Memcached software features, and get the latest performance optimizations."]'::jsonb, '["**Terraform configuration file (.tf):**\n\\", "\\", "\\", "\n", "**AWS CLI command to upgrade ElastiCache engine version:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/advisor/advisor-security-recommendations"]'::jsonb),
  ('aws_elasticache_instance_generation', 'InfraUpgrade', 'Elasticache Instance Generation should be latest', 'Using the latest generation of Amazon ElastiCache cluster nodes instead of the previous generation nodes has tangible benefits such as better hardware performance (more computing capacity and faster CPUs, memory optimization, superior I/O, and higher network throughput), better support for the newest Redis/Memcached engine versions, and lower costs for CPU, memory, and storage.', 'AmazonElastiCache', '["Ensure that all the Amazon ElastiCache cache clusters provisioned in your AWS account are using the latest generation of cache node types in order to get the best performance with lower costs. If you are using cache nodes from the previous generation, Trend Micro Cloud One™ – Conformity strongly recommends that you upgrade your nodes with their latest generation equivalents."]'::jsonb, '["**AWS CLI command to upgrade ElastiCache instance generation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/CacheNodes.SupportedTypes.html"]'::jsonb),
  ('aws_ec2_orphaned_volume', 'InfraUpgrade', 'EBS Volumes Should Not Be Orphaned', 'Any Amazon EBS volume provisioned in your AWS cloud account adds charges to your monthly bill, regardless of whether it is in use. If you have Amazon EBS volumes that are not attached to EC2 instances and their data is no longer needed, consider deleting these volumes. Removing unattached/orphaned Amazon EBS volumes from your AWS account will help you to avoid unexpected charges on your AWS bill and halt access to any sensitive data available on these volumes.', 'AmazonEC2', '["Identify unused (unattached) Amazon Elastic Block Store (EBS) volumes available within your AWS cloud account and delete these volumes in order to lower the cost of your AWS bill and reduce the risk of confidential and sensitive data leaks."]'::jsonb, '["**AWS CLI command to delete orphaned EBS volume:**\n        - Create Snapshot\n\\", "\\", "\\", "\n\n        - Delete Volume\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-deleting-volume.html"]'::jsonb),
  ('aws_ec2_ebs_generation_upgrade', 'InfraUpgrade', 'Use latest EBS Volume Generation', 'For same amount of storage space, gp3 is 20 percent more cost-effective than gp2 volumes. It’s also interesting to consider what a maximum performance and maximum throughput volume would cost for both gp2 and gp3', 'AmazonEC2', '["Migrate EBS volumes from GP2 to GP3 to save up to 20% on costs."]'::jsonb, '["**AWS CLI command to upgrade EBS volume generation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://aws.amazon.com/blogs/storage/migrate-your-amazon-ebs-volumes-from-gp2-to-gp3-and-save-up-to-20-on-costs/"]'::jsonb),
  ('aws_rds_instance_generation', 'InfraUpgrade', 'RDS Instance Generation Upgrade', 'Using the latest generation of Amazon RDS database instances instead of the previous generation instances has tangible benefits such as better hardware performance (more computing capacity and faster CPUs, memory optimization and higher network throughput), better support for latest database engines versions, and lower costs for memory and storage', 'AmazonRDS', '["Ensure that all the Amazon RDS databases instances provisioned within your AWS account are using the latest generation of instance classes in order to get the best performance with lower costs. If you are using database instances from the previous generation, Trend Micro Cloud One™ – Conformity strongly recommends that you upgrade your instances with their latest generation equivalents."]'::jsonb, '["**AWS CLI command to upgrade RDS instance generation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html"]'::jsonb),
  ('aws_fargate_latest_platform_version', 'InfraUpgrade', 'Fargate Task Uses Latest Platform Version', 'AWS Fargate platform versions control the runtime environment for tasks. Older platform versions may lack security patches, performance improvements, and new features. Running on the latest platform version ensures you benefit from the most recent improvements.', 'AWSFargate', '["Ensure all Fargate tasks use the LATEST platform version to benefit from security patches and performance improvements."]'::jsonb, '["Update the Fargate service or task definition to use platform version LATEST:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('aws_ecs_fargate_latest_platform_version', 'InfraUpgrade', 'ECS Fargate Service Uses Latest Platform Version', 'ECS Fargate services should run on the latest platform version to receive security fixes, kernel updates, and new features. Using outdated platform versions may expose your workloads to known vulnerabilities.', 'AmazonECS', '["Update ECS Fargate services to use the LATEST platform version."]'::jsonb, '["Update the service platform version:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html"]'::jsonb),
  ('aws_elasticbeanstalk_outdated_platform', 'InfraUpgrade', 'Elastic Beanstalk Uses Outdated Platform', 'AWS Elastic Beanstalk environments running on outdated or retired platform versions may miss critical security patches, bug fixes, and performance improvements. AWS regularly retires older platform branches.', 'AWSElasticBeanstalk', '["Upgrade Elastic Beanstalk environments to the latest supported platform version."]'::jsonb, '["Update the environment platform version:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.platform.upgrade.html"]'::jsonb),
  ('aws_elasticbeanstalk_unhealthy', 'InfraUpgrade', 'Elastic Beanstalk Environment Health Degraded', 'An Elastic Beanstalk environment with degraded or severe health status indicates issues with the underlying instances, deployment, or application. This can affect availability and performance.', 'AWSElasticBeanstalk', '["Investigate and resolve health issues in degraded Elastic Beanstalk environments."]'::jsonb, '["Check environment health:\n\\", "\\", "\\", "\nReview recent events and instance health to identify root cause."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced.html"]'::jsonb),
  ('aws_redshift_cluster_version', 'InfraUpgrade', 'Redshift Cluster Version Upgrade', 'Amazon Redshift regularly releases new cluster versions with performance improvements, security patches, and new features. Running an outdated version may expose you to known vulnerabilities and miss optimizations.', 'AmazonRedshift', '["Ensure Redshift clusters are running the latest available version and that automatic version upgrades are enabled."]'::jsonb, '["Enable automatic version upgrades:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/redshift/latest/mgmt/cluster-versions.html"]'::jsonb),
  ('gcp_gke_old_cluster', 'InfraUpgrade', 'GKE Cluster Running Outdated Kubernetes Version', 'GKE clusters running older Kubernetes versions miss security patches, bug fixes, and new features. Google regularly deprecates older minor versions and eventually removes support.', 'GKE', '["Upgrade GKE clusters to a supported and recent Kubernetes version."]'::jsonb, '["Upgrade the cluster control plane and node pools:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels"]'::jsonb),
  ('gcp_compute_old_instance', 'InfraUpgrade', 'GCE Instance Using Outdated Machine Type', 'Google Compute Engine regularly introduces new machine type families (e.g., N2, E2, C3) with better price-performance ratios. Running instances on older machine types (N1) may cost more for less performance.', 'ComputeEngine', '["Migrate Compute Engine instances to the latest machine type generation for better performance and lower cost."]'::jsonb, '["Stop the instance, change machine type, and restart:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/compute/docs/instances/create-start-instance"]'::jsonb),
  ('gcp_sql_old_instance', 'InfraUpgrade', 'Cloud SQL Instance Running Outdated Database Version', 'Cloud SQL instances running older database engine versions (e.g., MySQL 5.7, PostgreSQL 12) may not receive security updates and lack newer features. Google eventually ends support for older versions.', 'CloudSQL', '["Upgrade Cloud SQL instances to a supported and recent database engine version."]'::jsonb, '["Upgrade the database version (requires downtime):\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/db-versions"]'::jsonb),
  ('gcp_storage_old_bucket', 'InfraUpgrade', 'GCS Bucket Using Legacy Storage Class', 'Google Cloud Storage buckets using legacy storage classes (e.g., Multi-Regional, Regional) should be migrated to the newer Standard, Nearline, Coldline, or Archive classes for better pricing and features.', 'CloudStorage', '["Update GCS bucket storage class from legacy to a current storage class."]'::jsonb, '["Update bucket storage class:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/storage-classes"]'::jsonb),
  ('azure_aks_old_kubernetes_version', 'InfraUpgrade', 'AKS Cluster Running Outdated Kubernetes Version', 'Azure Kubernetes Service clusters running outdated Kubernetes versions miss security patches and new features. Azure supports only a limited number of minor versions at any given time.', 'AKS', '["Upgrade AKS clusters to a supported and recent Kubernetes version."]'::jsonb, '["Upgrade the AKS cluster:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/aks/supported-kubernetes-versions"]'::jsonb),
  ('azure_function_old_runtime', 'InfraUpgrade', 'Azure Function Using Outdated Runtime Version', 'Azure Functions running on deprecated or outdated runtime versions may lack security patches and new features. Microsoft regularly retires older runtime versions.', 'AzureFunctions', '["Upgrade Azure Functions to the latest supported runtime version."]'::jsonb, '["Update the function app runtime version:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions"]'::jsonb),
  ('azure_managed_disk_sku_upgrade', 'InfraUpgrade', 'Azure Managed Disk SKU Upgrade Available', 'Azure Managed Disks have newer SKU options (e.g., Premium SSD v2) that offer better performance-per-cost. Standard HDD disks used for production workloads may benefit from an upgrade.', 'AzureManagedDisks', '["Consider upgrading managed disk SKU to a newer generation for better performance."]'::jsonb, '["Update disk SKU:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types"]'::jsonb),
  ('azure_disk_premium_ssd_v2_upgrade', 'InfraUpgrade', 'Azure Disk Eligible for Premium SSD v2 Upgrade', 'Premium SSD v2 offers sub-millisecond latency with independently configurable IOPS and throughput. Disks currently using Premium SSD (v1) may benefit from upgrading to v2 for better cost-performance.', 'AzureManagedDisks', '["Evaluate whether Premium SSD v2 is a better fit for workloads currently using Premium SSD v1."]'::jsonb, '["Premium SSD v2 migration requires creating a new disk and copying data. Refer to Azure documentation for migration steps."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types"]'::jsonb),
  ('azure_expressroute_enable_standard_sku', 'InfraUpgrade', 'ExpressRoute Circuit Should Use Standard or Premium SKU', 'Azure ExpressRoute circuits using the Basic or Local SKU may have limited features. Standard or Premium SKUs provide better routing options, more virtual network links, and global reach.', 'AzureExpressRoute', '["Evaluate whether upgrading the ExpressRoute circuit SKU would benefit your connectivity requirements."]'::jsonb, '["Update ExpressRoute SKU:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/expressroute/expressroute-about-virtual-network-gateways"]'::jsonb),
  ('azure_vm_generation_upgrade', 'InfraUpgrade', 'Azure VM Using Older Generation', 'Azure regularly introduces new VM series with better price-performance. VMs running on older series (e.g., Dv2) can be upgraded to newer series (e.g., Dv5) for improved performance at similar or lower cost.', 'AzureVMs', '["Upgrade Azure VMs to the latest generation VM series for better performance and cost efficiency."]'::jsonb, '["Resize the VM:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/generation-2"]'::jsonb),
  ('azure_logic_app_outdated_workflow', 'InfraUpgrade', 'Azure Logic App Workflow Is Outdated', 'The Logic App workflow version is outdated and should be updated.', 'LogicApps', '["The Logic App workflow version is outdated and should be updated."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-overview"]'::jsonb),
  ('gcp_compute_generation_upgrade', 'InfraUpgrade', 'GCP Compute Instance Should Be Upgraded to Newer Generation', 'This GCP Compute Engine instance is running on an older machine type generation. Newer generation machine types offer better price-performance ratios with improved processors and hardware capabilities.', 'ComputeEngine', '["Upgrade the instance to a newer machine type generation (e.g., from N1 to N2/N2D, or E2) for improved performance and cost efficiency."]'::jsonb, '["Stop the instance and change the machine type:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://cloud.google.com/compute/docs/machine-resource"]'::jsonb),
  ('aws_rds_underutilized', 'RightSizing', 'Underutilized RDS Instance', 'Identify any Amazon RDS database instances that appear to be underutilized and downsize (resize) them to help lower the cost of your monthly AWS bill. By default, an RDS database instance is considered "underutilized" when meets the following criteria:
        The average CPU utilization has been less than 60% for the last 7 days.
        The total number of ReadIOPS and WriteIOPS recorded per day for the last 7 days has been less than 100 on average.
        The AWS CloudWatch metrics utilized to detect underused RDS instances are:
        CPUUtilization - the percentage of CPU utilization (Units: Percent).
        ReadIOPS and WriteIOPS - the average number of disk I/O (Input/Output) operations per second (Units: Count/Second).
        Note: You can change the default threshold values for this rule on the Cloud Conformity console and set your own values for CPU utilization, and the total number of ReadIOPS and WriteIOPS to configure the underuse level for your RDS instances.', 'AmazonRDS', '["Downsizing underused RDS database instances represents a good strategy for optimizing your monthly AWS costs. For example, downgrading a db.m3.large RDS MySQL database instance to a db.m3.medium instance due to CPU and IOPS underuse, you can save roughly $70 per month (as of March 2017)."]'::jsonb, '["**AWS CLI command to upgrade RDS instance generation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MonitoringOverview.html"]'::jsonb),
  ('aws_rds_overutilized', 'RightSizing', 'Overutilized AWS RDS Instances', 'Identify any Amazon RDS database instances that appear to be overutilized and upgrade (upsize) them to help handle better the database workload and improve the response time. By default, an RDS database instance is considered "overutilized" when meets the following criteria:
      The daily average CPU utilization has been more than 90% for the last 7 days.
      - The AWS CloudWatch metrics utilized to detect overused RDS instances are:
      CPUUtilization - the percentage of CPU utilization (Units: Percent).
      Note: You can change the default threshold values for this rule on the Cloud Conformity console and set your own values for CPU utilization to configure the overuse level for your RDS instances.', 'AmazonRDS', '["Overutilized AWS RDS instances could indicate that the databases running on these servers do not have enough hardware resources to perform optimally. Upgrading (upsizing) overutilized RDS instances to meet the load needs will improve directly the health and success of your databases (and their applications)."]'::jsonb, '["**AWS CLI command to upgrade RDS instance generation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MonitoringOverview.html"]'::jsonb),
  ('aws_rds_alternate_instances', 'RightSizing', 'RDS Alternate Instances', 'Alternate instances represent a good candidate for reducing your monthly AWS costs. Regularly checking your AWS RDS instances for the number of database connections performed will help you efficiently detect and remove any alternate RDS resources from your AWS account in order to avoid accumulating unnecessary charges.', 'AmazonRDS', '["Ensure that any Amazon RDS database instances that appear to be alternate are deleted to help lower the cost of your monthly AWS bill. By default, an RDS instance is considered ''alternate'' when meets the following criteria (to declare the instance ''alternate'' both conditions must be true):\n          - memory and cpu configuration should be same\n          - RDS engine version should be same\n        "]'::jsonb, '["**AWS CLI command to upgrade RDS instance generation:**\n\\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html"]'::jsonb),
  ('aws_rds_free_storage_space', 'RightSizing', 'RDS Storage Space is 10pct Free', 'Low disk space will often lead to instability and slowdowns. Detecting RDS database instances that run low on disk space is crucial when these instances are used in production by latency sensitive applications as this can help you take immediate actions and expand the storage space in order to maintain an optimal response time.', 'AmazonRDS', '["Identify any Amazon RDS database instances that appear to run low on disk space and scale them up to alleviate any problems triggered by insufficient disk space and improve their I/O performance. The default threshold value set for the amount of free storage space is 10% as any value below this could have a serious impact on your database stability and performance. For example, if the free storage space becomes dangerously low, basic operations like connecting to the database will not be possible anymore."]'::jsonb, '["**AWS CLI command to scale up RDS instance storage space:**\n\\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.html"]'::jsonb),
  ('aws_rds_idle_instance', 'RightSizing', 'Idle RDS Instance', 'Idle RDS instances represent a good candidate for reducing your monthly AWS costs. Regularly checking your AWS RDS instances for the number of database connections performed will help you efficiently detect and remove any idle RDS resources from your AWS account in order to avoid accumulating unnecessary charges.
  
  Note 1: Backing up your RDS databases before termination is highly recommended because once these instances are deleted, all their automated backups (snapshots) will be permanently lost.
  Note 2: Knowing the role and the owner of an AWS RDS instance before you take the decision to remove it from your account is very important. For this rule Cloud Conformity assumes that your RDS instances are tagged with ''Role'' and ''Owner'' tags which provide visibility into their usage profile and help you decide whether it''s safe or not to terminate these resources.
  Note 3: You can change the default threshold for this rule on the Cloud Conformity console and set your own values for the number of database connections, and the total number of ReadIOPS and WriteIOPS for each condition in order to configure the instances idleness.
  Note 4: If the RDS database instance selected for the checkup is needed within your application stack, you can suppress (disable) the conformity rule check for the instance from the Cloud Conformity console.', 'AmazonRDS', '["\nIdentify any Amazon RDS database instances that appear to be idle and delete them to help lower the cost of your monthly AWS bill. By default, an RDS instance is considered ''idle'' when meets the following criteria (to declare the instance ''idle'' both conditions must be true):\n\nThe average number of database connections has been less than 1 for the last 7 days.\nThe total number of database ReadIOPS and WriteIOPS recorded per day for the last 7 days has been less than 20 on average.\nThe AWS CloudWatch metrics used to detect idle RDS instances are:\n\nDatabaseConnections - the number of RDS database connections in use (Units: Count).\nReadIOPS and WriteIOPS - the average number of disk I/O (Input/Output) operations per second (Units: Count/Second).        \n        "]'::jsonb, '["Delete the identified idle Amazon RDS database instances to reduce your monthly AWS costs. Before you delete an RDS instance, ensure that you have backed up the database to avoid losing any important data. To delete an RDS instance, use the AWS Management Console, AWS CLI or AWS SDKs.\n\\", "\\", "\\", "\n "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MonitoringOverview.html"]'::jsonb),
  ('aws_ec2_idle_instance', 'RightSizing', 'Idle EC2 Instance', 'Idle instances represent a good candidate to reduce your Amazon EC2 service costs and avoid accumulating unnecessary Amazon EC2 charges.', 'AmazonRDS', '["\n        Identify any Amazon EC2 instances that appear to be idle and stop or terminate them to help lower the cost of your AWS bill. By default, an Amazon EC2 instance is considered \"idle\" when meets the following criteria (to declare the instance \"idle\" both conditions must be true):\n        - The average CPU Utilization has been less than 2% for the last 7 days.\n        - The average Network I/O has been less than 5 MB for the last 7 days.\n        "]'::jsonb, '["**AWS CLI command to stop or terminate idle EC2 instance:**\n        - Stop Instance\n\\", "\\", "\\", "\n\n        - Terminate Instance\n\\", "\\", "\\", "\n        \n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-system-instance-status-check.html"]'::jsonb),
  ('aws_ec2_alternate_instances', 'RightSizing', 'EC2 Alternate Instances', 'Alternate instances represent a good candidate for reducing your monthly AWS costs. Regularly checking your AWS EC2 instances for the number of database connections performed will help you efficiently detect and remove any alternate EC2 resources from your AWS account in order to avoid accumulating unnecessary charges.', 'AmazonEC2', '["Ensure that any Amazon EC2 instances that appear to be alternate are deleted to help lower the cost of your monthly AWS bill. By default, an EC2 instance is considered ''alternate'' when meets the following criteria (to declare the instance ''alternate'' both conditions must be true):\n          - memory and cpu configuration should be same\n        "]'::jsonb, '["**AWS CLI command to upgrade EC2 instance generation:**\n\n        - Stop instance\n\\", "\\", "\\", "\n\n        - Modify Instance Type\n\n\\", "\\", "\\", "\n\n        - Start Instance\n\n\\", "\\", "\\", "\n\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-resize.html"]'::jsonb),
  ('aws_ec2_underutilized', 'RightSizing', 'Underutilized EC2 Instance', 'Identify any Amazon EC2 instances that appear to be underutilized and downsize (resize) them to help lower the cost of your AWS bill. By default, an Amazon EC2 instance is considered "underutilized" when matches the following criteria (to declare the instance "underutilized" both conditions must be met):
    The average CPU utilization has been less than 60% for the last 7 days.
    The average memory utilization has been less than 60% for the last 7 days. By default, Amazon CloudWatch can''t record an EC2 instance memory utilization because the necessary metric cannot be implemented at the hypervisor level, therefore to be able to report the memory utilization using CloudWatch you need to install an agent on the instance that you want to monitor and create a custom metric (we''ll name it EC2MemoryUtilization) on the Amazon CloudWatch console. The instructions required for installing the monitoring agent, based on the Operating System (OS) used by the instance, are available at this URL.', 'AmazonEC2', '["Downsizing underutilized Amazon EC2 instances to meet the capacity needs at the lowest cost represents an efficient strategy to reduce your AWS cloud costs. For example, resizing a c4.xlarge-type instance provisioned in the US-East (N. Virginia) region to a c4.large-type instance due to CPU and memory underuse, you can roughly save $72 per month."]'::jsonb, '["**AWS CLI command to upgrade E2 instance generation:**\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html"]'::jsonb),
  ('aws_ec2_overutilized', 'RightSizing', 'Overutilized AWS EC2 Instances', 'Identify any Amazon EC2 instances that appear to be overutilized and upgrade (resize) them in order to help your EC2-hosted applications to handle better the workload and improve the response time. By default, an Amazon EC2 instance is considered "overutilized" when matches the following criteria:
        The average CPU utilization has been more than 90% for the last 7 days.
        The average memory utilization has been more than 90% for the last 7 days. By default, Amazon CloudWatch can''t record an EC2 instance memory utilization because the necessary metric cannot be implemented at the hypervisor level, therefore to be able to report the memory utilization using CloudWatch you need to install an agent (PERL script) on the instance that you want to monitor and create a custom metric (we''ll name it EC2MemoryUtilization) on the CloudWatch console. The instructions required for installing the monitoring agent, based on the Operating System used by instance, are available at this', 'AmazonEC2', '["Overutilized Amazon EC2 instances could indicate that the applications running on these machines do not have enough hardware resources to perform optimally. Upgrading (upsizing) overutilized Amazon EC2 instances to meet your load needs will improve directly the health and success of your applications, resulting in a more stable environment and a faster response time."]'::jsonb, '["**AWS CLI command to upgrade Ec2 instance generation:**\n\\", "\\", "\\", "\n        "]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html"]'::jsonb),
  ('aws_fargate_service_underutilized', 'RightSizing', 'Fargate Service Underutilized', 'This Fargate service has low average CPU and memory utilization over the past 7 days. The allocated vCPU and memory may be larger than needed, resulting in unnecessary costs.', 'AWSFargate', '["Reduce the vCPU and memory allocation in the Fargate task definition to match actual utilization."]'::jsonb, '["Update the task definition with lower resource values and update the service:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html"]'::jsonb),
  ('aws_fargate_service_overutilized', 'RightSizing', 'Fargate Service Overutilized', 'This Fargate service has high average CPU or memory utilization over the past 7 days. The allocated resources may be insufficient, risking throttling or OOM kills.', 'AWSFargate', '["Increase the vCPU and/or memory allocation in the Fargate task definition to handle the workload."]'::jsonb, '["Update the task definition with higher resource values and update the service:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html"]'::jsonb),
  ('aws_ecs_fargate_service_underutilized', 'RightSizing', 'ECS Fargate Service Underutilized', 'This ECS Fargate service has consistently low CPU and memory utilization. Consider reducing task resource allocations to save costs.', 'AmazonECS', '["Right-size ECS Fargate task definitions by reducing CPU and memory to match actual usage patterns."]'::jsonb, '["Update the task definition with reduced CPU and memory values, then update the service to use the new task definition revision."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html"]'::jsonb),
  ('aws_ecs_fargate_service_overutilized', 'RightSizing', 'ECS Fargate Service Overutilized', 'This ECS Fargate service has consistently high CPU or memory utilization. Insufficient resources may cause performance degradation or task failures.', 'AmazonECS', '["Increase the CPU and/or memory allocation in the ECS Fargate task definition."]'::jsonb, '["Register a new task definition revision with increased CPU and memory, then update the service."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cloudwatch-metrics.html"]'::jsonb),
  ('aws_elb_unused', 'RightSizing', 'Unused Elastic Load Balancer', 'An Elastic Load Balancer with no registered targets or very low request count is incurring costs without providing value. Unused load balancers should be identified and removed.', 'AmazonELB', '["Delete unused Elastic Load Balancers that have no registered targets or negligible traffic."]'::jsonb, '["Delete the unused load balancer:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-deregister-register-instances.html"]'::jsonb),
  ('aws_elasticache_idle_instance', 'RightSizing', 'Idle ElastiCache Instance', 'An ElastiCache cluster with very few or no connections over the past 7 days may be idle. Idle clusters incur costs without providing value.', 'AmazonElastiCache', '["Delete idle ElastiCache clusters that are no longer in use to reduce costs."]'::jsonb, '["Delete the idle cluster:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/monitoring-elasticache.html"]'::jsonb),
  ('aws_native_ce_ri_recommendation', 'RightSizing', 'AWS Reserved Instance Recommendation', 'AWS Cost Explorer has identified potential savings by purchasing Reserved Instances for resources with steady-state usage. Reserved Instances can provide up to 72% discount compared to On-Demand pricing.', 'AWSCostExplorer', '["Review and consider purchasing Reserved Instances for workloads with predictable, steady-state usage patterns."]'::jsonb, '["Evaluate the RI recommendation in AWS Cost Explorer and purchase appropriate Reserved Instances based on your usage patterns and commitment preferences (1-year or 3-year, All Upfront, Partial, or No Upfront)."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/cost-management/latest/userguide/ri-recommendations.html"]'::jsonb),
  ('aws_native_ce_savings_plan_recommendation', 'RightSizing', 'AWS Savings Plan Recommendation', 'AWS Cost Explorer has identified potential savings through Savings Plans. Savings Plans offer flexible pricing in exchange for a commitment to a consistent amount of usage (measured in $/hour) for a 1- or 3-year term.', 'AWSCostExplorer', '["Review and consider purchasing Savings Plans for workloads with consistent compute usage."]'::jsonb, '["Evaluate the Savings Plan recommendation in AWS Cost Explorer and purchase appropriate plans based on your compute usage patterns."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/cost-management/latest/userguide/sp-recommendations.html"]'::jsonb),
  ('aws_native_co_ec2_rightsize', 'RightSizing', 'AWS Compute Optimizer EC2 Right-Sizing', 'AWS Compute Optimizer has analyzed EC2 instance utilization and identified that this instance is over-provisioned or under-provisioned. Rightsizing to the recommended instance type can improve performance or reduce cost.', 'AmazonEC2', '["Follow the AWS Compute Optimizer recommendation to resize the EC2 instance to the suggested instance type."]'::jsonb, '["Stop the instance, change its type, and restart:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html"]'::jsonb),
  ('aws_native_co_lambda_rightsize', 'RightSizing', 'AWS Compute Optimizer Lambda Right-Sizing', 'AWS Compute Optimizer has analyzed Lambda function invocations and identified that the configured memory is not optimal. Adjusting memory allocation can improve performance and/or reduce cost.', 'AWSLambda', '["Adjust Lambda function memory configuration based on AWS Compute Optimizer recommendations."]'::jsonb, '["Update function memory:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html"]'::jsonb),
  ('aws_native_co_ebs_rightsize', 'RightSizing', 'AWS Compute Optimizer EBS Right-Sizing', 'AWS Compute Optimizer has analyzed EBS volume performance and identified optimization opportunities. The volume may be over-provisioned in terms of IOPS or throughput.', 'AmazonEC2', '["Follow Compute Optimizer recommendations to modify EBS volume type, size, or IOPS configuration."]'::jsonb, '["Modify the EBS volume:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html"]'::jsonb),
  ('aws_native_co_ecs_rightsize', 'RightSizing', 'AWS Compute Optimizer ECS Right-Sizing', 'AWS Compute Optimizer has analyzed ECS task resource utilization and identified that CPU or memory allocations are not optimal for the workload.', 'AmazonECS', '["Adjust ECS task definition CPU and memory based on Compute Optimizer recommendations."]'::jsonb, '["Register a new task definition revision with the recommended CPU and memory values, then update the ECS service."]'::jsonb, '[]'::jsonb, '["https://docs.aws.amazon.com/compute-optimizer/latest/ug/viewing-recommendations.html"]'::jsonb),
  ('gcp_gke_inactive_cluster', 'RightSizing', 'GKE Cluster is Inactive', 'This GKE cluster has very low or no workload activity. Idle clusters still incur costs for the control plane and node pools.', 'GKE', '["Delete inactive GKE clusters or scale down node pools to zero if the cluster may be needed later."]'::jsonb, '["Scale node pool to zero or delete cluster:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/kubernetes-engine/docs/how-to/deleting-a-cluster"]'::jsonb),
  ('gcp_function_not_active', 'RightSizing', 'Cloud Function Not Active', 'This Cloud Function has had zero or very few invocations over the monitoring period. While Cloud Functions have no idle cost, associated resources (VPC connectors, allocated memory) may still incur charges.', 'CloudFunctions', '["Review and delete Cloud Functions that are no longer needed."]'::jsonb, '["Delete the function:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/functions/docs/monitoring"]'::jsonb),
  ('gcp_function_high_memory', 'RightSizing', 'Cloud Function Over-Provisioned Memory', 'This Cloud Function is allocated more memory than it uses. Over-provisioned memory increases cost per invocation without benefit.', 'CloudFunctions', '["Reduce Cloud Function memory allocation to match actual usage."]'::jsonb, '["Update function memory:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/functions/docs/configuring/memory"]'::jsonb),
  ('gcp_bigquery_table_unused', 'RightSizing', 'BigQuery Table Unused', 'This BigQuery table has not been queried or modified for an extended period. Unused tables still incur storage costs.', 'BigQuery', '["Delete or archive unused BigQuery tables to reduce storage costs. Consider exporting to Cloud Storage if data retention is required."]'::jsonb, '["Delete the table or set expiration:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/bigquery/docs/managing-tables"]'::jsonb),
  ('gcp_run_high_memory', 'RightSizing', 'Cloud Run Service Over-Provisioned Memory', 'This Cloud Run service is allocated more memory than it uses. Reducing memory allocation can lower costs.', 'CloudRun', '["Reduce Cloud Run service memory limit to match actual usage patterns."]'::jsonb, '["Update service memory:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/run/docs/configuring/memory-limits"]'::jsonb),
  ('gcp_compute_stopped_instance', 'RightSizing', 'GCE Stopped Instance Incurring Costs', 'Stopped Compute Engine instances still incur charges for attached persistent disks, static external IP addresses, and other associated resources.', 'ComputeEngine', '["Delete stopped instances that are no longer needed, or snapshot and delete their disks to reduce costs."]'::jsonb, '["Delete the stopped instance:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/compute/docs/instances/stop-start-instance"]'::jsonb),
  ('gcp_sql_inactive_instance', 'RightSizing', 'Cloud SQL Instance Inactive', 'This Cloud SQL instance has very few or no connections over the monitoring period. Idle Cloud SQL instances still incur full instance costs.', 'CloudSQL', '["Stop or delete inactive Cloud SQL instances. Consider using Cloud SQL start/stop feature for development instances."]'::jsonb, '["Stop or delete the instance:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/sql/docs/mysql/start-stop-restart-instance"]'::jsonb),
  ('gcp_lb_unused_forwarding_rule', 'RightSizing', 'Unused Load Balancer Forwarding Rule', 'This load balancer forwarding rule has no backends or receives negligible traffic. Unused forwarding rules still incur hourly charges.', 'CloudLoadBalancing', '["Delete unused load balancer forwarding rules and associated backend services."]'::jsonb, '["Delete the forwarding rule:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts"]'::jsonb),
  ('gcp_storage_class_optimization', 'RightSizing', 'GCS Bucket Storage Class Optimization', 'This GCS bucket contains objects that could be stored in a cheaper storage class based on access patterns. Moving infrequently accessed data to Nearline, Coldline, or Archive can significantly reduce costs.', 'CloudStorage', '["Configure lifecycle rules to automatically transition objects to cheaper storage classes based on access frequency."]'::jsonb, '["Set lifecycle rule to transition objects:\n\\", "\\", "\\", "\nWhere lifecycle.json transitions objects older than 30 days to Nearline."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/storage/docs/storage-classes"]'::jsonb),
  ('gcp_native_compute_instance_idle_resource', 'RightSizing', 'GCP Recommender: Idle Compute Instance', 'Google Cloud Recommender has identified this Compute Engine instance as idle based on low CPU, network, and disk utilization. Idle instances waste resources and incur unnecessary costs.', 'ComputeEngine', '["Stop or delete the idle Compute Engine instance as recommended by GCP Recommender."]'::jsonb, '["Stop or delete the instance:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_compute_instance_machine_type', 'RightSizing', 'GCP Recommender: Right-Size Compute Instance', 'Google Cloud Recommender has analyzed this Compute Engine instance and recommends changing to a different machine type for better cost-efficiency or performance.', 'ComputeEngine', '["Resize the Compute Engine instance to the recommended machine type."]'::jsonb, '["Stop, resize, and restart:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_compute_disk_idle_resource', 'RightSizing', 'GCP Recommender: Idle Persistent Disk', 'Google Cloud Recommender has identified this persistent disk as idle (not attached to any instance or has no I/O activity). Idle disks incur storage costs without providing value.', 'ComputeEngine', '["Snapshot and delete idle persistent disks."]'::jsonb, '["Snapshot and delete the disk:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_compute_address_idle_resource', 'RightSizing', 'GCP Recommender: Idle Static IP Address', 'Google Cloud Recommender has identified this static external IP address as idle (not associated with any resource). Idle static IPs incur hourly charges.', 'ComputeEngine', '["Release idle static IP addresses that are not in use."]'::jsonb, '["Release the static IP:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();

INSERT INTO public.recommendation_rule_metadata
  (rule_name, category, title, description, service_name, recommendations, mitigations, compliances, "references")
VALUES
  ('gcp_native_compute_image_idle_resource', 'RightSizing', 'GCP Recommender: Idle Compute Image', 'Google Cloud Recommender has identified this custom image as idle (not used to create instances). Idle images incur storage costs.', 'ComputeEngine', '["Delete unused custom images to reduce storage costs."]'::jsonb, '["Delete the image:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_cloudsql_instance_idle', 'RightSizing', 'GCP Recommender: Idle Cloud SQL Instance', 'Google Cloud Recommender has identified this Cloud SQL instance as idle based on very low connection and query activity. Idle instances incur full costs.', 'CloudSQL', '["Stop or delete idle Cloud SQL instances as recommended by GCP Recommender."]'::jsonb, '["Stop the instance:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_cloudsql_instance_overprovisioned', 'RightSizing', 'GCP Recommender: Overprovisioned Cloud SQL Instance', 'Google Cloud Recommender has identified this Cloud SQL instance as overprovisioned. The allocated CPU and memory exceed the actual workload requirements, resulting in unnecessary costs.', 'CloudSQL', '["Resize the Cloud SQL instance to a smaller machine type as recommended by GCP Recommender."]'::jsonb, '["Resize the instance (requires restart):\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_container_diagnosis', 'RightSizing', 'GCP Recommender: GKE Container Diagnosis', 'Google Cloud Recommender has identified potential issues with GKE container resource configurations, such as over-provisioned or under-provisioned CPU/memory requests and limits.', 'GKE', '["Review and adjust container resource requests and limits based on GCP Recommender suggestions."]'::jsonb, '["Update Kubernetes deployment manifests to adjust resource requests and limits according to the recommendation. Apply changes with kubectl apply."]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('gcp_native_cloudsql_instance_underprovisioned', 'RightSizing', 'GCP Recommender: Underprovisioned Cloud SQL Instance', 'Google Cloud Recommender has identified this Cloud SQL instance as underprovisioned. The instance may experience performance issues due to insufficient CPU or memory.', 'CloudSQL', '["Upgrade the Cloud SQL instance to a larger machine type as recommended by GCP Recommender."]'::jsonb, '["Resize the instance (requires restart):\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://cloud.google.com/recommender/docs/recommenders"]'::jsonb),
  ('azure_unassociated_public_ip', 'RightSizing', 'Unassociated Azure Public IP Address', 'Azure Public IP addresses that are not associated with any resource still incur hourly charges. Unassociated IPs should be deleted if no longer needed.', 'AzureNetworking', '["Delete unassociated public IP addresses to reduce costs."]'::jsonb, '["Delete the public IP:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/public-ip-addresses"]'::jsonb),
  ('azure_unused_load_balancer', 'RightSizing', 'Unused Azure Load Balancer', 'This Azure Load Balancer has no backend pool members or receives negligible traffic. Unused load balancers still incur charges.', 'AzureLoadBalancer', '["Delete unused Azure Load Balancers that have no backend pool members."]'::jsonb, '["Delete the load balancer:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-overview"]'::jsonb),
  ('azure_nic_orphaned', 'RightSizing', 'Orphaned Azure Network Interface', 'This network interface is not attached to any virtual machine. Orphaned NICs may have associated public IPs or NSGs that incur costs.', 'AzureNetworking', '["Delete orphaned network interfaces and their associated resources."]'::jsonb, '["Delete the NIC:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-network-interface"]'::jsonb),
  ('azure_disk_unattached_volume', 'RightSizing', 'Unattached Azure Managed Disk', 'This managed disk is not attached to any virtual machine. Unattached disks incur storage costs without providing value.', 'AzureManagedDisks', '["Snapshot and delete unattached managed disks to reduce storage costs."]'::jsonb, '["Create snapshot and delete disk:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disks-find-unattached-portal"]'::jsonb),
  ('azure_storage_account_potentially_idle', 'RightSizing', 'Potentially Idle Azure Storage Account', 'This storage account has very low transaction activity over the monitoring period. It may be unused and incurring unnecessary costs.', 'AzureStorage', '["Evaluate whether this storage account is still needed. Delete or consolidate if unused."]'::jsonb, '["Review storage account usage in Azure Monitor metrics. If confirmed idle, migrate any remaining data and delete the account."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview"]'::jsonb),
  ('azure_appgateway_stopped', 'RightSizing', 'Stopped Azure Application Gateway', 'This Application Gateway is in a stopped state. While stopped gateways have reduced costs, they may still incur charges for the public IP and other associated resources.', 'AzureAppGateway', '["Delete stopped Application Gateways that are no longer needed."]'::jsonb, '["Delete the Application Gateway:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/application-gateway/overview"]'::jsonb),
  ('azure_app_service_stopped_app', 'RightSizing', 'Stopped Azure App Service', 'This App Service is in a stopped state but still occupies resources in its App Service Plan. If the plan is not shared with other apps, it continues to incur full charges.', 'AzureAppService', '["Delete stopped App Services that are no longer needed, or consolidate them into shared plans."]'::jsonb, '["Delete the app:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/app-service/overview"]'::jsonb),
  ('azure_redis_overprovisioned_sku', 'RightSizing', 'Azure Redis Cache Overprovisioned SKU', 'This Azure Cache for Redis instance is using a higher SKU tier or cache size than its workload requires. Downgrading can reduce costs.', 'AzureRedis', '["Evaluate Redis cache utilization and consider downgrading to a smaller SKU."]'::jsonb, '["Note: Downgrading Redis SKU requires creating a new instance with the desired SKU and migrating data. Azure does not support in-place SKU downgrades."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-overview"]'::jsonb),
  ('azure_sql_database_pricing_model_upgrade', 'RightSizing', 'Azure SQL Database Pricing Model Optimization', 'This Azure SQL Database may benefit from switching to a different pricing model (e.g., from DTU to vCore, or vice versa) based on its workload characteristics.', 'AzureSQL', '["Evaluate whether switching the Azure SQL pricing model would reduce costs for the current workload."]'::jsonb, '["Review Azure SQL Database pricing models and use the Azure pricing calculator to compare DTU vs vCore costs for your workload."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/service-tiers-general-purpose-business-critical"]'::jsonb),
  ('azure_sql_serverless_optimization', 'RightSizing', 'Azure SQL Serverless Optimization', 'This Azure SQL Database has intermittent usage patterns that could benefit from the serverless compute tier, which auto-pauses during inactivity and scales automatically.', 'AzureSQL', '["Consider switching to Azure SQL Serverless for databases with intermittent, unpredictable usage patterns."]'::jsonb, '["Convert to serverless:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/azure-sql/database/serverless-tier-overview"]'::jsonb),
  ('azure_storage_redundancy_optimization', 'RightSizing', 'Azure Storage Redundancy Optimization', 'This storage account may be using a higher redundancy level (e.g., GRS, RA-GRS) than required. Switching to a lower redundancy level (e.g., LRS) can reduce costs.', 'AzureStorage', '["Evaluate whether a lower storage redundancy level is acceptable for this workload."]'::jsonb, '["Change storage redundancy:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-redundancy"]'::jsonb),
  ('azure_storage_performance_tier_upgrade', 'RightSizing', 'Azure Storage Performance Tier Optimization', 'This storage account is using a performance tier that may not match its access patterns. Standard tier may be sufficient for infrequently accessed data.', 'AzureStorage', '["Evaluate whether the storage account performance tier matches the actual access patterns."]'::jsonb, '["Review storage account metrics and consider switching between Premium and Standard tiers based on IOPS and latency requirements."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview"]'::jsonb),
  ('azure_storage_access_tier_optimization', 'RightSizing', 'Azure Storage Access Tier Optimization', 'This storage account contains blobs in the Hot access tier that are infrequently accessed. Moving them to Cool or Archive tier can significantly reduce storage costs.', 'AzureStorage', '["Configure lifecycle management policies to automatically move infrequently accessed blobs to cooler tiers."]'::jsonb, '["Set lifecycle management policy:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/blobs/access-tiers-overview"]'::jsonb),
  ('azure_files_unused_file_share', 'RightSizing', 'Unused Azure File Share', 'This Azure File Share has very low transaction activity and may be unused. Idle file shares still incur storage costs.', 'AzureStorage', '["Delete unused Azure File Shares to reduce storage costs."]'::jsonb, '["Delete the file share:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/files/storage-files-introduction"]'::jsonb),
  ('azure_vmss_empty', 'RightSizing', 'Empty Azure VM Scale Set', 'This VM Scale Set has zero instances but the scale set resource itself still exists. While there are no VM costs, the associated resources (load balancer, public IP) may still incur charges.', 'AzureVMSS', '["Delete empty VM Scale Sets that are no longer needed."]'::jsonb, '["Delete the scale set:\n\\", "\\", "\\", "\n"]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/overview"]'::jsonb),
  ('azure_native_advisor_cost', 'RightSizing', 'Azure Advisor: Cost Recommendation', 'Azure Advisor has identified an opportunity to reduce costs. This may include right-sizing VMs, purchasing reservations, deleting unused resources, or other cost optimizations.', 'AzureAdvisor', '["Review and implement the Azure Advisor cost recommendation to reduce your Azure spending."]'::jsonb, '["Follow the specific remediation steps provided in the Azure Advisor recommendation details. Actions vary by recommendation type."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/advisor/advisor-cost-recommendations"]'::jsonb),
  ('azure_native_advisor_highavailability', 'RightSizing', 'Azure Advisor: High Availability Recommendation', 'Azure Advisor has identified a potential improvement for the availability of your Azure resources. This may include enabling zone redundancy, configuring backup, or other HA improvements.', 'AzureAdvisor', '["Review and implement the Azure Advisor high availability recommendation to improve resilience."]'::jsonb, '["Follow the specific remediation steps provided in the Azure Advisor recommendation details."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/advisor/advisor-high-availability-recommendations"]'::jsonb),
  ('azure_native_advisor_operationalexcellence', 'RightSizing', 'Azure Advisor: Operational Excellence Recommendation', 'Azure Advisor has identified an opportunity to improve operational practices. This may include enabling diagnostics, updating configurations, or other operational improvements.', 'AzureAdvisor', '["Review and implement the Azure Advisor operational excellence recommendation."]'::jsonb, '["Follow the specific remediation steps provided in the Azure Advisor recommendation details."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/advisor/advisor-operational-excellence-recommendations"]'::jsonb),
  ('azure_native_advisor_performance', 'RightSizing', 'Azure Advisor: Performance Recommendation', 'Azure Advisor has identified an opportunity to improve performance. This may include right-sizing resources, enabling caching, optimizing queries, or other performance improvements.', 'AzureAdvisor', '["Review and implement the Azure Advisor performance recommendation."]'::jsonb, '["Follow the specific remediation steps provided in the Azure Advisor recommendation details."]'::jsonb, '[]'::jsonb, '["https://learn.microsoft.com/en-us/azure/advisor/advisor-performance-recommendations"]'::jsonb),
  ('azure_app_service_plan_optimization', 'RightSizing', 'Azure App Service Plan Should Be Optimized', 'The App Service Plan may be over-provisioned for the current workload. Consider scaling down or using a more cost-effective tier.', 'AppService', '["The App Service Plan may be over-provisioned for the current workload. Consider scaling down or using a more cost-effective tier."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans"]'::jsonb),
  ('azure_files_large_quota', 'RightSizing', 'Azure Files Share Has Very Large Quota', 'The file share has an unusually large quota that may be over-provisioned.', 'AzureFiles', '["The file share has an unusually large quota that may be over-provisioned."]'::jsonb, '["Review and remediate this finding. Refer to the documentation link below for detailed steps."]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/storage/files/storage-files-planning"]'::jsonb),
  ('azure_vm_idle_instance', 'RightSizing', 'Azure VM Is Idle and Should Be Stopped or Deallocated', 'This Azure Virtual Machine has been identified as idle based on low CPU utilization and minimal network activity over a sustained period. Idle VMs continue to incur compute charges even when not performing useful work.', 'VirtualMachines', '["Review the VM''s workload and determine if it is still needed. If the VM is no longer required, deallocate or delete it. If the workload is intermittent, consider using Azure Auto-Shutdown or scaling down to a smaller VM size."]'::jsonb, '["Deallocate the idle VM to stop incurring compute charges:\n\\", "\\", "\\", "\n\nOr configure auto-shutdown to automatically deallocate during off-hours:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/states-billing"]'::jsonb),
  ('azure_vm_premium_ssd_os_disk_used', 'RightSizing', 'Azure VM Using Premium SSD OS Disk May Be Over-Provisioned', 'This VM is using a Premium SSD for the OS disk. For workloads that don''t require high IOPS or low latency for the OS disk, switching to Standard SSD can reduce costs while maintaining adequate performance.', 'VirtualMachines', '["Evaluate whether the OS disk requires Premium SSD performance. For most general-purpose workloads, Standard SSD provides sufficient performance at a lower cost."]'::jsonb, '["Convert the OS disk from Premium SSD to Standard SSD:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types"]'::jsonb),
  ('azure_vm_underutilized', 'RightSizing', 'Azure VM Is Underutilized and Should Be Right-Sized', 'This Azure Virtual Machine is consistently using a small fraction of its allocated CPU and memory resources. Right-sizing to a smaller VM SKU can significantly reduce costs while maintaining adequate performance for the workload.', 'VirtualMachines', '["Analyze the VM''s resource utilization metrics and resize to a smaller VM SKU that matches the actual workload requirements. Consider the Bs-series for burstable workloads or a smaller size within the same family."]'::jsonb, '["Resize the VM to a smaller SKU:\n\\", "\\", "\\", "\n\nNote: The VM will be restarted during the resize operation. Plan for a brief downtime window."]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://learn.microsoft.com/en-us/azure/virtual-machines/resize-vm"]'::jsonb),
  ('gcp_compute_idle_instance', 'RightSizing', 'GCP Compute Instance Is Idle and Should Be Stopped', 'This GCP Compute Engine instance has been identified as idle based on consistently low CPU utilization and minimal network activity. Idle instances continue to incur compute and licensing charges.', 'ComputeEngine', '["Review the instance''s workload and stop or delete it if no longer needed. Consider scheduling start/stop for intermittent workloads."]'::jsonb, '["Stop the idle instance:\n\\", "\\", "\\", "\n\nOr set up an instance schedule for automatic start/stop:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://cloud.google.com/compute/docs/instances/stop-start-instance"]'::jsonb),
  ('gcp_compute_underutilized', 'RightSizing', 'GCP Compute Instance Is Underutilized and Should Be Right-Sized', 'This GCP Compute Engine instance is consistently using a small fraction of its allocated CPU and memory resources. Right-sizing to a smaller machine type can reduce costs while maintaining adequate performance.', 'ComputeEngine', '["Analyze the instance''s resource utilization and resize to a smaller machine type that matches actual workload requirements."]'::jsonb, '["Resize the instance to a smaller machine type:\n\\", "\\", "\\", ""]'::jsonb, '["APRA", "MAS"]'::jsonb, '["https://cloud.google.com/compute/docs/instances/changing-machine-type-of-stopped-instance"]'::jsonb)
ON CONFLICT (rule_name) DO UPDATE SET
  category = EXCLUDED.category,
  title = EXCLUDED.title,
  description = EXCLUDED.description,
  service_name = EXCLUDED.service_name,
  recommendations = EXCLUDED.recommendations,
  mitigations = EXCLUDED.mitigations,
  compliances = EXCLUDED.compliances,
  "references" = EXCLUDED."references",
  updated_at = now();


ALTER TABLE public.recommendation_rule_metadata RENAME TO recommendation_rule;

ALTER INDEX idx_recommendation_rule_metadata_category RENAME TO idx_recommendation_rule_category;

ALTER TRIGGER set_recommendation_rule_metadata_updated_at ON public.recommendation_rule
    RENAME TO set_recommendation_rule_updated_at;
