|
|
|
|
@ -5,11 +5,13 @@ import com.redhat.pctsec.model.api.request.pssaas;
|
|
|
|
|
import com.redhat.pctsec.model.api.request.scanChain; |
|
|
|
|
import com.redhat.pctsec.model.jpa.ScanRepository; |
|
|
|
|
import io.quarkus.security.Authenticated; |
|
|
|
|
import io.quarkus.security.identity.SecurityIdentity; |
|
|
|
|
import io.vertx.mutiny.core.eventbus.EventBus; |
|
|
|
|
import jakarta.enterprise.context.ApplicationScoped; |
|
|
|
|
import jakarta.inject.Inject; |
|
|
|
|
import jakarta.transaction.Transactional; |
|
|
|
|
import jakarta.validation.Valid; |
|
|
|
|
import jakarta.validation.constraints.Email; |
|
|
|
|
import jakarta.ws.rs.*; |
|
|
|
|
import org.jboss.resteasy.reactive.RestQuery; |
|
|
|
|
|
|
|
|
|
@ -29,6 +31,10 @@ public class ScanResource {
|
|
|
|
|
@Inject |
|
|
|
|
EventBus bus; |
|
|
|
|
|
|
|
|
|
@Inject |
|
|
|
|
SecurityIdentity identity; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@POST |
|
|
|
|
@Path("PSSaaS") |
|
|
|
|
@Consumes({ "application/json" }) |
|
|
|
|
@ -38,9 +44,12 @@ public class ScanResource {
|
|
|
|
|
{ |
|
|
|
|
ScanRequests scanRequests = new ScanRequests(scanRequest); |
|
|
|
|
Scan s = new Scan(); |
|
|
|
|
s.setRequestor("cpaas"); |
|
|
|
|
s.setProductName(scanRequest.productId); |
|
|
|
|
s.setScanRequests(scanRequests); |
|
|
|
|
if(!identity.getPrincipal().getName().isEmpty()) |
|
|
|
|
s.setRequestor(identity.getPrincipal().getName()); |
|
|
|
|
else |
|
|
|
|
s.setRequestor("CPaaS"); |
|
|
|
|
sr.persist(s); |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
@ -52,6 +61,7 @@ public class ScanResource {
|
|
|
|
|
public List<ScanTask> createRunPSSAAS(@Valid pssaas scanRequest) |
|
|
|
|
{ |
|
|
|
|
Scan s = this.createPSSAAS(scanRequest); |
|
|
|
|
s.propagateOptions(); |
|
|
|
|
return s.scanRequests.execute(bus); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -64,6 +74,12 @@ public class ScanResource {
|
|
|
|
|
{ |
|
|
|
|
ScanRequests scanRequests = new ScanRequests(scanRequest); |
|
|
|
|
Scan s = new Scan(); |
|
|
|
|
//Set the requestor to kerberos uid first
|
|
|
|
|
if(!identity.getPrincipal().getName().isEmpty()) |
|
|
|
|
s.setRequestor(identity.getPrincipal().getName()); |
|
|
|
|
//Set the email to be our kerberos id + @redhat.com
|
|
|
|
|
s.setEmail(s.getEmail()); |
|
|
|
|
//Now set the actual payload requestor
|
|
|
|
|
s.setRequestor(scanRequest.requestor); |
|
|
|
|
s.setProductName(scanRequest.productName); |
|
|
|
|
s.setScanRequests(scanRequests); |
|
|
|
|
@ -78,6 +94,7 @@ public class ScanResource {
|
|
|
|
|
public List<ScanTask> createRunScanChain(@Valid scanChain scanRequest) |
|
|
|
|
{ |
|
|
|
|
Scan s = this.createScanChain(scanRequest); |
|
|
|
|
s.propagateOptions(); |
|
|
|
|
return s.scanRequests.execute(bus); |
|
|
|
|
} |
|
|
|
|
@GET |
|
|
|
|
@ -103,9 +120,23 @@ public class ScanResource {
|
|
|
|
|
public List<ScanTask> scanRequestExe(String id) |
|
|
|
|
{ |
|
|
|
|
Scan s = sr.findById(UUID.fromString(id)); |
|
|
|
|
s.propagateOptions(); |
|
|
|
|
return s.scanRequests.execute(bus); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PATCH |
|
|
|
|
@Path("{id}/{email}") |
|
|
|
|
@Consumes({"application/octet-stream"}) |
|
|
|
|
@Produces({"application/json"}) |
|
|
|
|
@Authenticated |
|
|
|
|
@Transactional |
|
|
|
|
public Scan patchScanEmail(String id, @Email String email) |
|
|
|
|
{ |
|
|
|
|
Scan s = sr.findById(UUID.fromString(id)); |
|
|
|
|
s.setEmail(email); |
|
|
|
|
sr.persist(s); |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GET |
|
|
|
|
@Path("single/git") |
|
|
|
|
@ -115,7 +146,8 @@ public class ScanResource {
|
|
|
|
|
public Scan singleGit(@RestQuery String repo, @RestQuery String ref) |
|
|
|
|
{ |
|
|
|
|
Scan s = new Scan(); |
|
|
|
|
s.setRequestor("jochrist"); |
|
|
|
|
if(!identity.getPrincipal().getName().isEmpty()) |
|
|
|
|
s.setRequestor(identity.getPrincipal().getName()); |
|
|
|
|
s.getScanRequests().addGit(repo,ref); |
|
|
|
|
sr.persist(s); |
|
|
|
|
return s; |
|
|
|
|
@ -129,7 +161,8 @@ public class ScanResource {
|
|
|
|
|
public Scan singleGit(@RestQuery String brewId) |
|
|
|
|
{ |
|
|
|
|
Scan s = new Scan(); |
|
|
|
|
s.setRequestor("jochrist"); |
|
|
|
|
if(!identity.getPrincipal().getName().isEmpty()) |
|
|
|
|
s.setRequestor(identity.getPrincipal().getName()); |
|
|
|
|
s.getScanRequests().addBrewBuild(brewId); |
|
|
|
|
sr.persist(s); |
|
|
|
|
return s; |
|
|
|
|
@ -142,7 +175,8 @@ public class ScanResource {
|
|
|
|
|
public Scan singlePNC(@RestQuery String pncId) |
|
|
|
|
{ |
|
|
|
|
Scan s = new Scan(); |
|
|
|
|
s.setRequestor("jochrist"); |
|
|
|
|
if(!identity.getPrincipal().getName().isEmpty()) |
|
|
|
|
s.setRequestor(identity.getPrincipal().getName()); |
|
|
|
|
s.getScanRequests().addPNCBuild(pncId); |
|
|
|
|
sr.persist(s); |
|
|
|
|
return s; |
|
|
|
|
|