Skip to content

Commit 555ff10

Browse files
this is release 2.30 many new typing improvements. deprecate python 3.6.
1 parent 0e52f5b commit 555ff10

File tree

161 files changed

+643
-923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+643
-923
lines changed

.github/workflows/tox.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
11+
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
1212
steps:
1313
- uses: actions/checkout@v1
1414
- name: Set up Python ${{ matrix.python-version }}

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
rev: v2.10.0
55
hooks:
66
- id: pyupgrade
7-
args: ["--py36-plus"]
7+
args: ["--py37-plus"]
88

99
- repo: https://github.com/psf/black
1010
rev: 20.8b1

CHANGELOG.rst

+24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
Release Notes
22
#############
33

4+
Release 2.3.0
5+
*************
6+
7+
* Deprecate Python 3.6
8+
* Support Python 3.10
9+
* Dependency updates
10+
* MISP Output plugin extension
11+
* add new public keys ECDSAKeys and ed25519 (#1627)
12+
* fix userdb.example (#1619)
13+
* cache url submission to virustotal
14+
* MySQL connector (#1575) - needs new external dependency mysql-connector-python
15+
* Fix mysql string expansion (#1565)
16+
* Rewrite CSIRTG output plugin to use new library version
17+
* Fixed the Slack output to work with the versions 2.x of slackclient
18+
* fix MySQL error handling
19+
* fix tar command
20+
* limit connections to private address ranges
21+
* Update GreyNoise Output Script to Use Community API (#1524)
22+
* Implement getopt-style parsing for uname (#1516)
23+
* Allow SSLv3 connections for wget and curl
24+
* Support for 301 redirects in wget
25+
* Malshare update API (#1472)
26+
* Remove hpfeeds.py infavour of hpfeeds3.py
27+
428
Release 2.2.0
529
*************
630

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Requirements
7373

7474
Software required:
7575

76-
* Python 3.6+
76+
* Python 3.7+
7777
* python-virtualenv
7878

7979
For Python dependencies, see `requirements.txt <https://github.com/cowrie/cowrie/blob/master/requirements.txt>`_.

mypy.ini

-49
This file was deleted.

pyproject.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[tool.mypy]
2+
3+
namespace_packages = true
4+
plugins = [ "mypy_zope:plugin" ]
5+
6+
ignore_missing_imports = true
7+
warn_unused_configs = true
8+
no_implicit_optional = true
9+
show_column_numbers = true
10+
show_error_codes = true
11+
strict_optional = true
12+
warn_no_return = true
13+
warn_redundant_casts = true
14+
warn_return_any = true
15+
warn_unreachable = true
16+
disallow_incomplete_defs = true
17+
disallow_any_unimported = true
18+
strict_equality = true
19+
disallow_untyped_decorators = true
20+
disallow_subclassing_any = true
21+
22+
# These are too strict for us at the moment
23+
24+
check_untyped_defs = false
25+
disallow_untyped_defs = false
26+
disallow_any_decorated = false
27+
disallow_any_explicit = false
28+
disallow_any_expr = false
29+
disallow_any_generics = false
30+
disallow_untyped_calls = false
31+
warn_unused_ignores = false

requirements-dev.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
Sphinx==4.2.0
2-
flake8==3.9.2
3-
importlib_metadata==4.8.1; python_version<'3.8'
2+
flake8==4.0.1
3+
importlib_metadata<4; python_version<'3.8'
44
mypy-extensions==0.4.3; platform_python_implementation=='CPython'
55
mypy-zope==0.3.2; platform_python_implementation=='CPython'
66
mypy==0.910; platform_python_implementation=='CPython'
77
pathspec==0.9.0
8-
pipdeptree==2.1.0
8+
pipdeptree==2.2.0
99
pre-commit==2.15.0
1010
pur==5.4.2
1111
pyre-check==0.9.6
12-
pytype==2021.10.4; platform_python_implementation=='CPython' and python_version<'3.10'
12+
pytype==2021.10.11; platform_python_implementation=='CPython' and python_version<'3.10'
1313
pyupgrade==2.29.0
14-
pyyaml==5.4.1
14+
pyyaml==6.0
1515
setuptools==58.2.0
1616
sphinx-copybutton==0.4.0
1717
sphinx_rtd_theme==1.0.0
1818
tox==3.24.4
1919
twistedchecker==0.7.4
20-
types-python-dateutil==2.8.0
21-
types-redis==3.5.11
22-
types-requests==2.25.9
20+
types-python-dateutil==2.8.2
21+
types-redis==3.5.15
22+
types-requests==2.25.11
2323
yamllint==1.26.3

requirements-output.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ geoip2
66
requests==2.26.0
77

88
# elasticsearch
9-
elasticsearch==7.15.0
9+
elasticsearch==7.15.1
1010

1111
# hpfeeds
1212
hpfeeds3==0.9.10
@@ -21,18 +21,14 @@ pymongo==3.12.0
2121
rethinkdb==2.4.8
2222

2323
# s3
24-
botocore==1.21.58
24+
botocore==1.21.63
2525

2626
# slack
2727
slackclient==2.9.3
2828

2929
# influxdb
3030
influxdb==5.3.1
3131

32-
# kafka
33-
afkak==21.5.0.post0
34-
python-snappy==0.6.0
35-
3632
# dblog_xmpp
3733
wokkel==18.0.0
3834

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package_dir={"": "src"},
2020
package_data={"": ["*.md"]},
2121
use_incremental=True,
22-
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
22+
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, <4",
2323
scripts=["bin/fsctl", "bin/asciinema", "bin/cowrie", "bin/createfs", "bin/playlog"],
2424
classifiers=[
2525
"Development Status :: 5 - Production/Stable",

src/backend_pool/libvirt/backend_service.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2019 Guilherme Borges <[email protected]>
22
# See the COPYRIGHT file for more information
33

4+
from __future__ import annotations
5+
46
import os
57
import random
68
import sys

src/backend_pool/libvirt/guest_handler.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2019 Guilherme Borges <[email protected]>
22
# See the COPYRIGHT file for more information
3+
from __future__ import annotations
34
import os
45
from configparser import NoOptionError
56

src/backend_pool/libvirt/network_handler.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2019 Guilherme Borges <[email protected]>
22
# See the COPYRIGHT file for more information
3+
from __future__ import annotations
34
import os
45

56
from twisted.python import log

src/backend_pool/libvirt/snapshot_handler.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2019 Guilherme Borges <[email protected]>
22
# See the COPYRIGHT file for more information
33

4+
from __future__ import annotations
5+
46
import getpass
57
import shutil
68
import subprocess
@@ -16,7 +18,6 @@ def create_disk_snapshot(source_img, destination_img):
1618
# could use `capture_output=True` instead of `stdout` and `stderr` args in Python 3.7
1719
out = subprocess.run(
1820
["qemu-img", "create", "-f", "qcow2", "-b", source_img, destination_img],
19-
stdout=subprocess.PIPE,
20-
stderr=subprocess.PIPE,
21+
capture_output=True,
2122
)
2223
return out.returncode == 0

src/backend_pool/nat.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import annotations
12
from threading import Lock
23

3-
from twisted.internet import protocol, reactor
4+
from twisted.internet import protocol
5+
from twisted.internet import reactor # type: ignore
46

57

68
class ClientProtocol(protocol.Protocol):

src/backend_pool/pool_server.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2019 Guilherme Borges <[email protected]>
22
# See the COPYRIGHT file for more information
33

4+
from __future__ import annotations
5+
46
import struct
57

68
from twisted.internet.protocol import Factory, Protocol
@@ -12,8 +14,8 @@
1214

1315

1416
class PoolServer(Protocol):
15-
def __init__(self, factory):
16-
self.factory = factory
17+
def __init__(self, factory: PoolServerFactory) -> None:
18+
self.factory: PoolServerFactory = factory
1719
self.local_pool: bool = (
1820
CowrieConfig.get("proxy", "pool", fallback="local") == "local"
1921
)
@@ -25,13 +27,13 @@ def __init__(self, factory):
2527
)
2628

2729
if self.use_nat:
28-
self.nat_public_ip = CowrieConfig.get("backend_pool", "nat_public_ip")
30+
self.nat_public_ip: str = CowrieConfig.get("backend_pool", "nat_public_ip")
2931

30-
def dataReceived(self, data):
31-
res_op = struct.unpack("!c", bytes([data[0]]))[
32+
def dataReceived(self, data: bytes) -> None:
33+
res_op: bytes = struct.unpack("!c", bytes([data[0]]))[
3234
0
3335
] # yes, this needs to be done to extract the op code correctly
34-
response = None
36+
response: bytes = b""
3537

3638
if res_op == b"i":
3739
recv = struct.unpack("!II?", data[1:])
@@ -76,10 +78,10 @@ def dataReceived(self, data):
7678
guest_id=guest_id,
7779
)
7880

79-
ssh_port = CowrieConfig.getint(
81+
ssh_port: int = CowrieConfig.getint(
8082
"backend_pool", "guest_ssh_port", fallback=22
8183
)
82-
telnet_port = CowrieConfig.getint(
84+
telnet_port: int = CowrieConfig.getint(
8385
"backend_pool", "guest_telnet_port", fallback=23
8486
)
8587

@@ -162,31 +164,32 @@ def dataReceived(self, data):
162164
# free this connection and allow VM to be re-used
163165
self.factory.pool_service.reuse_vm(guest_id)
164166

165-
if response:
167+
if response and self.transport:
166168
self.transport.write(response)
167169

168170

169171
class PoolServerFactory(Factory):
170-
def __init__(self):
171-
self.initialised = False
172+
def __init__(self) -> None:
173+
self.initialised: bool = False
172174

173175
# pool handling
174-
self.pool_service = None
176+
self.pool_service: PoolService
175177

176178
self.tac = None
177179

178180
# NAT service
179181
self.nat = NATService()
180182

181-
def startFactory(self):
183+
def startFactory(self) -> None:
182184
# start the pool thread with default configs
183185
self.pool_service = PoolService(self.nat)
184-
self.pool_service.start_pool()
186+
if self.pool_service:
187+
self.pool_service.start_pool()
185188

186-
def stopFactory(self):
189+
def stopFactory(self) -> None:
187190
log.msg(eventid="cowrie.backend_pool.server", format="Stopping backend pool...")
188-
189-
self.pool_service.shutdown_pool()
191+
if self.pool_service:
192+
self.pool_service.shutdown_pool()
190193

191194
def buildProtocol(self, addr):
192195
log.msg(

src/backend_pool/pool_service.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Copyright (c) 2019 Guilherme Borges <[email protected]>
22
# See the COPYRIGHT file for more information
3+
from __future__ import annotations
34

45
import os
56
import time
67
from threading import Lock
78

8-
from twisted.internet import reactor, threads
9+
from twisted.internet import reactor # type: ignore
10+
from twisted.internet import threads
911
from twisted.python import log
1012

1113
import backend_pool.libvirt.backend_service
@@ -58,7 +60,7 @@ def __init__(self, nat_service):
5860
"backend_pool", "guest_telnet_port", fallback=-1
5961
)
6062

61-
self.local_pool: str = (
63+
self.local_pool: bool = (
6264
CowrieConfig.get("proxy", "pool", fallback="local") == "local"
6365
)
6466
self.pool_only: bool = CowrieConfig.getboolean(

src/backend_pool/ssh_exec.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from __future__ import annotations
2+
13
from twisted.conch.ssh import channel, common, connection, transport, userauth
2-
from twisted.internet import defer, protocol, reactor
4+
from twisted.internet import defer, protocol
5+
from twisted.internet import reactor # type: ignore
36

47

58
# object is added for Python 2.7 compatibility (#1198) - as is super with args

0 commit comments

Comments
 (0)