You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.7 KiB
109 lines
2.7 KiB
package com.redhat.pctsec.model; |
|
|
|
import com.redhat.pctsec.model.api.request.pssaas; |
|
import com.redhat.pctsec.model.api.request.scanChain; |
|
import io.vertx.mutiny.core.eventbus.EventBus; |
|
import jakarta.enterprise.context.ApplicationScoped; |
|
|
|
import java.util.*; |
|
import java.util.stream.Collectors; |
|
|
|
import jakarta.persistence.*; |
|
|
|
@ApplicationScoped |
|
@Entity |
|
@Table(name="ScanRequests") |
|
public class ScanRequests { |
|
|
|
@Id |
|
@GeneratedValue |
|
private UUID id; |
|
|
|
@OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL) |
|
@JoinColumn(name = "scan_request_id", referencedColumnName = "id") |
|
private Set<ScanRequest> scanRequests;// = new HashSet<>(); |
|
|
|
|
|
@Column(name="scan_properties") |
|
private String scanProperties; |
|
|
|
@Column(name="scan_metadata") |
|
private String scanMetadata; |
|
|
|
|
|
public ScanRequests(){ |
|
//Default to the Snyk scan |
|
this.scanProperties = "-p snyk-only-unstable --tarball-build-script=\":\""; |
|
this.scanRequests = new HashSet<>(); |
|
} |
|
|
|
public ScanRequests(pssaas pssaas){ |
|
this(); |
|
//Iterate scan payload and create scans |
|
} |
|
|
|
public ScanRequests(scanChain scanchain){ |
|
this(); |
|
} |
|
|
|
//public ScanRequests(String repo, String rev){ |
|
// //shortcut for single scans |
|
// scanRequests.add(new ScanRequest(repo, rev)); |
|
//} |
|
|
|
/* |
|
public ScanRequests(String brewBuildId){ |
|
scanRequests.add(new ScanRequest(new B)); |
|
} |
|
*/ |
|
|
|
public void addBrewBuild(String brewBuildId) |
|
{ |
|
scanRequests.add(new ScanRequest(new BrewBuild(brewBuildId))); |
|
} |
|
|
|
public void addGit(String repo, String rev) |
|
{ |
|
scanRequests.add(new ScanRequest(new Git(repo, rev))); |
|
} |
|
|
|
public void addPNCBuild(String pncBuildId) |
|
{ |
|
scanRequests.add(new ScanRequest(new PNCBuild(pncBuildId))); |
|
} |
|
|
|
//Create tekton pipeline/taskrun |
|
public List<ScanTask> execute(EventBus eventBus){ |
|
scanRequests.stream().forEach(s -> s.setBus(eventBus)); |
|
return scanRequests.stream().map(s -> s.executeScan()).collect(Collectors.toList()); |
|
/* |
|
for(ScanRequest s : scanRequests){ |
|
s.executeScan(); |
|
} |
|
*/ |
|
} |
|
|
|
public Set<ScanRequest> getScanRequests() { |
|
return scanRequests; |
|
} |
|
|
|
public void setScanRequests(Set<ScanRequest> scanRequests) { |
|
this.scanRequests = scanRequests; |
|
} |
|
|
|
public String getScanProperties() { |
|
return scanProperties; |
|
} |
|
|
|
public void setScanProperties(String scanProperties) { |
|
this.scanProperties = scanProperties; |
|
} |
|
|
|
public String getScanMetadata() { |
|
return scanMetadata; |
|
} |
|
|
|
public void setScanMetadata(String scanMetadata) { |
|
this.scanMetadata = scanMetadata; |
|
} |
|
}
|
|
|