result.go
1 // Copyright (c) 2024-2026 Tencent Zhuque Lab. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // Requirement: Any integration or derivative work must explicitly attribute 16 // Tencent Zhuque Lab (https://github.com/Tencent/AI-Infra-Guard) in its 17 // documentation or user interface, as detailed in the NOTICE file. 18 19 // Package runner 结果结构体 20 package runner 21 22 import ( 23 "encoding/json" 24 25 "github.com/Tencent/AI-Infra-Guard/common/fingerprints/preload" 26 "github.com/Tencent/AI-Infra-Guard/pkg/vulstruct" 27 ) 28 29 // Result defines an interface for result output 30 // 定义了结果输出的接口 31 type Result interface { 32 STR() string // Returns result as string format 33 JSON() string // Returns result as JSON format 34 } 35 36 // HttpResult represents the HTTP scanning result structure 37 // HTTP扫描结果的结构体,包含了请求的详细信息和检测结果 38 type HttpResult struct { 39 URL string `json:"url"` // Target URL 40 Title string `json:"title"` // Page title 41 ContentLength int `json:"content-length"` // Response content length 42 StatusCode int `json:"status-code"` // HTTP status code 43 ResponseTime string `json:"response-time"` // Request response time 44 Fingers []preload.FpResult `json:"fingerprints"` // Fingerprint detection results 45 Advisories []vulstruct.VersionVul `json:"advisories"` // Vulnerability advisory information 46 Resp string 47 s string // Internal string representation 48 } 49 50 // JSON converts HttpResult to JSON string 51 // 将HttpResult转换为JSON字符串格式 52 func (r *HttpResult) JSON() string { 53 if js, err := json.Marshal(r); err == nil { 54 return string(js) 55 } 56 return "" 57 }