@extends('layouts.app') @section('title', '源碼掃描報告') @section('content')
等待輸出…
{{ $codeScan->error_log }}
| 嚴重度 | 問題描述 | 檔案位置 | OWASP / CVE | |
|---|---|---|---|---|
|
{{ strtoupper($sev) }}
@if($codeScan->scanner_type === 'sonarqube')
{{ $typeLabel }} @endif |
{{ Str::limit($f['name'] ?? '—', 80) }}
@if(!empty($f['template_id']))
{{ $f['template_id'] }}
@endif
|
{{ $f['file'] ?? $f['matched_at'] ?? '—' }}
@if(!empty($f['line'])) :{{ $f['line'] }} @endif
@if(!empty($f['code']))
{{ $f['code'] }}
@endif
|
@foreach((array)($f['owasp']??[]) as $oid) {{ $oid }} @endforeach @foreach((array)($f['cve_id']??[]) as $cid) {{ $cid }} @endforeach | |
|
{{-- 欄1:檔案位置 + 程式碼片段 --}}
檔案位置
{{ $f['file'] ?? $f['matched_at'] ?? '—' }}
@if(!empty($f['line']))
第 {{ $f['line'] }} 行
@endif
{{-- 程式碼片段 --}}
@if(!empty($f['code']))
程式碼片段
{{ $f['code'] }}
程式碼片段
問題說明
{{ $f['description'] ?: $f['name'] }} 解決方式
@php $ruleKey = $f['extra']['rule'] ?? ''; $ruleDetail = $sonarRules[$ruleKey] ?? null; @endphp
@if(!empty($f['remediation']))
{{ $f['remediation'] }}
@elseif($ruleDetail)
{{-- SonarQube 官方建議:直接顯示中文說明 --}}
@foreach($ruleDetail['sections'] as $sec)
@if(in_array($sec['label'], ['問題根因','修復方式']))
{{ $sec['label'] }}
@endif
@endforeach
@if($ruleDetail['effort'])
@if(!empty($sec['zh'])) {{ $sec['zh'] }} @endif 修復耗時 {{ $ruleDetail['effort'] }}
@endif
@elseif(!empty($f['extra']['fix']))
{{ $f['extra']['fix'] }}
@else
尚無建議
@endif
@php
// SonarQube:優先用 rule 的外部參考連結,過濾掉 localhost
$displayRefs = [];
if ($codeScan->scanner_type === 'sonarqube' && !empty($ruleDetail['references'])) {
$displayRefs = $ruleDetail['references'];
} else {
foreach ((array)($f['reference'] ?? []) as $ref) {
if (!str_contains($ref, 'localhost')) {
$displayRefs[] = ['url' => $ref, 'label' => $ref];
}
}
}
@endphp
@if(!empty($displayRefs))
參考資料
@foreach(array_slice($displayRefs, 0, 5) as $ref)
@php $refUrl = is_array($ref) ? $ref['url'] : $ref; $refLabel = is_array($ref) ? $ref['label'] : $ref; @endphp
{{ $refLabel }}
@endforeach
@endif
@if(!empty($f['owasp']))
OWASP
@foreach((array)$f['owasp'] as $oid)
{{ $oid }}
@endforeach
@endif
@if(!empty($f['extra']['cwe']))
CWE
@foreach((array)$f['extra']['cwe'] as $c)
{{ $c }}
@endforeach
@endif
@if(!empty($f['extra']['cvss_score'])) CVSS:{{ $f['extra']['cvss_score'] }}
@endif @if(!empty($f['extra']['package'])) 套件:{{ $f['extra']['package'] }}@{{ $f['extra']['installed_ver']??'' }}@if(!empty($f['extra']['fixed_ver'])) → {{ $f['extra']['fixed_ver'] }}@endif @endif @if(!empty($f['extra']['rule_id'])) Rule:{{ $f['extra']['rule_id'] }} @endif |
||||