software.amazon.awssdk.services.codegurusecurity.model.Finding Maven / Gradle / Ivy
Show all versions of codegurusecurity Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/
package software.amazon.awssdk.services.codegurusecurity.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about a finding that was detected in your code.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Finding implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("createdAt").getter(getter(Finding::createdAt)).setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(Finding::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField DETECTOR_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("detectorId").getter(getter(Finding::detectorId)).setter(setter(Builder::detectorId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("detectorId").build()).build();
private static final SdkField DETECTOR_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("detectorName").getter(getter(Finding::detectorName)).setter(setter(Builder::detectorName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("detectorName").build()).build();
private static final SdkField> DETECTOR_TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("detectorTags")
.getter(getter(Finding::detectorTags))
.setter(setter(Builder::detectorTags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("detectorTags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField GENERATOR_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("generatorId").getter(getter(Finding::generatorId)).setter(setter(Builder::generatorId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("generatorId").build()).build();
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(Finding::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField REMEDIATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("remediation").getter(getter(Finding::remediation)).setter(setter(Builder::remediation))
.constructor(Remediation::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("remediation").build()).build();
private static final SdkField RESOURCE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("resource").getter(getter(Finding::resource)).setter(setter(Builder::resource))
.constructor(Resource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resource").build()).build();
private static final SdkField RULE_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("ruleId")
.getter(getter(Finding::ruleId)).setter(setter(Builder::ruleId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ruleId").build()).build();
private static final SdkField SEVERITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("severity").getter(getter(Finding::severityAsString)).setter(setter(Builder::severity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("severity").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(Finding::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("title")
.getter(getter(Finding::title)).setter(setter(Builder::title))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("title").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("type")
.getter(getter(Finding::type)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("type").build()).build();
private static final SdkField UPDATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("updatedAt").getter(getter(Finding::updatedAt)).setter(setter(Builder::updatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("updatedAt").build()).build();
private static final SdkField VULNERABILITY_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("vulnerability").getter(getter(Finding::vulnerability)).setter(setter(Builder::vulnerability))
.constructor(Vulnerability::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("vulnerability").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CREATED_AT_FIELD,
DESCRIPTION_FIELD, DETECTOR_ID_FIELD, DETECTOR_NAME_FIELD, DETECTOR_TAGS_FIELD, GENERATOR_ID_FIELD, ID_FIELD,
REMEDIATION_FIELD, RESOURCE_FIELD, RULE_ID_FIELD, SEVERITY_FIELD, STATUS_FIELD, TITLE_FIELD, TYPE_FIELD,
UPDATED_AT_FIELD, VULNERABILITY_FIELD));
private static final long serialVersionUID = 1L;
private final Instant createdAt;
private final String description;
private final String detectorId;
private final String detectorName;
private final List detectorTags;
private final String generatorId;
private final String id;
private final Remediation remediation;
private final Resource resource;
private final String ruleId;
private final String severity;
private final String status;
private final String title;
private final String type;
private final Instant updatedAt;
private final Vulnerability vulnerability;
private Finding(BuilderImpl builder) {
this.createdAt = builder.createdAt;
this.description = builder.description;
this.detectorId = builder.detectorId;
this.detectorName = builder.detectorName;
this.detectorTags = builder.detectorTags;
this.generatorId = builder.generatorId;
this.id = builder.id;
this.remediation = builder.remediation;
this.resource = builder.resource;
this.ruleId = builder.ruleId;
this.severity = builder.severity;
this.status = builder.status;
this.title = builder.title;
this.type = builder.type;
this.updatedAt = builder.updatedAt;
this.vulnerability = builder.vulnerability;
}
/**
*
* The time when the finding was created.
*
*
* @return The time when the finding was created.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* A description of the finding.
*
*
* @return A description of the finding.
*/
public final String description() {
return description;
}
/**
*
* The identifier for the detector that detected the finding in your code. A detector is a defined rule based on
* industry standards and AWS best practices.
*
*
* @return The identifier for the detector that detected the finding in your code. A detector is a defined rule
* based on industry standards and AWS best practices.
*/
public final String detectorId() {
return detectorId;
}
/**
*
* The name of the detector that identified the security vulnerability in your code.
*
*
* @return The name of the detector that identified the security vulnerability in your code.
*/
public final String detectorName() {
return detectorName;
}
/**
* For responses, this returns true if the service returned a value for the DetectorTags property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasDetectorTags() {
return detectorTags != null && !(detectorTags instanceof SdkAutoConstructList);
}
/**
*
* One or more tags or categorizations that are associated with a detector. These tags are defined by type,
* programming language, or other classification such as maintainability or consistency.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasDetectorTags} method.
*
*
* @return One or more tags or categorizations that are associated with a detector. These tags are defined by type,
* programming language, or other classification such as maintainability or consistency.
*/
public final List detectorTags() {
return detectorTags;
}
/**
*
* The identifier for the component that generated a finding such as AmazonCodeGuruSecurity.
*
*
* @return The identifier for the component that generated a finding such as AmazonCodeGuruSecurity.
*/
public final String generatorId() {
return generatorId;
}
/**
*
* The identifier for a finding.
*
*
* @return The identifier for a finding.
*/
public final String id() {
return id;
}
/**
*
* An object that contains the details about how to remediate a finding.
*
*
* @return An object that contains the details about how to remediate a finding.
*/
public final Remediation remediation() {
return remediation;
}
/**
*
* The resource where Amazon CodeGuru Security detected a finding.
*
*
* @return The resource where Amazon CodeGuru Security detected a finding.
*/
public final Resource resource() {
return resource;
}
/**
*
* The identifier for the rule that generated the finding.
*
*
* @return The identifier for the rule that generated the finding.
*/
public final String ruleId() {
return ruleId;
}
/**
*
* The severity of the finding. Severity can be critical, high, medium, low, or informational. For information on
* severity levels, see Finding severity in the Amazon CodeGuru Security User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link Severity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The severity of the finding. Severity can be critical, high, medium, low, or informational. For
* information on severity levels, see Finding severity in the Amazon CodeGuru Security User Guide.
* @see Severity
*/
public final Severity severity() {
return Severity.fromValue(severity);
}
/**
*
* The severity of the finding. Severity can be critical, high, medium, low, or informational. For information on
* severity levels, see Finding severity in the Amazon CodeGuru Security User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link Severity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The severity of the finding. Severity can be critical, high, medium, low, or informational. For
* information on severity levels, see Finding severity in the Amazon CodeGuru Security User Guide.
* @see Severity
*/
public final String severityAsString() {
return severity;
}
/**
*
* The status of the finding. A finding status can be open or closed.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link Status#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the finding. A finding status can be open or closed.
* @see Status
*/
public final Status status() {
return Status.fromValue(status);
}
/**
*
* The status of the finding. A finding status can be open or closed.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link Status#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the finding. A finding status can be open or closed.
* @see Status
*/
public final String statusAsString() {
return status;
}
/**
*
* The title of the finding.
*
*
* @return The title of the finding.
*/
public final String title() {
return title;
}
/**
*
* The type of finding.
*
*
* @return The type of finding.
*/
public final String type() {
return type;
}
/**
*
* The time when the finding was last updated. Findings are updated when you remediate them or when the finding code
* location changes.
*
*
* @return The time when the finding was last updated. Findings are updated when you remediate them or when the
* finding code location changes.
*/
public final Instant updatedAt() {
return updatedAt;
}
/**
*
* An object that describes the detected security vulnerability.
*
*
* @return An object that describes the detected security vulnerability.
*/
public final Vulnerability vulnerability() {
return vulnerability;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(detectorId());
hashCode = 31 * hashCode + Objects.hashCode(detectorName());
hashCode = 31 * hashCode + Objects.hashCode(hasDetectorTags() ? detectorTags() : null);
hashCode = 31 * hashCode + Objects.hashCode(generatorId());
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(remediation());
hashCode = 31 * hashCode + Objects.hashCode(resource());
hashCode = 31 * hashCode + Objects.hashCode(ruleId());
hashCode = 31 * hashCode + Objects.hashCode(severityAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(type());
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
hashCode = 31 * hashCode + Objects.hashCode(vulnerability());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Finding)) {
return false;
}
Finding other = (Finding) obj;
return Objects.equals(createdAt(), other.createdAt()) && Objects.equals(description(), other.description())
&& Objects.equals(detectorId(), other.detectorId()) && Objects.equals(detectorName(), other.detectorName())
&& hasDetectorTags() == other.hasDetectorTags() && Objects.equals(detectorTags(), other.detectorTags())
&& Objects.equals(generatorId(), other.generatorId()) && Objects.equals(id(), other.id())
&& Objects.equals(remediation(), other.remediation()) && Objects.equals(resource(), other.resource())
&& Objects.equals(ruleId(), other.ruleId()) && Objects.equals(severityAsString(), other.severityAsString())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(title(), other.title())
&& Objects.equals(type(), other.type()) && Objects.equals(updatedAt(), other.updatedAt())
&& Objects.equals(vulnerability(), other.vulnerability());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("Finding").add("CreatedAt", createdAt()).add("Description", description())
.add("DetectorId", detectorId()).add("DetectorName", detectorName())
.add("DetectorTags", hasDetectorTags() ? detectorTags() : null).add("GeneratorId", generatorId()).add("Id", id())
.add("Remediation", remediation()).add("Resource", resource()).add("RuleId", ruleId())
.add("Severity", severityAsString()).add("Status", statusAsString()).add("Title", title()).add("Type", type())
.add("UpdatedAt", updatedAt()).add("Vulnerability", vulnerability()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "createdAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "detectorId":
return Optional.ofNullable(clazz.cast(detectorId()));
case "detectorName":
return Optional.ofNullable(clazz.cast(detectorName()));
case "detectorTags":
return Optional.ofNullable(clazz.cast(detectorTags()));
case "generatorId":
return Optional.ofNullable(clazz.cast(generatorId()));
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "remediation":
return Optional.ofNullable(clazz.cast(remediation()));
case "resource":
return Optional.ofNullable(clazz.cast(resource()));
case "ruleId":
return Optional.ofNullable(clazz.cast(ruleId()));
case "severity":
return Optional.ofNullable(clazz.cast(severityAsString()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "title":
return Optional.ofNullable(clazz.cast(title()));
case "type":
return Optional.ofNullable(clazz.cast(type()));
case "updatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
case "vulnerability":
return Optional.ofNullable(clazz.cast(vulnerability()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function