From 653d64ca0b62fc3d8e5cd42d611c7926dcf8c68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fabianski?= Date: Thu, 17 Aug 2023 16:58:33 +0200 Subject: [PATCH] fix: remove cold from flu patterns (#1193) --- .../178_flu.json | 2 +- pkg/classification/schema/schema.go | 1 - pkg/classification/schema/schema_test.go | 44 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/pkg/classification/db/data_type_classification_patterns/178_flu.json b/pkg/classification/db/data_type_classification_patterns/178_flu.json index 44a9493ed..69388344b 100644 --- a/pkg/classification/db/data_type_classification_patterns/178_flu.json +++ b/pkg/classification/db/data_type_classification_patterns/178_flu.json @@ -6,7 +6,7 @@ "exclude_types": ["boolean"], "friendly_name": "Flu", "health_context_data_type_uuid": null, - "include_regexp": "\\b(flu|influenza|cold)\\b", + "include_regexp": "\\b(flu|influenza)\\b", "match_column": true, "match_object": false, "object_type": ["known", "unknown_extended"] diff --git a/pkg/classification/schema/schema.go b/pkg/classification/schema/schema.go index d7b0da767..62ccf96fe 100644 --- a/pkg/classification/schema/schema.go +++ b/pkg/classification/schema/schema.go @@ -279,7 +279,6 @@ func (classifier *Classifier) classifyKnownObject( } classifiedDatatype.Properties[i] = classifyAsInvalid(detection.Properties[i], "invalid_property", subjectName) - } if validProperties { diff --git a/pkg/classification/schema/schema_test.go b/pkg/classification/schema/schema_test.go index e3effd3cf..d0ac2c5c2 100644 --- a/pkg/classification/schema/schema_test.go +++ b/pkg/classification/schema/schema_test.go @@ -904,6 +904,7 @@ func TestSchemaObjectClassification(t *testing.T) { }, }, } + classifier := schema.New( schema.Config{ DataTypes: db.Default().DataTypes, @@ -919,4 +920,47 @@ func TestSchemaObjectClassification(t *testing.T) { assert.Equal(t, testCase.Want, output.Classification) }) } + + t.Run("incorrect Personal health history classification", func(t *testing.T) { + output := classifier.Classify( + schema.ClassificationRequest{ + Filename: "src/components/order/client-transaction-modals/withdraw-vault/index.jsx", + DetectorType: detectors.DetectorJavascript, + Value: &schema.ClassificationRequestDetection{ + Name: "selfManagedCustodySigningSteps", + SimpleType: reportschema.SimpleTypeObject, + Properties: []*schema.ClassificationRequestDetection{ + { + Name: "cold", + SimpleType: reportschema.SimpleTypeString, + }, + }, + }, + }) + + assert.Equal(t, &schema.ClassifiedDatatype{ + Name: "selfManagedCustodySigningSteps", + Properties: []*schema.ClassifiedDatatype{ + { + Name: "cold", + Properties: nil, + Classification: schema.Classification{ + Name: "cold", + DataType: nil, + Decision: classify.ClassificationDecision{ + State: classify.Invalid, + Reason: "invalid_property", + }, + }, + }, + }, + Classification: schema.Classification{ + Name: "self managed custody signing steps", + Decision: classify.ClassificationDecision{ + State: classify.Invalid, + Reason: "valid_object_with_invalid_properties", + }, + }, + }, output) + }) }