Skip to content

Commit

Permalink
fix(recipe): type processed incorrectly (#1038)
Browse files Browse the repository at this point in the history
* fix(recipe): type processed incorrectly

* fix: sort data category groups to fix flakey snapshot
  • Loading branch information
gotbadger committed Jun 6, 2023
1 parent 0cc1d54 commit ba142fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/classification/interfaces/interfaces.go
Expand Up @@ -58,6 +58,7 @@ type RecipeURLMatch struct {
RecipeURL string
RecipeUUID string
RecipeName string
RecipeType string
RecipeSubType string
ExcludedURL bool
}
Expand Down Expand Up @@ -223,7 +224,7 @@ func (classifier *Classifier) Classify(data detections.Detection) (*ClassifiedIn
RecipeMatch: true,
RecipeUUID: recipeMatch.RecipeUUID,
RecipeName: recipeMatch.RecipeName,
RecipeType: "",
RecipeType: recipeMatch.RecipeType,
RecipeSubType: recipeMatch.RecipeSubType,
},
}
Expand Down Expand Up @@ -301,6 +302,7 @@ func (classifier *Classifier) FindMatchingRecipeUrl(detectionURL string) (*Recip
RecipeURL: recipeURL.URL,
RecipeUUID: recipe.UUID,
RecipeName: recipe.Name,
RecipeType: recipe.Type,
RecipeSubType: recipe.SubType,
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/classification/interfaces/interfaces_test.go
Expand Up @@ -44,6 +44,7 @@ func TestInterface(t *testing.T) {
Want: &interfaces.Classification{
URL: "https://api.stripe.com",
RecipeName: "Stripe",
RecipeType: "external_service",
RecipeSubType: "third_party",
RecipeUUID: "c24b836a-d035-49dc-808f-1912f16f690d",
RecipeMatch: true,
Expand Down Expand Up @@ -129,6 +130,7 @@ func TestInterface(t *testing.T) {
Want: &interfaces.Classification{
URL: "http://*.stripe.com",
RecipeName: "Stripe",
RecipeType: "external_service",
RecipeSubType: "third_party",
RecipeUUID: "c24b836a-d035-49dc-808f-1912f16f690d",
RecipeMatch: true,
Expand Down Expand Up @@ -160,6 +162,7 @@ func TestInterface(t *testing.T) {
Want: &interfaces.Classification{
URL: "https://googleapis.com/auth/spreadsheets",
RecipeName: "Google Spreadsheets",
RecipeType: "external_service",
RecipeSubType: "third_party",
RecipeUUID: "ebe2e05e-bc56-4204-9329-d9b8d3cf1837",
RecipeMatch: true,
Expand Down
4 changes: 4 additions & 0 deletions pkg/report/output/dataflow/datatypes/datatypes.go
@@ -1,6 +1,8 @@
package datatypes

import (
"sort"

"github.com/bearer/bearer/pkg/classification/db"
"github.com/bearer/bearer/pkg/commands/process/settings"
"github.com/bearer/bearer/pkg/report/detectors"
Expand Down Expand Up @@ -109,6 +111,8 @@ func (holder *Holder) addDatatype(
categoryGroups = append(categoryGroups, group.Name)
}

sort.Strings(categoryGroups)

datatype := datatypeHolder{
name: classification.Name,
categoryName: classification.Category.Name,
Expand Down

0 comments on commit ba142fa

Please sign in to comment.