harness-mcp-v2 3.2.34 → 3.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -14
- package/build/client/harness-client.d.ts.map +1 -1
- package/build/client/harness-client.js +69 -11
- package/build/client/harness-client.js.map +1 -1
- package/build/config.d.ts +81 -2
- package/build/config.d.ts.map +1 -1
- package/build/config.js +132 -15
- package/build/config.js.map +1 -1
- package/build/data/schemas/v0/pipeline.d.ts.map +1 -1
- package/build/data/schemas/v0/pipeline.js +14861 -14726
- package/build/data/schemas/v0/pipeline.js.map +1 -1
- package/build/data/schemas/v0/template.d.ts.map +1 -1
- package/build/data/schemas/v0/template.js +6977 -6851
- package/build/data/schemas/v0/template.js.map +1 -1
- package/build/data/schemas/v1/pipeline.d.ts.map +1 -1
- package/build/data/schemas/v1/pipeline.js +261 -62
- package/build/data/schemas/v1/pipeline.js.map +1 -1
- package/build/data/schemas/v1/template.d.ts.map +1 -1
- package/build/data/schemas/v1/template.js +261 -62
- package/build/data/schemas/v1/template.js.map +1 -1
- package/build/index.js +25 -7
- package/build/index.js.map +1 -1
- package/build/prompts/run-evaluation.d.ts.map +1 -1
- package/build/prompts/run-evaluation.js +2 -1
- package/build/prompts/run-evaluation.js.map +1 -1
- package/build/registry/extractors.d.ts +32 -0
- package/build/registry/extractors.d.ts.map +1 -1
- package/build/registry/extractors.js +69 -0
- package/build/registry/extractors.js.map +1 -1
- package/build/registry/index.d.ts +23 -3
- package/build/registry/index.d.ts.map +1 -1
- package/build/registry/index.js +119 -6
- package/build/registry/index.js.map +1 -1
- package/build/registry/toolsets/ai-evals.d.ts.map +1 -1
- package/build/registry/toolsets/ai-evals.js +348 -100
- package/build/registry/toolsets/ai-evals.js.map +1 -1
- package/build/registry/toolsets/ccm-cost-category.d.ts +16 -0
- package/build/registry/toolsets/ccm-cost-category.d.ts.map +1 -0
- package/build/registry/toolsets/ccm-cost-category.js +46 -0
- package/build/registry/toolsets/ccm-cost-category.js.map +1 -0
- package/build/registry/toolsets/ccm.d.ts.map +1 -1
- package/build/registry/toolsets/ccm.js +15 -14
- package/build/registry/toolsets/ccm.js.map +1 -1
- package/build/registry/toolsets/chaos-descriptions.d.ts +48 -15
- package/build/registry/toolsets/chaos-descriptions.d.ts.map +1 -1
- package/build/registry/toolsets/chaos-descriptions.js +60 -20
- package/build/registry/toolsets/chaos-descriptions.js.map +1 -1
- package/build/registry/toolsets/chaos.d.ts.map +1 -1
- package/build/registry/toolsets/chaos.js +409 -41
- package/build/registry/toolsets/chaos.js.map +1 -1
- package/build/registry/toolsets/connectors.js +3 -3
- package/build/registry/toolsets/connectors.js.map +1 -1
- package/build/registry/toolsets/registries-v3.d.ts.map +1 -1
- package/build/registry/toolsets/registries-v3.js +80 -2
- package/build/registry/toolsets/registries-v3.js.map +1 -1
- package/build/tools/field-copy.d.ts +51 -0
- package/build/tools/field-copy.d.ts.map +1 -0
- package/build/tools/field-copy.js +46 -0
- package/build/tools/field-copy.js.map +1 -0
- package/build/tools/harness-create.d.ts.map +1 -1
- package/build/tools/harness-create.js +13 -10
- package/build/tools/harness-create.js.map +1 -1
- package/build/tools/harness-delete.d.ts.map +1 -1
- package/build/tools/harness-delete.js +12 -9
- package/build/tools/harness-delete.js.map +1 -1
- package/build/tools/harness-describe.d.ts.map +1 -1
- package/build/tools/harness-describe.js +14 -6
- package/build/tools/harness-describe.js.map +1 -1
- package/build/tools/harness-diagnose.d.ts.map +1 -1
- package/build/tools/harness-diagnose.js +9 -6
- package/build/tools/harness-diagnose.js.map +1 -1
- package/build/tools/harness-execute.d.ts.map +1 -1
- package/build/tools/harness-execute.js +19 -14
- package/build/tools/harness-execute.js.map +1 -1
- package/build/tools/harness-get.d.ts.map +1 -1
- package/build/tools/harness-get.js +10 -8
- package/build/tools/harness-get.js.map +1 -1
- package/build/tools/harness-list.d.ts.map +1 -1
- package/build/tools/harness-list.js +10 -8
- package/build/tools/harness-list.js.map +1 -1
- package/build/tools/harness-schema.d.ts.map +1 -1
- package/build/tools/harness-schema.js +5 -3
- package/build/tools/harness-schema.js.map +1 -1
- package/build/tools/harness-search.d.ts.map +1 -1
- package/build/tools/harness-search.js +10 -8
- package/build/tools/harness-search.js.map +1 -1
- package/build/tools/harness-status.js +4 -4
- package/build/tools/harness-status.js.map +1 -1
- package/build/tools/harness-update.d.ts.map +1 -1
- package/build/tools/harness-update.js +12 -9
- package/build/tools/harness-update.js.map +1 -1
- package/build/tools/input-schemas.d.ts +16 -5
- package/build/tools/input-schemas.d.ts.map +1 -1
- package/build/tools/input-schemas.js +32 -11
- package/build/tools/input-schemas.js.map +1 -1
- package/build/tools/output-schemas.d.ts +8 -0
- package/build/tools/output-schemas.d.ts.map +1 -1
- package/build/tools/output-schemas.js +10 -0
- package/build/tools/output-schemas.js.map +1 -1
- package/build/utils/canonical-resource-type.d.ts +7 -0
- package/build/utils/canonical-resource-type.d.ts.map +1 -0
- package/build/utils/canonical-resource-type.js +16 -0
- package/build/utils/canonical-resource-type.js.map +1 -0
- package/build/utils/http-auth.d.ts +2 -1
- package/build/utils/http-auth.d.ts.map +1 -1
- package/build/utils/http-auth.js +10 -2
- package/build/utils/http-auth.js.map +1 -1
- package/build/utils/oauth-auth.d.ts +1 -0
- package/build/utils/oauth-auth.d.ts.map +1 -1
- package/build/utils/oauth-auth.js +5 -0
- package/build/utils/oauth-auth.js.map +1 -1
- package/build/utils/oauth-broker.d.ts +25 -0
- package/build/utils/oauth-broker.d.ts.map +1 -0
- package/build/utils/oauth-broker.js +606 -0
- package/build/utils/oauth-broker.js.map +1 -0
- package/build/utils/oauth-proxy-redis-vault.d.ts +51 -0
- package/build/utils/oauth-proxy-redis-vault.d.ts.map +1 -0
- package/build/utils/oauth-proxy-redis-vault.js +242 -0
- package/build/utils/oauth-proxy-redis-vault.js.map +1 -0
- package/build/utils/oauth-proxy-vault.d.ts +108 -0
- package/build/utils/oauth-proxy-vault.d.ts.map +1 -0
- package/build/utils/oauth-proxy-vault.js +183 -0
- package/build/utils/oauth-proxy-vault.js.map +1 -0
- package/build/utils/oauth-proxy.d.ts +53 -0
- package/build/utils/oauth-proxy.d.ts.map +1 -0
- package/build/utils/oauth-proxy.js +493 -0
- package/build/utils/oauth-proxy.js.map +1 -0
- package/npm-shrinkwrap.json +178 -31
- package/package.json +6 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import YAML from "yaml";
|
|
3
|
-
import { passthrough, ngExtract, chaosPageExtract, chaosHeatmapExtract, chaosScannedRiskGetExtract, chaosExperimentListExtract, chaosInputSetListExtract, chaosAppMapPageExtract, chaosProbeListExtract, chaosInfraListExtract, chaosK8sInfraListExtract, chaosLoadTestListExtract, chaosLoadTestExtract, chaosServiceListExtract, chaosHubListExtract, chaosDRTestListExtract, sdPageExtract, chaosRunTimeInputsExtract, chaosActionExtract, } from "../extractors.js";
|
|
3
|
+
import { passthrough, ngExtract, chaosPageExtract, chaosHeatmapExtract, chaosScannedRiskGetExtract, chaosExperimentListExtract, chaosInputSetListExtract, chaosAppMapPageExtract, chaosProbeListExtract, chaosInfraListExtract, chaosK8sInfraListExtract, chaosLoadTestListExtract, chaosLoadTestExtract, chaosServiceListExtract, chaosHubListExtract, chaosDRTestListExtract, sdPageExtract, sdV2PageExtract, chaosRunTimeInputsExtract, chaosActionExtract, } from "../extractors.js";
|
|
4
4
|
import { descToolsetChaos,
|
|
5
5
|
// Resource descriptions
|
|
6
6
|
descChaosExperiment, descChaosExperimentRun, descChaosProbe, descChaosExperimentTemplate, descChaosExperimentVariable, descChaosInfrastructure, descChaosLoadtest, descChaosService, descChaosK8sInfrastructure, descChaosEnabledInfrastructure, descChaosHub, descChaosFault, descChaosFaultExperimentRun, descChaosFaultTemplate, descChaosProbeTemplate, descChaosActionTemplate, descChaosHubFault, descChaosEnvironment, descChaosApplicationMap, descDiscoveredNetworkMap, descChaosGuardCondition, descChaosGuardRule, descChaosRecommendation, descChaosRisk, descChaosAction, descChaosProbeInRun, descChaosDRTest, descChaosComponentVariable,
|
|
7
7
|
// Operation descriptions
|
|
8
|
-
descListExperiments, descGetExperiment, descGetExperimentRun, descListProbes, descGetProbe, descCreateProbe, descListExperimentTemplates, descGetExperimentTemplate, descDeleteExperimentTemplate, descListExperimentVariables, descGetComponentVariable, descCreateExperiment, descListLinuxInfra, descListLoadtests, descGetLoadtest, descCreateLoadtest, descUpdateLoadtest, descDeleteLoadtest, descListChaosServices, descGetChaosService, descDeleteChaosService, descCreateChaosService, descUpdateChaosService, descChaosServiceEnvironmentIds, descChaosServiceInfrastructureIds, descChaosServiceTags, descChaosServiceIncludeAllScope, descChaosServiceProbeIds, descChaosServiceOnboardingIdFilter, descListChaosServiceExperimentRuns, descListChaosServiceLoadTests, descChaosServiceSearch, descChaosServiceIdentity, descBodyChaosServiceCreate, descBodyChaosServiceUpdate, descChaosServiceName, descChaosServiceDescription, descChaosServiceTagsBody, descChaosServiceExternalServiceId, descChaosServiceAgentId, descChaosServiceEnvironmentId, descChaosServiceInfrastructureId, descChaosServiceInfrastructureType, descChaosServiceOnboardingId, descChaosServiceProbes, descChaosServiceProbesUpdate, descListK8sInfra, descGetK8sInfra, descCreateK8sInfra, descListChaosEnabledInfra, descBodyK8sInfraCreate, descK8sInfraIdentityCreate, descK8sInfraNameCreate, descK8sInfraEnvironmentIdCreate, descK8sInfraInfraIdCreate, descK8sInfraConnectorIdCreate, descK8sInfraNamespaceCreate, descK8sInfraServiceAccountCreate, descK8sInfraScopeCreate, descK8sInfraTypeCreate, descK8sInfraAiEnabledCreate, descListHubs, descGetHub, descCreateHub, descUpdateHub, descDeleteHub, descListFaults, descGetFault, descListFaultTemplates, descGetFaultTemplate, descDeleteFaultTemplate, descListProbeTemplates, descGetProbeTemplate, descDeleteProbeTemplate, descListActionTemplates, descGetActionTemplate, descDeleteActionTemplate, descListHubFaults, descListChaosEnvironments, descListApplicationMaps, descGetApplicationMap, descAppMapSearch, descAppMapEnvironmentId, descAppMapInfraId, descAppMapAll, descAppMapMinimal, descListDiscoveredNetworkMaps, descSDNetworkMapSearch, descListGuardConditions, descGetGuardCondition, descDeleteGuardCondition, descListGuardRules, descGetGuardRule, descDeleteGuardRule, descListRecommendations, descGetRecommendation, descListRisks, descGetRisk, descListDRTests, descDeleteProbe, descGetProbeManifest, descListProbesInRun, descGetFaultVariables, descGetFaultYaml, descListFaultExperimentRuns, descDeleteFault, descListActions, descGetAction, descGetActionManifest, descDeleteAction, descCreateAction, descBodyActionCreate, descActionName, descActionIdentityCreate, descActionEntityTypeCreate, descActionInfraTypeCreate, descActionPropertiesBody, descActionDurationShorthand, descActionDescriptionCreate, descActionTagsCreate, descActionVariablesBody, descActionRunPropertiesBody, descActionInputsBody,
|
|
8
|
+
descListExperiments, descGetExperiment, descGetExperimentRun, descListProbes, descGetProbe, descCreateProbe, descListExperimentTemplates, descGetExperimentTemplate, descDeleteExperimentTemplate, descListExperimentVariables, descGetComponentVariable, descCreateExperiment, descListLinuxInfra, descListLoadtests, descGetLoadtest, descCreateLoadtest, descUpdateLoadtest, descDeleteLoadtest, descListChaosServices, descGetChaosService, descDeleteChaosService, descCreateChaosService, descUpdateChaosService, descChaosServiceEnvironmentIds, descChaosServiceInfrastructureIds, descChaosServiceTags, descChaosServiceIncludeAllScope, descChaosServiceProbeIds, descChaosServiceOnboardingIdFilter, descListChaosServiceExperimentRuns, descListChaosServiceLoadTests, descChaosServiceSearch, descChaosServiceIdentity, descBodyChaosServiceCreate, descBodyChaosServiceUpdate, descChaosServiceName, descChaosServiceDescription, descChaosServiceTagsBody, descChaosServiceExternalServiceId, descChaosServiceAgentId, descChaosServiceEnvironmentId, descChaosServiceInfrastructureId, descChaosServiceInfrastructureType, descChaosServiceOnboardingId, descChaosServiceLinkedDiscoveredService, descChaosServiceProbes, descCustomService, descListCustomServices, descGetCustomService, descCreateCustomService, descBodyCustomServiceCreate, descCustomServiceIdentity, descCustomServiceName, descCustomServiceType, descCustomServiceRepoURL, descCustomServiceModule, descCustomServiceSpec, descUpdateCustomService, descBodyCustomServiceUpdate, descCustomServiceTypeFilter, descCustomServiceCategoryFilter, descChaosServiceProbesUpdate, descListK8sInfra, descGetK8sInfra, descCreateK8sInfra, descListChaosEnabledInfra, descBodyK8sInfraCreate, descK8sInfraIdentityCreate, descK8sInfraNameCreate, descK8sInfraEnvironmentIdCreate, descK8sInfraInfraIdCreate, descK8sInfraConnectorIdCreate, descK8sInfraNamespaceCreate, descK8sInfraServiceAccountCreate, descK8sInfraScopeCreate, descK8sInfraTypeCreate, descK8sInfraAiEnabledCreate, descListHubs, descGetHub, descCreateHub, descUpdateHub, descDeleteHub, descListFaults, descGetFault, descListFaultTemplates, descGetFaultTemplate, descDeleteFaultTemplate, descListProbeTemplates, descGetProbeTemplate, descDeleteProbeTemplate, descListActionTemplates, descGetActionTemplate, descDeleteActionTemplate, descListHubFaults, descListChaosEnvironments, descListApplicationMaps, descGetApplicationMap, descAppMapSearch, descAppMapEnvironmentId, descAppMapInfraId, descAppMapAll, descAppMapMinimal, descListDiscoveredNetworkMaps, descSDNetworkMapSearch, descListGuardConditions, descGetGuardCondition, descDeleteGuardCondition, descListGuardRules, descGetGuardRule, descDeleteGuardRule, descListRecommendations, descGetRecommendation, descListRisks, descGetRisk, descListDRTests, descDeleteProbe, descGetProbeManifest, descListProbesInRun, descGetFaultVariables, descGetFaultYaml, descListFaultExperimentRuns, descDeleteFault, descListActions, descGetAction, descGetActionManifest, descDeleteAction, descCreateAction, descBodyActionCreate, descActionName, descActionIdentityCreate, descActionEntityTypeCreate, descActionInfraTypeCreate, descActionPropertiesBody, descActionDurationShorthand, descActionDescriptionCreate, descActionTagsCreate, descActionVariablesBody, descActionRunPropertiesBody, descActionInputsBody,
|
|
9
9
|
// Action descriptions
|
|
10
10
|
descRunExperiment, descStopExperiment, descDeleteExperiment, descEnableProbe, descVerifyProbe, descCreateFromTemplate, descListRevisions, descGetVariables, descGetYaml, descCompareRevisions, descRunLoadtest, descStopLoadtest, descCheckK8sHealth, descEnableGuardRule, descGetProbeTemplateVariables, descListActionTemplateRevisions, descGetActionTemplateVariables, descCompareActionTemplateRevisions,
|
|
11
11
|
// Body schema descriptions
|
|
@@ -21,7 +21,7 @@ descExperimentManifest, descExperimentInfraType, descExperimentInfraIdCreate, de
|
|
|
21
21
|
// Service Discovery
|
|
22
22
|
descSDAgentIdentity, descSDEnvironmentId, descSDAgentListEnvironmentId, descSDFetchAll, descSDAgentDiagnostic, descDiscoveredAgent, descListDiscoveredAgents, descDiscoveredAgentSearch, descDiscoveredNamespace, descListDiscoveredNamespaces, descSDNamespaceNameFilter, descDiscoveredService, descListDiscoveredServices, descSDNamespaceFilter, descSDSearchFilter,
|
|
23
23
|
// Scanned Risks / Risk Rules / Risk Scans (chaos-manager v3)
|
|
24
|
-
descScannedRisk, descChaosRiskRule, descChaosRiskScan, descListScannedRisks, descGetScannedRisk, descListScannedRiskOccurrences, descSummarizeScannedRisksByService, descListRiskRules, descGetRiskRule, descListRiskScans, descGetRiskScan, descCreateRiskScan, descUpdateRiskScan, descDeleteRiskScan, descRetryRiskScan, descAbortRiskScan, descGetRiskScanReport, descGetRiskScanReportDownload, descGetRiskScanHeatmap, descBodyRiskScanCreate, descBodyRiskScanUpdate, descRiskScanIdentity, descRiskScanName, descRiskScanDescription, descRiskScanTags, descRiskScanType, descRiskScanSource, descScannedRiskSeverity, descScannedRiskRuleId, descScannedRiskValidationType, descScannedRiskServiceIdentity, descScannedRiskScanType, descRiskEnvironmentIdentity, descRiskAgentIdentity, descRiskPipelineIdentity, descRiskScanStatus, descRiskSearch, descRiskSortField, descRiskSortAscending, descRiskTags, descRiskIncludeAllScope, descRiskStartTime, descRiskEndTime, descRiskRuleDataSource, descRiskRuleIsSystem, descHeatmapSearch, } from "./chaos-descriptions.js";
|
|
24
|
+
descScannedRisk, descChaosRiskRule, descChaosRiskScan, descListScannedRisks, descGetScannedRisk, descListScannedRiskOccurrences, descSummarizeScannedRisksByService, descListRiskRules, descGetRiskRule, descCreateRiskRule, descUpdateRiskRule, descDeleteRiskRule, descBodyRiskRuleCreate, descBodyRiskRuleUpdate, descRiskRuleIdentity, descRiskRuleName, descRiskRuleDescription, descRiskRuleTags, descRiskRuleSeverity, descRiskRuleCategory, descRiskRuleSpec, descRiskRuleCustomOnly, descListRiskScans, descGetRiskScan, descCreateRiskScan, descUpdateRiskScan, descDeleteRiskScan, descRetryRiskScan, descAbortRiskScan, descSubmitRiskScanFindings, descBodySubmitRiskScanFindings, descRiskScanFindings, descRiskScanDetectionMethod, descGetRiskScanReport, descGetRiskScanReportDownload, descGetRiskScanHeatmap, descBodyRiskScanCreate, descBodyRiskScanUpdate, descRiskScanIdentity, descRiskScanName, descRiskScanDescription, descRiskScanTags, descRiskScanType, descRiskScanSource, descScannedRiskSeverity, descScannedRiskRuleId, descScannedRiskValidationType, descScannedRiskServiceIdentity, descScannedRiskScanType, descRiskEnvironmentIdentity, descRiskAgentIdentity, descRiskPipelineIdentity, descRiskScanStatus, descRiskSearch, descRiskSortField, descRiskSortAscending, descRiskTags, descRiskIncludeAllScope, descRiskStartTime, descRiskEndTime, descRiskRuleDataSource, descRiskRuleIsSystem, descHeatmapSearch, } from "./chaos-descriptions.js";
|
|
25
25
|
/**
|
|
26
26
|
* Chaos API base path.
|
|
27
27
|
* REST endpoints live under rest/v2/ (experiments, probes) and rest/ (templates).
|
|
@@ -37,6 +37,8 @@ const CHAOS_LOADTEST = "/loadTest/manager/api";
|
|
|
37
37
|
* collected by an SD agent running inside the user's cluster.
|
|
38
38
|
*/
|
|
39
39
|
const SD = "/gateway/servicediscovery/api/v1";
|
|
40
|
+
const SD_V2 = "/gateway/servicediscovery/api/v2";
|
|
41
|
+
const CUSTOM_DISCOVERY_AGENT = "custom-discovery-agent";
|
|
40
42
|
/** Chaos scope override — Chaos REST API uses organizationIdentifier (not orgIdentifier). */
|
|
41
43
|
const CHAOS_SCOPE = { org: "organizationIdentifier" };
|
|
42
44
|
/** Unwrap single-item response from get-chaos-component-variable endpoint. */
|
|
@@ -77,6 +79,110 @@ function compactDiscoveredAgent(item) {
|
|
|
77
79
|
}
|
|
78
80
|
return slim;
|
|
79
81
|
}
|
|
82
|
+
function optionalText(value) {
|
|
83
|
+
if (value == null)
|
|
84
|
+
return undefined;
|
|
85
|
+
const text = String(value).trim();
|
|
86
|
+
return text === "" ? undefined : text;
|
|
87
|
+
}
|
|
88
|
+
function stringList(value) {
|
|
89
|
+
if (value == null || value === "")
|
|
90
|
+
return undefined;
|
|
91
|
+
if (Array.isArray(value))
|
|
92
|
+
return value.map((item) => String(item).trim()).filter(Boolean);
|
|
93
|
+
return String(value).split(",").map((item) => item.trim()).filter(Boolean);
|
|
94
|
+
}
|
|
95
|
+
function linkedDiscoveredService(value) {
|
|
96
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
97
|
+
return undefined;
|
|
98
|
+
const linked = value;
|
|
99
|
+
const agentId = optionalText(linked.agent_id ?? linked.agentId);
|
|
100
|
+
const environmentId = optionalText(linked.environment_id ?? linked.environmentId);
|
|
101
|
+
const externalId = optionalText(linked.external_id ?? linked.externalId);
|
|
102
|
+
if (!agentId && !environmentId && !externalId)
|
|
103
|
+
return undefined;
|
|
104
|
+
if (!agentId || !environmentId || !externalId) {
|
|
105
|
+
const missing = [
|
|
106
|
+
!agentId ? "agent_id" : "",
|
|
107
|
+
!environmentId ? "environment_id" : "",
|
|
108
|
+
!externalId ? "external_id" : "",
|
|
109
|
+
].filter(Boolean);
|
|
110
|
+
throw new Error(`linked_discovered_service requires agent_id, environment_id, and external_id. Missing: ${missing.join(", ")}.`);
|
|
111
|
+
}
|
|
112
|
+
return { agentId, environmentId, externalId };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A CodeRepository chaos service is the only one that may omit infrastructure,
|
|
116
|
+
* and only when agent_id is the custom discovery agent. Every other service
|
|
117
|
+
* must send both identifiers so an update cannot clear its mapping.
|
|
118
|
+
*/
|
|
119
|
+
function assertChaosServiceInfrastructure(agentId, environmentId, infrastructureId) {
|
|
120
|
+
if (agentId === CUSTOM_DISCOVERY_AGENT) {
|
|
121
|
+
if (Boolean(environmentId) !== Boolean(infrastructureId)) {
|
|
122
|
+
throw new Error("environment_id and infrastructure_id must both be set or both omitted for a CodeRepository service (agent_id custom-discovery-agent).");
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const missing = [
|
|
127
|
+
!environmentId ? "environment_id" : "",
|
|
128
|
+
!infrastructureId ? "infrastructure_id" : "",
|
|
129
|
+
].filter(Boolean);
|
|
130
|
+
if (missing.length > 0) {
|
|
131
|
+
throw new Error(`${missing.join(" and ")} required for a chaos service. Omit both only for a CodeRepository service with agent_id ${CUSTOM_DISCOVERY_AGENT}.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function buildCustomServiceBody(input) {
|
|
135
|
+
const b = coerceBody(input);
|
|
136
|
+
const type = optionalText(b.type) ?? "";
|
|
137
|
+
const specInput = b.spec;
|
|
138
|
+
const specRecord = specInput && typeof specInput === "object" && !Array.isArray(specInput)
|
|
139
|
+
? specInput
|
|
140
|
+
: undefined;
|
|
141
|
+
let spec;
|
|
142
|
+
if (type === "CodeRepository") {
|
|
143
|
+
const nested = specRecord?.codeRepository;
|
|
144
|
+
const nestedRecord = nested && typeof nested === "object" && !Array.isArray(nested)
|
|
145
|
+
? nested
|
|
146
|
+
: undefined;
|
|
147
|
+
const repoURL = optionalText(b.repo_url ?? b.repoURL ?? nestedRecord?.repoURL ?? nestedRecord?.repo_url);
|
|
148
|
+
if (!repoURL) {
|
|
149
|
+
throw new Error("repo_url is required when type is CodeRepository");
|
|
150
|
+
}
|
|
151
|
+
spec = {
|
|
152
|
+
codeRepository: {
|
|
153
|
+
repoURL,
|
|
154
|
+
module: optionalText(b.module ?? nestedRecord?.module) ?? ".",
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else if (specRecord) {
|
|
159
|
+
spec = specRecord;
|
|
160
|
+
}
|
|
161
|
+
else if (type) {
|
|
162
|
+
throw new Error(`spec is required when type is ${type}`);
|
|
163
|
+
}
|
|
164
|
+
const tags = stringList(b.tags);
|
|
165
|
+
return {
|
|
166
|
+
...(optionalText(b.identity) ? { identity: optionalText(b.identity) } : {}),
|
|
167
|
+
...(optionalText(b.name) ? { name: optionalText(b.name) } : {}),
|
|
168
|
+
...(type ? { type } : {}),
|
|
169
|
+
...(optionalText(b.description) ? { description: optionalText(b.description) } : {}),
|
|
170
|
+
...(tags ? { tags } : {}),
|
|
171
|
+
...(spec ? { spec } : {}),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* PUT /api/v2/services/{identity} replaces name, description, tags, type and spec.
|
|
176
|
+
* The identity belongs on the path, not in the body, and the API requires name and type.
|
|
177
|
+
*/
|
|
178
|
+
function buildCustomServiceUpdateBody(input) {
|
|
179
|
+
const { identity: _identity, ...body } = buildCustomServiceBody(input);
|
|
180
|
+
if (!body.name)
|
|
181
|
+
throw new Error("name is required to update a custom service");
|
|
182
|
+
if (!body.type)
|
|
183
|
+
throw new Error("type is required to update a custom service");
|
|
184
|
+
return body;
|
|
185
|
+
}
|
|
80
186
|
/**
|
|
81
187
|
* Parse input.body when LLMs double-serialize it as a JSON string instead of an object.
|
|
82
188
|
* Fails loudly on malformed JSON so callers' defaults can never silently produce a
|
|
@@ -95,6 +201,87 @@ function coerceBody(input) {
|
|
|
95
201
|
}
|
|
96
202
|
return raw;
|
|
97
203
|
}
|
|
204
|
+
const MAX_RISK_SCAN_FINDINGS = 100;
|
|
205
|
+
const RISK_RULE_BODY_FIELDS = [
|
|
206
|
+
{ name: "name", type: "string", required: true, description: descRiskRuleName },
|
|
207
|
+
{ name: "description", type: "string", required: false, description: descRiskRuleDescription },
|
|
208
|
+
{ name: "tags", type: "array", required: false, itemType: "string", description: descRiskRuleTags },
|
|
209
|
+
{ name: "severity", type: "string", required: true, description: descRiskRuleSeverity },
|
|
210
|
+
{ name: "category", type: "string", required: true, description: descRiskRuleCategory },
|
|
211
|
+
{ name: "spec", type: "object", required: true, description: descRiskRuleSpec },
|
|
212
|
+
];
|
|
213
|
+
const RISK_RULE_IDENTITY_RE = /^code-[a-z0-9-]{3,60}$/;
|
|
214
|
+
const RISK_RULE_DATA_SOURCE = "SourceCode";
|
|
215
|
+
const RISK_RULE_PROMPT_LIST_LIMIT = 10;
|
|
216
|
+
const RISK_RULE_PROMPT_ENTRY_LIMIT = 500;
|
|
217
|
+
/** Custom rules are SourceCode-only; an omitted dataSource defaults to that. */
|
|
218
|
+
function riskRuleDataSource(value) {
|
|
219
|
+
const dataSource = value ?? [RISK_RULE_DATA_SOURCE];
|
|
220
|
+
if (!Array.isArray(dataSource) ||
|
|
221
|
+
dataSource.length !== 1 ||
|
|
222
|
+
dataSource[0] !== RISK_RULE_DATA_SOURCE) {
|
|
223
|
+
throw new Error('spec.dataSource must be exactly ["SourceCode"]. Custom rules are SourceCode-only.');
|
|
224
|
+
}
|
|
225
|
+
return dataSource;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* prompt.do and prompt.outcome are required; prompt.dont is optional.
|
|
229
|
+
* Each list holds at most 10 entries of 500 characters.
|
|
230
|
+
*/
|
|
231
|
+
function riskRulePromptList(value, field, required) {
|
|
232
|
+
if (value == null) {
|
|
233
|
+
if (required)
|
|
234
|
+
throw new Error(`${field} must list at least one entry.`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!Array.isArray(value)) {
|
|
238
|
+
throw new Error(`${field} must be an array of strings.`);
|
|
239
|
+
}
|
|
240
|
+
if (required && value.length === 0) {
|
|
241
|
+
throw new Error(`${field} must list at least one entry.`);
|
|
242
|
+
}
|
|
243
|
+
if (value.length > RISK_RULE_PROMPT_LIST_LIMIT) {
|
|
244
|
+
throw new Error(`${field} holds at most ${RISK_RULE_PROMPT_LIST_LIMIT} entries.`);
|
|
245
|
+
}
|
|
246
|
+
for (const entry of value) {
|
|
247
|
+
if (typeof entry !== "string" || entry.trim() === "") {
|
|
248
|
+
throw new Error(`${field} entries must be non-empty strings.`);
|
|
249
|
+
}
|
|
250
|
+
if (entry.length > RISK_RULE_PROMPT_ENTRY_LIMIT) {
|
|
251
|
+
throw new Error(`${field} entries must be at most ${RISK_RULE_PROMPT_ENTRY_LIMIT} characters.`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** Builds the mutable part of a custom risk rule; spec.dataSource defaults to SourceCode. */
|
|
256
|
+
function buildRiskRuleBody(b) {
|
|
257
|
+
const missing = ["name", "severity", "category", "spec"].filter((k) => b[k] == null || b[k] === "");
|
|
258
|
+
if (missing.length > 0) {
|
|
259
|
+
throw new Error(`Missing required field(s): ${missing.join(", ")}.`);
|
|
260
|
+
}
|
|
261
|
+
if (typeof b.spec !== "object" || b.spec == null || Array.isArray(b.spec)) {
|
|
262
|
+
throw new Error("spec must be an object.");
|
|
263
|
+
}
|
|
264
|
+
const spec = b.spec;
|
|
265
|
+
const dataSource = riskRuleDataSource(spec.dataSource);
|
|
266
|
+
if (!Array.isArray(spec.faults) || spec.faults.length === 0) {
|
|
267
|
+
throw new Error("spec.faults must list at least one chaos fault that can prove the risk (e.g. pod-network-latency).");
|
|
268
|
+
}
|
|
269
|
+
if (typeof spec.prompt !== "object" || spec.prompt == null || Array.isArray(spec.prompt)) {
|
|
270
|
+
throw new Error("spec.prompt must include non-empty do and outcome lists.");
|
|
271
|
+
}
|
|
272
|
+
const prompt = spec.prompt;
|
|
273
|
+
riskRulePromptList(prompt.do, "spec.prompt.do", true);
|
|
274
|
+
riskRulePromptList(prompt.dont, "spec.prompt.dont", false);
|
|
275
|
+
riskRulePromptList(prompt.outcome, "spec.prompt.outcome", true);
|
|
276
|
+
return {
|
|
277
|
+
name: b.name,
|
|
278
|
+
...(b.description != null ? { description: b.description } : {}),
|
|
279
|
+
...(b.tags != null ? { tags: b.tags } : {}),
|
|
280
|
+
severity: b.severity,
|
|
281
|
+
category: b.category,
|
|
282
|
+
spec: { ...spec, dataSource },
|
|
283
|
+
};
|
|
284
|
+
}
|
|
98
285
|
/**
|
|
99
286
|
* Detects whether a chaos experiment identifier looks like the internal UUID
|
|
100
287
|
* (e.g. "ef9199b6-0248-4c0b-9d63-9176bf2b7123") rather than a human-readable
|
|
@@ -2186,9 +2373,10 @@ export const chaosToolset = {
|
|
|
2186
2373
|
{ name: "onboarding_id", description: descChaosServiceOnboardingIdFilter },
|
|
2187
2374
|
],
|
|
2188
2375
|
relatedResources: [
|
|
2189
|
-
{ resourceType: "discovered_agent", relationship: "prerequisite", description: "STEP 1 of create: pick the Service Discovery agent. Its 'identity' becomes agent_id, its environmentIdentifier becomes environment_id, and (for SD K8s) its identity is also the bare infrastructure_id." },
|
|
2376
|
+
{ resourceType: "discovered_agent", relationship: "prerequisite", description: "STEP 1 of create: pick the Service Discovery agent. Its 'identity' becomes agent_id, its environmentIdentifier becomes environment_id, and (for SD K8s) its identity is also the bare infrastructure_id. A code-repository service uses agent_id custom-discovery-agent and omits environment and infrastructure." },
|
|
2190
2377
|
{ resourceType: "discovered_namespace", relationship: "filters", description: "Optional STEP 2a: list namespaces for the chosen agent to narrow the discovered_service list before picking a service." },
|
|
2191
|
-
{ resourceType: "discovered_service", relationship: "prerequisite", description: "STEP 2b of create: pick the service to onboard. Its 'id' becomes external_service_id (the server derives serviceType/namespace from it)." },
|
|
2378
|
+
{ resourceType: "discovered_service", relationship: "prerequisite", description: "STEP 2b of create: pick the runtime service to onboard. Its 'id' becomes external_service_id (the server derives serviceType/namespace from it)." },
|
|
2379
|
+
{ resourceType: "custom_service", relationship: "prerequisite", description: "Code-repository create: pick or create the custom service. Its 'id' becomes external_service_id and agent_id is custom-discovery-agent. Omit environment_id and infrastructure_id." },
|
|
2192
2380
|
{ resourceType: "chaos_probe", relationship: "associates", description: "STEP 4 of create: optional health-check probes to attach. Source probe identities and their inputs[] schema here; fill each input value before adding to the create body's probes array." },
|
|
2193
2381
|
],
|
|
2194
2382
|
operations: {
|
|
@@ -2236,13 +2424,15 @@ export const chaosToolset = {
|
|
|
2236
2424
|
operationPolicy: { risk: "medium_write", retryPolicy: "do_not_retry" },
|
|
2237
2425
|
bodyBuilder: (input) => {
|
|
2238
2426
|
const b = coerceBody(input);
|
|
2239
|
-
const externalServiceId = b.external_service_id ?? b.externalServiceId;
|
|
2240
|
-
const agentId = b.agent_id ?? b.agentId;
|
|
2241
|
-
const environmentId = b.environment_id ?? b.environmentId;
|
|
2242
|
-
const infrastructureId = b.infrastructure_id ?? b.infrastructureId;
|
|
2243
|
-
const infrastructureType = b.infrastructure_type ?? b.infrastructureType;
|
|
2244
|
-
const onboardingId = b.onboarding_id ?? b.onboardingId;
|
|
2245
|
-
const tags = b.tags;
|
|
2427
|
+
const externalServiceId = optionalText(b.external_service_id ?? b.externalServiceId);
|
|
2428
|
+
const agentId = optionalText(b.agent_id ?? b.agentId);
|
|
2429
|
+
const environmentId = optionalText(b.environment_id ?? b.environmentId);
|
|
2430
|
+
const infrastructureId = optionalText(b.infrastructure_id ?? b.infrastructureId);
|
|
2431
|
+
const infrastructureType = optionalText(b.infrastructure_type ?? b.infrastructureType);
|
|
2432
|
+
const onboardingId = optionalText(b.onboarding_id ?? b.onboardingId);
|
|
2433
|
+
const tags = stringList(b.tags);
|
|
2434
|
+
const linked = linkedDiscoveredService(b.linked_discovered_service ?? b.linkedDiscoveredService);
|
|
2435
|
+
assertChaosServiceInfrastructure(agentId, environmentId, infrastructureId);
|
|
2246
2436
|
const probes = b.probes?.map((p) => ({
|
|
2247
2437
|
probeId: p.probeId ?? p.probe_id,
|
|
2248
2438
|
...(p.inputs ? { inputs: p.inputs } : {}),
|
|
@@ -2251,30 +2441,21 @@ export const chaosToolset = {
|
|
|
2251
2441
|
identity: b.identity,
|
|
2252
2442
|
name: b.name,
|
|
2253
2443
|
...(b.description ? { description: b.description } : {}),
|
|
2254
|
-
...(tags
|
|
2255
|
-
? {
|
|
2256
|
-
tags: Array.isArray(tags)
|
|
2257
|
-
? tags
|
|
2258
|
-
: String(tags)
|
|
2259
|
-
.split(",")
|
|
2260
|
-
.map((t) => t.trim())
|
|
2261
|
-
.filter(Boolean),
|
|
2262
|
-
}
|
|
2263
|
-
: {}),
|
|
2444
|
+
...(tags ? { tags } : {}),
|
|
2264
2445
|
externalServiceId,
|
|
2265
2446
|
agentId,
|
|
2266
|
-
environmentId,
|
|
2267
|
-
infrastructureId,
|
|
2268
2447
|
// Dual-write snake_case keys so registry required-field validation
|
|
2269
2448
|
// (which checks bodySchema.fields names against this transformed
|
|
2270
2449
|
// payload) sees the fields it expects. See getBodySchemaValidationPayload
|
|
2271
|
-
// in registry/index.ts.
|
|
2450
|
+
// in registry/index.ts. environment and infrastructure are omitted
|
|
2451
|
+
// only for a CodeRepository service (agent_id custom-discovery-agent).
|
|
2272
2452
|
external_service_id: externalServiceId,
|
|
2273
2453
|
agent_id: agentId,
|
|
2274
|
-
environment_id: environmentId,
|
|
2275
|
-
infrastructure_id: infrastructureId,
|
|
2454
|
+
...(environmentId ? { environmentId, environment_id: environmentId } : {}),
|
|
2455
|
+
...(infrastructureId ? { infrastructureId, infrastructure_id: infrastructureId } : {}),
|
|
2276
2456
|
...(infrastructureType ? { infrastructureType } : {}),
|
|
2277
2457
|
...(onboardingId ? { onboardingId } : {}),
|
|
2458
|
+
...(linked ? { linkedDiscoveredService: linked } : {}),
|
|
2278
2459
|
...(probes && probes.length > 0 ? { probes } : {}),
|
|
2279
2460
|
};
|
|
2280
2461
|
},
|
|
@@ -2287,13 +2468,14 @@ export const chaosToolset = {
|
|
|
2287
2468
|
{ name: "name", type: "string", required: true, description: descChaosServiceName },
|
|
2288
2469
|
{ name: "external_service_id", type: "string", required: true, description: descChaosServiceExternalServiceId },
|
|
2289
2470
|
{ name: "agent_id", type: "string", required: true, description: descChaosServiceAgentId },
|
|
2290
|
-
{ name: "environment_id", type: "string", required:
|
|
2291
|
-
{ name: "infrastructure_id", type: "string", required:
|
|
2471
|
+
{ name: "environment_id", type: "string", required: false, description: descChaosServiceEnvironmentId },
|
|
2472
|
+
{ name: "infrastructure_id", type: "string", required: false, description: descChaosServiceInfrastructureId },
|
|
2292
2473
|
{ name: "infrastructure_type", type: "string", required: false, description: descChaosServiceInfrastructureType },
|
|
2293
2474
|
{ name: "description", type: "string", required: false, description: descChaosServiceDescription },
|
|
2294
2475
|
{ name: "tags", type: "array", required: false, description: descChaosServiceTagsBody },
|
|
2295
2476
|
{ name: "onboarding_id", type: "string", required: false, description: descChaosServiceOnboardingId },
|
|
2296
2477
|
{ name: "probes", type: "array", required: false, description: descChaosServiceProbes },
|
|
2478
|
+
{ name: "linked_discovered_service", type: "object", required: false, description: descChaosServiceLinkedDiscoveredService },
|
|
2297
2479
|
],
|
|
2298
2480
|
},
|
|
2299
2481
|
},
|
|
@@ -2306,9 +2488,12 @@ export const chaosToolset = {
|
|
|
2306
2488
|
const b = coerceBody(input);
|
|
2307
2489
|
const externalServiceId = b.external_service_id ?? b.externalServiceId;
|
|
2308
2490
|
const agentId = b.agent_id ?? b.agentId;
|
|
2309
|
-
const environmentId = b.environment_id ?? b.environmentId;
|
|
2310
|
-
const infrastructureId = b.infrastructure_id ?? b.infrastructureId;
|
|
2311
|
-
const
|
|
2491
|
+
const environmentId = optionalText(b.environment_id ?? b.environmentId);
|
|
2492
|
+
const infrastructureId = optionalText(b.infrastructure_id ?? b.infrastructureId);
|
|
2493
|
+
const infrastructureType = optionalText(b.infrastructure_type ?? b.infrastructureType);
|
|
2494
|
+
const tags = stringList(b.tags);
|
|
2495
|
+
const linked = linkedDiscoveredService(b.linked_discovered_service ?? b.linkedDiscoveredService);
|
|
2496
|
+
assertChaosServiceInfrastructure(optionalText(agentId), environmentId, infrastructureId);
|
|
2312
2497
|
const probes = b.probes?.map((p) => ({
|
|
2313
2498
|
probeId: p.probeId ?? p.probe_id,
|
|
2314
2499
|
...(p.inputs ? { inputs: p.inputs } : {}),
|
|
@@ -2328,13 +2513,15 @@ export const chaosToolset = {
|
|
|
2328
2513
|
: {}),
|
|
2329
2514
|
externalServiceId,
|
|
2330
2515
|
agentId,
|
|
2331
|
-
environmentId,
|
|
2332
|
-
infrastructureId,
|
|
2333
2516
|
// Dual-write snake_case keys — see comment in create bodyBuilder above.
|
|
2517
|
+
// Empty environment and infrastructure are omitted only for a
|
|
2518
|
+
// CodeRepository service, so a normal update cannot clear its mapping.
|
|
2334
2519
|
external_service_id: externalServiceId,
|
|
2335
2520
|
agent_id: agentId,
|
|
2336
|
-
environment_id: environmentId,
|
|
2337
|
-
infrastructure_id: infrastructureId,
|
|
2521
|
+
...(environmentId ? { environmentId, environment_id: environmentId } : {}),
|
|
2522
|
+
...(infrastructureId ? { infrastructureId, infrastructure_id: infrastructureId } : {}),
|
|
2523
|
+
...(infrastructureType ? { infrastructureType } : {}),
|
|
2524
|
+
...(linked ? { linkedDiscoveredService: linked } : {}),
|
|
2338
2525
|
// Full desired-state replace (hce-saas reconcileProbeMappings):
|
|
2339
2526
|
// pass an explicit [] straight through (detach all) rather than
|
|
2340
2527
|
// dropping it, but leave the key absent when the caller omitted it
|
|
@@ -2351,11 +2538,13 @@ export const chaosToolset = {
|
|
|
2351
2538
|
{ name: "name", type: "string", required: true, description: descChaosServiceName },
|
|
2352
2539
|
{ name: "external_service_id", type: "string", required: true, description: descChaosServiceExternalServiceId },
|
|
2353
2540
|
{ name: "agent_id", type: "string", required: true, description: descChaosServiceAgentId },
|
|
2354
|
-
{ name: "environment_id", type: "string", required:
|
|
2355
|
-
{ name: "infrastructure_id", type: "string", required:
|
|
2541
|
+
{ name: "environment_id", type: "string", required: false, description: descChaosServiceEnvironmentId },
|
|
2542
|
+
{ name: "infrastructure_id", type: "string", required: false, description: descChaosServiceInfrastructureId },
|
|
2543
|
+
{ name: "infrastructure_type", type: "string", required: false, description: descChaosServiceInfrastructureType },
|
|
2356
2544
|
{ name: "description", type: "string", required: false, description: descChaosServiceDescription },
|
|
2357
2545
|
{ name: "tags", type: "array", required: false, description: descChaosServiceTagsBody },
|
|
2358
2546
|
{ name: "probes", type: "array", required: true, description: descChaosServiceProbesUpdate },
|
|
2547
|
+
{ name: "linked_discovered_service", type: "object", required: false, description: descChaosServiceLinkedDiscoveredService },
|
|
2359
2548
|
],
|
|
2360
2549
|
},
|
|
2361
2550
|
},
|
|
@@ -3786,6 +3975,109 @@ export const chaosToolset = {
|
|
|
3786
3975
|
},
|
|
3787
3976
|
},
|
|
3788
3977
|
},
|
|
3978
|
+
// ── Custom services (service-discovery v2) ─────────────────────────
|
|
3979
|
+
// POST/GET /gateway/servicediscovery/api/v2/services. Creates are pinned
|
|
3980
|
+
// to the custom discovery agent; the API rejects any other agent.
|
|
3981
|
+
{
|
|
3982
|
+
resourceType: "custom_service",
|
|
3983
|
+
displayName: "Custom Service",
|
|
3984
|
+
description: descCustomService,
|
|
3985
|
+
toolset: "chaos",
|
|
3986
|
+
scope: "project",
|
|
3987
|
+
scopeParams: CHAOS_SCOPE,
|
|
3988
|
+
identifierFields: ["identity"],
|
|
3989
|
+
deepLinkTemplate: "/ng/account/{accountId}/module/chaos/orgs/{orgIdentifier}/projects/{projectIdentifier}/settings/discovery/custom-discovery-agent/custom-service/{identity}",
|
|
3990
|
+
searchAliases: [
|
|
3991
|
+
"custom service", "custom discovery service", "code repository service",
|
|
3992
|
+
"code repository", "repository service",
|
|
3993
|
+
],
|
|
3994
|
+
listFilterFields: [
|
|
3995
|
+
{ name: "type", description: descCustomServiceTypeFilter },
|
|
3996
|
+
{ name: "category", description: descCustomServiceCategoryFilter },
|
|
3997
|
+
{ name: "search", description: descChaosServiceSearch },
|
|
3998
|
+
],
|
|
3999
|
+
relatedResources: [
|
|
4000
|
+
{
|
|
4001
|
+
resourceType: "chaos_service",
|
|
4002
|
+
relationship: "promoted_to",
|
|
4003
|
+
description: "Onboard the custom service as a chaos service. Pass this record's id as external_service_id and agent_id custom-discovery-agent. For type CodeRepository, omit environment_id and infrastructure_id.",
|
|
4004
|
+
},
|
|
4005
|
+
],
|
|
4006
|
+
operations: {
|
|
4007
|
+
list: {
|
|
4008
|
+
method: "GET",
|
|
4009
|
+
path: `${SD_V2}/services`,
|
|
4010
|
+
operationPolicy: { risk: "read", retryPolicy: "safe" },
|
|
4011
|
+
queryParams: {
|
|
4012
|
+
page: "page",
|
|
4013
|
+
limit: "limit",
|
|
4014
|
+
size: "limit",
|
|
4015
|
+
search: "search",
|
|
4016
|
+
search_term: "search",
|
|
4017
|
+
type: "type",
|
|
4018
|
+
category: "category",
|
|
4019
|
+
},
|
|
4020
|
+
staticQueryParams: { agentIdentifier: CUSTOM_DISCOVERY_AGENT },
|
|
4021
|
+
responseExtractor: sdV2PageExtract,
|
|
4022
|
+
description: descListCustomServices,
|
|
4023
|
+
},
|
|
4024
|
+
get: {
|
|
4025
|
+
method: "GET",
|
|
4026
|
+
path: `${SD_V2}/services/{identity}`,
|
|
4027
|
+
operationPolicy: { risk: "read", retryPolicy: "safe" },
|
|
4028
|
+
pathParams: { identity: "identity" },
|
|
4029
|
+
staticQueryParams: { agentIdentifier: CUSTOM_DISCOVERY_AGENT },
|
|
4030
|
+
responseExtractor: passthrough,
|
|
4031
|
+
description: descGetCustomService,
|
|
4032
|
+
},
|
|
4033
|
+
create: {
|
|
4034
|
+
method: "POST",
|
|
4035
|
+
path: `${SD_V2}/services`,
|
|
4036
|
+
operationPolicy: { risk: "medium_write", retryPolicy: "do_not_retry" },
|
|
4037
|
+
staticQueryParams: { agentIdentifier: CUSTOM_DISCOVERY_AGENT },
|
|
4038
|
+
skipScopeBodyInjection: true,
|
|
4039
|
+
bodyBuilder: buildCustomServiceBody,
|
|
4040
|
+
responseExtractor: passthrough,
|
|
4041
|
+
description: descCreateCustomService,
|
|
4042
|
+
bodySchema: {
|
|
4043
|
+
description: descBodyCustomServiceCreate,
|
|
4044
|
+
fields: [
|
|
4045
|
+
{ name: "identity", type: "string", required: true, description: descCustomServiceIdentity },
|
|
4046
|
+
{ name: "name", type: "string", required: true, description: descCustomServiceName },
|
|
4047
|
+
{ name: "type", type: "string", required: true, description: descCustomServiceType },
|
|
4048
|
+
{ name: "repo_url", type: "string", required: false, description: descCustomServiceRepoURL },
|
|
4049
|
+
{ name: "module", type: "string", required: false, description: descCustomServiceModule },
|
|
4050
|
+
{ name: "spec", type: "object", required: false, description: descCustomServiceSpec },
|
|
4051
|
+
{ name: "description", type: "string", required: false, description: descChaosServiceDescription },
|
|
4052
|
+
{ name: "tags", type: "array", required: false, description: descChaosServiceTagsBody },
|
|
4053
|
+
],
|
|
4054
|
+
},
|
|
4055
|
+
},
|
|
4056
|
+
update: {
|
|
4057
|
+
method: "PUT",
|
|
4058
|
+
path: `${SD_V2}/services/{identity}`,
|
|
4059
|
+
operationPolicy: { risk: "medium_write", retryPolicy: "do_not_retry" },
|
|
4060
|
+
pathParams: { identity: "identity" },
|
|
4061
|
+
staticQueryParams: { agentIdentifier: CUSTOM_DISCOVERY_AGENT },
|
|
4062
|
+
skipScopeBodyInjection: true,
|
|
4063
|
+
bodyBuilder: buildCustomServiceUpdateBody,
|
|
4064
|
+
responseExtractor: passthrough,
|
|
4065
|
+
description: descUpdateCustomService,
|
|
4066
|
+
bodySchema: {
|
|
4067
|
+
description: descBodyCustomServiceUpdate,
|
|
4068
|
+
fields: [
|
|
4069
|
+
{ name: "name", type: "string", required: true, description: descCustomServiceName },
|
|
4070
|
+
{ name: "type", type: "string", required: true, description: descCustomServiceType },
|
|
4071
|
+
{ name: "repo_url", type: "string", required: false, description: descCustomServiceRepoURL },
|
|
4072
|
+
{ name: "module", type: "string", required: false, description: descCustomServiceModule },
|
|
4073
|
+
{ name: "spec", type: "object", required: false, description: descCustomServiceSpec },
|
|
4074
|
+
{ name: "description", type: "string", required: false, description: descChaosServiceDescription },
|
|
4075
|
+
{ name: "tags", type: "array", required: false, description: descChaosServiceTagsBody },
|
|
4076
|
+
],
|
|
4077
|
+
},
|
|
4078
|
+
},
|
|
4079
|
+
},
|
|
4080
|
+
},
|
|
3789
4081
|
// ── Service Discovery: Agents ──────────────────────────────────────
|
|
3790
4082
|
// GET /gateway/servicediscovery/api/v1/agents (service-discovery repo).
|
|
3791
4083
|
// Envelope matches the other SD list endpoints:
|
|
@@ -4130,13 +4422,14 @@ export const chaosToolset = {
|
|
|
4130
4422
|
scope: "project",
|
|
4131
4423
|
scopeParams: CHAOS_SCOPE,
|
|
4132
4424
|
identifierFields: ["identity"],
|
|
4133
|
-
searchAliases: ["risk rule", "risk check", "manifest risk rule"],
|
|
4425
|
+
searchAliases: ["risk rule", "risk check", "manifest risk rule", "code risk rule", "source code risk rule", "umbrella risk rule"],
|
|
4134
4426
|
listFilterFields: [
|
|
4135
4427
|
{ name: "search", description: descRiskSearch },
|
|
4136
4428
|
{ name: "sort_field", description: descRiskSortField },
|
|
4137
4429
|
{ name: "sort_ascending", description: descRiskSortAscending, type: "boolean" },
|
|
4138
4430
|
{ name: "tags", description: descRiskTags },
|
|
4139
4431
|
{ name: "is_system", description: descRiskRuleIsSystem, type: "boolean" },
|
|
4432
|
+
{ name: "custom_only", description: descRiskRuleCustomOnly, type: "boolean" },
|
|
4140
4433
|
{ name: "data_source", description: descRiskRuleDataSource },
|
|
4141
4434
|
{ name: "include_all_scope", description: descRiskIncludeAllScope, type: "boolean" },
|
|
4142
4435
|
],
|
|
@@ -4156,6 +4449,7 @@ export const chaosToolset = {
|
|
|
4156
4449
|
sort_ascending: "sortAscending",
|
|
4157
4450
|
tags: "tags",
|
|
4158
4451
|
is_system: "isSystem",
|
|
4452
|
+
custom_only: "customOnly",
|
|
4159
4453
|
data_source: "dataSource",
|
|
4160
4454
|
include_all_scope: "includeAllScope",
|
|
4161
4455
|
},
|
|
@@ -4171,6 +4465,51 @@ export const chaosToolset = {
|
|
|
4171
4465
|
responseExtractor: passthrough,
|
|
4172
4466
|
description: descGetRiskRule,
|
|
4173
4467
|
},
|
|
4468
|
+
create: {
|
|
4469
|
+
method: "POST",
|
|
4470
|
+
path: `${CHAOS}/v3/risk-rules`,
|
|
4471
|
+
operationPolicy: { risk: "low_write", retryPolicy: "do_not_retry" },
|
|
4472
|
+
bodyBuilder: (input) => {
|
|
4473
|
+
const b = coerceBody(input);
|
|
4474
|
+
if (!b.identity) {
|
|
4475
|
+
throw new Error("Missing required field: identity. Use code-<failure-mode>, e.g. code-outbound-call-without-timeout.");
|
|
4476
|
+
}
|
|
4477
|
+
if (typeof b.identity !== "string" || !RISK_RULE_IDENTITY_RE.test(b.identity)) {
|
|
4478
|
+
throw new Error(`identity must match ${RISK_RULE_IDENTITY_RE.source} (lowercase letters, digits and hyphens), e.g. code-outbound-call-without-timeout.`);
|
|
4479
|
+
}
|
|
4480
|
+
return { identity: b.identity, ...buildRiskRuleBody(b) };
|
|
4481
|
+
},
|
|
4482
|
+
responseExtractor: passthrough,
|
|
4483
|
+
description: descCreateRiskRule,
|
|
4484
|
+
bodySchema: {
|
|
4485
|
+
description: descBodyRiskRuleCreate,
|
|
4486
|
+
fields: [
|
|
4487
|
+
{ name: "identity", type: "string", required: true, description: descRiskRuleIdentity },
|
|
4488
|
+
...RISK_RULE_BODY_FIELDS,
|
|
4489
|
+
],
|
|
4490
|
+
},
|
|
4491
|
+
},
|
|
4492
|
+
update: {
|
|
4493
|
+
method: "PUT",
|
|
4494
|
+
path: `${CHAOS}/v3/risk-rules/{identity}`,
|
|
4495
|
+
operationPolicy: { risk: "low_write", retryPolicy: "do_not_retry" },
|
|
4496
|
+
pathParams: { identity: "identity" },
|
|
4497
|
+
bodyBuilder: (input) => buildRiskRuleBody(coerceBody(input)),
|
|
4498
|
+
responseExtractor: passthrough,
|
|
4499
|
+
description: descUpdateRiskRule,
|
|
4500
|
+
bodySchema: {
|
|
4501
|
+
description: descBodyRiskRuleUpdate,
|
|
4502
|
+
fields: RISK_RULE_BODY_FIELDS,
|
|
4503
|
+
},
|
|
4504
|
+
},
|
|
4505
|
+
delete: {
|
|
4506
|
+
method: "DELETE",
|
|
4507
|
+
path: `${CHAOS}/v3/risk-rules/{identity}`,
|
|
4508
|
+
operationPolicy: { risk: "destructive", retryPolicy: "do_not_retry" },
|
|
4509
|
+
pathParams: { identity: "identity" },
|
|
4510
|
+
responseExtractor: passthrough,
|
|
4511
|
+
description: descDeleteRiskRule,
|
|
4512
|
+
},
|
|
4174
4513
|
},
|
|
4175
4514
|
},
|
|
4176
4515
|
// ── Chaos Risk Scans (chaos-manager v3) ────────────────────────────
|
|
@@ -4182,13 +4521,13 @@ export const chaosToolset = {
|
|
|
4182
4521
|
scope: "project",
|
|
4183
4522
|
scopeParams: CHAOS_SCOPE,
|
|
4184
4523
|
identifierFields: ["identity"],
|
|
4185
|
-
searchAliases: ["risk scan", "resilience risk scan", "manifest scan"],
|
|
4524
|
+
searchAliases: ["risk scan", "resilience risk scan", "manifest scan", "code scan", "code repository risk scan"],
|
|
4186
4525
|
listFilterFields: [
|
|
4187
4526
|
{ name: "search", description: descRiskSearch },
|
|
4188
4527
|
{ name: "sort_field", description: descRiskSortField },
|
|
4189
4528
|
{ name: "sort_ascending", description: descRiskSortAscending, type: "boolean" },
|
|
4190
4529
|
{ name: "tags", description: descRiskTags },
|
|
4191
|
-
{ name: "scan_type", description: descScannedRiskScanType, enum: ["PipelineExecution", "DiscoveryAgent"] },
|
|
4530
|
+
{ name: "scan_type", description: descScannedRiskScanType, enum: ["PipelineExecution", "DiscoveryAgent", "CodeRepository"] },
|
|
4192
4531
|
{ name: "status", description: descRiskScanStatus, enum: ["PENDING", "COLLECTING", "ANALYSING", "REPORTING", "COMPLETED", "ERRORED", "ABORTED"] },
|
|
4193
4532
|
{ name: "pipeline_identity", description: descRiskPipelineIdentity },
|
|
4194
4533
|
{ name: "agent_identity", description: descRiskAgentIdentity },
|
|
@@ -4252,12 +4591,15 @@ export const chaosToolset = {
|
|
|
4252
4591
|
if (missing.length > 0) {
|
|
4253
4592
|
throw new Error(`Missing required field(s): ${missing.join(", ")}. All are required to create a risk scan.`);
|
|
4254
4593
|
}
|
|
4594
|
+
const detectionMethod = b.detectionMethod ?? b.detection_method
|
|
4595
|
+
?? (scanType === "CodeRepository" ? "External" : undefined);
|
|
4255
4596
|
return {
|
|
4256
4597
|
identity: b.identity,
|
|
4257
4598
|
name: b.name,
|
|
4258
4599
|
...(b.description != null ? { description: b.description } : {}),
|
|
4259
4600
|
...(b.tags != null ? { tags: b.tags } : {}),
|
|
4260
4601
|
scanType,
|
|
4602
|
+
...(detectionMethod != null ? { detectionMethod } : {}),
|
|
4261
4603
|
source: b.source,
|
|
4262
4604
|
};
|
|
4263
4605
|
},
|
|
@@ -4271,6 +4613,7 @@ export const chaosToolset = {
|
|
|
4271
4613
|
{ name: "description", type: "string", required: false, description: descRiskScanDescription },
|
|
4272
4614
|
{ name: "tags", type: "array", required: false, itemType: "string", description: descRiskScanTags },
|
|
4273
4615
|
{ name: "scanType", type: "string", required: true, description: descRiskScanType },
|
|
4616
|
+
{ name: "detectionMethod", type: "string", required: false, description: descRiskScanDetectionMethod },
|
|
4274
4617
|
{ name: "source", type: "object", required: true, description: descRiskScanSource },
|
|
4275
4618
|
],
|
|
4276
4619
|
},
|
|
@@ -4329,6 +4672,31 @@ export const chaosToolset = {
|
|
|
4329
4672
|
actionDescription: descAbortRiskScan,
|
|
4330
4673
|
bodySchema: { description: descBodyNoBody, fields: [] },
|
|
4331
4674
|
},
|
|
4675
|
+
submit_findings: {
|
|
4676
|
+
method: "POST",
|
|
4677
|
+
path: `${CHAOS}/v3/risk-scans/{identity}/findings`,
|
|
4678
|
+
operationPolicy: { risk: "low_write", retryPolicy: "do_not_retry" },
|
|
4679
|
+
pathParams: { identity: "identity" },
|
|
4680
|
+
bodyBuilder: (input) => {
|
|
4681
|
+
const b = coerceBody(input);
|
|
4682
|
+
const findings = b.findings;
|
|
4683
|
+
if (!Array.isArray(findings)) {
|
|
4684
|
+
throw new Error("Missing required field: findings (array). Submit an empty array to complete a scan with no findings.");
|
|
4685
|
+
}
|
|
4686
|
+
if (findings.length > MAX_RISK_SCAN_FINDINGS) {
|
|
4687
|
+
throw new Error(`Too many findings: ${findings.length}. At most ${MAX_RISK_SCAN_FINDINGS} findings can be submitted per scan; aggregate call sites into one finding per rule and module.`);
|
|
4688
|
+
}
|
|
4689
|
+
return { findings };
|
|
4690
|
+
},
|
|
4691
|
+
responseExtractor: passthrough,
|
|
4692
|
+
actionDescription: descSubmitRiskScanFindings,
|
|
4693
|
+
bodySchema: {
|
|
4694
|
+
description: descBodySubmitRiskScanFindings,
|
|
4695
|
+
fields: [
|
|
4696
|
+
{ name: "findings", type: "array", required: true, itemType: "object", description: descRiskScanFindings },
|
|
4697
|
+
],
|
|
4698
|
+
},
|
|
4699
|
+
},
|
|
4332
4700
|
report: {
|
|
4333
4701
|
method: "GET",
|
|
4334
4702
|
path: `${CHAOS}/v3/risk-scans/{identity}/report`,
|