|
|
|
|
@ -5,6 +5,7 @@ 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; |
|
|
|
|
@ -30,6 +31,10 @@ public class ScanResource {
|
|
|
|
|
@Inject |
|
|
|
|
EventBus bus; |
|
|
|
|
|
|
|
|
|
@Inject |
|
|
|
|
SecurityIdentity identity; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@POST |
|
|
|
|
@Path("PSSaaS") |
|
|
|
|
@Consumes({ "application/json" }) |
|
|
|
|
@ -39,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; |
|
|
|
|
} |
|
|
|
|
@ -65,9 +73,14 @@ 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); |
|
|
|
|
sr.persist(s); |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
@ -129,7 +142,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; |
|
|
|
|
@ -143,7 +157,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; |
|
|
|
|
@ -156,7 +171,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; |
|
|
|
|
|