From 501f8fd6e4aafbf106f6db5d0077398ec67d3dfb Mon Sep 17 00:00:00 2001 From: James Alseth Date: Sat, 1 Jul 2023 11:09:49 -0700 Subject: [PATCH] Init dev.sigstore.rekor.events.v1 package This package defines the messages for events that may be produced by Rekor. The first event is NewEntry which is published when a new entry is added to the log. Signed-off-by: James Alseth --- .../events/v1/sigstore_rekor_events.pb.go | 271 ++++++++++++++++++ .../dev/sigstore/rekor/events/__init__.py | 0 .../dev/sigstore/rekor/events/v1/__init__.py | 57 ++++ gen/pb-ruby/lib/sigstore_rekor_events_pb.rb | 35 +++ .../__generated__/sigstore_rekor_events.ts | 108 +++++++ protos/sigstore_rekor_events.proto | 69 +++++ 6 files changed, 540 insertions(+) create mode 100644 gen/pb-go/rekor/events/v1/sigstore_rekor_events.pb.go create mode 100644 gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/__init__.py create mode 100644 gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/v1/__init__.py create mode 100644 gen/pb-ruby/lib/sigstore_rekor_events_pb.rb create mode 100644 gen/pb-typescript/src/__generated__/sigstore_rekor_events.ts create mode 100644 protos/sigstore_rekor_events.proto diff --git a/gen/pb-go/rekor/events/v1/sigstore_rekor_events.pb.go b/gen/pb-go/rekor/events/v1/sigstore_rekor_events.pb.go new file mode 100644 index 00000000..f1142439 --- /dev/null +++ b/gen/pb-go/rekor/events/v1/sigstore_rekor_events.pb.go @@ -0,0 +1,271 @@ +// Copyright 2023 The Sigstore Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.6 +// source: sigstore_rekor_events.proto + +package v1 + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// NewEntry defines the CloudEvents (https://cloudevents.io/) message that +// is published when a new entry is added to Rekor. Adheres to the v1.0.2 schema +// defined in https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/cloudevents.json. +type NewEntry struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The CloudEvents specification version. + SpecVersion string `protobuf:"bytes,1,opt,name=spec_version,json=specversion,proto3" json:"spec_version,omitempty"` + // The unique id of the entry in the log. + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + // The JSON-encoded dev.sigstore.rekor.v1.TransparencyLogEntry message. + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + // The type of the encoded data. Must be "application/json". + DataType string `protobuf:"bytes,4,opt,name=data_type,json=datacontenttype,proto3" json:"data_type,omitempty"` + // The type of the message. Must be "dev.sigstore.rekor.events.v1.NewEntry". + Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` + // The source of the event. + Source string `protobuf:"bytes,6,opt,name=source,proto3" json:"source,omitempty"` + // The kind (aka type) of the entry. Must match the value in the + // dev.sigstore.rekor.v1.TransparencyLogEntry.KindVersion.kind field. + EntryKind string `protobuf:"bytes,7,opt,name=entry_kind,json=rekor_entry_kind,proto3" json:"entry_kind,omitempty"` + // The subject identifiers for the entities that signed the artifact + // uploaded to Rekor. This field may not be set if the entry_kind is not a + // format that supports this type of metadata. + Subjects []string `protobuf:"bytes,8,rep,name=subjects,json=rekor_signing_subjects,proto3" json:"subjects,omitempty"` + // The timestamp that the entry was added to the log. Should match the + // value in dev.sigstore.rekor.v1.TransparencyLogEntry.integrated_time. + Time *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=time,proto3" json:"time,omitempty"` +} + +func (x *NewEntry) Reset() { + *x = NewEntry{} + if protoimpl.UnsafeEnabled { + mi := &file_sigstore_rekor_events_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewEntry) ProtoMessage() {} + +func (x *NewEntry) ProtoReflect() protoreflect.Message { + mi := &file_sigstore_rekor_events_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewEntry.ProtoReflect.Descriptor instead. +func (*NewEntry) Descriptor() ([]byte, []int) { + return file_sigstore_rekor_events_proto_rawDescGZIP(), []int{0} +} + +func (x *NewEntry) GetSpecVersion() string { + if x != nil { + return x.SpecVersion + } + return "" +} + +func (x *NewEntry) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *NewEntry) GetData() string { + if x != nil { + return x.Data + } + return "" +} + +func (x *NewEntry) GetDataType() string { + if x != nil { + return x.DataType + } + return "" +} + +func (x *NewEntry) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *NewEntry) GetSource() string { + if x != nil { + return x.Source + } + return "" +} + +func (x *NewEntry) GetEntryKind() string { + if x != nil { + return x.EntryKind + } + return "" +} + +func (x *NewEntry) GetSubjects() []string { + if x != nil { + return x.Subjects + } + return nil +} + +func (x *NewEntry) GetTime() *timestamppb.Timestamp { + if x != nil { + return x.Time + } + return nil +} + +var File_sigstore_rekor_events_proto protoreflect.FileDescriptor + +var file_sigstore_rekor_events_proto_rawDesc = []byte{ + 0x0a, 0x1b, 0x73, 0x69, 0x67, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x6b, 0x6f, 0x72, + 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x64, + 0x65, 0x76, 0x2e, 0x73, 0x69, 0x67, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x72, 0x65, 0x6b, 0x6f, + 0x72, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, + 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc4, 0x02, + 0x0a, 0x08, 0x4e, 0x65, 0x77, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x26, 0x0a, 0x0c, 0x73, 0x70, + 0x65, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0b, 0x73, 0x70, 0x65, 0x63, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x13, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, + 0xe0, 0x41, 0x02, 0x52, 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x27, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, + 0x29, 0x0a, 0x0a, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x10, 0x72, 0x65, 0x6b, 0x6f, 0x72, 0x5f, + 0x65, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x73, 0x75, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x16, 0x72, 0x65, + 0x6b, 0x6f, 0x72, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x73, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, + 0x74, 0x69, 0x6d, 0x65, 0x42, 0x76, 0x0a, 0x22, 0x64, 0x65, 0x76, 0x2e, 0x73, 0x69, 0x67, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6b, 0x6f, 0x72, + 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x52, 0x65, 0x6b, 0x6f, + 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x69, 0x67, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2d, 0x73, 0x70, 0x65, + 0x63, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x62, 0x2d, 0x67, 0x6f, 0x2f, 0x72, 0x65, 0x6b, + 0x6f, 0x72, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_sigstore_rekor_events_proto_rawDescOnce sync.Once + file_sigstore_rekor_events_proto_rawDescData = file_sigstore_rekor_events_proto_rawDesc +) + +func file_sigstore_rekor_events_proto_rawDescGZIP() []byte { + file_sigstore_rekor_events_proto_rawDescOnce.Do(func() { + file_sigstore_rekor_events_proto_rawDescData = protoimpl.X.CompressGZIP(file_sigstore_rekor_events_proto_rawDescData) + }) + return file_sigstore_rekor_events_proto_rawDescData +} + +var file_sigstore_rekor_events_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_sigstore_rekor_events_proto_goTypes = []interface{}{ + (*NewEntry)(nil), // 0: dev.sigstore.rekor.events.v1.NewEntry + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp +} +var file_sigstore_rekor_events_proto_depIdxs = []int32{ + 1, // 0: dev.sigstore.rekor.events.v1.NewEntry.time:type_name -> google.protobuf.Timestamp + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_sigstore_rekor_events_proto_init() } +func file_sigstore_rekor_events_proto_init() { + if File_sigstore_rekor_events_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_sigstore_rekor_events_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewEntry); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_sigstore_rekor_events_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_sigstore_rekor_events_proto_goTypes, + DependencyIndexes: file_sigstore_rekor_events_proto_depIdxs, + MessageInfos: file_sigstore_rekor_events_proto_msgTypes, + }.Build() + File_sigstore_rekor_events_proto = out.File + file_sigstore_rekor_events_proto_rawDesc = nil + file_sigstore_rekor_events_proto_goTypes = nil + file_sigstore_rekor_events_proto_depIdxs = nil +} diff --git a/gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/__init__.py b/gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/v1/__init__.py b/gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/v1/__init__.py new file mode 100644 index 00000000..d892bb37 --- /dev/null +++ b/gen/pb-python/sigstore_protobuf_specs/dev/sigstore/rekor/events/v1/__init__.py @@ -0,0 +1,57 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# sources: sigstore_rekor_events.proto +# plugin: python-betterproto +from dataclasses import dataclass +from datetime import datetime +from typing import List + +import betterproto + + +@dataclass(eq=False, repr=False) +class NewEntry(betterproto.Message): + """ + NewEntry defines the CloudEvents (https://cloudevents.io/) message that is + published when a new entry is added to Rekor. Adheres to the v1.0.2 schema + defined in https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/form + ats/cloudevents.json. + """ + + spec_version: str = betterproto.string_field(1) + """The CloudEvents specification version.""" + + id: str = betterproto.string_field(2) + """The unique id of the entry in the log.""" + + data: str = betterproto.string_field(3) + """The JSON-encoded dev.sigstore.rekor.v1.TransparencyLogEntry message.""" + + data_type: str = betterproto.string_field(4) + """The type of the encoded data. Must be "application/json".""" + + type: str = betterproto.string_field(5) + """ + The type of the message. Must be "dev.sigstore.rekor.events.v1.NewEntry". + """ + + source: str = betterproto.string_field(6) + """The source of the event.""" + + entry_kind: str = betterproto.string_field(7) + """ + The kind (aka type) of the entry. Must match the value in the + dev.sigstore.rekor.v1.TransparencyLogEntry.KindVersion.kind field. + """ + + subjects: List[str] = betterproto.string_field(8) + """ + The subject identifiers for the entities that signed the artifact uploaded + to Rekor. This field may not be set if the entry_kind is not a format that + supports this type of metadata. + """ + + time: datetime = betterproto.message_field(9) + """ + The timestamp that the entry was added to the log. Should match the value + in dev.sigstore.rekor.v1.TransparencyLogEntry.integrated_time. + """ diff --git a/gen/pb-ruby/lib/sigstore_rekor_events_pb.rb b/gen/pb-ruby/lib/sigstore_rekor_events_pb.rb new file mode 100644 index 00000000..cde035c7 --- /dev/null +++ b/gen/pb-ruby/lib/sigstore_rekor_events_pb.rb @@ -0,0 +1,35 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: sigstore_rekor_events.proto + +require 'google/protobuf' + +require 'google/api/field_behavior_pb' +require 'google/protobuf/timestamp_pb' + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("sigstore_rekor_events.proto", :syntax => :proto3) do + add_message "dev.sigstore.rekor.events.v1.NewEntry" do + optional :spec_version, :string, 1, json_name: "specversion" + optional :id, :string, 2 + optional :data, :string, 3 + optional :data_type, :string, 4, json_name: "datacontenttype" + optional :type, :string, 5 + optional :source, :string, 6 + optional :entry_kind, :string, 7, json_name: "rekor_entry_kind" + repeated :subjects, :string, 8, json_name: "rekor_signing_subjects" + optional :time, :message, 9, "google.protobuf.Timestamp" + end + end +end + +module Dev + module Sigstore + module Rekor + module Events + module V1 + NewEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dev.sigstore.rekor.events.v1.NewEntry").msgclass + end + end + end + end +end diff --git a/gen/pb-typescript/src/__generated__/sigstore_rekor_events.ts b/gen/pb-typescript/src/__generated__/sigstore_rekor_events.ts new file mode 100644 index 00000000..f13b1ceb --- /dev/null +++ b/gen/pb-typescript/src/__generated__/sigstore_rekor_events.ts @@ -0,0 +1,108 @@ +/* eslint-disable */ +import { Timestamp } from "./google/protobuf/timestamp"; + +/** + * NewEntry defines the CloudEvents (https://cloudevents.io/) message that + * is published when a new entry is added to Rekor. Adheres to the v1.0.2 schema + * defined in https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/cloudevents.json. + */ +export interface NewEntry { + /** The CloudEvents specification version. */ + specVersion: string; + /** The unique id of the entry in the log. */ + id: string; + /** The JSON-encoded dev.sigstore.rekor.v1.TransparencyLogEntry message. */ + data: string; + /** The type of the encoded data. Must be "application/json". */ + dataType: string; + /** The type of the message. Must be "dev.sigstore.rekor.events.v1.NewEntry". */ + type: string; + /** The source of the event. */ + source: string; + /** + * The kind (aka type) of the entry. Must match the value in the + * dev.sigstore.rekor.v1.TransparencyLogEntry.KindVersion.kind field. + */ + entryKind: string; + /** + * The subject identifiers for the entities that signed the artifact + * uploaded to Rekor. This field may not be set if the entry_kind is not a + * format that supports this type of metadata. + */ + subjects: string[]; + /** + * The timestamp that the entry was added to the log. Should match the + * value in dev.sigstore.rekor.v1.TransparencyLogEntry.integrated_time. + */ + time: Date | undefined; +} + +function createBaseNewEntry(): NewEntry { + return { + specVersion: "", + id: "", + data: "", + dataType: "", + type: "", + source: "", + entryKind: "", + subjects: [], + time: undefined, + }; +} + +export const NewEntry = { + fromJSON(object: any): NewEntry { + return { + specVersion: isSet(object.specversion) ? String(object.specversion) : "", + id: isSet(object.id) ? String(object.id) : "", + data: isSet(object.data) ? String(object.data) : "", + dataType: isSet(object.datacontenttype) ? String(object.datacontenttype) : "", + type: isSet(object.type) ? String(object.type) : "", + source: isSet(object.source) ? String(object.source) : "", + entryKind: isSet(object.rekor_entry_kind) ? String(object.rekor_entry_kind) : "", + subjects: Array.isArray(object?.rekor_signing_subjects) + ? object.rekor_signing_subjects.map((e: any) => String(e)) + : [], + time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined, + }; + }, + + toJSON(message: NewEntry): unknown { + const obj: any = {}; + message.specVersion !== undefined && (obj.specversion = message.specVersion); + message.id !== undefined && (obj.id = message.id); + message.data !== undefined && (obj.data = message.data); + message.dataType !== undefined && (obj.datacontenttype = message.dataType); + message.type !== undefined && (obj.type = message.type); + message.source !== undefined && (obj.source = message.source); + message.entryKind !== undefined && (obj.rekor_entry_kind = message.entryKind); + if (message.subjects) { + obj.rekor_signing_subjects = message.subjects.map((e) => e); + } else { + obj.rekor_signing_subjects = []; + } + message.time !== undefined && (obj.time = message.time.toISOString()); + return obj; + }, +}; + +function fromTimestamp(t: Timestamp): Date { + let millis = Number(t.seconds) * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/protos/sigstore_rekor_events.proto b/protos/sigstore_rekor_events.proto new file mode 100644 index 00000000..4585a40d --- /dev/null +++ b/protos/sigstore_rekor_events.proto @@ -0,0 +1,69 @@ +// Copyright 2023 The Sigstore Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; +package dev.sigstore.rekor.events.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/sigstore/protobuf-specs/gen/pb-go/rekor/events/v1"; +option java_package = "dev.sigstore.proto.rekor.events.v1"; +option java_multiple_files = true; +option java_outer_classname = "RekorEventsProto"; + +// NewEntry defines the CloudEvents (https://cloudevents.io/) message that +// is published when a new entry is added to Rekor. Adheres to the v1.0.2 schema +// defined in https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/cloudevents.json. +message NewEntry { + // The CloudEvents specification version. + string spec_version = 1 [ + json_name="specversion", + (google.api.field_behavior)=REQUIRED + ]; + + // The unique id of the entry in the log. + string id = 2 [(google.api.field_behavior)=REQUIRED]; + + // The JSON-encoded dev.sigstore.rekor.v1.TransparencyLogEntry message. + string data = 3 [(google.api.field_behavior)=REQUIRED]; + + // The type of the encoded data. Must be "application/json". + string data_type = 4 [ + json_name="datacontenttype", + (google.api.field_behavior)=REQUIRED + ]; + + // The type of the message. Must be "dev.sigstore.rekor.events.v1.NewEntry". + string type = 5 [(google.api.field_behavior)=REQUIRED]; + + // The source of the event. + string source = 6 [(google.api.field_behavior)=REQUIRED]; + + // The kind (aka type) of the entry. Must match the value in the + // dev.sigstore.rekor.v1.TransparencyLogEntry.KindVersion.kind field. + string entry_kind = 7 [ + json_name="rekor_entry_kind", + (google.api.field_behavior)=REQUIRED + ]; + + // The subject identifiers for the entities that signed the artifact + // uploaded to Rekor. This field may not be set if the entry_kind is not a + // format that supports this type of metadata. + repeated string subjects = 8 [json_name="rekor_signing_subjects"]; + + // The timestamp that the entry was added to the log. Should match the + // value in dev.sigstore.rekor.v1.TransparencyLogEntry.integrated_time. + .google.protobuf.Timestamp time = 9; +}