Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5605877
rhel: add csaf/vex updater
crozzy Feb 2, 2024
99ec7a8
rhel: update RHEL matcher to account for CPE subset matching
crozzy Apr 25, 2024
3853221
rhel: move IgnoreUnpatched config key from updater to matcher
crozzy May 9, 2024
daaf5fd
rhel: remove rhel oval updater from defaults
crozzy May 14, 2024
812a7b6
vex: check if debug logging enabled before appending
crozzy Aug 19, 2024
c01da99
chore: v1.5.29 changelog bump
crozzy Aug 21, 2024
3cb3a1b
test: add some go-cmp helpers
hdonnay Aug 21, 2024
5ee4391
test: add limited jsonref implementation
hdonnay Aug 21, 2024
0ea197e
mock/datastore: add datastore mocks
hdonnay Aug 21, 2024
0066d63
test: add Matcher test harness
hdonnay Aug 21, 2024
2c933d4
java: port Matcher test to harness
hdonnay Aug 20, 2024
eb20bed
chore(deps): bump go.opentelemetry.io/otel/trace in the otel group
dependabot[bot] Aug 26, 2024
649b2aa
chore(deps): bump github.com/prometheus/client_golang
dependabot[bot] Aug 26, 2024
9773352
ruby: port Matcher test to harness
hdonnay Aug 26, 2024
c2fc225
nodejs: port Matcher test to harness
hdonnay Aug 27, 2024
4011b96
cvss: v3: fix scope multiplication placement
RTann Aug 27, 2024
0e59253
rhel: update security data url domain
RTann Aug 29, 2024
da9a4a0
vex: update some minor parsing logic
crozzy Sep 4, 2024
70a5e30
python: port Matcher test to harness
hdonnay Aug 26, 2024
64d2456
cicd: automate list of "golang" image versions
hdonnay Aug 26, 2024
8dd6a35
rhel: add repo_key matching constraint
crozzy Aug 28, 2024
0f0668f
matcher: cache query results for the same query
crozzy Aug 29, 2024
cec4646
chore: v1.5.30 changelog bump
crozzy Sep 6, 2024
e369597
chore(deps): bump peter-evans/create-pull-request from 6 to 7
dependabot[bot] Sep 9, 2024
9bb83c3
chore(deps): bump github.com/prometheus/client_golang
dependabot[bot] Sep 10, 2024
85a0988
chore(deps): bump modernc.org/sqlite from 1.32.0 to 1.33.0
dependabot[bot] Sep 10, 2024
9e43829
vex: buffer changes.csv response
crozzy Sep 11, 2024
635444d
chore: v1.5.31 changelog bump
crozzy Sep 16, 2024
a6ebdd9
chore(deps): bump modernc.org/sqlite from 1.33.0 to 1.33.1
dependabot[bot] Sep 16, 2024
f96bfb4
chore: update go version to go1.22.7
crozzy Sep 17, 2024
66c3c9b
chore: align go version with docs
crozzy Sep 19, 2024
3bb955d
chore(deps): bump go.opentelemetry.io/otel from 1.29.0 to 1.30.0
dependabot[bot] Sep 20, 2024
db89e27
chore(deps): bump the golang-x group across 1 directory with 4 updates
dependabot[bot] Sep 20, 2024
1602d4b
chore(deps): bump github.com/prometheus/client_golang
dependabot[bot] Sep 23, 2024
7088f7b
vex: fetcher add changes before archived data
crozzy Aug 21, 2024
a39764c
chore(deps): bump github.com/klauspost/compress from 1.17.9 to 1.17.10
dependabot[bot] Sep 30, 2024
65b6b8b
alpine: use alpine security vuln link
RTann Oct 2, 2024
54959d6
vex: account for package module when parsing VEX
crozzy Sep 18, 2024
19b7774
chore: v1.5.32 changelog bump
crozzy Oct 4, 2024
b037b25
chore(deps): bump the golang-x group with 5 updates
dependabot[bot] Oct 7, 2024
9db6de4
chore(deps): bump go.opentelemetry.io/otel from 1.30.0 to 1.31.0
dependabot[bot] Oct 14, 2024
59b3a5a
chore(deps): bump github.com/klauspost/compress from 1.17.10 to 1.17.11
dependabot[bot] Oct 14, 2024
cefc21a
chore(deps): bump github.com/prometheus/client_golang
dependabot[bot] Oct 21, 2024
2627978
chore(deps): bump go.uber.org/mock from 0.4.0 to 0.5.0
dependabot[bot] Oct 28, 2024
73859ed
osv: disable more ecosystems
crozzy Oct 28, 2024
ada0982
suse: dynamic distribution discovery
crozzy Oct 28, 2024
946d38f
vex: remove unused newFingerprint() function
crozzy Nov 5, 2024
b76b7ba
vex: add non-vuln advisories to the deleted slice
crozzy Nov 5, 2024
adf5065
chore: v1.5.33 changelog bump
crozzy Nov 8, 2024
8695f45
docs: update README to remove non-existent commands
crozzy Nov 8, 2024
c31338f
chore(deps): bump go.opentelemetry.io/otel/trace in the otel group
dependabot[bot] Nov 11, 2024
81480f4
chore(deps): bump the golang-x group with 7 updates
dependabot[bot] Nov 11, 2024
e7094c2
osv: account for event objects that have multiple streams
crozzy Oct 17, 2024
23d3de1
chore(deps): bump modernc.org/sqlite from 1.33.1 to 1.34.1
dependabot[bot] Nov 18, 2024
3f4919e
chore(deps): bump codecov/codecov-action from 4 to 5
dependabot[bot] Nov 19, 2024
ad640c4
gobin: ignore flags in stdlib version
RTann Nov 14, 2024
ae50b58
periodic: account for differences with Konflux built images
crozzy Nov 22, 2024
c5d5226
chore(deps): bump the golang-x group with 6 updates
dependabot[bot] Dec 9, 2024
4c76010
chore(deps): bump modernc.org/sqlite from 1.34.1 to 1.34.2
dependabot[bot] Dec 9, 2024
340d457
chore(deps): bump golang.org/x/crypto in the golang-x group
dependabot[bot] Dec 16, 2024
f49fb5d
chore(deps): bump go.opentelemetry.io/otel/trace in the otel group
dependabot[bot] Dec 16, 2024
4701605
rhel: deprecate updater in favor of VEX updater
crozzy Jun 27, 2024
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
15 changes: 14 additions & 1 deletion .github/workflows/golang-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,27 @@ env:
QUAY_USER: projectquay+claircore_github

