@@ -93,32 +93,33 @@ def addContentToDictMappings(self, content: SecurityContentObject):
93
93
94
94
95
95
class Colors :
96
- HEADER = ' \033 [95m'
97
- BLUE = ' \033 [94m'
98
- CYAN = ' \033 [96m'
99
- GREEN = ' \033 [92m'
100
- YELLOW = ' \033 [93m'
101
- RED = ' \033 [91m'
102
- BOLD = ' \033 [1m'
103
- UNDERLINE = ' \033 [4m'
104
- END = ' \033 [0m'
105
- MAGENTA = ' \033 [35m'
106
- BRIGHT_MAGENTA = ' \033 [95m'
96
+ HEADER = " \033 [95m"
97
+ BLUE = " \033 [94m"
98
+ CYAN = " \033 [96m"
99
+ GREEN = " \033 [92m"
100
+ YELLOW = " \033 [93m"
101
+ RED = " \033 [91m"
102
+ BOLD = " \033 [1m"
103
+ UNDERLINE = " \033 [4m"
104
+ END = " \033 [0m"
105
+ MAGENTA = " \033 [35m"
106
+ BRIGHT_MAGENTA = " \033 [95m"
107
107
108
108
# Add fallback symbols for Windows
109
- CHECK_MARK = '✓' if sys .platform != ' win32' else '*'
110
- WARNING = '⚠️' if sys .platform != ' win32' else '!'
111
- ERROR = '❌' if sys .platform != ' win32' else 'X'
112
- ARROW = '🎯' if sys .platform != ' win32' else '>'
113
- TOOLS = '🛠️' if sys .platform != ' win32' else '#'
114
- DOCS = '📚' if sys .platform != ' win32' else '?'
115
- BULB = '💡' if sys .platform != ' win32' else 'i'
116
- SEARCH = '🔍' if sys .platform != ' win32' else '@'
117
- ZAP = '⚡' if sys .platform != ' win32' else '!'
109
+ CHECK_MARK = "✓" if sys .platform != " win32" else "*"
110
+ WARNING = "⚠️" if sys .platform != " win32" else "!"
111
+ ERROR = "❌" if sys .platform != " win32" else "X"
112
+ ARROW = "🎯" if sys .platform != " win32" else ">"
113
+ TOOLS = "🛠️" if sys .platform != " win32" else "#"
114
+ DOCS = "📚" if sys .platform != " win32" else "?"
115
+ BULB = "💡" if sys .platform != " win32" else "i"
116
+ SEARCH = "🔍" if sys .platform != " win32" else "@"
117
+ ZAP = "⚡" if sys .platform != " win32" else "!"
118
118
119
119
120
120
class ValidationFailedError (Exception ):
121
- """Custom exception for validation failures that already have formatted output"""
121
+ """Custom exception for validation failures that already have formatted output."""
122
+
122
123
def __init__ (self , message : str ):
123
124
self .message = message
124
125
super ().__init__ (message )
@@ -144,8 +145,9 @@ def execute(self, input_dto: validate) -> None:
144
145
self .createSecurityContent (SecurityContentType .detections )
145
146
self .createSecurityContent (SecurityContentType .dashboards )
146
147
147
- from contentctl .objects .abstract_security_content_objects .detection_abstract import \
148
- MISSING_SOURCES
148
+ from contentctl .objects .abstract_security_content_objects .detection_abstract import (
149
+ MISSING_SOURCES ,
150
+ )
149
151
150
152
if len (MISSING_SOURCES ) > 0 :
151
153
missing_sources_string = "\n 🟡 " .join (sorted (list (MISSING_SOURCES )))
@@ -289,41 +291,59 @@ def createSecurityContent(self, contentType: SecurityContentType) -> None:
289
291
if len (validation_errors ) > 0 :
290
292
print ("\n " ) # Clean separation
291
293
print (f"{ Colors .BOLD } { Colors .BRIGHT_MAGENTA } ╔{ '═' * 60 } ╗{ Colors .END } " )
292
- print (f"{ Colors .BOLD } { Colors .BRIGHT_MAGENTA } ║{ Colors .BLUE } { f'{ Colors .SEARCH } Content Validation Summary' :^60} { Colors .BRIGHT_MAGENTA } ║{ Colors .END } " )
294
+ print (
295
+ f"{ Colors .BOLD } { Colors .BRIGHT_MAGENTA } ║{ Colors .BLUE } { f'{ Colors .SEARCH } Content Validation Summary' :^60} { Colors .BRIGHT_MAGENTA } ║{ Colors .END } "
296
+ )
293
297
print (f"{ Colors .BOLD } { Colors .BRIGHT_MAGENTA } ╚{ '═' * 60 } ╝{ Colors .END } \n " )
294
298
295
- print (f"{ Colors .BOLD } { Colors .GREEN } ✨ Validation Completed{ Colors .END } – Issues detected in { Colors .RED } { Colors .BOLD } { len (validation_errors )} { Colors .END } files.\n " )
299
+ print (
300
+ f"{ Colors .BOLD } { Colors .GREEN } ✨ Validation Completed{ Colors .END } – Issues detected in { Colors .RED } { Colors .BOLD } { len (validation_errors )} { Colors .END } files.\n "
301
+ )
296
302
297
303
for index , entry in enumerate (validation_errors , 1 ):
298
304
file_path , error = entry
299
305
width = max (70 , len (str (file_path )) + 15 )
300
-
306
+
301
307
# File header with numbered emoji
302
308
number_emoji = f"{ index } ️⃣"
303
309
print (f"{ Colors .YELLOW } ┏{ '━' * width } ┓{ Colors .END } " )
304
- print (f"{ Colors .YELLOW } ┃{ Colors .BOLD } { number_emoji } File: { Colors .CYAN } { file_path } { Colors .END } { ' ' * (width - len (str (file_path )) - 12 )} { Colors .YELLOW } ┃{ Colors .END } " )
310
+ print (
311
+ f"{ Colors .YELLOW } ┃{ Colors .BOLD } { number_emoji } File: { Colors .CYAN } { file_path } { Colors .END } { ' ' * (width - len (str (file_path )) - 12 )} { Colors .YELLOW } ┃{ Colors .END } "
312
+ )
305
313
print (f"{ Colors .YELLOW } ┗{ '━' * width } ┛{ Colors .END } " )
306
-
307
- print (f" { Colors .RED } { Colors .BOLD } { Colors .ZAP } Validation Issues:{ Colors .END } " )
314
+
315
+ print (
316
+ f" { Colors .RED } { Colors .BOLD } { Colors .ZAP } Validation Issues:{ Colors .END } "
317
+ )
308
318
309
319
if isinstance (error , ValidationError ):
310
320
for err in error .errors ():
311
321
error_msg = err .get ("msg" , "" )
312
322
if "https://errors.pydantic.dev" in error_msg :
313
323
continue
314
-
324
+
315
325
# Clean error categorization
316
326
if "Field required" in error_msg :
317
- print (f" { Colors .YELLOW } { Colors .WARNING } Field Required: { err .get ('loc' , ['' ])[0 ]} { Colors .END } " )
327
+ print (
328
+ f" { Colors .YELLOW } { Colors .WARNING } Field Required: { err .get ('loc' , ['' ])[0 ]} { Colors .END } "
329
+ )
318
330
elif "Input should be" in error_msg :
319
- print (f" { Colors .MAGENTA } { Colors .ARROW } Invalid Value for { err .get ('loc' , ['' ])[0 ]} { Colors .END } " )
331
+ print (
332
+ f" { Colors .MAGENTA } { Colors .ARROW } Invalid Value for { err .get ('loc' , ['' ])[0 ]} { Colors .END } "
333
+ )
320
334
if "permitted values:" in error_msg :
321
- options = error_msg .split ("permitted values:" )[- 1 ].strip ()
335
+ options = error_msg .split ("permitted values:" )[
336
+ - 1
337
+ ].strip ()
322
338
print (f" Valid options: { options } " )
323
339
elif "Extra inputs" in error_msg :
324
- print (f" { Colors .BLUE } ❌ Unexpected Field: { err .get ('loc' , ['' ])[0 ]} { Colors .END } " )
340
+ print (
341
+ f" { Colors .BLUE } ❌ Unexpected Field: { err .get ('loc' , ['' ])[0 ]} { Colors .END } "
342
+ )
325
343
elif "Failed to find" in error_msg :
326
- print (f" { Colors .RED } 🔍 Missing Reference: { error_msg } { Colors .END } " )
344
+ print (
345
+ f" { Colors .RED } 🔍 Missing Reference: { error_msg } { Colors .END } "
346
+ )
327
347
else :
328
348
print (f" { Colors .RED } ❌ { error_msg } { Colors .END } " )
329
349
else :
@@ -333,14 +353,26 @@ def createSecurityContent(self, contentType: SecurityContentType) -> None:
333
353
# Clean footer with next steps
334
354
max_width = max (60 , max (len (str (e [0 ])) + 15 for e in validation_errors ))
335
355
print (f"{ Colors .BOLD } { Colors .CYAN } ╔{ '═' * max_width } ╗{ Colors .END } " )
336
- print (f"{ Colors .BOLD } { Colors .CYAN } ║{ Colors .BLUE } { '🎯 Next Steps' :^{max_width }} { Colors .CYAN } ║{ Colors .END } " )
356
+ print (
357
+ f"{ Colors .BOLD } { Colors .CYAN } ║{ Colors .BLUE } { '🎯 Next Steps' :^{max_width }} { Colors .CYAN } ║{ Colors .END } "
358
+ )
337
359
print (f"{ Colors .BOLD } { Colors .CYAN } ╚{ '═' * max_width } ╝{ Colors .END } \n " )
338
360
339
- print (f"{ Colors .GREEN } { Colors .TOOLS } Fix the validation issues in the listed files{ Colors .END } " )
340
- print (f"{ Colors .YELLOW } { Colors .DOCS } Check the documentation: { Colors .UNDERLINE } https://github.com/splunk/contentctl{ Colors .END } " )
341
- print (f"{ Colors .BLUE } { Colors .BULB } Use --verbose for detailed error information{ Colors .END } \n " )
342
-
343
- raise ValidationFailedError (f"Validation failed with { len (validation_errors )} error(s)" )
361
+ print (
362
+ f"{ Colors .GREEN } { Colors .TOOLS } Fix the validation issues in the listed files{ Colors .END } "
363
+ )
364
+ print (
365
+ f"{ Colors .YELLOW } { Colors .DOCS } Check the documentation: { Colors .UNDERLINE } https://github.com/splunk/contentctl{ Colors .END } "
366
+ )
367
+ print (
368
+ f"{ Colors .BLUE } { Colors .BULB } Use --verbose for detailed error information{ Colors .END } \n "
369
+ )
370
+
371
+ raise ValidationFailedError (
372
+ f"Validation failed with { len (validation_errors )} error(s)"
373
+ )
344
374
345
375
# Success case
346
- print (f"\r { f'{ contentType .name .upper ()} Progress' .rjust (23 )} : [{ progress_percent :3.0f} %]... { Colors .GREEN } { Colors .CHECK_MARK } Done!{ Colors .END } " )
376
+ print (
377
+ f"\r { f'{ contentType .name .upper ()} Progress' .rjust (23 )} : [{ progress_percent :3.0f} %]... { Colors .GREEN } { Colors .CHECK_MARK } Done!{ Colors .END } "
378
+ )
0 commit comments