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:
@@ -9,12 +9,14 @@
|
||||
#include "../../fw/Templates.hpp"
|
||||
#include "../../fw/Validate.hpp"
|
||||
#include "clients/body/json.h"
|
||||
#include "google/armor/agent_categories.h"
|
||||
#include "google/armor/armor_util.h"
|
||||
#include "google/armor/caps.h"
|
||||
#include "google/armor/dashboard.h"
|
||||
#include "google/armor/findings.h"
|
||||
#include "google/armor/guarded_model.h"
|
||||
#include "google/armor/model_armor.h"
|
||||
#include "google/armor/security_admin.h"
|
||||
#include "google/credentials.h"
|
||||
#include "google/endpoints.h"
|
||||
|
||||
@@ -157,6 +159,8 @@ OAuth access token, not an API key.</p>
|
||||
<option value="floor/get">Floor settings</option>
|
||||
<option value="findings">Agent findings</option>
|
||||
<option value="dashboard">Security summary</option>
|
||||
<option value="scc/availability">Security Command Center status</option>
|
||||
<option value="scc/configs/list">List SCC configs</option>
|
||||
</select></label>
|
||||
<label>Template id <input id="a-template" type="text" maxlength="128" placeholder="my-template"></label>
|
||||
<label>Text <textarea id="a-text" rows="4" maxlength="4000" placeholder="Text to check"></textarea></label>
|
||||
@@ -164,6 +168,12 @@ OAuth access token, not an API key.</p>
|
||||
<label>Severity
|
||||
<select id="a-severity"><option value="">any</option><option>CRITICAL</option>
|
||||
<option>HIGH</option><option>MEDIUM</option><option>LOW</option></select></label>
|
||||
<label>Agent threat category family
|
||||
<select id="a-family"><option value="">any category</option><option value="agent">all agent categories</option>
|
||||
<option value="runtime">runtime</option><option value="control_plane">control plane</option></select></label>
|
||||
<label>SCC config kind
|
||||
<select id="a-kind"><option>muteConfigs</option><option>notificationConfigs</option>
|
||||
<option>bigQueryExports</option></select></label>
|
||||
<button id="a-run" type="button" class="primary">Run</button>
|
||||
<p id="a-error" class="error" role="alert"></p>
|
||||
<pre id="a-out" class="out"></pre>
|
||||
@@ -354,6 +364,12 @@ void register_agent_armor_demo(fw::Router& router, Services& services) {
|
||||
q.severity = field(in, "severity");
|
||||
q.state = field(in, "state");
|
||||
if (!field(in, "category").empty()) q.categories = {field(in, "category")};
|
||||
// family selects the documented Agent Platform Threat Detection categories.
|
||||
std::string family = field(in, "family");
|
||||
if (family == "runtime") q.categories = armor::AgentCategories::strings(armor::AgentFamily::kRuntime);
|
||||
else if (family == "control_plane") q.categories = armor::AgentCategories::strings(armor::AgentFamily::kControlPlane);
|
||||
else if (family == "agent") q.categories = armor::AgentCategories::strings();
|
||||
else if (!family.empty()) bad("family must be runtime, control_plane or agent");
|
||||
q.order_by = field(in, "order_by");
|
||||
q.page_size = int_field(in, "page_size", 0, armor::ArmorCaps::kMaxFindingsPageSize);
|
||||
q.max_pages = static_cast<std::size_t>(int_field(in, "max_pages", 1, armor::ArmorCaps::kMaxFindingPages));
|
||||
@@ -378,6 +394,8 @@ void register_agent_armor_demo(fw::Router& router, Services& services) {
|
||||
Json o = Json::object();
|
||||
o.set("findings", items);
|
||||
o.set("truncated", page.truncated);
|
||||
o.set("count", static_cast<long>(page.findings.size()));
|
||||
o.set("cap_findings", static_cast<long>(armor::ArmorCaps::kMaxFindings));
|
||||
o.set("total_size", static_cast<long>(page.total_size));
|
||||
return json_out(o);
|
||||
});
|
||||
@@ -393,6 +411,126 @@ void register_agent_armor_demo(fw::Router& router, Services& services) {
|
||||
return json_out(dash.summarize(q).to_json());
|
||||
});
|
||||
});
|
||||
|
||||
// ---- Documented Agent Threat Detection categories (no credential needed).
|
||||
router.get("/agent/armor/categories", "agent-armor-categories", [](fw::Request req) {
|
||||
(void)req;
|
||||
Json arr = Json::array();
|
||||
for (const armor::AgentCategory& c : armor::AgentCategories::all()) {
|
||||
Json o = Json::object();
|
||||
o.set("category", c.category);
|
||||
o.set("alt", c.alt);
|
||||
o.set("module", c.module);
|
||||
o.set("family", c.family == armor::AgentFamily::kRuntime ? "runtime" : "control_plane");
|
||||
arr.push(o);
|
||||
}
|
||||
Json o = Json::object();
|
||||
o.set("count", static_cast<long>(arr.as_array().size()));
|
||||
o.set("anomaly_detection", "no documented category string; recognised by the agentAnomaly member");
|
||||
o.set("categories", arr);
|
||||
return json_out(o);
|
||||
});
|
||||
|
||||
// ---- Security Command Center administration (SecurityAdmin).
|
||||
auto kind_of = [](const Form& in) {
|
||||
std::string k = field(in, "kind");
|
||||
if (k == "muteConfigs") return armor::SccCollection::kMuteConfigs;
|
||||
if (k == "notificationConfigs") return armor::SccCollection::kNotificationConfigs;
|
||||
if (k == "bigQueryExports") return armor::SccCollection::kBigQueryExports;
|
||||
bad("kind must be muteConfigs, notificationConfigs or bigQueryExports");
|
||||
};
|
||||
|
||||
router.post("/agent/armor/scc/availability", "agent-armor-scc-availability", [client](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
std::string scope = field(in, "scope");
|
||||
if (scope.empty()) {
|
||||
google::CloudContext ctx = google::CloudContext::from_env();
|
||||
if (!ctx.project.empty()) scope = "projects/" + ctx.project;
|
||||
}
|
||||
return guarded([&] {
|
||||
Json o = Json::object();
|
||||
o.set("scope", scope);
|
||||
o.set("state", armor::availability_name(armor::SecurityAdmin(client).availability(scope)));
|
||||
return json_out(o);
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/agent/armor/scc/configs/list", "agent-armor-scc-configs-list", [client, kind_of](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
armor::SccCollection kind = kind_of(in);
|
||||
std::string parent = field(in, "parent");
|
||||
return guarded([&] { return json_out(armor::SecurityAdmin(client).list_configs(kind, parent).to_json()); });
|
||||
});
|
||||
|
||||
router.post("/agent/armor/scc/configs/get", "agent-armor-scc-configs-get", [client, kind_of](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
armor::SccCollection kind = kind_of(in);
|
||||
std::string name = field(in, "name");
|
||||
return guarded([&] { return json_out(armor::SecurityAdmin(client).get_config(kind, name)); });
|
||||
});
|
||||
|
||||
// Destructive and explicit: one config, DELETE only.
|
||||
router.del("/agent/armor/scc/configs", "agent-armor-scc-configs-delete", [client](fw::Request req) {
|
||||
Form in = {{"kind", req.query_or("kind", "")}};
|
||||
armor::SccCollection kind;
|
||||
if (in["kind"] == "muteConfigs") kind = armor::SccCollection::kMuteConfigs;
|
||||
else if (in["kind"] == "notificationConfigs") kind = armor::SccCollection::kNotificationConfigs;
|
||||
else if (in["kind"] == "bigQueryExports") kind = armor::SccCollection::kBigQueryExports;
|
||||
else bad("kind must be muteConfigs, notificationConfigs or bigQueryExports");
|
||||
std::string name = req.query_or("name", "");
|
||||
return guarded([&] {
|
||||
armor::SecurityAdmin(client).delete_config(kind, name);
|
||||
Json o = Json::object();
|
||||
o.set("deleted", true);
|
||||
return json_out(o);
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/agent/armor/scc/finding/state", "agent-armor-scc-finding-state", [client](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
std::string state = field(in, "state");
|
||||
if (state != "ACTIVE" && state != "INACTIVE") bad("state must be ACTIVE or INACTIVE");
|
||||
std::string finding = field(in, "finding");
|
||||
return guarded([&] {
|
||||
return json_out(armor::SecurityAdmin(client).set_finding_state(
|
||||
finding, state == "ACTIVE" ? armor::FindingState::kActive : armor::FindingState::kInactive));
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/agent/armor/scc/finding/mute", "agent-armor-scc-finding-mute", [client](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
std::string mute = field(in, "mute");
|
||||
if (mute != "MUTED" && mute != "UNMUTED" && mute != "UNDEFINED") bad("mute must be MUTED, UNMUTED or UNDEFINED");
|
||||
std::string finding = field(in, "finding");
|
||||
return guarded([&] {
|
||||
return json_out(armor::SecurityAdmin(client).set_finding_mute(
|
||||
finding, mute == "MUTED" ? armor::MuteValue::kMuted
|
||||
: mute == "UNMUTED" ? armor::MuteValue::kUnmuted : armor::MuteValue::kUndefined));
|
||||
});
|
||||
});
|
||||
|
||||
// Mass change: needs a filter and confirm=bulk-mute.
|
||||
router.post("/agent/armor/scc/bulk-mute", "agent-armor-scc-bulk-mute", [client](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
if (field(in, "confirm") != "bulk-mute") bad("confirm must be bulk-mute");
|
||||
std::string value = field(in, "value");
|
||||
if (value != "MUTED" && value != "UNDEFINED") bad("value must be MUTED or UNDEFINED");
|
||||
std::string parent = field(in, "parent"), filter = field(in, "filter");
|
||||
return guarded([&] {
|
||||
google::Operation op = armor::SecurityAdmin(client).bulk_mute(
|
||||
parent, filter, value == "MUTED" ? armor::BulkMuteValue::kMuted : armor::BulkMuteValue::kUndefined);
|
||||
Json o = Json::object();
|
||||
o.set("operation", op.name);
|
||||
o.set("done", op.done);
|
||||
return json_out(o);
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/agent/armor/scc/operations/list", "agent-armor-scc-operations", [client](fw::Request req) {
|
||||
Form in = fw::parse_json_object_flat(req.body);
|
||||
std::string org = field(in, "organization");
|
||||
return guarded([&] { return json_out(armor::SecurityAdmin(client).list_operations(org).to_json()); });
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace molo::example::app
|
||||
|
||||
Reference in New Issue
Block a user