Harbor format: 1000 cyber_authorization tasks (part 13)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/openfga-check-7cc9ccf012c36e250971/environment/Dockerfile +1 -0
- tasks/openfga-check-7cc9ccf012c36e250971/instruction.md +19 -0
- tasks/openfga-check-7cc9ccf012c36e250971/solution/reference.json +1 -0
- tasks/openfga-check-7cc9ccf012c36e250971/solution/solve.sh +3 -0
- tasks/openfga-check-7cc9ccf012c36e250971/task.toml +26 -0
- tasks/openfga-check-7cc9ccf012c36e250971/tests/expected.json +1 -0
- tasks/openfga-check-7cc9ccf012c36e250971/tests/grading.py +49 -0
- tasks/openfga-check-7cc9ccf012c36e250971/tests/test.sh +3 -0
- tasks/openfga-check-7cc9ccf012c36e250971/tests/verify.py +14 -0
- tasks/openfga-check-7cc9ccf012c36e250971/validation/openenv.json +1 -0
- tasks/openfga-check-7dc961b6521163211acb/environment/Dockerfile +1 -0
- tasks/openfga-check-7dc961b6521163211acb/instruction.md +21 -0
- tasks/openfga-check-7dc961b6521163211acb/solution/reference.json +1 -0
- tasks/openfga-check-7dc961b6521163211acb/solution/solve.sh +3 -0
- tasks/openfga-check-7dc961b6521163211acb/task.toml +26 -0
- tasks/openfga-check-7dc961b6521163211acb/tests/expected.json +1 -0
- tasks/openfga-check-7dc961b6521163211acb/tests/grading.py +49 -0
- tasks/openfga-check-7dc961b6521163211acb/tests/test.sh +3 -0
- tasks/openfga-check-7dc961b6521163211acb/tests/verify.py +14 -0
- tasks/openfga-check-7dc961b6521163211acb/validation/openenv.json +1 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/environment/Dockerfile +1 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/instruction.md +22 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/solution/reference.json +1 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/solution/solve.sh +3 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/task.toml +26 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/tests/expected.json +1 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/tests/grading.py +49 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/tests/test.sh +3 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/tests/verify.py +14 -0
- tasks/openfga-check-7e67850ca7dd29201c6a/validation/openenv.json +1 -0
- tasks/openfga-check-814e52198b341ef98a21/environment/Dockerfile +1 -0
- tasks/openfga-check-814e52198b341ef98a21/instruction.md +20 -0
- tasks/openfga-check-814e52198b341ef98a21/solution/reference.json +1 -0
- tasks/openfga-check-814e52198b341ef98a21/solution/solve.sh +3 -0
- tasks/openfga-check-814e52198b341ef98a21/task.toml +26 -0
- tasks/openfga-check-814e52198b341ef98a21/tests/expected.json +1 -0
- tasks/openfga-check-814e52198b341ef98a21/tests/grading.py +49 -0
- tasks/openfga-check-814e52198b341ef98a21/tests/test.sh +3 -0
- tasks/openfga-check-814e52198b341ef98a21/tests/verify.py +14 -0
- tasks/openfga-check-814e52198b341ef98a21/validation/openenv.json +1 -0
- tasks/openfga-check-81d260e39cb841b183b7/environment/Dockerfile +1 -0
- tasks/openfga-check-81d260e39cb841b183b7/instruction.md +25 -0
- tasks/openfga-check-81d260e39cb841b183b7/solution/reference.json +1 -0
- tasks/openfga-check-81d260e39cb841b183b7/solution/solve.sh +3 -0
- tasks/openfga-check-81d260e39cb841b183b7/task.toml +26 -0
- tasks/openfga-check-81d260e39cb841b183b7/tests/expected.json +1 -0
- tasks/openfga-check-81d260e39cb841b183b7/tests/grading.py +49 -0
- tasks/openfga-check-81d260e39cb841b183b7/tests/test.sh +3 -0
- tasks/openfga-check-81d260e39cb841b183b7/tests/verify.py +14 -0
- tasks/openfga-check-81d260e39cb841b183b7/validation/openenv.json +1 -0
tasks/openfga-check-7cc9ccf012c36e250971/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-check-7cc9ccf012c36e250971/instruction.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Perform a static OpenFGA 1.1 authorization review. Only the listed relationships exist. The current model controls which tuples can be used; stored tuples of a disallowed type have no effect. A tuple is written [object, relation, subject]. A subject ending in #relation includes the members of that related object. A typed wildcard includes any concrete subject of its type. 'A from B' follows B to related objects and checks A on those objects. 'but not' is set difference. Evaluate access under the model below.
|
| 2 |
+
Return exactly one JSON object {"decisions":[...]} listing a JSON boolean for each check in the given order.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type folder
|
| 8 |
+
relations
|
| 9 |
+
define parent: [folder]
|
| 10 |
+
define viewer: [user] or viewer from parent
|
| 11 |
+
define can_view: viewer
|
| 12 |
+
|
| 13 |
+
Stored relationships:
|
| 14 |
+
[["folder:1","viewer","user:1"],["folder:2","parent","folder:1"]]
|
| 15 |
+
|
| 16 |
+
Access checks in order:
|
| 17 |
+
[["folder:1","can_view","user:1"],["folder:2","can_view","user:1"]]
|
| 18 |
+
|
| 19 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-check-7cc9ccf012c36e250971/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true,true]}
|
tasks/openfga-check-7cc9ccf012c36e250971/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-check-7cc9ccf012c36e250971/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/openfga-check-7cc9ccf012c36e250971"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-check"
|
| 9 |
+
sealed_task_sha256 = "c72f08650fe831f7682cb3e758ce74339c59d1e5b2fc7708ef810b484143b5a4"
|
| 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/openfga-check-7cc9ccf012c36e250971/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true,true]}
|
tasks/openfga-check-7cc9ccf012c36e250971/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/openfga-check-7cc9ccf012c36e250971/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/openfga-check-7cc9ccf012c36e250971/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/openfga-check-7cc9ccf012c36e250971/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/openfga-check-7dc961b6521163211acb/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-check-7dc961b6521163211acb/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Perform a static OpenFGA 1.1 authorization review. Only the listed relationships exist. The current model controls which tuples can be used; stored tuples of a disallowed type have no effect. A tuple is written [object, relation, subject]. A subject ending in #relation includes the members of that related object. A typed wildcard includes any concrete subject of its type. 'A from B' follows B to related objects and checks A on those objects. 'but not' is set difference. Evaluate access under the model below.
|
| 2 |
+
Return exactly one JSON object {"decisions":[...]} listing a JSON boolean for each check in the given order.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
|
| 8 |
+
type document
|
| 9 |
+
relations
|
| 10 |
+
define everyone: [user:*]
|
| 11 |
+
define member: [user]
|
| 12 |
+
define banned: [user]
|
| 13 |
+
define viewer: everyone but not ((everyone but not member) or banned)
|
| 14 |
+
|
| 15 |
+
Stored relationships:
|
| 16 |
+
[["document:1","banned","user:2"],["document:1","everyone","user:*"],["document:1","member","user:1"],["document:1","member","user:2"]]
|
| 17 |
+
|
| 18 |
+
Access checks in order:
|
| 19 |
+
[["document:1","viewer","user:1"],["document:1","viewer","user:2"],["document:1","viewer","user:3"]]
|
| 20 |
+
|
| 21 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-check-7dc961b6521163211acb/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true,false,false]}
|
tasks/openfga-check-7dc961b6521163211acb/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-check-7dc961b6521163211acb/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/openfga-check-7dc961b6521163211acb"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-check"
|
| 9 |
+
sealed_task_sha256 = "e4dc149959de4d17eb5569af9219b3506f0187eb15c0f20d6cde95b5217c37d7"
|
| 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/openfga-check-7dc961b6521163211acb/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true,false,false]}
|
tasks/openfga-check-7dc961b6521163211acb/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/openfga-check-7dc961b6521163211acb/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/openfga-check-7dc961b6521163211acb/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/openfga-check-7dc961b6521163211acb/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/openfga-check-7e67850ca7dd29201c6a/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-check-7e67850ca7dd29201c6a/instruction.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Perform a static OpenFGA 1.1 authorization review. Only the listed relationships exist. The current model controls which tuples can be used; stored tuples of a disallowed type have no effect. A tuple is written [object, relation, subject]. A subject ending in #relation includes the members of that related object. A typed wildcard includes any concrete subject of its type. 'A from B' follows B to related objects and checks A on those objects. 'but not' is set difference. Evaluate access under the model below.
|
| 2 |
+
Return exactly one JSON object {"decisions":[...]} listing a JSON boolean for each check in the given order.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type folder1
|
| 8 |
+
type folder2
|
| 9 |
+
relations
|
| 10 |
+
define viewer: [user]
|
| 11 |
+
type document
|
| 12 |
+
relations
|
| 13 |
+
define viewer: viewer from parent
|
| 14 |
+
define parent: [folder1,folder2]
|
| 15 |
+
|
| 16 |
+
Stored relationships:
|
| 17 |
+
[["document:1","parent","folder2:1"],["folder2:1","viewer","user:1"]]
|
| 18 |
+
|
| 19 |
+
Access checks in order:
|
| 20 |
+
[["document:1","viewer","user:1"]]
|
| 21 |
+
|
| 22 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-check-7e67850ca7dd29201c6a/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true]}
|
tasks/openfga-check-7e67850ca7dd29201c6a/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-check-7e67850ca7dd29201c6a/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/openfga-check-7e67850ca7dd29201c6a"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-check"
|
| 9 |
+
sealed_task_sha256 = "3701814e89da17d745d564426de2b8c2865704d8deeb8978e21470e5ce4afb61"
|
| 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/openfga-check-7e67850ca7dd29201c6a/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true]}
|
tasks/openfga-check-7e67850ca7dd29201c6a/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/openfga-check-7e67850ca7dd29201c6a/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/openfga-check-7e67850ca7dd29201c6a/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/openfga-check-7e67850ca7dd29201c6a/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/openfga-check-814e52198b341ef98a21/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-check-814e52198b341ef98a21/instruction.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Perform a static OpenFGA 1.1 authorization review. Only the listed relationships exist. The current model controls which tuples can be used; stored tuples of a disallowed type have no effect. A tuple is written [object, relation, subject]. A subject ending in #relation includes the members of that related object. A typed wildcard includes any concrete subject of its type. 'A from B' follows B to related objects and checks A on those objects. 'but not' is set difference. Evaluate access under the model below.
|
| 2 |
+
Return exactly one JSON object {"decisions":[...]} listing a JSON boolean for each check in the given order.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type document
|
| 8 |
+
relations
|
| 9 |
+
define rel1: (rel2 and rel3) or rel1 from parent
|
| 10 |
+
define parent: [document]
|
| 11 |
+
define rel2: [user]
|
| 12 |
+
define rel3: [user]
|
| 13 |
+
|
| 14 |
+
Stored relationships:
|
| 15 |
+
[["document:1","rel2","user:1"],["document:2","parent","document:1"],["document:2","rel2","user:1"],["document:2","rel3","user:1"]]
|
| 16 |
+
|
| 17 |
+
Access checks in order:
|
| 18 |
+
[["document:2","rel1","user:1"]]
|
| 19 |
+
|
| 20 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-check-814e52198b341ef98a21/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true]}
|
tasks/openfga-check-814e52198b341ef98a21/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-check-814e52198b341ef98a21/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/openfga-check-814e52198b341ef98a21"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-check"
|
| 9 |
+
sealed_task_sha256 = "68e1858e4d8ec66961064f8cbba9cd0f3a9c38e3ade00bbbacdfb6033e2f7cbb"
|
| 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/openfga-check-814e52198b341ef98a21/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[true]}
|
tasks/openfga-check-814e52198b341ef98a21/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/openfga-check-814e52198b341ef98a21/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/openfga-check-814e52198b341ef98a21/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/openfga-check-814e52198b341ef98a21/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/openfga-check-81d260e39cb841b183b7/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-check-81d260e39cb841b183b7/instruction.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Perform a static OpenFGA 1.1 authorization review. Only the listed relationships exist. The current model controls which tuples can be used; stored tuples of a disallowed type have no effect. A tuple is written [object, relation, subject]. A subject ending in #relation includes the members of that related object. A typed wildcard includes any concrete subject of its type. 'A from B' follows B to related objects and checks A on those objects. 'but not' is set difference. Evaluate access under the model below.
|
| 2 |
+
Return exactly one JSON object {"decisions":[...]} listing a JSON boolean for each check in the given order.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type role
|
| 8 |
+
relations
|
| 9 |
+
define assignee: [user]
|
| 10 |
+
type permission
|
| 11 |
+
relations
|
| 12 |
+
define assignee: assignee from role
|
| 13 |
+
define role: [role]
|
| 14 |
+
type job
|
| 15 |
+
relations
|
| 16 |
+
define can_read: [permission#assignee]
|
| 17 |
+
define cannot_read: [user] but not can_read
|
| 18 |
+
|
| 19 |
+
Stored relationships:
|
| 20 |
+
[["job:1","can_read","permission:1#assignee"],["job:1","cannot_read","user:1"],["permission:1","role","role:1"],["role:1","assignee","user:1"]]
|
| 21 |
+
|
| 22 |
+
Access checks in order:
|
| 23 |
+
[["job:1","cannot_read","user:1"],["job:1","can_read","user:1"]]
|
| 24 |
+
|
| 25 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-check-81d260e39cb841b183b7/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[false,true]}
|
tasks/openfga-check-81d260e39cb841b183b7/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-check-81d260e39cb841b183b7/task.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/tmp/answer.json"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "cyber-defense/openfga-check-81d260e39cb841b183b7"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-check"
|
| 9 |
+
sealed_task_sha256 = "21cd9961795b6b3b61eedef6d590f1e1fad8ab5e2a3cf3553506bc2142c9d2b3"
|
| 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/openfga-check-81d260e39cb841b183b7/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"decisions":[false,true]}
|
tasks/openfga-check-81d260e39cb841b183b7/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/openfga-check-81d260e39cb841b183b7/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/openfga-check-81d260e39cb841b183b7/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/openfga-check-81d260e39cb841b183b7/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"]}}
|