66
77import { i18n } from '@kbn/i18n' ;
88
9- const responseMap = new Map ( ) ;
9+ const policyResponses : Array < [ string , string ] > = [
10+ [
11+ 'configure_dns_events' ,
12+ i18n . translate (
13+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_dns_events' ,
14+ { defaultMessage : 'Configure DNS Events' }
15+ ) ,
16+ ] ,
17+ [
18+ 'configure_elasticsearch_connection' ,
19+ i18n . translate (
20+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_elasticsearch_connection' ,
21+ { defaultMessage : 'Configure Elastic Search Connection' }
22+ ) ,
23+ ] ,
24+ [
25+ 'configure_file_events' ,
26+ i18n . translate (
27+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_file_events' ,
28+ { defaultMessage : 'Configure File Events' }
29+ ) ,
30+ ] ,
31+ [
32+ 'configure_imageload_events' ,
33+ i18n . translate (
34+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_imageload_events' ,
35+ { defaultMessage : 'Configure Image Load Events' }
36+ ) ,
37+ ] ,
38+ [
39+ 'configure_kernel' ,
40+ i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_kernel' , {
41+ defaultMessage : 'Configure Kernel' ,
42+ } ) ,
43+ ] ,
44+ [
45+ 'configure_logging' ,
46+ i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_logging' , {
47+ defaultMessage : 'Configure Logging' ,
48+ } ) ,
49+ ] ,
50+ [
51+ 'configure_malware' ,
52+ i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_malware' , {
53+ defaultMessage : 'Configure Malware' ,
54+ } ) ,
55+ ] ,
56+ [
57+ 'configure_network_events' ,
58+ i18n . translate (
59+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_network_events' ,
60+ { defaultMessage : 'Configure Network Events' }
61+ ) ,
62+ ] ,
63+ [
64+ 'configure_process_events' ,
65+ i18n . translate (
66+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_process_events' ,
67+ { defaultMessage : 'Configure Process Events' }
68+ ) ,
69+ ] ,
70+ [
71+ 'configure_registry_events' ,
72+ i18n . translate (
73+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_registry_events' ,
74+ { defaultMessage : 'Configure Registry Events' }
75+ ) ,
76+ ] ,
77+ [
78+ 'configure_security_events' ,
79+ i18n . translate (
80+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configure_security_events' ,
81+ { defaultMessage : 'Configure Security Events' }
82+ ) ,
83+ ] ,
84+ [
85+ 'connect_kernel' ,
86+ i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.connect_kernel' , {
87+ defaultMessage : 'Connect Kernel' ,
88+ } ) ,
89+ ] ,
90+ [
91+ 'detect_async_image_load_events' ,
92+ i18n . translate (
93+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_async_image_load_events' ,
94+ { defaultMessage : 'Detect Async Image Load Events' }
95+ ) ,
96+ ] ,
97+ [
98+ 'detect_file_open_events' ,
99+ i18n . translate (
100+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_file_open_events' ,
101+ { defaultMessage : 'Detect File Open Events' }
102+ ) ,
103+ ] ,
104+ [
105+ 'detect_file_write_events' ,
106+ i18n . translate (
107+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_file_write_events' ,
108+ { defaultMessage : 'Detect File Write Events' }
109+ ) ,
110+ ] ,
111+ [
112+ 'detect_network_events' ,
113+ i18n . translate (
114+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_network_events' ,
115+ { defaultMessage : 'Detect Network Events' }
116+ ) ,
117+ ] ,
118+ [
119+ 'detect_process_events' ,
120+ i18n . translate (
121+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_process_events' ,
122+ { defaultMessage : 'Detect Process Events' }
123+ ) ,
124+ ] ,
125+ [
126+ 'detect_registry_events' ,
127+ i18n . translate (
128+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_registry_events' ,
129+ { defaultMessage : 'Detect Registry Events' }
130+ ) ,
131+ ] ,
132+ [
133+ 'detect_sync_image_load_events' ,
134+ i18n . translate (
135+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detect_sync_image_load_events' ,
136+ { defaultMessage : 'Detect Sync Image Load Events' }
137+ ) ,
138+ ] ,
139+ [
140+ 'download_global_artifacts' ,
141+ i18n . translate (
142+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.download_global_artifacts' ,
143+ { defaultMessage : 'Download Global Artifacts' }
144+ ) ,
145+ ] ,
146+ [
147+ 'download_user_artifacts' ,
148+ i18n . translate (
149+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.download_user_artifacts' ,
150+ { defaultMessage : 'Download User Artifacts' }
151+ ) ,
152+ ] ,
153+ [
154+ 'load_config' ,
155+ i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.load_config' , {
156+ defaultMessage : 'Load Config' ,
157+ } ) ,
158+ ] ,
159+ [
160+ 'load_malware_model' ,
161+ i18n . translate (
162+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.load_malware_model' ,
163+ { defaultMessage : 'Load Malware Model' }
164+ ) ,
165+ ] ,
166+ [
167+ 'read_elasticsearch_config' ,
168+ i18n . translate (
169+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.read_elasticsearch_config' ,
170+ { defaultMessage : 'Read ElasticSearch Config' }
171+ ) ,
172+ ] ,
173+ [
174+ 'read_events_config' ,
175+ i18n . translate (
176+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.read_events_config' ,
177+ { defaultMessage : 'Read Events Config' }
178+ ) ,
179+ ] ,
180+ [
181+ 'read_kernel_config' ,
182+ i18n . translate (
183+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.read_kernel_config' ,
184+ { defaultMessage : 'Read Kernel Config' }
185+ ) ,
186+ ] ,
187+ [
188+ 'read_logging_config' ,
189+ i18n . translate (
190+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.read_logging_config' ,
191+ { defaultMessage : 'Read Logging Config' }
192+ ) ,
193+ ] ,
194+ [
195+ 'read_malware_config' ,
196+ i18n . translate (
197+ 'xpack.securitySolution.endpoint.hostDetails.policyResponse.read_malware_config' ,
198+ { defaultMessage : 'Read Malware Config' }
199+ ) ,
200+ ] ,
201+ [
202+ 'workflow' ,
203+ i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.workflow' , {
204+ defaultMessage : 'Workflow' ,
205+ } ) ,
206+ ] ,
207+ ] ;
208+
209+ const responseMap = new Map < string , string > ( policyResponses ) ;
210+
211+ // Additional values used in the Policy Response UI
10212responseMap . set (
11213 'success' ,
12214 i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.success' , {
@@ -49,144 +251,6 @@ responseMap.set(
49251 defaultMessage : 'Events' ,
50252 } )
51253) ;
52- responseMap . set (
53- 'configure_elasticsearch_connection' ,
54- i18n . translate (
55- 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configureElasticSearchConnection' ,
56- {
57- defaultMessage : 'Configure Elastic Search Connection' ,
58- }
59- )
60- ) ;
61- responseMap . set (
62- 'configure_logging' ,
63- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configureLogging' , {
64- defaultMessage : 'Configure Logging' ,
65- } )
66- ) ;
67- responseMap . set (
68- 'configure_kernel' ,
69- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configureKernel' , {
70- defaultMessage : 'Configure Kernel' ,
71- } )
72- ) ;
73- responseMap . set (
74- 'configure_malware' ,
75- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.configureMalware' , {
76- defaultMessage : 'Configure Malware' ,
77- } )
78- ) ;
79- responseMap . set (
80- 'connect_kernel' ,
81- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.connectKernel' , {
82- defaultMessage : 'Connect Kernel' ,
83- } )
84- ) ;
85- responseMap . set (
86- 'detect_file_open_events' ,
87- i18n . translate (
88- 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detectFileOpenEvents' ,
89- {
90- defaultMessage : 'Detect File Open Events' ,
91- }
92- )
93- ) ;
94- responseMap . set (
95- 'detect_file_write_events' ,
96- i18n . translate (
97- 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detectFileWriteEvents' ,
98- {
99- defaultMessage : 'Detect File Write Events' ,
100- }
101- )
102- ) ;
103- responseMap . set (
104- 'detect_image_load_events' ,
105- i18n . translate (
106- 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detectImageLoadEvents' ,
107- {
108- defaultMessage : 'Detect Image Load Events' ,
109- }
110- )
111- ) ;
112- responseMap . set (
113- 'detect_process_events' ,
114- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.detectProcessEvents' , {
115- defaultMessage : 'Detect Process Events' ,
116- } )
117- ) ;
118- responseMap . set (
119- 'download_global_artifacts' ,
120- i18n . translate (
121- 'xpack.securitySolution.endpoint.hostDetails.policyResponse.downloadGlobalArtifacts' ,
122- {
123- defaultMessage : 'Download Global Artifacts' ,
124- }
125- )
126- ) ;
127- responseMap . set (
128- 'load_config' ,
129- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.loadConfig' , {
130- defaultMessage : 'Load Config' ,
131- } )
132- ) ;
133- responseMap . set (
134- 'load_malware_model' ,
135- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.loadMalwareModel' , {
136- defaultMessage : 'Load Malware Model' ,
137- } )
138- ) ;
139- responseMap . set (
140- 'read_elasticsearch_config' ,
141- i18n . translate (
142- 'xpack.securitySolution.endpoint.hostDetails.policyResponse.readElasticSearchConfig' ,
143- {
144- defaultMessage : 'Read ElasticSearch Config' ,
145- }
146- )
147- ) ;
148- responseMap . set (
149- 'read_events_config' ,
150- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.readEventsConfig' , {
151- defaultMessage : 'Read Events Config' ,
152- } )
153- ) ;
154- responseMap . set (
155- 'read_kernel_config' ,
156- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.readKernelConfig' , {
157- defaultMessage : 'Read Kernel Config' ,
158- } )
159- ) ;
160- responseMap . set (
161- 'read_logging_config' ,
162- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.readLoggingConfig' , {
163- defaultMessage : 'Read Logging Config' ,
164- } )
165- ) ;
166- responseMap . set (
167- 'read_malware_config' ,
168- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.readMalwareConfig' , {
169- defaultMessage : 'Read Malware Config' ,
170- } )
171- ) ;
172- responseMap . set (
173- 'workflow' ,
174- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.workflow' , {
175- defaultMessage : 'Workflow' ,
176- } )
177- ) ;
178- responseMap . set (
179- 'download_model' ,
180- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.downloadModel' , {
181- defaultMessage : 'Download Model' ,
182- } )
183- ) ;
184- responseMap . set (
185- 'ingest_events_config' ,
186- i18n . translate ( 'xpack.securitySolution.endpoint.hostDetails.policyResponse.injestEventsConfig' , {
187- defaultMessage : 'Injest Events Config' ,
188- } )
189- ) ;
190254
191255/**
192256 * Maps a server provided value to corresponding i18n'd string.
@@ -195,5 +259,13 @@ export function formatResponse(responseString: string) {
195259 if ( responseMap . has ( responseString ) ) {
196260 return responseMap . get ( responseString ) ;
197261 }
198- return responseString ;
262+
263+ // Its possible for the UI to receive an Action name that it does not yet have a translation,
264+ // thus we generate a label for it here by making it more user fiendly
265+ responseMap . set (
266+ responseString ,
267+ responseString . replace ( / _ / g, ' ' ) . replace ( / \b ( \w ) / g, ( m ) => m . toUpperCase ( ) )
268+ ) ;
269+
270+ return responseMap . get ( responseString ) ;
199271}
0 commit comments