Skip to content

Commit

Permalink
1.5_add_support_for_evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-zepol committed Aug 24, 2023
1 parent e9bae23 commit 5f12e16
Show file tree
Hide file tree
Showing 9 changed files with 518 additions and 8 deletions.
49 changes: 46 additions & 3 deletions src/main/java/org/cyclonedx/model/Evidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,37 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.model.component.evidence.Callstack;
import org.cyclonedx.model.component.evidence.Identity;
import org.cyclonedx.model.component.evidence.Occurrence;
import org.cyclonedx.util.deserializer.LicenseDeserializer;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("unused")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({"licenses", "copyright"})
public class Evidence extends ExtensibleElement {

@JsonPropertyOrder({"identity", "occurrences", "callstack", "licenses", "copyright"})
public class Evidence
extends ExtensibleElement
{
private LicenseChoice license;

private List<Copyright> copyright;

@VersionFilter(versions = {"1.0", "1.1", "1.2", "1.3", "1.4"})
private Identity identity;

@VersionFilter(versions = {"1.0", "1.1", "1.2", "1.3", "1.4"})
private List<Occurrence> occurrences;

@VersionFilter(versions = {"1.0", "1.1", "1.2", "1.3", "1.4"})
private Callstack callstack;

@JacksonXmlProperty(localName = "licenses")
@JsonProperty("licenses")
@JsonDeserialize(using = LicenseDeserializer.class)
public LicenseChoice getLicenseChoice() {
return license;
}
Expand All @@ -63,4 +79,31 @@ public void addCopyright(Copyright copyright) {
}
this.copyright.add(copyright);
}

public Identity getIdentity() {
return identity;
}

public void setIdentity(final Identity identity) {
this.identity = identity;
}

@JsonProperty("occurrences")
@JacksonXmlElementWrapper(localName = "occurrences")
@JacksonXmlProperty(localName = "occurrence")
public List<Occurrence> getOccurrences() {
return occurrences;
}

public void setOccurrences(final List<Occurrence> occurrences) {
this.occurrences = occurrences;
}

public Callstack getCallstack() {
return callstack;
}

public void setCallstack(final Callstack callstack) {
this.callstack = callstack;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.cyclonedx.model.component.evidence;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Callstack
{
private List<Frame> frames;

@JacksonXmlElementWrapper(localName = "frames")
@JacksonXmlProperty(localName = "frame")
@JsonProperty("frames")
public List<Frame> getFrames() {
return frames;
}

public void setFrames(final List<Frame> frames) {
this.frames = frames;
}
}
88 changes: 88 additions & 0 deletions src/main/java/org/cyclonedx/model/component/evidence/Frame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package org.cyclonedx.model.component.evidence;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.model.ExtensibleElement;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Frame extends ExtensibleElement
{
private String packageFrame;

private String module;

private String function;

private List<String> parameters;

private Integer line;

private Integer column;

private String fullFilename;

public String getPackageFrame() {
return packageFrame;
}

public void setPackageFrame(final String packageFrame) {
this.packageFrame = packageFrame;
}

public String getModule() {
return module;
}

public void setModule(final String module) {
this.module = module;
}

public String getFunction() {
return function;
}

public void setFunction(final String function) {
this.function = function;
}

@JsonProperty("parameters")
@JacksonXmlElementWrapper(localName = "parameters")
@JacksonXmlProperty(localName = "parameter")
public List<String> getParameters() {
return parameters;
}

public void setParameters(final List<String> parameters) {
this.parameters = parameters;
}

public Integer getLine() {
return line;
}

public void setLine(final Integer line) {
this.line = line;
}

public Integer getColumn() {
return column;
}

public void setColumn(final Integer column) {
this.column = column;
}

public String getFullFilename() {
return fullFilename;
}

public void setFullFilename(final String fullFilename) {
this.fullFilename = fullFilename;
}
}
130 changes: 130 additions & 0 deletions src/main/java/org/cyclonedx/model/component/evidence/Identity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package org.cyclonedx.model.component.evidence;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.model.ExtensibleElement;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({"field", "confidence", "methods", "tools"})
public class Identity extends ExtensibleElement
{
public Field field;

public Double confidence;

@JacksonXmlElementWrapper(localName = "methods")
@JacksonXmlProperty(localName = "method")
@JsonProperty("methods")
public List<Method> methods;

@JacksonXmlElementWrapper(localName = "tools")
@JacksonXmlProperty(localName = "tool")
@JsonProperty("tools")
public List<Tool> tools;

public enum Field {
@JsonProperty("group")
GROUP("group"),
@JsonProperty("name")
NAME("name"),
@JsonProperty("version")
VERSION("version"),
@JsonProperty("purl")
PURL("purl"),
@JsonProperty("cpe")
CPE( "cpe"),
@JsonProperty("swid")
SWID("swid"),
@JsonProperty("hash")
HASH( "hash");

private final String name;

public String getTypeName() {
return this.name;
}

Field(String name) {
this.name = name;
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Tool {
@JacksonXmlProperty(isAttribute = true, localName = "ref")
@JsonProperty("ref")
private String ref;

private String bomLink;

public Tool() {
}

public Tool(String ref) {
this.ref = ref;
}

public String getRef() {
return ref;
}

public void setRef(final String ref) {
this.ref = ref;
}

@JsonProperty("bomLinkElement")
public String getBomLink() {
return bomLink;
}

public void setBomLink(final String bomLink) {
this.bomLink = bomLink;
}
}

public Field getField() {
return field;
}

public void setField(final Field field) {
this.field = field;
}

public Double getConfidence() {
return confidence;
}

public void setConfidence(final Double confidence) {
this.confidence = confidence;
}

@JsonProperty("methods")
@JacksonXmlElementWrapper(localName = "methods")
@JacksonXmlProperty(localName = "method")
public List<Method> getMethods() {
return methods;
}

public void setMethods(final List<Method> methods) {
this.methods = methods;
}

@JsonProperty("tools")
@JacksonXmlElementWrapper(localName = "tools")
@JacksonXmlProperty(localName = "tool")
public List<Tool> getTools() {
return tools;
}

public void setTools(final List<Tool> tools) {
this.tools = tools;
}
}
Loading

0 comments on commit 5f12e16

Please sign in to comment.