(_ context.Context, attachment *v1.PolicyGroupAttachment)
| 70 | type HTTPSGroupLoader struct{} |
| 71 | |
| 72 | func (l *HTTPSGroupLoader) Load(_ context.Context, attachment *v1.PolicyGroupAttachment) (*v1.PolicyGroup, *PolicyDescriptor, error) { |
| 73 | ref, wantDigest := ExtractDigest(attachment.GetRef()) |
| 74 | |
| 75 | // and do not remove the scheme since we need http(s):// to make the request |
| 76 | if _, err := ensureScheme(ref, httpScheme, httpsScheme); err != nil { |
| 77 | return nil, nil, fmt.Errorf("invalid policy reference %q: %w", ref, err) |
| 78 | } |
| 79 | |
| 80 | // #nosec G107 |
| 81 | resp, err := http.Get(ref) |
| 82 | if err != nil { |
| 83 | return nil, nil, fmt.Errorf("requesting remote policy: %w", err) |
| 84 | } |
| 85 | defer resp.Body.Close() |
| 86 | raw, err := io.ReadAll(resp.Body) |
| 87 | if err != nil { |
| 88 | return nil, nil, fmt.Errorf("reading remote policy: %w", err) |
| 89 | } |
| 90 | |
| 91 | var group v1.PolicyGroup |
| 92 | d, err := unmarshallResource(raw, ref, wantDigest, &group) |
| 93 | if err != nil { |
| 94 | return nil, nil, fmt.Errorf("unmarshalling policy spec: %w", err) |
| 95 | } |
| 96 | |
| 97 | return &group, d, nil |
| 98 | } |
| 99 | |
| 100 | // ChainloopGroupLoader loads groups referenced with chainloop://provider/name URLs |
| 101 | type ChainloopGroupLoader struct { |
nothing calls this directly
no test coverage detected