Skip to content

Commit

Permalink
fix: incorrect framework component type (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet authored Dec 12, 2023
1 parent 44d602e commit eb61c4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/report/output/dataflow/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions internal/report/output/dataflow/components/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}`,
Expand Down

0 comments on commit eb61c4d

Please sign in to comment.