Skip to content

Commit

Permalink
pb-rust: serde camelCase
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 Jul 19, 2023
1 parent dda8749 commit b7d905d
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 24 deletions.
1 change: 1 addition & 0 deletions gen/pb-rust/codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fn main() -> anyhow::Result<()> {
prost_build::Config::new()
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.type_attribute(".", r#"#[serde(rename_all = "camelCase")]"#)
.compile_well_known_types()
.extern_path(".google.protobuf", "::pbjson_types")
.out_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../src/codegen"))
Expand Down
5 changes: 5 additions & 0 deletions gen/pb-rust/src/codegen/dev.sigstore.bundle.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/// Currently only RFC3161 signatures are provided. More formats may be added
/// in the future.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimestampVerificationData {
Expand All @@ -18,6 +19,7 @@ pub struct TimestampVerificationData {
/// VerificationMaterial captures details on the materials used to verify
/// signatures.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationMaterial {
Expand All @@ -42,6 +44,7 @@ pub struct VerificationMaterial {
/// Nested message and enum types in `VerificationMaterial`.
pub mod verification_material {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Content {
Expand All @@ -52,6 +55,7 @@ pub mod verification_material {
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Bundle {
Expand All @@ -73,6 +77,7 @@ pub struct Bundle {
/// Nested message and enum types in `Bundle`.
pub mod bundle {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Content {
Expand Down
17 changes: 17 additions & 0 deletions gen/pb-rust/src/codegen/dev.sigstore.common.v1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// HashOutput captures a digest of a 'message' (generic octet sequence)
/// and the corresponding hash algorithm used.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HashOutput {
Expand All @@ -13,6 +14,7 @@ pub struct HashOutput {
}
/// MessageSignature stores the computed signature over a message.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MessageSignature {
Expand All @@ -32,6 +34,7 @@ pub struct MessageSignature {
}
/// LogId captures the identity of a transparency log.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogId {
Expand All @@ -44,6 +47,7 @@ pub struct LogId {
}
/// This message holds a RFC 3161 timestamp.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Rfc3161SignedTimestamp {
Expand All @@ -53,6 +57,7 @@ pub struct Rfc3161SignedTimestamp {
pub signed_timestamp: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublicKey {
Expand All @@ -70,6 +75,7 @@ pub struct PublicKey {
/// PublicKeyIdentifier can be used to identify an (out of band) delivered
/// key, to verify a signature.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublicKeyIdentifier {
Expand All @@ -87,6 +93,7 @@ pub struct PublicKeyIdentifier {
}
/// An ASN.1 OBJECT IDENTIFIER
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ObjectIdentifier {
Expand All @@ -95,6 +102,7 @@ pub struct ObjectIdentifier {
}
/// An OID and the corresponding (byte) value.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ObjectIdentifierValuePair {
Expand All @@ -104,6 +112,7 @@ pub struct ObjectIdentifierValuePair {
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DistinguishedName {
Expand All @@ -113,6 +122,7 @@ pub struct DistinguishedName {
pub common_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct X509Certificate {
Expand All @@ -121,6 +131,7 @@ pub struct X509Certificate {
pub raw_bytes: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubjectAlternativeName {
Expand All @@ -132,6 +143,7 @@ pub struct SubjectAlternativeName {
/// Nested message and enum types in `SubjectAlternativeName`.
pub mod subject_alternative_name {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Identity {
Expand All @@ -146,6 +158,7 @@ pub mod subject_alternative_name {
}
/// A chain of X.509 certificates.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct X509CertificateChain {
Expand Down Expand Up @@ -174,6 +187,7 @@ pub struct X509CertificateChain {
/// End is optional to be able to capture a period that has started but
/// has no known end.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimeRange {
Expand All @@ -190,6 +204,7 @@ pub struct TimeRange {
/// option is to *omit* the default value of an enum (which is the first
/// value, represented by '0'.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum HashAlgorithm {
Expand Down Expand Up @@ -223,6 +238,7 @@ impl HashAlgorithm {
/// cartesian set (i.e one combined variable instead of two, one for encoding
/// and one for the signature algorithm).
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PublicKeyDetails {
Expand Down Expand Up @@ -279,6 +295,7 @@ impl PublicKeyDetails {
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SubjectAlternativeNameType {
Expand Down
5 changes: 5 additions & 0 deletions gen/pb-rust/src/codegen/dev.sigstore.rekor.v1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// KindVersion contains the entry's kind and api version.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KindVersion {
Expand All @@ -20,6 +21,7 @@ pub struct KindVersion {
/// The signature has the same format as
/// InclusionPromise.signed_entry_timestamp. See below for more details.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Checkpoint {
Expand All @@ -29,6 +31,7 @@ pub struct Checkpoint {
/// InclusionProof is the proof returned from the transparency log. Can
/// be used for offline or online verification against the log.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InclusionProof {
Expand Down Expand Up @@ -65,6 +68,7 @@ pub struct InclusionProof {
/// This is used to verify the integration timestamp's value and that the log
/// has promised to include the entry.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InclusionPromise {
Expand All @@ -80,6 +84,7 @@ pub struct InclusionPromise {
/// the response from Rekor) is similar to a Signed Certificate Timestamp
/// as described here <https://www.rfc-editor.org/rfc/rfc6962.html#section-3.2.>
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransparencyLogEntry {
Expand Down
3 changes: 3 additions & 0 deletions gen/pb-rust/src/codegen/dev.sigstore.trustroot.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/// The included parameters are the minimal set required to identify a log,
/// and verify an inclusion proof/promise.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransparencyLogInstance {
Expand All @@ -25,6 +26,7 @@ pub struct TransparencyLogInstance {
/// CertificateAuthority enlists the information required to identify which
/// CA to use and perform signature verification.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CertificateAuthority {
Expand Down Expand Up @@ -70,6 +72,7 @@ pub struct CertificateAuthority {
/// All the listed instances SHOULD be sorted by the 'valid_for' in ascending
/// order, that is, the oldest instance first and the current instance last.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrustedRoot {
Expand Down
11 changes: 11 additions & 0 deletions gen/pb-rust/src/codegen/dev.sigstore.verification.v1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// The identity of a X.509 Certificate signer.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CertificateIdentity {
Expand All @@ -17,13 +18,15 @@ pub struct CertificateIdentity {
>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CertificateIdentities {
#[prost(message, repeated, tag = "1")]
pub identities: ::prost::alloc::vec::Vec<CertificateIdentity>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublicKeyIdentities {
Expand All @@ -33,6 +36,7 @@ pub struct PublicKeyIdentities {
/// A light-weight set of options/policies for identifying trusted signers,
/// used during verification of a single artifact.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArtifactVerificationOptions {
Expand Down Expand Up @@ -69,6 +73,7 @@ pub struct ArtifactVerificationOptions {
/// Nested message and enum types in `ArtifactVerificationOptions`.
pub mod artifact_verification_options {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TlogOptions {
Expand All @@ -83,6 +88,7 @@ pub mod artifact_verification_options {
pub disable: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CtlogOptions {
Expand All @@ -100,6 +106,7 @@ pub mod artifact_verification_options {
pub disable: bool,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimestampAuthorityOptions {
Expand All @@ -114,6 +121,7 @@ pub mod artifact_verification_options {
/// is an error. If at least one provided identity is found as a
/// signer, the verification is considered successful.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Signers {
Expand All @@ -133,6 +141,7 @@ pub mod artifact_verification_options {
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Artifact {
Expand All @@ -142,6 +151,7 @@ pub struct Artifact {
/// Nested message and enum types in `Artifact`.
pub mod artifact {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
Expand All @@ -156,6 +166,7 @@ pub mod artifact {
/// Input captures all that is needed to call the bundle verification method,
/// to verify a single artifact referenced by the bundle.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Input {
Expand Down
1 change: 1 addition & 0 deletions gen/pb-rust/src/codegen/google.api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
///
/// Note: This enum **may** receive new values in the future.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum FieldBehavior {
Expand Down
2 changes: 2 additions & 0 deletions gen/pb-rust/src/codegen/io.intoto.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// An authenticated message of arbitrary type.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Envelope {
Expand All @@ -24,6 +25,7 @@ pub struct Envelope {
pub signatures: ::prost::alloc::vec::Vec<Signature>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Signature {
Expand Down
24 changes: 0 additions & 24 deletions gen/pb-rust/tests/serialize_primitive.rs

This file was deleted.

Loading

0 comments on commit b7d905d

Please sign in to comment.