-
Notifications
You must be signed in to change notification settings - Fork 3
/
api.gen.go
670 lines (564 loc) · 31.3 KB
/
api.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.
package api
import (
"bytes"
"compress/gzip"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"time"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
"github.com/oapi-codegen/runtime"
)
const (
BasicAuthScopes = "BasicAuth.Scopes"
BearerAuthScopes = "BearerAuth.Scopes"
)
// Defines values for HarborSbomReportMediaType.
const (
HarborSbomReportMediaTypeApplicationspdxJson HarborSbomReportMediaType = "application/spdx+json"
HarborSbomReportMediaTypeApplicationvndCyclonedxJson HarborSbomReportMediaType = "application/vnd.cyclonedx+json"
)
// Defines values for SbomParametersSbomMediaTypes.
const (
SbomParametersSbomMediaTypesApplicationspdxJson SbomParametersSbomMediaTypes = "application/spdx+json"
SbomParametersSbomMediaTypesApplicationvndCyclonedxJson SbomParametersSbomMediaTypes = "application/vnd.cyclonedx+json"
)
// Defines values for ScanRequestEnabledCapabilitiesType.
const (
ScanRequestEnabledCapabilitiesTypeSbom ScanRequestEnabledCapabilitiesType = "sbom"
ScanRequestEnabledCapabilitiesTypeVulnerability ScanRequestEnabledCapabilitiesType = "vulnerability"
)
// Defines values for ScannerCapabilityType.
const (
ScannerCapabilityTypeSbom ScannerCapabilityType = "sbom"
ScannerCapabilityTypeVulnerability ScannerCapabilityType = "vulnerability"
)
// Defines values for Severity.
const (
Critical Severity = "Critical"
High Severity = "High"
Low Severity = "Low"
Medium Severity = "Medium"
Negligible Severity = "Negligible"
Unknown Severity = "Unknown"
)
// Artifact defines model for Artifact.
type Artifact struct {
// Digest The artifact's digest, consisting of an algorithm and hex portion.
Digest *string `json:"digest,omitempty"`
// MimeType The MIME type of the artifact.
MimeType *string `json:"mime_type,omitempty"`
// Repository The name of the Docker Registry repository containing the artifact.
Repository *string `json:"repository,omitempty"`
// Tag The artifact's tag
Tag *string `json:"tag,omitempty"`
}
// CVSSDetails defines model for CVSSDetails.
type CVSSDetails struct {
// ScoreV2 The CVSS 2.0 score for the vulnerability.
ScoreV2 *float32 `json:"score_v2,omitempty"`
// ScoreV3 The CVSS 3.0 score for the vulnerability.
ScoreV3 *float32 `json:"score_v3,omitempty"`
// VectorV2 The CVSS 2.0 vector for the vulnerability. The string is of the form AV:L/AC:M/Au:N/C:P/I:N/A:N
VectorV2 *string `json:"vector_v2,omitempty"`
// VectorV3 The CVSS 3.0 vector for the vulnerability.
VectorV3 *string `json:"vector_v3,omitempty"`
}
// Error defines model for Error.
type Error struct {
Message *string `json:"message,omitempty"`
}
// ErrorResponse defines model for ErrorResponse.
type ErrorResponse struct {
Error *Error `json:"error,omitempty"`
}
// HarborSbomReport defines model for HarborSbomReport.
type HarborSbomReport struct {
Artifact *Artifact `json:"artifact,omitempty"`
// GeneratedAt The time of the report generated.
GeneratedAt *time.Time `json:"generated_at,omitempty"`
// MediaType The format of the sbom data.
MediaType *HarborSbomReportMediaType `json:"media_type,omitempty"`
// Sbom The raw data of the sbom generated by the scanner.
Sbom *map[string]interface{} `json:"sbom,omitempty"`
// Scanner Basic scanner properties such as name, vendor, and version.
Scanner *Scanner `json:"scanner,omitempty"`
// VendorAttributes The additional attributes of the vendor.
VendorAttributes *map[string]interface{} `json:"vendor_attributes,omitempty"`
}
// HarborSbomReportMediaType The format of the sbom data.
type HarborSbomReportMediaType string
// HarborVulnerabilityReport defines model for HarborVulnerabilityReport.
type HarborVulnerabilityReport struct {
Artifact *Artifact `json:"artifact,omitempty"`
GeneratedAt *time.Time `json:"generated_at,omitempty"`
// Scanner Basic scanner properties such as name, vendor, and version.
Scanner *Scanner `json:"scanner,omitempty"`
// Severity A standard scale for measuring the severity of a vulnerability.
//
// * `Unknown` - either a security problem that has not been assigned to a priority yet or a priority that the
// scanner did not recognize.
// * `Negligible` - technically a security problem, but is only theoretical in nature, requires a very special
// situation, has almost no install base, or does no real damage.
// * `Low` - a security problem, but is hard to exploit due to environment, requires a user-assisted attack,
// a small install base, or does very little damage.
// * `Medium` - a real security problem, and is exploitable for many people. Includes network daemon denial of
// service attacks, cross-site scripting, and gaining user privileges.
// * `High` - a real problem, exploitable for many people in a default installation. Includes serious remote denial
// of service, local root privilege escalations, or data loss.
// * `Critical` - a world-burning problem, exploitable for nearly all people in a default installation. Includes
// remote root privilege escalations, or massive data loss.
Severity *Severity `json:"severity,omitempty"`
Vulnerabilities *[]VulnerabilityItem `json:"vulnerabilities,omitempty"`
}
// Registry defines model for Registry.
type Registry struct {
// Authorization An optional value of the HTTP Authorization header sent with each request to the Docker Registry v2 API.
// It's used to exchange Base64 encoded robot account credentials to a short lived JWT access token which
// allows the underlying scanner to pull the artifact from the Docker Registry.
Authorization *string `json:"authorization,omitempty"`
// Url A base URL or the Docker Registry v2 API.
Url *string `json:"url,omitempty"`
}
// SbomParameters defines model for SbomParameters.
type SbomParameters struct {
SbomMediaTypes *[]SbomParametersSbomMediaTypes `json:"sbom_media_types,omitempty"`
}
// SbomParametersSbomMediaTypes defines model for SbomParameters.SbomMediaTypes.
type SbomParametersSbomMediaTypes string
// ScanRequest defines model for ScanRequest.
type ScanRequest struct {
Artifact Artifact `json:"artifact"`
// EnabledCapabilities Enable which capabilities supported by scanner, for backward compatibility, without this field scanner can be considered to enable all capabilities by default.
EnabledCapabilities *[]struct {
// Parameters The additional parameters for the scan request, for the SBOM type, harbor will carry with `sbom_media_types` to specify the expected formats for SBOM content.
Parameters *ScanRequest_EnabledCapabilities_Parameters `json:"parameters"`
// ProducesMimeTypes The set of MIME types of reports generated by the scanner for the consumes_mime_types of the same capability record, it is a subset or fullset of the
// produces_mime_types of the capability returned by the metadata API, used for client to fine grained control of the expected report type. It's a optional
// field, only applied when client needs to customize it, otherwise the scanner can think it's a fullset as before behavior if without this field.
ProducesMimeTypes *[]string `json:"produces_mime_types,omitempty"`
// Type The type of the scan capability.
Type ScanRequestEnabledCapabilitiesType `json:"type"`
} `json:"enabled_capabilities,omitempty"`
Registry Registry `json:"registry"`
}
// ScanRequest_EnabledCapabilities_Parameters The additional parameters for the scan request, for the SBOM type, harbor will carry with `sbom_media_types` to specify the expected formats for SBOM content.
type ScanRequest_EnabledCapabilities_Parameters struct {
union json.RawMessage
}
// ScanRequestEnabledCapabilitiesType The type of the scan capability.
type ScanRequestEnabledCapabilitiesType string
// ScanRequestId A unique identifier returned by the [/scan](#/operation/AcceptScanRequest] operations. The format of the
// identifier is not imposed but it should be unique enough to prevent collisons when polling for scan reports.
type ScanRequestId = string
// ScanResponse defines model for ScanResponse.
type ScanResponse struct {
// Id A unique identifier returned by the [/scan](#/operation/AcceptScanRequest] operations. The format of the
// identifier is not imposed but it should be unique enough to prevent collisons when polling for scan reports.
Id ScanRequestId `json:"id"`
}
// Scanner Basic scanner properties such as name, vendor, and version.
type Scanner struct {
// Name The name of the scanner.
Name *string `json:"name,omitempty"`
// Vendor The name of the scanner's provider.
Vendor *string `json:"vendor,omitempty"`
// Version The version of the scanner.
Version *string `json:"version,omitempty"`
}
// ScannerAdapterMetadata Represents metadata of a Scanner Adapter which allows Harbor to lookup a scanner capabilities
// of scanning a given Artifact stored in its registry and making sure that it
// can interpret a returned result.
type ScannerAdapterMetadata struct {
Capabilities []ScannerCapability `json:"capabilities"`
// Properties A set of custom properties that can further describe capabilities of a given scanner.
Properties *ScannerProperties `json:"properties,omitempty"`
// Scanner Basic scanner properties such as name, vendor, and version.
Scanner Scanner `json:"scanner"`
}
// ScannerCapability Capability consists of the set of recognized artifact MIME types and the set of scanner report MIME types.
//
// For example, a scanner capable of analyzing Docker images and producing a vulnerabilities report recognizable
// by Harbor web console might be represented with the following capability:
// - consumes MIME types:
// - `application/vnd.oci.image.manifest.v1+json`
// - `application/vnd.docker.distribution.manifest.v2+json`
//
// - produces MIME types:
// - `application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0`
//
// For example, a scanner capable of analyzing artifacts and producing a sbom report recognizable
// by Harbor might be represented with the following capability:
// - type: sbom
// - consumes MIME types:
// - `application/vnd.oci.image.manifest.v1+json`
// - `application/vnd.docker.distribution.manifest.v2+json`
//
// - produces MIME types:
// - `application/vnd.security.sbom.report+json; version=1.0`
type ScannerCapability struct {
AdditionalAttributes *map[string]interface{} `json:"additional_attributes,omitempty"`
// ConsumesMimeTypes The set of MIME types of the artifacts supported by the scanner to produce the reports specified in the "produces_mime_types". A given
// mime type should only be present in one capability item.
ConsumesMimeTypes []string `json:"consumes_mime_types"`
// ProducesMimeTypes The set of MIME types of reports generated by the scanner for the consumes_mime_types of the same capability record.
ProducesMimeTypes []string `json:"produces_mime_types"`
// Type The type of the capability, for example, 'vulnerability' represents analyzing the artifact then producing the vulnerabilities report,
// 'sbom' represents generating the corresponding sbom for the artifact which be scanned. In order to the backward and forward compatible,
// the field is optional, we think it's a original 'vulnerability' scan if no such field.
Type *ScannerCapabilityType `json:"type,omitempty"`
}
// ScannerCapabilityType The type of the capability, for example, 'vulnerability' represents analyzing the artifact then producing the vulnerabilities report,
// 'sbom' represents generating the corresponding sbom for the artifact which be scanned. In order to the backward and forward compatible,
// the field is optional, we think it's a original 'vulnerability' scan if no such field.
type ScannerCapabilityType string
// ScannerProperties A set of custom properties that can further describe capabilities of a given scanner.
type ScannerProperties map[string]string
// Severity A standard scale for measuring the severity of a vulnerability.
//
// - `Unknown` - either a security problem that has not been assigned to a priority yet or a priority that the
// scanner did not recognize.
// - `Negligible` - technically a security problem, but is only theoretical in nature, requires a very special
// situation, has almost no install base, or does no real damage.
// - `Low` - a security problem, but is hard to exploit due to environment, requires a user-assisted attack,
// a small install base, or does very little damage.
// - `Medium` - a real security problem, and is exploitable for many people. Includes network daemon denial of
// service attacks, cross-site scripting, and gaining user privileges.
// - `High` - a real problem, exploitable for many people in a default installation. Includes serious remote denial
// of service, local root privilege escalations, or data loss.
// - `Critical` - a world-burning problem, exploitable for nearly all people in a default installation. Includes
// remote root privilege escalations, or massive data loss.
type Severity string
// VulnerabilityItem defines model for VulnerabilityItem.
type VulnerabilityItem struct {
// CweIds The Common Weakness Enumeration Identifiers associated with this vulnerability.
CweIds *[]string `json:"cwe_ids,omitempty"`
// Description The detailed description of the vulnerability.
Description *string `json:"description,omitempty"`
// FixVersion The version of the package containing the fix if available.
FixVersion *string `json:"fix_version,omitempty"`
// Id The unique identifier of the vulnerability.
Id *string `json:"id,omitempty"`
// Links The list of links to the upstream databases with the full description of the vulnerability.
Links *[]string `json:"links,omitempty"`
// Package An operating system package containing the vulnerability.
Package *string `json:"package,omitempty"`
PreferredCvss *CVSSDetails `json:"preferred_cvss,omitempty"`
// Severity A standard scale for measuring the severity of a vulnerability.
//
// * `Unknown` - either a security problem that has not been assigned to a priority yet or a priority that the
// scanner did not recognize.
// * `Negligible` - technically a security problem, but is only theoretical in nature, requires a very special
// situation, has almost no install base, or does no real damage.
// * `Low` - a security problem, but is hard to exploit due to environment, requires a user-assisted attack,
// a small install base, or does very little damage.
// * `Medium` - a real security problem, and is exploitable for many people. Includes network daemon denial of
// service attacks, cross-site scripting, and gaining user privileges.
// * `High` - a real problem, exploitable for many people in a default installation. Includes serious remote denial
// of service, local root privilege escalations, or data loss.
// * `Critical` - a world-burning problem, exploitable for nearly all people in a default installation. Includes
// remote root privilege escalations, or massive data loss.
Severity *Severity `json:"severity,omitempty"`
VendorAttributes *map[string]interface{} `json:"vendor_attributes,omitempty"`
// Version The version of the package containing the vulnerability.
Version *string `json:"version,omitempty"`
}
// GetScanReportParams defines parameters for GetScanReport.
type GetScanReportParams struct {
// SbomMediaType media_type specifies the format of SBOM to be retrieved from the scanner adapter, it should either SPDX SBOM or CycloneDX
SbomMediaType *string `form:"sbom_media_type,omitempty" json:"sbom_media_type,omitempty"`
Accept *string `json:"Accept,omitempty"`
}
// AcceptScanRequestApplicationVndScannerAdapterScanRequestPlusJSONVersion10RequestBody defines body for AcceptScanRequest for application/vnd.scanner.adapter.scan.request+json; version=1.0 ContentType.
type AcceptScanRequestApplicationVndScannerAdapterScanRequestPlusJSONVersion10RequestBody = ScanRequest
// AcceptScanRequestApplicationVndScannerAdapterScanRequestPlusJSONVersion11RequestBody defines body for AcceptScanRequest for application/vnd.scanner.adapter.scan.request+json; version=1.1 ContentType.
type AcceptScanRequestApplicationVndScannerAdapterScanRequestPlusJSONVersion11RequestBody = ScanRequest
// AsSbomParameters returns the union data inside the ScanRequest_EnabledCapabilities_Parameters as a SbomParameters
func (t ScanRequest_EnabledCapabilities_Parameters) AsSbomParameters() (SbomParameters, error) {
var body SbomParameters
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromSbomParameters overwrites any union data inside the ScanRequest_EnabledCapabilities_Parameters as the provided SbomParameters
func (t *ScanRequest_EnabledCapabilities_Parameters) FromSbomParameters(v SbomParameters) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeSbomParameters performs a merge with any union data inside the ScanRequest_EnabledCapabilities_Parameters, using the provided SbomParameters
func (t *ScanRequest_EnabledCapabilities_Parameters) MergeSbomParameters(v SbomParameters) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
func (t ScanRequest_EnabledCapabilities_Parameters) MarshalJSON() ([]byte, error) {
b, err := t.union.MarshalJSON()
return b, err
}
func (t *ScanRequest_EnabledCapabilities_Parameters) UnmarshalJSON(b []byte) error {
err := t.union.UnmarshalJSON(b)
return err
}
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Get scanner metadata
// (GET /metadata)
GetMetadata(ctx echo.Context) error
// Accept artifact scanning request
// (POST /scan)
AcceptScanRequest(ctx echo.Context) error
// Get scan report
// (GET /scan/{scan_request_id}/report)
GetScanReport(ctx echo.Context, scanRequestId ScanRequestId, params GetScanReportParams) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// GetMetadata converts echo context to params.
func (w *ServerInterfaceWrapper) GetMetadata(ctx echo.Context) error {
var err error
ctx.Set(BasicAuthScopes, []string{})
ctx.Set(BearerAuthScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetMetadata(ctx)
return err
}
// AcceptScanRequest converts echo context to params.
func (w *ServerInterfaceWrapper) AcceptScanRequest(ctx echo.Context) error {
var err error
ctx.Set(BasicAuthScopes, []string{})
ctx.Set(BearerAuthScopes, []string{})
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.AcceptScanRequest(ctx)
return err
}
// GetScanReport converts echo context to params.
func (w *ServerInterfaceWrapper) GetScanReport(ctx echo.Context) error {
var err error
// ------------- Path parameter "scan_request_id" -------------
var scanRequestId ScanRequestId
err = runtime.BindStyledParameterWithOptions("simple", "scan_request_id", ctx.Param("scan_request_id"), &scanRequestId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter scan_request_id: %s", err))
}
ctx.Set(BasicAuthScopes, []string{})
ctx.Set(BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetScanReportParams
// ------------- Optional query parameter "sbom_media_type" -------------
err = runtime.BindQueryParameter("form", true, false, "sbom_media_type", ctx.QueryParams(), ¶ms.SbomMediaType)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter sbom_media_type: %s", err))
}
headers := ctx.Request().Header
// ------------- Optional header parameter "Accept" -------------
if valueList, found := headers[http.CanonicalHeaderKey("Accept")]; found {
var Accept string
n := len(valueList)
if n != 1 {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Accept, got %d", n))
}
err = runtime.BindStyledParameterWithOptions("simple", "Accept", valueList[0], &Accept, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Accept: %s", err))
}
params.Accept = &Accept
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetScanReport(ctx, scanRequestId, params)
return err
}
// This is a simple interface which specifies echo.Route addition functions which
// are present on both echo.Echo and echo.Group, since we want to allow using
// either of them for path registration
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.GET(baseURL+"/metadata", wrapper.GetMetadata)
router.POST(baseURL+"/scan", wrapper.AcceptScanRequest)
router.GET(baseURL+"/scan/:scan_request_id/report", wrapper.GetScanReport)
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/+xce3Pbtpb/KhjmzrS9K1Gy7Dipdu7sKo639Z0k9cRJe2cjjw0ShxJqEmAAULKa+rvv",
"HAB8SdTDabqbu3PzRxKTBM4BcB6/84A/BbHMcilAGB2MPwU6nkNG7X8nyvCExgb/nyuZgzIc7BvGZ6Dt",
"cwY6Vjw3XIpgHLybA6F+1DeauM96JJZCc224mBGZECoITWdScTPPCBWMzOGe5FLhHGHQC+CeZnkKwTjQ",
"czp6ejo+jY/j09FJ9PQ5i6KYHcdDxp6PopP46XEyPDn6/oQdjU6exacAEaM0ehafHg3j5Bk7PX02/D46",
"joJeYFa5ndAoLmbBQy/IeAY37mnXIl5fvD4n+BoZNo1VtRmkeZ7ymOLAwUKwkMn4DlTIOBKKCruijAqe",
"gDbhYvRvv2opurhRkEvNjVSrbnYEzSpOXloa5C3MkMqK1GNxnw3lAvd5O88pjxRVq0EmxUx2MWPobO/J",
"4jfNSY/Do5P+PQhO080pH6onMvoVYoNEzn6+unoJhvJUb4qXjqWCm8Womw0cSkbhkNjPSCKVXe2iSAUo",
"GvGUm1U4xX1OpMqoCcZBkkpqasZEkUWgkA1P6XgHpeNDKFU7cRyODqG7gNhItX+J7rstlAl+6jaZcF3K",
"BxInk5/HrwaTs/HrwaQYvxmcjS8HF+M3g8n4TZvdYPIzPj7Dr92Hb/yHl12iUbK9b792sr3GAQ4aH4fD",
"Qcnzq8Hl2/GrwXvk42r8fnA2/rFk/jDZOldKqk2pykBrOrMKX1O/khmQQsB9DrEBRsCOPZzMW9C5FBo2",
"yUHJxV8UJME4eDKoDe3AW9mBY7Vz+h+piqS6imT2FtA6blKgDfu8i0hlxx96wQzwJAywG7rFfhte2xpl",
"KZNqU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CRzKlgKG/eO1vyRM8NrWQq0E6qyytt909bwcysC/MH2DjfD5TK5UBdzK11tBOMY0Z3Zqyja",
"RcKt0NU6IlsiaMSbCBrmEN+R27+UViZ0cextFetqf0MTPhY01eR2NBzeorLdPh0Ob7fgujqUtuC3vg/2",
"oSvztpkX7swclHtt60gMgnFCUw29gOM8iLCDXon+17Y8aBb5XW7w0S7nwqqkNit3S8VmtoKH3qcdv1fj",
"8EAu8Ktwd13rdTjJC5rsbmQW13e0bsyqOpZ09SsW3EURd5tOuoY9ozig+amuo5Ya4/W017g04mvjV5cv",
"/+EmkYqcuQaul//4Ipfg7TZ8LMDeuClPs91vtnM7rv9wJHFQT9DBNmr7ZfRDoNNawN4mu9GX5xPk/tTj",
"zfsCHPSNm20arLXYNTLVn3mR7JFb0vgVETuJ7tedL3IW2xCRe90Ljocdv/TkyqX8uGCW9bLdpGG5uSYR",
"4Isa/peN1qUFr+9jOV20v67CGQIrwW8hUaDn/Uliuq4vXTjiXsft7ZMFTQlN6jsxe6ltqBNOM7M96w9f",
"KQZ8QVm1pspy1dc9rQUpD8G2/UydO54G5bCQtPqj7Qg8KWvXyr44WZ6k62YR0pCcuiS5I1E5N/Ltf6zZ",
"qb/d399/1ytx6R2sBq1fdbA+3t/WsxiwaXN95v1kOAwdID/p6v4XODbhXra2+8+Gs/0XxPxfhphVN/CW",
"fEdpbjrhZKNgaGFUo1T44RpRQLMc+OEaHaHbP4e6XAp0QHM+WBwFD9cP/xMAAP//07Ks5UJNAAA=",
}
// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
if err != nil {
return nil, fmt.Errorf("error base64 decoding spec: %w", err)
}
zr, err := gzip.NewReader(bytes.NewReader(zipped))
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %w", err)
}
var buf bytes.Buffer
_, err = buf.ReadFrom(zr)
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %w", err)
}
return buf.Bytes(), nil
}
var rawSpec = decodeSpecCached()
// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
data, err := decodeSpec()
return func() ([]byte, error) {
return data, err
}
}
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
res := make(map[string]func() ([]byte, error))
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
return res
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
resolvePath := PathToRawSpec("")
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
pathToFile := url.String()
pathToFile = path.Clean(pathToFile)
getSpec, ok := resolvePath[pathToFile]
if !ok {
err1 := fmt.Errorf("path not found: %s", pathToFile)
return nil, err1
}
return getSpec()
}
var specData []byte
specData, err = rawSpec()
if err != nil {
return
}
swagger, err = loader.LoadFromData(specData)
if err != nil {
return
}
return
}