Skip to content

Commit

Permalink
fix summary, desc, and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Oct 4, 2023
1 parent 71cc68a commit 6ac3925
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/core_codemods/lxml_safe_parser_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

class LxmlSafeParserDefaults(SemgrepCodemod):
NAME = "safe-lxml-parser-defaults"
REVIEW_GUIDANCE = ReviewGuidance.MERGE_AFTER_CURSORY_REVIEW
SUMMARY = "Enable all security checks in `lxml.etree.XMLParser` call."
DESCRIPTION = "...........TODO"
REVIEW_GUIDANCE = ReviewGuidance.MERGE_WITHOUT_REVIEW
SUMMARY = "Use safe defaults for lxml parsers"
DESCRIPTION = "Replace lxml parser parameters with safe defaults"

@classmethod
def rule(cls):
Expand Down
17 changes: 16 additions & 1 deletion tests/codemods/test_lxml_safe_parameter_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)


class TestJwtDecodeVerify(BaseSemgrepCodemodTest):
class TestLxmlSafeParserDefaults(BaseSemgrepCodemodTest):
codemod = LxmlSafeParserDefaults

def test_name(self):
Expand Down Expand Up @@ -39,6 +39,21 @@ def test_from_import(self, tmpdir, klass):
parser = {klass}(resolve_entities=False)
var = "hello"
"""

self.run_and_assert(tmpdir, input_code, expexted_output)

@each_class
def test_from_import_module(self, tmpdir, klass):
input_code = f"""from lxml import etree
parser = etree.{klass}()
var = "hello"
"""
expexted_output = f"""from lxml import etree
parser = etree.{klass}(resolve_entities=False)
var = "hello"
"""

self.run_and_assert(tmpdir, input_code, expexted_output)
Expand Down

0 comments on commit 6ac3925

Please sign in to comment.