-
Notifications
You must be signed in to change notification settings - Fork 85
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
[RFC] cpesearch: Use NIST api to filter out deprecated CPEs #2511
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Thomas Staudinger <[email protected]>
if test "$argv[1]" = "--help"; or test "$argv[1]" = "-h"; or test (count $argv) -ne 1 | ||
echo "usage: cpesearch <package-name>" | ||
else | ||
curl -s -X POST https://cpe-guesser.cve-search.org/search -d "{\"query\": [\"$argv[1]\"]}" | jq . | ||
curl -s "https://services.nvd.nist.gov/rest/json/cpes/2.0?cpeMatchString=cpe:2.3:*:*:$argv[1]*" |\ | ||
jq 'del(.products.[] | select(.cpe.deprecated == true))' | jq -r '.products.[].cpe.cpeName' |\ | ||
cut -d":" -f1-5 | sort -u | ||
|
||
echo "Verify successful hits by visiting https://cve.circl.lu/search/\$VENDOR/\$PRODUCT" | ||
echo -e "\nVerify successful hits by visiting https://cve.circl.lu/search/\$VENDOR/\$PRODUCT" | ||
echo "- CPE entries for software applications have the form 'cpe:2.3:a:\$VENDOR:\$PRODUCT" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like at this point it might be a good idea to consolidate this by moving it to a bash script in common/Scripts
and calling that here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's more of a proof of concept (also it grew a bit more unwieldy than I initially expected ^^)
For the sake of argument, could we, say, allow allow searches w/prefixes and then filter on And, building on Silke's comment above, if this were a python script, would that give us more options re. using it from different shells? |
Summary
This makes the
cpesearch
helper function use the NIST website API instead of cve-search.org to enable the filtering out of deprecated CPEs.Example output:
Old output:
Note that
cpe:2.3:a:valvesoftware:steam
andcpe:2.3:a:valve:steam
are deprecatedConsiderations:
Hardcode ":a:" in
cpeMatchString
to only match applications?I'm not sure if we need e.g. ":h:" in some cases (for drivers?)
Also search vendor part of the CPEs?
This would require a second request as far as I can see
Allow matches with a prefix?
With the current version only suffixes to the searched string are allowed (to catch things like
_client
and so on). This could be an issue with libraries that may or may not start withlib
at times. On the other hand extending the wildcarding so prefixes are allowed produces A LOT of matches at times. I don't think the API itself allows finer-grained controls but additional filtering could be done injq
which has regex supportExample of searching for
steam
with prefixes allowed: