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

ubuntu: verify dist is actually ubuntu #970

Merged
merged 1 commit into from
Jun 23, 2023
Merged

Conversation

RTann
Copy link
Contributor

@RTann RTann commented Jun 16, 2023

This PR addresses #969

Note: This PR does not address potentially needing to migrate/cleanup the database for current installations. This does, however, prevent the issue from popping up in fresh installs.

@RTann RTann requested a review from a team as a code owner June 16, 2023 18:03
@RTann RTann requested review from crozzy and removed request for a team June 16, 2023 18:03
@RTann
Copy link
Contributor Author

RTann commented Jun 16, 2023

@crozzy the unit tests pass, but I'm wondering how you usually test ClairCore upgrades because I haven't done it before. Any suggestions?

@crozzy
Copy link
Contributor

crozzy commented Jun 16, 2023

I usually do a manual test for instances like these, we currently don't have a good automated way to test changes on environments with existing state:

  • checkout main and start Clair (docker-compose or however you like to do it, make sure you're replacing the claircore mod with your local go mod edit -replace github.com/quay/claircore=../claircore)
  • run an index request that is getting mis-distributioned (:grimacing:)
  • kill the indexer container/pod
  • checkout your branch
  • rebuild the indexer container/pod
  • re-run the index request, check that the distribution is correct

Happy to go into more detail if any steps aren't clear

@crozzy
Copy link
Contributor

crozzy commented Jun 21, 2023

This looks good, just needs a rebase

@RTann
Copy link
Contributor Author

RTann commented Jun 22, 2023

Testing by doing the following:

  1. Run the main branch of clair via make local-dev (only changes I made were to the config to run only debian and ubuntu matchers/updaters and removed the need for the auth psk)
  2. Ran go run ./cmd/clairctl report debian:stable-slim and go run ./cmd/clairctl report gcr.io/distroless/base
  3. Ran the following:
$ docker exec -it clair-database /bin/bash
$ psql indexer --username clair

From here, I can see the following:

indexer=> SELECT name, version, version_code_name, version_id FROM dist;
       name       |    version    | version_code_name | version_id 
------------------+---------------+-------------------+------------
 Ubuntu           | 12 (Bookworm) | bookworm          | 12
 Debian GNU/Linux | 12 (bookworm) | bookworm          | 12
 Debian GNU/Linux | 11 (bullseye) | bullseye          | 11
 Ubuntu           | 11 (Bullseye) | bullseye          | 11
(4 rows)

One thing to note: the vuln report only mentioned Debian in the distributions map. Never mentioned Ubuntu. For example:

"distributions": {
    "3": {
      "id": "3",
      "did": "debian",
      "name": "Debian GNU/Linux",
      "version": "11 (bullseye)",
      "version_code_name": "bullseye",
      "version_id": "11",
      "arch": "",
      "cpe": "",
      "pretty_name": "Debian GNU/Linux 11 (bullseye)"
    }
  },
  1. Add replace github.com/quay/claircore => github.com/RTann/claircore debian-isnt-ubuntu to the go.mod
  2. $ go mod tidy && go mod vendor
  3. Killed all containers and reran local-dev
  4. Generate vuln reports again
  5. Find this:
indexer=> select * from dist;
 id |       name       |  did   |    version    | version_code_name | version_id | arch | cpe |
          pretty_name           
----+------------------+--------+---------------+-------------------+------------+------+-----+
--------------------------------
  1 | Debian GNU/Linux | debian | 12 (bookworm) | bookworm          | 12         |      |     |
 Debian GNU/Linux 12 (bookworm)
  2 | Debian GNU/Linux | debian | 11 (bullseye) | bullseye          | 11         |      |     |
 Debian GNU/Linux 11 (bullseye)
(2 rows)

Looks like this PR properly attributes these images to Debian, only.

@crozzy
Copy link
Contributor

crozzy commented Jun 22, 2023

nice work @RTann

crozzy
crozzy previously approved these changes Jun 22, 2023
@RTann RTann force-pushed the debian-isnt-ubuntu branch from 65fdc77 to 14a482d Compare June 22, 2023 22:32
@RTann RTann force-pushed the debian-isnt-ubuntu branch from 14a482d to e2a0ae7 Compare June 22, 2023 22:42
@RTann RTann requested a review from crozzy June 22, 2023 22:45
ubuntu/distributionscanner.go Outdated Show resolved Hide resolved
@RTann RTann force-pushed the debian-isnt-ubuntu branch from e2a0ae7 to c9c47ca Compare June 23, 2023 21:10
@RTann RTann requested a review from hdonnay June 23, 2023 21:11
@crozzy crozzy merged commit 2462d9e into quay:main Jun 23, 2023
@RTann RTann deleted the debian-isnt-ubuntu branch June 23, 2023 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants