diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bf97b6a2e..75dfae406 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,7 +7,7 @@ on: - synchronize - reopened paths-ignore: - - 'docs/**' + - "docs/**" permissions: # Required: allow read access to the content for analysis. @@ -16,7 +16,7 @@ permissions: pull-requests: read # Optional: Allow write access to checks to allow the action to annotate code in the PR. checks: write - + jobs: golangci: name: lint diff --git a/pkg/detectors/internal/testhelper/testhelper.go b/pkg/detectors/internal/testhelper/testhelper.go index a26fc6488..1d1d07f8e 100644 --- a/pkg/detectors/internal/testhelper/testhelper.go +++ b/pkg/detectors/internal/testhelper/testhelper.go @@ -16,6 +16,7 @@ import ( reportdetectors "github.com/bearer/bearer/pkg/report/detectors" "github.com/bearer/bearer/pkg/report/frameworks" "github.com/bearer/bearer/pkg/report/interfaces" + "github.com/bearer/bearer/pkg/report/operations" "github.com/bearer/bearer/pkg/report/schema" "github.com/bearer/bearer/pkg/report/schema/datatype" "github.com/bearer/bearer/pkg/report/secret" @@ -211,3 +212,16 @@ func (report *InMemoryReport) AddError(filePath string, err error) { File: filePath, }) } + +func (report *InMemoryReport) AddOperation( + detectorType reportdetectors.Type, + operation operations.Operation, + source source.Source, +) { + report.Detections = append(report.Detections, &detections.Detection{ + DetectorType: detectorType, + Value: operation, + Source: source, + Type: detections.TypeOperation, + }) +} diff --git a/pkg/detectors/openapi/.snapshots/TestDetectorV2json b/pkg/detectors/openapi/.snapshots/TestDetectorV2json index baf50b7fe..de1a93b36 100644 --- a/pkg/detectors/openapi/.snapshots/TestDetectorV2json +++ b/pkg/detectors/openapi/.snapshots/TestDetectorV2json @@ -1,4 +1,85 @@ -([]*detections.Detection) (len=9) { +([]*detections.Detection) (len=12) { + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(17), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(17), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=5) "/pets", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v1", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(58), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(58), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=5) "/pets", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v1", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(76), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(76), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/pets/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v1", + Variables: ([]operations.Variable) + } + } + } + }), (*detections.Detection)({ Type: (detections.DetectionType) (len=6) "schema", DetectorType: (detectors.Type) (len=7) "openapi", diff --git a/pkg/detectors/openapi/.snapshots/TestDetectorV2yaml b/pkg/detectors/openapi/.snapshots/TestDetectorV2yaml index 372724cc8..1fddd6b15 100644 --- a/pkg/detectors/openapi/.snapshots/TestDetectorV2yaml +++ b/pkg/detectors/openapi/.snapshots/TestDetectorV2yaml @@ -1,4 +1,544 @@ -([]*detections.Detection) (len=47) { +([]*detections.Detection) (len=67) { + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(34), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(34), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=4) "/pet", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(63), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(63), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "put") + }, + Value: (operations.Operation) { + Path: (string) (len=4) "/pet", + Type: (string) (len=3) "PUT", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(94), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(94), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=17) "/pet/findByStatus", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(131), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(131), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=15) "/pet/findByTags", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(163), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(163), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(190), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(190), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(225), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(225), + EndColumnNumber: (*int)(11), + Text: (*string)((len=6) "delete") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(253), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(253), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=18) "/pet/*/uploadImage", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(290), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(290), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=16) "/store/inventory", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(310), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(310), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=12) "/store/order", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(334), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(334), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=14) "/store/order/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(361), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(361), + EndColumnNumber: (*int)(11), + Text: (*string)((len=6) "delete") + }, + Value: (operations.Operation) { + Path: (string) (len=14) "/store/order/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(387), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(387), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=5) "/user", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(407), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(407), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=21) "/user/createWithArray", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(429), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(429), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=20) "/user/createWithList", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(451), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(451), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=11) "/user/login", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(488), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(488), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=12) "/user/logout", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(502), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(502), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(526), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(526), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "put") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=3) "PUT", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-swagger.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(552), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(552), + EndColumnNumber: (*int)(11), + Text: (*string)((len=6) "delete") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=29) "http://petstore.swagger.io/v2", + Variables: ([]operations.Variable) + } + } + } + }), (*detections.Detection)({ Type: (detections.DetectionType) (len=6) "schema", DetectorType: (detectors.Type) (len=7) "openapi", diff --git a/pkg/detectors/openapi/.snapshots/TestDetectorV3json b/pkg/detectors/openapi/.snapshots/TestDetectorV3json index b26a8ec44..9aa23b9db 100644 --- a/pkg/detectors/openapi/.snapshots/TestDetectorV3json +++ b/pkg/detectors/openapi/.snapshots/TestDetectorV3json @@ -1,4 +1,669 @@ -([]*detections.Detection) (len=54) { +([]*detections.Detection) (len=73) { + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(57), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(57), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"put\"") + }, + Value: (operations.Operation) { + Path: (string) (len=4) "/pet", + Type: (string) (len=3) "PUT", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(120), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(120), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=4) "/pet", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(179), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(179), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=17) "/pet/findByStatus", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(241), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(241), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=15) "/pet/findByTags", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(300), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(300), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(364), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(364), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(413), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(413), + EndColumnNumber: (*int)(15), + Text: (*string)((len=8) "\"delete\"") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(457), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(457), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=18) "/pet/*/uploadImage", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(518), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(518), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=16) "/store/inventory", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(549), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(549), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=12) "/store/order", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(593), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(593), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=14) "/store/order/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(636), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(636), + EndColumnNumber: (*int)(15), + Text: (*string)((len=8) "\"delete\"") + }, + Value: (operations.Operation) { + Path: (string) (len=14) "/store/order/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(666), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(666), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=5) "/user", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(713), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(713), + EndColumnNumber: (*int)(13), + Text: (*string)((len=6) "\"post\"") + }, + Value: (operations.Operation) { + Path: (string) (len=20) "/user/createWithList", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(755), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(755), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=11) "/user/login", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(821), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(821), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=12) "/user/logout", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(837), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(837), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"get\"") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(879), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(879), + EndColumnNumber: (*int)(12), + Text: (*string)((len=5) "\"put\"") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=3) "PUT", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.json", + FullFilename: (string) "", + Language: (string) (len=4) "JSON", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(923), + StartColumnNumber: (*int)(7), + EndLineNumber: (*int)(923), + EndColumnNumber: (*int)(15), + Text: (*string)((len=8) "\"delete\"") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=1) { + (operations.Url) { + Url: (string) (len=28) "https://api.{test}.me/api/v3", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=4) "test", + Values: ([]string) (len=2) { + (string) (len=5) "test1", + (string) (len=5) "test2" + } + } + } + } + } + } + }), (*detections.Detection)({ Type: (detections.DetectionType) (len=6) "schema", DetectorType: (detectors.Type) (len=7) "openapi", diff --git a/pkg/detectors/openapi/.snapshots/TestDetectorV3yaml b/pkg/detectors/openapi/.snapshots/TestDetectorV3yaml index afe7e7f18..b6748c9c3 100644 --- a/pkg/detectors/openapi/.snapshots/TestDetectorV3yaml +++ b/pkg/detectors/openapi/.snapshots/TestDetectorV3yaml @@ -1,4 +1,1125 @@ -([]*detections.Detection) (len=48) { +([]*detections.Detection) (len=67) { + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(55), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(55), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=4) "/pet", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(90), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(90), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "put") + }, + Value: (operations.Operation) { + Path: (string) (len=4) "/pet", + Type: (string) (len=3) "PUT", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(130), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(130), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=17) "/pet/findByStatus", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(170), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(170), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=15) "/pet/findByTags", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(209), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(209), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(249), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(249), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(280), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(280), + EndColumnNumber: (*int)(11), + Text: (*string)((len=6) "delete") + }, + Value: (operations.Operation) { + Path: (string) (len=6) "/pet/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(308), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(308), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=18) "/pet/*/uploadImage", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(346), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(346), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=16) "/store/inventory", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(366), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(366), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=12) "/store/order", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(394), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(394), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=14) "/store/order/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(425), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(425), + EndColumnNumber: (*int)(11), + Text: (*string)((len=6) "delete") + }, + Value: (operations.Operation) { + Path: (string) (len=14) "/store/order/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(448), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(448), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=5) "/user", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(477), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(477), + EndColumnNumber: (*int)(9), + Text: (*string)((len=4) "post") + }, + Value: (operations.Operation) { + Path: (string) (len=20) "/user/createWithList", + Type: (string) (len=4) "POST", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(504), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(504), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=11) "/user/login", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(547), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(547), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=12) "/user/logout", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(558), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(558), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "get") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=3) "GET", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(585), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(585), + EndColumnNumber: (*int)(8), + Text: (*string)((len=3) "put") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=3) "PUT", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), + (*detections.Detection)({ + Type: (detections.DetectionType) (len=9) "operation", + DetectorType: (detectors.Type) (len=7) "openapi", + DetectorLanguage: (detectors.Language) "", + CommitSHA: (string) "", + Source: (source.Source) { + Filename: (string) (len=21) "petstore-openapi.yaml", + FullFilename: (string) "", + Language: (string) (len=4) "YAML", + LanguageType: (string) (len=4) "data", + StartLineNumber: (*int)(614), + StartColumnNumber: (*int)(5), + EndLineNumber: (*int)(614), + EndColumnNumber: (*int)(11), + Text: (*string)((len=6) "delete") + }, + Value: (operations.Operation) { + Path: (string) (len=7) "/user/*", + Type: (string) (len=6) "DELETE", + Urls: ([]operations.Url) (len=3) { + (operations.Url) { + Url: (string) (len=28) "{protocol}://api.example.com", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=8) "protocol", + Values: ([]string) (len=2) { + (string) (len=4) "http", + (string) (len=5) "https" + } + } + } + }, + (operations.Url) { + Url: (string) (len=36) "https://{environment}.example.com/v2", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=11) "environment", + Values: ([]string) (len=3) { + (string) (len=3) "api", + (string) (len=7) "api.dev", + (string) (len=11) "api.staging" + } + } + } + }, + (operations.Url) { + Url: (string) (len=11) "{server}/v1", + Variables: ([]operations.Variable) (len=1) { + (operations.Variable) { + Name: (string) (len=6) "server", + Values: ([]string) (len=1) { + (string) (len=23) "https://api.example.com" + } + } + } + } + } + } + }), (*detections.Detection)({ Type: (detections.DetectionType) (len=6) "schema", DetectorType: (detectors.Type) (len=7) "openapi", diff --git a/pkg/detectors/openapi/reportadder/reportadder.go b/pkg/detectors/openapi/reportadder/reportadder.go index d423a22a7..0949edb9c 100644 --- a/pkg/detectors/openapi/reportadder/reportadder.go +++ b/pkg/detectors/openapi/reportadder/reportadder.go @@ -1,18 +1,24 @@ package reportadder import ( + "regexp" "sort" + "strings" "github.com/bearer/bearer/pkg/parser" "github.com/bearer/bearer/pkg/parser/nodeid" reporttypes "github.com/bearer/bearer/pkg/report" "github.com/bearer/bearer/pkg/report/detectors" + "github.com/bearer/bearer/pkg/report/operations" + "github.com/bearer/bearer/pkg/report/operations/operationshelper" "github.com/bearer/bearer/pkg/report/schema" "github.com/bearer/bearer/pkg/report/schema/schemahelper" "github.com/bearer/bearer/pkg/util/file" "github.com/bearer/bearer/pkg/util/stringutil" ) +var regexpPathVariable = regexp.MustCompile(`\{.+\}`) + type SortableSchema struct { Key parser.Node Value *schemahelper.Schema @@ -62,7 +68,7 @@ func AddSchema(file *file.FileInfo, report reporttypes.Report, foundValues map[p if !report.SchemaGroupIsOpen() { report.SchemaGroupBegin( detectors.DetectorOpenAPI, - nil, + &node, schema.Value, &schema.Source, nil, @@ -94,3 +100,41 @@ func convertSchema(value string) string { return schema.SimpleTypeObject } } + +func AddOperations(file *file.FileInfo, report reporttypes.Report, foundValues map[parser.Node]*operationshelper.Operation, servers []operations.Url) { + // we need sorted schemas so our reports are consistent and repeatable + var sortedOperations []*operationshelper.Operation + for _, operation := range foundValues { + sortedOperations = append(sortedOperations, operation) + } + sort.Slice(sortedOperations, func(i, j int) bool { + lineNumberA := sortedOperations[i].Source.StartLineNumber + lineNumberB := sortedOperations[j].Source.StartLineNumber + return *lineNumberA < *lineNumberB + }) + for _, operation := range sortedOperations { + operation.Source.Language = file.Language + operation.Source.LanguageType = file.LanguageTypeString() + operation.Value.Path = standardizeOperationPath(stringutil.StripQuotes(operation.Value.Path)) + operation.Value.Type = standardizeOperationType(stringutil.StripQuotes(operation.Value.Type)) + operation.Value.Urls = servers + report.AddOperation(detectors.DetectorOpenAPI, operation.Value, operation.Source) + } +} + +func standardizeOperationType(input string) (output string) { + input = strings.ToUpper(input) + supportedvalues := []string{operations.TypeGet, operations.TypeDelete, operations.TypePost, operations.TypePut} + + for _, v := range supportedvalues { + if input == v { + return v + } + } + + return operations.TypeOther +} + +func standardizeOperationPath(input string) (output string) { + return regexpPathVariable.ReplaceAllString(input, "*") +} diff --git a/pkg/detectors/openapi/v2json/server.go b/pkg/detectors/openapi/v2json/server.go new file mode 100644 index 000000000..65faa5a43 --- /dev/null +++ b/pkg/detectors/openapi/v2json/server.go @@ -0,0 +1,87 @@ +package v2json + +import ( + "strings" + + "github.com/bearer/bearer/pkg/parser" + "github.com/bearer/bearer/pkg/report/operations" + "github.com/bearer/bearer/pkg/util/stringutil" + "github.com/smacker/go-tree-sitter/javascript" +) + +var queryServersHost = parser.QueryMustCompile(javascript.GetLanguage(), ` +(expression_statement + (object + (pair + key: (string) @helper_host + (#match? @helper_host "^\"host\"$") + value: (string) @param_host + ) + ) +) +`) + +var queryServersBasePath = parser.QueryMustCompile(javascript.GetLanguage(), ` +(expression_statement + (object + (pair + key: (string) @helper_basePath + (#match? @helper_basePath "^\"basePath\"$") + value: (string) @param_base_path + ) + ) +) +`) + +var queryServerSchemes = parser.QueryMustCompile(javascript.GetLanguage(), ` +(expression_statement + (object + (pair + key: (string) @helper_schemes + (#match? @helper_schemes "^\"schemes\"$") + value: (array + (string) @param_schemes + ) + ) + ) +) +`) + +func findServers(tree *parser.Tree) (result []operations.Url) { + host := "" + captures := tree.QueryConventional(queryServersHost) + for _, capture := range captures { + host = stringutil.StripQuotes(capture["param_host"].Content()) + } + + basePath := "" + captures = tree.QueryConventional(queryServersBasePath) + for _, capture := range captures { + basePath = stringutil.StripQuotes(capture["param_base_path"].Content()) + } + + schemes := make([]string, 0) + captures = tree.QueryConventional(queryServerSchemes) + for _, capture := range captures { + schemes = append(schemes, stringutil.StripQuotes(capture["param_schemes"].Content())) + } + + if len(schemes) == 0 { + schemes = append(schemes, "http://", "https://") + } + + for _, scheme := range schemes { + if !strings.HasSuffix(scheme, "://") { + scheme = scheme + "://" + } + + if !strings.HasPrefix(basePath, "/") { + basePath = "/" + basePath + } + result = append(result, operations.Url{ + Url: scheme + host + basePath, + }) + } + + return result +} diff --git a/pkg/detectors/openapi/v2json/v2json.go b/pkg/detectors/openapi/v2json/v2json.go index 054a9775e..cf4637be1 100644 --- a/pkg/detectors/openapi/v2json/v2json.go +++ b/pkg/detectors/openapi/v2json/v2json.go @@ -68,6 +68,8 @@ func ProcessFile(idGenerator nodeid.Generator, file *file.FileInfo, report repor return false, err } + servers := findServers(tree) + reportadder.AddOperations(file, report, foundPaths, servers) reportadder.AddSchema(file, report, foundSchemas, idGenerator) return true, err diff --git a/pkg/detectors/openapi/v2yaml/server.go b/pkg/detectors/openapi/v2yaml/server.go new file mode 100644 index 000000000..389db9b80 --- /dev/null +++ b/pkg/detectors/openapi/v2yaml/server.go @@ -0,0 +1,95 @@ +package v2yaml + +import ( + "strings" + + "github.com/bearer/bearer/pkg/parser" + "github.com/bearer/bearer/pkg/report/operations" + "github.com/bearer/bearer/pkg/util/stringutil" + "github.com/smacker/go-tree-sitter/yaml" +) + +var queryServersHost = parser.QueryMustCompile(yaml.GetLanguage(), ` +(document + (block_node + (block_mapping + (block_mapping_pair + key: (flow_node) @helper_host + value: (flow_node) @param_host + ) + ) + ) +) +`) + +var queryServersBasePath = parser.QueryMustCompile(yaml.GetLanguage(), ` +(document + (block_node + (block_mapping + (block_mapping_pair + key: (flow_node) @helper_basePath + value: (flow_node) @param_base_path + ) + ) + ) +) +`) + +var queryServerSchemes = parser.QueryMustCompile(yaml.GetLanguage(), ` +(document + (block_node + (block_mapping + (block_mapping_pair + key: (flow_node) @helper_schemes + value: + (block_node + (block_sequence + (block_sequence_item + (flow_node) @param_scheme + ) + ) + ) + ) + ) + ) +) +`) + +func findServers(tree *parser.Tree) (result []operations.Url) { + host := "" + captures := tree.QueryConventional(queryServersHost) + for _, capture := range captures { + host = stringutil.StripQuotes(capture["param_host"].Content()) + } + + basePath := "" + captures = tree.QueryConventional(queryServersBasePath) + for _, capture := range captures { + basePath = stringutil.StripQuotes(capture["param_base_path"].Content()) + } + + schemes := make([]string, 0) + captures = tree.QueryConventional(queryServerSchemes) + for _, capture := range captures { + schemes = append(schemes, stringutil.StripQuotes(capture["param_scheme"].Content())) + } + + if len(schemes) == 0 { + schemes = append(schemes, "http://", "https://") + } + + for _, scheme := range schemes { + if !strings.HasSuffix(scheme, "://") { + scheme = scheme + "://" + } + + if !strings.HasPrefix(basePath, "/") { + basePath = "/" + basePath + } + result = append(result, operations.Url{ + Url: scheme + host + basePath, + }) + } + + return result +} diff --git a/pkg/detectors/openapi/v2yaml/v2yml.go b/pkg/detectors/openapi/v2yaml/v2yml.go index 5abfb8e3d..4c5fff69f 100644 --- a/pkg/detectors/openapi/v2yaml/v2yml.go +++ b/pkg/detectors/openapi/v2yaml/v2yml.go @@ -68,6 +68,8 @@ func ProcessFile(idGenerator nodeid.Generator, file *file.FileInfo, report repor return false, err } + servers := findServers(tree) + reportadder.AddOperations(file, report, foundPaths, servers) reportadder.AddSchema(file, report, foundValues, idGenerator) return true, err diff --git a/pkg/detectors/openapi/v3json/v3json.go b/pkg/detectors/openapi/v3json/v3json.go index 6505f06be..2347fed6c 100644 --- a/pkg/detectors/openapi/v3json/v3json.go +++ b/pkg/detectors/openapi/v3json/v3json.go @@ -67,6 +67,9 @@ func ProcessFile(idGenerator nodeid.Generator, file *file.FileInfo, report repor return false, err } + servers := queries.FindUrls(file) + + reportadder.AddOperations(file, report, foundPaths, servers) reportadder.AddSchema(file, report, foundSchemas, idGenerator) return true, err diff --git a/pkg/detectors/openapi/v3yaml/v3yml.go b/pkg/detectors/openapi/v3yaml/v3yml.go index 903fbd6ce..6c7b6c0b6 100644 --- a/pkg/detectors/openapi/v3yaml/v3yml.go +++ b/pkg/detectors/openapi/v3yaml/v3yml.go @@ -66,6 +66,8 @@ func ProcessFile(idGenerator nodeid.Generator, file *file.FileInfo, report repor return false, err } + servers := queries.FindUrls(file) + reportadder.AddOperations(file, report, foundPaths, servers) reportadder.AddSchema(file, report, foundSchemas, idGenerator) return true, err diff --git a/pkg/report/detections/detections.go b/pkg/report/detections/detections.go index cc69fe1c8..24eb0f7e3 100644 --- a/pkg/report/detections/detections.go +++ b/pkg/report/detections/detections.go @@ -28,6 +28,7 @@ var TypeCustom DetectionType = "custom" var TypeCustomClassified DetectionType = "custom_classified" var TypeCustomRisk DetectionType = "custom_risk" var TypeExpectedDetection DetectionType = "expected_detection" +var TypeOperation DetectionType = "operation" type ReportDetection interface { AddDetection(detectionType DetectionType, detectorType detectors.Type, source source.Source, value interface{}) diff --git a/pkg/report/output/dataflow/dataflow.go b/pkg/report/output/dataflow/dataflow.go index 292fe0101..78df144ae 100644 --- a/pkg/report/output/dataflow/dataflow.go +++ b/pkg/report/output/dataflow/dataflow.go @@ -13,6 +13,7 @@ import ( "github.com/bearer/bearer/pkg/report/output/dataflow/datatypes" "github.com/bearer/bearer/pkg/report/output/dataflow/detectiondecoder" fileerrors "github.com/bearer/bearer/pkg/report/output/dataflow/file_errors" + "github.com/bearer/bearer/pkg/report/output/dataflow/paths" "github.com/bearer/bearer/pkg/report/output/dataflow/risks" "github.com/bearer/bearer/pkg/report/output/types" "github.com/bearer/bearer/pkg/util/file" @@ -31,6 +32,7 @@ var allowedDetections []detections.DetectionType = []detections.DetectionType{ detections.TypeFileList, detections.TypeFileFailed, detections.TypeExpectedDetection, + detections.TypeOperation, } func contains(detections []detections.DetectionType, detection detections.DetectionType) bool { @@ -53,6 +55,7 @@ func AddReportData(reportData *types.ReportData, config settings.Config, isInter dataTypesHolder := datatypes.New(config, isInternal) risksHolder := risks.New(config, isInternal) componentsHolder := components.New(isInternal) + pathsHolder := paths.New(isInternal) errorsHolder := fileerrors.New() extras, err := datatypes.NewExtras(reportData.Detectors, config) @@ -122,6 +125,7 @@ func AddReportData(reportData *types.ReportData, config settings.Config, isInter errorsHolder.AddError(errorDetection) default: var castDetection detections.Detection + buf := bytes.NewBuffer(nil) if err := json.NewEncoder(buf).Encode(detection); err != nil { return err @@ -144,6 +148,12 @@ func AddReportData(reportData *types.ReportData, config settings.Config, isInter if err = dataTypesHolder.AddSchema(castDetection, detectionExtras); err != nil { return err } + case detections.TypeOperation: + operationDetection, err := detectiondecoder.GetOperation(detection) + if err != nil { + return err + } + pathsHolder.AddOperation(castDetection.DetectorType, operationDetection, fullFilename) case detections.TypeExpectedDetection: expectedHolder.AddRiskPresence(castDetection) case detections.TypeCustomRisk: @@ -234,6 +244,7 @@ func AddReportData(reportData *types.ReportData, config settings.Config, isInter Components: componentsHolder.ToDataFlow(), Dependencies: componentsHolder.ToDataFlowForDependencies(), Errors: errorsHolder.ToDataFlow(), + Paths: pathsHolder.ToDataFlow(), } return nil diff --git a/pkg/report/output/dataflow/detectiondecoder/operation_classification.go b/pkg/report/output/dataflow/detectiondecoder/operation_classification.go new file mode 100644 index 000000000..63adad662 --- /dev/null +++ b/pkg/report/output/dataflow/detectiondecoder/operation_classification.go @@ -0,0 +1,24 @@ +package detectiondecoder + +import ( + "bytes" + "encoding/json" + "fmt" + + "github.com/bearer/bearer/pkg/report/operations/operationshelper" +) + +func GetOperation(detection interface{}) (operationshelper.Operation, error) { + var value operationshelper.Operation + buf := bytes.NewBuffer(nil) + err := json.NewEncoder(buf).Encode(detection) + if err != nil { + return operationshelper.Operation{}, fmt.Errorf("expect detection to have value of type operation %#v", detection) + } + err = json.NewDecoder(buf).Decode(&value) + if err != nil { + return operationshelper.Operation{}, fmt.Errorf("expect detection to have value of type operation %#v", detection) + } + + return value, nil +} diff --git a/pkg/report/output/dataflow/paths/paths.go b/pkg/report/output/dataflow/paths/paths.go new file mode 100644 index 000000000..3f524eb82 --- /dev/null +++ b/pkg/report/output/dataflow/paths/paths.go @@ -0,0 +1,77 @@ +package paths + +import ( + "github.com/bearer/bearer/pkg/report/detectors" + "github.com/bearer/bearer/pkg/report/operations/operationshelper" + "github.com/bearer/bearer/pkg/report/output/dataflow/types" +) + +type Holder struct { + detectors map[string]*detector +} + +type detector struct { + detections []*types.Detection + name string +} + +func New(isInternal bool) *Holder { + return &Holder{ + detectors: make(map[string]*detector), + } +} + +func (holder *Holder) AddOperation(detectorType detectors.Type, detection operationshelper.Operation, fullFilename string) { + var urls []string + + for _, url := range detection.Value.Urls { + urls = append(urls, url.Url) + } + + holder.addPath( + string(detectorType), + detection.Source.Filename, + fullFilename, + *detection.Source.StartLineNumber, + detection.Value.Path, + urls, + ) +} + +func (holder *Holder) addPath( + detectorName string, + fileName string, + fullFilename string, + lineNumber int, + path string, + urls []string, +) { + + if _, exists := holder.detectors[detectorName]; !exists { + holder.detectors[detectorName] = &detector{ + name: detectorName, + detections: []*types.Detection{}, + } + } + + targetDetector := holder.detectors[detectorName] + targetDetector.detections = append(targetDetector.detections, &types.Detection{ + FullFilename: fullFilename, + FullName: fileName, + LineNumber: &lineNumber, + Path: path, + Urls: urls, + }) +} + +func (holder *Holder) ToDataFlow() []types.Path { + data := make([]types.Path, 0) + for _, detector := range holder.detectors { + data = append(data, types.Path{ + DetectorName: detector.name, + Detections: holder.detectors[detector.name].detections, + }) + } + + return data +} diff --git a/pkg/report/output/dataflow/types/paths.go b/pkg/report/output/dataflow/types/paths.go new file mode 100644 index 000000000..43a919d7b --- /dev/null +++ b/pkg/report/output/dataflow/types/paths.go @@ -0,0 +1,14 @@ +package types + +type Path struct { + DetectorName string `json:"detector_name" yaml:"detector_name"` + Detections []*Detection `json:"detections" yaml:"detections"` +} + +type Detection struct { + FullFilename string `json:"full_filename" yaml:"full_filename"` + FullName string `json:"full_name" yaml:"full_name"` + LineNumber *int `json:"line_number" yaml:"line_number"` + Path string `json:"path" yam:"path"` + Urls []string `json:"urls" yaml:"urls"` +} diff --git a/pkg/report/output/types/types.go b/pkg/report/output/types/types.go index 094a34c00..e62e3ab6c 100644 --- a/pkg/report/output/types/types.go +++ b/pkg/report/output/types/types.go @@ -30,6 +30,7 @@ type DataFlow struct { Components []dataflowtypes.Component `json:"components,omitempty" yaml:"components,omitempty"` Dependencies []dataflowtypes.Dependency `json:"dependencies,omitempty" yaml:"dependencies,omitempty"` Errors []dataflowtypes.Error `json:"errors,omitempty" yaml:"errors,omitempty"` + Paths []dataflowtypes.Path `json:"paths,omitempty" yaml:"paths,omitempty"` } type GenericFormatter interface { diff --git a/pkg/report/report.go b/pkg/report/report.go index ee08d715d..3935fbd80 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -6,6 +6,7 @@ import ( "github.com/bearer/bearer/pkg/report/detectors" "github.com/bearer/bearer/pkg/report/frameworks" "github.com/bearer/bearer/pkg/report/interfaces" + "github.com/bearer/bearer/pkg/report/operations" "github.com/bearer/bearer/pkg/report/schema" "github.com/bearer/bearer/pkg/report/schema/datatype" @@ -21,5 +22,6 @@ type Report interface { AddFramework(detectorType detectors.Type, frameworkType frameworks.Type, data interface{}, source source.Source) AddDependency(detectorType detectors.Type, detectorLanguage detectors.Language, dependency dependencies.Dependency, source source.Source) AddSecretLeak(secret secret.Secret, source source.Source) + AddOperation(detectorType detectors.Type, operation operations.Operation, source source.Source) AddError(filePath string, err error) } diff --git a/pkg/report/writer/detectors.go b/pkg/report/writer/detectors.go index 9f72b2326..2c0d26ee3 100644 --- a/pkg/report/writer/detectors.go +++ b/pkg/report/writer/detectors.go @@ -17,6 +17,7 @@ import ( "github.com/bearer/bearer/pkg/report/detectors" "github.com/bearer/bearer/pkg/report/frameworks" "github.com/bearer/bearer/pkg/report/interfaces" + "github.com/bearer/bearer/pkg/report/operations" "github.com/bearer/bearer/pkg/report/schema" "github.com/bearer/bearer/pkg/report/schema/datatype" "github.com/bearer/bearer/pkg/report/secret" @@ -132,7 +133,6 @@ func (report *Detectors) SchemaGroupEnd(idGenerator nodeid.Generator) { UUID: schema.FieldUUID, } } - // Build parent data type parentDataType := &datatype.DataType{ Node: report.StoredSchemas.Node, @@ -142,7 +142,6 @@ func (report *Detectors) SchemaGroupEnd(idGenerator nodeid.Generator) { Properties: childDataTypes, UUID: report.StoredSchemas.ParentSchema.Value.ObjectUUID, } - classifiedDatatypes := make(map[parser.NodeID]*datatype.ClassifiedDatatype, 0) parentClassificationRequest := classificationschema.ClassificationRequest{DetectorType: report.StoredSchemas.DetectorType, Value: parentDataType.ToClassificationRequestDetection(), Filename: report.StoredSchemas.ParentSchema.Source.Filename} @@ -223,6 +222,14 @@ func (report *Detectors) AddError(filePath string, err error) { }) } +func (report *Detectors) AddOperation( + detectorType detectors.Type, + operation operations.Operation, + source source.Source, +) { + report.AddDetection(detections.TypeOperation, detectorType, source, operation) +} + func (report *Detectors) Add(data interface{}) { detectionsToAdd := []interface{}{data}