Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e87bbb4
Check name uniqueness across an agent policy's spaces
MichelLosier Oct 15, 2025
62120da
Check name uniqueness of agent policy spaces on create
MichelLosier Oct 15, 2025
e01bee9
Remove optionality of name uniqueness check when updating agent polic…
MichelLosier Oct 15, 2025
a16c5a9
Add and update tests for agentPolicyService.requireUniqueName
MichelLosier Oct 16, 2025
1e4a070
Increment package names with space awareness when creating agent poli…
MichelLosier Oct 17, 2025
9e2371f
Have agentPolicyService.requireUniqueName use own client when multipl…
MichelLosier Oct 17, 2025
eee0ff0
WIP add FTR tests for agent policy name uniqueness
MichelLosier Oct 20, 2025
f4c452e
Add FTR tests for agent policy space aware name uniqueness
MichelLosier Oct 21, 2025
5ebb7d2
Fix type issues
MichelLosier Oct 21, 2025
42fab4c
WIP: package policy multispace name conflict tests
MichelLosier Oct 23, 2025
a189fdb
Add FTR tests for handling package policy spaceaware name conflict ch…
MichelLosier Oct 24, 2025
b77ded2
Have packagePolicyClient create and update enforce name uniqueness
MichelLosier Oct 24, 2025
931d0e1
Fix Package policy name helper tests
MichelLosier Oct 27, 2025
0035454
Fix types issue
MichelLosier Oct 28, 2025
63967dd
Only include namespaces opt on SO client if multispace
MichelLosier Oct 28, 2025
5868c19
Fix package policy name constraint filtering
MichelLosier Oct 28, 2025
8e8e7c5
WIP: update jest tests
MichelLosier Oct 28, 2025
faf5680
Update requireUniqueName jest tests
MichelLosier Oct 29, 2025
d82a477
Add mock to removeOutputFromAll jest test
MichelLosier Oct 29, 2025
8f82492
Merge branch 'main' into enforce-spaceaware-unique-policy-name
MichelLosier Oct 29, 2025
522532d
fix incrementPackageName when no spaceids provided
MichelLosier Oct 29, 2025
50348a5
Closely couple usage of all spaces char with soClient type
MichelLosier Oct 30, 2025
284c1a3
Merge branch 'main' into enforce-spaceaware-unique-policy-name
MichelLosier Oct 31, 2025
f156269
Remove unneeded inclusion of package policies when fetching agent pol…
MichelLosier Oct 31, 2025
11037cd
Merge branch 'main' into enforce-spaceaware-unique-policy-name
MichelLosier Nov 3, 2025
74e7ba5
Merge branch 'main' into enforce-spaceaware-unique-policy-name
MichelLosier Nov 3, 2025
5ce00aa
Merge branch 'main' into enforce-spaceaware-unique-policy-name
MichelLosier Nov 4, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,10 @@ export const createAgentPolicyHandler: FleetRequestHandler<
const monitoringEnabled = request.body.monitoring_enabled;
const logger = appContextService.getLogger().get('httpCreateAgentPolicyHandler');

const {
has_fleet_server: hasFleetServer,
force,
space_ids: spaceIds,
...newPolicy
} = request.body;
const { has_fleet_server: hasFleetServer, force, ...newPolicy } = request.body;
const spaceId = fleetContext.spaceId;
const authorizationHeader = HTTPAuthorizationHeader.parseFromRequest(request, user?.username);
const { space_ids: spaceIds } = request.body;

logger.debug(`Creating agent policy [${newPolicy.name}]`);

Expand Down Expand Up @@ -401,9 +397,11 @@ export const createAgentPolicyHandler: FleetRequestHandler<
(spaceIds.length > 1 || (spaceIds.length === 0 && spaceIds[0]) !== spaceId)
) {
await updateAgentPolicySpaces({
agentPolicyId: agentPolicy.id,
agentPolicy: {
...agentPolicy,
space_ids: spaceIds,
},
currentSpaceId: spaceId,
newSpaceIds: spaceIds,
authorizedSpaces,
options: { force },
});
Expand Down Expand Up @@ -543,8 +541,9 @@ export const updateAgentPolicyHandler: FleetRequestHandler<
const fleetContext = await context.fleet;
const esClient = coreContext.elasticsearch.client.asInternalUser;
const user = appContextService.getSecurityCore().authc.getCurrentUser(request) || undefined;
const { force, bumpRevision, space_ids: spaceIds, ...data } = request.body;
const { force, bumpRevision, ...data } = request.body;

const spaceIds = data.space_ids;
let spaceId = fleetContext.spaceId;

logger.debug(`updating policy [${request.params.agentPolicyId}] in space [${spaceId}]`);
Expand All @@ -560,11 +559,10 @@ export const updateAgentPolicyHandler: FleetRequestHandler<
context
);
await updateAgentPolicySpaces({
agentPolicyId: request.params.agentPolicyId,
agentPolicy: { ...data, id: request.params.agentPolicyId },
currentSpaceId: spaceId,
newSpaceIds: spaceIds,
authorizedSpaces,
options: { force, validateUniqueName: true },
options: { force },
});

spaceId = spaceIds[0];
Expand Down
Loading
Loading