restapi

package
v0.0.0-...-6cfc1b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package restapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.11.1-0.20220609223533-7da811e1cf30 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

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 Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type ApiToken

type ApiToken struct {
	Key string `json:"key"`

	// An enumeration for the authorization type parameter.
	Type  AuthorizationTypeEnum `json:"type"`
	Value string                `json:"value"`
}

ApiToken defines model for ApiToken.

type AuthorizationScheme

type AuthorizationScheme struct {
	// contains filtered or unexported fields
}

AuthorizationScheme defines model for AuthorizationScheme.

func (AuthorizationScheme) AsApiToken

func (t AuthorizationScheme) AsApiToken() (ApiToken, error)

func (AuthorizationScheme) AsBasicAuth

func (t AuthorizationScheme) AsBasicAuth() (BasicAuth, error)

func (AuthorizationScheme) AsBearerToken

func (t AuthorizationScheme) AsBearerToken() (BearerToken, error)

func (AuthorizationScheme) Discriminator

func (t AuthorizationScheme) Discriminator() (string, error)

func (*AuthorizationScheme) FromApiToken

func (t *AuthorizationScheme) FromApiToken(v ApiToken) error

func (*AuthorizationScheme) FromBasicAuth

func (t *AuthorizationScheme) FromBasicAuth(v BasicAuth) error

func (*AuthorizationScheme) FromBearerToken

func (t *AuthorizationScheme) FromBearerToken(v BearerToken) error

func (AuthorizationScheme) MarshalJSON

func (t AuthorizationScheme) MarshalJSON() ([]byte, error)

func (*AuthorizationScheme) UnmarshalJSON

func (t *AuthorizationScheme) UnmarshalJSON(b []byte) error

func (AuthorizationScheme) ValueByDiscriminator

func (t AuthorizationScheme) ValueByDiscriminator() (interface{}, error)

type AuthorizationSchemeBase

type AuthorizationSchemeBase struct {
	// An enumeration for the authorization type parameter.
	Type AuthorizationTypeEnum `json:"type"`
}

AuthorizationSchemeBase defines model for AuthorizationSchemeBase.

type AuthorizationTypeEnum

type AuthorizationTypeEnum string

An enumeration for the authorization type parameter.

const (
	APITOKEN    AuthorizationTypeEnum = "APITOKEN"
	BASICAUTH   AuthorizationTypeEnum = "BASICAUTH"
	BEARERTOKEN AuthorizationTypeEnum = "BEARERTOKEN"
)

Defines values for AuthorizationTypeEnum.

type BasicAuth

type BasicAuth struct {
	Password string `json:"password"`

	// An enumeration for the authorization type parameter.
	Type     AuthorizationTypeEnum `json:"type"`
	Username string                `json:"username"`
}

BasicAuth defines model for BasicAuth.

type BearerToken

type BearerToken struct {
	Token string `json:"token"`

	// An enumeration for the authorization type parameter.
	Type AuthorizationTypeEnum `json:"type"`
}

BearerToken defines model for BearerToken.

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type Finding

type Finding struct {
	// description of the finding
	Description *string `json:"description,omitempty"`

	// Name of the finding
	Name *string `json:"name,omitempty"`

	// risk of the finding
	Risk *string `json:"risk,omitempty"`
}

Finding defines model for Finding.

type Findings

type Findings struct {
	Items *[]Finding `json:"items,omitempty"`

	// Nb of items, used for pagination
	Total *int `json:"total,omitempty"`
}

Findings defines model for Findings.

type FuzzingReportItem

type FuzzingReportItem struct {
	Description *string `json:"description,omitempty"`

	// List of paths that has been fuzzed
	Findings *[]RawFindings `json:"findings,omitempty"`
	Name     *string        `json:"name,omitempty"`

	// List of paths that has been fuzzed
	Paths    *[]FuzzingReportPath `json:"paths,omitempty"`
	Source   *string              `json:"source,omitempty"`
	Status   *string              `json:"status,omitempty"`
	TestType *string              `json:"testType,omitempty"`
}

Current fuzzer report

type FuzzingReportOperation

type FuzzingReportOperation struct {
	Findings *[]externalRef0.APIFinding `json:"findings,omitempty"`

	// Severity of a finding
	HighestSeverity *externalRef0.Severity     `json:"highestSeverity,omitempty"`
	Operation       externalRef0.MethodAndPath `json:"operation"`

	// Request count to this operation item during the test
	RequestsCount int32 `json:"requestsCount"`
}

Report tag operation

type FuzzingReportPath

