Skip to content

Validation checks improvements #33

@patel-bhavin

Description

@patel-bhavin

Add a function to check if values of observables are in the SPL and risk_message in detection.py

Example:

        if "deprecated" not in values["file_path"] and "endpoint" in values["file_path"]:
            for observable_key, observable_value in values["tags"]:
                if observable_key == "observable":
                    for entry in observable_value:
                        if entry["name"] not in values["search"]:
                            print (values["search_name"])
                else:
                    continue
        return values

###Add a function to check description and howtoimplement that has a escaped new line using \

```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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions