goval-dictionary icon indicating copy to clipboard operation
goval-dictionary copied to clipboard

CentOS lookups return ‘ Unsupport family’ error

Open ianmuscat opened this issue 5 years ago • 0 comments

I've encountered what seems to be a bug with CentOS when goval-dictionary is operated in server mode (using MySQL as a database).

The following request returns null

curl http://127.0.0.1:1324/packs/centos/7.7.1908/kernel
null

Compare this to the same request, but using redhat instead of centos

curl http://127.0.0.1:1324/packs/redhat/7.7.1908/kernel16:20:15
[
  {
    "ID": 158,
    "DefinitionID": "oval:com.redhat.rhsa:def:20140678",
    ...

Upon looking at the logs, I noticed that anytime I make a request using centos, I get the following error.

EROR[01-28|16:23:19] Failed to get by CveID.                  err="Unsupport family: redhat"

The reason this error seems to be occuring is because when checking if ovalMap has a key of family: https://github.com/kotakanbe/goval-dictionary/blob/9dfb9028794e2316c3ca45be18199e261c592d5b/db/rdb/rdb.go#L200 It is failing since ovalMap["redhat"] does not exist (ovalMap["centos"] exists instead).

https://github.com/kotakanbe/goval-dictionary/blob/9dfb9028794e2316c3ca45be18199e261c592d5b/db/rdb/rdb.go#L82-L83 Changing the above to the following seems to have fixed the issue for me, however, I'm not sure if this change breaks anything else.

case c.RedHat, c.CentOS:
		ovalMap[c.RedHat] = NewRedHat()

Re-issuing the same HTTP request with the above patch applied produces the expected output.

curl http://127.0.0.1:1324/packs/centos/7.7.1908/kernel
[
  {
    "ID": 158,
    "DefinitionID": "oval:com.redhat.rhsa:def:20140678",
    ...

I would gladly submit a PR, assuming my reading of how to fix this bug is correct.

ianmuscat avatar Jan 28 '20 15:01 ianmuscat