
اكتشاف الثغرات البرمجية المحتملة من رسائل التزامات غيت

العثور على الثغرات الأمنية المحتملة في البرمجيات من رسائل التزام git. صيغة الإخراج هي JSON مع التزام المرتبط الذي قد يحتوي على إصلاح لثغرة أمنية. يعتمد البحث على مجموعة من التعبيرات النمطية مقابل رسائل الالتزام فقط. إذا كانت معرفات CVE موجودة، يتم إضافتها تلقائيًا في الإخراج. يمكن أن يكون الإدخال أي مستودعات git أو مصدر GH archive.
sudo apt install jq)يمكن تثبيت git-vuln-finder باستخدام poetry. إذا لم يكن poetry مثبتًا لديك، يمكنك القيام بما يلي curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python.
$ poetry install
$ poetry shell
$ git-vuln-finder -h
يمكنك أيضًا استخدام pip. ثم استيراده فقط:
Python 3.8.0 (default, Dec 11 2019, 21:43:13)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from git_vuln_finder import find
>>> all_potential_vulnerabilities, all_cve_found, found = find("~/git/curl")
>>> [commit for commit, summary in all_potential_vulnerabilities.items() if summary['state'] == 'cve-assigned']
['9069838b30fb3b48af0123e39f664cea683254a5', 'facb0e4662415b5f28163e853dc6742ac5fafb3d',
... snap ...
'8a75dbeb2305297640453029b7905ef51b87e8dd', '1dc43de0dccc2ea7da6dddb7b98f8d7dcf323914', '192c4f788d48f82c03e9cef40013f34370e90737', '2eb8dcf26cb37f09cffe26909a646e702dbcab66', 'fa1ae0abcde5df8d0b3283299e3f246bedf7692c', 'c11c30a8c8d727dcf5634fa0cc6ee0b4b77ddc3d', '75ca568fa1c19de4c5358fed246686de8467c238', 'a20daf90e358c1476a325ea665d533f7a27e3364', '042cc1f69ec0878f542667cb684378869f859911']
>>> print(json.dumps(all_potential_vulnerabilities['9069838b30fb3b48af0123e39f664cea683254a5'], sort_keys=True, indent=4, separators=(",", ": ")))
{
"author": "Daniel Stenberg",
"author-email": "[email protected]",
"authored_date": 1567544372,
"branches": [
"master"
],
"commit-id": "9069838b30fb3b48af0123e39f664cea683254a5",
"committed_date": 1568009674,
"cve": [
"CVE-2019-5481",
"CVE-2019-5481"
],
"language": "en",
"message": "security:read_data fix bad realloc()\n\n... that could end up a double-free\n\nCVE-2019-5481\nBug: https://curl.haxx.se/docs/CVE-2019-5481.html\n",
"origin": "https://github.com/curl/curl.git",
"origin-github-api": "https://api.github.com/repos///github.com/curl/curl/commits/9069838b30fb3b48af0123e39f664cea683254a5",
"pattern-matches": [
"double-free"
],
"pattern-selected": "(?i)(double[-| ]free|buffer overflow|double free|race[-| ]condition)",
"state": "cve-assigned",
"stats": {
"deletions": 4,
"files": 1,
"insertions": 2,
"lines": 6
},
"summary": "security:read_data fix bad realloc()",
"tags": []
}
$ git clone https://github.com/cve-search/git-vuln-finder.git
$ cd https://github.com/cve-search/git-vuln-finder.git
$ pip install .
$ git-vuln-finder --help
يمكنك أيضًا استخدام pip.
يقوم pipx بتثبيت البرامج النصية (المتاحة على مستوى النظام) المقدمة من حزم Python في بيئات افتراضية منفصلة لحمايتها من نظامك ومن بعضها البعض.
usage: git-vuln-finder [-h] [-v] [-r R] [-o O] [-s S] [-p P] [-c] [-t] [-gh GH]
Finding potential software vulnerabilities from git commit messages.
optional arguments:
-h, --help show this help message and exit
-v increase output verbosity
-r R git repository to analyse
-o O Output format: [json]
-s S State of the commit found
-p P Matching pattern to use: [vulnpatterns, cryptopatterns, cpatterns] - the pattern 'all' is used to match all the patterns at once.
-c output only a list of the CVE pattern found in commit messages (disable by default)
-t Include tags matching a specific commit
-gh GH special option for gharchive, pass a file containing a PushEvent in JSON format
More info: https://github.com/cve-search/git-vuln-finder
يأتي git-vuln-finder مع 3 أنماط افتراضية يمكن تحديدها للعثور على الثغرات الأمنية المحتملة الموصوفة في رسائل الالتزام، مثل:
vulnpatterns هو نمط ثغرات عام يستهدف بشكل خاص تطبيقات الويب ورسائل الالتزام الأمنية العامة. يعتمد على ورقة أكاديمية.cryptopatterns هو نمط ثغرات للأخطاء التشفيرية المذكورة في رسائل الالتزام.cpatterns هو مجموعة من أنماط الثغرات القياسية المستخدمة في اللغات الشبيهة بـ C/C++.