001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * https://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.release.plugin.slsa.v1_2; 018 019import java.util.List; 020import java.util.Objects; 021 022import com.fasterxml.jackson.annotation.JsonInclude; 023import com.fasterxml.jackson.annotation.JsonProperty; 024 025/** 026 * Details about the build invocation: the builder identity, execution metadata, and any byproduct artifacts. 027 * 028 * @see <a href="https://slsa.dev/spec/v1.2">SLSA v1.2 Specification</a> 029 * @since 1.10.0 030 */ 031@JsonInclude(JsonInclude.Include.NON_NULL) 032public class RunDetails { 033 034 /** 035 * Entity that executed the build. 036 */ 037 @JsonProperty("builder") 038 private Builder builder; 039 /** 040 * Artifacts produced as a side effect of the build. 041 */ 042 @JsonProperty("byproducts") 043 private List<ResourceDescriptor> byproducts; 044 /** 045 * Metadata about the build invocation. 046 */ 047 @JsonProperty("metadata") 048 private BuildMetadata metadata; 049 050 /** 051 * Creates a new RunDetails instance. 052 */ 053 public RunDetails() { 054 } 055 056 /** 057 * Creates a new RunDetails with the given builder and metadata. 058 * 059 * @param builder entity that executed the build. 060 * @param metadata metadata about the build invocation. 061 */ 062 public RunDetails(final Builder builder, final BuildMetadata metadata) { 063 this.builder = builder; 064 this.metadata = metadata; 065 } 066 067 @Override 068 public boolean equals(final Object o) { 069 if (this == o) { 070 return true; 071 } 072 if (o == null || getClass() != o.getClass()) { 073 return false; 074 } 075 final RunDetails that = (RunDetails) o; 076 return Objects.equals(builder, that.builder) && Objects.equals(metadata, that.metadata) && Objects.equals(byproducts, that.byproducts); 077 } 078 079 /** 080 * Gets the builder that executed the invocation. 081 * 082 * <p> 083 * The builder is trusted to have correctly performed the operation and populated this provenance. 084 * </p> 085 * 086 * @return The builder, or {@code null} if not set. 087 */ 088 public Builder getBuilder() { 089 return builder; 090 } 091 092 /** 093 * Gets artifacts produced as a side effect of the build that are not the primary output. 094 * 095 * @return The list of byproduct artifacts, or {@code null} if not set. 096 */ 097 public List<ResourceDescriptor> getByproducts() { 098 return byproducts; 099 } 100 101 /** 102 * Gets the metadata about the build invocation, including its identifier and timing. 103 * 104 * @return The build metadata, or {@code null} if not set. 105 */ 106 public BuildMetadata getMetadata() { 107 return metadata; 108 } 109 110 @Override 111 public int hashCode() { 112 return Objects.hash(builder, metadata, byproducts); 113 } 114 115 /** 116 * Sets the builder that executed the invocation. 117 * 118 * @param builder The builder. 119 * @return this for chaining. 120 */ 121 public RunDetails setBuilder(final Builder builder) { 122 this.builder = builder; 123 return this; 124 } 125 126 /** 127 * Sets the artifacts produced as a side effect of the build that are not the primary output. 128 * 129 * @param byproducts The list of byproduct artifacts. 130 * @return this for chaining. 131 */ 132 public RunDetails setByproducts(final List<ResourceDescriptor> byproducts) { 133 this.byproducts = byproducts; 134 return this; 135 } 136 137 /** 138 * Sets the metadata about the build invocation. 139 * 140 * @param metadata The build metadata. 141 * @return this for chaining. 142 */ 143 public RunDetails setMetadata(final BuildMetadata metadata) { 144 this.metadata = metadata; 145 return this; 146 } 147 148 @Override 149 public String toString() { 150 return "RunDetails{builder=" + builder + ", metadata=" + metadata + ", byproducts=" + byproducts + '}'; 151 } 152}