cybersecurity · beginner · ~15 min · safe pentest lab
Encode the authorization precondition for any test.
Encode the precondition that gates every security test: you act only with written permission against an in-scope target.
Implement int authorized(int has_written_permission, int target_in_scope) that returns 1 only if both conditions hold.
has_written_permission: 1 if you hold written permission, else 0.target_in_scope: 1 if the target is within the agreed scope, else 0.Returns int: 1 if both flags are 1, else 0.
authorized(1, 1) -> 1
authorized(0, 1) -> 0 (no permission)
authorized(1, 0) -> 0 (out of scope)
Two int flags: has_written_permission and target_in_scope.
An int: 1 only if both flags are 1, else 0.
Both conditions are required.
int authorized(int has_written_permission, int target_in_scope) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.