Skip to content

Commit

Permalink
feat: add string values (#1710)
Browse files Browse the repository at this point in the history
* Add string values

* fix test

* add content to dataflow

* bring back openapi to dataflow
  • Loading branch information
cfabianski authored Nov 22, 2024
1 parent e027b9c commit fff2faa
Show file tree
Hide file tree
Showing 31 changed files with 2,881 additions and 66 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
2 changes: 1 addition & 1 deletion e2e/flags/.snapshots/TestReportFlags-report-dataflow
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"data_types":[{"category_name":"Contact","category_groups":["PII","Personal Data"],"name":"Email Address","detectors":[{"name":"ruby","locations":[{"filename":"main.rb","full_filename":"e2e/flags/testdata/simple/main.rb","start_line_number":1,"start_column_number":31,"end_column_number":36,"field_name":"email","object_name":"user","subject_name":"User"}]}]}]}
{"data_types":[{"uuid":"22e24c62-82d3-4b72-827c-e261533331bd","category_uuid":"cef587dd-76db-430b-9e18-7b031e1a193b","category_name":"Contact","category_groups":["PII","Personal Data"],"name":"Email Address","detectors":[{"name":"ruby","locations":[{"filename":"main.rb","full_filename":"e2e/flags/testdata/simple/main.rb","start_line_number":1,"start_column_number":31,"end_column_number":36,"field_name":"email","object_name":"user","subject_name":"User"}]}]}]}

--
Analyzing codebase
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 fff2faa

Please sign in to comment.