type FuzzingReportPath struct {
	Payload  *string `json:"payload,omitempty"`
	Response *string `json:"response,omitempty"`
	Result   *int    `json:"result,omitempty"`
	Uri      *string `json:"uri,omitempty"`
	Verb     *string `json:"verb,omitempty"`
}

Current fuzzer report

type FuzzingReportTag

type FuzzingReportTag struct {
	// Severity of a finding
	HighestSeverity *externalRef0.Severity `json:"highestSeverity,omitempty"`

	// Tag name
	Name       string                   `json:"name"`
	Operations []FuzzingReportOperation `json:"operations"`
}

Report tag item

type FuzzingStatusAndReport

type FuzzingStatusAndReport struct {
	Progress int `json:"progress"`

	// List of report item
	Report map[string]FuzzingReportItem `json:"report"`

	// An enumeration.
	Status FuzzingStatusEnum `json:"status"`
}

fuzzing status and reporting

type FuzzingStatusEnum

type FuzzingStatusEnum string

An enumeration.

const (
	DONE       FuzzingStatusEnum = "DONE"
	ERROR      FuzzingStatusEnum = "ERROR"
	INPROGRESS FuzzingStatusEnum = "IN_PROGRESS"
)

Defines values for FuzzingStatusEnum.

type GetAPIFindingsParams

type GetAPIFindingsParams struct {
	// Should findings include sensitive data ?
	Sensitive *externalRef0.Sensitive `form:"sensitive,omitempty" json:"sensitive,omitempty"`
}

GetAPIFindingsParams defines parameters for GetAPIFindings.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type PostUpdateStatusJSONBody

type PostUpdateStatusJSONBody = FuzzingStatusAndReport

PostUpdateStatusJSONBody defines parameters for PostUpdateStatus.

type PostUpdateStatusJSONRequestBody

type PostUpdateStatusJSONRequestBody = PostUpdateStatusJSONBody

PostUpdateStatusJSONRequestBody defines body for PostUpdateStatus for application/json ContentType.

type RawFindings

type RawFindings struct {
	AdditionalInfo *string `json:"additionalInfo,omitempty"`
	Description    *string `json:"description,omitempty"`

	// location string token
	Location  *[]string            `json:"location,omitempty"`
	Namespace *string              `json:"namespace,omitempty"`
	Request   *RawFindingsSeverity `json:"request,omitempty"`
	Type      *string              `json:"type,omitempty"`
}

RawFindings defines model for RawFindings.

type RawFindingsBundle

type RawFindingsBundle struct {
	// Opaque data structure for the raw finding
	Data string `json:"data"`

	// An enumeration.
	Source RawFindingsSourceEnum `json:"source"`

	// An enumeration.
	Status ScoreExitStatusEnum `json:"status"`

	// Message giving details about the exist status
	StatusMessage *string `json:"status_message,omitempty"`

	// Raw finding timestamp format= date-time
	Timestamp string `json:"timestamp"`
}

RawFindingsBundle defines model for RawFindingsBundle.

type RawFindingsSeverity

type RawFindingsSeverity struct {
	Severity *string `json:"severity,omitempty"`
}

RawFindingsSeverity defines model for RawFindingsSeverity.

type RawFindingsSourceEnum

type RawFindingsSourceEnum string

An enumeration.

const (
	APIFUZZER        RawFindingsSourceEnum = "API_FUZZER"
	BITSIGHT         RawFindingsSourceEnum = "BITSIGHT"
	GRPCANALYZER     RawFindingsSourceEnum = "GRPC_ANALYZER"
	OASANALYSER      RawFindingsSourceEnum = "OAS_ANALYSER"
	OASTRACEANALYZER RawFindingsSourceEnum = "OAS_TRACE_ANALYZER"
	OPENDNS          RawFindingsSourceEnum = "OPENDNS"
	TALOS            RawFindingsSourceEnum = "TALOS"
)

Defines values for RawFindingsSourceEnum.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ScoreExitStatusEnum

type ScoreExitStatusEnum string

An enumeration.

const (
	GENERICFAILURE ScoreExitStatusEnum = "GENERIC_FAILURE"
	NETWORKFAILURE ScoreExitStatusEnum = "NETWORK_FAILURE"
	PARSEERROR     ScoreExitStatusEnum = "PARSE_ERROR"
	SUCCESS        ScoreExitStatusEnum = "SUCCESS"
	TOOLONG        ScoreExitStatusEnum = "TOO_LONG"
)

Defines values for ScoreExitStatusEnum.

type ServerInterface

