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

feat(db/redis): do not use Arch for Key in Oracle, Amazon, Fedora #402

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

MaineK00n
Copy link
Collaborator

@MaineK00n MaineK00n commented Jun 21, 2024

If this Pull Request is work in progress, Add a prefix of “[WIP]” in the title.

What did you implement:

Oracle, Amazon, and Fedora had Package Name and Arch for Key.
This allows you to find a really related Definition from the affected package and architecture.

$ redis-cli -n 1 KEYS "OVAL#debian#12#PKG#bash"
1) "OVAL#debian#12#PKG#bash"

// It is not known which architectures will be affected!
$ redis-cli -n 1 SMEMBERS "OVAL#debian#12#PKG#bash"
 1) "oval:org.debian:def:155603378603305228310656709111303140715" // Maybe Aarch64 is not affected!
 2) "oval:org.debian:def:104452954611053805468881680603569149504"
 3) "oval:org.debian:def:242327748915839239835482148445959073568"
 ...

$ redis-cli -n 1 KEYS "OVAL#oracle#8#PKG#bash#*"
1) "OVAL#oracle#8#PKG#bash#x86_64"
2) "OVAL#oracle#8#PKG#bash#aarch64"

// This Definition always affects x86_64!
$ redis-cli -n 1 SMEMBERS "OVAL#oracle#8#PKG#bash#x86_64"
1) "oval:com.oracle.elsa:def:20211679" 

However, it is only necessary to check that the Arch is listed in the package affected by Definition, even if you do not attach ARCH to the end of Key.

$ redis-cli -n 1 KEYS "OVAL#oracle#8#PKG#bash"

$ redis-cli -n 1 SMEMBERS "OVAL#oracle#8#PKG#bash"

// Only x86_64 and aarch64 are affected!
$ redis-cli -n 1 HGET "OVAL#oracle#8#DEF" "oval:com.oracle.elsa:def:20211679" | jq
{
  "DefinitionID": "oval:com.oracle.elsa:def:20211679",
  "Title": "ELSA-2021-1679:  bash security and bug fix update (LOW)",
  "Description": "[4.4.19-14]\n- Fix hang when limit for nproc is very high\n  Resolves: #1890888\n\n[4.4.19-13]\n- Correctly drop saved UID when effective UID is not equal to its real UID\n  Resolves: #1793943",
  "Advisory": {
    "Severity": "LOW",
    "Cves": [
      {
        "CveID": "CVE-2019-18276",
        "Cvss2": "",
        "Cvss3": "",
        "Cwe": "",
        "Impact": "",
        "Href": "https://linux.oracle.com/cve/CVE-2019-18276.html",
        "Public": ""
      }
    ],
    "Bugzillas": [],
    "AffectedResolution": null,
    "AffectedCPEList": [],
    "AffectedRepository": "",
    "Issued": "1000-01-01T00:00:00Z",
    "Updated": "1000-01-01T00:00:00Z"
  },
  "Debian": null,
  "AffectedPacks": [
    {
      "Name": "bash",
      "Version": "0:4.4.19-14.el8",
      "Arch": "aarch64",
      "NotFixedYet": false,
      "ModularityLabel": ""
    },
    {
      "Name": "bash-doc",
      "Version": "0:4.4.19-14.el8",
      "Arch": "aarch64",
      "NotFixedYet": false,
      "ModularityLabel": ""
    },
    {
      "Name": "bash",
      "Version": "0:4.4.19-14.el8",
      "Arch": "x86_64",
      "NotFixedYet": false,
      "ModularityLabel": ""
    },
    {
      "Name": "bash-doc",
      "Version": "0:4.4.19-14.el8",
      "Arch": "x86_64",
      "NotFixedYet": false,
      "ModularityLabel": ""
    }
  ],
  "References": [
    {
      "Source": "elsa",
      "RefID": "ELSA-2021-1679",
      "RefURL": "https://linux.oracle.com/errata/ELSA-2021-1679.html"
    },
    {
      "Source": "CVE",
      "RefID": "CVE-2019-18276",
      "RefURL": "https://linux.oracle.com/cve/CVE-2019-18276.html"
    }
  ]
}

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

before

$ docker run --rm -d -p 127.0.0.1:6379:6379 redis
$ goval-dictionary fetch oracle 8 --dbtype redis --dbpath "redis://127.0.0.1:6379/1"
$ redis-cli -n 1 dbsize
(integer) 11226

$ goval-dictionary select --by-package oracle 8 "bash" "x86_64" --dbtype redis --dbpath "redis://127.0.0.1:6379/1"
CVE-2019-18276
    {0 0 bash 0:4.4.19-14.el8 x86_64 false }
    {0 0 bash-doc 0:4.4.19-14.el8 x86_64 false }
------------------
...
$ goval-dictionary select --by-package oracle 8 "bash" "i386" --dbtype redis --dbpath "redis://127.0.0.1:6379/1"
------------------
[]models.Definition{}

after

$ docker run --rm -d -p 127.0.0.1:6379:6379 redis
$ goval-dictionary fetch oracle 8 --dbtype redis --dbpath "redis://127.0.0.1:6379/1"
$ redis-cli -n 1 dbsize
(integer) 7902

$ goval-dictionary select --by-package oracle 8 "bash" "x86_64" --dbtype redis --dbpath "redis://127.0.0.1:6379/1"
CVE-2019-18276
    {0 0 bash 0:4.4.19-14.el8 x86_64 false }
    {0 0 bash-doc 0:4.4.19-14.el8 x86_64 false }
------------------
...
$ goval-dictionary select --by-package oracle 8 "bash" "i386" --dbtype redis --dbpath "redis://127.0.0.1:6379/1"
------------------
[]models.Definition{}

Checklist:

You don't have to satisfy all of the following.

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

Reference

@MaineK00n MaineK00n self-assigned this Jun 21, 2024
@MaineK00n MaineK00n marked this pull request as ready for review June 23, 2024 23:36
@MaineK00n MaineK00n requested a review from shino June 24, 2024 03:03
@MaineK00n MaineK00n removed the request for review from shino June 24, 2024 09:53
@MaineK00n MaineK00n requested a review from shino June 25, 2024 06:30
Copy link
Contributor

@shino shino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greatly simplified!

@MaineK00n MaineK00n merged commit 1da5dfb into master Jun 25, 2024
13 checks passed
@MaineK00n MaineK00n deleted the MaineK00n/redis branch June 25, 2024 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants