From 05aa76bc60a5a32c8818270f7d0664e6e6b9f630 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 8 Jan 2021 04:22:17 -0800 Subject: [PATCH] Fix regex for custom board menu option titles Due to greedy matching, the previous regular expression matched against option properties in addition to the intended option titles. --- etc/schemas/arduino-boards-txt-definitions-schema.json | 6 +++--- internal/rule/rulefunction/platform.go | 2 +- internal/rule/schema/schemadata/bindata.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/etc/schemas/arduino-boards-txt-definitions-schema.json b/etc/schemas/arduino-boards-txt-definitions-schema.json index 5f01879e..b765a908 100644 --- a/etc/schemas/arduino-boards-txt-definitions-schema.json +++ b/etc/schemas/arduino-boards-txt-definitions-schema.json @@ -165,7 +165,7 @@ }, { "patternProperties": { - "menu\\..+\\..+$": { + "^menu\\.[^.]+\\.[^.]+$": { "$ref": "#/definitions/propertiesObjects/boardIDMenuMenuIDOptionID/permissive/object" }, "^[vp]id\\.[0-9]+$": { @@ -230,7 +230,7 @@ }, { "patternProperties": { - "menu\\..+\\..+$": { + "^menu\\.[^.]+\\.[^.]+$": { "$ref": "#/definitions/propertiesObjects/boardIDMenuMenuIDOptionID/specification/object" }, "^[vp]id\\.[0-9]+$": { @@ -295,7 +295,7 @@ }, { "patternProperties": { - "menu\\..+\\..+$": { + "^menu\\.[^.]+\\.[^.]+$": { "$ref": "#/definitions/propertiesObjects/boardIDMenuMenuIDOptionID/strict/object" }, "^[vp]id\\.[0-9]+$": { diff --git a/internal/rule/rulefunction/platform.go b/internal/rule/rulefunction/platform.go index 6b936240..41b4ae9a 100644 --- a/internal/rule/rulefunction/platform.go +++ b/internal/rule/rulefunction/platform.go @@ -245,7 +245,7 @@ func BoardsTxtBoardIDMenuMenuIDOptionIDLTMinLength() (result ruleresult.Type, ou return ruleresult.Skip, "boards.txt has no boards" } - nonCompliantBoardIDs := boardIDValueLTMinLength("menu\\..+\\..+", compliancelevel.Strict) + nonCompliantBoardIDs := boardIDValueLTMinLength("menu\\.[^.]+\\.[^.]+", compliancelevel.Strict) if len(nonCompliantBoardIDs) > 0 { return ruleresult.Fail, strings.Join(nonCompliantBoardIDs, ", ") diff --git a/internal/rule/schema/schemadata/bindata.go b/internal/rule/schema/schemadata/bindata.go index 0578006c..3967459b 100644 --- a/internal/rule/schema/schemadata/bindata.go +++ b/internal/rule/schema/schemadata/bindata.go @@ -237,7 +237,7 @@ var _arduinoBoardsTxtDefinitionsSchemaJson = []byte(`{ }, { "patternProperties": { - "menu\\..+\\..+$": { + "^menu\\.[^.]+\\.[^.]+$": { "$ref": "#/definitions/propertiesObjects/boardIDMenuMenuIDOptionID/permissive/object" }, "^[vp]id\\.[0-9]+$": { @@ -302,7 +302,7 @@ var _arduinoBoardsTxtDefinitionsSchemaJson = []byte(`{ }, { "patternProperties": { - "menu\\..+\\..+$": { + "^menu\\.[^.]+\\.[^.]+$": { "$ref": "#/definitions/propertiesObjects/boardIDMenuMenuIDOptionID/specification/object" }, "^[vp]id\\.[0-9]+$": { @@ -367,7 +367,7 @@ var _arduinoBoardsTxtDefinitionsSchemaJson = []byte(`{ }, { "patternProperties": { - "menu\\..+\\..+$": { + "^menu\\.[^.]+\\.[^.]+$": { "$ref": "#/definitions/propertiesObjects/boardIDMenuMenuIDOptionID/strict/object" }, "^[vp]id\\.[0-9]+$": {