-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OSSFuzzImprover to IMPROVERS_REGISTRY Fix oss-fuzz test ( add weakness in expected test file ) Add oss-fuzz tests Import data from oss_fuzz using osv format Resolve merge conflicts Signed-off-by: ziadhany <ziadhany2016@gmail.com>
- Loading branch information
Showing
9 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# VulnerableCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
# See https://github.com/nexB/vulnerablecode for support or download. | ||
# See https://aboutcode.org for more information about nexB OSS projects. | ||
# | ||
import logging | ||
from pathlib import Path | ||
from typing import Iterable | ||
|
||
import saneyaml | ||
|
||
from vulnerabilities.importer import AdvisoryData | ||
from vulnerabilities.importer import Importer | ||
from vulnerabilities.importers.osv import parse_advisory_data | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class OSSFuzzImporter(Importer): | ||
license_url = "https://github.com/google/oss-fuzz-vulns/blob/main/LICENSE" | ||
spdx_license_expression = "CC-BY-4.0" | ||
url = "git+https://github.com/google/oss-fuzz-vulns" | ||
|
||
def advisory_data(self) -> Iterable[AdvisoryData]: | ||
try: | ||
self.clone(repo_url=self.url) | ||
path = Path(self.vcs_response.dest_dir) / "vulns" | ||
for file in path.glob("**/*.yaml"): | ||
with open(file) as f: | ||
yaml_data = saneyaml.load(f.read()) | ||
yield parse_advisory_data(yaml_data, supported_ecosystem="oss-fuzz") | ||
finally: | ||
if self.vcs_response: | ||
self.vcs_response.delete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
vulnerabilities/tests/test_data/oss_fuzz/oss-fuzz-data1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
id: OSV-2021-933 | ||
summary: Heap-buffer-overflow in print_mac | ||
details: | | ||
OSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35887 | ||
``` | ||
Crash type: Heap-buffer-overflow WRITE 4 | ||
Crash state: | ||
print_mac | ||
log_packet | ||
dhcp_reply | ||
``` | ||
modified: '2022-04-13T03:04:31.143462Z' | ||
published: '2021-07-08T00:01:26.369555Z' | ||
references: | ||
- type: REPORT | ||
url: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35887 | ||
affected: | ||
- package: | ||
name: dnsmasq | ||
ecosystem: OSS-Fuzz | ||
ranges: | ||
- type: GIT | ||
repo: git://thekelleys.org.uk/dnsmasq.git | ||
events: | ||
- introduced: 96f6444958c29a670f4254722d787f328153605c | ||
- fixed: d242cbffa4f20c9f7472f79b3a9e47008b6fe77c | ||
versions: | ||
- v2.86 | ||
- v2.86rc1 | ||
- v2.86rc2 | ||
- v2.86rc3 | ||
- v2.86test5 | ||
- v2.86test6 | ||
- v2.86test7 | ||
- v2.87test1 | ||
- v2.87test2 | ||
- v2.87test3 | ||
- v2.87test4 | ||
ecosystem_specific: | ||
severity: HIGH |
20 changes: 20 additions & 0 deletions
20
vulnerabilities/tests/test_data/oss_fuzz/oss-fuzz-data1.yaml-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"aliases": [ | ||
"OSV-2021-933" | ||
], | ||
"summary": "Heap-buffer-overflow in print_mac\nOSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35887\n\n```\nCrash type: Heap-buffer-overflow WRITE 4\nCrash state:\nprint_mac\nlog_packet\ndhcp_reply\n```", | ||
"affected_packages": [ | ||
|
||
], | ||
"references": [ | ||
{ | ||
"reference_id": "", | ||
"url": "https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35887", | ||
"severities": [ | ||
|
||
] | ||
} | ||
], | ||
"date_published": "2021-07-08T00:01:26.369555+00:00", | ||
"weaknesses": [] | ||
} |
33 changes: 33 additions & 0 deletions
33
vulnerabilities/tests/test_data/oss_fuzz/oss-fuzz-data2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
id: OSV-2022-145 | ||
summary: Heap-buffer-overflow in print_mac | ||
details: | | ||
OSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44581 | ||
``` | ||
Crash type: Heap-buffer-overflow WRITE 4 | ||
Crash state: | ||
print_mac | ||
log_packet | ||
dhcp_reply | ||
``` | ||
modified: '2022-04-13T03:04:31.179893Z' | ||
published: '2022-02-13T00:01:27.883603Z' | ||
references: | ||
- type: REPORT | ||
url: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44581 | ||
affected: | ||
- package: | ||
name: dnsmasq | ||
ecosystem: OSS-Fuzz | ||
purl: pkg:generic/dnsmasq | ||
ranges: | ||
- type: GIT | ||
repo: git://thekelleys.org.uk/dnsmasq.git | ||
events: | ||
- introduced: e426c2d3bc182d790f83039b77a09d55230ca71f | ||
- fixed: 03345ecefeb0d82e3c3a4c28f27c3554f0611b39 | ||
versions: | ||
- v2.87test8 | ||
ecosystem_specific: | ||
severity: HIGH | ||
schema_version: 1.2.0 |
20 changes: 20 additions & 0 deletions
20
vulnerabilities/tests/test_data/oss_fuzz/oss-fuzz-data2.yaml-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"aliases": [ | ||
"OSV-2022-145" | ||
], | ||
"summary": "Heap-buffer-overflow in print_mac\nOSS-Fuzz report: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44581\n\n```\nCrash type: Heap-buffer-overflow WRITE 4\nCrash state:\nprint_mac\nlog_packet\ndhcp_reply\n```", | ||
"affected_packages": [ | ||
|
||
], | ||
"references": [ | ||
{ | ||
"reference_id": "", | ||
"url": "https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44581", | ||
"severities": [ | ||
|
||
] | ||
} | ||
], | ||
"date_published": "2022-02-13T00:01:27.883603+00:00", | ||
"weaknesses": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# VulnerableCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
# See https://github.com/nexB/vulnerablecode for support or download. | ||
# See https://aboutcode.org for more information about nexB OSS projects. | ||
# | ||
import os | ||
from unittest import TestCase | ||
|
||
import saneyaml | ||
|
||
from vulnerabilities.importers.osv import parse_advisory_data | ||
from vulnerabilities.tests import util_tests | ||
|
||
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
TEST_DATA = os.path.join(BASE_DIR, "test_data/oss_fuzz") | ||
|
||
|
||
class TestOSSFuzzImporter(TestCase): | ||
def test_to_advisories1(self): | ||
with open(os.path.join(TEST_DATA, "oss-fuzz-data1.yaml")) as f: | ||
mock_response = saneyaml.load(f) | ||
expected_file = os.path.join(TEST_DATA, "oss-fuzz-data1.yaml-expected.json") | ||
imported_data = parse_advisory_data(mock_response, "oss-fuzz") | ||
result = imported_data.to_dict() | ||
util_tests.check_results_against_json(result, expected_file) | ||
|
||
def test_to_advisorie2(self): | ||
with open(os.path.join(TEST_DATA, "oss-fuzz-data2.yaml")) as f: | ||
mock_response = saneyaml.load(f) | ||
expected_file = os.path.join(TEST_DATA, "oss-fuzz-data2.yaml-expected.json") | ||
imported_data = parse_advisory_data(mock_response, "oss-fuzz") | ||
result = imported_data.to_dict() | ||
util_tests.check_results_against_json(result, expected_file) |