Skip to content

Commit

Permalink
[Cloud_security] update constants usages (elastic#131305)
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenIdo authored and dmlemeshko committed May 5, 2022
1 parent 5946fe8 commit 853677f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/cloud_security_posture/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const UPDATE_RULES_CONFIG_ROUTE_PATH =

export const CLOUD_SECURITY_POSTURE_PACKAGE_NAME = 'cloud_security_posture';

export const AGENT_LOGS_INDEX_PATTERN = '.logs-cloud_security_posture.metadata*';
export const CSP_LATEST_FINDINGS_DATA_VIEW = 'logs-cloud_security_posture.findings_latest-*';
export const FINDINGS_INDEX_PATTERN = 'logs-cloud_security_posture.findings-default*';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const initializeCspTransformsIndices = async (

export const createIndexIfNotExists = async (
esClient: ElasticsearchClient,
indexName: string,
indexTemplateName: string,
indexPattern: string,
mappings: MappingTypeMapping,
logger: Logger
Expand All @@ -53,7 +53,7 @@ export const createIndexIfNotExists = async (

if (!isLatestIndexExists) {
await esClient.indices.putIndexTemplate({
name: indexName,
name: indexTemplateName,
index_patterns: indexPattern,
template: { mappings },
priority: 500,
Expand All @@ -65,7 +65,7 @@ export const createIndexIfNotExists = async (
}
} catch (err) {
const error = transformError(err);
logger.error(`Failed to create ${LATEST_FINDINGS_INDEX_DEFAULT_NS}`);
logger.error(`Failed to create the index template: ${indexTemplateName}`);
logger.error(error.message);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export const getPackagePolicy = async (
throw new Error(`package policy Id '${packagePolicyId}' is not exist`);
}
if (packagePolicies[0].package?.name !== CLOUD_SECURITY_POSTURE_PACKAGE_NAME) {
// TODO: improve this validator to support any future CSP package
throw new Error(`Package Policy Id '${packagePolicyId}' is not CSP package`);
throw new Error(
`Package Policy Id '${packagePolicyId}' is not of type cloud security posture package`
);
}

return packagePolicies![0];
Expand Down

0 comments on commit 853677f

Please sign in to comment.