diff --git a/new/detector/composition/java/java.go b/new/detector/composition/java/java.go index d2b13d75a..e6d979415 100644 --- a/new/detector/composition/java/java.go +++ b/new/detector/composition/java/java.go @@ -31,6 +31,7 @@ import ( java "github.com/bearer/bearer/new/language/implementation/java" "github.com/bearer/bearer/new/language/tree" languagetypes "github.com/bearer/bearer/new/language/types" + reporttypes "github.com/bearer/bearer/pkg/report/detectors" ) type Composition struct { @@ -112,7 +113,7 @@ func New( }() } - detector, err := datatype.New(lang, classifier.Schema) + detector, err := datatype.New(reporttypes.DetectorJava, lang, classifier.Schema) if err != nil { composition.Close() return nil, fmt.Errorf("failed to create datatype detector: %s", err) diff --git a/new/detector/composition/javascript/javascript.go b/new/detector/composition/javascript/javascript.go index 920d82afa..2064676e9 100644 --- a/new/detector/composition/javascript/javascript.go +++ b/new/detector/composition/javascript/javascript.go @@ -31,6 +31,7 @@ import ( "github.com/bearer/bearer/new/language/implementation/javascript" "github.com/bearer/bearer/new/language/tree" languagetypes "github.com/bearer/bearer/new/language/types" + reporttypes "github.com/bearer/bearer/pkg/report/detectors" ) type Composition struct { @@ -112,7 +113,7 @@ func New( }() } - detector, err := datatype.New(lang, classifier.Schema) + detector, err := datatype.New(reporttypes.DetectorJavascript, lang, classifier.Schema) if err != nil { composition.Close() return nil, fmt.Errorf("failed to create datatype detector: %s", err) diff --git a/new/detector/composition/ruby/ruby.go b/new/detector/composition/ruby/ruby.go index bec745746..cf8749c58 100644 --- a/new/detector/composition/ruby/ruby.go +++ b/new/detector/composition/ruby/ruby.go @@ -31,6 +31,7 @@ import ( "github.com/bearer/bearer/new/language/implementation/ruby" "github.com/bearer/bearer/new/language/tree" languagetypes "github.com/bearer/bearer/new/language/types" + reporttypes "github.com/bearer/bearer/pkg/report/detectors" ) type Composition struct { @@ -111,7 +112,7 @@ func New( }() } - detector, err := datatype.New(lang, classifier.Schema) + detector, err := datatype.New(reporttypes.DetectorRuby, lang, classifier.Schema) if err != nil { composition.Close() return nil, fmt.Errorf("failed to create datatype detector: %s", err) diff --git a/new/detector/implementation/generic/datatype/datatype.go b/new/detector/implementation/generic/datatype/datatype.go index c6953dbb5..d7e9cf117 100644 --- a/new/detector/implementation/generic/datatype/datatype.go +++ b/new/detector/implementation/generic/datatype/datatype.go @@ -25,13 +25,15 @@ type Property struct { } type datatypeDetector struct { + detectorType detectors.Type types.DetectorBase classifier *classificationschema.Classifier } -func New(lang languagetypes.Language, classifier *classificationschema.Classifier) (types.Detector, error) { +func New(detectorType detectors.Type, lang languagetypes.Language, classifier *classificationschema.Classifier) (types.Detector, error) { return &datatypeDetector{ - classifier: classifier, + detectorType: detectorType, + classifier: classifier, }, nil } @@ -73,7 +75,7 @@ func (detector *datatypeDetector) classifyObject( ) (Data, classificationschema.Classification, bool) { objectData := detection.Data.(generictypes.Object) - classification := detector.classifier.Classify(buildClassificationRequest(filename, name, objectData)) + classification := detector.classifier.Classify(buildClassificationRequest(detector.detectorType, filename, name, objectData)) containsValidClassification := classification.Classification.Decision.State == classify.Valid properties := make([]Property, len(objectData.Properties)) @@ -140,7 +142,7 @@ func (detector *datatypeDetector) classifyProperty( containsValidClassification || propertyClassification.Decision.State == classify.Valid } -func buildClassificationRequest(filename, name string, data generictypes.Object) classificationschema.ClassificationRequest { +func buildClassificationRequest(detectorType detectors.Type, filename, name string, data generictypes.Object) classificationschema.ClassificationRequest { var properties []*classificationschema.ClassificationRequestDetection for _, property := range data.Properties { @@ -156,7 +158,7 @@ func buildClassificationRequest(filename, name string, data generictypes.Object) SimpleType: schema.SimpleTypeUnknown, Properties: properties, }, - DetectorType: detectors.DetectorRuby, + DetectorType: detectorType, Filename: filename, } }