← All Exercises
Evaluate an IAM Statement Against a Request
intermediatejavascript
Background
Cloud permissions are expressed as statements that match actions and resources with wildcards. A policy evaluator that ignores wildcard semantics silently over-grants access.
Problem
Evaluate one allow/deny statement, including wildcard actions and resource ARNs, and decide whether the request is permitted.
Input
JSON object: { policy: { effect, actions, resources }, request: { action, resource } }Output
JSON string: "Allow" or "Deny"
Sample tests
Sample 1
Input: {"policy":{"effect":"Allow","actions":["s3:GetObject"],"resources":["arn:aws:s3:::reports/*"]},"request":{"action":"s3:GetObject","resource":"arn:aws:s3:::reports/q1.csv"}}Expected: "Allow"
Sample 2
Input: {"policy":{"effect":"Allow","actions":["s3:GetObject"],"resources":["arn:aws:s3:::reports/*"]},"request":{"action":"s3:PutObject","resource":"arn:aws:s3:::reports/q1.csv"}}Expected: "Deny"
Your solution
Learning objective
Read an IAM statement as a matcher and prove the resulting decision with concrete requests.