Skip to content

Commit

Permalink
refactor: 🔨 Fix SNYK Insecure Xml Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
frack113 committed Jan 28, 2024
1 parent e053841 commit b069562
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions print-coverage.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Prints code testing coverage as percentage for badge generation.
import xml.etree.ElementTree as et

tree = et.parse("cov.xml")
root = tree.getroot()
coverage = float(root.attrib["line-rate"]) * 100
print(f"COVERAGE={coverage:3.4}%")
if coverage >= 95.0:
print("COVERAGE_COLOR=green")
elif coverage >= 90.0:
print("COVERAGE_COLOR=yellow")
elif coverage >= 85.0:
print("COVERAGE_COLOR=orange")
else:
print("COVERAGE_COLOR=red")
# Prints code testing coverage as percentage for badge generation.
from defusedxml.ElementTree import parse

tree = parse("cov.xml")
root = tree.getroot()
coverage = float(root.attrib["line-rate"]) * 100
print(f"COVERAGE={coverage:3.4}%")
if coverage >= 95.0:
print("COVERAGE_COLOR=green")
elif coverage >= 90.0:
print("COVERAGE_COLOR=yellow")
elif coverage >= 85.0:
print("COVERAGE_COLOR=orange")
else:
print("COVERAGE_COLOR=red")
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ pysigma = "^0.11"

[tool.poetry.dev-dependencies]
black = "^24.1"
defusedxml = "^0.7"

[tool.poetry.group.dev.dependencies]
coverage = "^7.4"
pytest = "^8.0"
pytest-cov = "^4.1"
coverage = "^7.4"

[build-system]
requires = ["poetry-core>=1.8.1"]
Expand Down

0 comments on commit b069562

Please sign in to comment.