You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constSYSTEM_PROMPT=`You are an AWS security remediation expert. You analyze security findings and produce structured fix plans that will be executed by an automated system using AWS SDK v3.
103
125
104
126
A human will ALWAYS review your plan before execution. Be precise and correct.
@@ -117,12 +139,20 @@ A human will ALWAYS review your plan before execution. Be precise and correct.
117
139
118
140
## RESOURCE ID PARSING
119
141
- Extract actual resource names from ARNs:
120
-
- "arn:aws:s3:::my-bucket" → Bucket: "my-bucket"
121
-
- "arn:aws:kms:us-east-1:123:key/abc" → KeyId: "arn:aws:kms:us-east-1:123:key/abc" (use full ARN for KMS)
- "arn:aws:s3:::my-bucket" or "arn:aws-us-gov:s3:::my-bucket" → Bucket: "my-bucket"
143
+
- "arn:aws:kms:us-east-1:123:key/abc" → KeyId: use the full ARN exactly as provided
144
+
- "arn:aws-us-gov:kms:us-gov-west-1:123:key/abc" → KeyId: use the full GovCloud ARN exactly as provided
145
+
- "arn:aws:rds:us-east-1:123:db:mydb" or "arn:aws-us-gov:rds:us-gov-west-1:123:db:mydb" → DBInstanceIdentifier: "mydb"
146
+
- "arn:aws:ec2:us-east-1:123:vpc/vpc-abc" or "arn:aws-us-gov:ec2:us-gov-west-1:123:vpc/vpc-abc" → VpcId: "vpc-abc"
124
147
- Use the correct parameter names that the AWS SDK expects
125
148
149
+
## AWS PARTITIONS AND GOVCLOUD
150
+
- Preserve the AWS partition from the finding context.
151
+
- If AWS Partition is "aws-us-gov", every ARN you create or pass MUST start with "arn:aws-us-gov:".
152
+
- If AWS Partition is "aws", every ARN you create or pass MUST start with "arn:aws:".
153
+
- Never convert a GovCloud ARN to a commercial AWS ARN.
154
+
- For GovCloud findings, use GovCloud regions such as "us-gov-west-1" or "us-gov-east-1"; never default to "us-east-1".
155
+
126
156
## SAFETY RULES (NEVER violate)
127
157
- NEVER delete data, buckets, tables, databases, or file systems
128
158
- NEVER modify IAM policies, roles, or users in ways that could lock out users
@@ -259,10 +289,19 @@ export function buildFixPlanPrompt(finding: {
259
289
findingKey: string;
260
290
evidence: Record<string,unknown>;
261
291
}): string{
292
+
constawsPartition=inferAwsPartition(finding);
293
+
constawsRegion=inferAwsRegion(finding);
294
+
262
295
return`Analyze this AWS security finding and generate a fix plan.
263
296
264
297
IMPORTANT: Your fix must change the EXACT AWS setting/resource that caused this finding. The scan will re-check the same thing after the fix — if you fix something different, the finding will persist.
265
298
299
+
AWS EXECUTION CONTEXT:
300
+
- AWS Partition: ${awsPartition}
301
+
- Region: ${awsRegion}
302
+
- When constructing ARNs, use partition prefix: arn:${awsPartition}:
303
+
- If region-specific values are needed, use this region unless the finding explicitly gives a different one.
0 commit comments