MCPcopy
hub / github.com/OpenNHP/opennhp / GetEvidenceWithCCUrl

Function GetEvidenceWithCCUrl

nhp/core/wasm/engine/host.go:37–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37func GetEvidenceWithCCUrl() ([]byte, error) {
38 client := &http.Client{Timeout: 3 * time.Second}
39
40 resp, err := client.Get(confidentialContainerEvidenceUrl)
41 if err != nil {
42 return nil, fmt.Errorf("http request failed: %w", err)
43 }
44
45 defer resp.Body.Close()
46
47 if resp.StatusCode != http.StatusOK {
48 return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
49 }
50
51 body, err := io.ReadAll(resp.Body)
52 if err != nil {
53 return nil, fmt.Errorf("failed to read response body: %w", err)
54 }
55
56 var buf bytes.Buffer
57 w := zlib.NewWriter(&buf)
58 _, err = w.Write(body)
59 w.Close()
60 if err != nil {
61 return nil, fmt.Errorf("failed to compress response body: %w", err)
62 }
63
64 compressedBody := buf.Bytes()
65
66 return compressedBody, nil
67}
68
69func GetEvidenceWithAgentUuid() ([]byte, error) {
70 agentUniqueId, err := CalculateAgentUniqueId()

Callers 1

GetEvidenceFunction · 0.85

Calls 4

CloseMethod · 0.65
BytesMethod · 0.65
GetMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected