mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Cloud Posture] Remove postCreateHook for creating the cfg data.yaml (#144006)
[Cloud Posture] Remove postCreate hook
This commit is contained in:
parent
88a8bd470c
commit
e12371d884
3 changed files with 6 additions and 26 deletions
|
@ -24,7 +24,7 @@ setting up your development environment.
|
|||
Kibana has a pretty long CI process.
|
||||
Therefore, we suggest running the following commands locally before creating a PR:
|
||||
|
||||
1. Typescript check: `node_modules/.bin/tsc -b x-pack/plugins/cloud_security_posture/tsconfig.json --pretty`
|
||||
1. Typescript check: `node scripts/type_check.js --project=x-pack/plugins/cloud_security_posture/tsconfig.json`
|
||||
2. Linter check: `yarn lint:es x-pack/plugins/cloud_security_posture`
|
||||
3. Unit tests: `yarn jest --config x-pack/plugins/cloud_security_posture/jest.config.js`
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ describe('Cloud Security Posture Plugin', () => {
|
|||
expect(spy).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('packagePolicyPostCreate should return the updated packagePolicy', async () => {
|
||||
it('packagePolicyPostCreate should return the same received policy', async () => {
|
||||
fleetMock.packageService.asInternalUser.getInstallation.mockImplementationOnce(
|
||||
async (): Promise<Installation | undefined> => {
|
||||
return;
|
||||
|
@ -272,13 +272,9 @@ describe('Cloud Security Posture Plugin', () => {
|
|||
contextMock,
|
||||
httpServerMock.createKibanaRequest()
|
||||
);
|
||||
if (fleetMock.packagePolicyService.update.mock.calls.length) {
|
||||
expect(updatedPackagePolicy).toHaveProperty('vars');
|
||||
expect(updatedPackagePolicy.vars).toHaveProperty('runtimeCfg');
|
||||
expect(updatedPackagePolicy.vars!.runtimeCfg).toHaveProperty('value');
|
||||
}
|
||||
expect(updatedPackagePolicy).toEqual(packageMock);
|
||||
}
|
||||
expect(fleetMock.packagePolicyService.update).toHaveBeenCalledTimes(1);
|
||||
expect(fleetMock.packagePolicyService.update).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should uninstall resources when package is removed', async () => {
|
||||
|
|
|
@ -43,10 +43,6 @@ import {
|
|||
removeCspRulesInstancesCallback,
|
||||
} from './fleet_integration/fleet_integration';
|
||||
import { CLOUD_SECURITY_POSTURE_PACKAGE_NAME } from '../common/constants';
|
||||
import {
|
||||
updatePackagePolicyRuntimeCfgVar,
|
||||
getCspRulesSO,
|
||||
} from './routes/configuration/update_rules_configuration';
|
||||
import {
|
||||
removeFindingsStatsTask,
|
||||
scheduleFindingsStatsTask,
|
||||
|
@ -127,27 +123,15 @@ export class CspPlugin
|
|||
async (
|
||||
packagePolicy: PackagePolicy,
|
||||
context: RequestHandlerContext,
|
||||
request: KibanaRequest
|
||||
_: KibanaRequest
|
||||
): Promise<PackagePolicy> => {
|
||||
if (isCspPackage(packagePolicy.package?.name)) {
|
||||
await this.initialize(core, plugins.taskManager);
|
||||
|
||||
const soClient = (await context.core).savedObjects.client;
|
||||
const esClient = (await context.core).elasticsearch.client.asCurrentUser;
|
||||
const user = await plugins.security.authc.getCurrentUser(request);
|
||||
|
||||
await onPackagePolicyPostCreateCallback(this.logger, packagePolicy, soClient);
|
||||
|
||||
const updatedPackagePolicy = await updatePackagePolicyRuntimeCfgVar({
|
||||
rules: await getCspRulesSO(soClient, packagePolicy.id, packagePolicy.policy_id),
|
||||
packagePolicy,
|
||||
packagePolicyService: plugins.fleet.packagePolicyService,
|
||||
esClient,
|
||||
soClient,
|
||||
user,
|
||||
});
|
||||
|
||||
return updatedPackagePolicy;
|
||||
return packagePolicy;
|
||||
}
|
||||
|
||||
return packagePolicy;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue