(
connection: sqlite3.Connection,
scan: sqlite3.Row,
occurrence: sqlite3.Row,
)
| 3273 | |
| 3274 | |
| 3275 | def finding_result( |
| 3276 | connection: sqlite3.Connection, |
| 3277 | scan: sqlite3.Row, |
| 3278 | occurrence: sqlite3.Row, |
| 3279 | ) -> dict[str, Any]: |
| 3280 | details = bounded_finding_details(read_finding_details(occurrence["details_json"])) |
| 3281 | confidence = details.get("confidence") |
| 3282 | confidence = confidence if isinstance(confidence, dict) else {} |
| 3283 | severity = details.get("severity") |
| 3284 | severity = severity if isinstance(severity, dict) else {} |
| 3285 | locations = [] |
| 3286 | try: |
| 3287 | target = require_scan_target_identity(scan) |
| 3288 | except SystemExit: |
| 3289 | target = None |
| 3290 | for row in connection.execute( |
| 3291 | """ |
| 3292 | SELECT relative_path, start_line, end_line, role |
| 3293 | FROM finding_locations |
| 3294 | WHERE occurrence_id = ? |
| 3295 | ORDER BY CASE WHEN role = 'root_control' THEN 0 ELSE 1 END, sort_order |
| 3296 | LIMIT ? |
| 3297 | """, |
| 3298 | (occurrence["id"], FINDING_LOCATIONS_LIMIT), |
| 3299 | ): |
| 3300 | absolute_path = safe_source_path(target, row["relative_path"]) if target else None |
| 3301 | location = { |
| 3302 | "endLine": row["end_line"], |
| 3303 | "path": bounded_output_text(row["relative_path"], FINDING_LOCATION_PATH_BYTES), |
| 3304 | "role": ( |
| 3305 | bounded_output_text(row["role"], FINDING_LOCATION_ROLE_BYTES) |
| 3306 | if row["role"] is not None |
| 3307 | else None |
| 3308 | ), |
| 3309 | "startLine": row["start_line"], |
| 3310 | } |
| 3311 | if absolute_path is not None: |
| 3312 | location["absolutePath"] = bounded_output_text( |
| 3313 | absolute_path, FINDING_ABSOLUTE_PATH_BYTES |
| 3314 | ) |
| 3315 | locations.append(location) |
| 3316 | result = { |
| 3317 | **details, |
| 3318 | "confidence": { |
| 3319 | **confidence, |
| 3320 | "level": bounded_output_text(occurrence["confidence"], FINDING_LEVEL_BYTES), |
| 3321 | }, |
| 3322 | "createdAt": occurrence["created_at"], |
| 3323 | "findingId": occurrence["finding_id"], |
| 3324 | "locations": locations, |
| 3325 | "occurrenceId": occurrence["id"], |
| 3326 | "remediationState": finding_remediation_result(connection, occurrence["id"]), |
| 3327 | "remediation": bounded_output_text(occurrence["remediation"], FINDING_REMEDIATION_BYTES), |
| 3328 | "severity": { |
| 3329 | **severity, |
| 3330 | "level": bounded_output_text(occurrence["severity"], FINDING_LEVEL_BYTES), |
| 3331 | }, |
| 3332 | "summary": bounded_output_text(occurrence["summary"], FINDING_SUMMARY_BYTES), |
no test coverage detected