Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY_SOLUTION] 145: Advanced Policy Tests #82898

Merged
merged 64 commits into from
Nov 20, 2020
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d4af7e4
Create Policies for each generated host
paul-tavares Aug 3, 2020
9b1ff83
Refactor Ingest setup to also setup Fleet
paul-tavares Aug 3, 2020
915c910
Rename prop name
paul-tavares Aug 3, 2020
9e53c33
Add generic response type to KbnClient.request + support for headers
paul-tavares Aug 3, 2020
3797983
first attempt at adding fleet agent registration
paul-tavares Aug 4, 2020
67425be
a little closer with fleet integration
paul-tavares Aug 4, 2020
3dc453c
SUCCESS. Able to enroll agent and set it to online
paul-tavares Aug 4, 2020
766821b
Merge branch 'master' into task/endpoint-host-data-generator-create-p…
elasticmachine Aug 21, 2020
63f4d1c
update names to be policy
kevinlog Aug 23, 2020
a2297b3
policy generator has advanced types in endpoint confit
parkiino Aug 31, 2020
0889459
linting
jmiller263 Aug 31, 2020
ffd46ef
Merge branch 'task/endpoint-host-data-generator-create-policy' of htt…
jmiller263 Aug 31, 2020
e868b25
flesh out callback
jmiller263 Sep 1, 2020
41cfac0
add submit button for verify_peer
jmiller263 Sep 1, 2020
ba3b90e
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Sep 1, 2020
67b12d2
add verify hostname field
jmiller263 Sep 3, 2020
638dc5f
145 generalize cb
jmiller263 Sep 10, 2020
59c8170
145 fix setAgain and getValue
jmiller263 Sep 10, 2020
98601b2
145 merge conflict
jmiller263 Sep 23, 2020
ff425c8
145 merge conflict
jmiller263 Sep 23, 2020
3726588
145 add verify_hostname back, start loop for form
jmiller263 Sep 23, 2020
0b98114
145 remove OS trick
jmiller263 Sep 28, 2020
201f433
145 make AdvancedPolicyForms its own component
jmiller263 Sep 29, 2020
749c3f3
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Sep 29, 2020
e534356
145 grid partially working
jmiller263 Oct 1, 2020
2c6530e
145 grid partially working
jmiller263 Oct 1, 2020
bda9b8c
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 5, 2020
aa94cda
145 back to basics
jmiller263 Oct 8, 2020
6074d82
145 back to basics
jmiller263 Oct 8, 2020
38574c6
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 8, 2020
9a1a2da
145 rolled back grid
jmiller263 Oct 12, 2020
d0dba21
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 12, 2020
9d36541
145 flex table working
jmiller263 Oct 13, 2020
34adcc9
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 13, 2020
5ecd799
145 undo accidental change
jmiller263 Oct 13, 2020
00dedbb
145 remove extra schema file
jmiller263 Oct 13, 2020
afe40b7
145 remove unused variable
jmiller263 Oct 13, 2020
23238e9
145 kevin's PR feedback
jmiller263 Oct 15, 2020
0bdfa5f
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 15, 2020
bb3174d
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 19, 2020
0c5a577
145 fix type check and jest
jmiller263 Oct 19, 2020
ec0cb65
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 20, 2020
5546c25
145 EuiFlexGroups
jmiller263 Oct 20, 2020
7c79ece
145 use simple EuiFormRow and add show/hide buttons
jmiller263 Oct 21, 2020
b37f2af
145 merge conflicts
jmiller263 Oct 21, 2020
f44601c
145 move all advanced policy code to advanced file; remove unnec test…
jmiller263 Oct 21, 2020
50d799b
145 fix IDs
jmiller263 Oct 21, 2020
8bd1ef6
145 take out unnecessary stuff
jmiller263 Oct 22, 2020
9a6afa0
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 22, 2020
06c3b4d
145 removed a couple more lines
jmiller263 Oct 22, 2020
37cc6a4
145 add some fields back in
jmiller263 Oct 22, 2020
c7054c6
145 add spacer
jmiller263 Oct 22, 2020
946dbc1
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 27, 2020
a55447a
Merge remote-tracking branch 'upstream/master' into task/145_advanced…
jmiller263 Oct 28, 2020
4583915
Merge remote-tracking branch 'upstream/master' into test/145_advanced…
jmiller263 Oct 29, 2020
fc5a77a
145 start tests
jmiller263 Nov 3, 2020
4ea76d9
Merge remote-tracking branch 'upstream/master' into test/145_advanced…
jmiller263 Nov 3, 2020
8839e5f
145 add findAdvancedPolicyButton
jmiller263 Nov 5, 2020
c26cea0
Merge remote-tracking branch 'upstream/master' into test/145_advanced…
jmiller263 Nov 5, 2020
6382a30
145 test passing
jmiller263 Nov 6, 2020
9696182
Merge remote-tracking branch 'upstream/master' into test/145_advanced…
jmiller263 Nov 6, 2020
75df3ee
145 remove comment
jmiller263 Nov 6, 2020
249a4e4
Merge remote-tracking branch 'upstream/master' into test/145_advanced…
jmiller263 Nov 9, 2020
fa4b4c7
Merge branch 'master' into test/145_advanced_policy
kibanamachine Nov 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update names to be policy
  • Loading branch information
