Skip to content

Commit 2b6809f

Browse files
committed
Fix 5 scripts + linter: 032 zip test, 066 cognito (4 bugs), 074 textract grep, 010 regex, validation.yaml
032-cloudwatch-streams: zip -t → unzip -t (zip -t means set-date on this system) 066-amazon-cognito-gs: MFA OFF, user pool ID regex, auth flow, temp password symbols, deletion protection 074-amazon-textract-gs: grep -o returns exit 1 on no match under set -e 010-cloudmap-service-discovery: allow uppercase hex in operation_id .doc_gen/validation.yaml: allow === separator string
1 parent 5b89af0 commit 2b6809f

5 files changed

Lines changed: 17 additions & 16 deletions

File tree

.doc_gen/validation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
allow_list:
22
- "bPxRfiCYEXAMPLEKEY/wJalrXUtnFEMI/K7MDENG"
33
- "role/AmazonEC2ContainerServiceforEC2Role"
4+
- "========================================"
45
sample_files:
56
- "README.md"

tuts/010-cloudmap-service-discovery/cloudmap-service-discovery.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ check_operation() {
8989
local retry_count=0
9090

9191
# Validate operation_id format (basic UUID validation)
92-
if [[ -z "$operation_id" ]] || ! [[ "$operation_id" =~ ^[a-f0-9-]+$ ]]; then
92+
if [[ -z "$operation_id" ]] || ! [[ "$operation_id" =~ ^[a-fA-F0-9-]+$ ]]; then
9393
log "Error: Invalid operation_id format"
9494
return 1
9595
fi
@@ -240,7 +240,7 @@ NAMESPACE_ID=$(aws servicediscovery list-namespaces \
240240
--query "Namespaces[?Name=='$NAMESPACE_NAME'].Id" \
241241
--output text)
242242

243-
if [[ -z "$NAMESPACE_ID" ]] || ! [[ "$NAMESPACE_ID" =~ ^[a-f0-9-]+$ ]]; then
243+
if [[ -z "$NAMESPACE_ID" ]] || ! [[ "$NAMESPACE_ID" =~ ^[a-fA-F0-9-]+$ ]]; then
244244
log "Error: Failed to retrieve namespace ID"
245245
exit 1
246246
fi

tuts/032-cloudwatch-streams/cloudwatch-streams.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ if ! python3 -m py_compile lambda_function.py 2>/dev/null; then
195195
fi
196196

197197
# Zip the Lambda function code
198-
log_cmd "zip -j -q lambda_function.zip lambda_function.py"
198+
zip -j -q lambda_function.zip lambda_function.py
199199
if [ ! -f lambda_function.zip ]; then
200200
echo "ERROR: Failed to create lambda_function.zip" | tee -a "$LOG_FILE"
201201
exit 1
202202
fi
203203
chmod 600 lambda_function.zip
204204

205205
# Validate zip file integrity
206-
if ! zip -t lambda_function.zip > /dev/null 2>&1; then
206+
if ! unzip -t lambda_function.zip > /dev/null 2>&1; then
207207
echo "ERROR: Created zip file is corrupted" | tee -a "$LOG_FILE"
208208
exit 1
209209
fi

tuts/066-amazon-cognito-gs/amazon-cognito-gs.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ USER_POOL_OUTPUT=$(aws cognito-idp create-user-pool \
134134
--username-attributes email \
135135
--policies '{"PasswordPolicy":{"MinimumLength":12,"RequireUppercase":true,"RequireLowercase":true,"RequireNumbers":true,"RequireSymbols":true}}' \
136136
--schema '[{"Name":"email","Required":true,"Mutable":true}]' \
137-
--mfa-configuration OPTIONAL \
137+
--mfa-configuration OFF \
138138
--user-attribute-update-settings '{"AttributesRequireVerificationBeforeUpdate":["email"]}' \
139139
--account-recovery-setting 'RecoveryMechanisms=[{Name=verified_email,Priority=1}]' \
140-
--deletion-protection ACTIVE \
140+
--deletion-protection INACTIVE \
141141
--region "$AWS_REGION" \
142142
2>&1)
143143
check_aws_error "create-user-pool"
@@ -150,7 +150,7 @@ if [ -z "$USER_POOL_ID" ]; then
150150
fi
151151

152152
# Validate User Pool ID format
153-
if ! [[ "$USER_POOL_ID" =~ ^[a-z]{2}-[a-z]+-[0-9]{1}_[a-zA-Z0-9]{25}$ ]]; then
153+
if ! [[ "$USER_POOL_ID" =~ ^[a-z]{2}-[a-z]+-[0-9]+_[a-zA-Z0-9]+$ ]]; then
154154
echo "ERROR: Invalid User Pool ID format: $USER_POOL_ID" >&2
155155
exit 1
156156
fi
@@ -167,7 +167,7 @@ APP_CLIENT_OUTPUT=$(aws cognito-idp create-user-pool-client \
167167
--user-pool-id "$USER_POOL_ID" \
168168
--client-name "$APP_CLIENT_NAME" \
169169
--no-generate-secret \
170-
--explicit-auth-flows ALLOW_REFRESH_TOKEN_AUTH \
170+
--explicit-auth-flows ALLOW_REFRESH_TOKEN_AUTH ALLOW_USER_PASSWORD_AUTH \
171171
--callback-urls '["https://localhost:3000/callback"]' \
172172
--allowed-o-auth-flows 'code' \
173173
--allowed-o-auth-scopes 'openid' 'email' 'profile' \
@@ -231,7 +231,7 @@ echo "App Client details retrieved successfully"
231231
# Step 6: Create a User (Admin)
232232
echo "Creating admin user..."
233233
ADMIN_USER_EMAIL="admin@example.com"
234-
TEMP_PASSWORD=$(openssl rand -base64 12 | tr -d '\n')
234+
TEMP_PASSWORD="$(openssl rand -base64 12 | tr -d '\n')!@#"
235235
if [ -z "$TEMP_PASSWORD" ]; then
236236
echo "ERROR: Failed to generate temporary password" >&2
237237
cleanup_on_error

tuts/074-amazon-textract-gs/amazon-textract-getting-started.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ BLOCKS_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType":' | wc -l)
198198
echo "Total blocks detected: $BLOCKS_COUNT"
199199

200200
# Count different block types using jq if available, fallback to grep
201-
PAGE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "PAGE"' | wc -l)
202-
LINE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "LINE"' | wc -l)
203-
WORD_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "WORD"' | wc -l)
204-
TABLE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "TABLE"' | wc -l)
205-
CELL_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "CELL"' | wc -l)
206-
KEY_VALUE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "KEY_VALUE_SET"' | wc -l)
207-
SIGNATURE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "SIGNATURE"' | wc -l)
201+
PAGE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "PAGE"' | wc -l || echo 0)
202+
LINE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "LINE"' | wc -l || echo 0)
203+
WORD_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "WORD"' | wc -l || echo 0)
204+
TABLE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "TABLE"' | wc -l || echo 0)
205+
CELL_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "CELL"' | wc -l || echo 0)
206+
KEY_VALUE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "KEY_VALUE_SET"' | wc -l || echo 0)
207+
SIGNATURE_COUNT=$(echo "$ANALYZE_OUTPUT" | grep -o '"BlockType": "SIGNATURE"' | wc -l || echo 0)
208208

209209
echo "Pages: $PAGE_COUNT"
210210
echo "Lines of text: $LINE_COUNT"

0 commit comments

Comments
 (0)