mirror of
https://github.com/splunk/security_content
synced 2026-06-08 17:32:49 +00:00
new line check
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,15 @@ class Detection(BaseModel, SecurityContentObject):
|
||||
raise ValueError("name is longer then 67 chars: " + values["name"])
|
||||
return values
|
||||
|
||||
|
||||
@root_validator
|
||||
def description_new_line_check(cls, values):
|
||||
# Check if there is a new line in description that is not escaped
|
||||
pattern = r'(?<!\\)\n'
|
||||
if re.search(pattern, values["description"]):
|
||||
raise ValueError("desciption key contains new line but it is not escaped using backslash. Add backslash before a new line : " + values["name"])
|
||||
return values
|
||||
|
||||
# @validator('references')
|
||||
# def references_check(cls, v, values):
|
||||
# return LinkValidator.SecurityContentObject_validate_references(v, values)
|
||||
|
||||
Reference in New Issue
Block a user