Skip to content

Commit

Permalink
Sort imports
Browse files Browse the repository at this point in the history
Sorts all the imports in order to reduce unnecessary merge conflicts.

Signed-off-by: Hritik Vijay <[email protected]>
  • Loading branch information
Hritik14 committed Jun 10, 2021
1 parent 2f0f33a commit d0eccde
Show file tree
Hide file tree
Showing 76 changed files with 257 additions and 434 deletions.
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from setuptools import find_packages
from setuptools import setup

from setuptools import find_packages, setup

requirements = [
r.strip() for r in open("requirements.txt") if r.strip() and not r.strip().startswith("#")
Expand Down
2 changes: 1 addition & 1 deletion vulnerabilities/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
from django.contrib import admin

from vulnerabilities.models import (
PackageRelatedVulnerability,
Importer,
Package,
PackageRelatedVulnerability,
Vulnerability,
VulnerabilityReference,
VulnerabilitySeverity,
Expand Down
12 changes: 7 additions & 5 deletions vulnerabilities/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
from django_filters import rest_framework as filters
from drf_spectacular.utils import extend_schema, inline_serializer
from packageurl import PackageURL

from rest_framework import serializers, viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from vulnerabilities.models import Package
from vulnerabilities.models import Vulnerability
from vulnerabilities.models import VulnerabilityReference
from vulnerabilities.models import VulnerabilitySeverity

from vulnerabilities.models import (
Package,
Vulnerability,
VulnerabilityReference,
VulnerabilitySeverity,
)

# This serializer is used for the bulk apis, to prevent wrong auto documentation
# TODO: Fix the swagger documentation for bulk apis
Expand Down
18 changes: 5 additions & 13 deletions vulnerabilities/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,19 @@
import tempfile
import traceback
import xml.etree.ElementTree as ET
from binaryornot.helpers import is_binary_string
from datetime import datetime
from pathlib import Path
from typing import Any
from typing import ContextManager
from typing import Iterable
from typing import List
from typing import Mapping
from typing import Optional
from typing import Set
from typing import Tuple
from git import Repo, DiffIndex
from typing import Any, ContextManager, Iterable, List, Mapping, Optional, Set, Tuple

from binaryornot.helpers import is_binary_string
from git import DiffIndex, Repo
from packageurl import PackageURL
from univers.version_specifier import VersionSpecifier
from univers.versions import version_class_by_package_type

from vulnerabilities.helpers import AffectedPackage, is_cve, nearest_patched_package
from vulnerabilities.oval_parser import OvalParser
from vulnerabilities.severity_systems import ScoringSystem
from vulnerabilities.helpers import is_cve
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.helpers import AffectedPackage

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions vulnerabilities/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import dataclasses
import json
import re
from typing import Optional
from typing import List
from typing import List, Optional

import requests
import saneyaml
Expand Down
8 changes: 3 additions & 5 deletions vulnerabilities/import_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
import dataclasses
import datetime
import logging
import traceback
from collections import Counter
from itertools import chain
import traceback
from typing import Set
from typing import Tuple
from typing import Set, Tuple

from django.core import serializers

from vulnerabilities import models
from vulnerabilities.data_source import Advisory, DataSource
from vulnerabilities.data_source import PackageURL
from vulnerabilities.data_source import Advisory, DataSource, PackageURL

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion vulnerabilities/importers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from vulnerabilities.importers.elixir_security import ElixirSecurityDataSource
from vulnerabilities.importers.gentoo import GentooDataSource
from vulnerabilities.importers.github import GitHubAPIDataSource
from vulnerabilities.importers.istio import IstioDataSource
from vulnerabilities.importers.kaybee import KaybeeDataSource
from vulnerabilities.importers.nginx import NginxDataSource
from vulnerabilities.importers.npm import NpmDataSource
Expand All @@ -46,6 +47,5 @@
from vulnerabilities.importers.suse_scores import SUSESeverityScoreDataSource
from vulnerabilities.importers.ubuntu import UbuntuDataSource
from vulnerabilities.importers.ubuntu_usn import UbuntuUSNDataSource
from vulnerabilities.importers.istio import IstioDataSource

# from vulnerabilities.importers.suse_backports import SUSEBackportsDataSource
14 changes: 3 additions & 11 deletions vulnerabilities/importers/alpine_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,15 @@
# VulnerableCode is a free software code scanning tool from nexB Inc. and others.
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
from re import IGNORECASE
from typing import Any
from typing import Iterable
from typing import List
from typing import Mapping
from typing import Set
from typing import Any, Iterable, List, Mapping, Set

import requests
import saneyaml
from bs4 import BeautifulSoup
from packageurl import PackageURL
from schema import Or
from schema import Regex
from schema import Schema
from schema import Or, Regex, Schema

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import Reference
from vulnerabilities.data_source import Advisory, DataSource, Reference
from vulnerabilities.helpers import is_cve

BASE_URL = "https://secdb.alpinelinux.org/"
Expand Down
17 changes: 9 additions & 8 deletions vulnerabilities/importers/apache_httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@
import requests
from bs4 import BeautifulSoup
from packageurl import PackageURL
from univers.versions import MavenVersion
from univers.version_specifier import VersionSpecifier
from univers.versions import MavenVersion

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import DataSourceConfiguration
from vulnerabilities.data_source import Reference
from vulnerabilities.data_source import VulnerabilitySeverity
from vulnerabilities.data_source import (
Advisory,
DataSource,
DataSourceConfiguration,
Reference,
VulnerabilitySeverity,
)
from vulnerabilities.helpers import create_etag, nearest_patched_package
from vulnerabilities.package_managers import GitHubTagsAPI
from vulnerabilities.severity_systems import scoring_systems
from vulnerabilities.helpers import create_etag
from vulnerabilities.helpers import nearest_patched_package


@dataclasses.dataclass
Expand Down
8 changes: 3 additions & 5 deletions vulnerabilities/importers/apache_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
import requests
from bs4 import BeautifulSoup
from packageurl import PackageURL
from univers.versions import MavenVersion
from univers.version_specifier import VersionSpecifier
from univers.versions import MavenVersion

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import Reference
from vulnerabilities.package_managers import GitHubTagsAPI
from vulnerabilities.data_source import Advisory, DataSource, Reference
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.package_managers import GitHubTagsAPI

GH_PAGE_URL = "https://raw.githubusercontent.com/apache/kafka-site/asf-site/cve-list.html"
ASF_PAGE_URL = "https://kafka.apache.org/cve-list"
Expand Down
11 changes: 3 additions & 8 deletions vulnerabilities/importers/apache_tomcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@
import dataclasses
import re


import requests
from bs4 import BeautifulSoup
from packageurl import PackageURL
from univers.version_specifier import VersionSpecifier
from univers.versions import MavenVersion
from packageurl import PackageURL

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import DataSourceConfiguration
from vulnerabilities.data_source import Reference
from vulnerabilities.helpers import create_etag
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.data_source import Advisory, DataSource, DataSourceConfiguration, Reference
from vulnerabilities.helpers import create_etag, nearest_patched_package
from vulnerabilities.package_managers import MavenVersionAPI


Expand Down
21 changes: 10 additions & 11 deletions vulnerabilities/importers/archlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
import dataclasses
import json
from typing import Iterable
from typing import List
from typing import Mapping
from typing import Set
from typing import Iterable, List, Mapping, Set
from urllib.request import urlopen

from packageurl import PackageURL
from schema import Regex, Schema, Or

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import DataSourceConfiguration
from vulnerabilities.data_source import Reference
from vulnerabilities.data_source import VulnerabilitySeverity
from schema import Or, Regex, Schema

from vulnerabilities.data_source import (
Advisory,
DataSource,
DataSourceConfiguration,
Reference,
VulnerabilitySeverity,
)
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.severity_systems import scoring_systems

Expand Down
19 changes: 5 additions & 14 deletions vulnerabilities/importers/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,14 @@

import dataclasses
import json
from dateutil import parser as dateparser
from typing import Any
from typing import List
from typing import Mapping
from typing import Set
from typing import Any, List, Mapping, Set

import requests
from dateutil import parser as dateparser
from packageurl import PackageURL
from schema import Optional
from schema import Or
from schema import Regex
from schema import Schema

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import DataSourceConfiguration
from vulnerabilities.data_source import Reference
from schema import Optional, Or, Regex, Schema

from vulnerabilities.data_source import Advisory, DataSource, DataSourceConfiguration, Reference
from vulnerabilities.helpers import nearest_patched_package


Expand Down
11 changes: 4 additions & 7 deletions vulnerabilities/importers/debian_oval.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@

import asyncio
import dataclasses
from typing import Iterable
from typing import List
from typing import Mapping
from typing import Set
import xml.etree.ElementTree as ET
from typing import Iterable, List, Mapping, Set

import requests
from aiohttp import ClientSession
from aiohttp.client_exceptions import ClientResponseError, ServerDisconnectedError
import requests

from vulnerabilities.data_source import OvalDataSource, DataSourceConfiguration
from vulnerabilities.package_managers import DebianVersionAPI
from vulnerabilities.data_source import DataSourceConfiguration, OvalDataSource
from vulnerabilities.helpers import create_etag
from vulnerabilities.package_managers import DebianVersionAPI


@dataclasses.dataclass
Expand Down
7 changes: 2 additions & 5 deletions vulnerabilities/importers/elixir_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
from univers.version_specifier import VersionSpecifier
from univers.versions import SemverVersion

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import GitDataSource
from vulnerabilities.data_source import Reference
from vulnerabilities.helpers import load_yaml
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.data_source import Advisory, GitDataSource, Reference
from vulnerabilities.helpers import load_yaml, nearest_patched_package
from vulnerabilities.package_managers import HexVersionAPI


Expand Down
4 changes: 1 addition & 3 deletions vulnerabilities/importers/gentoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

from packageurl import PackageURL

from vulnerabilities.data_source import GitDataSource
from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import Reference
from vulnerabilities.data_source import Advisory, GitDataSource, Reference
from vulnerabilities.helpers import nearest_patched_package


Expand Down
34 changes: 17 additions & 17 deletions vulnerabilities/importers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@
# Visit https://github.com/nexB/vulnerablecode/ for support and download.

import asyncio
import os
import dataclasses
import json
from typing import Set
from typing import Tuple
from typing import List
from typing import Mapping
from typing import Optional
import os
from typing import List, Mapping, Optional, Set, Tuple

import requests
from packageurl import PackageURL
from univers.version_specifier import VersionSpecifier
from univers.versions import version_class_by_package_type

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import DataSource
from vulnerabilities.data_source import DataSourceConfiguration
from vulnerabilities.data_source import Reference
from vulnerabilities.data_source import VulnerabilitySeverity
from vulnerabilities.package_managers import MavenVersionAPI
from vulnerabilities.package_managers import NugetVersionAPI
from vulnerabilities.package_managers import ComposerVersionAPI
from vulnerabilities.package_managers import PypiVersionAPI
from vulnerabilities.package_managers import RubyVersionAPI
from vulnerabilities.severity_systems import scoring_systems
from vulnerabilities.data_source import (
Advisory,
DataSource,
DataSourceConfiguration,
Reference,
VulnerabilitySeverity,
)
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.package_managers import (
ComposerVersionAPI,
MavenVersionAPI,
NugetVersionAPI,
PypiVersionAPI,
RubyVersionAPI,
)
from vulnerabilities.severity_systems import scoring_systems

# set of all possible values of first '%s' = {'MAVEN','COMPOSER', 'NUGET', 'RUBYGEMS', 'PYPI'}
# second '%s' is interesting, it will have the value '' for the first request,
Expand Down
7 changes: 2 additions & 5 deletions vulnerabilities/importers/istio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
# Visit https://github.com/nexB/vulnerablecode/ for support and download.
import asyncio
import re
from typing import List
from typing import Set
from typing import List, Set

import saneyaml
from packageurl import PackageURL
from univers.version_specifier import VersionSpecifier
from univers.versions import SemverVersion

from vulnerabilities.data_source import Advisory
from vulnerabilities.data_source import GitDataSource
from vulnerabilities.data_source import Reference
from vulnerabilities.data_source import Advisory, GitDataSource, Reference
from vulnerabilities.helpers import nearest_patched_package
from vulnerabilities.package_managers import GitHubTagsAPI

Expand Down
Loading

0 comments on commit d0eccde

Please sign in to comment.