feat(clients): sessions+registry+optimize+armor: close gaps, loud list truncation, shared Gemini adapter
sessions: operations get/list/cancel/delete/wait for engine, session, memory and serving profile; servingProfiles CRUD. registry: ListResult with truncated flag, v1alpha twins, gateway/policy operations, authz IAM, deny policy update, boundary patch/bindings. optimize: make_gemini_model over models::VertexModel (DirectModel removed), generateSyntheticData, online evaluator operations, trace/log writers. armor: SecurityAdmin for all SCC v2 methods (attack exposure excluded), documented agent threat categories, floor settings fixed to location global after live run. check_discovery.py of all four enforce coverage. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
// Routes: GET /agent/armor/categories (no credential) and the Security
|
||||
// Command Center administration routes under /agent/armor/scc. Without a
|
||||
// credential a valid request answers 503 google_not_configured; bad input is
|
||||
// 422 before any traffic; a wrong verb is 405. Google replies are not scripted.
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "support/GoogleRig.hpp"
|
||||
|
||||
using namespace molo::example::test;
|
||||
using molo::example::fw::Method;
|
||||
|
||||
int main() {
|
||||
setenv("GOOGLE_CLOUD_PROJECT", "demo-project", 1);
|
||||
const std::string json = "application/json";
|
||||
const std::string finding = "organizations/1/sources/2/findings/f1";
|
||||
struct Route {
|
||||
std::string path, valid, invalid;
|
||||
};
|
||||
const std::vector<Route> routes = {
|
||||
{"/agent/armor/scc/availability", "{\"scope\":\"projects/demo-project\"}",
|
||||
"{\"scope\":\"projects/demo-project/locations/global\"}"},
|
||||
{"/agent/armor/scc/configs/list",
|
||||
"{\"kind\":\"muteConfigs\",\"parent\":\"projects/demo-project/locations/global\"}",
|
||||
"{\"kind\":\"widgets\",\"parent\":\"projects/demo-project\"}"},
|
||||
{"/agent/armor/scc/configs/get",
|
||||
"{\"kind\":\"muteConfigs\",\"name\":\"projects/demo-project/muteConfigs/m1\"}",
|
||||
"{\"kind\":\"muteConfigs\",\"name\":\"projects/demo-project\"}"},
|
||||
{"/agent/armor/scc/finding/state", "{\"finding\":\"" + finding + "\",\"state\":\"INACTIVE\"}",
|
||||
"{\"finding\":\"" + finding + "\",\"state\":\"MAYBE\"}"},
|
||||
{"/agent/armor/scc/finding/mute", "{\"finding\":\"" + finding + "\",\"mute\":\"MUTED\"}",
|
||||
"{\"finding\":\"organizations/1/sources/2\",\"mute\":\"MUTED\"}"},
|
||||
{"/agent/armor/scc/bulk-mute",
|
||||
"{\"parent\":\"projects/demo-project\",\"filter\":\"severity=\\\"LOW\\\"\",\"value\":\"MUTED\","
|
||||
"\"confirm\":\"bulk-mute\"}",
|
||||
"{\"parent\":\"projects/demo-project\",\"filter\":\"\",\"value\":\"MUTED\",\"confirm\":\"bulk-mute\"}"},
|
||||
{"/agent/armor/scc/operations/list", "{\"organization\":\"organizations/1\"}",
|
||||
"{\"organization\":\"projects/demo-project\"}"},
|
||||
};
|
||||
{
|
||||
GoogleRig rig(false);
|
||||
Fixture f(rig.client);
|
||||
for (const auto& r : routes) {
|
||||
auto res = f.client->post(r.path, r.valid, json);
|
||||
check(res.status == 503 && contains(res.body, "google_not_configured"),
|
||||
"503 google_not_configured: " + r.path);
|
||||
}
|
||||
auto del = f.client->request(Method::Delete,
|
||||
"/agent/armor/scc/configs?kind=muteConfigs&name=projects/demo-project/muteConfigs/m1");
|
||||
check(del.status == 503 && contains(del.body, "google_not_configured"), "delete config: 503 without a credential");
|
||||
check(rig.mock->send_count() == 0, "no upstream traffic without a credential");
|
||||
}
|
||||
{
|
||||
GoogleRig rig;
|
||||
Fixture f(rig.client);
|
||||
for (const auto& r : routes) {
|
||||
auto res = f.client->post(r.path, r.invalid, json);
|
||||
check(res.status == 422 && contains(res.body, "validation_error"), "422 on bad input: " + r.path);
|
||||
check(f.client->get(r.path).status == 405, "get is 405: " + r.path);
|
||||
}
|
||||
// Limit and guard cases.
|
||||
check(f.client->post("/agent/armor/scc/bulk-mute",
|
||||
"{\"parent\":\"projects/demo-project\",\"filter\":\"x\",\"value\":\"MUTED\"}", json)
|
||||
.status == 422,
|
||||
"bulk mute without confirm is 422");
|
||||
check(f.client->post("/agent/armor/scc/bulk-mute",
|
||||
"{\"parent\":\"projects/demo-project\",\"filter\":\"x\",\"value\":\"UNMUTED\","
|
||||
"\"confirm\":\"bulk-mute\"}", json).status == 422,
|
||||
"bulk mute value UNMUTED is not allowed (422)");
|
||||
check(f.client->request(Method::Delete, "/agent/armor/scc/configs?kind=x&name=y").status == 422,
|
||||
"delete config: unknown kind is 422");
|
||||
check(f.client->request(Method::Delete,
|
||||
"/agent/armor/scc/configs?kind=muteConfigs&name=projects/demo-project").status == 422,
|
||||
"delete config: a parent is not a config name (422)");
|
||||
check(f.client->post("/agent/armor/scc/configs").status == 405, "post on the delete route is 405");
|
||||
check(f.client->post("/agent/armor/findings", "{\"scope\":\"projects/demo-project\",\"family\":\"bogus\"}",
|
||||
json).status == 422,
|
||||
"findings: unknown family is 422");
|
||||
check(rig.mock->send_count() == 0, "side effect: rejected before any upstream call");
|
||||
}
|
||||
{
|
||||
// The category table needs no credential and never calls Google.
|
||||
GoogleRig rig(false);
|
||||
Fixture f(rig.client);
|
||||
auto res = f.client->get("/agent/armor/categories");
|
||||
check(res.status == 200 && contains(res.headers.get("Content-Type"), "application/json"), "categories 200 json");
|
||||
check(contains(res.body, "Execution: Container Escape") && contains(res.body, "AGENT_ENGINE_CONTAINER_ESCAPE"),
|
||||
"lists a documented runtime category and its module");
|
||||
check(contains(res.body, "AGENT_ENGINE_REVERSE_SHELL") && contains(res.body, "control_plane"),
|
||||
"lists both families");
|
||||
check(contains(res.body, "agentAnomaly"), "says how anomaly findings are recognised");
|
||||
check(f.client->post("/agent/armor/categories").status == 405, "post is 405");
|
||||
check(rig.mock->send_count() == 0, "side effect: GET never calls Google");
|
||||
}
|
||||
return finish("agent/armor/scc");
|
||||
}
|
||||
Reference in New Issue
Block a user