Skip to content

Commit 24c1bb1

Browse files
committed
Update run_cfn_guard script with better rule removal
1 parent 275713e commit 24c1bb1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

scripts/run_cfn_guard.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,28 @@ declare -a rulesets=("ncsc" "ncsc-cafv3" "wa-Reliability-Pillar" "wa-Security-Pi
1616
# Create a custom NCSC ruleset that excludes the problematic rule
1717
cp "/tmp/ruleset/output/ncsc.guard" "/tmp/ruleset/output/ncsc-custom.guard"
1818

19+
# Debug: Check if the rule exists before removal
20+
echo "Checking for LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED rule..."
21+
grep -n "LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED" "/tmp/ruleset/output/ncsc-custom.guard" || echo "Rule not found with exact name"
22+
1923
# Remove the problematic Lambda function public access rule
20-
# This rule is incompatible with standard AWS service integrations
24+
# Try multiple patterns to ensure we catch the rule
25+
sed -i '/LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED/,/^rule /d' "/tmp/ruleset/output/ncsc-custom.guard"
2126
sed -i '/LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED/,/^$/d' "/tmp/ruleset/output/ncsc-custom.guard"
2227

28+
# Also try removing any remaining references
29+
grep -v "LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED" "/tmp/ruleset/output/ncsc-custom.guard" > "/tmp/ncsc-temp.guard" || true
30+
mv "/tmp/ncsc-temp.guard" "/tmp/ruleset/output/ncsc-custom.guard" || true
31+
32+
echo "After removal, checking for remaining references..."
33+
grep -n "LAMBDA_FUNCTION_PUBLIC_ACCESS_PROHIBITED" "/tmp/ruleset/output/ncsc-custom.guard" || echo "✅ Rule successfully removed"
34+
2335
for ruleset in "${rulesets[@]}"
2436
do
2537
# Use custom NCSC ruleset that excludes the problematic rule
2638
if [ "$ruleset" = "ncsc" ]; then
2739
ruleset_file="/tmp/ruleset/output/ncsc-custom.guard"
40+
echo "Using custom NCSC ruleset: $ruleset_file"
2841
else
2942
ruleset_file="/tmp/ruleset/output/$ruleset.guard"
3043
fi

0 commit comments

Comments
 (0)