Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion vulnerabilities/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class Meta:


class VulnerabilitySerializer(serializers.HyperlinkedModelSerializer):

fixed_packages = MinimalPackageSerializer(
many=True, source="filtered_fixed_packages", read_only=True
)
Expand Down
2 changes: 0 additions & 2 deletions vulnerabilities/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class PackageSearchForm(forms.Form):

search = forms.CharField(
required=True,
widget=forms.TextInput(
Expand All @@ -24,7 +23,6 @@ class PackageSearchForm(forms.Form):


class VulnerabilitySearchForm(forms.Form):

search = forms.CharField(
required=True,
widget=forms.TextInput(
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def from_dict(cls, severity: dict):

@dataclasses.dataclass(order=True)
class Reference:

reference_id: str = ""
url: str = ""
severities: List[VulnerabilitySeverity] = dataclasses.field(default_factory=list)
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/alpine_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def load_advisories(
vuln_ids = vuln_ids[1:]
references = []
for reference_id in vuln_ids:

if reference_id.startswith("XSA"):
references.append(XsaReference.from_id(xsa_id=reference_id))

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/apache_httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@


class ApacheHTTPDImporter(Importer):

base_url = "https://httpd.apache.org/security/json/"
spdx_license_expression = "Apache-2.0"
license_url = "https://www.apache.org/licenses/LICENSE-2.0"
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/apache_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@


class ApacheKafkaImporter(Importer):

GH_PAGE_URL = "https://raw.githubusercontent.com/apache/kafka-site/asf-site/cve-list.html"
ASF_PAGE_URL = "https://kafka.apache.org/cve-list"
spdx_license_expression = "Apache-2.0"
Expand Down
3 changes: 0 additions & 3 deletions vulnerabilities/importers/apache_tomcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@


class ApacheTomcatImporter(Importer):

spdx_license_expression = "Apache-2.0"
license_url = "https://www.apache.org/licenses/LICENSE-2.0"

Expand Down Expand Up @@ -404,7 +403,6 @@ def to_version_ranges_apache(versions_data, fixed_versions):
)

for fixed_item in fixed_versions:

if "-" in fixed_item and not any([i.isalpha() for i in fixed_item]):
fixed_item_split = fixed_item.split(" ")
fixed_constraint_tuple_list.append(VersionConstraintTuple(">=", fixed_item_split[0]))
Expand Down Expand Up @@ -495,7 +493,6 @@ def to_version_ranges_maven(versions_data, fixed_versions):
)

for fixed_item in fixed_versions:

if "-" in fixed_item and not any([i.isalpha() for i in fixed_item]):
fixed_item_split = fixed_item.split(" ")

Expand Down
6 changes: 4 additions & 2 deletions vulnerabilities/importers/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@


class DebianImporter(Importer):

spdx_license_expression = "LicenseRef-scancode-other-permissive"
license_url = "https://www.debian.org/license"
notice = """
Expand Down Expand Up @@ -226,7 +225,10 @@ def get_inferences(self, advisory_data: AdvisoryData) -> Iterable[Inference]:
vulnerable_packages=affected_purls, resolved_packages=fixed_purls
)

for (fixed_package, affected_packages,) in get_affected_packages_by_patched_package(
for (
fixed_package,
affected_packages,
) in get_affected_packages_by_patched_package(
affected_packages=affected_packages
).items():
yield Inference.from_advisory_data(
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/debian_oval.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class DebianOvalImporter(OvalImporter):

spdx_license_expression = "LicenseRef-scancode-other-permissive"
license_url = "https://www.debian.org/license"
notice = """
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/elixir_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class ElixirSecurityImporter(Importer):

repo_url = "git+https://github.com/dependabot/elixir-security-advisories"
license_url = "https://github.com/dependabot/elixir-security-advisories/blob/master/LICENSE.txt"
spdx_license_expression = "CC0-1.0"
Expand Down
2 changes: 0 additions & 2 deletions vulnerabilities/importers/istio.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def advisory_data(self) -> Set[AdvisoryData]:
yield from self.process_file(file)

def process_file(self, path):

data = self.get_data_from_md(path)
published_date = data.get("publishdate")
release_date = None
Expand Down Expand Up @@ -108,7 +107,6 @@ def process_file(self, path):
)

for cve_id in data.get("cves") or []:

if not cve_id.startswith("CVE"):
continue

Expand Down
2 changes: 0 additions & 2 deletions vulnerabilities/importers/nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@


class NginxImporter(Importer):

url = "https://nginx.org/en/security_advisories.html"

spdx_license_expression = "BSD-2-Clause"
Expand Down Expand Up @@ -168,7 +167,6 @@ def parse_advisory_data_from_paragraph(vuln_info):
):
aliases.append(text)
if text.startswith("CVE-"):

# always keep the CVE as a reference too
link = f"https://nvd.nist.gov/vuln/detail/{text}"
reference = Reference(reference_id=text, url=link)
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/osv.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def get_fixed_versions(fixed_range, raw_id) -> List[Version]:
fixed_range_type = fixed_range["type"]

for version in extract_fixed_versions(fixed_range):

# FIXME: ECOSYSTEM does not imply PyPI!!!!
if fixed_range_type == "ECOSYSTEM":
try:
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class PostgreSQLImporter(Importer):

root_url = "https://www.postgresql.org/support/security/"
license_url = "https://www.postgresql.org/about/licence/"
spdx_license_expression = "PostgreSQL"
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/project_kb_msr2019.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class ProjectKBMSRImporter(Importer):

url = "https://raw.githubusercontent.com/SAP/project-kb/master/MSR2019/dataset/vulas_db_msr2019_release.csv"
spdx_license_expression = "Apache-2.0"
license_url = "https://github.com/SAP/project-kb/blob/main/LICENSE.txt"
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def get_data_from_url(url):


class RedhatImporter(Importer):

spdx_license_expression = "CC-BY-4.0"
license_url = "https://access.redhat.com/documentation/en-us/red_hat_security_data_api/1.0/html/red_hat_security_data_api/legal-notice"

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/ruby.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def process_file(self, path) -> List[AdvisoryData]:

@staticmethod
def categorize_versions(all_versions, unaffected_version_ranges):

for id, elem in enumerate(unaffected_version_ranges):
unaffected_version_ranges[id] = VersionRange.from_scheme_version_spec_string(
"semver", elem
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/suse_backports.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def updated_advisories(self):
return self.batch_advisories(advisories)

def _fetch_yaml(self, url):

try:
resp = requests.get(url)
resp.raise_for_status()
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/suse_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class SUSESeverityScoreImporter(Importer):

spdx_license_expression = "CC-BY-4.0"
license_url = "https://ftp.suse.com/pub/projects/security/yaml/LICENSE"

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/importers/xen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class XenImporter(Importer):

url = "https://xenbits.xen.org/xsa/xsa.json"
spdx_license_expression = "LicenseRef-scancode-other-permissive"
notice = """
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/improve_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def process_inferences(inferences: List[Inference], advisory: Advisory, improver
continue

for ref in inference.references:

reference = VulnerabilityReference.objects.get_or_none(
reference_id=ref.reference_id,
url=ref.url,
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/lib_oval.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def writeToFile(self, filename):
return False

def to_string(self):

if not self.tree:
return None

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/management/commands/create_api_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def add_arguments(self, parser):
)

def handle(self, *args, **options):

email = options["email"]
try:
validate_email(email)
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/management/commands/purl2cpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class Command(BaseCommand):
help = "Dump a mapping of CPEs to PURLs grouped by vulnerability."

def add_arguments(self, parser):

parser.add_argument(
"--limit",
default=0,
Expand Down
3 changes: 0 additions & 3 deletions vulnerabilities/oval_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

class OvalParser:
def __init__(self, translations: Dict, oval_document: ET.ElementTree):

self.translations = translations
self.oval_document = OvalDocument(oval_document)
self.all_definitions = self.oval_document.getDefinitions()
Expand All @@ -37,7 +36,6 @@ def get_data(self) -> List[Dict]:
"""
oval_data = []
for definition in self.all_definitions:

matching_tests = self.get_tests_of_definition(definition)
if not matching_tests:
continue
Expand Down Expand Up @@ -72,7 +70,6 @@ def get_tests_of_definition(self, definition: OvalDefinition) -> List[OvalTest]:
criteria_refs = []

for child in definition.element.iter():

if "test_ref" in child.attrib:
criteria_refs.append(child.get("test_ref"))

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ def fetch_version_info(version_info: str, escaped_pkg: str) -> Optional[PackageV
return PackageVersion(value=value, release_date=release_date)

def fetch(self, pkg: str) -> Iterable[PackageVersion]:

# escape uppercase in module path
escaped_pkg = self.escape_path(pkg)
trimmed_pkg = pkg
Expand Down
1 change: 1 addition & 0 deletions vulnerabilities/rpm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# This code has been vendored from scancode.


# https://github.com/nexB/scancode-toolkit/blob/16ae20a343c5332114edac34c7b6fcf2fb6bca74/src/packagedcode/rpm.py#L91
class EVR(namedtuple("EVR", "epoch version release")):
"""
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/tests/example_importer_improver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@


class ExampleImporter(Importer):

spdx_license_expression = "BSD-2-Clause"

def advisory_data(self) -> Iterable[AdvisoryData]:
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def setUp(self):
self.client.credentials(HTTP_AUTHORIZATION=self.auth)

def test_query_qualifier_filtering(self):

# packages to check filtering with single/multiple and unordered qualifier filtering
pk_multi_qf = Package.objects.create(
name="vlc", version="1.50-1.1", type="deb", qualifiers={"foo": "bar", "tar": "ball"}
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/tests/test_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def test_create_purl():


def test__collect_pkgs():

xmls = load_oval_data()

expected_suse_pkgs = {"cacti-spine", "apache2-mod_perl", "cacti", "apache2-mod_perl-devel"}
Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def mock_fetch_additional_aliases(alias):
mock_fetch_additional_aliases,
)
class TestExampleImporter(testcase.FileBasedTesting):

test_data_dir = str(Path(__file__).resolve().parent / "test_data" / "example")

def test_parse_advisory_data(self):
Expand Down
2 changes: 0 additions & 2 deletions vulnerabilities/tests/test_nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def test_advisory_data_from_text(self):

@pytest.mark.django_db(transaction=True)
def test_NginxImporter(self):

expected_file = self.get_test_loc(
"security_advisories-importer-expected.json", must_exist=False
)
Expand Down Expand Up @@ -221,7 +220,6 @@ def test_NginxBasicImprover_fetch_nginx_version_from_git_tags(self, mock_fetcher

@pytest.mark.django_db(transaction=True)
def test_NginxBasicImprover__get_inferences_from_versions_end_to_end(self):

with open(self.get_test_loc("improver/improver-advisories.json")) as vf:
advisories_data = json.load(vf)

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/tests/test_nvd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_to_advisories_skips_hardware(regen=REGEN):

# TODO: use a JSON fixtures instead
def get_test_cve_item():

return {
"cve": {
"data_type": "CVE",
Expand Down
2 changes: 0 additions & 2 deletions vulnerabilities/tests/test_openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def test_to_advisory_data(self):

@pytest.mark.django_db(transaction=True)
def test_OpensslImporter(self):

expected_file = self.get_test_loc(
"security_advisories-importer-expected.json", must_exist=False
)
Expand Down Expand Up @@ -153,7 +152,6 @@ def fetch(self):

@pytest.mark.django_db(transaction=True)
def test_DefaultImprover_inferences_on_Openssl(self):

with open(self.get_test_loc("improver/improver-advisories.json")) as vf:
advisories_data = json.load(vf)

Expand Down
3 changes: 0 additions & 3 deletions vulnerabilities/tests/test_package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def test_pypi_fetch_with_no_release(mock_response):

@mock.patch("vulnerabilities.package_managers.get_response")
def test_ruby_fetch_with_no_release(mock_response):

with open(os.path.join(TEST_DATA, "gem.json")) as f:
mock_response.return_value = json.load(f)

Expand All @@ -122,7 +121,6 @@ def test_ruby_fetch_with_no_release(mock_response):


class TestComposerVersionAPI:

expected_versions = [
PackageVersion(value=("10.0.0",), release_date=dt_local(2019, 7, 23, 7, 6, 3)),
PackageVersion(value=("10.1.0",), release_date=dt_local(2019, 10, 1, 8, 18, 18)),
Expand Down Expand Up @@ -257,7 +255,6 @@ def test_fetch(self, mock_response):

class TestGoproxyVersionAPI:
def test_trim_go_url_path(self):

url1 = "https://pkg.go.dev/github.com/containous/traefik/v2"
assert GoproxyVersionAPI.trim_go_url_path(url1) == "github.com/containous/traefik"

Expand Down
1 change: 0 additions & 1 deletion vulnerabilities/tests/test_ruby.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def test_process_file(self, mock_write):
assert sorted(found_advisories) == sorted(expected_advisories)

def test_categorize_versions(self):

all_versions = ["1.0.0", "1.2.0", "9.0.2", "0.2.3"]
safe_ver_ranges = ["==1.0.0", ">1.2.0"]

Expand Down
Loading