type ServerInterface interface {
	// Retreive the annotated spec for an API
	// (GET /annotatedspec/{apiID})
	GetAnnotatedSpec(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Get findings for an API and module
	// (GET /apiFindings/{apiID})
	GetAPIFindings(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, params GetAPIFindingsParams)
	// Start a test for an API
	// (GET /fuzz/{apiID}/progress)
	GetTestProgress(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Start a test for an API
	// (GET /fuzz/{apiID}/report)
	GetTestReport(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Start a test for an API
	// (POST /fuzz/{apiID}/start)
	StartTest(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Stop (cancel) a running test for an API
	// (POST /fuzz/{apiID}/stop)
	StopTest(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Retreive a report for an API
	// (GET /report/{apiID}/{timestamp})
	GetReport(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, timestamp int64)
	// Retrieve a report for an API for a specific test
	// (GET /report/{apiID}/{timestamp}/short)
	GetShortReportByTimestamp(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, timestamp int64)
	// Get the current running state of this module
	// (GET /state)
	GetState(w http.ResponseWriter, r *http.Request)
	// Retreieve the list of tests for an API
	// (GET /tests/{apiID})
	GetTests(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Retreive last update status for an API under fuzzing
	// (GET /updateStatus/{apiID})
	GetUpdateStatus(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Update status for an API under fuzzing
	// (POST /updateStatus/{apiID})
	PostUpdateStatus(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Get the version of this Module
	// (GET /version)
	GetVersion(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetAPIFindings

func (siw *ServerInterfaceWrapper) GetAPIFindings(w http.ResponseWriter, r *http.Request)

GetAPIFindings operation middleware

func (*ServerInterfaceWrapper) GetAnnotatedSpec

func (siw *ServerInterfaceWrapper) GetAnnotatedSpec(w http.ResponseWriter, r *http.Request)

GetAnnotatedSpec operation middleware

func (*ServerInterfaceWrapper) GetReport

func (siw *ServerInterfaceWrapper) GetReport(w http.ResponseWriter, r *http.Request)

GetReport operation middleware

func (*ServerInterfaceWrapper) GetShortReportByTimestamp

func (siw *ServerInterfaceWrapper) GetShortReportByTimestamp(w http.ResponseWriter, r *http.Request)

GetShortReportByTimestamp operation middleware

func (*ServerInterfaceWrapper) GetState

func (siw *ServerInterfaceWrapper) GetState(w http.ResponseWriter, r *http.Request)

GetState operation middleware

func (*ServerInterfaceWrapper) GetTestProgress

func (siw *ServerInterfaceWrapper) GetTestProgress(w http.ResponseWriter, r *http.Request)

GetTestProgress operation middleware

func (*ServerInterfaceWrapper) GetTestReport

func (siw *ServerInterfaceWrapper) GetTestReport(w http.ResponseWriter, r *http.Request)

GetTestReport operation middleware

func (*ServerInterfaceWrapper) GetTests

func (siw *ServerInterfaceWrapper) GetTests(w http.ResponseWriter, r *http.Request)

GetTests operation middleware

func (*ServerInterfaceWrapper) GetUpdateStatus

func (siw *ServerInterfaceWrapper) GetUpdateStatus(w http.ResponseWriter, r *http.Request)

GetUpdateStatus operation middleware

func (*ServerInterfaceWrapper) GetVersion

func (siw *ServerInterfaceWrapper) GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion operation middleware

func (*ServerInterfaceWrapper) PostUpdateStatus

func (siw *ServerInterfaceWrapper) PostUpdateStatus(w http.ResponseWriter, r *http.Request)

PostUpdateStatus operation middleware

func (*ServerInterfaceWrapper) StartTest

func (siw *ServerInterfaceWrapper) StartTest(w http.ResponseWriter, r *http.Request)

StartTest operation middleware

func (*ServerInterfaceWrapper) StopTest

func (siw *ServerInterfaceWrapper) StopTest(w http.ResponseWriter, r *http.Request)

StopTest operation middleware

type ShortTestProgress

type ShortTestProgress struct {
	ApiID *externalRef0.ApiID `json:"apiID,omitempty"`

	// Progress of the test
	Progress int `json:"progress"`

	// Timestamp of the start of the test
	Starttime int64 `json:"starttime"`
}

Describes the progress of an ongoing test

type ShortTestReport

type ShortTestReport struct {
	ApiID *externalRef0.ApiID `json:"apiID,omitempty"`

	// Severity of a finding
	HighestSeverity *externalRef0.Severity `json:"highestSeverity,omitempty"`

	// Timestamp of the start of the test
	Starttime int64 `json:"starttime"`

	// An enumeration.
	Status FuzzingStatusEnum `json:"status"`

	// Message for status details, if any
	StatusMessage *string             `json:"statusMessage,omitempty"`
	Tags          *[]FuzzingReportTag `json:"tags,omitempty"`
}

Short Test Report

type StartTestJSONBody

type StartTestJSONBody = TestInput

StartTestJSONBody defines parameters for StartTest.

type StartTestJSONRequestBody

type StartTestJSONRequestBody = StartTestJSONBody

StartTestJSONRequestBody defines body for StartTest for application/json ContentType.

type Test

type Test struct {
	// A message in case of error
	ErrorMessage *string `json:"errorMessage,omitempty"`

	// Progress of the test
	Progress *int `json:"progress,omitempty"`

	// Timestamp of the start of the test
	Starttime *int64 `json:"starttime,omitempty"`

	// risk of the finding
	Vulnerabilities *Vulnerabilities `json:"vulnerabilities,omitempty"`
}

Test defines model for Test.

type TestHandle

type TestHandle struct {
	ApiID     *externalRef0.ApiID `json:"apiID,omitempty"`
	Timestamp *int64              `json:"timestamp,omitempty"`
}

TestHandle defines model for TestHandle.

type TestInput

type TestInput struct {
	Auth *AuthorizationScheme `json:"auth,omitempty"`

	// An enumeration for input depth parameter.
	Depth TestInputDepthEnum `json:"depth"`
}

contains all input parameters for a test

type TestInputDepthEnum

type TestInputDepthEnum string

An enumeration for input depth parameter.

const (
	DEEP    TestInputDepthEnum = "DEEP"
	DEFAULT TestInputDepthEnum = "DEFAULT"
	QUICK   TestInputDepthEnum = "QUICK"
)

Defines values for TestInputDepthEnum.

type TestProgressNotification

type TestProgressNotification struct {
	ApiID            *externalRef0.ApiID `json:"apiID,omitempty"`
	NotificationType string              `json:"notificationType"`

	// Progress of the test
	Progress int `json:"progress"`

	// Timestamp of the start of the test
	Starttime int64 `json:"starttime"`
}

TestProgressNotification defines model for TestProgressNotification.

type TestReportNotification

type TestReportNotification struct {
	ApiID *externalRef0.ApiID `json:"apiID,omitempty"`

	// Severity of a finding
	HighestSeverity  *externalRef0.Severity `json:"highestSeverity,omitempty"`
	NotificationType string                 `json:"notificationType"`

	// Timestamp of the start of the test
	Starttime int64 `json:"starttime"`

	// An enumeration.
	Status FuzzingStatusEnum `json:"status"`

	// Message for status details, if any
	StatusMessage *string             `json:"statusMessage,omitempty"`
	Tags          *[]FuzzingReportTag `json:"tags,omitempty"`
}

TestReportNotification defines model for TestReportNotification.

type TestWithReport

type TestWithReport struct {
	// A message in case of error
	ErrorMessage *string `json:"errorMessage,omitempty"`

	// Timestamp of the last report received for the test
	LastReportTime *int64 `json:"lastReportTime,omitempty"`

	// Progress of the test
	Progress *int `json:"progress,omitempty"`

	// fuzzing status and reporting
	Report *FuzzingStatusAndReport `json:"report,omitempty"`

	// Timestamp of the start of the test
	Starttime *int64 `json:"starttime,omitempty"`

	// risk of the finding
	Vulnerabilities *Vulnerabilities `json:"vulnerabilities,omitempty"`
}

TestWithReport defines model for TestWithReport.

type TestingModuleState

type TestingModuleState struct {
	APIsInCache int    `json:"APIsInCache"`
	Version     string `json:"version"`
}

TestingModuleState defines model for TestingModuleState.

type Tests

type Tests struct {
	Items *[]Test `json:"items,omitempty"`

	// Nb of items, used for pagination
	Total *int `json:"total,omitempty"`
}

Tests defines model for Tests.

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type Version

type Version struct {
	Version string `json:"version"`
}

Version defines model for Version.

type Vulnerabilities

type Vulnerabilities struct {
	// Total of vuln
	Critical *int `json:"critical,omitempty"`

	// Total of vuln
	High *int `json:"high,omitempty"`

	// Total of vuln
	Low *int `json:"low,omitempty"`

	// Total of vuln
	Medium *int `json:"medium,omitempty"`

	// Total of vuln
	Total *int `json:"total,omitempty"`
}

risk of the finding

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL