cybersecurity · beginner · ~15 min · safe pentest lab

Are you authorized to test?

Encode the authorization precondition for any test.

Challenge

Encode the precondition that gates every security test: you act only with written permission against an in-scope target.

Task

Implement int authorized(int has_written_permission, int target_in_scope) that returns 1 only if both conditions hold.

Input

  • 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.

Output

Returns int: 1 if both flags are 1, else 0.

Example

authorized(1, 1)   ->   1
authorized(0, 1)   ->   0   (no permission)
authorized(1, 0)   ->   0   (out of scope)

Edge cases

  • Both conditions are required — either one missing yields 0.

Input format

Two int flags: has_written_permission and target_in_scope.

Output format

An int: 1 only if both flags are 1, else 0.

Constraints

Both conditions are required.

Starter code

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.