Closed royragsdale closed 4 years ago
When attempting to create an build, the sdk does not return an err evenif the build fails. This causes the next step of attempting to extract artifacts to fail:
err
src: https://github.com/ArmyCyberInstitute/cmgr/blob/master/cmgr/docker.go#L130-L134
cmgr: [DEBUG: creating image ecb-1:f8a0ec358ae1b74474eb88020dacd3d7fbd8ba1aa13c5d10348ca72ecd658b52] cmgr: [ERROR: failed to create artifacts container: Error: No such image: ecb-1:f8a0ec358ae1b74474eb88020dacd3d7fbd8ba1aa13c5d10348ca72ecd658b52]
By reading the response.Body:
+ defer resp.Body.Close() + _, err = io.Copy(os.Stdout, resp.Body) + if err != nil { + log.Fatal(err, " :unable to read image build response") + } + */
you can see the last line has an error/errorDetail instead of a stream response:
{"errorDetail":{"code":1,"message":"The command '/bin/sh -c shell_manager install /app \u0026\u0026 shell_manager deploy all -c -i ${SEED} -f ${FLAG_FORMAT}' returned a non-zero code: 1"},"error":"The command '/bin/sh -c shell_manager install /app \u0026\u0026 shell_manager deploy all -c -i ${SEED} -f ${FLAG_FORMAT}' returned a non-zero code: 1"}
Full response:
cmgr: [DEBUG: creating image ecb-1:f8a0ec358ae1b74474eb88020dacd3d7fbd8ba1aa13c5d10348ca72ecd658b52] {"stream":"Step 1/8 : FROM aci/shellmanager"} {"stream":"\n"} {"stream":" ---\u003e 75c160870323\n"} {"stream":"Step 2/8 : COPY . /app"} {"stream":"\n"} {"stream":" ---\u003e 876697a3c14d\n"} {"stream":"Step 3/8 : ARG FLAG_FORMAT"} {"stream":"\n"} {"stream":" ---\u003e Running in bc29dc9d8c16\n"} {"stream":" ---\u003e e7354559b547\n"} {"stream":"Step 4/8 : ARG FLAG"} {"stream":"\n"} {"stream":" ---\u003e Running in 941a5cde6ffe\n"} {"stream":" ---\u003e bf628383969a\n"} {"stream":"Step 5/8 : ARG SEED"} {"stream":"\n"} {"stream":" ---\u003e Running in 4922fa6099d5\n"} {"stream":" ---\u003e 5eacf67bd705\n"} {"stream":"Step 6/8 : RUN shell_manager install /app \u0026\u0026 shell_manager deploy all -c -i ${SEED} -f ${FLAG_FORMAT}"} {"stream":"\n"} {"stream":" ---\u003e Running in 83100ec5a7da\n"} {"stream":"\u001b[91m17:08:38 hacksport.install INFO: Installing problem ecb-1-b06174a...\n\u001b[0m"} {"stream":"\u001b[91m17:08:43 hacksport.install INFO: ecb-1-b06174a installed successfully\n\u001b[0m"} {"stream":"\u001b[91m17:08:43 hacksport.deploy INFO: Deploying with custom flag format: flag{%s}\n\u001b[0m"} {"stream":"\u001b[91mTraceback (most recent call last):\n File \"/usr/local/bin/shell_manager\", line 11, in \u003cmodule\u003e\n load_entry_point('ctf-shell-manager==1.2.1', 'console_scripts', 'shell_manager')()\n File \"/picoCTF-env/lib/python3.7/site-packages/shell_manager/run.py\", line 279, in main\n args.func(args)\n File \"/picoCTF-env/lib/python3.7/site-packages/hacksport/deploy.py\", line 1073, in deploy_problems\n containerize=args.containerize\n File \"/picoCTF-env/lib/python3.7/site-packages/hacksport/deploy.py\", line 853, in deploy_problem\n deployment_directory=deployment_directory,\n File \"/picoCTF-env/lib/python3.7/site-packages/hacksport/deploy.py\", line 660, in generate_instance\n problem.flag = problem.generate_flag(Random(seed))\n File \"/opt/hacksports/shared/staging/ECB 1_42_5146271601474774/problem_files/challenge.py\", line 26, in generate_flag\n flag[32] = \"}\"\nTypeError: 'str' object does not support item assignment\n\u001b[0m"} {"errorDetail":{"code":1,"message":"The command '/bin/sh -c shell_manager install /app \u0026\u0026 shell_manager deploy all -c -i ${SEED} -f ${FLAG_FORMAT}' returned a non-zero code: 1"},"error":"The command '/bin/sh -c shell_manager install /app \u0026\u0026 shell_manager deploy all -c -i ${SEED} -f ${FLAG_FORMAT}' returned a non-zero code: 1"} cmgr: [ERROR: failed to create artifacts container: Error: No such image: ecb-1:f8a0ec358ae1b74474eb88020dacd3d7fbd8ba1aa13c5d10348ca72ecd658b52]
Fixed in ed0dc68d95fe56cd66f09b2e46344b26e866a071
When attempting to create an build, the sdk does not return an
err
evenif the build fails. This causes the next step of attempting to extract artifacts to fail:src: https://github.com/ArmyCyberInstitute/cmgr/blob/master/cmgr/docker.go#L130-L134
By reading the response.Body:
you can see the last line has an error/errorDetail instead of a stream response:
Full response: