From eb61c4d7bc62e1975d04514d8ebd577a0719dfe3 Mon Sep 17 00:00:00 2001 From: elsapet Date: Tue, 12 Dec 2023 17:25:36 +0200 Subject: [PATCH] fix: incorrect framework component type (#1436) --- .../output/dataflow/components/components.go | 2 +- .../dataflow/components/components_test.go | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/internal/report/output/dataflow/components/components.go b/internal/report/output/dataflow/components/components.go index dc9bbed91..2c50405d5 100644 --- a/internal/report/output/dataflow/components/components.go +++ b/internal/report/output/dataflow/components/components.go @@ -143,7 +143,7 @@ func (holder *Holder) AddFramework(classifiedDetection frameworkclassification.C return nil } - componentType := getComponentType(classifiedDetection.Classification.Decision.Reason, classifiedDetection.Classification.Decision.Reason) + componentType := getComponentType(classifiedDetection.Classification.RecipeType, classifiedDetection.Classification.Decision.Reason) componentSubType := classifiedDetection.Classification.RecipeSubType if classifiedDetection.Classification.Decision.State == classify.Valid { diff --git a/internal/report/output/dataflow/components/components_test.go b/internal/report/output/dataflow/components/components_test.go index bba30679f..d0cd1a3aa 100644 --- a/internal/report/output/dataflow/components/components_test.go +++ b/internal/report/output/dataflow/components/components_test.go @@ -63,6 +63,26 @@ func TestDataflowComponents(t *testing.T) { }, }, }, + { + Name: "single detection - framework", + FileContent: `{ "detector_type": "rails", "type": "framework_classified", "source": {"filename": "config/storage.yml", "line_number": 5, "start_line_number": 5}, "classification": { "Decision": { "state": "valid" }, "recipe_name": "Disk", "recipe_match": true, "recipe_type": "data_type", "recipe_sub_type": "flat_file"}}`, + Want: []types.Component{ + { + Name: "Disk", + Type: "data_type", + SubType: "flat_file", + UUID: "", + Locations: []types.ComponentLocation{ + { + Detector: "rails", + FullFilename: "config/storage.yml", + Filename: "config/storage.yml", + LineNumber: 5, + }, + }, + }, + }, + }, { Name: "single detection - interface - no classification", FileContent: `{ "detector_type": "ruby", "type": "interface_classified", "source": {"filename": "billing.rb", "line_number": 2, "start_line_number": 2}}`,