diff --git a/internal/commands/process/settings/policies/common.rego b/internal/commands/process/settings/policies/common.rego index 702d1c355..8a9bf6d64 100644 --- a/internal/commands/process/settings/policies/common.rego +++ b/internal/commands/process/settings/policies/common.rego @@ -8,7 +8,6 @@ build_item(location) := { "sink": { "start": location.source.start_line_number, "end": location.source.end_line_number, - "content": location.source.content, "column": { "start": location.source.start_column_number, "end": location.source.end_column_number, @@ -49,7 +48,6 @@ build_local_item(location, data_type) := { "sink": { "start": location.source.start_line_number, "end": location.source.end_line_number, - "content": location.source.content, "column": { "start": location.source.start_column_number, "end": location.source.end_column_number, @@ -75,7 +73,6 @@ build_item(location) := { "sink": { "start": location.source.start_line_number, "end": location.source.end_line_number, - "content": location.source.content, "column": { "start": location.source.start_column_number, "end": location.source.end_column_number, diff --git a/internal/commands/process/settings/policies/risk_policy.rego b/internal/commands/process/settings/policies/risk_policy.rego index 8a05d7f85..9f066e22c 100644 --- a/internal/commands/process/settings/policies/risk_policy.rego +++ b/internal/commands/process/settings/policies/risk_policy.rego @@ -155,7 +155,6 @@ policy_failure contains item if { "sink": { "start": location.source.start_line_number, "end": location.source.end_line_number, - "content": location.source.content, "column": { "start": location.source.start_column_number, "end": location.source.end_column_number, diff --git a/internal/detectors/beego/beego.go b/internal/detectors/beego/beego.go index 6ce37b08a..51231a7da 100644 --- a/internal/detectors/beego/beego.go +++ b/internal/detectors/beego/beego.go @@ -135,7 +135,7 @@ func extractDatabases(drivers []*databaseDriver, fileInfo *fileInfo, report repo Package: driverPackage, DriverName: targetdriver, TypeConstant: driverTypeConstant, - }, functionNode.Source(true)) + }, functionNode.Source()) } diff --git a/internal/detectors/custom/custom.go b/internal/detectors/custom/custom.go index 4e12f029a..11ea87504 100644 --- a/internal/detectors/custom/custom.go +++ b/internal/detectors/custom/custom.go @@ -306,22 +306,19 @@ func (detector *Detector) extractData(captures []parser.Captures, rule config.Co } if rule.DetectPresence { - content := capture["rule"].Source(false) - content.Text = &rule.Pattern - + content := capture["rule"].Source() var schemaSource *schema.Source var source source.Source if !rule.OmitParent { - source = capture["rule"].Source(true) + source = capture["rule"].Source() schemaSource = &schema.Source{ StartLineNumber: *source.StartLineNumber, EndLineNumber: *source.EndLineNumber, StartColumnNumber: *source.StartColumnNumber, EndColumnNumber: *source.EndColumnNumber, - Content: *source.Text, } } else { - source = capture["rule"].Source(false) + source = capture["rule"].Source() schemaSource = &schema.Source{ StartLineNumber: *source.StartLineNumber, StartColumnNumber: *source.StartColumnNumber, diff --git a/internal/detectors/django/django.go b/internal/detectors/django/django.go index 4c2b10e69..4c1e9762f 100644 --- a/internal/detectors/django/django.go +++ b/internal/detectors/django/django.go @@ -106,7 +106,7 @@ func (detector *detector) ProcessFile(file *file.FileInfo, dir *file.Path, repor report.AddFramework(detectors.DetectorDjango, django.TypeDatabase, django.Database{ Name: name, Engine: engine, - }, nameNode.Source(false)) + }, nameNode.Source()) return err }) diff --git a/internal/detectors/dotnet/dotnet.go b/internal/detectors/dotnet/dotnet.go index 31d8e83d9..c8d03b021 100644 --- a/internal/detectors/dotnet/dotnet.go +++ b/internal/detectors/dotnet/dotnet.go @@ -70,7 +70,7 @@ func (detector *detector) ProcessFile(file *file.FileInfo, dir *file.Path, repor report.AddFramework(detectors.DetectorDotnet, dotnet.TypeDatabase, dotnet.DBContext{ TypeName: typeName, UseDbMethodName: useDbMethodName, - }, nameNode.Source(false)) + }, nameNode.Source()) return nil }) diff --git a/internal/detectors/envfile/envfile.go b/internal/detectors/envfile/envfile.go index b858a1220..9c64a17b9 100644 --- a/internal/detectors/envfile/envfile.go +++ b/internal/detectors/envfile/envfile.go @@ -63,7 +63,7 @@ func (detector *detector) ProcessFile(file *file.FileInfo, dir *file.Path, repor Value: parsedValue, Type: interfaceType, VariableName: name, - }, detectionNode.Source(true)) + }, detectionNode.Source()) } return nil diff --git a/internal/detectors/gitleaks/gitleaks.go b/internal/detectors/gitleaks/gitleaks.go index 4c29f8cf5..967213374 100644 --- a/internal/detectors/gitleaks/gitleaks.go +++ b/internal/detectors/gitleaks/gitleaks.go @@ -3,7 +3,6 @@ package gitleaks import ( _ "embed" "log" - "strings" "github.com/bearer/bearer/internal/detectors/types" "github.com/bearer/bearer/internal/parser/nodeid" @@ -52,7 +51,6 @@ func (detector *detector) ProcessFile(file *file.FileInfo, dir *file.Path, repor } for _, finding := range findings { - text := strings.TrimPrefix(finding.Line, "\n") report.AddSecretLeak(secret.Secret{ Description: finding.Description, }, source.Source{ @@ -61,7 +59,6 @@ func (detector *detector) ProcessFile(file *file.FileInfo, dir *file.Path, repor StartColumnNumber: &finding.StartColumn, EndLineNumber: &finding.EndLine, EndColumnNumber: &finding.EndColumn, - Text: &text, }) } diff --git a/internal/detectors/graphql/graphql.go b/internal/detectors/graphql/graphql.go index 90b315368..deab2168b 100644 --- a/internal/detectors/graphql/graphql.go +++ b/internal/detectors/graphql/graphql.go @@ -100,7 +100,7 @@ func (detector *detector) ExtractFromSchema( } if !report.SchemaGroupIsOpen() { - source := objectNode.Source(true) + source := objectNode.Source() report.SchemaGroupBegin( detectors.DetectorGraphQL, objectNode, @@ -109,7 +109,7 @@ func (detector *detector) ExtractFromSchema( nil, ) } - source := fieldNode.Source(true) + source := fieldNode.Source() report.SchemaGroupAddItem( fieldNode, currentSchema, diff --git a/internal/detectors/html/html.go b/internal/detectors/html/html.go index 368d4ff18..5ef5f7dc4 100644 --- a/internal/detectors/html/html.go +++ b/internal/detectors/html/html.go @@ -115,7 +115,7 @@ func extractScripts(report report.Report, tree *parser.Tree, file *file.FileInfo report.AddInterface(detectors.DetectorHTML, interfacetype.Interface{ Value: parsedValue, Type: interfaceType, - }, tagNode.Source(true)) + }, tagNode.Source()) } return nil diff --git a/internal/detectors/openapi/queries/objects.go b/internal/detectors/openapi/queries/objects.go index f497d9e10..be6a44358 100644 --- a/internal/detectors/openapi/queries/objects.go +++ b/internal/detectors/openapi/queries/objects.go @@ -68,7 +68,7 @@ func AnnotateObjects(request ObjectsRequest) error { } request.FoundValues[*propertyName] = &schemahelper.Schema{ - Source: propertyName.Source(true), + Source: propertyName.Source(), Value: schema.Schema{ FieldName: propertyName.Content(), FieldUUID: request.NodeIDMap.ValueForNode(propertyName.ID()), diff --git a/internal/detectors/openapi/queries/paths.go b/internal/detectors/openapi/queries/paths.go index a2e94e843..4871684d9 100644 --- a/internal/detectors/openapi/queries/paths.go +++ b/internal/detectors/openapi/queries/paths.go @@ -27,7 +27,7 @@ func AnnotatePaths(request PathsRequest) error { requestType := capture["param_request_type"] request.FoundValues[*requestType] = &operationshelper.Operation{ - Source: requestType.Source(true), + Source: requestType.Source(), Value: operations.Operation{ Path: stringutil.StripQuotes(path.Content()), Type: stringutil.StripQuotes(requestType.Content()), diff --git a/internal/detectors/openapi/queries/v2parameters.go b/internal/detectors/openapi/queries/v2parameters.go index 8f8b274a0..dfd968685 100644 --- a/internal/detectors/openapi/queries/v2parameters.go +++ b/internal/detectors/openapi/queries/v2parameters.go @@ -27,7 +27,7 @@ func AnnotateV2Paramaters(nodeIDMap *nodeid.Map, tree *parser.Tree, foundValues typeNode := capture["param_type"] foundValues[*nameNode] = &schemahelper.Schema{ - Source: nameNode.Source(true), + Source: nameNode.Source(), Value: schema.Schema{ FieldName: nameNode.Content(), FieldType: typeNode.Content(), diff --git a/internal/detectors/openapi/queries/v3parameters.go b/internal/detectors/openapi/queries/v3parameters.go index 6094dd9cf..f2cf73cd3 100644 --- a/internal/detectors/openapi/queries/v3parameters.go +++ b/internal/detectors/openapi/queries/v3parameters.go @@ -48,7 +48,7 @@ func AnnotateV3Paramaters( } foundValues[*nameNode] = &schemahelper.Schema{ - Source: nameNode.Source(true), + Source: nameNode.Source(), Value: schema.Schema{ FieldName: nameNode.Content(), FieldType: fieldType, diff --git a/internal/detectors/proto/proto.go b/internal/detectors/proto/proto.go index 87fee5b9e..06bc66bf7 100644 --- a/internal/detectors/proto/proto.go +++ b/internal/detectors/proto/proto.go @@ -104,7 +104,7 @@ func (detector *detector) ExtractFromSchema( } if !report.SchemaGroupIsOpen() { - source := objectNode.Source(true) + source := objectNode.Source() report.SchemaGroupBegin( detectors.DetectorProto, objectNode, @@ -113,7 +113,7 @@ func (detector *detector) ExtractFromSchema( nil, ) } - source := fieldNode.Source(true) + source := fieldNode.Source() report.SchemaGroupAddItem( fieldNode, currentSchema, diff --git a/internal/detectors/rails/cache/cache.go b/internal/detectors/rails/cache/cache.go index 2538c49aa..7be4a4f07 100644 --- a/internal/detectors/rails/cache/cache.go +++ b/internal/detectors/rails/cache/cache.go @@ -34,7 +34,7 @@ func ExtractCaches(file *file.FileInfo, report report.Report) error { report.AddFramework(detectors.DetectorRails, rails.TypeCache, rails.Cache{ Type: typeName, - }, typeSymbol.Source(false)) + }, typeSymbol.Source()) return nil }) diff --git a/internal/detectors/rails/schema_rb/schema_rb.go b/internal/detectors/rails/schema_rb/schema_rb.go index 35d67a22b..58a289f19 100644 --- a/internal/detectors/rails/schema_rb/schema_rb.go +++ b/internal/detectors/rails/schema_rb/schema_rb.go @@ -84,7 +84,7 @@ func ExtractFromDatabaseSchema( } if !report.SchemaGroupIsOpen() { - source := tableNode.Source(false) + source := tableNode.Source() report.SchemaGroupBegin( detectors.DetectorSchemaRb, tableNode, @@ -93,7 +93,7 @@ func ExtractFromDatabaseSchema( ruleNode, ) } - source := columnNode.Source(false) + source := columnNode.Source() report.SchemaGroupAddItem( columnNode, currentSchema, diff --git a/internal/detectors/simple/simple.go b/internal/detectors/simple/simple.go index 3823cb03c..f80b73b64 100644 --- a/internal/detectors/simple/simple.go +++ b/internal/detectors/simple/simple.go @@ -109,7 +109,6 @@ func extractURLs(fileInfo *file.FileInfo, line string, lineNumber int, report re LanguageType: fileInfo.LanguageTypeString(), StartLineNumber: &lineNumber, StartColumnNumber: pointers.Int(globalOffset + startOffset), - Text: &url, }) } diff --git a/internal/detectors/spring/spring.go b/internal/detectors/spring/spring.go index 7ab81882a..9c6f807fd 100644 --- a/internal/detectors/spring/spring.go +++ b/internal/detectors/spring/spring.go @@ -142,7 +142,6 @@ func extractDataStoresFromProperties(file *file.FileInfo, report report.Report) LanguageType: file.LanguageTypeString(), Filename: file.RelativePath, StartLineNumber: &property.lineNumber, - Text: &property.text, }) return nil diff --git a/internal/detectors/typescript/datatype/knex/functions.go b/internal/detectors/typescript/datatype/knex/functions.go index 80ad87136..6b1b978ff 100644 --- a/internal/detectors/typescript/datatype/knex/functions.go +++ b/internal/detectors/typescript/datatype/knex/functions.go @@ -73,14 +73,14 @@ func detectFunctionTypes(report report.Report, tree *parser.Tree, language *sitt } sort.Slice(sortedTypes, func(i, j int) bool { - lineNumberA := sortedTypes[i].node.Source(false).StartLineNumber - lineNumberB := sortedTypes[j].node.Source(false).StartLineNumber + lineNumberA := sortedTypes[i].node.Source().StartLineNumber + lineNumberB := sortedTypes[j].node.Source().StartLineNumber return *lineNumberA < *lineNumberB }) for _, functionType := range sortedTypes { for _, dataType := range functionType.types { - report.AddFramework(detectors.DetectorTypescript, reportknex.TypeFunction, reportknex.Function{DataType: dataType}, functionType.node.Source(false)) + report.AddFramework(detectors.DetectorTypescript, reportknex.TypeFunction, reportknex.Function{DataType: dataType}, functionType.node.Source()) } } } diff --git a/internal/detectors/typescript/datatype/knex/table.go b/internal/detectors/typescript/datatype/knex/table.go index ff851f283..d3a19b9b0 100644 --- a/internal/detectors/typescript/datatype/knex/table.go +++ b/internal/detectors/typescript/datatype/knex/table.go @@ -79,7 +79,7 @@ func detectTableDeclarationModule(report report.Report, tree *parser.Tree, langu report.AddFramework(detectors.DetectorTypescript, reportknex.TypeSchema, reportknex.Schema{ DataType: propertyType.Content(), PropertyName: propertyName.Content(), - }, tableChild.Source(false)) + }, tableChild.Source()) } } } diff --git a/internal/detectors/yamlconfig/yamlconfig.go b/internal/detectors/yamlconfig/yamlconfig.go index a6e8fc707..dabca264f 100644 --- a/internal/detectors/yamlconfig/yamlconfig.go +++ b/internal/detectors/yamlconfig/yamlconfig.go @@ -111,7 +111,7 @@ func extractInterfaces(report report.Report, tree *parser.Tree) error { Type: interfaceType, Value: parsedValue, VariableName: key, - }, definitionNode.Source(true)) + }, definitionNode.Source()) } return nil diff --git a/internal/languages/javascript/pattern/pattern.go b/internal/languages/javascript/pattern/pattern.go index f7fae3251..eab402933 100644 --- a/internal/languages/javascript/pattern/pattern.go +++ b/internal/languages/javascript/pattern/pattern.go @@ -65,7 +65,7 @@ func (*Pattern) ExtractVariables(input string) (string, []language.PatternVariab return replaced, params, nil } -func produceDummyValue(i int, nodeType string) string { +func produceDummyValue(i int, _ string) string { return "BearerVar" + fmt.Sprint(i) } diff --git a/internal/parser/datatype/scope.go b/internal/parser/datatype/scope.go index 85b13df4f..f7ad46285 100644 --- a/internal/parser/datatype/scope.go +++ b/internal/parser/datatype/scope.go @@ -25,15 +25,15 @@ func (scope *Scope) toSortedDatatypes() [][]datatype.DataTypable { } sort.Slice(sortedDatatypes, func(i, j int) bool { - lineNumberA := sortedDatatypes[i][0].GetNode().Source(false).StartLineNumber - lineNumberB := sortedDatatypes[j][0].GetNode().Source(false).StartLineNumber + lineNumberA := sortedDatatypes[i][0].GetNode().Source().StartLineNumber + lineNumberB := sortedDatatypes[j][0].GetNode().Source().StartLineNumber if *lineNumberA != *lineNumberB { return *lineNumberA < *lineNumberB } - columnNumberA := sortedDatatypes[i][0].GetNode().Source(false).StartColumnNumber - columnNumberB := sortedDatatypes[j][0].GetNode().Source(false).StartColumnNumber + columnNumberA := sortedDatatypes[i][0].GetNode().Source().StartColumnNumber + columnNumberB := sortedDatatypes[j][0].GetNode().Source().StartColumnNumber return *columnNumberA < *columnNumberB }) @@ -147,15 +147,15 @@ func UnifyUUID(datatypes []datatype.DataTypable, idGenerator nodeid.Generator) { func SortScopes(input []*Scope) { sort.Slice(input, func(i, j int) bool { - lineNumberA := input[i].Node.Source(false).StartLineNumber - lineNumberB := input[j].Node.Source(false).StartLineNumber + lineNumberA := input[i].Node.Source().StartLineNumber + lineNumberB := input[j].Node.Source().StartLineNumber if *lineNumberA != *lineNumberB { return *lineNumberA < *lineNumberB } - columnNumberA := input[i].Node.Source(false).StartColumnNumber - columnNumberB := input[j].Node.Source(false).StartColumnNumber + columnNumberA := input[i].Node.Source().StartColumnNumber + columnNumberB := input[j].Node.Source().StartColumnNumber return *columnNumberA < *columnNumberB }) diff --git a/internal/parser/interfacedetector/interfaces.go b/internal/parser/interfacedetector/interfaces.go index b7df50a56..c4b7ffac3 100644 --- a/internal/parser/interfacedetector/interfaces.go +++ b/internal/parser/interfacedetector/interfaces.go @@ -37,7 +37,7 @@ func Detect(req *Request) error { req.Report.AddInterface(req.DetectorType, reportinterface.Interface{ Type: interfaceType, Value: value, - }, node.Source(true)) + }, node.Source()) } }) } diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 4d0b015cc..cdd12e792 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -244,12 +244,7 @@ func (node *Node) EndColumnNumber() int { return int(node.sitter.EndPoint().Column + 1) } -func (node *Node) Source(includeText bool) source.Source { - text := "" - if includeText { - text = strings.TrimSpace(node.Content()) - } - +func (node *Node) Source() source.Source { return source.New( node.tree.fileInfo, node.tree.File(), @@ -257,7 +252,6 @@ func (node *Node) Source(includeText bool) source.Source { node.StartColumnNumber(), node.EndLineNumber(), node.EndColumnNumber(), - text, ) } diff --git a/internal/report/output/dataflow/risks/risks.go b/internal/report/output/dataflow/risks/risks.go index 79155cec4..e88377343 100644 --- a/internal/report/output/dataflow/risks/risks.go +++ b/internal/report/output/dataflow/risks/risks.go @@ -85,12 +85,10 @@ func (holder *Holder) AddRiskPresence(detection detections.Detection) { StartColumnNumber: *detection.Source.StartColumnNumber, EndLineNumber: *detection.Source.EndLineNumber, EndColumnNumber: *detection.Source.EndColumnNumber, - Content: *detection.Source.Text, } } else { // parent can be nil source = extractCustomRiskParent(detection.Value) - content = *detection.Source.Text } holder.addDatatype( @@ -195,9 +193,6 @@ func (holder *Holder) addDatatype( line := file.startLineNumber[startLineNumber] // create datatype source entry if it doesn't exist sourceKey := "undefined_source" - if schema.Source != nil { - sourceKey = schema.Source.Content - } if _, exists := line.source[sourceKey]; !exists { line.source[sourceKey] = sourceHolder{ diff --git a/internal/report/output/privacy/privacy_test.go b/internal/report/output/privacy/privacy_test.go index cb0ca1125..af94697e1 100644 --- a/internal/report/output/privacy/privacy_test.go +++ b/internal/report/output/privacy/privacy_test.go @@ -91,7 +91,6 @@ func dummyDataflow() *outputtypes.DataFlow { StartColumnNumber: 10, EndLineNumber: 38, EndColumnNumber: 28, - Content: "Sentry.set_user(email: current_user.email)", }, DataTypes: []types.RiskDatatype{ { diff --git a/internal/report/output/security/security_test.go b/internal/report/output/security/security_test.go index cf3a9c9cd..1434a2732 100644 --- a/internal/report/output/security/security_test.go +++ b/internal/report/output/security/security_test.go @@ -226,7 +226,6 @@ func TestFingerprintIsStableWithBaseBranchFindings(t *testing.T) { StartColumnNumber: 1, EndLineNumber: 1, EndColumnNumber: 44, - Content: "http.verify_mode = OpenSSL::SSL::VERIFY_NONE", }, PresenceMatches: []dataflowtypes.RiskPresence{ { @@ -247,7 +246,6 @@ func TestFingerprintIsStableWithBaseBranchFindings(t *testing.T) { StartColumnNumber: 1, EndLineNumber: 2, EndColumnNumber: 44, - Content: "http.verify_mode = OpenSSL::SSL::VERIFY_NONE", }, PresenceMatches: []dataflowtypes.RiskPresence{ { @@ -341,7 +339,6 @@ func dummyDataflowData() *outputtypes.ReportData { StartColumnNumber: 10, EndLineNumber: 2, EndColumnNumber: 28, - Content: "http.verify_mode = OpenSSL::SSL::VERIFY_NONE", }, PresenceMatches: []dataflowtypes.RiskPresence{ { @@ -363,7 +360,6 @@ func dummyDataflowData() *outputtypes.ReportData { StartColumnNumber: 10, EndLineNumber: 2, EndColumnNumber: 28, - Content: "Rails.logger.info(user.biometric_data)", }, DataTypes: []dataflowtypes.RiskDatatype{ { diff --git a/internal/report/schema/datatype/datatype.go b/internal/report/schema/datatype/datatype.go index fee135fca..f77ac6702 100644 --- a/internal/report/schema/datatype/datatype.go +++ b/internal/report/schema/datatype/datatype.go @@ -207,7 +207,6 @@ func dataTypeToSchema[D DataTypable](report detections.ReportDetection, detectio if parent != nil { sourceSchema = &schema.Source{ - Content: parent.Content(), StartLineNumber: parent.StartLineNumber(), StartColumnNumber: parent.StartColumnNumber(), EndLineNumber: parent.EndLineNumber(), @@ -222,7 +221,7 @@ func dataTypeToSchema[D DataTypable](report detections.ReportDetection, detectio report.AddDetection( detectionType, detectorType, - dataType.GetNode().Source(false), + dataType.GetNode().Source(), schema.Schema{ ObjectName: parentName, FieldName: selfName, @@ -263,15 +262,15 @@ func SortParserMap[D DataTypable](input map[parser.NodeID]D) []D { func SortSlice[D DataTypable](input []D) []D { sort.Slice(input, func(i, j int) bool { - lineNumberA := input[i].GetNode().Source(false).StartLineNumber - lineNumberB := input[j].GetNode().Source(false).StartLineNumber + lineNumberA := input[i].GetNode().Source().StartLineNumber + lineNumberB := input[j].GetNode().Source().StartLineNumber if *lineNumberA != *lineNumberB { return *lineNumberA < *lineNumberB } - columnNumberA := input[i].GetNode().Source(false).StartColumnNumber - columnNumberB := input[j].GetNode().Source(false).StartColumnNumber + columnNumberA := input[i].GetNode().Source().StartColumnNumber + columnNumberB := input[j].GetNode().Source().StartColumnNumber if *columnNumberA != *columnNumberB { return *columnNumberA < *columnNumberB diff --git a/internal/report/schema/schema.go b/internal/report/schema/schema.go index e4d2b43c5..2f266fc35 100644 --- a/internal/report/schema/schema.go +++ b/internal/report/schema/schema.go @@ -33,11 +33,11 @@ type Schema struct { type Source struct { // This is the starting line number, the very beginning of what's used by the custom detection - StartLineNumber int `json:"start_line_number,omitempty" yaml:"start_line_number,omitempty"` - StartColumnNumber int `json:"start_column_number,omitempty" yaml:"start_column_number,omitempty"` - EndLineNumber int `json:"end_line_number,omitempty" yaml:"end_line_number,omitempty"` - EndColumnNumber int `json:"end_column_number,omitempty" yaml:"end_column_number,omitempty"` - Content string `json:"content,omitempty" yaml:"content,omitempty"` + StartLineNumber int `json:"start_line_number,omitempty" yaml:"start_line_number,omitempty"` + StartColumnNumber int `json:"start_column_number,omitempty" yaml:"start_column_number,omitempty"` + EndLineNumber int `json:"end_line_number,omitempty" yaml:"end_line_number,omitempty"` + EndColumnNumber int `json:"end_column_number,omitempty" yaml:"end_column_number,omitempty"` + Content *string `json:"content,omitempty" yaml:"content,omitempty"` } type ReportSchema interface { diff --git a/internal/report/source/source.go b/internal/report/source/source.go index 80c461f69..760436837 100644 --- a/internal/report/source/source.go +++ b/internal/report/source/source.go @@ -6,15 +6,14 @@ import ( // Source represents a part of a source file that is referenced in the scan report. type Source struct { - Filename string `json:"filename" yaml:"filename"` - FullFilename string `json:"full_filename" yaml:"full_filename"` - Language string `json:"language" yaml:"language"` - LanguageType string `json:"language_type" yaml:"language_type"` - StartLineNumber *int `json:"start_line_number" yaml:"start_line_number"` - StartColumnNumber *int `json:"start_column_number" yaml:"start_column_number"` - EndLineNumber *int `json:"end_line_number" yaml:"end_line_number"` - EndColumnNumber *int `json:"end_column_number" yaml:"end_column_number"` - Text *string `json:"text" yaml:"text"` + Filename string `json:"filename" yaml:"filename"` + FullFilename string `json:"full_filename" yaml:"full_filename"` + Language string `json:"language" yaml:"language"` + LanguageType string `json:"language_type" yaml:"language_type"` + StartLineNumber *int `json:"start_line_number" yaml:"start_line_number"` + StartColumnNumber *int `json:"start_column_number" yaml:"start_column_number"` + EndLineNumber *int `json:"end_line_number" yaml:"end_line_number"` + EndColumnNumber *int `json:"end_column_number" yaml:"end_column_number"` } func New( @@ -24,7 +23,6 @@ func New( startColumnNumber int, endLineNumber, endColumnNumber int, - text string, ) Source { var sourceStartLineNumber *int if startLineNumber != 0 { @@ -46,11 +44,6 @@ func New( sourceEndColumnNumber = &endColumnNumber } - var sourceText *string - if text != "" { - sourceText = &text - } - language := "" languageType := "" if fileInfo != nil { @@ -66,6 +59,5 @@ func New( StartColumnNumber: sourceStartColumnNumber, EndLineNumber: sourceEndLineNumber, EndColumnNumber: sourceEndColumnNumber, - Text: sourceText, } } diff --git a/internal/report/writer/detectors.go b/internal/report/writer/detectors.go index 95196e425..02a82d07e 100644 --- a/internal/report/writer/detectors.go +++ b/internal/report/writer/detectors.go @@ -67,7 +67,7 @@ func (report *Detectors) AddDataType(detectionType detections.DetectionType, det for nodeID, target := range values { classification := report.Classifier.Schema.Classify(classificationschema.ClassificationRequest{ Value: target.ToClassificationRequestDetection(), - Filename: target.GetNode().Source(false).Filename, + Filename: target.GetNode().Source().Filename, DetectorType: detectorType, }) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index b22235ed9..e2530dc67 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -84,14 +84,12 @@ func (scanner *Scanner) Scan( detection.MatchNode.ContentStart.Column, detection.MatchNode.ContentEnd.Line, detection.MatchNode.ContentEnd.Column, - fmt.Sprintf("bearer:expected %s", detection.RuleID), ), reportschema.Source{ StartLineNumber: detection.MatchNode.ContentStart.Line, EndLineNumber: detection.MatchNode.ContentEnd.Line, StartColumnNumber: detection.MatchNode.ContentStart.Column, EndColumnNumber: detection.MatchNode.ContentEnd.Column, - Content: detection.MatchNode.Content(), }) } @@ -109,14 +107,12 @@ func (scanner *Scanner) Scan( detection.MatchNode.ContentStart.Column, detection.MatchNode.ContentEnd.Line, detection.MatchNode.ContentEnd.Column, - data.Pattern, ), reportschema.Source{ StartLineNumber: detection.MatchNode.ContentStart.Line, EndLineNumber: detection.MatchNode.ContentEnd.Line, StartColumnNumber: detection.MatchNode.ContentStart.Column, EndColumnNumber: detection.MatchNode.ContentEnd.Column, - Content: detection.MatchNode.Content(), }) } @@ -157,7 +153,6 @@ func reportDatatypeDetection( property.Node.ContentStart.Column, property.Node.ContentEnd.Line, property.Node.ContentEnd.Column, - "", ), reportschema.Schema{ ObjectName: objectName, @@ -170,7 +165,6 @@ func reportDatatypeDetection( EndLineNumber: detection.MatchNode.ContentEnd.Line, StartColumnNumber: detection.MatchNode.ContentStart.Column, EndColumnNumber: detection.MatchNode.ContentEnd.Column, - Content: detection.MatchNode.Content(), }, }, )