nilp0inter / cpe

CPE: Common Platform Enumeration for Python
GNU Lesser General Public License v3.0
89 stars 28 forks source link

cpe name_match false when argument is fs format string #52

Open beruhan opened 3 years ago

beruhan commented 3 years ago

Compare cpe use fs format string,the two same cpe compare false.But when use wfn format,It return True

# -*- coding: utf-8 -*-
from cpe.cpeset2_3 import CPESet2_3
from cpe.cpe2_3 import CPE2_3
# compare fs
K = CPESet2_3()
c1 = CPE2_3('cpe:2.3:a:deltaww:cncsoft_screeneditor:1:*:*:*:*:*:*:*')
c2 = CPE2_3("cpe:2.3:a:deltaww:cncsoft_screeneditor:1:*:*:*:*:*:*:*")
K.append(c1)
print(K.name_match(c2))

# compare wfn
K = CPESet2_3()
K.append(CPE2_3(c1.as_wfn()))
print(K.name_match(CPE2_3(c1.as_wfn())))
ywgdjryf commented 3 months ago

Same problem unsolved until now 2024, when use wfn format, the cpe is stored like ['"deltaww"'] , and when use fs it is stroed like ['deltaww']

print(c1.get_vendor(), CPE2_3(c1.as_wfn()).get_vendor())

I guess thats the reason when using fs they compare false as a result.

figure002 commented 1 month ago

Same problem unsolved until now 2024, when use wfn format, the cpe is stored like ['"deltaww"'] , and when use fs it is stroed like ['deltaww']

print(c1.get_vendor(), CPE2_3(c1.as_wfn()).get_vendor())

I guess thats the reason when using fs they compare false as a result.

While this may not be the cause of the above error, this is still a bug. This should be fixed as well, or a new issue created.

figure002 commented 1 month ago

While this may not be the cause of the above error, this is still a bug. This should be fixed as well, or a new issue created.

Regarding my comment above; I just found this in the spec:

In WFNs, attribute-value strings will be enclosed in double quotes as in the examples below. The quotation marks are, of course, not considered part of the string values themselves.

So it's probably done on purpose. And I also noticed in the source that they do account for double quotes, and they are not used for comparison.