Harbor format: 1000 cyber_authorization tasks
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/cedar_authorization-0062a76719bc2b2148d7/environment/Dockerfile +1 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/instruction.md +31 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/solution/reference.json +1 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/solution/solve.sh +3 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/task.toml +26 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/tests/expected.json +1 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/tests/grading.py +49 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/tests/test.sh +3 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/tests/verify.py +14 -0
- tasks/cedar_authorization-0062a76719bc2b2148d7/validation/openenv.json +1 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/environment/Dockerfile +1 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/instruction.md +31 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/solution/reference.json +1 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/solution/solve.sh +3 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/task.toml +26 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/expected.json +1 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/grading.py +49 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/test.sh +3 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/verify.py +14 -0
- tasks/cedar_authorization-00a804ddf1ad7b45e29f/validation/openenv.json +1 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/environment/Dockerfile +1 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/instruction.md +31 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/solution/reference.json +1 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/solution/solve.sh +3 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/task.toml +26 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/expected.json +1 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/grading.py +49 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/test.sh +3 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/verify.py +14 -0
- tasks/cedar_authorization-01a20e9cc8514ec4d2e5/validation/openenv.json +1 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/environment/Dockerfile +1 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/instruction.md +31 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/solution/reference.json +1 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/solution/solve.sh +3 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/task.toml +26 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/expected.json +1 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/grading.py +49 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/test.sh +3 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/verify.py +14 -0
- tasks/cedar_authorization-01c2f93d495f34df9bc8/validation/openenv.json +1 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/environment/Dockerfile +1 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/instruction.md +31 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/solution/reference.json +1 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/solution/solve.sh +3 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/task.toml +26 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/tests/expected.json +1 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/tests/grading.py +49 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/tests/test.sh +3 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/tests/verify.py +14 -0
- tasks/cedar_authorization-03d55858a8ef7108f16f/validation/openenv.json +1 -0
tasks/cedar_authorization-0062a76719bc2b2148d7/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/cedar_authorization-0062a76719bc2b2148d7/instruction.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Review these authorization requests using Cedar semantics. Evaluate each independently against the same policies and entity snapshot. A matching forbid overrides all permits. With no matching permit the decision is deny. A policy whose evaluation errors is skipped. For an allow list all matching permits as determining; for an explicit deny list all matching forbids; for default deny use an empty list. Include all policy IDs that errored separately. The entity "in" operation includes the entity itself and transitive parents. No authorization schema is applied.
|
| 2 |
+
Return one JSON object with key "results". Its value is an array in request order. Each entry has "request" (the displayed ID), "decision" ("allow" or "deny"), "determining" (array of IDs), and "errors" (array of IDs). Sort each ID array lexicographically.
|
| 3 |
+
|
| 4 |
+
policy0
|
| 5 |
+
permit(
|
| 6 |
+
principal is a in a::"",
|
| 7 |
+
action in [Action::""],
|
| 8 |
+
resource == a::""
|
| 9 |
+
) when {
|
| 10 |
+
true
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
policy1
|
| 14 |
+
forbid(
|
| 15 |
+
principal in r::r::r::r::a::"",
|
| 16 |
+
action == r::r::r::r::Action::"action",
|
| 17 |
+
resource in r::r::r::r::a::""
|
| 18 |
+
) when {
|
| 19 |
+
true && (if [r::r::r::r::a::"", principal, principal].containsAll([]) then action in action else action in action) && (action in action) && (action in action)
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
Entities
|
| 23 |
+
[{"attrs":{},"parents":[],"uid":{"id":"","type":"Action"}},{"attrs":{},"parents":[],"uid":{"id":"","type":"r::r::r::r::a"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"r::r::r::r::Action"}}]
|
| 24 |
+
|
| 25 |
+
Requests
|
| 26 |
+
{"action":{"id":"action","type":"r::r::r::r::Action"},"context":{},"principal":{"id":"","type":"r::r::r::r::a"},"request":"R1","resource":{"id":"","type":"r::r::r::r::a"}}
|
| 27 |
+
{"action":{"id":"","type":"Action"},"context":{},"principal":{"id":"","type":"a"},"request":"R2","resource":{"id":"","type":"a"}}
|
| 28 |
+
{"action":{"id":"","type":"Action"},"context":{},"principal":{"id":"","type":"a"},"request":"R3","resource":{"id":"","type":"r::r::r::r::a"}}
|
| 29 |
+
{"action":{"id":"action","type":"r::r::r::r::Action"},"context":{},"principal":{"id":"","type":"a"},"request":"R4","resource":{"id":"","type":"a"}}
|
| 30 |
+
|
| 31 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/cedar_authorization-0062a76719bc2b2148d7/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"deny","determining":["policy1"],"errors":[],"request":"R1"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R2"},{"decision":"deny","determining":[],"errors":[],"request":"R3"},{"decision":"deny","determining":[],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-0062a76719bc2b2148d7/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/cedar_authorization-0062a76719bc2b2148d7/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/cedar_authorization-0062a76719bc2b2148d7"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "cedar_authorization"
|
| 9 |
+
sealed_task_sha256 = "8187e97f7f2fa976740bb4590e8d46ac26bc70ceff56228d74512a442eede482"
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
docker_image = "public.ecr.aws/docker/library/python@sha256:05a994d2344eb364cc186910f4fc8786a38215f39f00d0acc25bff33a08f4177"
|
| 13 |
+
workdir = "/tmp"
|
| 14 |
+
cpus = 1
|
| 15 |
+
memory_mb = 512
|
| 16 |
+
storage_mb = 2048
|
| 17 |
+
network_mode = "no-network"
|
| 18 |
+
|
| 19 |
+
[agent]
|
| 20 |
+
timeout_sec = 120
|
| 21 |
+
network_mode = "no-network"
|
| 22 |
+
|
| 23 |
+
[verifier]
|
| 24 |
+
timeout_sec = 60
|
| 25 |
+
environment_mode = "separate"
|
| 26 |
+
network_mode = "no-network"
|
tasks/cedar_authorization-0062a76719bc2b2148d7/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"deny","determining":["policy1"],"errors":[],"request":"R1"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R2"},{"decision":"deny","determining":[],"errors":[],"request":"R3"},{"decision":"deny","determining":[],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-0062a76719bc2b2148d7/tests/grading.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared JSON grading contract for the environment and rollout controller."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def canonical(value) -> bytes:
|
| 9 |
+
return json.dumps(value, ensure_ascii=False, sort_keys=True,
|
| 10 |
+
separators=(",", ":"), allow_nan=False).encode("utf-8")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def payload_sha256(row: dict) -> str:
|
| 14 |
+
payload = {key: value for key, value in row.items() if key != "task_sha256"}
|
| 15 |
+
return hashlib.sha256(canonical(payload)).hexdigest()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _object(pairs):
|
| 19 |
+
result = {}
|
| 20 |
+
for key, value in pairs:
|
| 21 |
+
if key in result:
|
| 22 |
+
raise ValueError(f"Duplicate JSON member {key!r}")
|
| 23 |
+
result[key] = value
|
| 24 |
+
return result
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _bad_number(token):
|
| 28 |
+
raise ValueError(f"Non-finite number {token!r}")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def parse_answer(text: str) -> dict:
|
| 32 |
+
if not isinstance(text, str):
|
| 33 |
+
raise ValueError("An answer must be JSON text")
|
| 34 |
+
text = text.strip()
|
| 35 |
+
fence = re.fullmatch(r"```(?:json)?\s*\n(.*?)\n```", text, flags=re.DOTALL | re.IGNORECASE)
|
| 36 |
+
if fence:
|
| 37 |
+
text = fence.group(1)
|
| 38 |
+
value = json.loads(text, object_pairs_hook=_object, parse_constant=_bad_number)
|
| 39 |
+
if not isinstance(value, dict):
|
| 40 |
+
raise ValueError("An answer must be a JSON object")
|
| 41 |
+
canonical(value)
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def reward(expected: dict, submitted: object) -> int:
|
| 46 |
+
try:
|
| 47 |
+
return int(isinstance(submitted, dict) and canonical(expected) == canonical(submitted))
|
| 48 |
+
except (TypeError, ValueError, RecursionError):
|
| 49 |
+
return 0
|
tasks/cedar_authorization-0062a76719bc2b2148d7/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
exec /usr/local/bin/python -I -B -S /tests/verify.py
|
tasks/cedar_authorization-0062a76719bc2b2148d7/tests/verify.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from runpy import run_path
|
| 3 |
+
|
| 4 |
+
contract = run_path('/tests/grading.py')
|
| 5 |
+
expected = contract['parse_answer'](Path('/tests/expected.json').read_text())
|
| 6 |
+
answer = Path('/tmp/answer.json')
|
| 7 |
+
try:
|
| 8 |
+
submitted = None if answer.is_symlink() else contract['parse_answer'](answer.read_text())
|
| 9 |
+
except (OSError, ValueError, RecursionError):
|
| 10 |
+
submitted = None
|
| 11 |
+
value = contract['reward'](expected, submitted)
|
| 12 |
+
log = Path('/logs/verifier')
|
| 13 |
+
log.mkdir(parents=True, exist_ok=True)
|
| 14 |
+
(log / 'reward.txt').write_text(str(value) + '\n')
|
tasks/cedar_authorization-0062a76719bc2b2148d7/validation/openenv.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"profile":"harbor-semantic-v1","requires_credentials":false,"resources":{"cpu":1,"disk_mb":2048,"episode_timeout_s":180,"memory_mb":512},"reward":{"floor_margin":0.1,"oracle_tolerance":0,"range":[0,1]},"reward_key":"reward","types":{"tags":["authorization"]}}
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/instruction.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Review these authorization requests using Cedar semantics. Evaluate each independently against the same policies and entity snapshot. A matching forbid overrides all permits. With no matching permit the decision is deny. A policy whose evaluation errors is skipped. For an allow list all matching permits as determining; for an explicit deny list all matching forbids; for default deny use an empty list. Include all policy IDs that errored separately. The entity "in" operation includes the entity itself and transitive parents. No authorization schema is applied.
|
| 2 |
+
Return one JSON object with key "results". Its value is an array in request order. Each entry has "request" (the displayed ID), "decision" ("allow" or "deny"), "determining" (array of IDs), and "errors" (array of IDs). Sort each ID array lexicographically.
|
| 3 |
+
|
| 4 |
+
policy0
|
| 5 |
+
permit(
|
| 6 |
+
principal == A::I::a::"",
|
| 7 |
+
action == A::I::Action::"action",
|
| 8 |
+
resource == A::I::a::""
|
| 9 |
+
) when {
|
| 10 |
+
true
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
policy1
|
| 14 |
+
forbid(
|
| 15 |
+
principal in a::"",
|
| 16 |
+
action in [Action::"action"],
|
| 17 |
+
resource in a::""
|
| 18 |
+
) when {
|
| 19 |
+
true && (if if ip("198.198.198.198").isMulticast() then action in [a::"", a::"", a::""] else ip("198.198.198.198").isMulticast() then true else [true, true, true].contains(true)) && true
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
Entities
|
| 23 |
+
[{"attrs":{},"parents":[],"uid":{"id":"","type":"A::I::a"}},{"attrs":{},"parents":[],"uid":{"id":"","type":"a"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"A::I::Action"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"Action"}}]
|
| 24 |
+
|
| 25 |
+
Requests
|
| 26 |
+
{"action":{"id":"action","type":"Action"},"context":{},"principal":{"id":"","type":"A::I::a"},"request":"R1","resource":{"id":"","type":"a"}}
|
| 27 |
+
{"action":{"id":"action","type":"A::I::Action"},"context":{},"principal":{"id":"","type":"A::I::a"},"request":"R2","resource":{"id":"","type":"A::I::a"}}
|
| 28 |
+
{"action":{"id":"action","type":"Action"},"context":{},"principal":{"id":"","type":"a"},"request":"R3","resource":{"id":"","type":"a"}}
|
| 29 |
+
{"action":{"id":"action","type":"A::I::Action"},"context":{},"principal":{"id":"","type":"a"},"request":"R4","resource":{"id":"","type":"A::I::a"}}
|
| 30 |
+
|
| 31 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"deny","determining":[],"errors":[],"request":"R1"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R2"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R3"},{"decision":"deny","determining":[],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/cedar_authorization-00a804ddf1ad7b45e29f"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "cedar_authorization"
|
| 9 |
+
sealed_task_sha256 = "8af42c14f8fe913c49404a39da91f7d1a0f6ee2af078d8d9ea5f677302789fe2"
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
docker_image = "public.ecr.aws/docker/library/python@sha256:05a994d2344eb364cc186910f4fc8786a38215f39f00d0acc25bff33a08f4177"
|
| 13 |
+
workdir = "/tmp"
|
| 14 |
+
cpus = 1
|
| 15 |
+
memory_mb = 512
|
| 16 |
+
storage_mb = 2048
|
| 17 |
+
network_mode = "no-network"
|
| 18 |
+
|
| 19 |
+
[agent]
|
| 20 |
+
timeout_sec = 120
|
| 21 |
+
network_mode = "no-network"
|
| 22 |
+
|
| 23 |
+
[verifier]
|
| 24 |
+
timeout_sec = 60
|
| 25 |
+
environment_mode = "separate"
|
| 26 |
+
network_mode = "no-network"
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"deny","determining":[],"errors":[],"request":"R1"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R2"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R3"},{"decision":"deny","determining":[],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/grading.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared JSON grading contract for the environment and rollout controller."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def canonical(value) -> bytes:
|
| 9 |
+
return json.dumps(value, ensure_ascii=False, sort_keys=True,
|
| 10 |
+
separators=(",", ":"), allow_nan=False).encode("utf-8")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def payload_sha256(row: dict) -> str:
|
| 14 |
+
payload = {key: value for key, value in row.items() if key != "task_sha256"}
|
| 15 |
+
return hashlib.sha256(canonical(payload)).hexdigest()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _object(pairs):
|
| 19 |
+
result = {}
|
| 20 |
+
for key, value in pairs:
|
| 21 |
+
if key in result:
|
| 22 |
+
raise ValueError(f"Duplicate JSON member {key!r}")
|
| 23 |
+
result[key] = value
|
| 24 |
+
return result
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _bad_number(token):
|
| 28 |
+
raise ValueError(f"Non-finite number {token!r}")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def parse_answer(text: str) -> dict:
|
| 32 |
+
if not isinstance(text, str):
|
| 33 |
+
raise ValueError("An answer must be JSON text")
|
| 34 |
+
text = text.strip()
|
| 35 |
+
fence = re.fullmatch(r"```(?:json)?\s*\n(.*?)\n```", text, flags=re.DOTALL | re.IGNORECASE)
|
| 36 |
+
if fence:
|
| 37 |
+
text = fence.group(1)
|
| 38 |
+
value = json.loads(text, object_pairs_hook=_object, parse_constant=_bad_number)
|
| 39 |
+
if not isinstance(value, dict):
|
| 40 |
+
raise ValueError("An answer must be a JSON object")
|
| 41 |
+
canonical(value)
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def reward(expected: dict, submitted: object) -> int:
|
| 46 |
+
try:
|
| 47 |
+
return int(isinstance(submitted, dict) and canonical(expected) == canonical(submitted))
|
| 48 |
+
except (TypeError, ValueError, RecursionError):
|
| 49 |
+
return 0
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
exec /usr/local/bin/python -I -B -S /tests/verify.py
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/tests/verify.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from runpy import run_path
|
| 3 |
+
|
| 4 |
+
contract = run_path('/tests/grading.py')
|
| 5 |
+
expected = contract['parse_answer'](Path('/tests/expected.json').read_text())
|
| 6 |
+
answer = Path('/tmp/answer.json')
|
| 7 |
+
try:
|
| 8 |
+
submitted = None if answer.is_symlink() else contract['parse_answer'](answer.read_text())
|
| 9 |
+
except (OSError, ValueError, RecursionError):
|
| 10 |
+
submitted = None
|
| 11 |
+
value = contract['reward'](expected, submitted)
|
| 12 |
+
log = Path('/logs/verifier')
|
| 13 |
+
log.mkdir(parents=True, exist_ok=True)
|
| 14 |
+
(log / 'reward.txt').write_text(str(value) + '\n')
|
tasks/cedar_authorization-00a804ddf1ad7b45e29f/validation/openenv.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"profile":"harbor-semantic-v1","requires_credentials":false,"resources":{"cpu":1,"disk_mb":2048,"episode_timeout_s":180,"memory_mb":512},"reward":{"floor_margin":0.1,"oracle_tolerance":0,"range":[0,1]},"reward_key":"reward","types":{"tags":["authorization"]}}
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/instruction.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Review these authorization requests using Cedar semantics. Evaluate each independently against the same policies and entity snapshot. A matching forbid overrides all permits. With no matching permit the decision is deny. A policy whose evaluation errors is skipped. For an allow list all matching permits as determining; for an explicit deny list all matching forbids; for default deny use an empty list. Include all policy IDs that errored separately. The entity "in" operation includes the entity itself and transitive parents. No authorization schema is applied.
|
| 2 |
+
Return one JSON object with key "results". Its value is an array in request order. Each entry has "request" (the displayed ID), "decision" ("allow" or "deny"), "determining" (array of IDs), and "errors" (array of IDs). Sort each ID array lexicographically.
|
| 3 |
+
|
| 4 |
+
policy0
|
| 5 |
+
permit(
|
| 6 |
+
principal,
|
| 7 |
+
action,
|
| 8 |
+
resource
|
| 9 |
+
) when {
|
| 10 |
+
true && (resource in resource) && (resource in resource)
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
policy1
|
| 14 |
+
forbid(
|
| 15 |
+
principal == r::r::r::r::a::"=",
|
| 16 |
+
action == r::r::r::r::Action::"action",
|
| 17 |
+
resource == r::r::r::r::a::"="
|
| 18 |
+
) when {
|
| 19 |
+
true && ({"": action}[""] in {"": action}[""])
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
Entities
|
| 23 |
+
[{"attrs":{},"parents":[],"uid":{"id":"","type":"r::r::r::r::r::r"}},{"attrs":{},"parents":[],"uid":{"id":"=","type":"r::r::r::r::a"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"r::r::r::r::Action"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"r::r::r::r::r::Action"}}]
|
| 24 |
+
|
| 25 |
+
Requests
|
| 26 |
+
{"action":{"id":"action","type":"r::r::r::r::Action"},"context":{},"principal":{"id":"","type":"r::r::r::r::a"},"request":"R1","resource":{"id":"","type":"r::r::r::r::a"}}
|
| 27 |
+
{"action":{"id":"action","type":"r::r::r::r::Action"},"context":{},"principal":{"id":"","type":"r::r::r::r::r::r"},"request":"R2","resource":{"id":"=","type":"r::r::r::r::a"}}
|
| 28 |
+
{"action":{"id":"action","type":"r::r::r::r::r::Action"},"context":{},"principal":{"id":"","type":"r::r::r::r::r::r"},"request":"R3","resource":{"id":"=","type":"r::r::r::r::a"}}
|
| 29 |
+
{"action":{"id":"action","type":"r::r::r::r::Action"},"context":{},"principal":{"id":"=","type":"r::r::r::r::a"},"request":"R4","resource":{"id":"=","type":"r::r::r::r::a"}}
|
| 30 |
+
|
| 31 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"allow","determining":["policy0"],"errors":[],"request":"R1"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R2"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R3"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/cedar_authorization-01a20e9cc8514ec4d2e5"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "cedar_authorization"
|
| 9 |
+
sealed_task_sha256 = "ffe36263309154737791a7051840b09bb34cd13be2b05f089afd8b8d70afe59d"
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
docker_image = "public.ecr.aws/docker/library/python@sha256:05a994d2344eb364cc186910f4fc8786a38215f39f00d0acc25bff33a08f4177"
|
| 13 |
+
workdir = "/tmp"
|
| 14 |
+
cpus = 1
|
| 15 |
+
memory_mb = 512
|
| 16 |
+
storage_mb = 2048
|
| 17 |
+
network_mode = "no-network"
|
| 18 |
+
|
| 19 |
+
[agent]
|
| 20 |
+
timeout_sec = 120
|
| 21 |
+
network_mode = "no-network"
|
| 22 |
+
|
| 23 |
+
[verifier]
|
| 24 |
+
timeout_sec = 60
|
| 25 |
+
environment_mode = "separate"
|
| 26 |
+
network_mode = "no-network"
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"allow","determining":["policy0"],"errors":[],"request":"R1"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R2"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R3"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/grading.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared JSON grading contract for the environment and rollout controller."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def canonical(value) -> bytes:
|
| 9 |
+
return json.dumps(value, ensure_ascii=False, sort_keys=True,
|
| 10 |
+
separators=(",", ":"), allow_nan=False).encode("utf-8")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def payload_sha256(row: dict) -> str:
|
| 14 |
+
payload = {key: value for key, value in row.items() if key != "task_sha256"}
|
| 15 |
+
return hashlib.sha256(canonical(payload)).hexdigest()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _object(pairs):
|
| 19 |
+
result = {}
|
| 20 |
+
for key, value in pairs:
|
| 21 |
+
if key in result:
|
| 22 |
+
raise ValueError(f"Duplicate JSON member {key!r}")
|
| 23 |
+
result[key] = value
|
| 24 |
+
return result
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _bad_number(token):
|
| 28 |
+
raise ValueError(f"Non-finite number {token!r}")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def parse_answer(text: str) -> dict:
|
| 32 |
+
if not isinstance(text, str):
|
| 33 |
+
raise ValueError("An answer must be JSON text")
|
| 34 |
+
text = text.strip()
|
| 35 |
+
fence = re.fullmatch(r"```(?:json)?\s*\n(.*?)\n```", text, flags=re.DOTALL | re.IGNORECASE)
|
| 36 |
+
if fence:
|
| 37 |
+
text = fence.group(1)
|
| 38 |
+
value = json.loads(text, object_pairs_hook=_object, parse_constant=_bad_number)
|
| 39 |
+
if not isinstance(value, dict):
|
| 40 |
+
raise ValueError("An answer must be a JSON object")
|
| 41 |
+
canonical(value)
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def reward(expected: dict, submitted: object) -> int:
|
| 46 |
+
try:
|
| 47 |
+
return int(isinstance(submitted, dict) and canonical(expected) == canonical(submitted))
|
| 48 |
+
except (TypeError, ValueError, RecursionError):
|
| 49 |
+
return 0
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
exec /usr/local/bin/python -I -B -S /tests/verify.py
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/tests/verify.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from runpy import run_path
|
| 3 |
+
|
| 4 |
+
contract = run_path('/tests/grading.py')
|
| 5 |
+
expected = contract['parse_answer'](Path('/tests/expected.json').read_text())
|
| 6 |
+
answer = Path('/tmp/answer.json')
|
| 7 |
+
try:
|
| 8 |
+
submitted = None if answer.is_symlink() else contract['parse_answer'](answer.read_text())
|
| 9 |
+
except (OSError, ValueError, RecursionError):
|
| 10 |
+
submitted = None
|
| 11 |
+
value = contract['reward'](expected, submitted)
|
| 12 |
+
log = Path('/logs/verifier')
|
| 13 |
+
log.mkdir(parents=True, exist_ok=True)
|
| 14 |
+
(log / 'reward.txt').write_text(str(value) + '\n')
|
tasks/cedar_authorization-01a20e9cc8514ec4d2e5/validation/openenv.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"profile":"harbor-semantic-v1","requires_credentials":false,"resources":{"cpu":1,"disk_mb":2048,"episode_timeout_s":180,"memory_mb":512},"reward":{"floor_margin":0.1,"oracle_tolerance":0,"range":[0,1]},"reward_key":"reward","types":{"tags":["authorization"]}}
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/instruction.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Review these authorization requests using Cedar semantics. Evaluate each independently against the same policies and entity snapshot. A matching forbid overrides all permits. With no matching permit the decision is deny. A policy whose evaluation errors is skipped. For an allow list all matching permits as determining; for an explicit deny list all matching forbids; for default deny use an empty list. Include all policy IDs that errored separately. The entity "in" operation includes the entity itself and transitive parents. No authorization schema is applied.
|
| 2 |
+
Return one JSON object with key "results". Its value is an array in request order. Each entry has "request" (the displayed ID), "decision" ("allow" or "deny"), "determining" (array of IDs), and "errors" (array of IDs). Sort each ID array lexicographically.
|
| 3 |
+
|
| 4 |
+
policy0
|
| 5 |
+
permit(
|
| 6 |
+
principal in r::r::r3w333333::r::r::"",
|
| 7 |
+
action in [r::r::r3w333333::r::Action::"action"],
|
| 8 |
+
resource == r::r::r3w333333::r::r::""
|
| 9 |
+
) when {
|
| 10 |
+
true
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
policy1
|
| 14 |
+
forbid(
|
| 15 |
+
principal in LYY::"",
|
| 16 |
+
action in [Action::"E"],
|
| 17 |
+
resource
|
| 18 |
+
) when {
|
| 19 |
+
true && (if if (-4412750543122711235) == (-4412964684863978814) then false == false else decimal("-441275054312267.7054").lessThan(decimal("-325532544215600.324")) then {"": resource}[""] in {"": resource}[""] else {"": decimal("-441289735163997.3182")}[""].lessThan({"": decimal("214141746698.7714")}[""], if true then decimal("-441275054312267.7054") else decimal("0.1")))
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
Entities
|
| 23 |
+
[{"attrs":{},"parents":[],"uid":{"id":"","type":"LYY"}},{"attrs":{},"parents":[],"uid":{"id":"","type":"LYc"}},{"attrs":{},"parents":[{"id":"","type":"r::r::r3w333333::r::r"}],"uid":{"id":"","type":"r::r::r3w333333::r::fg"}},{"attrs":{},"parents":[],"uid":{"id":"","type":"r::r::r3w333333::r::r"}},{"attrs":{},"parents":[],"uid":{"id":"E","type":"Action"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"r::r::r3w333333::r::Action"}},{"attrs":{},"parents":[{"id":"","type":"r::r::r3w333333::r::fg"},{"id":"","type":"r::r::r3w333333::r::r"}],"uid":{"id":"||||||||","type":"r::r::r3w333333::r::r"}}]
|
| 24 |
+
|
| 25 |
+
Requests
|
| 26 |
+
{"action":{"id":"action","type":"r::r::r3w333333::r::Action"},"context":{},"principal":{"id":"","type":"r::r::r3w333333::r::r"},"request":"R1","resource":{"id":"","type":"r::r::r3w333333::r::r"}}
|
| 27 |
+
{"action":{"id":"E","type":"Action"},"context":{},"principal":{"id":"","type":"LYY"},"request":"R2","resource":{"id":"","type":"r::r::r3w333333::r::r"}}
|
| 28 |
+
{"action":{"id":"action","type":"r::r::r3w333333::r::Action"},"context":{},"principal":{"id":"","type":"r::r::r3w333333::r::r"},"request":"R3","resource":{"id":"","type":"LYY"}}
|
| 29 |
+
{"action":{"id":"E","type":"Action"},"context":{},"principal":{"id":"","type":"r::r::r3w333333::r::r"},"request":"R4","resource":{"id":"","type":"LYY"}}
|
| 30 |
+
|
| 31 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"allow","determining":["policy0"],"errors":[],"request":"R1"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R2"},{"decision":"deny","determining":[],"errors":[],"request":"R3"},{"decision":"deny","determining":[],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/cedar_authorization-01c2f93d495f34df9bc8"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "cedar_authorization"
|
| 9 |
+
sealed_task_sha256 = "bce32064a811de2a736ed5549e057710cc8c8f25caabc82cd2fb1afc868e4679"
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
docker_image = "public.ecr.aws/docker/library/python@sha256:05a994d2344eb364cc186910f4fc8786a38215f39f00d0acc25bff33a08f4177"
|
| 13 |
+
workdir = "/tmp"
|
| 14 |
+
cpus = 1
|
| 15 |
+
memory_mb = 512
|
| 16 |
+
storage_mb = 2048
|
| 17 |
+
network_mode = "no-network"
|
| 18 |
+
|
| 19 |
+
[agent]
|
| 20 |
+
timeout_sec = 120
|
| 21 |
+
network_mode = "no-network"
|
| 22 |
+
|
| 23 |
+
[verifier]
|
| 24 |
+
timeout_sec = 60
|
| 25 |
+
environment_mode = "separate"
|
| 26 |
+
network_mode = "no-network"
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"allow","determining":["policy0"],"errors":[],"request":"R1"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R2"},{"decision":"deny","determining":[],"errors":[],"request":"R3"},{"decision":"deny","determining":[],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/grading.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared JSON grading contract for the environment and rollout controller."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def canonical(value) -> bytes:
|
| 9 |
+
return json.dumps(value, ensure_ascii=False, sort_keys=True,
|
| 10 |
+
separators=(",", ":"), allow_nan=False).encode("utf-8")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def payload_sha256(row: dict) -> str:
|
| 14 |
+
payload = {key: value for key, value in row.items() if key != "task_sha256"}
|
| 15 |
+
return hashlib.sha256(canonical(payload)).hexdigest()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _object(pairs):
|
| 19 |
+
result = {}
|
| 20 |
+
for key, value in pairs:
|
| 21 |
+
if key in result:
|
| 22 |
+
raise ValueError(f"Duplicate JSON member {key!r}")
|
| 23 |
+
result[key] = value
|
| 24 |
+
return result
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _bad_number(token):
|
| 28 |
+
raise ValueError(f"Non-finite number {token!r}")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def parse_answer(text: str) -> dict:
|
| 32 |
+
if not isinstance(text, str):
|
| 33 |
+
raise ValueError("An answer must be JSON text")
|
| 34 |
+
text = text.strip()
|
| 35 |
+
fence = re.fullmatch(r"```(?:json)?\s*\n(.*?)\n```", text, flags=re.DOTALL | re.IGNORECASE)
|
| 36 |
+
if fence:
|
| 37 |
+
text = fence.group(1)
|
| 38 |
+
value = json.loads(text, object_pairs_hook=_object, parse_constant=_bad_number)
|
| 39 |
+
if not isinstance(value, dict):
|
| 40 |
+
raise ValueError("An answer must be a JSON object")
|
| 41 |
+
canonical(value)
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def reward(expected: dict, submitted: object) -> int:
|
| 46 |
+
try:
|
| 47 |
+
return int(isinstance(submitted, dict) and canonical(expected) == canonical(submitted))
|
| 48 |
+
except (TypeError, ValueError, RecursionError):
|
| 49 |
+
return 0
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
exec /usr/local/bin/python -I -B -S /tests/verify.py
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/tests/verify.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from runpy import run_path
|
| 3 |
+
|
| 4 |
+
contract = run_path('/tests/grading.py')
|
| 5 |
+
expected = contract['parse_answer'](Path('/tests/expected.json').read_text())
|
| 6 |
+
answer = Path('/tmp/answer.json')
|
| 7 |
+
try:
|
| 8 |
+
submitted = None if answer.is_symlink() else contract['parse_answer'](answer.read_text())
|
| 9 |
+
except (OSError, ValueError, RecursionError):
|
| 10 |
+
submitted = None
|
| 11 |
+
value = contract['reward'](expected, submitted)
|
| 12 |
+
log = Path('/logs/verifier')
|
| 13 |
+
log.mkdir(parents=True, exist_ok=True)
|
| 14 |
+
(log / 'reward.txt').write_text(str(value) + '\n')
|
tasks/cedar_authorization-01c2f93d495f34df9bc8/validation/openenv.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"profile":"harbor-semantic-v1","requires_credentials":false,"resources":{"cpu":1,"disk_mb":2048,"episode_timeout_s":180,"memory_mb":512},"reward":{"floor_margin":0.1,"oracle_tolerance":0,"range":[0,1]},"reward_key":"reward","types":{"tags":["authorization"]}}
|
tasks/cedar_authorization-03d55858a8ef7108f16f/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/cedar_authorization-03d55858a8ef7108f16f/instruction.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Review these authorization requests using Cedar semantics. Evaluate each independently against the same policies and entity snapshot. A matching forbid overrides all permits. With no matching permit the decision is deny. A policy whose evaluation errors is skipped. For an allow list all matching permits as determining; for an explicit deny list all matching forbids; for default deny use an empty list. Include all policy IDs that errored separately. The entity "in" operation includes the entity itself and transitive parents. No authorization schema is applied.
|
| 2 |
+
Return one JSON object with key "results". Its value is an array in request order. Each entry has "request" (the displayed ID), "decision" ("allow" or "deny"), "determining" (array of IDs), and "errors" (array of IDs). Sort each ID array lexicographically.
|
| 3 |
+
|
| 4 |
+
policy0
|
| 5 |
+
permit(
|
| 6 |
+
principal == PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::YEEEEEEEEEEEE::"",
|
| 7 |
+
action in [PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action::"action",PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action::"action",PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action::"action"],
|
| 8 |
+
resource
|
| 9 |
+
) when {
|
| 10 |
+
true
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
policy1
|
| 14 |
+
forbid(
|
| 15 |
+
principal is l,
|
| 16 |
+
action == Action::"action",
|
| 17 |
+
resource is l
|
| 18 |
+
) when {
|
| 19 |
+
true && ([ip("ffff:a20:6e69:61df:3bdf:dfdf:dfdf:dfdf"), ip("1c1c:1c1c:1c1c:1c1c:1c1c:7201:1c1c:1c1c"), ip("ff00:0:1ff:ffff:ffff:ffff:efff:ffff/126")].containsAny([ip("a0a0:0:20:6e61:6b62:6544:10:8df"), ip("ffff:ffff:ffff:fffb:ffff:ffff:ffff:ffff/126"), ip("ffff:400:0:20:6e61:6962:6544:5aff")]) || (principal in principal) || (resource in resource)) && (resource in resource) && (resource in resource)
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
Entities
|
| 23 |
+
[{"attrs":{},"parents":[],"uid":{"id":"","type":"l"}},{"attrs":{},"parents":[],"uid":{"id":"","type":"r"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"Action"}},{"attrs":{},"parents":[],"uid":{"id":"action","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action"}}]
|
| 24 |
+
|
| 25 |
+
Requests
|
| 26 |
+
{"action":{"id":"action","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action"},"context":{},"principal":{"id":"","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::lHHHHHHH"},"request":"R1","resource":{"id":"","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::YEEEch0005"}}
|
| 27 |
+
{"action":{"id":"action","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action"},"context":{},"principal":{"id":"","type":"l"},"request":"R2","resource":{"id":"","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::dEEEEEEEEE"}}
|
| 28 |
+
{"action":{"id":"action","type":"Action"},"context":{},"principal":{"id":"","type":"l"},"request":"R3","resource":{"id":"","type":"l"}}
|
| 29 |
+
{"action":{"id":"action","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::Action"},"context":{},"principal":{"id":"","type":"PcZgcecccccccc0::meccc::mcc60::k6afm::mh0005c31VOnnnh::lEEEEEEE::YEEEEEEEEE::r::YEEEEEEEEEEEE"},"request":"R4","resource":{"id":"","type":"l"}}
|
| 30 |
+
|
| 31 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/cedar_authorization-03d55858a8ef7108f16f/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"deny","determining":[],"errors":[],"request":"R1"},{"decision":"deny","determining":[],"errors":[],"request":"R2"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R3"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-03d55858a8ef7108f16f/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/cedar_authorization-03d55858a8ef7108f16f/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/cedar_authorization-03d55858a8ef7108f16f"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "cedar_authorization"
|
| 9 |
+
sealed_task_sha256 = "c71c9b942e055c538ee99f4d0ad911e56f3566c27d40476b85b8ce5cf7fb0cf1"
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
docker_image = "public.ecr.aws/docker/library/python@sha256:05a994d2344eb364cc186910f4fc8786a38215f39f00d0acc25bff33a08f4177"
|
| 13 |
+
workdir = "/tmp"
|
| 14 |
+
cpus = 1
|
| 15 |
+
memory_mb = 512
|
| 16 |
+
storage_mb = 2048
|
| 17 |
+
network_mode = "no-network"
|
| 18 |
+
|
| 19 |
+
[agent]
|
| 20 |
+
timeout_sec = 120
|
| 21 |
+
network_mode = "no-network"
|
| 22 |
+
|
| 23 |
+
[verifier]
|
| 24 |
+
timeout_sec = 60
|
| 25 |
+
environment_mode = "separate"
|
| 26 |
+
network_mode = "no-network"
|
tasks/cedar_authorization-03d55858a8ef7108f16f/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"results":[{"decision":"deny","determining":[],"errors":[],"request":"R1"},{"decision":"deny","determining":[],"errors":[],"request":"R2"},{"decision":"deny","determining":["policy1"],"errors":[],"request":"R3"},{"decision":"allow","determining":["policy0"],"errors":[],"request":"R4"}]}
|
tasks/cedar_authorization-03d55858a8ef7108f16f/tests/grading.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared JSON grading contract for the environment and rollout controller."""
|
| 2 |
+
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import re
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def canonical(value) -> bytes:
|
| 9 |
+
return json.dumps(value, ensure_ascii=False, sort_keys=True,
|
| 10 |
+
separators=(",", ":"), allow_nan=False).encode("utf-8")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def payload_sha256(row: dict) -> str:
|
| 14 |
+
payload = {key: value for key, value in row.items() if key != "task_sha256"}
|
| 15 |
+
return hashlib.sha256(canonical(payload)).hexdigest()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _object(pairs):
|
| 19 |
+
result = {}
|
| 20 |
+
for key, value in pairs:
|
| 21 |
+
if key in result:
|
| 22 |
+
raise ValueError(f"Duplicate JSON member {key!r}")
|
| 23 |
+
result[key] = value
|
| 24 |
+
return result
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _bad_number(token):
|
| 28 |
+
raise ValueError(f"Non-finite number {token!r}")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def parse_answer(text: str) -> dict:
|
| 32 |
+
if not isinstance(text, str):
|
| 33 |
+
raise ValueError("An answer must be JSON text")
|
| 34 |
+
text = text.strip()
|
| 35 |
+
fence = re.fullmatch(r"```(?:json)?\s*\n(.*?)\n```", text, flags=re.DOTALL | re.IGNORECASE)
|
| 36 |
+
if fence:
|
| 37 |
+
text = fence.group(1)
|
| 38 |
+
value = json.loads(text, object_pairs_hook=_object, parse_constant=_bad_number)
|
| 39 |
+
if not isinstance(value, dict):
|
| 40 |
+
raise ValueError("An answer must be a JSON object")
|
| 41 |
+
canonical(value)
|
| 42 |
+
return value
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def reward(expected: dict, submitted: object) -> int:
|
| 46 |
+
try:
|
| 47 |
+
return int(isinstance(submitted, dict) and canonical(expected) == canonical(submitted))
|
| 48 |
+
except (TypeError, ValueError, RecursionError):
|
| 49 |
+
return 0
|
tasks/cedar_authorization-03d55858a8ef7108f16f/tests/test.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
exec /usr/local/bin/python -I -B -S /tests/verify.py
|
tasks/cedar_authorization-03d55858a8ef7108f16f/tests/verify.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
from runpy import run_path
|
| 3 |
+
|
| 4 |
+
contract = run_path('/tests/grading.py')
|
| 5 |
+
expected = contract['parse_answer'](Path('/tests/expected.json').read_text())
|
| 6 |
+
answer = Path('/tmp/answer.json')
|
| 7 |
+
try:
|
| 8 |
+
submitted = None if answer.is_symlink() else contract['parse_answer'](answer.read_text())
|
| 9 |
+
except (OSError, ValueError, RecursionError):
|
| 10 |
+
submitted = None
|
| 11 |
+
value = contract['reward'](expected, submitted)
|
| 12 |
+
log = Path('/logs/verifier')
|
| 13 |
+
log.mkdir(parents=True, exist_ok=True)
|
| 14 |
+
(log / 'reward.txt').write_text(str(value) + '\n')
|
tasks/cedar_authorization-03d55858a8ef7108f16f/validation/openenv.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"profile":"harbor-semantic-v1","requires_credentials":false,"resources":{"cpu":1,"disk_mb":2048,"episode_timeout_s":180,"memory_mb":512},"reward":{"floor_margin":0.1,"oracle_tolerance":0,"range":[0,1]},"reward_key":"reward","types":{"tags":["authorization"]}}
|