Skip to content

Commit

Permalink
common/Scripts: Allow no args usage of cpesearch() (#1761)
Browse files Browse the repository at this point in the history
**Summary**
- When no args are passed to cpesearch() it'll use the current directory
name. Useful in combination with gotopkg().

**Test Plan**

`gotopkg systemd; cpesearch`
`goroot; cpesearch systemd`

**Checklist**

- [ ] Package was built and tested against unstable
  • Loading branch information
ermo authored Feb 29, 2024
2 parents 6109493 + 792b0d7 commit a240e9b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions common/Scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

# Primitive CPE search tool
function cpesearch() {
if [[ -z "$1" || "$1" == "--help" || "$1" == "-h" ]]; then
echo "usage: cpesearch <package-name>"
else
function search() {
curl -s -X POST https://cpe-guesser.cve-search.org/search -d "{\"query\": [\"$1\"]}" | jq .

echo "Verify 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'"
}

if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "usage: cpesearch <package-name>"
elif [[ $# -eq 0 ]]; then
echo "Warning: No paramaters passed, using current directory name. Pass --help to see usage"
search "$(basename "$(pwd)")"
else
search "$1"
fi
}

Expand Down

0 comments on commit a240e9b

Please sign in to comment.