go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/provenance/api/snooperpb/v1/report.proto (about) 1 // Copyright 2022 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 syntax = "proto3"; 16 17 package provenance.snooperpb; 18 19 option go_package = "go.chromium.org/luci/provenance/api/snooperpb/v1;snooperpb"; 20 21 import "google/protobuf/empty.proto"; 22 import "google/protobuf/timestamp.proto"; 23 import "go.chromium.org/luci/cipd/api/cipd/v1/repo.proto"; 24 25 service SelfReport { 26 // Interface to report cipd packages admitted on the local machine. 27 rpc ReportCipd(ReportCipdRequest) returns (google.protobuf.Empty); 28 29 // Interface to report git repos checked out on the local machine. 30 rpc ReportGit(ReportGitRequest) returns (google.protobuf.Empty); 31 32 // Interface to report gcs artifacts downloaded on a local machine. 33 rpc ReportGcs(ReportGcsRequest) returns (google.protobuf.Empty); 34 35 // Reports running task's stage. A task is typically a collection of 36 // workflows/statements. Some of these statements can be grouped together 37 // to define a stage, e.g. when a task is downloading sources/deps, it is 38 // known as `FETCH` stage. 39 // For details read go/snoopy-design (Google-internal). 40 rpc ReportTaskStage(ReportTaskStageRequest) returns (google.protobuf.Empty); 41 42 // Reports a PID to track execution of the process. When implementing the 43 // provenance server ensure safeguards to the end point with strict input 44 // validation. 45 rpc ReportPID(ReportPIDRequest) returns (google.protobuf.Empty); 46 47 // Reports digest of produced artifact from a task. 48 rpc ReportArtifactDigest(ReportArtifactDigestRequest) returns (google.protobuf.Empty); 49 } 50 51 // Indicator to task status. This is used to annotate logs when a task starts 52 // ends or reaches a certain "interesting" stage. 53 // 54 // This is crucial to enforce security policies based on current state of the 55 // task. For example, more restrictive network connections can be applied when a 56 // task reaches `compile` stage. 57 // 58 // Below is a brief rationale behind each steps: 59 // * STARTED: provenance of an artifact captures sources that goes into a 60 // build. A single compute resource typically outlives a task, in 61 // other words, a single machine can run multiple tasks in it's 62 // lifetime. Task start indicates the capturing time window began. 63 // * FETCH: typically a task depends on a bunch of dependencies that are 64 // fetched to set up the environment before compiling the artifact. 65 // Fetch indicates that the task is currently installing these deps. 66 // * COMPILE: ideally in compile step, there shouldn't be any new fetching. 67 // * UPLOAD: after finishing compilation, this step indicates built artifacts 68 // are being uploaded to its destination. A single task can have 69 // multiple produced artifacts. 70 // * UPLOAD_COMPLETE: it indicates all produced artifacts have been uploaded. 71 // This is crucial to closing the capturing time window for 72 // provenance generation. 73 // * TEST: often a task runs regression tests after an artifact has been 74 // produced. Some times requirements around this tests is an open 75 // environment which might not be safe for other task phases. To 76 // support effective tests, some policies can be lifted at this stage. 77 // (Although it is highly encouraged to schedule tests on a separate 78 // machine when possible to minimize risks of cross-contamination). 79 // * COMPLETE: complete indicates whether a task execution finished. This is 80 // crucial for server to set as this creates a clear boundary 81 // between subsequent tasks on a same machine. 82 enum TaskStage { 83 STAGE_UNSPECIFIED = 0; 84 STARTED = 1; 85 FETCH = 2; 86 COMPILE = 3; 87 UPLOAD = 4; 88 UPLOAD_COMPLETE = 5; 89 TEST = 6; 90 COMPLETE = 7; 91 } 92 93 // Identifies storage location of a particular artifact. This will be used to 94 // attach provenance: 95 // * GCS: provenance will be uploaded alongside the artifact. 96 // * CIPD: provenance will be added to package metadata. 97 // Currently we support provenance for two types of artifacts (gcs, cipd). 98 message Artifact { 99 // Artifacts stored on CIPD. This defaults to prod instance of CIPD. 100 message CIPD { 101 // Identifies a hierarchical package. This will be the absolute name 102 // of a package (including path). 103 string package_name = 1; 104 // Unique identifier of an instance of a package. 105 string instance_id = 2; 106 // CIPD backend host (dev/prod) where the artifact is stored. 107 // If not provided, default is CIPD prod host. 108 string host = 3; 109 } 110 oneof kind { 111 // Artifacts stored on Google Cloud Storage, e.g. Chrome binaries. 112 // Identifier of artifact's storage location, e.g. 113 // gs://example-bucket/app/1.2.3.4/mac64/bin.dmg 114 string gcs = 1; 115 CIPD cipd = 2; 116 } 117 } 118 119 message CipdReport { 120 // An identifier to map multiple reports to a machine/task. This is 121 // going to be the hash(access_token) used by bots to make requests 122 // to luci services. 123 string requestor_id = 1; 124 125 // CIPD package name requested/installed on the machine. 126 string package_name = 2; 127 128 // Unique identifier of the package instance, a.k.a. instance_id. 129 string iid = 3; 130 131 // CIPD tags attached to the deployed package. 132 repeated cipd.Tag tags = 4; 133 134 // CIPD refs attached to the deployed package. 135 repeated cipd.Ref refs = 5; 136 137 // Event timestamp. This is local to the service, not necessarily same as 138 // the reflected recorded timestamp on the logs. 139 google.protobuf.Timestamp event_ts = 6; 140 } 141 142 message GcsReport { 143 // An identifier to map multiple reports to a machine/task. This is 144 // going to be a build identifier. 145 string requestor_id = 1; 146 147 // GCS URI for the artifact downloaded on the machine. 148 string gcs_uri = 2; 149 150 // Digest of the downloaded artifact. 151 string digest = 3; 152 153 // Event timestamp. This is local to the service, not necessarily same as 154 // the reflected recorded timestamp on the logs. 155 google.protobuf.Timestamp event_ts = 4; 156 } 157 158 message GitReport { 159 // An identifier to map multiple reports to a machine/task. Reporter do not 160 // need to set this. It is used by the server to group reports together and 161 // bind them to a single task. 162 string requestor_id = 1; 163 164 // Git repository URL. 165 string repo = 2; 166 // Commit that was fetched for this repo. 167 string commit = 3; 168 // This is coming from an upstream dependency, although a checkout can be 169 // uniquely attributed by a repo and a commit, they don't often produce 170 // measurable inputs for security policy. 171 // For example, a git repo may have multiple refs/branches and only some of 172 // them may have `Code Review` required. 173 // 174 // To make a security policy decision about a particular commit, sometimes 175 // it is useful to know which branch/ref the commit is associated with, note 176 // a single commit can be associated with multiple branches, but the highest 177 // security policy will always be enforced. 178 // Scenario: 179 // Git repo: "http://repo.git" 180 // Commit : "deadbeef" 181 // Refs : ["refs/heads/main", "refs/feature/experimental"] 182 // In this example, the particular commit belongs to two branches, one does 183 // not have mandatory code review (experimental) but the other does. 184 // 185 // Irrespective of the order of where the commit belonged first, it is 186 // certain that the change was reviewed as this was merged to main branch. 187 string refs = 4; 188 189 // Event timestamp. This is local to the service, not necessarily same as 190 // the reflected recorded timestamp on the logs. 191 google.protobuf.Timestamp event_ts = 5; 192 } 193 194 message ReportTaskStageRequest { 195 TaskStage task_stage = 1; 196 google.protobuf.Timestamp timestamp = 2; 197 198 // Recipe is essentially the entry point for the given task, it can be a 199 // `build_rule` or a custom executable (like `luci recipes`) that dictates 200 // workflow of a task. 201 // 202 // (Required) when reporting a task start. 203 string recipe = 3; 204 // Process ID of the task that self-reports task stages. It is used by the 205 // server to periodically check health of running task and assert a close 206 // approximation of task end time. 207 // 208 // Accuracy on task end time estimation can vary between implementations, it 209 // directly depends on frequency at which provenance server checks status of 210 // reported pid. 211 // 212 // (Required) when reported a task start. 213 int64 pid = 4; 214 } 215 216 message ReportArtifactDigestRequest { 217 // SHA256 digest of artifact. 218 string digest = 1; 219 220 // Identifies storage location of a particular artifact. This is used 221 // by Spike to attach provenance: 222 // * GCS: provenance will be uploaded alongside the artifact. 223 // * CIPD: provenance will be added to package metadata. 224 Artifact artifact = 2; 225 226 // If set, identifies that the artifact is an SBOM for other artifacts, 227 // identified by SHA256 digest. 228 repeated string sbom_subjects = 3; 229 } 230 231 message ReportCipdRequest { 232 // cipd_report will consist of package name, instance_id of a cipd package. 233 CipdReport cipd_report = 1; 234 } 235 236 message ReportGitRequest { 237 // git_report will consist of repo name, git hash of checked out repo. 238 GitReport git_report = 1; 239 } 240 241 message ReportGcsRequest { 242 // gcs_report will consist of gcs uri, hash of downloaded artifact. 243 GcsReport gcs_report = 1; 244 } 245 246 message ReportPIDRequest { 247 // Process ID to track execution of a task running. It is used by the 248 // server to periodically check health of running task and assert a close 249 // approximation of task end time. 250 // 251 // Accuracy on task end time estimation can vary between implementations, it 252 // directly depends on frequency at which provenance server checks status of 253 // reported pid. 254 int64 pid = 1; 255 // Reporter of the pid request. In the client of provenance server, this 256 // should be automatically assigned by something similar to Go lang's native 257 // os.Executable(). 258 // 259 // This can be used to define an allowlist of reporters for this action. 260 string reporter = 2; 261 }