Skip to content

Commit

Permalink
bring back openapi to dataflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski committed Nov 22, 2024
1 parent 5d30fdc commit 971bc0c
Show file tree
Hide file tree
Showing 21 changed files with 2,802 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- synchronize
- reopened
paths-ignore:
- 'docs/**'
- "docs/**"

permissions:
# Required: allow read access to the content for analysis.
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/detectors/internal/testhelper/testhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
})
}
83 changes: 82 additions & 1 deletion pkg/detectors/openapi/.snapshots/TestDetectorV2json
Original file line number Diff line number Diff line change
@@ -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) <nil>
}
}
}
}),
(*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) <nil>
}
}
}
}),
(*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) <nil>
}
}
}
}),
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=7) "openapi",
Expand Down
Loading

0 comments on commit 971bc0c

Please sign in to comment.