package com.redhat.pctsec.model; import com.redhat.pctsec.model.api.request.pssaas; import com.redhat.pctsec.model.api.request.scanChain; import jakarta.enterprise.context.ApplicationScoped; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import jakarta.persistence.*; @ApplicationScoped @Entity public class ScanRequests { @Id @GeneratedValue private Long id; @OneToMany @JoinColumn(name = "scan_request_id", referencedColumnName = "id") private Set scanRequests; @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=\":\""; } 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 void execute(){ for(ScanRequest s : scanRequests){ s.executeScan(); } } }