mirror of
https://github.com/splunk/security_content
synced 2026-06-08 17:32:49 +00:00
Branch was auto-updated.
This commit is contained in:
@@ -6,6 +6,7 @@ from pydantic import BaseModel, validator, root_validator
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Union
|
||||
import re
|
||||
|
||||
|
||||
from bin.contentctl_project.contentctl_core.domain.entities.security_content_object import (
|
||||
@@ -139,6 +140,23 @@ class Detection(BaseModel, SecurityContentObject):
|
||||
raise ValueError("name is longer then 67 chars: " + values["name"])
|
||||
return values
|
||||
|
||||
|
||||
@root_validator
|
||||
def new_line_check(cls, values):
|
||||
# Check if there is a new line in description and how to implement that is not escaped
|
||||
pattern = r'(?<!\\)\n'
|
||||
if re.search(pattern, values["description"]):
|
||||
match_obj = re.search(pattern,values["description"])
|
||||
words = values["description"][:match_obj.span()[0]].split()[-10:]
|
||||
newline_context = ' '.join(words)
|
||||
raise ValueError(f"Field named 'description' contains new line that is not escaped using backslash. Add backslash at the end of the line after the words: '{newline_context}' in '{values['name']}'")
|
||||
if re.search(pattern, values["how_to_implement"]):
|
||||
match_obj = re.search(pattern,values["how_to_implement"])
|
||||
words = values["how_to_implement"][:match_obj.span()[0]].split()[-10:]
|
||||
newline_context = ' '.join(words)
|
||||
raise ValueError(f"Field named 'how_to_implement' contains new line that is not escaped using backslash. Add backslash at the end of the line after the words: '{newline_context}' in '{values['name']}'")
|
||||
return values
|
||||
|
||||
# @validator('references')
|
||||
# def references_check(cls, v, values):
|
||||
# return LinkValidator.SecurityContentObject_validate_references(v, values)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ pycvesearch==1.2
|
||||
pydantic==1.10.8
|
||||
pysigma==0.9.8
|
||||
pysigma-backend-splunk==1.0.2
|
||||
pytest==7.3.1
|
||||
pytest==7.4.0
|
||||
PyYAML>=5.4.1
|
||||
questionary==1.10.0
|
||||
requests==2.31.0
|
||||
|
||||
Reference in New Issue
Block a user