kevinlog committed Aug 23, 2020
commit 63f4d1ce7c0bc21f8a5e925837bb830f3a6d419a
63 changes: 34 additions & 29 deletions x-pack/plugins/security_solution/common/endpoint/index_data.ts
Original file line number Diff line number Diff line change
@@ -11,16 +11,16 @@ import { AxiosResponse } from 'axios';
import fetch from 'node-fetch';
import { EndpointDocGenerator, TreeOptions, Event } from './generate_data';
import {
CreateAgentConfigRequest,
CreateAgentConfigResponse,
CreatePackageConfigRequest,
CreatePackageConfigResponse,
CreateAgentPolicyRequest,
CreateAgentPolicyResponse,
CreatePackagePolicyRequest,
CreatePackagePolicyResponse,
GetPackagesResponse,
PostAgentEnrollRequest,
AGENT_API_ROUTES,
AGENT_CONFIG_API_ROUTES,
AGENT_POLICY_API_ROUTES,
EPM_API_ROUTES,
PACKAGE_CONFIG_API_ROUTES,
PACKAGE_POLICY_API_ROUTES,
ENROLLMENT_API_KEY_ROUTES,
GetEnrollmentAPIKeysResponse,
GetOneEnrollmentAPIKeyResponse,
@@ -49,7 +49,7 @@ export async function indexHostsAndAlerts(
const random = seedrandom(seed);
const epmEndpointPackage = await getEndpointPackageInfo(kbnClient);
// Keep a map of host applied policy ids (fake) to real ingest package configs (policy record)
const realPolicies: Record<string, CreatePackageConfigResponse['item']> = {};
const realPolicies: Record<string, CreatePackagePolicyResponse['item']> = {};

for (let i = 0; i < numHosts; i++) {
const generator = new EndpointDocGenerator(random);
@@ -82,7 +82,7 @@ async function indexHostDocs(
numDocs: number,
client: Client,
kbnClient: KbnClient,
realPolicies: Record<string, CreatePackageConfigResponse['item']>,
realPolicies: Record<string, CreatePackagePolicyResponse['item']>,
epmEndpointPackage: GetPackagesResponse['response'][0],
metadataIndex: string,
policyResponseIndex: string,
@@ -117,7 +117,7 @@ async function indexHostDocs(
enrolledAgent = await fleetEnrollAgentForHost(
kbnClient,
hostMetadata!,
realPolicies[appliedPolicyId].config_id
realPolicies[appliedPolicyId].policy_id
);
}

@@ -194,24 +194,29 @@ const createPolicy = async (
kbnClient: KbnClient,
policyName: string,
endpointPackageVersion: string
): Promise<CreatePackageConfigResponse['item']> => {
// Create Agent Configuration first
const newAgentconfigData: CreateAgentConfigRequest['body'] = {
name: `Config for ${policyName}`,
): Promise<CreatePackagePolicyResponse['item']> => {
// Create Agent Policy first
const newAgentPolicyData: CreateAgentPolicyRequest['body'] = {
name: `Policy for ${policyName}`,
description: '',
namespace: 'default',
};
const agentConfig = (await kbnClient.request({
path: AGENT_CONFIG_API_ROUTES.CREATE_PATTERN,
method: 'POST',
body: newAgentconfigData,
})) as AxiosResponse<CreateAgentConfigResponse>;
let agentPolicy;
try {
agentPolicy = (await kbnClient.request({
path: AGENT_POLICY_API_ROUTES.CREATE_PATTERN,
method: 'POST',
body: newAgentPolicyData,
})) as AxiosResponse<CreateAgentPolicyResponse>;
} catch (error) {
throw new Error(`create policy ${error}`);
}

// Create Package Configuration
const newPackageConfigData: CreatePackageConfigRequest['body'] = {
const newPackagePolicyData: CreatePackagePolicyRequest['body'] = {
name: policyName,
description: 'Protect the worlds data',
config_id: agentConfig.data.item.id,
policy_id: agentPolicy.data.item.id,
enabled: true,
output_id: '',
inputs: [
@@ -233,12 +238,12 @@ const createPolicy = async (
version: endpointPackageVersion,
},
};
const packageConfig = (await kbnClient.request({
path: PACKAGE_CONFIG_API_ROUTES.CREATE_PATTERN,
const packagePolicy = (await kbnClient.request({
path: PACKAGE_POLICY_API_ROUTES.CREATE_PATTERN,
method: 'POST',
body: newPackageConfigData,
})) as AxiosResponse<CreatePackageConfigResponse>;
return packageConfig.data.item;
body: newPackagePolicyData,
})) as AxiosResponse<CreatePackagePolicyResponse>;
return packagePolicy.data.item;
};

const getEndpointPackageInfo = async (
@@ -261,23 +266,23 @@ const getEndpointPackageInfo = async (
const fleetEnrollAgentForHost = async (
kbnClient: KbnClient,
endpointHost: HostMetadata,
agentConfigId: string
agentPolicyId: string
): Promise<undefined | PostAgentEnrollResponse['item']> => {
// Get Enrollement key for host's applied policy
const enrollmentApiKey = await kbnClient
.request<GetEnrollmentAPIKeysResponse>({
path: ENROLLMENT_API_KEY_ROUTES.LIST_PATTERN,
method: 'GET',
query: {
kuery: `fleet-enrollment-api-keys.config_id:"${agentConfigId}"`,
kuery: `fleet-enrollment-api-keys.policy_id:"${agentPolicyId}"`,
},
})
.then((apiKeysResponse) => {
const apiKey = apiKeysResponse.data.list[0];

if (!apiKey) {
return Promise.reject(
new Error(`no API enrolment key found for agent config id ${agentConfigId}`)
new Error(`no API enrolment key found for agent policy id ${agentPolicyId}`)
);
}

@@ -402,7 +407,7 @@ const fleetEnrollAgentForHost = async (
subtype: 'CONFIG',
timestamp: new Date().toISOString(),
agent_id: action.agent_id,
config_id: agentConfigId,
policy_id: agentPolicyId,
message: `endpoint generator: Endpoint Started`,
};
}),