Harbor format: 1000 cyber_authorization tasks (part 14)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/environment/Dockerfile +1 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/instruction.md +19 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/solution/reference.json +1 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/solution/solve.sh +3 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/task.toml +26 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/tests/expected.json +1 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/tests/grading.py +49 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/tests/test.sh +3 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/tests/verify.py +14 -0
- tasks/openfga-list-objects-1fd7bd216e89b4d4501a/validation/openenv.json +1 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/environment/Dockerfile +1 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/instruction.md +20 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/solution/reference.json +1 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/solution/solve.sh +3 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/task.toml +26 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/tests/expected.json +1 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/tests/grading.py +49 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/tests/test.sh +3 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/tests/verify.py +14 -0
- tasks/openfga-list-objects-202824f69404e9cc67a1/validation/openenv.json +1 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/environment/Dockerfile +1 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/instruction.md +21 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/solution/reference.json +1 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/solution/solve.sh +3 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/task.toml +26 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/tests/expected.json +1 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/tests/grading.py +49 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/tests/test.sh +3 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/tests/verify.py +14 -0
- tasks/openfga-list-objects-216e265daa4e22e6ce08/validation/openenv.json +1 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/environment/Dockerfile +1 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/instruction.md +28 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/solution/reference.json +1 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/solution/solve.sh +3 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/task.toml +26 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/tests/expected.json +1 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/tests/grading.py +49 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/tests/test.sh +3 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/tests/verify.py +14 -0
- tasks/openfga-list-objects-23bcd9c6802b70164857/validation/openenv.json +1 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/environment/Dockerfile +1 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/instruction.md +36 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/solution/reference.json +1 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/solution/solve.sh +3 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/task.toml +26 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/tests/expected.json +1 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/tests/grading.py +49 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/tests/test.sh +3 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/tests/verify.py +14 -0
- tasks/openfga-list-objects-23e76a134f8de6995a4d/validation/openenv.json +1 -0
tasks/openfga-list-objects-1fd7bd216e89b4d4501a/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-list-objects-1fd7bd216e89b4d4501a/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 {"objects":[...]} with all authorized object IDs of the requested type, lexicographically sorted. Use an empty list if none qualify.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
|
| 8 |
+
type document
|
| 9 |
+
relations
|
| 10 |
+
define writer: [user]
|
| 11 |
+
define viewer: writer
|
| 12 |
+
|
| 13 |
+
Stored relationships:
|
| 14 |
+
[["document:1","writer","user:1"]]
|
| 15 |
+
|
| 16 |
+
ListObjects request:
|
| 17 |
+
{"relation":"viewer","type":"document","user":"user:1"}
|
| 18 |
+
|
| 19 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-list-objects-1fd7bd216e89b4d4501a/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":["document:1"]}
|
tasks/openfga-list-objects-1fd7bd216e89b4d4501a/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-list-objects-1fd7bd216e89b4d4501a/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-list-objects-1fd7bd216e89b4d4501a"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-list-objects"
|
| 9 |
+
sealed_task_sha256 = "64ddf0753b78e64ddfcfcb73842ecdf00faf17eb24508ee51ed7f7aae62b3ea8"
|
| 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-list-objects-1fd7bd216e89b4d4501a/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":["document:1"]}
|
tasks/openfga-list-objects-1fd7bd216e89b4d4501a/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-list-objects-1fd7bd216e89b4d4501a/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-list-objects-1fd7bd216e89b4d4501a/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-list-objects-1fd7bd216e89b4d4501a/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-list-objects-202824f69404e9cc67a1/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-list-objects-202824f69404e9cc67a1/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 {"objects":[...]} with all authorized object IDs of the requested type, lexicographically sorted. Use an empty list if none qualify.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type repo
|
| 8 |
+
relations
|
| 9 |
+
define blocked: [user]
|
| 10 |
+
define owner: [user] but not blocked
|
| 11 |
+
|
| 12 |
+
Stored relationships:
|
| 13 |
+
[["repo:1","owner","user:1"]]
|
| 14 |
+
Additional relationships valid only for this query:
|
| 15 |
+
[["repo:2","owner","user:2"]]
|
| 16 |
+
|
| 17 |
+
ListObjects request:
|
| 18 |
+
{"relation":"owner","type":"repo","user":"user:1"}
|
| 19 |
+
|
| 20 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-list-objects-202824f69404e9cc67a1/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":["repo:1"]}
|
tasks/openfga-list-objects-202824f69404e9cc67a1/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-list-objects-202824f69404e9cc67a1/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-list-objects-202824f69404e9cc67a1"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-list-objects"
|
| 9 |
+
sealed_task_sha256 = "28b3d2e154995fcc9cbf28aa12da9a894243840393330c5aabfbb48d85ea43e0"
|
| 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-list-objects-202824f69404e9cc67a1/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":["repo:1"]}
|
tasks/openfga-list-objects-202824f69404e9cc67a1/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-list-objects-202824f69404e9cc67a1/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-list-objects-202824f69404e9cc67a1/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-list-objects-202824f69404e9cc67a1/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-list-objects-216e265daa4e22e6ce08/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-list-objects-216e265daa4e22e6ce08/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 {"objects":[...]} with all authorized object IDs of the requested type, lexicographically sorted. Use an empty list if none qualify.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
|
| 8 |
+
type document
|
| 9 |
+
relations
|
| 10 |
+
define writer: [user]
|
| 11 |
+
define editor: [user]
|
| 12 |
+
define owner: [user]
|
| 13 |
+
define viewer: writer and editor and owner
|
| 14 |
+
|
| 15 |
+
Stored relationships:
|
| 16 |
+
[["document:1","editor","user:1"],["document:1","owner","user:1"],["document:1","writer","user:1"],["document:2","editor","user:2"],["document:2","writer","user:2"],["document:3","owner","user:3"],["document:3","writer","user:3"],["document:4","writer","user:4"],["document:5","editor","user:5"],["document:6","owner","user:6"]]
|
| 17 |
+
|
| 18 |
+
ListObjects request:
|
| 19 |
+
{"relation":"viewer","type":"document","user":"user:3"}
|
| 20 |
+
|
| 21 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-list-objects-216e265daa4e22e6ce08/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":[]}
|
tasks/openfga-list-objects-216e265daa4e22e6ce08/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-list-objects-216e265daa4e22e6ce08/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-list-objects-216e265daa4e22e6ce08"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-list-objects"
|
| 9 |
+
sealed_task_sha256 = "9ec66e71f7b98401bd97b83f58ac6e98318ce16aac176af52419415e3bb97898"
|
| 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-list-objects-216e265daa4e22e6ce08/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":[]}
|
tasks/openfga-list-objects-216e265daa4e22e6ce08/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-list-objects-216e265daa4e22e6ce08/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-list-objects-216e265daa4e22e6ce08/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-list-objects-216e265daa4e22e6ce08/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-list-objects-23bcd9c6802b70164857/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-list-objects-23bcd9c6802b70164857/instruction.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 {"objects":[...]} with all authorized object IDs of the requested type, lexicographically sorted. Use an empty list if none qualify.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type group
|
| 8 |
+
relations
|
| 9 |
+
define member: [user]
|
| 10 |
+
type folder
|
| 11 |
+
relations
|
| 12 |
+
define owner: [group]
|
| 13 |
+
define viewer: member from owner
|
| 14 |
+
type document
|
| 15 |
+
relations
|
| 16 |
+
define banned: [user]
|
| 17 |
+
define owner: [folder]
|
| 18 |
+
define viewer: viewer from owner
|
| 19 |
+
define can_view: viewer but not banned
|
| 20 |
+
define can_see: can_view
|
| 21 |
+
|
| 22 |
+
Stored relationships:
|
| 23 |
+
[["document:1","owner","folder:1"],["folder:1","owner","group:1"],["group:1","member","user:1"]]
|
| 24 |
+
|
| 25 |
+
ListObjects request:
|
| 26 |
+
{"relation":"can_see","type":"document","user":"user:1"}
|
| 27 |
+
|
| 28 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-list-objects-23bcd9c6802b70164857/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":["document:1"]}
|
tasks/openfga-list-objects-23bcd9c6802b70164857/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-list-objects-23bcd9c6802b70164857/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-list-objects-23bcd9c6802b70164857"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-list-objects"
|
| 9 |
+
sealed_task_sha256 = "8f7f476761e7e09e82c8e894906dd7fc0745b3a620f5d4f44b94800a38e21d99"
|
| 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-list-objects-23bcd9c6802b70164857/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":["document:1"]}
|
tasks/openfga-list-objects-23bcd9c6802b70164857/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-list-objects-23bcd9c6802b70164857/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-list-objects-23bcd9c6802b70164857/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-list-objects-23bcd9c6802b70164857/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-list-objects-23e76a134f8de6995a4d/environment/Dockerfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
FROM docker.io/library/python@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
tasks/openfga-list-objects-23e76a134f8de6995a4d/instruction.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 {"objects":[...]} with all authorized object IDs of the requested type, lexicographically sorted. Use an empty list if none qualify.
|
| 3 |
+
|
| 4 |
+
model
|
| 5 |
+
schema 1.1
|
| 6 |
+
type user
|
| 7 |
+
type folder
|
| 8 |
+
relations
|
| 9 |
+
define parent: [folder]
|
| 10 |
+
define owner: [group]
|
| 11 |
+
define folder_reader: [user, group#member] or folder_reader from owner or folder_reader from parent
|
| 12 |
+
define blocked: [user, user:*, group#member] or nblocked from parent
|
| 13 |
+
define unblocked: [user, group#member]
|
| 14 |
+
define nblocked: blocked but not unblocked
|
| 15 |
+
define allowed: [user, user:*, group#member] or allowed from parent
|
| 16 |
+
define super_allowed: [user, group#member] or super_allowed from parent
|
| 17 |
+
define reader: folder_reader and allowed and super_allowed
|
| 18 |
+
define can_read: reader but not nblocked
|
| 19 |
+
type group
|
| 20 |
+
relations
|
| 21 |
+
define parent: [group]
|
| 22 |
+
define allowed: [user, group#member] or allowed from parent
|
| 23 |
+
define super_allowed: [user, group#super_allowed]
|
| 24 |
+
define blocked: [user, group#member] or blocked from parent
|
| 25 |
+
define og_member: [user] or member from parent
|
| 26 |
+
define allowed_member: og_member and allowed and super_allowed
|
| 27 |
+
define member: allowed_member but not blocked
|
| 28 |
+
define folder_reader: [group#member] or folder_reader from parent
|
| 29 |
+
|
| 30 |
+
Stored relationships:
|
| 31 |
+
[["folder:1","allowed","group:3#member"],["folder:1","blocked","user:5"],["folder:1","blocked","user:7"],["folder:1","owner","group:2"],["folder:1","super_allowed","group:3#member"],["folder:2","blocked","user:2"],["folder:2","parent","folder:1"],["folder:2","unblocked","group:1#member"],["folder:2","unblocked","user:5"],["folder:3","parent","folder:2"],["folder:4","allowed","user:*"],["folder:4","blocked","user:*"],["folder:4","parent","folder:3"],["folder:5","parent","folder:4"],["folder:5","unblocked","user:8"],["group:1","allowed","user:7"],["group:1","og_member","user:7"],["group:1","super_allowed","user:7"],["group:2","parent","group:3"],["group:2","super_allowed","group:3#super_allowed"],["group:3","allowed","user:1"],["group:3","allowed","user:2"],["group:3","allowed","user:3"],["group:3","allowed","user:4"],["group:3","allowed","user:5"],["group:3","allowed","user:7"],["group:3","allowed","user:8"],["group:3","blocked","user:4"],["group:3","folder_reader","group:3#member"],["group:3","og_member","user:1"],["group:3","og_member","user:2"],["group:3","og_member","user:3"],["group:3","og_member","user:4"],["group:3","og_member","user:5"],["group:3","og_member","user:7"],["group:3","og_member","user:8"],["group:3","super_allowed","user:1"],["group:3","super_allowed","user:2"],["group:3","super_allowed","user:4"],["group:3","super_allowed","user:5"],["group:3","super_allowed","user:7"],["group:3","super_allowed","user:8"],["repo:1","owner","user:*"]]
|
| 32 |
+
|
| 33 |
+
ListObjects request:
|
| 34 |
+
{"relation":"can_read","type":"folder","user":"user:4"}
|
| 35 |
+
|
| 36 |
+
Save your final JSON response to /tmp/answer.json. Harbor grades the contents of this file.
|
tasks/openfga-list-objects-23e76a134f8de6995a4d/solution/reference.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":[]}
|
tasks/openfga-list-objects-23e76a134f8de6995a4d/solution/solve.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
cp /solution/reference.json /tmp/answer.json
|
tasks/openfga-list-objects-23e76a134f8de6995a4d/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-list-objects-23e76a134f8de6995a4d"
|
| 6 |
+
|
| 7 |
+
[metadata.cyber_defense]
|
| 8 |
+
family = "openfga-list-objects"
|
| 9 |
+
sealed_task_sha256 = "a88fd8f51bb47bc192fe6c1e5f75849bd2c5d3f517fc3dd90b679e589870fa8a"
|
| 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-list-objects-23e76a134f8de6995a4d/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"objects":[]}
|
tasks/openfga-list-objects-23e76a134f8de6995a4d/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-list-objects-23e76a134f8de6995a4d/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-list-objects-23e76a134f8de6995a4d/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-list-objects-23e76a134f8de6995a4d/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"]}}
|