Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/format-code-task-000034/environment/Dockerfile +3 -0
- tasks/format-code-task-000034/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000034/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000034/tests/test.patch +259 -0
- tasks/format-code-task-000034/tests/test.sh +39 -0
- tasks/format-code-task-000034/tests/test_command.sh +1 -0
- tasks/format-code-task-000035/environment/Dockerfile +3 -0
- tasks/format-code-task-000035/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000035/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000035/tests/test.patch +200 -0
- tasks/format-code-task-000035/tests/test.sh +39 -0
- tasks/format-code-task-000035/tests/test_command.sh +1 -0
- tasks/format-code-task-000046/environment/Dockerfile +3 -0
- tasks/format-code-task-000046/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000046/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000046/tests/test.patch +180 -0
- tasks/format-code-task-000046/tests/test.sh +39 -0
- tasks/format-code-task-000046/tests/test_command.sh +1 -0
- tasks/format-code-task-000051/environment/Dockerfile +3 -0
- tasks/format-code-task-000051/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000051/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000051/tests/test.patch +499 -0
- tasks/format-code-task-000051/tests/test.sh +42 -0
- tasks/format-code-task-000051/tests/test_command.sh +1 -0
- tasks/format-code-task-000056/environment/Dockerfile +3 -0
- tasks/format-code-task-000056/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000056/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000056/tests/test.patch +288 -0
- tasks/format-code-task-000056/tests/test.sh +38 -0
- tasks/format-code-task-000056/tests/test_command.sh +1 -0
- tasks/format-code-task-000058/environment/Dockerfile +3 -0
- tasks/format-code-task-000058/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000058/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000058/tests/test.patch +114 -0
- tasks/format-code-task-000058/tests/test.sh +40 -0
- tasks/format-code-task-000058/tests/test_command.sh +1 -0
- tasks/format-code-task-000060/environment/Dockerfile +3 -0
- tasks/format-code-task-000060/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000060/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000060/tests/test.patch +140 -0
- tasks/format-code-task-000060/tests/test.sh +39 -0
- tasks/format-code-task-000060/tests/test_command.sh +1 -0
- tasks/format-code-task-000067/environment/Dockerfile +3 -0
- tasks/format-code-task-000067/environment/setup/files/blocklist +33 -0
- tasks/format-code-task-000067/environment/setup/setup.sh +34 -0
- tasks/format-code-task-000067/tests/test.patch +87 -0
- tasks/format-code-task-000067/tests/test.sh +39 -0
- tasks/format-code-task-000067/tests/test_command.sh +1 -0
- tasks/format-code-task-000069/environment/Dockerfile +3 -0
- tasks/format-code-task-000069/environment/setup/files/blocklist +33 -0
tasks/format-code-task-000034/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:97cb9a9081323508cf4eaa282765cfe9253530e431d20cd5e74758bc96193edb
|
tasks/format-code-task-000034/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000034/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000034/tests/test.patch
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/cli/azd/internal/vsrpc/handler_test.go b/cli/azd/internal/vsrpc/handler_test.go
|
| 2 |
+
index a4f33297f..9d78cc34d 100644
|
| 3 |
+
--- a/cli/azd/internal/vsrpc/handler_test.go
|
| 4 |
+
+++ b/cli/azd/internal/vsrpc/handler_test.go
|
| 5 |
+
@@ -3,6 +3,7 @@ package vsrpc
|
| 6 |
+
import (
|
| 7 |
+
"context"
|
| 8 |
+
"errors"
|
| 9 |
+
+ "strings"
|
| 10 |
+
"testing"
|
| 11 |
+
|
| 12 |
+
"github.com/stretchr/testify/require"
|
| 13 |
+
@@ -83,6 +84,144 @@ func TestHandler(t *testing.T) {
|
| 14 |
+
t.Run("HandlerFunc3", func(t *testing.T) { runHandlerSuite(t, newHandlerFunc3, []any{"arg0", "arg1", "arg2"}, "ok") })
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
+type panicHandlerCase struct {
|
| 18 |
+
+ name string
|
| 19 |
+
+ message string
|
| 20 |
+
+ handler Handler
|
| 21 |
+
+ request jsonrpc2.Request
|
| 22 |
+
+}
|
| 23 |
+
+
|
| 24 |
+
+func TestPanicRecoveredAcrossHandlerAdapters(t *testing.T) {
|
| 25 |
+
+ cases := []panicHandlerCase{
|
| 26 |
+
+ {
|
| 27 |
+
+ name: "action zero args",
|
| 28 |
+
+ message: "hidden action zero panic",
|
| 29 |
+
+ handler: HandlerAction0(func(context.Context) error {
|
| 30 |
+
+ panicRpcTestFrame("hidden action zero panic")
|
| 31 |
+
+ return nil
|
| 32 |
+
+ }),
|
| 33 |
+
+ request: requestWithParams(t),
|
| 34 |
+
+ },
|
| 35 |
+
+ {
|
| 36 |
+
+ name: "action one arg",
|
| 37 |
+
+ message: "hidden action one panic",
|
| 38 |
+
+ handler: HandlerAction1(func(ctx context.Context, value string) error {
|
| 39 |
+
+ require.Equal(t, "alpha", value)
|
| 40 |
+
+ panicRpcTestFrame("hidden action one panic")
|
| 41 |
+
+ return nil
|
| 42 |
+
+ }),
|
| 43 |
+
+ request: requestWithParams(t, "alpha"),
|
| 44 |
+
+ },
|
| 45 |
+
+ {
|
| 46 |
+
+ name: "action two args",
|
| 47 |
+
+ message: "hidden action two panic",
|
| 48 |
+
+ handler: HandlerAction2(func(ctx context.Context, value string, count int) error {
|
| 49 |
+
+ require.Equal(t, "bravo", value)
|
| 50 |
+
+ require.Equal(t, 42, count)
|
| 51 |
+
+ panicRpcTestFrame("hidden action two panic")
|
| 52 |
+
+ return nil
|
| 53 |
+
+ }),
|
| 54 |
+
+ request: requestWithParams(t, "bravo", 42),
|
| 55 |
+
+ },
|
| 56 |
+
+ {
|
| 57 |
+
+ name: "action three args",
|
| 58 |
+
+ message: "hidden action three panic",
|
| 59 |
+
+ handler: HandlerAction3(func(ctx context.Context, value string, count int, flag bool) error {
|
| 60 |
+
+ require.Equal(t, "charlie", value)
|
| 61 |
+
+ require.Equal(t, 7, count)
|
| 62 |
+
+ require.True(t, flag)
|
| 63 |
+
+ panicRpcTestFrame("hidden action three panic")
|
| 64 |
+
+ return nil
|
| 65 |
+
+ }),
|
| 66 |
+
+ request: requestWithParams(t, "charlie", 7, true),
|
| 67 |
+
+ },
|
| 68 |
+
+ {
|
| 69 |
+
+ name: "func zero args",
|
| 70 |
+
+ message: "hidden func zero panic",
|
| 71 |
+
+ handler: HandlerFunc0(func(context.Context) (string, error) {
|
| 72 |
+
+ panicRpcTestFrame("hidden func zero panic")
|
| 73 |
+
+ return "", nil
|
| 74 |
+
+ }),
|
| 75 |
+
+ request: requestWithParams(t),
|
| 76 |
+
+ },
|
| 77 |
+
+ {
|
| 78 |
+
+ name: "func one arg",
|
| 79 |
+
+ message: "hidden func one panic",
|
| 80 |
+
+ handler: HandlerFunc1(func(ctx context.Context, value string) (string, error) {
|
| 81 |
+
+ require.Equal(t, "delta", value)
|
| 82 |
+
+ panicRpcTestFrame("hidden func one panic")
|
| 83 |
+
+ return "", nil
|
| 84 |
+
+ }),
|
| 85 |
+
+ request: requestWithParams(t, "delta"),
|
| 86 |
+
+ },
|
| 87 |
+
+ {
|
| 88 |
+
+ name: "func two args",
|
| 89 |
+
+ message: "hidden func two panic",
|
| 90 |
+
+ handler: HandlerFunc2(func(ctx context.Context, value string, count int) (string, error) {
|
| 91 |
+
+ require.Equal(t, "echo", value)
|
| 92 |
+
+ require.Equal(t, 84, count)
|
| 93 |
+
+ panicRpcTestFrame("hidden func two panic")
|
| 94 |
+
+ return "", nil
|
| 95 |
+
+ }),
|
| 96 |
+
+ request: requestWithParams(t, "echo", 84),
|
| 97 |
+
+ },
|
| 98 |
+
+ {
|
| 99 |
+
+ name: "func three args",
|
| 100 |
+
+ message: "hidden func three panic",
|
| 101 |
+
+ handler: HandlerFunc3(func(ctx context.Context, value string, count int, flag bool) (string, error) {
|
| 102 |
+
+ require.Equal(t, "foxtrot", value)
|
| 103 |
+
+ require.Equal(t, 21, count)
|
| 104 |
+
+ require.False(t, flag)
|
| 105 |
+
+ panicRpcTestFrame("hidden func three panic")
|
| 106 |
+
+ return "", nil
|
| 107 |
+
+ }),
|
| 108 |
+
+ request: requestWithParams(t, "foxtrot", 21, false),
|
| 109 |
+
+ },
|
| 110 |
+
+ }
|
| 111 |
+
+
|
| 112 |
+
+ for _, tc := range cases {
|
| 113 |
+
+ t.Run(tc.name, func(t *testing.T) {
|
| 114 |
+
+ var repliedErr error
|
| 115 |
+
+ reply := func(ctx context.Context, result any, err error) error {
|
| 116 |
+
+ repliedErr = err
|
| 117 |
+
+ return err
|
| 118 |
+
+ }
|
| 119 |
+
+
|
| 120 |
+
+ var handlerErr error
|
| 121 |
+
+ require.NotPanics(t, func() {
|
| 122 |
+
+ handlerErr = tc.handler(context.Background(), nil, reply, tc.request)
|
| 123 |
+
+ })
|
| 124 |
+
+
|
| 125 |
+
+ require.Error(t, handlerErr)
|
| 126 |
+
+ require.Same(t, repliedErr, handlerErr)
|
| 127 |
+
+ assertPanicRpcError(t, handlerErr, tc.message)
|
| 128 |
+
+ })
|
| 129 |
+
+ }
|
| 130 |
+
+}
|
| 131 |
+
+
|
| 132 |
+
+func requestWithParams(t *testing.T, params ...any) jsonrpc2.Request {
|
| 133 |
+
+ t.Helper()
|
| 134 |
+
+
|
| 135 |
+
+ req, err := jsonrpc2.NewCall(jsonrpc2.NewNumberID(1), "hidden/test", params)
|
| 136 |
+
+ require.NoError(t, err)
|
| 137 |
+
+
|
| 138 |
+
+ return req
|
| 139 |
+
+}
|
| 140 |
+
+
|
| 141 |
+
+func assertPanicRpcError(t *testing.T, err error, panicMessage string) {
|
| 142 |
+
+ t.Helper()
|
| 143 |
+
+
|
| 144 |
+
+ var rpcErr *jsonrpc2.Error
|
| 145 |
+
+ require.True(t, errors.As(err, &rpcErr), "expected JSON-RPC error, got %T: %v", err, err)
|
| 146 |
+
+ require.Equal(t, jsonrpc2.InternalError, rpcErr.Code)
|
| 147 |
+
+ require.True(t, strings.HasPrefix(rpcErr.Message, "panic:"), "message should start with panic:, got %q", rpcErr.Message)
|
| 148 |
+
+ require.Contains(t, rpcErr.Message, panicMessage)
|
| 149 |
+
+}
|
| 150 |
+
+
|
| 151 |
+
+func panicRpcTestFrame(message string) {
|
| 152 |
+
+ panic(message)
|
| 153 |
+
+}
|
| 154 |
+
+
|
| 155 |
+
func newHandlerAction0(t *testing.T, tc handlerTestCase) Handler {
|
| 156 |
+
return HandlerAction0(func(ctx context.Context) error {
|
| 157 |
+
select {
|
| 158 |
+
diff --git a/cli/azd/internal/vsrpc/server_test.go b/cli/azd/internal/vsrpc/server_test.go
|
| 159 |
+
index 4ed8aad0e..3f5a3016c 100644
|
| 160 |
+
--- a/cli/azd/internal/vsrpc/server_test.go
|
| 161 |
+
+++ b/cli/azd/internal/vsrpc/server_test.go
|
| 162 |
+
@@ -6,8 +6,10 @@ import (
|
| 163 |
+
"errors"
|
| 164 |
+
"net/http/httptest"
|
| 165 |
+
"net/url"
|
| 166 |
+
+ "strings"
|
| 167 |
+
"sync"
|
| 168 |
+
"testing"
|
| 169 |
+
+ "time"
|
| 170 |
+
|
| 171 |
+
"github.com/gorilla/websocket"
|
| 172 |
+
"github.com/stretchr/testify/require"
|
| 173 |
+
@@ -132,3 +134,64 @@ func TestObserverable(t *testing.T) {
|
| 174 |
+
// The onCompleted message takes no parameters and the args value is empty.
|
| 175 |
+
require.Len(t, onCompletedParams[0], 0)
|
| 176 |
+
}
|
| 177 |
+
+
|
| 178 |
+
+func TestDebugServicePanicErrorDetails(t *testing.T) {
|
| 179 |
+
+ rpcConn := debugRpcConn(t)
|
| 180 |
+
+
|
| 181 |
+
+ err := callTestPanicAsync(t, rpcConn, "panic probe alpha hidden")
|
| 182 |
+
+ assertDebugPanicError(t, err, "panic probe alpha hidden")
|
| 183 |
+
+}
|
| 184 |
+
+
|
| 185 |
+
+func TestDebugServicePanicDoesNotCloseConnection(t *testing.T) {
|
| 186 |
+
+ rpcConn := debugRpcConn(t)
|
| 187 |
+
+
|
| 188 |
+
+ firstErr := callTestPanicAsync(t, rpcConn, "panic probe beta one hidden")
|
| 189 |
+
+ assertDebugPanicError(t, firstErr, "panic probe beta one hidden")
|
| 190 |
+
+
|
| 191 |
+
+ secondErr := callTestPanicAsync(t, rpcConn, "panic probe beta two hidden")
|
| 192 |
+
+ assertDebugPanicError(t, secondErr, "panic probe beta two hidden")
|
| 193 |
+
+}
|
| 194 |
+
+
|
| 195 |
+
+func debugRpcConn(t *testing.T) jsonrpc2.Conn {
|
| 196 |
+
+ t.Helper()
|
| 197 |
+
+
|
| 198 |
+
+ debugServer := httptest.NewServer(newDebugService())
|
| 199 |
+
+ t.Cleanup(debugServer.Close)
|
| 200 |
+
+
|
| 201 |
+
+ serverUrl, err := url.Parse(debugServer.URL)
|
| 202 |
+
+ require.NoError(t, err)
|
| 203 |
+
+ serverUrl.Scheme = "ws"
|
| 204 |
+
+
|
| 205 |
+
+ wsConn, _, err := websocket.DefaultDialer.Dial(serverUrl.String(), nil)
|
| 206 |
+
+ require.NoError(t, err)
|
| 207 |
+
+ t.Cleanup(func() {
|
| 208 |
+
+ require.NoError(t, wsConn.Close())
|
| 209 |
+
+ })
|
| 210 |
+
+
|
| 211 |
+
+ rpcConn := jsonrpc2.NewConn(newWebSocketStream(wsConn))
|
| 212 |
+
+ rpcConn.Go(context.Background(), nil)
|
| 213 |
+
+
|
| 214 |
+
+ return rpcConn
|
| 215 |
+
+}
|
| 216 |
+
+
|
| 217 |
+
+func callTestPanicAsync(t *testing.T, rpcConn jsonrpc2.Conn, message string) error {
|
| 218 |
+
+ t.Helper()
|
| 219 |
+
+
|
| 220 |
+
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
| 221 |
+
+ defer cancel()
|
| 222 |
+
+
|
| 223 |
+
+ _, err := rpcConn.Call(ctx, "TestPanicAsync", []any{message}, nil)
|
| 224 |
+
+ require.Error(t, err)
|
| 225 |
+
+
|
| 226 |
+
+ return err
|
| 227 |
+
+}
|
| 228 |
+
+
|
| 229 |
+
+func assertDebugPanicError(t *testing.T, err error, panicMessage string) {
|
| 230 |
+
+ t.Helper()
|
| 231 |
+
+
|
| 232 |
+
+ var rpcErr *jsonrpc2.Error
|
| 233 |
+
+ require.True(t, errors.As(err, &rpcErr), "expected JSON-RPC error, got %T: %v", err, err)
|
| 234 |
+
+ require.Equal(t, jsonrpc2.InternalError, rpcErr.Code)
|
| 235 |
+
+ require.True(t, strings.HasPrefix(rpcErr.Message, "panic:"), "message should start with panic:, got %q", rpcErr.Message)
|
| 236 |
+
+ require.Contains(t, rpcErr.Message, panicMessage)
|
| 237 |
+
+}
|
| 238 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 239 |
+
new file mode 100755
|
| 240 |
+
--- /dev/null
|
| 241 |
+
+++ b/mimo_test_command.sh
|
| 242 |
+
@@ -0,0 +1,17 @@
|
| 243 |
+
+#!/bin/bash
|
| 244 |
+
+set -uo pipefail
|
| 245 |
+
+
|
| 246 |
+
+cd /testbed
|
| 247 |
+
+
|
| 248 |
+
+case "${1:-}" in
|
| 249 |
+
+ base)
|
| 250 |
+
+ go test github.com/azure/azure-dev/cli/azd/internal/vsrpc -v -count=1 -run '^(TestHandler|TestCancellation|TestObserverable)$'
|
| 251 |
+
+ ;;
|
| 252 |
+
+ new)
|
| 253 |
+
+ go test github.com/azure/azure-dev/cli/azd/internal/vsrpc -v -count=1 -run '^(TestPanicRecoveredAcrossHandlerAdapters|TestDebugServicePanicErrorDetails|TestDebugServicePanicDoesNotCloseConnection)$'
|
| 254 |
+
+ ;;
|
| 255 |
+
+ *)
|
| 256 |
+
+ echo "usage: $0 base|new"
|
| 257 |
+
+ exit 2
|
| 258 |
+
+ ;;
|
| 259 |
+
+esac
|
tasks/format-code-task-000034/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
cli/azd/internal/vsrpc/handler_test.go
|
| 25 |
+
cli/azd/internal/vsrpc/server_test.go
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000034/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new
|
tasks/format-code-task-000035/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f0d2850673fd9e046920cdde1d05976e8e941d2d4aa08931551ba0a76b7b8a40
|
tasks/format-code-task-000035/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000035/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000035/tests/test.patch
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/packages/components/psammead-brand/src/print.test.jsx b/packages/components/psammead-brand/src/print.test.jsx
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 000000000..76d1d3445
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/packages/components/psammead-brand/src/print.test.jsx
|
| 6 |
+
@@ -0,0 +1,172 @@
|
| 7 |
+
+import React from 'react';
|
| 8 |
+
+import renderer from 'react-test-renderer';
|
| 9 |
+
+import 'jest-styled-components';
|
| 10 |
+
+// eslint-disable-next-line import/no-extraneous-dependencies
|
| 11 |
+
+import { getCSS } from 'jest-styled-components/src/utils';
|
| 12 |
+
+import Brand from './index';
|
| 13 |
+
+
|
| 14 |
+
+const findByType = (node, type) => {
|
| 15 |
+
+ if (!node || typeof node !== 'object') return null;
|
| 16 |
+
+ if (Array.isArray(node)) {
|
| 17 |
+
+ for (let i = 0; i < node.length; i += 1) {
|
| 18 |
+
+ const f = findByType(node[i], type);
|
| 19 |
+
+ if (f) return f;
|
| 20 |
+
+ }
|
| 21 |
+
+ return null;
|
| 22 |
+
+ }
|
| 23 |
+
+ if (node.type === type) return node;
|
| 24 |
+
+ if (!node.children) return null;
|
| 25 |
+
+ for (let i = 0; i < node.children.length; i += 1) {
|
| 26 |
+
+ const f = findByType(node.children[i], type);
|
| 27 |
+
+ if (f) return f;
|
| 28 |
+
+ }
|
| 29 |
+
+ return null;
|
| 30 |
+
+};
|
| 31 |
+
+
|
| 32 |
+
+
|
| 33 |
+
+const getGClassTokens = tree => {
|
| 34 |
+
+ const g = findByType(tree, 'g');
|
| 35 |
+
+ if (!g || !g.props || !g.props.className) return [];
|
| 36 |
+
+ return String(g.props.className).trim().split(/\s+/);
|
| 37 |
+
+};
|
| 38 |
+
+
|
| 39 |
+
+
|
| 40 |
+
+const getWrapperClassTokens = tree => {
|
| 41 |
+
+ if (!tree || !tree.props || !tree.props.className) return [];
|
| 42 |
+
+ return String(tree.props.className).trim().split(/\s+/);
|
| 43 |
+
+};
|
| 44 |
+
+
|
| 45 |
+
+
|
| 46 |
+
+const collectPrintMediaRules = ast => {
|
| 47 |
+
+ if (!ast || !ast.stylesheet) return [];
|
| 48 |
+
+ return ast.stylesheet.rules.filter(
|
| 49 |
+
+ r => r.type === 'media' && /print/.test(r.media || ''),
|
| 50 |
+
+ );
|
| 51 |
+
+};
|
| 52 |
+
+
|
| 53 |
+
+
|
| 54 |
+
+
|
| 55 |
+
+const selectorTargetsG = (selector, gClassTokens) => {
|
| 56 |
+
+ if (typeof selector !== 'string') return false;
|
| 57 |
+
+ if (gClassTokens.some(c => selector.includes(`.${c}`))) return true;
|
| 58 |
+
+
|
| 59 |
+
+ if (/(^|[\s>+~])g\s*$/.test(selector.trim())) return true;
|
| 60 |
+
+ return false;
|
| 61 |
+
+};
|
| 62 |
+
+
|
| 63 |
+
+
|
| 64 |
+
+
|
| 65 |
+
+const selectorTargetsWrapper = (selector, wrapperClassTokens) =>
|
| 66 |
+
+ typeof selector === 'string' &&
|
| 67 |
+
+ wrapperClassTokens.some(c => selector.includes(`.${c}`));
|
| 68 |
+
+
|
| 69 |
+
+
|
| 70 |
+
+
|
| 71 |
+
+
|
| 72 |
+
+
|
| 73 |
+
+
|
| 74 |
+
+
|
| 75 |
+
+const hasValidPrintVisibilityFix = (ast, gClassTokens, wrapperClassTokens) => {
|
| 76 |
+
+ const printRules = collectPrintMediaRules(ast);
|
| 77 |
+
+ for (let i = 0; i < printRules.length; i += 1) {
|
| 78 |
+
+ const media = printRules[i];
|
| 79 |
+
+ if (!media.rules) continue; // eslint-disable-line no-continue
|
| 80 |
+
+ for (let j = 0; j < media.rules.length; j += 1) {
|
| 81 |
+
+ const rule = media.rules[j];
|
| 82 |
+
+ if (rule.type !== 'rule' || !rule.declarations) continue; // eslint-disable-line no-continue
|
| 83 |
+
+
|
| 84 |
+
+ const hasFill = rule.declarations.some(d => d.property === 'fill');
|
| 85 |
+
+ const hasBg = rule.declarations.some(
|
| 86 |
+
+ d => d.property === 'background-color',
|
| 87 |
+
+ );
|
| 88 |
+
+ const hasPrintColorAdjust = rule.declarations.some(
|
| 89 |
+
+ d =>
|
| 90 |
+
+ (d.property === 'print-color-adjust' ||
|
| 91 |
+
+ d.property === '-webkit-print-color-adjust') &&
|
| 92 |
+
+ d.value === 'exact',
|
| 93 |
+
+ );
|
| 94 |
+
+
|
| 95 |
+
+ const selectors = rule.selectors || [];
|
| 96 |
+
+
|
| 97 |
+
+
|
| 98 |
+
+ if (
|
| 99 |
+
+ hasFill &&
|
| 100 |
+
+ selectors.some(s => selectorTargetsG(s, gClassTokens))
|
| 101 |
+
+ ) {
|
| 102 |
+
+ return true;
|
| 103 |
+
+ }
|
| 104 |
+
+
|
| 105 |
+
+
|
| 106 |
+
+ if (
|
| 107 |
+
+ hasBg &&
|
| 108 |
+
+ hasPrintColorAdjust &&
|
| 109 |
+
+ selectors.some(s => selectorTargetsWrapper(s, wrapperClassTokens))
|
| 110 |
+
+ ) {
|
| 111 |
+
+ return true;
|
| 112 |
+
+ }
|
| 113 |
+
+ }
|
| 114 |
+
+ }
|
| 115 |
+
+ return false;
|
| 116 |
+
+};
|
| 117 |
+
+
|
| 118 |
+
+describe('Brand print visibility fix', () => {
|
| 119 |
+
+ it('ensures the SVG logo remains visible when printing', () => {
|
| 120 |
+
+ const tree = renderer.create(<Brand brandName="BBC News" />).toJSON();
|
| 121 |
+
+ const gClassTokens = getGClassTokens(tree);
|
| 122 |
+
+ const wrapperClassTokens = getWrapperClassTokens(tree);
|
| 123 |
+
+ const ast = getCSS();
|
| 124 |
+
+
|
| 125 |
+
+ expect(
|
| 126 |
+
+ hasValidPrintVisibilityFix(ast, gClassTokens, wrapperClassTokens),
|
| 127 |
+
+ ).toBe(true);
|
| 128 |
+
+ });
|
| 129 |
+
+
|
| 130 |
+
+ it('does not leave the <g> fill="#fff" attribute unmitigated', () => {
|
| 131 |
+
+
|
| 132 |
+
+
|
| 133 |
+
+
|
| 134 |
+
+
|
| 135 |
+
+
|
| 136 |
+
+ const tree = renderer.create(<Brand brandName="BBC News" />).toJSON();
|
| 137 |
+
+ const g = findByType(tree, 'g');
|
| 138 |
+
+ expect(g).not.toBeNull();
|
| 139 |
+
+
|
| 140 |
+
+ const fillAttr = g.props.fill;
|
| 141 |
+
+ const gClassTokens = getGClassTokens(tree);
|
| 142 |
+
+ const wrapperClassTokens = getWrapperClassTokens(tree);
|
| 143 |
+
+ const ast = getCSS();
|
| 144 |
+
+ const cssLevelFix = hasValidPrintVisibilityFix(
|
| 145 |
+
+ ast,
|
| 146 |
+
+ gClassTokens,
|
| 147 |
+
+ wrapperClassTokens,
|
| 148 |
+
+ );
|
| 149 |
+
+
|
| 150 |
+
+ const attrLevelFix = fillAttr !== '#fff' && fillAttr !== '#FFFFFF';
|
| 151 |
+
+ expect(cssLevelFix || attrLevelFix).toBe(true);
|
| 152 |
+
+ });
|
| 153 |
+
+
|
| 154 |
+
+ it('preserves the BBC News link href (regression check)', () => {
|
| 155 |
+
+ const tree = renderer
|
| 156 |
+
+ .create(<Brand brandName="BBC News" />)
|
| 157 |
+
+ .toJSON();
|
| 158 |
+
+ const a = findByType(tree, 'a');
|
| 159 |
+
+ expect(a).not.toBeNull();
|
| 160 |
+
+ expect(a.props.href).toBe('https://www.bbc.co.uk/news');
|
| 161 |
+
+ });
|
| 162 |
+
+
|
| 163 |
+
+ it('preserves the rendered brand name (regression check)', () => {
|
| 164 |
+
+ const tree = renderer
|
| 165 |
+
+ .create(<Brand brandName="My Branded Service" />)
|
| 166 |
+
+ .toJSON();
|
| 167 |
+
+ expect(JSON.stringify(tree)).toContain('My Branded Service');
|
| 168 |
+
+ });
|
| 169 |
+
+
|
| 170 |
+
+ it('preserves the SVG element with the expected viewBox (regression check)', () => {
|
| 171 |
+
+ const tree = renderer
|
| 172 |
+
+ .create(<Brand brandName="BBC News" />)
|
| 173 |
+
+ .toJSON();
|
| 174 |
+
+ const svg = findByType(tree, 'svg');
|
| 175 |
+
+ expect(svg).not.toBeNull();
|
| 176 |
+
+ expect(svg.props.viewBox).toBe('0 0 167.95 24');
|
| 177 |
+
+ });
|
| 178 |
+
+});
|
| 179 |
+
diff --git a/test_commands.json b/test_commands.json
|
| 180 |
+
new file mode 100644
|
| 181 |
+
index 000000000..4393faeba
|
| 182 |
+
--- /dev/null
|
| 183 |
+
+++ b/test_commands.json
|
| 184 |
+
@@ -0,0 +1,3 @@
|
| 185 |
+
+{
|
| 186 |
+
+ "test_commands": ["npx jest packages/components/psammead-brand/src/print.test.jsx --verbose"]
|
| 187 |
+
+}
|
| 188 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 189 |
+
new file mode 100755
|
| 190 |
+
--- /dev/null
|
| 191 |
+
+++ b/mimo_test_command.sh
|
| 192 |
+
@@ -0,0 +1,8 @@
|
| 193 |
+
+#!/usr/bin/env bash
|
| 194 |
+
+
|
| 195 |
+
+set -uo pipefail
|
| 196 |
+
+cd /testbed
|
| 197 |
+
+rc=0
|
| 198 |
+
+npx jest packages/components/psammead-brand/src/print.test.jsx --verbose
|
| 199 |
+
+rc=$(( rc | $? ))
|
| 200 |
+
+exit $rc
|
tasks/format-code-task-000035/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
packages/components/psammead-brand/src/print.test.jsx
|
| 25 |
+
test_commands.json
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000035/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000046/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ceeb9bea228a86c93e3a983e9b9e1ec7ff8d761feccc194c57d110cc75b4e519
|
tasks/format-code-task-000046/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000046/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000046/tests/test.patch
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/test/parse/grammar/interperter_spec.ts b/test/parse/grammar/interperter_spec.ts
|
| 2 |
+
index 2d0629124..a7b0c0b7d 100644
|
| 3 |
+
--- a/test/parse/grammar/interperter_spec.ts
|
| 4 |
+
+++ b/test/parse/grammar/interperter_spec.ts
|
| 5 |
+
@@ -1,38 +1,39 @@
|
| 6 |
+
import {ITokenGrammarPath} from "../../../src/parse/grammar/path_public"
|
| 7 |
+
import {
|
| 8 |
+
- ActionTok,
|
| 9 |
+
actionDec,
|
| 10 |
+
+ actionDecSep,
|
| 11 |
+
+ ActionTok,
|
| 12 |
+
+ atLeastOneRule,
|
| 13 |
+
+ atLeastOneSepRule,
|
| 14 |
+
+ callArguments,
|
| 15 |
+
+ ColonTok,
|
| 16 |
+
+ CommaTok,
|
| 17 |
+
+ DotTok,
|
| 18 |
+
IdentTok,
|
| 19 |
+
LParenTok,
|
| 20 |
+
- RParenTok,
|
| 21 |
+
- ColonTok,
|
| 22 |
+
- SemicolonTok,
|
| 23 |
+
LSquareTok,
|
| 24 |
+
- RSquareTok,
|
| 25 |
+
- DotTok,
|
| 26 |
+
- CommaTok,
|
| 27 |
+
paramSpec,
|
| 28 |
+
- callArguments,
|
| 29 |
+
- actionDecSep,
|
| 30 |
+
- atLeastOneRule,
|
| 31 |
+
qualifiedNameSep,
|
| 32 |
+
- atLeastOneSepRule
|
| 33 |
+
+ RParenTok,
|
| 34 |
+
+ RSquareTok,
|
| 35 |
+
+ SemicolonTok
|
| 36 |
+
} from "./samples"
|
| 37 |
+
import {
|
| 38 |
+
NextAfterTokenWalker,
|
| 39 |
+
+ nextPossibleTokensAfter,
|
| 40 |
+
+ NextTerminalAfterAtLeastOneSepWalker,
|
| 41 |
+
NextTerminalAfterAtLeastOneWalker,
|
| 42 |
+
- NextTerminalAfterManyWalker,
|
| 43 |
+
NextTerminalAfterManySepWalker,
|
| 44 |
+
- NextTerminalAfterAtLeastOneSepWalker,
|
| 45 |
+
- possiblePathsFrom,
|
| 46 |
+
- nextPossibleTokensAfter
|
| 47 |
+
+ NextTerminalAfterManyWalker,
|
| 48 |
+
+ possiblePathsFrom
|
| 49 |
+
} from "../../../src/parse/grammar/interpreter"
|
| 50 |
+
-import {setEquality, createRegularToken} from "../../utils/matchers"
|
| 51 |
+
+import {createRegularToken, setEquality} from "../../utils/matchers"
|
| 52 |
+
import {gast} from "../../../src/parse/grammar/gast_public"
|
| 53 |
+
-import {Token, IToken} from "../../../src/scan/tokens_public"
|
| 54 |
+
+import {createToken, IToken, Token} from "../../../src/scan/tokens_public"
|
| 55 |
+
import {map} from "../../../src/utils/utils"
|
| 56 |
+
-import {TokenConstructor} from "../../../src/scan/lexer_public"
|
| 57 |
+
+import {Lexer, TokenConstructor} from "../../../src/scan/lexer_public"
|
| 58 |
+
import {augmentTokenClasses, tokenStructuredMatcher} from "../../../src/scan/tokens"
|
| 59 |
+
+import {Parser} from "../../../src/parse/parser_public"
|
| 60 |
+
|
| 61 |
+
let RepetitionMandatory = gast.RepetitionMandatory
|
| 62 |
+
let Terminal = gast.Terminal
|
| 63 |
+
@@ -571,11 +572,11 @@ describe("The chevrotain grammar interpreter capabilities", () => {
|
| 64 |
+
], Comma),
|
| 65 |
+
new gast.Terminal(Gamma)
|
| 66 |
+
]
|
| 67 |
+
-
|
| 68 |
+
expect(extractPartialPaths(possiblePathsFrom(rep, 1))).to.deep.equal([[Alpha], [Gamma]])
|
| 69 |
+
expect(extractPartialPaths(possiblePathsFrom(rep, 2))).to.deep.equal([[Alpha, Alpha], [Gamma]])
|
| 70 |
+
- expect(extractPartialPaths(possiblePathsFrom(rep, 3))).to.deep.equal([[Alpha, Alpha, Gamma], [Gamma]])
|
| 71 |
+
- expect(extractPartialPaths(possiblePathsFrom(rep, 4))).to.deep.equal([[Alpha, Alpha, Gamma], [Gamma]])
|
| 72 |
+
+ expect(extractPartialPaths(possiblePathsFrom(rep, 3))).to.deep.equal([[Alpha, Alpha, Comma], [Alpha, Alpha, Gamma], [Gamma]])
|
| 73 |
+
+ expect(extractPartialPaths(possiblePathsFrom(rep, 4))).to.deep.equal(
|
| 74 |
+
+ [[Alpha, Alpha, Comma, Alpha], [Alpha, Alpha, Gamma], [Gamma]])
|
| 75 |
+
})
|
| 76 |
+
|
| 77 |
+
it("Mandatory Repetition with Separator", () => {
|
| 78 |
+
@@ -590,8 +591,9 @@ describe("The chevrotain grammar interpreter capabilities", () => {
|
| 79 |
+
|
| 80 |
+
expect(extractPartialPaths(possiblePathsFrom(repMandSep, 1))).to.deep.equal([[Alpha]])
|
| 81 |
+
expect(extractPartialPaths(possiblePathsFrom(repMandSep, 2))).to.deep.equal([[Alpha, Alpha]])
|
| 82 |
+
- expect(extractPartialPaths(possiblePathsFrom(repMandSep, 3))).to.deep.equal([[Alpha, Alpha, Gamma]])
|
| 83 |
+
- expect(extractPartialPaths(possiblePathsFrom(repMandSep, 4))).to.deep.equal([[Alpha, Alpha, Gamma]])
|
| 84 |
+
+ expect(extractPartialPaths(possiblePathsFrom(repMandSep, 3))).to.deep.equal([[Alpha, Alpha, Comma], [Alpha, Alpha, Gamma]])
|
| 85 |
+
+ expect(extractPartialPaths(possiblePathsFrom(repMandSep, 4))).to.deep.equal(
|
| 86 |
+
+ [[Alpha, Alpha, Comma, Alpha], [Alpha, Alpha, Gamma]])
|
| 87 |
+
})
|
| 88 |
+
|
| 89 |
+
it("NonTerminal", () => {
|
| 90 |
+
@@ -882,5 +884,68 @@ describe("The chevrotain grammar interpreter capabilities", () => {
|
| 91 |
+
expect(nextPossibleTokensAfter(seq, INPUT([Alpha, Beta, Gamma]), tokenStructuredMatcher, 5)).to.be.empty
|
| 92 |
+
})
|
| 93 |
+
})
|
| 94 |
+
+})
|
| 95 |
+
+
|
| 96 |
+
+describe("issue 391 - WITH_SEP variants do not take SEP into account in lookahead", () => {
|
| 97 |
+
+ it("Reproduce issue", () => {
|
| 98 |
+
+
|
| 99 |
+
+ const LParen = createToken({name: "LParen", pattern: /\(/})
|
| 100 |
+
+ const RParen = createToken({name: "RParen", pattern: /\)/})
|
| 101 |
+
+ const Comma = createToken({name: "Comma", pattern: /,/})
|
| 102 |
+
+ const FatArrow = createToken({name: "FatArrow", pattern: /=>/})
|
| 103 |
+
+ const Identifier = createToken({name: "Identifier", pattern: /[a-zA-Z]+/})
|
| 104 |
+
+ const WhiteSpace = createToken({name: "WhiteSpace", pattern: /\s+/, group: Lexer.SKIPPED})
|
| 105 |
+
+
|
| 106 |
+
+ const allTokens = [WhiteSpace, LParen, RParen, Comma, FatArrow, Identifier]
|
| 107 |
+
+ const issue391Lexer = new Lexer(allTokens)
|
| 108 |
+
|
| 109 |
+
+ class Issue391Parser extends Parser {
|
| 110 |
+
+ constructor(input:Token[] = []) {
|
| 111 |
+
+ super(input, allTokens, {maxLookahead: 4});
|
| 112 |
+
+ (Parser as any).performSelfAnalysis(this)
|
| 113 |
+
+ }
|
| 114 |
+
+
|
| 115 |
+
+ topRule = this.RULE("topRule", () => {
|
| 116 |
+
+ return this.OR1([
|
| 117 |
+
+ {
|
| 118 |
+
+
|
| 119 |
+
+ ALT: () => {
|
| 120 |
+
+ this.CONSUME1(LParen)
|
| 121 |
+
+ this.MANY_SEP({
|
| 122 |
+
+ SEP: Comma,
|
| 123 |
+
+ DEF: () => {
|
| 124 |
+
+ this.CONSUME1(Identifier)
|
| 125 |
+
+ }
|
| 126 |
+
+ })
|
| 127 |
+
+ this.CONSUME1(RParen)
|
| 128 |
+
+ this.CONSUME1(FatArrow)
|
| 129 |
+
+ }
|
| 130 |
+
+ },
|
| 131 |
+
+ {
|
| 132 |
+
+
|
| 133 |
+
+ ALT: () => {
|
| 134 |
+
+ this.CONSUME2(LParen)
|
| 135 |
+
+ this.CONSUME2(Identifier)
|
| 136 |
+
+ this.CONSUME2(RParen)
|
| 137 |
+
+ }
|
| 138 |
+
+ },
|
| 139 |
+
+ ])
|
| 140 |
+
+ })
|
| 141 |
+
+ }
|
| 142 |
+
+
|
| 143 |
+
+ expect(() => new Issue391Parser([])).to.not.throw("Ambiguous alternatives: <1 ,2>")
|
| 144 |
+
+ const myParser = new Issue391Parser([])
|
| 145 |
+
+
|
| 146 |
+
+ function testInput(input) {
|
| 147 |
+
+ const tokens = issue391Lexer.tokenize(input).tokens
|
| 148 |
+
+ myParser.input = tokens
|
| 149 |
+
+ myParser.topRule()
|
| 150 |
+
+ expect(myParser.errors).to.be.empty
|
| 151 |
+
+ }
|
| 152 |
+
+
|
| 153 |
+
+ testInput("(x, y) => ")
|
| 154 |
+
+ testInput("() =>")
|
| 155 |
+
+ testInput("(x) =>")
|
| 156 |
+
+ testInput("(x)")
|
| 157 |
+
+ })
|
| 158 |
+
})
|
| 159 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 160 |
+
new file mode 100644
|
| 161 |
+
--- /dev/null
|
| 162 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 163 |
+
@@ -0,0 +1,6 @@
|
| 164 |
+
+H4sIAAAAAAAAA+3SQU+DMBgGYM78ii/xbKEM2A/Y3YPzTqB0o4ZR0pbp/r0fmOhiortsMcb3OVBI
|
| 165 |
+
+268tb0Uzmb6t9HBMoltJ2boolpZ9bZd3WWQyW0m5zmWUSlmsy4iKm+3ozORD7YgiZ234adyl/j9K
|
| 166 |
+
+fOYftA+VsodDPbTCd9db41L+q1J+5F+WOeefl5LzT6+3he/98/xVS0vwjW7j+I62LyaojoKlB9tq
|
| 167 |
+
+8ewpS2lnHfG9GOtgGtObcCIe1dHTadRb5cwYKBMrkcetPt779wIDz+apc8kNzzS9Ph/u7eSU9sQX
|
| 168 |
+
+jebFfTyMrxS8msc/TgOFThPHstdh6acdF4jnmtXBtlOvfSIaMyT8pbqaRNKbZjlFMtbO62Tvar7F
|
| 169 |
+
+LjFD0G7Ujp+VH7Xi88S//cMBAAAAAAAAAAAAAAAAAAAAAK7oDZKdjQMAKAAA
|
| 170 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 171 |
+
new file mode 100755
|
| 172 |
+
--- /dev/null
|
| 173 |
+
+++ b/mimo_test_command.sh
|
| 174 |
+
@@ -0,0 +1,6 @@
|
| 175 |
+
+#!/usr/bin/env bash
|
| 176 |
+
+
|
| 177 |
+
+set -uo pipefail
|
| 178 |
+
+cd /testbed || exit 1
|
| 179 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 180 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000046/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
test/parse/grammar/interperter_spec.ts
|
| 25 |
+
mimo_build_env.tar.gz.b64
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000046/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000051/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f190d89c473987498ee878e62c22a35f63f1a081bc5045e031430d2cdb13d0dc
|
tasks/format-code-task-000051/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000051/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000051/tests/test.patch
ADDED
|
@@ -0,0 +1,499 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 0000000000..5dbd79c4e6
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh
|
| 6 |
+
@@ -0,0 +1,14 @@
|
| 7 |
+
+#!/bin/bash
|
| 8 |
+
+
|
| 9 |
+
+
|
| 10 |
+
+if [ ! -f /var/log/syslog ]; then
|
| 11 |
+
+ mkdir -p /var/log/
|
| 12 |
+
+ touch /var/log/syslog
|
| 13 |
+
+fi
|
| 14 |
+
+
|
| 15 |
+
+if ! grep -q "^syslog:" /etc/passwd; then
|
| 16 |
+
+ useradd syslog
|
| 17 |
+
+fi
|
| 18 |
+
+
|
| 19 |
+
+chown syslog /var/log/syslog
|
| 20 |
+
+
|
| 21 |
+
diff --git a/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh
|
| 22 |
+
new file mode 100644
|
| 23 |
+
index 0000000000..c1855cbd56
|
| 24 |
+
--- /dev/null
|
| 25 |
+
+++ b/linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh
|
| 26 |
+
@@ -0,0 +1,14 @@
|
| 27 |
+
+#!/bin/bash
|
| 28 |
+
+
|
| 29 |
+
+
|
| 30 |
+
+if [ ! -f /var/log/syslog ]; then
|
| 31 |
+
+ mkdir -p /var/log/
|
| 32 |
+
+ touch /var/log/syslog
|
| 33 |
+
+fi
|
| 34 |
+
+
|
| 35 |
+
+if ! grep -q "^syslog:" /etc/passwd; then
|
| 36 |
+
+ useradd syslog
|
| 37 |
+
+fi
|
| 38 |
+
+
|
| 39 |
+
+useradd testuser_123
|
| 40 |
+
+chown testuser_123 /var/log/syslog
|
| 41 |
+
diff --git a/shared/templates/file_owner/tests/correct_owner.pass.sh b/shared/templates/file_owner/tests/correct_owner.pass.sh
|
| 42 |
+
index f05418c94f..92b31b7d87 100644
|
| 43 |
+
--- a/shared/templates/file_owner/tests/correct_owner.pass.sh
|
| 44 |
+
+++ b/shared/templates/file_owner/tests/correct_owner.pass.sh
|
| 45 |
+
@@ -8,15 +8,15 @@ fi
|
| 46 |
+
{{% if FILE_REGEX %}}
|
| 47 |
+
echo "Create specific tests for this rule because of regex"
|
| 48 |
+
{{% elif RECURSIVE %}}
|
| 49 |
+
-find -L {{{ path }}} -type d -exec chown {{{ FILEUID }}} {} \;
|
| 50 |
+
+find -L {{{ path }}} -type d -exec chown {{{ UID_OR_NAME }}} {} \;
|
| 51 |
+
{{% else %}}
|
| 52 |
+
-chown {{{ FILEUID }}} {{{ path }}}
|
| 53 |
+
+chown {{{ UID_OR_NAME }}} {{{ path }}}
|
| 54 |
+
{{% endif %}}
|
| 55 |
+
{{% else %}}
|
| 56 |
+
if [ ! -f {{{ path }}} ]; then
|
| 57 |
+
mkdir -p "$(dirname '{{{ path }}}')"
|
| 58 |
+
touch {{{ path }}}
|
| 59 |
+
fi
|
| 60 |
+
-chown {{{ FILEUID }}} {{{ path }}}
|
| 61 |
+
+chown {{{ UID_OR_NAME }}} {{{ path }}}
|
| 62 |
+
{{% endif %}}
|
| 63 |
+
{{% endfor %}}
|
| 64 |
+
diff --git a/shared/templates/file_owner/tests/incorrect_owner.fail.sh b/shared/templates/file_owner/tests/incorrect_owner.fail.sh
|
| 65 |
+
index 8d4ccfe0d5..82c16cb89a 100644
|
| 66 |
+
--- a/shared/templates/file_owner/tests/incorrect_owner.fail.sh
|
| 67 |
+
+++ b/shared/templates/file_owner/tests/incorrect_owner.fail.sh
|
| 68 |
+
@@ -13,6 +13,7 @@ useradd testuser_123
|
| 69 |
+
if [ ! -d {{{ path }}} ]; then
|
| 70 |
+
mkdir -p {{{ path }}}
|
| 71 |
+
fi
|
| 72 |
+
+touch "{{{ path }}}"/cac_file_owner_test_file
|
| 73 |
+
{{% if FILE_REGEX %}}
|
| 74 |
+
find -L {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chown testuser_123 {} \;
|
| 75 |
+
{{% elif RECURSIVE %}}
|
| 76 |
+
diff --git a/tests/test_file_owner_uid_or_name_behavior.py b/tests/test_file_owner_uid_or_name_behavior.py
|
| 77 |
+
new file mode 100644
|
| 78 |
+
index 0000000000..6fa46dc554
|
| 79 |
+
--- /dev/null
|
| 80 |
+
+++ b/tests/test_file_owner_uid_or_name_behavior.py
|
| 81 |
+
@@ -0,0 +1,386 @@
|
| 82 |
+
+#!/usr/bin/env python3
|
| 83 |
+
+import importlib.util
|
| 84 |
+
+import os
|
| 85 |
+
+import random
|
| 86 |
+
+import re
|
| 87 |
+
+import shutil
|
| 88 |
+
+import subprocess
|
| 89 |
+
+import sys
|
| 90 |
+
+import tempfile
|
| 91 |
+
+import xml.etree.ElementTree as ET
|
| 92 |
+
+from pathlib import Path
|
| 93 |
+
+
|
| 94 |
+
+
|
| 95 |
+
+REPO_ROOT = Path(__file__).resolve().parents[1]
|
| 96 |
+
+OPENSHIFT_ROOT = REPO_ROOT / "applications" / "openshift"
|
| 97 |
+
+TEMPLATE_ROOT = REPO_ROOT / "shared" / "templates" / "file_owner"
|
| 98 |
+
+RULE_ID = "file_owner_fixture_uid_or_name"
|
| 99 |
+
+
|
| 100 |
+
+sys.path.insert(0, str(REPO_ROOT))
|
| 101 |
+
+
|
| 102 |
+
+import ssg.jinja # noqa: E402
|
| 103 |
+
+
|
| 104 |
+
+
|
| 105 |
+
+def _assert(condition, message):
|
| 106 |
+
+ if not condition:
|
| 107 |
+
+ raise AssertionError(message)
|
| 108 |
+
+
|
| 109 |
+
+
|
| 110 |
+
+def _run(cmd, **kwargs):
|
| 111 |
+
+ result = subprocess.run(
|
| 112 |
+
+ cmd,
|
| 113 |
+
+ text=True,
|
| 114 |
+
+ stdout=subprocess.PIPE,
|
| 115 |
+
+ stderr=subprocess.PIPE,
|
| 116 |
+
+ **kwargs,
|
| 117 |
+
+ )
|
| 118 |
+
+ if result.returncode != 0:
|
| 119 |
+
+ raise AssertionError(
|
| 120 |
+
+ "command failed: {0}\nstdout:\n{1}\nstderr:\n{2}".format(
|
| 121 |
+
+ " ".join(cmd), result.stdout, result.stderr
|
| 122 |
+
+ )
|
| 123 |
+
+ )
|
| 124 |
+
+ return result
|
| 125 |
+
+
|
| 126 |
+
+
|
| 127 |
+
+def _load_template_preprocessor():
|
| 128 |
+
+
|
| 129 |
+
+
|
| 130 |
+
+
|
| 131 |
+
+ path = TEMPLATE_ROOT / "template.py"
|
| 132 |
+
+ spec = importlib.util.spec_from_file_location("fixture_file_owner_template", path)
|
| 133 |
+
+ module = importlib.util.module_from_spec(spec)
|
| 134 |
+
+ spec.loader.exec_module(module)
|
| 135 |
+
+ return module
|
| 136 |
+
+
|
| 137 |
+
+
|
| 138 |
+
+def _render_file_owner_template(lang, template_vars):
|
| 139 |
+
+ params = dict(template_vars)
|
| 140 |
+
+ params.setdefault("_rule_id", RULE_ID)
|
| 141 |
+
+ params.setdefault("recursive", "false")
|
| 142 |
+
+
|
| 143 |
+
+ preprocessor = _load_template_preprocessor()
|
| 144 |
+
+ processed = preprocessor.preprocess(params, lang)
|
| 145 |
+
+ substitutions = {key.upper(): value for key, value in processed.items()}
|
| 146 |
+
+ merged = ssg.jinja.load_macros()
|
| 147 |
+
+ merged.update(substitutions)
|
| 148 |
+
+
|
| 149 |
+
+ return ssg.jinja.process_file(str(TEMPLATE_ROOT / f"{lang}.template"), merged)
|
| 150 |
+
+
|
| 151 |
+
+
|
| 152 |
+
+def _parse_oval_fragment(rendered_oval):
|
| 153 |
+
+ wrapped = (
|
| 154 |
+
+ '<root xmlns:unix="urn:unix" xmlns:ind="urn:ind" xmlns:xsi="urn:xsi">'
|
| 155 |
+
+ + rendered_oval
|
| 156 |
+
+ + "</root>"
|
| 157 |
+
+ )
|
| 158 |
+
+ return ET.fromstring(wrapped)
|
| 159 |
+
+
|
| 160 |
+
+
|
| 161 |
+
+def _namespace(tag):
|
| 162 |
+
+ return {
|
| 163 |
+
+ "unix": f"{{urn:unix}}{tag}",
|
| 164 |
+
+ "ind": f"{{urn:ind}}{tag}",
|
| 165 |
+
+ }
|
| 166 |
+
+
|
| 167 |
+
+
|
| 168 |
+
+def _local_name(tag):
|
| 169 |
+
+ return tag.rsplit("}", 1)[-1]
|
| 170 |
+
+
|
| 171 |
+
+
|
| 172 |
+
+def _unique_user():
|
| 173 |
+
+ return "cacfo{0}{1}".format(os.getpid(), random.randrange(1000, 9999))
|
| 174 |
+
+
|
| 175 |
+
+
|
| 176 |
+
+def _ensure_user(name):
|
| 177 |
+
+ try:
|
| 178 |
+
+ import pwd
|
| 179 |
+
+
|
| 180 |
+
+ return pwd.getpwnam(name).pw_uid
|
| 181 |
+
+ except KeyError:
|
| 182 |
+
+ _run(["useradd", name])
|
| 183 |
+
+ return pwd.getpwnam(name).pw_uid
|
| 184 |
+
+
|
| 185 |
+
+
|
| 186 |
+
+def _delete_user(name):
|
| 187 |
+
+ subprocess.run(["userdel", "-r", name], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 188 |
+
+
|
| 189 |
+
+
|
| 190 |
+
+def _run_shell_script(script):
|
| 191 |
+
+ result = subprocess.run(
|
| 192 |
+
+ ["bash", "-e"],
|
| 193 |
+
+ input=script,
|
| 194 |
+
+ text=True,
|
| 195 |
+
+ stdout=subprocess.PIPE,
|
| 196 |
+
+ stderr=subprocess.PIPE,
|
| 197 |
+
+ )
|
| 198 |
+
+ if result.returncode != 0:
|
| 199 |
+
+ raise AssertionError(
|
| 200 |
+
+ "rendered shell remediation failed\nstdout:\n{0}\nstderr:\n{1}\nscript:\n{2}".format(
|
| 201 |
+
+ result.stdout, result.stderr, script
|
| 202 |
+
+ )
|
| 203 |
+
+ )
|
| 204 |
+
+
|
| 205 |
+
+
|
| 206 |
+
+def test_bash_remediation_accepts_numeric_uid_and_username():
|
| 207 |
+
+ _assert(os.geteuid() == 0, "ownership behavior checks must run as root")
|
| 208 |
+
+ _assert(shutil.which("useradd"), "useradd is required for username ownership checks")
|
| 209 |
+
+ _assert(shutil.which("userdel"), "userdel is required for username ownership cleanup")
|
| 210 |
+
+
|
| 211 |
+
+ owner_name = _unique_user()
|
| 212 |
+
+ try:
|
| 213 |
+
+ owner_uid = _ensure_user(owner_name)
|
| 214 |
+
+ _assert(owner_uid != 0, "dynamic test account should not be root")
|
| 215 |
+
+
|
| 216 |
+
+ with tempfile.TemporaryDirectory(prefix="cac-file-owner-") as tmpdir:
|
| 217 |
+
+ target = Path(tmpdir) / "owned_file"
|
| 218 |
+
+ target.write_text("fixture file_owner behavior\n", encoding="utf-8")
|
| 219 |
+
+
|
| 220 |
+
+ os.chown(target, 0, -1)
|
| 221 |
+
+ numeric_script = _render_file_owner_template(
|
| 222 |
+
+ "bash", {"filepath": str(target), "uid_or_name": str(owner_uid)}
|
| 223 |
+
+ )
|
| 224 |
+
+ _run_shell_script(numeric_script)
|
| 225 |
+
+ _assert(
|
| 226 |
+
+ target.stat().st_uid == owner_uid,
|
| 227 |
+
+ "numeric uid_or_name should be accepted by the generated remediation",
|
| 228 |
+
+ )
|
| 229 |
+
+
|
| 230 |
+
+ os.chown(target, 0, -1)
|
| 231 |
+
+ username_script = _render_file_owner_template(
|
| 232 |
+
+ "bash", {"filepath": str(target), "uid_or_name": owner_name}
|
| 233 |
+
+ )
|
| 234 |
+
+ _run_shell_script(username_script)
|
| 235 |
+
+ _assert(
|
| 236 |
+
+ target.stat().st_uid == owner_uid,
|
| 237 |
+
+ "username uid_or_name should be resolved by the system when remediation runs",
|
| 238 |
+
+ )
|
| 239 |
+
+ finally:
|
| 240 |
+
+ _delete_user(owner_name)
|
| 241 |
+
+
|
| 242 |
+
+
|
| 243 |
+
+def test_oval_check_numeric_uid_uses_integer_user_id():
|
| 244 |
+
+ for uid in ("0", "4242"):
|
| 245 |
+
+ rendered = _render_file_owner_template(
|
| 246 |
+
+ "oval", {"filepath": "/tmp/cac-file-owner-fixture", "uid_or_name": uid}
|
| 247 |
+
+ )
|
| 248 |
+
+ root = _parse_oval_fragment(rendered)
|
| 249 |
+
+ user_ids = list(root.iter(_namespace("user_id")["unix"]))
|
| 250 |
+
+ _assert(user_ids, "rendered numeric OVAL must contain a file owner user_id state")
|
| 251 |
+
+ _assert(
|
| 252 |
+
+ any(el.attrib.get("datatype") == "int" and (el.text or "").strip() == uid for el in user_ids),
|
| 253 |
+
+ "numeric uid_or_name should render as an integer user_id matching the configured UID",
|
| 254 |
+
+ )
|
| 255 |
+
+ _assert(
|
| 256 |
+
+ all("var_ref" not in el.attrib for el in user_ids),
|
| 257 |
+
+ "numeric uid_or_name should not require a runtime username lookup variable",
|
| 258 |
+
+ )
|
| 259 |
+
+ passwd_lookups = [
|
| 260 |
+
+ (el.text or "").strip()
|
| 261 |
+
+ for el in root.iter(_namespace("filepath")["ind"])
|
| 262 |
+
+ if (el.text or "").strip() == "/etc/passwd"
|
| 263 |
+
+ ]
|
| 264 |
+
+ _assert(
|
| 265 |
+
+ not passwd_lookups,
|
| 266 |
+
+ "numeric uid_or_name should keep the previous direct numeric UID behavior",
|
| 267 |
+
+ )
|
| 268 |
+
+
|
| 269 |
+
+
|
| 270 |
+
+def test_oval_check_username_resolves_owner_on_scanned_system():
|
| 271 |
+
+ username = "cac_fixture_owner_{0}".format(random.randrange(10000, 99999))
|
| 272 |
+
+ rendered = _render_file_owner_template(
|
| 273 |
+
+ "oval", {"filepath": "/tmp/cac-file-owner-fixture", "uid_or_name": username}
|
| 274 |
+
+ )
|
| 275 |
+
+ root = _parse_oval_fragment(rendered)
|
| 276 |
+
+
|
| 277 |
+
+ user_ids = list(root.iter(_namespace("user_id")["unix"]))
|
| 278 |
+
+ _assert(user_ids, "rendered username OVAL must contain a file owner user_id state")
|
| 279 |
+
+ _assert(
|
| 280 |
+
+ any("var_ref" in el.attrib for el in user_ids),
|
| 281 |
+
+ "username uid_or_name should compare file owner against a runtime-resolved UID",
|
| 282 |
+
+ )
|
| 283 |
+
+ _assert(
|
| 284 |
+
+ all((el.text or "").strip() != username for el in user_ids),
|
| 285 |
+
+ "username uid_or_name must not be emitted as a literal integer user_id",
|
| 286 |
+
+ )
|
| 287 |
+
+
|
| 288 |
+
+ var_refs = {
|
| 289 |
+
+ el.attrib["var_ref"]
|
| 290 |
+
+ for el in user_ids
|
| 291 |
+
+ if el.attrib.get("datatype") == "int" and "var_ref" in el.attrib
|
| 292 |
+
+ }
|
| 293 |
+
+ _assert(
|
| 294 |
+
+ var_refs,
|
| 295 |
+
+ "username uid_or_name should use a runtime variable for the expected UID",
|
| 296 |
+
+ )
|
| 297 |
+
+
|
| 298 |
+
+ variables = {el.attrib.get("id"): el for el in root.iter() if _local_name(el.tag).endswith("variable")}
|
| 299 |
+
+ connected_variables = [variables[var_ref] for var_ref in var_refs if var_ref in variables]
|
| 300 |
+
+ _assert(
|
| 301 |
+
+ connected_variables,
|
| 302 |
+
+ "username UID comparison should be backed by an OVAL variable definition",
|
| 303 |
+
+ )
|
| 304 |
+
+
|
| 305 |
+
+ component_refs = set()
|
| 306 |
+
+ for variable in connected_variables:
|
| 307 |
+
+ for element in variable.iter():
|
| 308 |
+
+ ref = element.attrib.get("object_ref")
|
| 309 |
+
+ if ref:
|
| 310 |
+
+ component_refs.add(ref)
|
| 311 |
+
+
|
| 312 |
+
+ lookup_objects = {el.attrib.get("id"): el for el in root.iter(_namespace("textfilecontent54_object")["ind"])}
|
| 313 |
+
+ connected_lookup_objects = [lookup_objects[ref] for ref in component_refs if ref in lookup_objects]
|
| 314 |
+
+ _assert(
|
| 315 |
+
+ connected_lookup_objects,
|
| 316 |
+
+ "runtime UID variable should be derived from scanned system account data",
|
| 317 |
+
+ )
|
| 318 |
+
+
|
| 319 |
+
+ lookup_text = "\n".join(
|
| 320 |
+
+ (element.text or "").strip()
|
| 321 |
+
+ for lookup_object in connected_lookup_objects
|
| 322 |
+
+ for element in lookup_object.iter()
|
| 323 |
+
+ )
|
| 324 |
+
+ _assert(
|
| 325 |
+
+ username in lookup_text,
|
| 326 |
+
+ "runtime UID lookup should be tied to the configured account name",
|
| 327 |
+
+ )
|
| 328 |
+
+
|
| 329 |
+
+
|
| 330 |
+
+def _line_indent(line):
|
| 331 |
+
+ return len(line) - len(line.lstrip(" "))
|
| 332 |
+
+
|
| 333 |
+
+
|
| 334 |
+
+def _strip_quotes(value):
|
| 335 |
+
+ value = value.strip()
|
| 336 |
+
+ if len(value) >= 2 and value[0] in ("'", '"') and value[-1] == value[0]:
|
| 337 |
+
+ return value[1:-1]
|
| 338 |
+
+ return value
|
| 339 |
+
+
|
| 340 |
+
+
|
| 341 |
+
+def _active_file_owner_template_vars(rule_path):
|
| 342 |
+
+ lines = rule_path.read_text(encoding="utf-8").splitlines()
|
| 343 |
+
+ for index, line in enumerate(lines):
|
| 344 |
+
+ stripped = line.strip()
|
| 345 |
+
+ if not stripped or stripped.startswith("#"):
|
| 346 |
+
+ continue
|
| 347 |
+
+ if stripped != "template:":
|
| 348 |
+
+ continue
|
| 349 |
+
+
|
| 350 |
+
+ template_indent = _line_indent(line)
|
| 351 |
+
+ block = []
|
| 352 |
+
+ for candidate in lines[index + 1 :]:
|
| 353 |
+
+ candidate_stripped = candidate.strip()
|
| 354 |
+
+ if (
|
| 355 |
+
+ candidate_stripped
|
| 356 |
+
+ and not candidate_stripped.startswith("#")
|
| 357 |
+
+ and _line_indent(candidate) <= template_indent
|
| 358 |
+
+ ):
|
| 359 |
+
+ break
|
| 360 |
+
+ block.append(candidate)
|
| 361 |
+
+
|
| 362 |
+
+ is_file_owner = False
|
| 363 |
+
+ vars_index = None
|
| 364 |
+
+ vars_indent = None
|
| 365 |
+
+ for block_index, block_line in enumerate(block):
|
| 366 |
+
+ block_stripped = block_line.strip()
|
| 367 |
+
+ if not block_stripped or block_stripped.startswith("#") or block_stripped.startswith("{{"):
|
| 368 |
+
+ continue
|
| 369 |
+
+ if block_stripped.startswith("name:"):
|
| 370 |
+
+ is_file_owner = _strip_quotes(block_stripped.split(":", 1)[1]) == "file_owner"
|
| 371 |
+
+ if block_stripped == "vars:":
|
| 372 |
+
+ vars_index = block_index
|
| 373 |
+
+ vars_indent = _line_indent(block_line)
|
| 374 |
+
+
|
| 375 |
+
+ if not is_file_owner or vars_index is None:
|
| 376 |
+
+ continue
|
| 377 |
+
+
|
| 378 |
+
+ vars_ = {}
|
| 379 |
+
+ for var_line in block[vars_index + 1 :]:
|
| 380 |
+
+ var_stripped = var_line.strip()
|
| 381 |
+
+ if not var_stripped or var_stripped.startswith("#") or var_stripped.startswith("{{"):
|
| 382 |
+
+ continue
|
| 383 |
+
+ if _line_indent(var_line) <= vars_indent:
|
| 384 |
+
+ break
|
| 385 |
+
+ match = re.match(r"([A-Za-z0-9_@-]+)\s*:\s*(.*)$", var_stripped)
|
| 386 |
+
+ if match:
|
| 387 |
+
+ vars_[match.group(1)] = _strip_quotes(match.group(2))
|
| 388 |
+
+ return vars_
|
| 389 |
+
+ return None
|
| 390 |
+
+
|
| 391 |
+
+
|
| 392 |
+
+def _base_file_owner_template_vars(relative_path):
|
| 393 |
+
+ try:
|
| 394 |
+
+ result = _run(["git", "show", "HEAD:{0}".format(relative_path)])
|
| 395 |
+
+ except AssertionError:
|
| 396 |
+
+ return None
|
| 397 |
+
+
|
| 398 |
+
+ with tempfile.NamedTemporaryFile("w", encoding="utf-8", delete=False) as tmp:
|
| 399 |
+
+ tmp.write(result.stdout)
|
| 400 |
+
+ tmp_path = Path(tmp.name)
|
| 401 |
+
+ try:
|
| 402 |
+
+ return _active_file_owner_template_vars(tmp_path)
|
| 403 |
+
+ finally:
|
| 404 |
+
+ tmp_path.unlink(missing_ok=True)
|
| 405 |
+
+
|
| 406 |
+
+
|
| 407 |
+
+def test_openshift_file_owner_rules_use_uid_or_name_and_preserve_values():
|
| 408 |
+
+ discovered = {}
|
| 409 |
+
+ migrated_from_base = {}
|
| 410 |
+
+ offenders = []
|
| 411 |
+
+ for rule_path in OPENSHIFT_ROOT.rglob("rule.yml"):
|
| 412 |
+
+ vars_ = _active_file_owner_template_vars(rule_path)
|
| 413 |
+
+ if vars_ is None:
|
| 414 |
+
+ continue
|
| 415 |
+
+ relative = rule_path.relative_to(REPO_ROOT).as_posix()
|
| 416 |
+
+ discovered[relative] = vars_
|
| 417 |
+
+ base_vars = _base_file_owner_template_vars(relative)
|
| 418 |
+
+ if base_vars and "fileuid" in base_vars:
|
| 419 |
+
+ migrated_from_base[relative] = base_vars["fileuid"]
|
| 420 |
+
+ if "fileuid" in vars_ or "uid_or_name" not in vars_:
|
| 421 |
+
+ offenders.append(
|
| 422 |
+
+ "{0}: fileuid={1!r}, uid_or_name={2!r}".format(
|
| 423 |
+
+ relative, vars_.get("fileuid"), vars_.get("uid_or_name")
|
| 424 |
+
+ )
|
| 425 |
+
+ )
|
| 426 |
+
+
|
| 427 |
+
+ _assert(discovered, "expected active OpenShift file_owner rules to exist")
|
| 428 |
+
+ _assert(
|
| 429 |
+
+ not offenders,
|
| 430 |
+
+ "active OpenShift file_owner rules must use uid_or_name instead of fileuid:\n"
|
| 431 |
+
+ + "\n".join(offenders),
|
| 432 |
+
+ )
|
| 433 |
+
+
|
| 434 |
+
+ _assert(
|
| 435 |
+
+ migrated_from_base,
|
| 436 |
+
+ "expected base OpenShift file_owner rules using fileuid to be migration targets",
|
| 437 |
+
+ )
|
| 438 |
+
+
|
| 439 |
+
+ wrong = []
|
| 440 |
+
+ for relative, expected in sorted(migrated_from_base.items()):
|
| 441 |
+
+ if relative not in discovered:
|
| 442 |
+
+ wrong.append("{0}: active file_owner rule disappeared".format(relative))
|
| 443 |
+
+ continue
|
| 444 |
+
+ actual = str(discovered[relative].get("uid_or_name"))
|
| 445 |
+
+ if actual != expected:
|
| 446 |
+
+ wrong.append("{0}: expected {1!r}, got {2!r}".format(relative, expected, actual))
|
| 447 |
+
+ _assert(
|
| 448 |
+
+ not wrong,
|
| 449 |
+
+ "OpenShift file_owner uid_or_name values must preserve the previous owner:\n"
|
| 450 |
+
+ + "\n".join(wrong),
|
| 451 |
+
+ )
|
| 452 |
+
+
|
| 453 |
+
+
|
| 454 |
+
+def main():
|
| 455 |
+
+ tests = [
|
| 456 |
+
+ test_bash_remediation_accepts_numeric_uid_and_username,
|
| 457 |
+
+ test_oval_check_numeric_uid_uses_integer_user_id,
|
| 458 |
+
+ test_oval_check_username_resolves_owner_on_scanned_system,
|
| 459 |
+
+ test_openshift_file_owner_rules_use_uid_or_name_and_preserve_values,
|
| 460 |
+
+ ]
|
| 461 |
+
+ for test in tests:
|
| 462 |
+
+ test()
|
| 463 |
+
+ print("PASS {0}".format(test.__name__))
|
| 464 |
+
+
|
| 465 |
+
+
|
| 466 |
+
+if __name__ == "__main__":
|
| 467 |
+
+ main()
|
| 468 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 469 |
+
new file mode 100755
|
| 470 |
+
--- /dev/null
|
| 471 |
+
+++ b/mimo_test_command.sh
|
| 472 |
+
@@ -0,0 +1,27 @@
|
| 473 |
+
+#!/bin/bash
|
| 474 |
+
+set -uo pipefail
|
| 475 |
+
+cd /testbed
|
| 476 |
+
+
|
| 477 |
+
+
|
| 478 |
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 479 |
+
+REPO_ROOT="/testbed"
|
| 480 |
+
+
|
| 481 |
+
+
|
| 482 |
+
+
|
| 483 |
+
+case "${1:-}" in
|
| 484 |
+
+ base)
|
| 485 |
+
+ python3 - <<'PY'
|
| 486 |
+
+import sys
|
| 487 |
+
+sys.path.insert(0, "/testbed")
|
| 488 |
+
+import ssg.jinja
|
| 489 |
+
+print("base smoke: ssg.jinja import ok")
|
| 490 |
+
+PY
|
| 491 |
+
+ ;;
|
| 492 |
+
+ new)
|
| 493 |
+
+ python3 /testbed/tests/test_file_owner_uid_or_name_behavior.py
|
| 494 |
+
+ ;;
|
| 495 |
+
+ *)
|
| 496 |
+
+ echo "usage: $0 base|new"
|
| 497 |
+
+ exit 2
|
| 498 |
+
+ ;;
|
| 499 |
+
+esac
|
tasks/format-code-task-000051/tests/test.sh
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/correct_owner.pass.sh
|
| 25 |
+
linux_os/guide/system/permissions/files/permissions_var_log_dir/file_owner_var_log_syslog/tests/incorrect_owner.fail.sh
|
| 26 |
+
shared/templates/file_owner/tests/correct_owner.pass.sh
|
| 27 |
+
shared/templates/file_owner/tests/incorrect_owner.fail.sh
|
| 28 |
+
tests/test_file_owner_uid_or_name_behavior.py
|
| 29 |
+
mimo_test_command.sh
|
| 30 |
+
EOF_RESET_TEST_FILES
|
| 31 |
+
|
| 32 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 33 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 34 |
+
cat "$V/apply.log" >&2
|
| 35 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 36 |
+
exit 1
|
| 37 |
+
fi
|
| 38 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 39 |
+
RC=$?
|
| 40 |
+
tail -c 12000 "$V/test_output.log"
|
| 41 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 42 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000051/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new
|
tasks/format-code-task-000056/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d026ee734aefb4a241fb86d03b1543ebd95f6a7259109c02a4be47500d8b2f74
|
tasks/format-code-task-000056/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000056/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000056/tests/test.patch
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/pkg/serverless/logs/logs_test.go b/pkg/serverless/logs/logs_test.go
|
| 2 |
+
index 938393f354..19a88406ae 100644
|
| 3 |
+
--- a/pkg/serverless/logs/logs_test.go
|
| 4 |
+
+++ b/pkg/serverless/logs/logs_test.go
|
| 5 |
+
@@ -12,6 +12,7 @@ import (
|
| 6 |
+
"net/http"
|
| 7 |
+
"net/http/httptest"
|
| 8 |
+
"os"
|
| 9 |
+
+ "strings"
|
| 10 |
+
"testing"
|
| 11 |
+
"time"
|
| 12 |
+
|
| 13 |
+
@@ -392,7 +393,74 @@ func TestProcessMessageShouldNotProcessLogsDropped(t *testing.T) {
|
| 14 |
+
assert.Len(t, timed, 0)
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
-func TestProcessMessageShouldProcessLogTypeFunction(t *testing.T) {
|
| 18 |
+
+func countMetricsByName(samples []metrics.MetricSample, name string) int {
|
| 19 |
+
+ count := 0
|
| 20 |
+
+ for _, sample := range samples {
|
| 21 |
+
+ if sample.Name == name {
|
| 22 |
+
+ count++
|
| 23 |
+
+ }
|
| 24 |
+
+ }
|
| 25 |
+
+ return count
|
| 26 |
+
+}
|
| 27 |
+
+
|
| 28 |
+
+func platformReportJSON(requestID, status string, memoryUsed, memorySize float64) []byte {
|
| 29 |
+
+ return []byte(fmt.Sprintf(`{
|
| 30 |
+
+ "time": %q,
|
| 31 |
+
+ "type": "platform.report",
|
| 32 |
+
+ "record": {
|
| 33 |
+
+ "requestId": %q,
|
| 34 |
+
+ "status": %q,
|
| 35 |
+
+ "metrics": {
|
| 36 |
+
+ "maxMemoryUsedMB": %.1f,
|
| 37 |
+
+ "memorySizeMB": %.1f
|
| 38 |
+
+ }
|
| 39 |
+
+ }
|
| 40 |
+
+ }`, time.Unix(0, 0).UTC().Format(logMessageTimeLayout), requestID, status, memoryUsed, memorySize))
|
| 41 |
+
+}
|
| 42 |
+
+
|
| 43 |
+
+func unmarshalPlatformReport(t *testing.T, raw []byte) *LambdaLogAPIMessage {
|
| 44 |
+
+ t.Helper()
|
| 45 |
+
+ message := &LambdaLogAPIMessage{}
|
| 46 |
+
+ require.NoError(t, json.Unmarshal(raw, message))
|
| 47 |
+
+ return message
|
| 48 |
+
+}
|
| 49 |
+
+
|
| 50 |
+
+func newOOMTestCollector(t *testing.T, demux aggregator.Demultiplexer, requestID string) *LambdaLogsCollector {
|
| 51 |
+
+ t.Helper()
|
| 52 |
+
+
|
| 53 |
+
+ executionContext := &executioncontext.ExecutionContext{}
|
| 54 |
+
+ return newOOMTestCollectorWithExecutionContext(t, demux, requestID, executionContext)
|
| 55 |
+
+}
|
| 56 |
+
+
|
| 57 |
+
+func newOOMTestCollectorWithExecutionContext(t *testing.T, demux aggregator.Demultiplexer, requestID string, executionContext *executioncontext.ExecutionContext) *LambdaLogsCollector {
|
| 58 |
+
+ t.Helper()
|
| 59 |
+
+
|
| 60 |
+
+ arn := "arn:aws:lambda:us-east-1:123456789012:function:test-function"
|
| 61 |
+
+ metricTags := []string{"functionname:test-function"}
|
| 62 |
+
+ tags := Tags{Tags: metricTags}
|
| 63 |
+
+ executionContext.SetFromInvocation(arn, requestID)
|
| 64 |
+
+
|
| 65 |
+
+ lc := NewLambdaLogCollector(
|
| 66 |
+
+ make(chan<- *config.ChannelMessage),
|
| 67 |
+
+ demux,
|
| 68 |
+
+ &tags,
|
| 69 |
+
+ true,
|
| 70 |
+
+ true,
|
| 71 |
+
+ executionContext,
|
| 72 |
+
+ func() {},
|
| 73 |
+
+ make(chan<- float64),
|
| 74 |
+
+ )
|
| 75 |
+
+ lc.lastRequestID = requestID
|
| 76 |
+
+ return lc
|
| 77 |
+
+}
|
| 78 |
+
+
|
| 79 |
+
+func processAndWaitForSamples(lc *LambdaLogsCollector, message LambdaLogAPIMessage, expectedSamples int) ([]metrics.MetricSample, []metrics.MetricSample) {
|
| 80 |
+
+ lc.Start()
|
| 81 |
+
+ lc.In <- []LambdaLogAPIMessage{message}
|
| 82 |
+
+ return lc.demux.(*aggregator.TestAgentDemultiplexer).WaitForNumberOfSamples(expectedSamples, 0, 100*time.Millisecond)
|
| 83 |
+
+}
|
| 84 |
+
+
|
| 85 |
+
+func TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory(t *testing.T) {
|
| 86 |
+
demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 87 |
+
defer demux.Stop(false)
|
| 88 |
+
message := &LambdaLogAPIMessage{
|
| 89 |
+
@@ -413,14 +481,170 @@ func TestProcessMessageShouldProcessLogTypeFunction(t *testing.T) {
|
| 90 |
+
mockExecutionContext.SetFromInvocation(arn, lastRequestID)
|
| 91 |
+
|
| 92 |
+
lc := NewLambdaLogCollector(make(chan<- *config.ChannelMessage), demux, &tags, true, computeEnhancedMetrics, mockExecutionContext, func() {}, make(chan<- float64))
|
| 93 |
+
+ lc.lastRequestID = lastRequestID
|
| 94 |
+
|
| 95 |
+
- go lc.processMessage(message)
|
| 96 |
+
+ received, timed := processAndWaitForSamples(lc, *message, 2)
|
| 97 |
+
|
| 98 |
+
- received, timed := demux.WaitForNumberOfSamples(2, 0, 100*time.Millisecond)
|
| 99 |
+
assert.Len(t, received, 2)
|
| 100 |
+
assert.Len(t, timed, 0)
|
| 101 |
+
- assert.Equal(t, serverlessMetrics.OutOfMemoryMetric, received[0].Name)
|
| 102 |
+
- assert.Equal(t, serverlessMetrics.ErrorsMetric, received[1].Name)
|
| 103 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 104 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.ErrorsMetric))
|
| 105 |
+
+}
|
| 106 |
+
+
|
| 107 |
+
+func TestProcessPlatformReportOOMEmitsEnhancedMetricsFromJSON(t *testing.T) {
|
| 108 |
+
+ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 109 |
+
+ defer demux.Stop(false)
|
| 110 |
+
+
|
| 111 |
+
+ requestID := "8286a188-ba32-4475-8077-530cd35c09a9"
|
| 112 |
+
+ message := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 512, 512))
|
| 113 |
+
+ lc := newOOMTestCollector(t, demux, requestID)
|
| 114 |
+
+
|
| 115 |
+
+ received, timed := processAndWaitForSamples(lc, *message, 8)
|
| 116 |
+
+ assert.Len(t, timed, 0)
|
| 117 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 118 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.ErrorsMetric))
|
| 119 |
+
+}
|
| 120 |
+
+
|
| 121 |
+
+func TestProcessPlatformReportOOMAlsoEmitsWhenMemoryExceedsLimit(t *testing.T) {
|
| 122 |
+
+ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 123 |
+
+ defer demux.Stop(false)
|
| 124 |
+
+
|
| 125 |
+
+ requestID := "5d607cb8-d752-43e7-8f99-f5b5f6a17452"
|
| 126 |
+
+ message := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 768, 512))
|
| 127 |
+
+ lc := newOOMTestCollector(t, demux, requestID)
|
| 128 |
+
+
|
| 129 |
+
+ received, timed := processAndWaitForSamples(lc, *message, 8)
|
| 130 |
+
+ assert.Len(t, timed, 0)
|
| 131 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 132 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.ErrorsMetric))
|
| 133 |
+
+}
|
| 134 |
+
+
|
| 135 |
+
+func TestProcessPlatformReportOOMRequiresQualifyingReport(t *testing.T) {
|
| 136 |
+
+ testCases := []struct {
|
| 137 |
+
+ name string
|
| 138 |
+
+ status string
|
| 139 |
+
+ memoryUsed float64
|
| 140 |
+
+ memorySize float64
|
| 141 |
+
+ }{
|
| 142 |
+
+ {
|
| 143 |
+
+ name: "non-error status at memory limit",
|
| 144 |
+
+ status: "success",
|
| 145 |
+
+ memoryUsed: 256,
|
| 146 |
+
+ memorySize: 256,
|
| 147 |
+
+ },
|
| 148 |
+
+ {
|
| 149 |
+
+ name: "error status below memory limit",
|
| 150 |
+
+ status: "error",
|
| 151 |
+
+ memoryUsed: 255,
|
| 152 |
+
+ memorySize: 256,
|
| 153 |
+
+ },
|
| 154 |
+
+ {
|
| 155 |
+
+ name: "error status with zero memory used",
|
| 156 |
+
+ status: "error",
|
| 157 |
+
+ memoryUsed: 0,
|
| 158 |
+
+ memorySize: 256,
|
| 159 |
+
+ },
|
| 160 |
+
+ }
|
| 161 |
+
+
|
| 162 |
+
+ for _, tc := range testCases {
|
| 163 |
+
+ t.Run(tc.name, func(t *testing.T) {
|
| 164 |
+
+ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 165 |
+
+ defer demux.Stop(false)
|
| 166 |
+
+
|
| 167 |
+
+ requestID := "negative-" + strings.ReplaceAll(tc.name, " ", "-")
|
| 168 |
+
+ message := unmarshalPlatformReport(t, platformReportJSON(requestID, tc.status, tc.memoryUsed, tc.memorySize))
|
| 169 |
+
+ lc := newOOMTestCollector(t, demux, requestID)
|
| 170 |
+
+
|
| 171 |
+
+ received, timed := processAndWaitForSamples(lc, *message, 6)
|
| 172 |
+
+ assert.Len(t, timed, 0)
|
| 173 |
+
+ assert.Equal(t, 0, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 174 |
+
+ })
|
| 175 |
+
+ }
|
| 176 |
+
+}
|
| 177 |
+
+
|
| 178 |
+
+func TestOutOfMemoryEnhancedMetricsAreDedupedPerRequest(t *testing.T) {
|
| 179 |
+
+ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 180 |
+
+ defer demux.Stop(false)
|
| 181 |
+
+
|
| 182 |
+
+ requestID := "fa7d55f7-4054-412f-9567-8f607c8376db"
|
| 183 |
+
+ lc := newOOMTestCollector(t, demux, requestID)
|
| 184 |
+
+ functionOOM := &LambdaLogAPIMessage{
|
| 185 |
+
+ logType: logTypeFunction,
|
| 186 |
+
+ time: time.Now(),
|
| 187 |
+
+ stringRecord: "JavaScript heap out of memory",
|
| 188 |
+
+ }
|
| 189 |
+
+ reportOOM := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 1024, 1024))
|
| 190 |
+
+
|
| 191 |
+
+ lc.Start()
|
| 192 |
+
+ lc.In <- []LambdaLogAPIMessage{*functionOOM, *reportOOM}
|
| 193 |
+
+
|
| 194 |
+
+ received, timed := demux.WaitForNumberOfSamples(8, 0, 100*time.Millisecond)
|
| 195 |
+
+ assert.Len(t, timed, 0)
|
| 196 |
+
+ assert.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 197 |
+
+}
|
| 198 |
+
+
|
| 199 |
+
+func TestPersistedOOMDeduplicationPreventsDuplicateAfterRestore(t *testing.T) {
|
| 200 |
+
+ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 201 |
+
+ defer demux.Stop(false)
|
| 202 |
+
+
|
| 203 |
+
+ const stateFile = "/tmp/dd-lambda-extension-cache.json"
|
| 204 |
+
+ require.NoError(t, os.RemoveAll(stateFile))
|
| 205 |
+
+ t.Cleanup(func() {
|
| 206 |
+
+ _ = os.Remove(stateFile)
|
| 207 |
+
+ })
|
| 208 |
+
+
|
| 209 |
+
+ requestID := "72946812-35dd-4382-b180-92f51cb7168c"
|
| 210 |
+
+ lc := newOOMTestCollector(t, demux, requestID)
|
| 211 |
+
+ firstReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 384, 256))
|
| 212 |
+
+
|
| 213 |
+
+ received, timed := processAndWaitForSamples(lc, *firstReport, 8)
|
| 214 |
+
+ require.Len(t, timed, 0)
|
| 215 |
+
+ require.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 216 |
+
+
|
| 217 |
+
+ require.NoError(t, lc.executionContext.SaveCurrentExecutionContext())
|
| 218 |
+
+
|
| 219 |
+
+ restoredCollector := newOOMTestCollector(t, demux, requestID)
|
| 220 |
+
+ require.NoError(t, restoredCollector.executionContext.RestoreCurrentStateFromFile())
|
| 221 |
+
+ replayedReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 384, 256))
|
| 222 |
+
+
|
| 223 |
+
+ restoredCollector.Start()
|
| 224 |
+
+ restoredCollector.In <- []LambdaLogAPIMessage{*replayedReport}
|
| 225 |
+
+
|
| 226 |
+
+ replayed, replayedTimed := demux.WaitForNumberOfSamples(14, 0, 100*time.Millisecond)
|
| 227 |
+
+ assert.Len(t, replayedTimed, 0)
|
| 228 |
+
+ assert.Equal(t, 1, countMetricsByName(replayed, serverlessMetrics.OutOfMemoryMetric))
|
| 229 |
+
+}
|
| 230 |
+
+
|
| 231 |
+
+func TestPersistedOOMDeduplicationPreventsDuplicateForArbitraryRequest(t *testing.T) {
|
| 232 |
+
+ demux := aggregator.InitTestAgentDemultiplexerWithFlushInterval(time.Hour)
|
| 233 |
+
+ defer demux.Stop(false)
|
| 234 |
+
+
|
| 235 |
+
+ const stateFile = "/tmp/dd-lambda-extension-cache.json"
|
| 236 |
+
+ require.NoError(t, os.RemoveAll(stateFile))
|
| 237 |
+
+ t.Cleanup(func() {
|
| 238 |
+
+ _ = os.Remove(stateFile)
|
| 239 |
+
+ })
|
| 240 |
+
+
|
| 241 |
+
+ requestID := "2b11979d-d2f0-4e1a-8840-5357f2c20b42"
|
| 242 |
+
+ lc := newOOMTestCollector(t, demux, requestID)
|
| 243 |
+
+ firstReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 640, 512))
|
| 244 |
+
+
|
| 245 |
+
+ received, timed := processAndWaitForSamples(lc, *firstReport, 8)
|
| 246 |
+
+ require.Len(t, timed, 0)
|
| 247 |
+
+ require.Equal(t, 1, countMetricsByName(received, serverlessMetrics.OutOfMemoryMetric))
|
| 248 |
+
+
|
| 249 |
+
+ require.NoError(t, lc.executionContext.SaveCurrentExecutionContext())
|
| 250 |
+
+
|
| 251 |
+
+ restoredCollector := newOOMTestCollector(t, demux, requestID)
|
| 252 |
+
+ require.NoError(t, restoredCollector.executionContext.RestoreCurrentStateFromFile())
|
| 253 |
+
+ replayedReport := unmarshalPlatformReport(t, platformReportJSON(requestID, "error", 640, 512))
|
| 254 |
+
+
|
| 255 |
+
+ restoredCollector.Start()
|
| 256 |
+
+ restoredCollector.In <- []LambdaLogAPIMessage{*replayedReport}
|
| 257 |
+
+
|
| 258 |
+
+ replayed, replayedTimed := demux.WaitForNumberOfSamples(14, 0, 100*time.Millisecond)
|
| 259 |
+
+ assert.Len(t, replayedTimed, 0)
|
| 260 |
+
+ assert.Equal(t, 1, countMetricsByName(replayed, serverlessMetrics.OutOfMemoryMetric))
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
func TestProcessLogMessageLogsEnabled(t *testing.T) {
|
| 264 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 265 |
+
new file mode 100755
|
| 266 |
+
--- /dev/null
|
| 267 |
+
+++ b/mimo_test_command.sh
|
| 268 |
+
@@ -0,0 +1,20 @@
|
| 269 |
+
+#!/bin/bash
|
| 270 |
+
+set -uo pipefail
|
| 271 |
+
+cd /testbed
|
| 272 |
+
+
|
| 273 |
+
+
|
| 274 |
+
+cd /testbed
|
| 275 |
+
+
|
| 276 |
+
+
|
| 277 |
+
+case "${1:-}" in
|
| 278 |
+
+ base)
|
| 279 |
+
+ go test -v -count=1 ./pkg/serverless/executioncontext/... ./pkg/serverless/logs/...
|
| 280 |
+
+ ;;
|
| 281 |
+
+ new)
|
| 282 |
+
+ go test -v -count=1 ./pkg/serverless/logs/... -run '^(TestProcessMessageShouldProcessLogTypeFunctionOutOfMemory|TestProcessPlatformReportOOMEmitsEnhancedMetricsFromJSON|TestProcessPlatformReportOOMAlsoEmitsWhenMemoryExceedsLimit|TestProcessPlatformReportOOMRequiresQualifyingReport|TestOutOfMemoryEnhancedMetricsAreDedupedPerRequest|TestPersistedOOMDeduplicationPreventsDuplicateAfterRestore|TestPersistedOOMDeduplicationPreventsDuplicateForArbitraryRequest)$'
|
| 283 |
+
+ ;;
|
| 284 |
+
+ *)
|
| 285 |
+
+ echo "usage: $0 base|new"
|
| 286 |
+
+ exit 2
|
| 287 |
+
+ ;;
|
| 288 |
+
+esac
|
tasks/format-code-task-000056/tests/test.sh
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
pkg/serverless/logs/logs_test.go
|
| 25 |
+
mimo_test_command.sh
|
| 26 |
+
EOF_RESET_TEST_FILES
|
| 27 |
+
|
| 28 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 29 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 30 |
+
cat "$V/apply.log" >&2
|
| 31 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 32 |
+
exit 1
|
| 33 |
+
fi
|
| 34 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 35 |
+
RC=$?
|
| 36 |
+
tail -c 12000 "$V/test_output.log"
|
| 37 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 38 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000056/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new
|
tasks/format-code-task-000058/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:91b7266714fc6d0a66653e4b15a81820625e6019b8510e625560989946c22c47
|
tasks/format-code-task-000058/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000058/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000058/tests/test.patch
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/rtloader/test/datadog_agent/datadog_agent.go b/rtloader/test/datadog_agent/datadog_agent.go
|
| 2 |
+
index e0f202c0b34e5b..ef8474ab6dd84c 100644
|
| 3 |
+
--- a/rtloader/test/datadog_agent/datadog_agent.go
|
| 4 |
+
+++ b/rtloader/test/datadog_agent/datadog_agent.go
|
| 5 |
+
@@ -4,6 +4,7 @@ import (
|
| 6 |
+
"fmt"
|
| 7 |
+
"io/ioutil"
|
| 8 |
+
"os"
|
| 9 |
+
+ "time"
|
| 10 |
+
"runtime"
|
| 11 |
+
"strings"
|
| 12 |
+
"unsafe"
|
| 13 |
+
@@ -33,6 +34,7 @@ extern void writePersistentCache(char*, char*);
|
| 14 |
+
extern char* readPersistentCache(char*);
|
| 15 |
+
extern char* obfuscateSQL(char*, char*, char**);
|
| 16 |
+
extern char* obfuscateSQLExecPlan(char*, bool, char**);
|
| 17 |
+
+extern double getProcessStartTime();
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
static void initDatadogAgentTests(rtloader_t *rtloader) {
|
| 21 |
+
@@ -50,6 +52,7 @@ static void initDatadogAgentTests(rtloader_t *rtloader) {
|
| 22 |
+
set_read_persistent_cache_cb(rtloader, readPersistentCache);
|
| 23 |
+
set_obfuscate_sql_cb(rtloader, obfuscateSQL);
|
| 24 |
+
set_obfuscate_sql_exec_plan_cb(rtloader, obfuscateSQLExecPlan);
|
| 25 |
+
+ set_get_process_start_time_cb(rtloader, getProcessStartTime);
|
| 26 |
+
}
|
| 27 |
+
*/
|
| 28 |
+
import "C"
|
| 29 |
+
@@ -282,3 +285,10 @@ func obfuscateSQLExecPlan(rawQuery *C.char, normalize C.bool, errResult **C.char
|
| 30 |
+
return nil
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
+
|
| 34 |
+
+var processStartTime = float64(time.Now().Unix())
|
| 35 |
+
+
|
| 36 |
+
+//export getProcessStartTime
|
| 37 |
+
+func getProcessStartTime() float64 {
|
| 38 |
+
+ return processStartTime
|
| 39 |
+
+}
|
| 40 |
+
diff --git a/rtloader/test/datadog_agent/datadog_agent_test.go b/rtloader/test/datadog_agent/datadog_agent_test.go
|
| 41 |
+
index 6f17ebfe12174d..beb88133b4f1e5 100644
|
| 42 |
+
--- a/rtloader/test/datadog_agent/datadog_agent_test.go
|
| 43 |
+
+++ b/rtloader/test/datadog_agent/datadog_agent_test.go
|
| 44 |
+
@@ -4,6 +4,7 @@ import (
|
| 45 |
+
"fmt"
|
| 46 |
+
"os"
|
| 47 |
+
"regexp"
|
| 48 |
+
+ "strconv"
|
| 49 |
+
"testing"
|
| 50 |
+
|
| 51 |
+
"github.com/DataDog/datadog-agent/rtloader/test/helpers"
|
| 52 |
+
@@ -578,3 +579,34 @@ func TestObfuscateSqlExecPlanErrors(t *testing.T) {
|
| 53 |
+
|
| 54 |
+
helpers.AssertMemoryUsage(t)
|
| 55 |
+
}
|
| 56 |
+
+
|
| 57 |
+
+func TestProcessStartTime(t *testing.T) {
|
| 58 |
+
+ // Reset memory counters
|
| 59 |
+
+ helpers.ResetMemoryStats()
|
| 60 |
+
+
|
| 61 |
+
+ exp := processStartTime // copy the value before anything touches it
|
| 62 |
+
+
|
| 63 |
+
+ code := fmt.Sprintf(`
|
| 64 |
+
+ with open(r'%s', 'w') as f:
|
| 65 |
+
+ pst = datadog_agent.get_process_start_time()
|
| 66 |
+
+ assert type(pst) == type(0.0)
|
| 67 |
+
+ f.write(pst.hex())
|
| 68 |
+
+ `, tmpfile.Name())
|
| 69 |
+
+
|
| 70 |
+
+ out, err := run(code)
|
| 71 |
+
+ if err != nil {
|
| 72 |
+
+ t.Fatal(err)
|
| 73 |
+
+ }
|
| 74 |
+
+
|
| 75 |
+
+ val, err := strconv.ParseFloat(out, 64)
|
| 76 |
+
+ if err != nil {
|
| 77 |
+
+ t.Fatal(err)
|
| 78 |
+
+ }
|
| 79 |
+
+
|
| 80 |
+
+ if val != exp {
|
| 81 |
+
+ t.Errorf("Unexpected printed value: '%s'", out)
|
| 82 |
+
+ }
|
| 83 |
+
+
|
| 84 |
+
+ // Check for leaks
|
| 85 |
+
+ helpers.AssertMemoryUsage(t)
|
| 86 |
+
+}
|
| 87 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 88 |
+
new file mode 100644
|
| 89 |
+
--- /dev/null
|
| 90 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 91 |
+
@@ -0,0 +1,12 @@
|
| 92 |
+
+H4sIAAAAAAAAA+2UbU/bMBDH+zqf4tRNGwg5IX0Y0qRO6sOASoUiYJqQJlWubVqvjh1sh6n79HPS
|
| 93 |
+
+0RUY8AY0bbufFNk6X+7+9j9OPC2k4hOhr5PaS7Eb2Gu3qzFwd6zmabuRNhqtNG21artp2t5r16D9
|
| 94 |
+
+Yoo2KJynFqBmjfGP5T21/pcS//LfC+cnzGQZ1Tx28+fr8YT/wezm2v/dVhr8b71LmzXYfT4JD/Of
|
| 95 |
+
++884VMZPBY+iV3D2TXo2B2/goN+HtAlb1dgGRgsnHDCjL5VkXuoZ8cs8RIS1xjqQGhbFVBReqpht
|
| 96 |
+
+R1xcE7eqNWMsFLpd/GTp50ZDM04bm6l5FW6u4uGFoQ7mKBXSL7pHI9iy4qqQVnCYLsF6ZSgX9q0D
|
| 97 |
+
+523QA2XvUoj0kir5nXpp9HZ0U5NkkMs8LK9KEjK1gi6IWzovMpJTtqCzsB1yFVQsaaag8SEJ0hJd
|
| 98 |
+
+KFVq6ZX3ZN0V+kl/ZwfcnJZylJxaaqVwkc2A2Mt1WlLdrihbcGmB5HfjjN+LZHQhgAwGw7Nub/Rx
|
| 99 |
+
+cnJxfjg+bnTGxyHY+zQcDSaDj0fjznh/H+I4CSLfpNHqna+vt3RuDdteBYPk00KDnwvg1FNuZpOw
|
| 100 |
+
+Qe2hdNtFG74naw1lIOofjCf9/VH34KxTJ8P7SVIzVfDQ8Ddr5d8j+Eo+a0O4yK1g1AsepkxRWxni
|
| 101 |
+
+6vClajEa3PQY3a9THUbi51aIBB5OWLtB1M89kmqPZHNBlR3DuY2GvdPu6cXkpHt+2Kk/VTJ5/7iq
|
| 102 |
+
+sujMVIcZPi3DO+EB4unMQb3KqANhptC+kwK5hji5ZUISx3H0p68+giAIgiAIgiAIgiAIgiAIgiAI
|
| 103 |
+
+giAIgiD/CD8AmGc2XwAoAAA=
|
| 104 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 105 |
+
new file mode 100755
|
| 106 |
+
--- /dev/null
|
| 107 |
+
+++ b/mimo_test_command.sh
|
| 108 |
+
@@ -0,0 +1,6 @@
|
| 109 |
+
+#!/usr/bin/env bash
|
| 110 |
+
+# Verifier for the opensource-code dataset. Exit 0 means resolved.
|
| 111 |
+
+set -uo pipefail
|
| 112 |
+
+cd /testbed || exit 1
|
| 113 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 114 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000058/tests/test.sh
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
rtloader/test/datadog_agent/datadog_agent.go
|
| 25 |
+
rtloader/test/datadog_agent/datadog_agent_test.go
|
| 26 |
+
mimo_build_env.tar.gz.b64
|
| 27 |
+
mimo_test_command.sh
|
| 28 |
+
EOF_RESET_TEST_FILES
|
| 29 |
+
|
| 30 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 31 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 32 |
+
cat "$V/apply.log" >&2
|
| 33 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 34 |
+
exit 1
|
| 35 |
+
fi
|
| 36 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 37 |
+
RC=$?
|
| 38 |
+
tail -c 12000 "$V/test_output.log"
|
| 39 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 40 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000058/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000060/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c3b5d988c97689ca6a49626f265b52954d31b1110062a6df7f52ec16e8f8cb6f
|
tasks/format-code-task-000060/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000060/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000060/tests/test.patch
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/internal/controller/datadogmonitor/monitor_test.go b/internal/controller/datadogmonitor/monitor_test.go
|
| 2 |
+
index ae74b3500..da8a4bb66 100644
|
| 3 |
+
--- a/internal/controller/datadogmonitor/monitor_test.go
|
| 4 |
+
+++ b/internal/controller/datadogmonitor/monitor_test.go
|
| 5 |
+
@@ -18,32 +18,17 @@ import (
|
| 6 |
+
"time"
|
| 7 |
+
|
| 8 |
+
"github.com/stretchr/testify/assert"
|
| 9 |
+
+ "k8s.io/utils/ptr"
|
| 10 |
+
|
| 11 |
+
datadogapi "github.com/DataDog/datadog-api-client-go/v2/api/datadog"
|
| 12 |
+
- datadogV1 "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
|
| 13 |
+
+ "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
|
| 14 |
+
+
|
| 15 |
+
datadoghqv1alpha1 "github.com/DataDog/datadog-operator/api/datadoghq/v1alpha1"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
const dateFormat = "2006-01-02 15:04:05.999999999 -0700 MST"
|
| 19 |
+
|
| 20 |
+
func Test_buildMonitor(t *testing.T) {
|
| 21 |
+
- evalDelay := int64(100)
|
| 22 |
+
- escalationMsg := "This is an escalation message"
|
| 23 |
+
- valTrue := true
|
| 24 |
+
- newGroupDelay := int64(400)
|
| 25 |
+
- noDataTimeframe := int64(15)
|
| 26 |
+
- renotifyInterval := int64(1440)
|
| 27 |
+
- renotifyOccurrences := int64(1)
|
| 28 |
+
- renotifyStatuses := []datadogV1.MonitorRenotifyStatusType{
|
| 29 |
+
- datadogV1.MONITORRENOTIFYSTATUSTYPE_ALERT,
|
| 30 |
+
- datadogV1.MONITORRENOTIFYSTATUSTYPE_WARN,
|
| 31 |
+
- }
|
| 32 |
+
-
|
| 33 |
+
- timeoutH := int64(2)
|
| 34 |
+
- critThreshold := "0.05"
|
| 35 |
+
- warnThreshold := "0.02"
|
| 36 |
+
- priority := int64(3)
|
| 37 |
+
-
|
| 38 |
+
dm := &datadoghqv1alpha1.DatadogMonitor{
|
| 39 |
+
Spec: datadoghqv1alpha1.DatadogMonitorSpec{
|
| 40 |
+
RestrictedRoles: []string{"an-admin-uuid"},
|
| 41 |
+
@@ -51,36 +36,46 @@ func Test_buildMonitor(t *testing.T) {
|
| 42 |
+
Type: "metric alert",
|
| 43 |
+
Name: "Test monitor",
|
| 44 |
+
Message: "Something went wrong",
|
| 45 |
+
- Priority: priority,
|
| 46 |
+
+ Priority: int64(3),
|
| 47 |
+
Tags: []string{
|
| 48 |
+
"env:staging",
|
| 49 |
+
"kube_namespace:test",
|
| 50 |
+
"kube_cluster:test.staging",
|
| 51 |
+
},
|
| 52 |
+
Options: datadoghqv1alpha1.DatadogMonitorOptions{
|
| 53 |
+
- EnableLogsSample: &valTrue,
|
| 54 |
+
- EvaluationDelay: &evalDelay,
|
| 55 |
+
- EscalationMessage: &escalationMsg,
|
| 56 |
+
- IncludeTags: &valTrue,
|
| 57 |
+
- GroupbySimpleMonitor: &valTrue,
|
| 58 |
+
- Locked: &valTrue,
|
| 59 |
+
- NewGroupDelay: &newGroupDelay,
|
| 60 |
+
- NoDataTimeframe: &noDataTimeframe,
|
| 61 |
+
+ EnableLogsSample: ptr.To(true),
|
| 62 |
+
+ EvaluationDelay: ptr.To(int64(100)),
|
| 63 |
+
+ EscalationMessage: ptr.To("This is an escalation message"),
|
| 64 |
+
+ IncludeTags: ptr.To(true),
|
| 65 |
+
+ GroupbySimpleMonitor: ptr.To(true),
|
| 66 |
+
+ Locked: ptr.To(true),
|
| 67 |
+
+ NewGroupDelay: ptr.To(int64(400)),
|
| 68 |
+
+ NoDataTimeframe: ptr.To(int64(15)),
|
| 69 |
+
NotificationPresetName: "show_all",
|
| 70 |
+
NotifyBy: []string{
|
| 71 |
+
"env",
|
| 72 |
+
"kube_namespace",
|
| 73 |
+
"kube_cluster",
|
| 74 |
+
},
|
| 75 |
+
- NotifyNoData: &valTrue,
|
| 76 |
+
+ NotifyNoData: ptr.To(true),
|
| 77 |
+
OnMissingData: "default",
|
| 78 |
+
- RenotifyOccurrences: &renotifyOccurrences,
|
| 79 |
+
- RenotifyInterval: &renotifyInterval,
|
| 80 |
+
- RenotifyStatuses: renotifyStatuses,
|
| 81 |
+
- TimeoutH: &timeoutH,
|
| 82 |
+
+ RenotifyOccurrences: ptr.To(int64(1)),
|
| 83 |
+
+ RenotifyInterval: ptr.To(int64(1440)),
|
| 84 |
+
+ RenotifyStatuses: []datadogV1.MonitorRenotifyStatusType{
|
| 85 |
+
+ datadogV1.MONITORRENOTIFYSTATUSTYPE_ALERT,
|
| 86 |
+
+ datadogV1.MONITORRENOTIFYSTATUSTYPE_WARN,
|
| 87 |
+
+ },
|
| 88 |
+
+ SchedulingOptions: &datadoghqv1alpha1.DatadogMonitorOptionsSchedulingOptions{
|
| 89 |
+
+ EvaluationWindow: &datadoghqv1alpha1.DatadogMonitorOptionsSchedulingOptionsEvaluationWindow{
|
| 90 |
+
+ DayStarts: ptr.To("01:00"),
|
| 91 |
+
+ HourStarts: ptr.To(int32(2)),
|
| 92 |
+
+ MonthStarts: ptr.To(int32(3)),
|
| 93 |
+
+ },
|
| 94 |
+
+ },
|
| 95 |
+
+ TimeoutH: ptr.To(int64(2)),
|
| 96 |
+
Thresholds: &datadoghqv1alpha1.DatadogMonitorOptionsThresholds{
|
| 97 |
+
- Critical: &critThreshold,
|
| 98 |
+
- Warning: &warnThreshold,
|
| 99 |
+
+ Critical: ptr.To("0.05"),
|
| 100 |
+
+ Warning: ptr.To("0.02"),
|
| 101 |
+
},
|
| 102 |
+
},
|
| 103 |
+
},
|
| 104 |
+
@@ -151,6 +146,15 @@ func Test_buildMonitor(t *testing.T) {
|
| 105 |
+
assert.Equal(t, dm.Spec.Options.RenotifyStatuses, monitor.Options.GetRenotifyStatuses(), "discrepancy found in parameter: RenotifyStatuses")
|
| 106 |
+
assert.Equal(t, dm.Spec.Options.RenotifyStatuses, monitorUR.Options.GetRenotifyStatuses(), "discrepancy found in parameter: RenotifyStatuses")
|
| 107 |
+
|
| 108 |
+
+ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.DayStarts, monitor.Options.SchedulingOptions.EvaluationWindow.GetDayStarts(), "discrepancy found in parameter: EvaluationWindow.DayStarts")
|
| 109 |
+
+ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.DayStarts, monitorUR.Options.SchedulingOptions.EvaluationWindow.GetDayStarts(), "discrepancy found in parameter: EvaluationWindow.DayStarts")
|
| 110 |
+
+
|
| 111 |
+
+ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.HourStarts, monitor.Options.SchedulingOptions.EvaluationWindow.GetHourStarts(), "discrepancy found in parameter: EvaluationWindow.HourStarts")
|
| 112 |
+
+ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.HourStarts, monitorUR.Options.SchedulingOptions.EvaluationWindow.GetHourStarts(), "discrepancy found in parameter: EvaluationWindow.HourStarts")
|
| 113 |
+
+
|
| 114 |
+
+ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.MonthStarts, monitor.Options.SchedulingOptions.EvaluationWindow.GetMonthStarts(), "discrepancy found in parameter: EvaluationWindow.MonthStarts")
|
| 115 |
+
+ assert.Equal(t, *dm.Spec.Options.SchedulingOptions.EvaluationWindow.MonthStarts, monitorUR.Options.SchedulingOptions.EvaluationWindow.GetMonthStarts(), "discrepancy found in parameter: EvaluationWindow.MonthStarts")
|
| 116 |
+
+
|
| 117 |
+
assert.Equal(t, *dm.Spec.Options.TimeoutH, monitor.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH")
|
| 118 |
+
assert.Equal(t, *dm.Spec.Options.TimeoutH, monitorUR.Options.GetTimeoutH(), "discrepancy found in parameter: TimeoutH")
|
| 119 |
+
|
| 120 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 121 |
+
new file mode 100644
|
| 122 |
+
--- /dev/null
|
| 123 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 124 |
+
@@ -0,0 +1,5 @@
|
| 125 |
+
+H4sIAAAAAAAAA+3STWrDMBAFYK1zirmArZ9G8SpHyK77oFgiMdgakMc5f2MX2lJos0koTd63mUES
|
| 126 |
+
+aMRTfZi6Pu5TPmt1L+ai8X6pF9/r0lvvrDPO+vVGGWt90yjyd5voi2mUUIhUYZbfzl3b/6fqz/wl
|
| 127 |
+
+jbJveRhCjvV4ut0d1/K3L/4jf+fm/Ncb4xWZ243wsyfPv420BH9IcXVkmluqzlS1PGXZWqp1lyWV
|
| 128 |
+
+HHrdcpbCfZ+KjkFC5OPAuRMumqoyZXqd/8/ynXbv66u/fhwAAAAAAAAAAAAAAAAAAAAAwIN7A7fv
|
| 129 |
+
+5lEAKAAA
|
| 130 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 131 |
+
new file mode 100755
|
| 132 |
+
--- /dev/null
|
| 133 |
+
+++ b/mimo_test_command.sh
|
| 134 |
+
@@ -0,0 +1,6 @@
|
| 135 |
+
+#!/usr/bin/env bash
|
| 136 |
+
+
|
| 137 |
+
+set -uo pipefail
|
| 138 |
+
+cd /testbed || exit 1
|
| 139 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 140 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000060/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
internal/controller/datadogmonitor/monitor_test.go
|
| 25 |
+
mimo_build_env.tar.gz.b64
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000060/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000067/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5987f5e3ecbdc9568af6bd08225a63fb8c4daba8bb466709a64be3a195ed15e6
|
tasks/format-code-task-000067/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|
tasks/format-code-task-000067/environment/setup/setup.sh
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into
|
| 3 |
+
# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
[ -f "$M/ready" ] && exit 0
|
| 6 |
+
chmod 700 "$M"
|
| 7 |
+
fail() { echo "setup: $*" >&2; exit 1; }
|
| 8 |
+
# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs
|
| 9 |
+
write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
|
| 10 |
+
|
| 11 |
+
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).
|
| 12 |
+
CWD=/testbed
|
| 13 |
+
git config --global --add safe.directory "$CWD"
|
| 14 |
+
cd "$CWD" || fail "no working directory $CWD"
|
| 15 |
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit
|
| 16 |
+
git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty
|
| 17 |
+
fi
|
| 18 |
+
BASE=$(git rev-parse HEAD 2>/dev/null)
|
| 19 |
+
[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"
|
| 20 |
+
echo "$BASE" > "$M/base"
|
| 21 |
+
# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,
|
| 22 |
+
# so .git is hidden while the agent works and put back for grading.
|
| 23 |
+
LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)
|
| 24 |
+
rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true
|
| 25 |
+
git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1
|
| 26 |
+
find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true
|
| 27 |
+
if [ "$LATER" -gt 0 ]; then
|
| 28 |
+
mv "$CWD/.git" "$M/git-hidden"
|
| 29 |
+
echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"
|
| 30 |
+
fi
|
| 31 |
+
write_blocklist
|
| 32 |
+
|
| 33 |
+
touch "$M/ready"
|
| 34 |
+
echo "setup done"
|
tasks/format-code-task-000067/tests/test.patch
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/directory/tests/test_directory.py b/directory/tests/test_directory.py
|
| 2 |
+
index 3b655e109394d..927eaccb4ce7c 100644
|
| 3 |
+
--- a/directory/tests/test_directory.py
|
| 4 |
+
+++ b/directory/tests/test_directory.py
|
| 5 |
+
@@ -331,29 +331,44 @@ def test_non_existent_directory_ignore_missing(aggregator):
|
| 6 |
+
aggregator.assert_service_check('system.disk.directory.exists', DirectoryCheck.WARNING, tags=expected_tags)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
-def test_os_error_mid_walk_emits_error_and_continues(aggregator, monkeypatch, caplog):
|
| 10 |
+
+def test_os_error_mid_walk_emits_error_and_continues(aggregator, caplog):
|
| 11 |
+
caplog.set_level(logging.WARNING)
|
| 12 |
+
|
| 13 |
+
- def mock_walk(folder, *args, **kwargs):
|
| 14 |
+
- from datadog_checks.directory.traverse import walk
|
| 15 |
+
-
|
| 16 |
+
- walker = walk(folder, *args, **kwargs)
|
| 17 |
+
- yield next(walker)
|
| 18 |
+
- raise OSError('Permission denied')
|
| 19 |
+
-
|
| 20 |
+
- monkeypatch.setattr('datadog_checks.directory.directory.walk', mock_walk)
|
| 21 |
+
+
|
| 22 |
+
+
|
| 23 |
+
+
|
| 24 |
+
+
|
| 25 |
+
+
|
| 26 |
+
+
|
| 27 |
+
+
|
| 28 |
+
+
|
| 29 |
+
+
|
| 30 |
+
+
|
| 31 |
+
|
| 32 |
+
with temp_directory() as tdir:
|
| 33 |
+
-
|
| 34 |
+
- # Create folder
|
| 35 |
+
- mkdir(os.path.join(tdir, 'a_folder'))
|
| 36 |
+
+
|
| 37 |
+
+ os.makedirs(os.path.join(tdir, 'bad_folder_a'), mode=0o377)
|
| 38 |
+
+ os.makedirs(os.path.join(tdir, 'bad_folder_b'), mode=0o377)
|
| 39 |
+
+
|
| 40 |
+
+ os.makedirs(os.path.join(tdir, 'ok'))
|
| 41 |
+
+ with open(os.path.join(tdir, 'ok', 'file'), 'w') as f:
|
| 42 |
+
+ f.write('')
|
| 43 |
+
|
| 44 |
+
# Run Check
|
| 45 |
+
instance = {'directory': tdir, 'recursive': True}
|
| 46 |
+
check = DirectoryCheck('directory', {}, [instance])
|
| 47 |
+
check.check(instance)
|
| 48 |
+
|
| 49 |
+
- assert 'Permission denied' in caplog.text
|
| 50 |
+
+
|
| 51 |
+
+ os.chmod(os.path.join(tdir, 'bad_folder_a'), 0o777)
|
| 52 |
+
+ os.chmod(os.path.join(tdir, 'bad_folder_b'), 0o777)
|
| 53 |
+
+
|
| 54 |
+
+ aggregator.assert_metric("system.disk.directory.files", count=1, value=1)
|
| 55 |
+
+
|
| 56 |
+
+ permission_denied_log_lines = [line for line in caplog.text.splitlines() if 'Permission denied' in line]
|
| 57 |
+
+ assert len(permission_denied_log_lines) == 2
|
| 58 |
+
+ assert 'bad_folder_a' in caplog.text
|
| 59 |
+
+ assert 'bad_folder_b' in caplog.text
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def test_no_recursive_symlink_loop(aggregator):
|
| 63 |
+
diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64
|
| 64 |
+
new file mode 100644
|
| 65 |
+
--- /dev/null
|
| 66 |
+
+++ b/mimo_build_env.tar.gz.b64
|
| 67 |
+
@@ -0,0 +1,9 @@
|
| 68 |
+
+H4sIAAAAAAAAA+2UzW7TQBDHffZTDKkUgSrbccDpjQvijvoC1np3QlbYu2Y/Qi3KuzPrKEkbCXpp
|
| 69 |
+
+hVDnd/Bas/O5/7XLLupetWj2VfZSrIibpplX4nKd3+tmXa9X9aZZr7NVXTc3TQbNi3X0gOiDcACZ
|
| 70 |
+
+szb8ze+p/f+U8qx/QB9aaYdBGFX63fPVeEL/un5fn/T/sCF7Tc9NBqvna+HPvHL9r95U0buq06ai
|
| 71 |
+
+OwCd8LvcY4ACo4VRj7gVus+lgvl6dKjy/Ao+ORQBIVmiRwd6C8YGED3Z1QSjQ48m5FpBEc9ey4+V
|
| 72 |
+
+wn1lYt/D/T0km1DkMpxcUu7PxkeHsE/daA9CSvRedz2Vs1TFFEmIOdjncjdYSnAL4trdnTqsyhSc
|
| 73 |
+
+b7VRFzYowjQiUAjeoYRD+Bz78xdcp+q30UDYHUaj4v7c/dtj7XfQoRRkOzm21rfonHXtoFX7Q/Tf
|
| 74 |
+
+Whx0OBrpc6LPygRtInqqkULA4feo6ZxAPB4qTfmVzn/xBd2gaXJrQKHRqBYwp/NAFgoMTsuAChRl
|
| 75 |
+
+kcE6jb7MfYTi3HLhYRY2iQqFhIW30Um8OJTZRcig90nT5RIeiF0ds09pY5zCjoqTYPSWhphP6fDf
|
| 76 |
+
+ODmW4wTFfpH/64vNMAzDMAzDMAzDMAzDMAzDMAzDMAzDMAzzSvgNIXRQMAAoAAA=
|
| 77 |
+
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
|
| 78 |
+
new file mode 100755
|
| 79 |
+
--- /dev/null
|
| 80 |
+
+++ b/mimo_test_command.sh
|
| 81 |
+
@@ -0,0 +1,6 @@
|
| 82 |
+
+#!/usr/bin/env bash
|
| 83 |
+
+
|
| 84 |
+
+set -uo pipefail
|
| 85 |
+
+cd /testbed || exit 1
|
| 86 |
+
+base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1
|
| 87 |
+
+exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'
|
tasks/format-code-task-000067/tests/test.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
|
| 3 |
+
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
|
| 4 |
+
M=/var/lib/mimo
|
| 5 |
+
CWD=/testbed
|
| 6 |
+
V=/logs/verifier
|
| 7 |
+
mkdir -p "$V"
|
| 8 |
+
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
|
| 9 |
+
cd "$CWD" || exit 1
|
| 10 |
+
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
|
| 11 |
+
# the agent's change against the base, so its own commits count too
|
| 12 |
+
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
|
| 13 |
+
git reset -q
|
| 14 |
+
if ! (
|
| 15 |
+
while IFS= read -r tf; do
|
| 16 |
+
[ -z "$tf" ] && continue
|
| 17 |
+
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
|
| 18 |
+
git checkout $BASE -- "$tf" 2>/dev/null || true
|
| 19 |
+
else
|
| 20 |
+
git rm -f --cached "$tf" >/dev/null 2>&1 || true
|
| 21 |
+
rm -f "$tf"
|
| 22 |
+
fi
|
| 23 |
+
done <<'EOF_RESET_TEST_FILES'
|
| 24 |
+
directory/tests/test_directory.py
|
| 25 |
+
mimo_build_env.tar.gz.b64
|
| 26 |
+
mimo_test_command.sh
|
| 27 |
+
EOF_RESET_TEST_FILES
|
| 28 |
+
|
| 29 |
+
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
|
| 30 |
+
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
|
| 31 |
+
cat "$V/apply.log" >&2
|
| 32 |
+
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
|
| 33 |
+
exit 1
|
| 34 |
+
fi
|
| 35 |
+
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
|
| 36 |
+
RC=$?
|
| 37 |
+
tail -c 12000 "$V/test_output.log"
|
| 38 |
+
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
|
| 39 |
+
echo "test command exited $RC"
|
tasks/format-code-task-000067/tests/test_command.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
bash /testbed/mimo_test_command.sh
|
tasks/format-code-task-000069/environment/Dockerfile
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The task's image, pinned by digest (the same as [environment].docker_image).
|
| 2 |
+
# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.
|
| 3 |
+
FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:25f55976fd5a55e4280cb4ec3c6e7273e7f58d066037d5282d9428d38cafa679
|
tasks/format-code-task-000069/environment/setup/files/blocklist
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# mimo answer-leak blocklist (mimoagent)
|
| 2 |
+
0.0.0.0 github.com
|
| 3 |
+
0.0.0.0 www.github.com
|
| 4 |
+
0.0.0.0 api.github.com
|
| 5 |
+
0.0.0.0 raw.githubusercontent.com
|
| 6 |
+
0.0.0.0 codeload.github.com
|
| 7 |
+
0.0.0.0 objects.githubusercontent.com
|
| 8 |
+
0.0.0.0 gist.github.com
|
| 9 |
+
0.0.0.0 gist.githubusercontent.com
|
| 10 |
+
0.0.0.0 gitlab.com
|
| 11 |
+
0.0.0.0 bitbucket.org
|
| 12 |
+
0.0.0.0 sourceforge.net
|
| 13 |
+
0.0.0.0 git.kernel.org
|
| 14 |
+
0.0.0.0 chromium.googlesource.com
|
| 15 |
+
0.0.0.0 android.googlesource.com
|
| 16 |
+
0.0.0.0 sourcegraph.com
|
| 17 |
+
0.0.0.0 bugs.chromium.org
|
| 18 |
+
0.0.0.0 issues.oss-fuzz.com
|
| 19 |
+
0.0.0.0 oss-fuzz.com
|
| 20 |
+
0.0.0.0 osv.dev
|
| 21 |
+
0.0.0.0 api.osv.dev
|
| 22 |
+
0.0.0.0 bugzilla.mozilla.org
|
| 23 |
+
0.0.0.0 proxy.golang.org
|
| 24 |
+
0.0.0.0 sum.golang.org
|
| 25 |
+
0.0.0.0 pkg.go.dev
|
| 26 |
+
0.0.0.0 google.com
|
| 27 |
+
0.0.0.0 www.google.com
|
| 28 |
+
0.0.0.0 bing.com
|
| 29 |
+
0.0.0.0 www.bing.com
|
| 30 |
+
0.0.0.0 duckduckgo.com
|
| 31 |
+
0.0.0.0 html.duckduckgo.com
|
| 32 |
+
0.0.0.0 search.brave.com
|
| 33 |
+
0.0.0.0 stackoverflow.com
|