Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy authored and jdobes committed Aug 27, 2024
1 parent 63b4695 commit 9be208f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
[VMaaS](https://github.com/RedHatInsights/vmaas) library for Updates and Vulnerabilities evaluation

# Prerequisites
sqlite data dump generated by [vmaas-reposcan](https://github.com/RedHatInsights/vmaas/tree/master/vmaas/reposcan) `/api/vmaas/v1/export/dump`

available in [examples/vmaas.db](https://github.com/RedHatInsights/vmaas-lib/blob/main/example/vmaas.db) for testing purposes
- [rpm](https://rpm.org/) library
- sqlite data dump generated by [vmaas-reposcan](https://github.com/RedHatInsights/vmaas/tree/master/vmaas/reposcan) `/api/vmaas/v1/export/dump`. Available in [example/vmaas.db](https://github.com/RedHatInsights/vmaas-lib/blob/main/example/vmaas.db) for testing purposes

# Usage
```go
Expand All @@ -29,9 +28,24 @@ request := vmaas.Request{
Packages: []string{"kernel-0:4.18.0-372.26.1.el8_6.x86_64"},
}
// get CVEs for given package
vulnerabilities, _ := api.Vulnerabilities(request)
vulnerabilities, _ := api.Vulnerabilities(&request)
// get Updates for given package
updates, _ := api.Updates(request)
updates, _ := api.Updates(&request)

```

or inspect and run [example/main.go](https://github.com/RedHatInsights/vmaas-lib/blob/main/example/main.go)
```
go run example/main.go
```

# Setup for MacOS
This package uses `rpm` library, it can be installed using [Homebrew](https://brew.sh/)
```
brew install rpm
```
and linked with
```
export CGO_LDFLAGS="-L/opt/homebrew/opt/rpm/lib"
export CGO_CFLAGS="-I/opt/homebrew/opt/rpm/include -I/opt/homebrew/opt/popt/include"
```
21 changes: 21 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"github.com/redhatinsights/vmaas-lib/vmaas"
"github.com/redhatinsights/vmaas-lib/vmaas/utils"
)

func main() {
api, _ := vmaas.InitFromFile("./example/vmaas.db")
repo := []string{"rhel-7-server-rpms"}
request := vmaas.Request{
Packages: []string{"kernel-0:3.10.0-957.5.1.el7.x86_64"},
Repos: &repo,
UseCsaf: true,
}

vulnerabilities, _ := api.Vulnerabilities(&request)
utils.LogInfo("cves", vulnerabilities.CVEs, "Vulnerabilities")
utils.LogInfo("manually fixable cves", vulnerabilities.ManuallyFixableCVEs, "Vulnerabilities")
utils.LogInfo("unpatched cves", vulnerabilities.UnpatchedCVEs, "Vulnerabilities")
}

0 comments on commit 9be208f

Please sign in to comment.