Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2021-2024 the original author or 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.
*/
package com.metaeffekt.mirror.contents.advisory;
import com.metaeffekt.artifact.analysis.utils.TimeUtils;
import com.metaeffekt.artifact.analysis.version.curation.VersionContext;
import com.metaeffekt.mirror.contents.base.DescriptionParagraph;
import com.metaeffekt.mirror.contents.base.Reference;
import com.metaeffekt.mirror.contents.store.AdvisoryTypeStore;
import com.metaeffekt.mirror.contents.store.OtherTypeStore;
import com.metaeffekt.mirror.contents.store.VulnerabilityTypeStore;
import com.metaeffekt.mirror.contents.vulnerability.VulnerableSoftwareVersionRange;
import com.metaeffekt.mirror.contents.vulnerability.VulnerableSoftwareVersionRangeEcosystem;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.json.JSONArray;
import org.json.JSONObject;
import org.metaeffekt.core.inventory.processor.model.AdvisoryMetaData;
import org.metaeffekt.core.inventory.processor.report.model.AdvisoryUtils;
import org.metaeffekt.core.security.cvss.CvssSource;
import org.metaeffekt.core.security.cvss.KnownCvssEntities;
import org.metaeffekt.core.security.cvss.v2.Cvss2;
import org.metaeffekt.core.security.cvss.v3.Cvss3P1;
import org.metaeffekt.core.security.cvss.v4P0.Cvss4P0;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public class GhsaAdvisorEntry extends AdvisoryEntry {
private final static Logger LOG = LoggerFactory.getLogger(GhsaAdvisorEntry.class);
protected final static Set CONVERSION_KEYS_AMB = new HashSet(AdvisoryEntry.CONVERSION_KEYS_AMB) {{
}};
protected final static Set CONVERSION_KEYS_MAP = new HashSet(AdvisoryEntry.CONVERSION_KEYS_MAP) {{
add("severity");
add("githubReviewed");
add("githubReviewedAt");
add("nvdPublishedAt");
add("vulnerableSoftware");
}};
private String severity;
private boolean githubReviewed;
private Date githubReviewedAt;
private Date nvdPublishedAt;
private final List vulnerableSoftwares = new ArrayList<>();
public GhsaAdvisorEntry() {
super(AdvisoryTypeStore.GHSA);
}
public GhsaAdvisorEntry(String id) {
super(AdvisoryTypeStore.GHSA, id);
}
public String getSeverity() {
return severity;
}
public void setSeverity(String severity) {
this.severity = severity;
}
public boolean isGithubReviewed() {
return githubReviewed;
}
public List getVulnerableSoftwares() {
return vulnerableSoftwares;
}
public void setGithubReviewed(boolean githubReviewed) {
this.githubReviewed = githubReviewed;
}
public Date getGithubReviewedAt() {
return githubReviewedAt;
}
public void setGithubReviewedAt(Date githubReviewedAt) {
this.githubReviewedAt = githubReviewedAt;
}
public Date getNvdPublishedAt() {
return nvdPublishedAt;
}
public void setNvdPublishedAt(Date nvdPublishedAt) {
this.nvdPublishedAt = nvdPublishedAt;
}
@Override
public String getUrl() {
return "https://github.com/advisories/" + getId();
}
@Override
public String getType() {
return AdvisoryUtils.normalizeType("alert");
}
/* TYPE CONVERSION METHODS */
@Override
protected Set conversionKeysAmb() {
return CONVERSION_KEYS_AMB;
}
@Override
protected Set conversionKeysMap() {
return CONVERSION_KEYS_MAP;
}
@Override
public GhsaAdvisorEntry constructDataClass() {
return new GhsaAdvisorEntry();
}
public static GhsaAdvisorEntry fromAdvisoryMetaData(AdvisoryMetaData amd) {
return AdvisoryEntry.fromAdvisoryMetaData(amd, GhsaAdvisorEntry::new);
}
public static GhsaAdvisorEntry fromInputMap(Map map) {
return AdvisoryEntry.fromInputMap(map, GhsaAdvisorEntry::new);
}
public static GhsaAdvisorEntry fromJson(JSONObject json) {
return AdvisoryEntry.fromJson(json, GhsaAdvisorEntry::new);
}
public static GhsaAdvisorEntry fromDocument(Document document) {
return AdvisoryEntry.fromDocument(document, GhsaAdvisorEntry::new);
}
@Override
public void appendFromBaseModel(AdvisoryMetaData amd) {
super.appendFromBaseModel(amd);
}
@Override
public void appendToBaseModel(AdvisoryMetaData amd) {
super.appendToBaseModel(amd);
}
@Override
public void appendFromMap(Map map) {
super.appendFromMap(map);
this.setSeverity((String) map.getOrDefault("severity", null));
this.setGithubReviewed((boolean) map.getOrDefault("githubReviewed", false));
this.setGithubReviewedAt(TimeUtils.tryParse(map.getOrDefault("githubReviewedAt", null)));
this.setNvdPublishedAt(TimeUtils.tryParse(map.getOrDefault("nvdPublishedAt", null)));
final List