Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation checks improvements #33

Closed
patel-bhavin opened this issue Jul 28, 2023 · 1 comment · Fixed by #34
Closed

Validation checks improvements #33

patel-bhavin opened this issue Jul 28, 2023 · 1 comment · Fixed by #34
Assignees
Labels
enhancement New feature or request WIP

Comments

@patel-bhavin
Copy link
Contributor

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
@pyth0n1c
Copy link
Contributor

Thank you Bhavin - I am tracking these updates and more in the following Pull Request:
#34

@pyth0n1c pyth0n1c self-assigned this Jul 31, 2023
@pyth0n1c pyth0n1c added WIP enhancement New feature or request labels Jul 31, 2023
@pyth0n1c pyth0n1c linked a pull request Jul 31, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request WIP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants