feat(doos): add container runtime, audit cases, example demo and tests
- New rootless doos container runtime: sandbox, cgroup, network, images, hardening, davmount, CLI plus molo integration - 18 CVE audit reproductions with READMEs and Makefiles - Example DoosDemo routes, IndexCatalog, static assets, spec update - CLI serve on 0.0.0.0:8000, arg parser, dev server improvements - Runtime HTTP fixes, supervisor isolation backend - Tests for doos, example doos routes, CLI serve; suite count 261 to 265
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Route: POST /doos/create (idempotent create with options)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("create");
|
||||
Fixture f;
|
||||
auto first = f.client->post("/doos/create", "name=app1&size=1g",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(first.status == 200, "status 200");
|
||||
check(contains(first.body, "\"created\":true"), "first create reports created");
|
||||
auto again = f.client->post("/doos/create", "name=app1", "application/x-www-form-urlencoded");
|
||||
check(contains(again.body, "\"created\":false"), "second create is idempotent");
|
||||
auto noname = f.client->post("/doos/create", "size=1g", "application/x-www-form-urlencoded");
|
||||
check(noname.status == 422, "missing name rejected");
|
||||
auto badname = f.client->post("/doos/create", "name=Bad+Name",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(badname.status == 422, "bad name rejected");
|
||||
auto badsize = f.client->post("/doos/create", "name=app2&size=1x",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(badsize.status == 422, "bad size rejected");
|
||||
auto badnet = f.client->post("/doos/create", "name=app2&net=bogus",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(badnet.status == 422, "bad net rejected");
|
||||
auto multi = f.client->post("/doos/create", "size=1x&net=bogus",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(multi.status == 422, "multi-failure is 422");
|
||||
check(contains(multi.body, "name is required"), "all failures listed (name)");
|
||||
check(contains(multi.body, "invalid size"), "all failures listed (size)");
|
||||
return finish("doos/create");
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Route: POST /doos/delete (dry run unless confirm=yes)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("delete");
|
||||
Fixture f;
|
||||
auto made = f.client->post("/doos/create", "name=temp1", "application/x-www-form-urlencoded");
|
||||
check(made.status == 200, "create 200");
|
||||
auto dry = f.client->post("/doos/delete", "name=temp1", "application/x-www-form-urlencoded");
|
||||
check(dry.status == 200, "dry run 200");
|
||||
check(contains(dry.body, "\"dry_run\":true"), "dry run without confirm");
|
||||
check(contains(dry.body, "dry run"), "report text");
|
||||
auto still = f.client->get("/doos/status");
|
||||
check(contains(still.body, "\"name\":\"temp1\""), "dry run deletes nothing");
|
||||
auto gone = f.client->post("/doos/delete", "name=temp1&confirm=yes",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(contains(gone.body, "\"dry_run\":false"), "confirm deletes");
|
||||
auto after = f.client->get("/doos/status");
|
||||
check(!contains(after.body, "\"name\":\"temp1\""), "container gone after confirm");
|
||||
auto missing = f.client->post("/doos/delete", "name=temp1&confirm=yes",
|
||||
"application/x-www-form-urlencoded");
|
||||
check(missing.status == 404, "missing container is 404");
|
||||
auto noname = f.client->post("/doos/delete", "confirm=yes", "application/x-www-form-urlencoded");
|
||||
check(noname.status == 422, "missing name rejected");
|
||||
return finish("doos/delete");
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Route: GET /doos (sandboxed containers page)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("page");
|
||||
Fixture f;
|
||||
auto res = f.client->get("/doos");
|
||||
check(res.status == 200, "status 200");
|
||||
check(contains(res.body, "Sandboxed containers"), "heading");
|
||||
check(contains(res.body, "0 containers"), "empty demo store");
|
||||
auto made = f.client->post("/doos/create", "name=web1", "application/x-www-form-urlencoded");
|
||||
check(made.status == 200, "create 200");
|
||||
auto again = f.client->get("/doos");
|
||||
check(contains(again.body, "1 containers"), "count follows creates");
|
||||
check(contains(again.body, "web1"), "row names the container");
|
||||
return finish("doos/page");
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Route: GET /doos/status (containers, images, davmounts, version)
|
||||
#include "support/Assert.hpp"
|
||||
#include "support/DoosHome.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
|
||||
int main() {
|
||||
ScratchDoosHome home("status");
|
||||
Fixture f;
|
||||
auto res = f.client->get("/doos/status");
|
||||
check(res.status == 200, "status 200");
|
||||
check(contains(res.body, "\"containers\":[]"), "no containers yet");
|
||||
check(contains(res.body, "\"davmounts\":[]"), "no davmounts yet");
|
||||
check(contains(res.body, "\"version\":\"1.6.0\""), "libdoos version");
|
||||
check(contains(res.body, "\"name\":\"alpine\""), "catalog lists alpine");
|
||||
auto made = f.client->post("/doos/create", "name=db1", "application/x-www-form-urlencoded");
|
||||
check(made.status == 200, "create 200");
|
||||
auto after = f.client->get("/doos/status");
|
||||
check(contains(after.body, "\"name\":\"db1\""), "status shows the container");
|
||||
return finish("doos/status");
|
||||
}
|
||||
@@ -13,6 +13,14 @@ int main() {
|
||||
check(contains(res.body, "/routing/hello/world"), "matrix links a route");
|
||||
check(contains(res.body, "viewport"), "responsive viewport meta");
|
||||
check(contains(res.body, "nav-narrow"), "narrow nav dropdown present");
|
||||
check(contains(res.body, "id=\"g-routing\""), "routing group section");
|
||||
check(contains(res.body, "id=\"g-vendors\""), "vendor group section");
|
||||
check(contains(res.body, "needs API key"), "key badge on credentialed groups");
|
||||
check(contains(res.body, "id=\"filter\""), "filter box");
|
||||
check(contains(res.body, "<a href=\"/routing/hello/world\">Routing</a>"),
|
||||
"row shows a readable name linking the route");
|
||||
check(contains(res.body, "<a href=\"/ai/openai\">AI OpenAI</a>"), "acronyms prettified");
|
||||
check(!contains(res.body, "g-other"), "every registered route is grouped");
|
||||
check(res.headers.has("X-Request-ID"), "request id middleware ran");
|
||||
return finish("index");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
// Scratch DOOS_HOME for the /doos route tests: a unique dir under the system
|
||||
// temp root (the example suite points TMPDIR at build/example/tmp), exported
|
||||
// before the Fixture builds the app, removed on teardown.
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
|
||||
namespace molo::example::test {
|
||||
|
||||
struct ScratchDoosHome {
|
||||
std::filesystem::path dir;
|
||||
explicit ScratchDoosHome(const std::string& tag) {
|
||||
static int seq = 0;
|
||||
dir = std::filesystem::temp_directory_path() /
|
||||
("molo-doos-route-" + tag + "-" + std::to_string(::getpid()) + "-" +
|
||||
std::to_string(seq++));
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(dir, ec);
|
||||
std::filesystem::create_directories(dir, ec);
|
||||
::setenv("DOOS_HOME", dir.c_str(), 1);
|
||||
}
|
||||
~ScratchDoosHome() {
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(dir, ec);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace molo::example::test
|
||||
Reference in New Issue
Block a user