Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom processing for RHACS images #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Binaries
cve-analyser

./cve-analyser
6 changes: 2 additions & 4 deletions cmd/cve-analyser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ func main() {
os.Exit(1)
}
file_name := os.Args[1]
if fileExist(file_name) {
fmt.Printf("Processing the \"%v\"...\n", file_name)
} else {
if !fileExist(file_name) {
fmt.Println("file to check is incorrect or not exist")
os.Exit(1)
}
Expand All @@ -230,7 +228,7 @@ func main() {
var CPEtoRepos helper.RepoToCPEmap = helper.CallRepoToCPE()

// initiate 10 threads
for w := 0; w < 10; w++ {
for w := 0; w < 1; w++ {
wg.Add(1)
go processLines(&wg, jobs, results, CPEtoRepos)
}
Expand Down
28 changes: 26 additions & 2 deletions pkg/pyxis_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,31 @@ func unique(s []string) []string {
return result
}

func repomap(repository string, name string) string {
var result string
switch {
case repository == "rh-acs":
result += "advanced-cluster-security/"
switch{
case name == "main":
result += "rhacs-main-rhel8"
case name == "collector":
result += "rhacs-collector-rhel8"
case name == "scanner":
result += "rhacs-scanner-rhel8"
case name == "scanner-db":
result += "rhacs-scanner-db-rhel8"
}
default:
result += repository + "/" + name
}
return result
}

func CallPyxis_CPE(repository string, name string, tag string, CPEtoRepos RepoToCPEmap) []string {
var AllCPEs []string
url := PyxisUrl + "/repositories/registry/registry.access.redhat.com/repository/" + repository + "/" + name + "/tag/" + tag

url := PyxisUrl + "/repositories/registry/registry.access.redhat.com/repository/" + repomap(repository, name) + "/tag/" + tag

resp, err := http.Get(url)
if err != nil {
Expand Down Expand Up @@ -146,8 +168,10 @@ func CallRepoToCPE() RepoToCPEmap {
}

func CallPyxis_ImageID(repository string, name string, tag string) string {
url := PyxisUrl + "/repositories/registry/registry.access.redhat.com/repository/" + repository + "/" + name + "/tag/" + tag

url := PyxisUrl + "/repositories/registry/registry.access.redhat.com/repository/" + repomap(repository, name) + "/tag/" + tag
//fmt.Println(url)

// Get request
resp, err := http.Get(url)
if err != nil {
Expand Down