11 changed files with 138 additions and 42 deletions
@ -0,0 +1,13 @@
|
||||
package com.redhat.pctsec.model; |
||||
|
||||
import java.net.URI; |
||||
|
||||
public class Git { |
||||
private URI repo; |
||||
private String ref; |
||||
|
||||
public Git(String repo, String ref) { |
||||
this.repo = URI.create(repo); |
||||
this.ref = ref; |
||||
} |
||||
} |
||||
@ -1,52 +1,57 @@
|
||||
package com.redhat.pctsec.model; |
||||
|
||||
import com.redhat.pctsec.model.api.request.git; |
||||
import com.redhat.pctsec.tekton.brewTaskRun; |
||||
import com.redhat.pctsec.tekton.scmUrlPipelineRun; |
||||
import io.vertx.mutiny.core.eventbus.EventBus; |
||||
import jakarta.enterprise.context.ApplicationScoped; |
||||
import jakarta.inject.Inject; |
||||
import jakarta.inject.Singleton; |
||||
import jakarta.persistence.Entity; |
||||
|
||||
import java.util.HashMap; |
||||
|
||||
enum RequestType{BREW, PNC, GIT} |
||||
@ApplicationScoped |
||||
abstract public class ScanRequest { |
||||
@Entity |
||||
public class ScanRequest { |
||||
|
||||
@Inject |
||||
EventBus bus; |
||||
|
||||
private HashMap<String, String> metadata; |
||||
private HashMap<String, String> oshScanOptions; |
||||
private String metadata; |
||||
private String oshScanOptions; |
||||
|
||||
<<<<<<< HEAD |
||||
|
||||
//@Inject
|
||||
brewTaskRun btr; |
||||
RequestType type; |
||||
BrewBuild brewBuild; |
||||
PNCBuild pncBuild; |
||||
Git git; |
||||
|
||||
//@Inject
|
||||
scmUrlPipelineRun plr; |
||||
public ScanRequest(BrewBuild brewBuild) |
||||
{ |
||||
this.type = RequestType.BREW; |
||||
this.brewBuild = brewBuild; |
||||
} |
||||
|
||||
public ScanRequest(PNCBuild pncBuild) |
||||
{ |
||||
this.type = RequestType.PNC; |
||||
this.pncBuild = pncBuild; |
||||
} |
||||
|
||||
public ScanRequest(String brewBuildId) |
||||
public ScanRequest(Git git) |
||||
{ |
||||
this.brewBuild = brewBuildId; |
||||
this.type = RequestType.GIT; |
||||
this.git = git; |
||||
} |
||||
|
||||
public ScanRequest(String repo, String ref) |
||||
{ |
||||
this.scmurl = new HashMap<>(); |
||||
this.scmurl.put("repo", repo); |
||||
this.scmurl.put("ref", ref); |
||||
this.git = new Git(repo, ref); |
||||
} |
||||
public void executeScan(){ |
||||
if(this.brewBuild != null && !this.brewBuild.trim().isEmpty()){ |
||||
btr = new brewTaskRun(); |
||||
btr.invokeScanTask(this.brewBuild); |
||||
} |
||||
else if (this.scmurl != null && !this.scmurl.isEmpty()) |
||||
{ |
||||
plr = new scmUrlPipelineRun(); |
||||
plr.invokeOshScmScanPipeline(this.scmurl.get("repo"), this.scmurl.get("ref")); |
||||
} |
||||
//Drop self on event bus for tekton handler
|
||||
} |
||||
|
||||
} |
||||
|
||||
@ -1,7 +1,34 @@
|
||||
package com.redhat.pctsec.model.osh; |
||||
import picocli.CommandLine; |
||||
import picocli.CommandLine.Option; |
||||
import picocli.CommandLine.Parameters; |
||||
|
||||
public class paramMapper { |
||||
|
||||
@Option(names = {"-p", "--profile"}, description = "list of analyzers to use (see command 'list-\n" + |
||||
" analyzers'); use comma as a separator: e.g. \"\n" + |
||||
" --analyzer=gcc,clang,cppcheck\"") |
||||
private String profile; |
||||
|
||||
@Option(names = {"-a", "--analyzer"}, description = "list of analyzers to use (see command 'list-\n" + |
||||
" analyzers'); use comma as a separator: e.g. \"\n" + |
||||
" --analyzer=gcc,clang,cppcheck\"") |
||||
private String analyzers; |
||||
|
||||
@Option(names = {"--tarball-build-script"}, description = "With this option osh-cli accepts path to\n" + |
||||
" tarball specified via first argument and then\n" + |
||||
" the tarball will be scanned. This option sets\n" + |
||||
" command which should build the package,\n" + |
||||
" usually this should be just \"make\", in case\n" + |
||||
" of packages which doesn't need to be built,\n" + |
||||
" just pass \"true\".\n") |
||||
private String tarballBuildScript; |
||||
|
||||
@Option(names = {"--brew-build"}, description = "use a brew build (specified by NVR) instead\n" + |
||||
" of a local file") |
||||
private String brewBuild; |
||||
|
||||
public paramMapper(String params){ |
||||
new CommandLine(this).parseArgs("params"); |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.redhat.pctsec.model.osh; |
||||
|
||||
import io.quarkus.test.junit.QuarkusTest; |
||||
import jakarta.inject.Inject; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import static io.restassured.RestAssured.given; |
||||
import static org.hamcrest.CoreMatchers.is; |
||||
|
||||
@QuarkusTest |
||||
public class paramMapperTest { |
||||
|
||||
@Inject |
||||
paramMapper pm; |
||||
|
||||
@Test |
||||
public void testSnykScan() { |
||||
pm = new paramMapper("-p snyk-only-unstable --tarball-build-script=\":\""); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue