T09 · Insecure Skill Coding Practices
- Location
src/core.py:22- Finding
Quality-Gate Policy Bypass Through Unvalidated Thresholds
- Content
View full analysis
Vulnerability Details
File Location:
src/models.py:12-18,src/models.py:49-52,src/core.py:22-36, andsrc/core.py:66-83
Vulnerability Type: Improper input validation and fail-open policy evaluation
Risk Level: MediumVulnerable Code
python @dataclass class CoverageMetrics: """Coverage metrics data.""" line_coverage: float branch_coverage: float function_coverage: float target_line: float = 80.0 target_branch: float = 70.0 target_function: float = 80.0python unit_tests: List[str] = field(default_factory=list) integration_tests: List[str] = field(default_factory=list) e2e_tests: List[str] = field(default_factory=list) min_test_count: int = 1python for name, (value, target) in checks.items(): ratio = (value / target) if target > 0 else 0.0 ratios.append(min(ratio, 1.0)) passed = value >= target if not passed: all_passed = False details[name] = { "value": value, "target": target, "passed": passed, "ratio": round(ratio, 4), }python total = strategy.total_tests() has_unit = len(strategy.unit_tests) > 0 meets_min = total >= strategy.min_test_count layers_present = sum([ len(strategy.unit_tests) > 0, len(strategy.integration_tests) > 0, len(strategy.e2e_tests) > 0, ]) details = { "total_tests": total, "min_test_count": strategy.min_test_count, "meets_min_count": meets_min, "has_unit_tests": has_unit, "has_integration_tests": len(strategy.integration_tests) > 0, "has_e2e_tests": len(strategy.e2e_tests) > 0, "layers_present": layers_present, } passed = meets_min and has_unit ratio = min(total / strategy.min_test_count, 1.0) if strategy.min_test_count > 0 else 1.0Technical Analysis
The data models accept coverage values, coverage targets, and minimum test co ...[truncated 1887 chars]
- Remediation
View remediation
Remediation Suggestions
- Add validation in
CoverageMetrics.__post_init__()requiring all coverage values and targets to be finite numeric values in the range0through100. - Require coverage targets to be strictly positive if a zero target is not an explicitly supported policy.
- Add validation in
TestStrategy.__post_init__()requiringmin_test_countto be an integer of at least1. - Reject booleans, strings, non-finite floats, and other values that only incidentally support comparisons.
- Validate that all test collections are lists of non-empty strings.
- Treat invalid configuration as a failed gate result or raise a documented validation exception before evaluation.
- Replace tests that expect negative thresholds to pass with tests asserting that invalid thresholds are rejected.
- Add validation in
