package cd.casic.ci.process.dto.req.sast;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SastVulInfoReq {
    private String id;
    private String name;
    /**
     * UN_KNOWN("未知"),
     *     DEADLY("严重"),
     *     SEVERITY("高危"),
     *     POOR_RISK("中危"),
     *     LOW_RISK("低危"),
     *     SAFE("安全");
     * */
    private String severity;
    private int count;
    private List<DefectDetail> defectDetails = new ArrayList<>();

    // 便捷方法
    public void addDefectDetail(DefectDetail detail) {
        if (defectDetails == null) {
            defectDetails = new ArrayList<>();
        }
        defectDetails.add(detail);
    }
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class DefectDetail {
        private String file;
        private int line;
        private String path;
        private List<String> propagationPath = new ArrayList<>();
        private String description;
        private String potentialRisk;

        // 便捷方法
        public void addPropagationPath(String path) {
            if (propagationPath == null) {
                propagationPath = new ArrayList<>();
            }
            propagationPath.add(path);
        }
}


}