CycloneDX / specification

OWASP CycloneDX is a full-stack Bill of Materials (BOM) standard that provides advanced supply chain capabilities for cyber risk reduction. SBOM, SaaSBOM, HBOM, AI/ML-BOM, CBOM, OBOM, MBOM, VDR, and VEX
https://cyclonedx.org/
Apache License 2.0
338 stars 57 forks source link

wrong proto3 schema default values for enums #391

Open jkowalleck opened 4 months ago

jkowalleck commented 4 months ago

per proto3 schema definition, enum values of 0 are, per definition, used as "unspecified" or "fallback" values.

see https://protobuf.dev/programming-guides/enum/

enum Enum {
  A = 0;
  B = 1;
}

message Msg {
  optional Enum enum = 1;
}

Closed enums will parse the value 2 and store it in the message’s unknown field set. Accessors will report the field as being unset and will return the enum’s default value.

Therefore, enum value of 0 MUST be revisited.

The CDX v1.x protobuf schema has default values for enums, where XML/JSON does not. And this is for the fact, that protobuf schema uses value 0, where it should not.

When these enum values would be changed, this would be a breaking change.

This is a followup of https://github.com/CycloneDX/specification/pull/385


examples for wrong usage of 0 in enums: