Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/scripts/check_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,31 @@
import xml.etree.ElementTree as ET


def _confine(candidate: str, base: str) -> str:
"""Resolve candidate and confirm it stays within base, rejecting path traversal."""
resolved = os.path.realpath(candidate)
if resolved != base and not resolved.startswith(base + os.sep):
raise ValueError(f"Refusing path outside {base}: {candidate}")
return resolved


def main() -> int:
results_dir, floor = sys.argv[1], float(sys.argv[2])
reports = glob.glob(os.path.join(results_dir, "**", "coverage.cobertura.xml"), recursive=True)
base = os.path.realpath(os.getcwd())
try:
safe_results_dir = _confine(results_dir, base)
except ValueError as error:
print(error, file=sys.stderr)
return 1

reports = glob.glob(os.path.join(safe_results_dir, "**", "coverage.cobertura.xml"), recursive=True)
if not reports:
print(f"No coverage.cobertura.xml found under {results_dir}", file=sys.stderr)
return 1

hits: dict[tuple[str, str], int] = {}
for report in reports:
root = ET.parse(report).getroot()
root = ET.parse(_confine(report, base)).getroot()
for class_node in root.iter("class"):
filename = class_node.get("filename", "")
for line in class_node.iter("line"):
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- name: Fetch Dependabot metadata
id: meta
uses: dependabot/fetch-metadata@v3
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:

- name: Detect breaking API changes
if: steps.base-spec.outputs.exists == 'true'
uses: oasdiff/oasdiff-action/breaking@v0
uses: oasdiff/oasdiff-action/breaking@024f6c399f9a21ada1addb0f9a36ce1bfac995f1 # v0.1.6
with:
base: "origin/${{ github.base_ref }}:src/Orbit.Api/openapi.json"
revision: "src/Orbit.Api/openapi.json"
Expand Down
Loading