Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #316 from jjnicola/deprecated
Browse files Browse the repository at this point in the history
Remove py3.5 and py3.6 support and deprecated methods.
  • Loading branch information
bjoernricks committed Aug 17, 2020
2 parents 922de26 + 3b843ce commit d10835a
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 274 deletions.
28 changes: 0 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
version: 2.1

executors:
python-35:
docker:
- image: circleci/python:3.5
working_directory: ~/repo
python-36:
docker:
- image: circleci/python:3.6
working_directory: ~/repo
python-37:
docker:
- image: circleci/python:3.7
Expand Down Expand Up @@ -101,22 +93,6 @@ jobs:
executor: python-37
steps:
- lint
build-35:
executor: python-35
steps:
- build
test-35:
executor: python-35
steps:
- test
build-36:
executor: python-36
steps:
- build
test-36:
executor: python-36
steps:
- test
build-37:
executor: python-37
steps:
Expand All @@ -143,10 +119,6 @@ workflows:
build_and_test:
jobs:
- lint-python-files
- build-35
- test-35
- build-36
- test-36
- build-37
- test-37
- build-38
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [21.4] (unreleased)

### Removed
- Remove python3.5 support and deprecated methods. [#316](https://github.com/greenbone/ospd/pull/316)

## [20.8] (unreleased)

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ and the fingerprint is `8AE4 BE42 9B60 A59B 311C 2E73 9823 FAA6 0ED1 E580`.

### Requirements

ospd requires Python >= 3.5 along with the following libraries:
ospd requires Python >= 3.7 along with the following libraries:

- python3-paramiko

Expand Down
2 changes: 1 addition & 1 deletion doc/INSTALL-ospd-scanner.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ first with the mechanism of your system (for example via `apt` or `rpm`).
You may need to set the `PYTHONPATH` like this before running
the install command:

export PYTHONPATH=<prefix>/lib/python3.5/site-packages/
export PYTHONPATH=<prefix>/lib/python3.7/site-packages/

The actual value for `PYTHONPATH` depends on your Python version.

Expand Down
2 changes: 1 addition & 1 deletion ospd/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def init_logging(
*,
log_file: Optional[str] = None,
log_config: Optional[str] = None,
foreground: Optional[bool] = False
foreground: Optional[bool] = False,
):
config = configparser.ConfigParser()
config['handlers'] = DEFAULT_HANDLERS
Expand Down
62 changes: 2 additions & 60 deletions ospd/ospd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@

import psutil

from deprecated import deprecated

from ospd import __version__
from ospd.command import get_commands
from ospd.errors import OspdCommandError
from ospd.misc import ResultType, create_process
from ospd.network import resolve_hostname, target_str_to_list
from ospd.protocol import OspRequest, OspResponse, RequestParser
from ospd.protocol import RequestParser
from ospd.scan import ScanCollection, ScanStatus, ScanProgress
from ospd.server import BaseServer, Stream
from ospd.vtfilter import VtsFilter
Expand All @@ -59,7 +57,6 @@
elements_as_text,
get_result_xml,
get_progress_xml,
get_elements_from_dict,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -118,7 +115,7 @@ def __init__(
min_free_mem_scan_queue=0,
file_storage_dir='/var/run/ospd',
max_queued_scans=0,
**kwargs
**kwargs,
): # pylint: disable=unused-argument
""" Initializes the daemon's internal data. """
self.scan_collection = ScanCollection(file_storage_dir)
Expand Down Expand Up @@ -180,11 +177,6 @@ def set_command_attributes(self, name: str, attributes: Dict) -> None:
command = self.commands.get(name)
command.attributes = attributes

@deprecated(version="20.8", reason="Use set_scanner_param instead")
def add_scanner_param(self, name: str, scanner_params: Dict) -> None:
""" Set a scanner parameter. """
self.set_scanner_param(name, scanner_params)

def set_scanner_param(self, name: str, scanner_params: Dict) -> None:
""" Set a scanner parameter. """

Expand Down Expand Up @@ -336,30 +328,6 @@ def process_scan_params(self, params: Dict) -> Dict:
"""
return params

@staticmethod
@deprecated(
version="20.8",
reason="Please use OspRequest.process_vt_params instead.",
)
def process_vts_params(scanner_vts) -> Dict:
return OspRequest.process_vts_params(scanner_vts)

@staticmethod
@deprecated(
version="20.8",
reason="Please use OspRequest.process_credential_elements instead.",
)
def process_credentials_elements(cred_tree) -> Dict:
return OspRequest.process_credentials_elements(cred_tree)

@staticmethod
@deprecated(
version="20.8",
reason="Please use OspRequest.process_targets_elements instead.",
)
def process_targets_element(scanner_target) -> List:
return OspRequest.process_target_element(scanner_target)

def stop_scan(self, scan_id: str) -> None:
if (
scan_id in self.scan_collection.ids_iterator()
Expand Down Expand Up @@ -496,14 +464,6 @@ def get_scanner_param_default(self, param: str):
return None
return entry.get('default')

@deprecated(
version="20.8",
reason="Please use OspResponse.create_scanner_params_xml instead.",
)
def get_scanner_params_xml(self):
""" Returns the OSP Daemon's scanner params in xml format. """
return OspResponse.create_scanner_params_xml(self.scanner_params)

def handle_client_stream(self, stream: Stream) -> None:
""" Handles stream of data received from client. """
data = b''
Expand Down Expand Up @@ -717,11 +677,6 @@ def get_help_text(self) -> str:

return txt

@deprecated(version="20.8", reason="Use ospd.xml.elements_as_text instead.")
def elements_as_text(self, elems: Dict, indent: int = 2) -> str:
""" Returns the elems dictionary as formatted plain text. """
return elements_as_text(elems, indent)

def delete_scan(self, scan_id: str) -> int:
""" Deletes scan_id scan from collection.
Expand Down Expand Up @@ -785,19 +740,6 @@ def _get_scan_progress_xml(self, scan_id: str):

return get_progress_xml(current_progress)

@deprecated(
version="20.8",
reason="Please use ospd.xml.get_elements_from_dict instead.",
)
def get_xml_str(self, data: Dict) -> List:
""" Creates a string in XML Format using the provided data structure.
@param: Dictionary of xml tags and their elements.
@return: String of data in xml format.
"""
return get_elements_from_dict(data)

def get_scan_xml(
self,
scan_id: str,
Expand Down
7 changes: 1 addition & 6 deletions ospd/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,7 @@ def _load_config(self, configfile: str) -> Config:

configpath = Path(configfile)

try:
if not configpath.expanduser().resolve().exists():
logger.debug('Ignoring non existing config file %s', configfile)
return config
except FileNotFoundError:
# we are on python 3.5 and Path.resolve raised a FileNotFoundError
if not configpath.expanduser().resolve().exists():
logger.debug('Ignoring non existing config file %s', configfile)
return config

Expand Down
13 changes: 1 addition & 12 deletions ospd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,7 @@ def __init__(

validate_cacert_file(ca_file)

# Despite the name, ssl.PROTOCOL_SSLv23 selects the highest
# protocol version that both the client and server support. In modern
# Python versions (>= 3.4) it supports TLS >= 1.0 with SSLv2 and SSLv3
# being disabled. For Python > 3.5, PROTOCOL_SSLv23 is an alias for
# PROTOCOL_TLS which should be used once compatibility with Python 3.5
# is no longer desired.

if hasattr(ssl, 'PROTOCOL_TLS'):
protocol = ssl.PROTOCOL_TLS
else:
protocol = ssl.PROTOCOL_SSLv23

protocol = ssl.PROTOCOL_SSLv23
self.tls_context = ssl.SSLContext(protocol)
self.tls_context.verify_mode = ssl.CERT_REQUIRED

Expand Down
4 changes: 0 additions & 4 deletions ospd/vts.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ def __iter__(self) -> Iterator[str]:
if hasattr(self.vts, '__iter__'):
return self.vts.__iter__()

# Use iter because python3.5 has no support for
# iteration over DictProxy.
return iter(self.vts.keys())

def __getitem__(self, key):
return self.vts[key]

Expand Down
Loading

0 comments on commit d10835a

Please sign in to comment.