Skip to content

Commit

Permalink
pb-rust: schema generation bugs
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Leightcap <jack.leightcap@trailofbits.com>
  • Loading branch information
jleightcap committed Aug 4, 2023
1 parent 31c3ad9 commit f21f9ef
Show file tree
Hide file tree
Showing 26 changed files with 75 additions and 491 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jsonschema: docker-image-jsonschema
-c "cd defs/gen/jsonschema && ./jsonschema.sh -I ../../protos -I /googleapis/ --jsonschema_out=schemas ../../protos/*.proto"

gen/pb-rust/schemas: jsonschema
cp -r gen/jsonschema/schemas $@
cp -r gen/jsonschema/schemas gen/pb-rust

rust: docker-image gen/pb-rust/schemas
@echo "Generating rust protobuf files"
Expand Down
4 changes: 2 additions & 2 deletions gen/jsonschema/jsonschema.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
!/bin/sh
#!/bin/sh

set -u
set -e

protoc --plugin=/root/go/bin/protoc-gen-jsonschema \
--jsonschema_opt=disallow_additional_properties \
--jsonschema_opt=enforce_oneof \
--jsonschema_opt=enums_as_strings \
--jsonschema_opt=enums_as_strings_only \
--jsonschema_opt=file_extension=schema.json \
--jsonschema_opt=json_fieldnames \
"$@"
34 changes: 4 additions & 30 deletions gen/jsonschema/schemas/ArtifactVerificationOptions.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,15 @@
"keyDetails": {
"enum": [
"PUBLIC_KEY_DETAILS_UNSPECIFIED",
0,
"PKCS1_RSA_PKCS1V5",
1,
"PKCS1_RSA_PSS",
2,
"PKIX_RSA_PKCS1V5",
3,
"PKIX_RSA_PSS",
4,
"PKIX_ECDSA_P256_SHA_256",
5,
"PKIX_ECDSA_P256_HMAC_SHA_256",
6,
"PKIX_ED25519",
7
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"PKIX_ED25519"
],
"type": "string",
"title": "Public Key Details",
"description": "Details of a specific public key, capturing the the key encoding method, and signature algorithm. To avoid the possibility of contradicting formats such as PKCS1 with ED25519 the valid permutations are listed as a linear set instead of a cartesian set (i.e one combined variable instead of two, one for encoding and one for the signature algorithm)."
},
Expand Down Expand Up @@ -157,22 +142,11 @@
"type": {
"enum": [
"SUBJECT_ALTERNATIVE_NAME_TYPE_UNSPECIFIED",
0,
"EMAIL",
1,
"URI",
2,
"OTHER_NAME",
3
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"OTHER_NAME"
],
"type": "string",
"title": "Subject Alternative Name Type"
},
"regexp": {
Expand Down
13 changes: 2 additions & 11 deletions gen/jsonschema/schemas/Bundle.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,9 @@
"algorithm": {
"enum": [
"HASH_ALGORITHM_UNSPECIFIED",
0,
"SHA2_256",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"SHA2_256"
],
"type": "string",
"title": "This package defines commonly used message types within the Sigstore\n community.",
"description": "This package defines commonly used message types within the Sigstore community. Only a subset of the secure hash standard algorithms are supported. See \u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\u003e for more details. UNSPECIFIED SHOULD not be used, primary reason for inclusion is to force any proto JSON serialization to emit the used hash algorithm, as default option is to *omit* the default value of an enum (which is the first value, represented by '0'."
},
Expand Down
15 changes: 2 additions & 13 deletions gen/jsonschema/schemas/CertificateIdentities.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,11 @@
"type": {
"enum": [
"SUBJECT_ALTERNATIVE_NAME_TYPE_UNSPECIFIED",
0,
"EMAIL",
1,
"URI",
2,
"OTHER_NAME",
3
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"OTHER_NAME"
],
"type": "string",
"title": "Subject Alternative Name Type"
},
"regexp": {
Expand Down
15 changes: 2 additions & 13 deletions gen/jsonschema/schemas/CertificateIdentity.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,11 @@
"type": {
"enum": [
"SUBJECT_ALTERNATIVE_NAME_TYPE_UNSPECIFIED",
0,
"EMAIL",
1,
"URI",
2,
"OTHER_NAME",
3
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"OTHER_NAME"
],
"type": "string",
"title": "Subject Alternative Name Type"
},
"regexp": {
Expand Down
13 changes: 2 additions & 11 deletions gen/jsonschema/schemas/HashOutput.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@
"algorithm": {
"enum": [
"HASH_ALGORITHM_UNSPECIFIED",
0,
"SHA2_256",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"SHA2_256"
],
"type": "string",
"title": "This package defines commonly used message types within the Sigstore\n community.",
"description": "This package defines commonly used message types within the Sigstore community. Only a subset of the secure hash standard algorithms are supported. See \u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\u003e for more details. UNSPECIFIED SHOULD not be used, primary reason for inclusion is to force any proto JSON serialization to emit the used hash algorithm, as default option is to *omit* the default value of an enum (which is the first value, represented by '0'."
},
Expand Down
60 changes: 8 additions & 52 deletions gen/jsonschema/schemas/Input.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,9 @@
"algorithm": {
"enum": [
"HASH_ALGORITHM_UNSPECIFIED",
0,
"SHA2_256",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"SHA2_256"
],
"type": "string",
"title": "This package defines commonly used message types within the Sigstore\n community.",
"description": "This package defines commonly used message types within the Sigstore community. Only a subset of the secure hash standard algorithms are supported. See \u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\u003e for more details. UNSPECIFIED SHOULD not be used, primary reason for inclusion is to force any proto JSON serialization to emit the used hash algorithm, as default option is to *omit* the default value of an enum (which is the first value, represented by '0'."
},
Expand Down Expand Up @@ -249,30 +240,15 @@
"keyDetails": {
"enum": [
"PUBLIC_KEY_DETAILS_UNSPECIFIED",
0,
"PKCS1_RSA_PKCS1V5",
1,
"PKCS1_RSA_PSS",
2,
"PKIX_RSA_PKCS1V5",
3,
"PKIX_RSA_PSS",
4,
"PKIX_ECDSA_P256_SHA_256",
5,
"PKIX_ECDSA_P256_HMAC_SHA_256",
6,
"PKIX_ED25519",
7
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"PKIX_ED25519"
],
"type": "string",
"title": "Public Key Details",
"description": "Details of a specific public key, capturing the the key encoding method, and signature algorithm. To avoid the possibility of contradicting formats such as PKCS1 with ED25519 the valid permutations are listed as a linear set instead of a cartesian set (i.e one combined variable instead of two, one for encoding and one for the signature algorithm)."
},
Expand Down Expand Up @@ -329,22 +305,11 @@
"type": {
"enum": [
"SUBJECT_ALTERNATIVE_NAME_TYPE_UNSPECIFIED",
0,
"EMAIL",
1,
"URI",
2,
"OTHER_NAME",
3
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"OTHER_NAME"
],
"type": "string",
"title": "Subject Alternative Name Type"
},
"regexp": {
Expand Down Expand Up @@ -578,18 +543,9 @@
"hashAlgorithm": {
"enum": [
"HASH_ALGORITHM_UNSPECIFIED",
0,
"SHA2_256",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"SHA2_256"
],
"type": "string",
"title": "This package defines commonly used message types within the Sigstore\n community.",
"description": "This package defines commonly used message types within the Sigstore community. Only a subset of the secure hash standard algorithms are supported. See \u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\u003e for more details. UNSPECIFIED SHOULD not be used, primary reason for inclusion is to force any proto JSON serialization to emit the used hash algorithm, as default option is to *omit* the default value of an enum (which is the first value, represented by '0'."
},
Expand Down
13 changes: 2 additions & 11 deletions gen/jsonschema/schemas/MessageSignature.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,9 @@
"algorithm": {
"enum": [
"HASH_ALGORITHM_UNSPECIFIED",
0,
"SHA2_256",
1
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"SHA2_256"
],
"type": "string",
"title": "This package defines commonly used message types within the Sigstore\n community.",
"description": "This package defines commonly used message types within the Sigstore community. Only a subset of the secure hash standard algorithms are supported. See \u003chttps://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\u003e for more details. UNSPECIFIED SHOULD not be used, primary reason for inclusion is to force any proto JSON serialization to emit the used hash algorithm, as default option is to *omit* the default value of an enum (which is the first value, represented by '0'."
},
Expand Down
19 changes: 2 additions & 17 deletions gen/jsonschema/schemas/PublicKey.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,15 @@
"keyDetails": {
"enum": [
"PUBLIC_KEY_DETAILS_UNSPECIFIED",
0,
"PKCS1_RSA_PKCS1V5",
1,
"PKCS1_RSA_PSS",
2,
"PKIX_RSA_PKCS1V5",
3,
"PKIX_RSA_PSS",
4,
"PKIX_ECDSA_P256_SHA_256",
5,
"PKIX_ECDSA_P256_HMAC_SHA_256",
6,
"PKIX_ED25519",
7
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"PKIX_ED25519"
],
"type": "string",
"title": "Public Key Details",
"description": "Details of a specific public key, capturing the the key encoding method, and signature algorithm. To avoid the possibility of contradicting formats such as PKCS1 with ED25519 the valid permutations are listed as a linear set instead of a cartesian set (i.e one combined variable instead of two, one for encoding and one for the signature algorithm)."
},
Expand Down
19 changes: 2 additions & 17 deletions gen/jsonschema/schemas/PublicKeyIdentities.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,15 @@
"keyDetails": {
"enum": [
"PUBLIC_KEY_DETAILS_UNSPECIFIED",
0,
"PKCS1_RSA_PKCS1V5",
1,
"PKCS1_RSA_PSS",
2,
"PKIX_RSA_PKCS1V5",
3,
"PKIX_RSA_PSS",
4,
"PKIX_ECDSA_P256_SHA_256",
5,
"PKIX_ECDSA_P256_HMAC_SHA_256",
6,
"PKIX_ED25519",
7
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"PKIX_ED25519"
],
"type": "string",
"title": "Public Key Details",
"description": "Details of a specific public key, capturing the the key encoding method, and signature algorithm. To avoid the possibility of contradicting formats such as PKCS1 with ED25519 the valid permutations are listed as a linear set instead of a cartesian set (i.e one combined variable instead of two, one for encoding and one for the signature algorithm)."
},
Expand Down
15 changes: 2 additions & 13 deletions gen/jsonschema/schemas/SubjectAlternativeName.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,11 @@
"type": {
"enum": [
"SUBJECT_ALTERNATIVE_NAME_TYPE_UNSPECIFIED",
0,
"EMAIL",
1,
"URI",
2,
"OTHER_NAME",
3
],
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
"OTHER_NAME"
],
"type": "string",
"title": "Subject Alternative Name Type"
},
"regexp": {
Expand Down
Loading

0 comments on commit f21f9ef

Please sign in to comment.