jobs:
versions:
if: ${{ github.repository == 'quay/claircore' }}
name: Check available go versions
runs-on: 'ubuntu-latest'
outputs:
versions: ${{ steps.versions.outputs.versions }}
steps:
- id: versions
run: |
curl -sL 'https://golang.org/dl/?mode=json' |
jq -rc 'map(.version|sub("go(?<maj>1\\.[0-9]+)\\.[0-9]+$";"\(.maj)"))|@text "versions=\(.)"' >> $GITHUB_OUTPUT

golang-image:
if: ${{ github.repository == 'quay/claircore' }}
needs: versions
name: Build and publish golang image
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
go: ['1.18', '1.19', '1.20', '1.21', '1.22']
go: ${{ fromJSON(needs.versions.outputs.versions) }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
fail-fast: false
matrix:
go:
- '1.22'
- '1.21'
- 'stable'
- 'oldstable'
steps:
- name: Check for Previous Run
id: previous
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
steps.previous.outputs.cache-hit != 'true' &&
success() &&
strategy.job-index == 0
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
directory: ${{ runner.temp }}
override_branch: ${{ github.ref_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git fetch --tags origin refs/notes/changelog:refs/notes/changelog
.github/scripts/changelog-update "${{ github.event.inputs.tag }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
title: "${{ github.event.inputs.tag }} Changelog Bump"
body: "This is an automated changelog commit."
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-clair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
add-paths: go.mod,go.sum
token: ${{ steps.generate_token.outputs.token }}
Expand Down
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
<a name="v1.5.33"></a>
## [v1.5.33] - 2024-11-08
[v1.5.33]: https://github.com/quay/claircore/compare/v1.5.32...v1.5.33

- suse: dynamic distribution discovery
<details>
Previously Suse distributions were static/predefined in the code, the
lack of updates to those definitions had allowed the Suse support lapse.
This change adds dynamic support for two Suse distro flavors:
suse.linux.enterprise.server and opensuse.leap.
</details>

<a name="v1.5.32"></a>
## [v1.5.32] - 2024-10-04
[v1.5.32]: https://github.com/quay/claircore/compare/v1.5.31...v1.5.32

Nothing interesting happened this release.

<a name="v1.5.31"></a>
## [v1.5.31] - 2024-09-16
[v1.5.31]: https://github.com/quay/claircore/compare/v1.5.30...v1.5.31

Nothing interesting happened this release.

<a name="v1.5.30"></a>
## [v1.5.30] - 2024-09-06
[v1.5.30]: https://github.com/quay/claircore/compare/v1.5.29...v1.5.30

Nothing interesting happened this release.

<a name="v1.5.29"></a>
## [v1.5.29] - 2024-08-21
[v1.5.29]: https://github.com/quay/claircore/compare/v1.5.28...v1.5.29

- rhel: move IgnoreUnpatched config key from updater to matcher
<details>
Previously the IgnoreUnpatched config key was a part of the RHEL
updater and would dictate whether or not the updater would ingest
unpatched vulnerabilities. This change moves that key to the RHEL
matcher and dictates whether the matcher should check for a
fixed_in_version when querying potential vulnerabilities. This makes the
config option more usable at the expense of DB size.
</details>

- rhel: add csaf/vex updater
<details>
Replace the RHEL OVAL updater with a CSAF/VEX updater for Red Hat
security data. Update the matching logic to deal with CPE patterns
coming from the VEX files. Remove RHEL updater and add a migration to
delete Red Hat OVAL data from the database.
</details>

<a name="v1.5.28"></a>
## [v1.5.28] - 2024-05-13
[v1.5.28]: https://github.com/quay/claircore/compare/v1.5.27...v1.5.28
Expand Down
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
![](https://github.com/quay/claircore/workflows/CI/badge.svg)
# ClairCore
# Claircore

ClairCore provides a set of go modules which handle scanning container layers for installed packages and reporting any discovered vulnerabilities.
ClairCore is designed to be embedded into a service wrapper.
Claircore provides a set of go modules which handle scanning container layers for installed packages and reporting any discovered vulnerabilities.
Claircore is designed to be embedded into a service wrapper.

For a full overview see: [ClairCore Book](https://quay.github.io/claircore)
For a full overview see: [Claircore Book](https://quay.github.io/claircore)

# Local development and testing
# Testing

The following targets start and stop a local development environment
```
make local-dev-up
make local-dev-down
```

If you modify libvuln or libindex code the following make targets will restart the services with your changes
```
make libindexhttp-restart
make libvulnhttp-restart
The following make target runs unit tests which do not require a database or local development environment.
```sh
make unit
# or make unit-v for verbose output
```

With the local development environment up the following make target runs all tests including integration
```
With the local development environment up the following make target runs all tests including integration.
```sh
make integration
# or integration-v for verbose output
```

The following make target runs unit tests which do not require a database or local development environment
```
make unit
With the local development environment up the following make target runs all tests including integration with full benchmark results.
```sh
make bench
```
5 changes: 2 additions & 3 deletions alpine/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package alpine
import (
"context"
"encoding/json"
"fmt"
"io"

"github.com/quay/zlog"
Expand All @@ -13,7 +12,7 @@ import (
)

const (
cveURLPrefix = "https://www.cve.org/CVERecord?id=%s"
cveURLPrefix = "https://security.alpinelinux.org/vuln/"
)

var _ driver.Parser = (*updater)(nil)
Expand Down Expand Up @@ -59,7 +58,7 @@ func unpackSecFixes(partial claircore.Vulnerability, secFixes map[string][]strin
v := partial
v.Name = id
v.FixedInVersion = fixedIn
v.Links = fmt.Sprintf(cveURLPrefix, id)
v.Links = cveURLPrefix + id
out = append(out, &v)
}
}
Expand Down
18 changes: 9 additions & 9 deletions alpine/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var dist310 = stableRelease{3, 10}.Distribution()
var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
{
Name: "CVE-2018-20187",
Links: "https://www.cve.org/CVERecord?id=CVE-2018-20187",
Links: "https://security.alpinelinux.org/vuln/CVE-2018-20187",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "2.9.0-r0",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -30,7 +30,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2018-12435",
Links: "https://www.cve.org/CVERecord?id=CVE-2018-12435",
Links: "https://security.alpinelinux.org/vuln/CVE-2018-12435",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "2.7.0-r0",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -42,7 +42,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2018-9860",
Links: "https://www.cve.org/CVERecord?id=CVE-2018-9860",
Links: "https://security.alpinelinux.org/vuln/CVE-2018-9860",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "2.6.0-r0",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -54,7 +54,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2018-9127",
Links: "https://www.cve.org/CVERecord?id=CVE-2018-9127",
Links: "https://security.alpinelinux.org/vuln/CVE-2018-9127",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "2.5.0-r0",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -66,7 +66,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2019-9929",
Links: "https://www.cve.org/CVERecord?id=CVE-2019-9929",
Links: "https://security.alpinelinux.org/vuln/CVE-2019-9929",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "3.12.2-r0",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -78,7 +78,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2017-6949",
Links: "https://www.cve.org/CVERecord?id=CVE-2017-6949",
Links: "https://security.alpinelinux.org/vuln/CVE-2017-6949",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "4.12.0-r3",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -90,7 +90,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2017-9334",
Links: "https://www.cve.org/CVERecord?id=CVE-2017-9334",
Links: "https://security.alpinelinux.org/vuln/CVE-2017-9334",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "4.12.0-r2",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -102,7 +102,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2016-6830",
Links: "https://www.cve.org/CVERecord?id=CVE-2016-6830",
Links: "https://security.alpinelinux.org/vuln/CVE-2016-6830",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "4.11.1-r0",
NormalizedSeverity: claircore.Unknown,
Expand All @@ -114,7 +114,7 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{
},
{
Name: "CVE-2016-6831",
Links: "https://www.cve.org/CVERecord?id=CVE-2016-6831",
Links: "https://security.alpinelinux.org/vuln/CVE-2016-6831",
Updater: "alpine-community-v3.10-updater",
FixedInVersion: "4.11.1-r0",
NormalizedSeverity: claircore.Unknown,
Expand Down
31 changes: 25 additions & 6 deletions datastore/postgres/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ var (
)
)

type recordQuery struct {
record *claircore.IndexRecord
query string
}

// Get implements vulnstore.Vulnerability.
func (s *MatcherStore) Get(ctx context.Context, records []*claircore.IndexRecord, opts datastore.GetOpts) (map[string][]*claircore.Vulnerability, error) {
ctx = zlog.ContextWithValues(ctx, "component", "internal/vulnstore/postgres/Get")
Expand All @@ -46,6 +51,8 @@ func (s *MatcherStore) Get(ctx context.Context, records []*claircore.IndexRecord
defer tx.Rollback(ctx)
// start a batch
batch := &pgx.Batch{}
resCache := map[string]pgx.Rows{}
rqs := []*recordQuery{}
for _, record := range records {
query, err := buildGetQuery(record, &opts)
if err != nil {
Expand All @@ -56,8 +63,13 @@ func (s *MatcherStore) Get(ctx context.Context, records []*claircore.IndexRecord
Msg("could not build query for record")
continue
}
rqs = append(rqs, &recordQuery{query: query, record: record})
if _, ok := resCache[query]; ok {
continue
}
// queue the select query
batch.Queue(query)
resCache[query] = nil
}
// send the batch

Expand All @@ -70,11 +82,18 @@ func (s *MatcherStore) Get(ctx context.Context, records []*claircore.IndexRecord
// gather all the returned vulns for each queued select statement
results := make(map[string][]*claircore.Vulnerability)
vulnSet := make(map[string]map[string]struct{})
for _, record := range records {
rows, err := res.Query()
if err != nil {
res.Close()
return nil, err
for _, rq := range rqs {
rows, ok := resCache[rq.query]
if !ok {
return nil, fmt.Errorf("unexpected vulnerability query: %s", rq.query)
}
if rows == nil {
rows, err = res.Query()
if err != nil {
res.Close()
return nil, err
}
resCache[rq.query] = rows
}

// unpack all returned rows into claircore.Vulnerability structs
Expand Down Expand Up @@ -121,7 +140,7 @@ func (s *MatcherStore) Get(ctx context.Context, records []*claircore.IndexRecord
return nil, fmt.Errorf("failed to scan vulnerability: %v", err)
}

rid := record.Package.ID
rid := rq.record.Package.ID
if _, ok := vulnSet[rid]; !ok {
vulnSet[rid] = make(map[string]struct{})
}
Expand Down
4 changes: 4 additions & 0 deletions datastore/postgres/migrations/matcher/13-delete-rhel-oval.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- The rhel-vex updater will now be responsible for RHEL advisories so we have
-- to delete the existing rhel vulnerabilities.
DELETE FROM update_operation WHERE updater ~ 'RHEL[5-9]-*';
DELETE FROM vuln where updater ~ 'RHEL[5-9]-*';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- The rhel-vex updater will now be responsible for RHCC advisories so we have
-- to delete the existing RHCC vulnerabilities.
DELETE FROM update_operation WHERE updater = 'rhel-container-updater';
DELETE FROM vuln where updater = 'rhel-container-updater';
8 changes: 8 additions & 0 deletions datastore/postgres/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,12 @@ var MatcherMigrations = []migrate.Migration{
ID: 12,
Up: runFile("matcher/12-add-latest_update_operation-index.sql"),
},
{
ID: 13,
Up: runFile("matcher/13-delete-rhel-oval.sql"),
},
{
ID: 14,
Up: runFile("matcher/14-delete-rhcc-vulns.sql"),
},
}
5 changes: 5 additions & 0 deletions datastore/postgres/querybuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/doug-martin/goqu/v8"
_ "github.com/doug-martin/goqu/v8/dialect/postgres"
"github.com/doug-martin/goqu/v8/exp"

"github.com/quay/claircore"
"github.com/quay/claircore/datastore"
Expand Down Expand Up @@ -70,6 +71,10 @@ func buildGetQuery(record *claircore.IndexRecord, opts *datastore.GetOpts) (stri
ex = goqu.Ex{"dist_arch": record.Distribution.Arch}
case driver.RepositoryName:
ex = goqu.Ex{"repo_name": record.Repository.Name}
case driver.RepositoryKey:
ex = goqu.Ex{"repo_key": record.Repository.Key}
case driver.HasFixedInVersion:
ex = goqu.Ex{"fixed_in_version": goqu.Op{exp.NeqOp.String(): ""}}
default:
return "", fmt.Errorf("was provided unknown matcher: %v", m)
}
Expand Down
Loading