org.owasp.dependencycheck.dependency.Reference Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-check-core Show documentation
Show all versions of dependency-check-core Show documentation
dependency-check-core is the engine and reporting tool used to identify and report if there are any known, publicly disclosed vulnerabilities in the scanned project's dependencies. The engine extracts meta-data from the dependencies and uses this to do fuzzy key-word matching against the Common Platfrom Enumeration (CPE), if any CPE identifiers are found the associated Common Vulnerability and Exposure (CVE) entries are added to the generated report.
/*
* This file is part of dependency-check-core.
*
* 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.
*
* Copyright (c) 2012 Jeremy Long. All Rights Reserved.
*/
package org.owasp.dependencycheck.dependency;
import java.io.Serializable;
import javax.annotation.concurrent.ThreadSafe;
import org.apache.commons.lang3.builder.CompareToBuilder;
import org.jetbrains.annotations.NotNull;
/**
* An external reference for a vulnerability. This contains a name, URL, and a
* source.
*
* @author Jeremy Long
*/
@ThreadSafe
public class Reference implements Serializable, Comparable {
/**
* the serial version uid.
*/
private static final long serialVersionUID = -3444464824563008021L;
/**
* The name of the reference.
*/
private String name;
/**
* the url for the reference.
*/
private String url;
/**
* the source of the reference.
*/
private String source;
/**
* Get the value of name.
*
* @return the value of name
*/
public String getName() {
return name;
}
/**
* Set the value of name.
*
* @param name new value of name
*/
public void setName(String name) {
this.name = name;
}
/**
* Get the value of url.
*
* @return the value of url
*/
public String getUrl() {
return url;
}
/**
* Set the value of url.
*
* @param url new value of url
*/
public void setUrl(String url) {
this.url = url;
}
/**
* Get the value of source.
*
* @return the value of source
*/
public String getSource() {
return source;
}
/**
* Set the value of source.
*
* @param source new value of source
*/
public void setSource(String source) {
this.source = source;
}
@Override
public String toString() {
return "Reference: { name='" + this.name + "', url='" + this.url + "', source='" + this.source + "' }";
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof Reference)) {
return false;
}
final Reference other = (Reference) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.url == null) ? (other.url != null) : !this.url.equals(other.url)) {
return false;
}
return !((this.source == null) ? (other.source != null) : !this.source.equals(other.source));
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 67 * hash + (this.url != null ? this.url.hashCode() : 0);
hash = 67 * hash + (this.source != null ? this.source.hashCode() : 0);
return hash;
}
/**
* Implementation of the comparable interface.
*
* @param o the Reference being compared
* @return an integer indicating the ordering of the two objects
*/
@Override
public int compareTo(@NotNull Reference o) {
return new CompareToBuilder()
.append(source, o.source)
.append(name, o.name)
.append(url, o.url)
.toComparison();
}
}