Branch was auto-updated.

This commit is contained in:
srv-rr-gh-researchbt
2023-07-11 13:03:11 -07:00
committed by GitHub
2 changed files with 19 additions and 1 deletions
@@ -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
View File
@@ -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