Skip to content

Commit 6166e21

Browse files
authored
Merge pull request #400 from kyb3r/development
Development v3.3.0
2 parents ec5b827 + c8f8039 commit 6166e21

26 files changed

+3249
-2294
lines changed

.bandit_baseline.json

+243
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
{
2+
"errors": [],
3+
"generated_at": "2019-10-07T08:19:22Z",
4+
"metrics": {
5+
"./bot.py": {
6+
"CONFIDENCE.HIGH": 0.0,
7+
"CONFIDENCE.LOW": 0.0,
8+
"CONFIDENCE.MEDIUM": 0.0,
9+
"CONFIDENCE.UNDEFINED": 0.0,
10+
"SEVERITY.HIGH": 0.0,
11+
"SEVERITY.LOW": 0.0,
12+
"SEVERITY.MEDIUM": 0.0,
13+
"SEVERITY.UNDEFINED": 0.0,
14+
"loc": 933,
15+
"nosec": 0
16+
},
17+
"_totals": {
18+
"CONFIDENCE.HIGH": 2.0,
19+
"CONFIDENCE.LOW": 0.0,
20+
"CONFIDENCE.MEDIUM": 1.0,
21+
"CONFIDENCE.UNDEFINED": 0.0,
22+
"SEVERITY.HIGH": 0.0,
23+
"SEVERITY.LOW": 2.0,
24+
"SEVERITY.MEDIUM": 1.0,
25+
"SEVERITY.UNDEFINED": 0.0,
26+
"loc": 7299,
27+
"nosec": 0
28+
},
29+
"cogs/modmail.py": {
30+
"CONFIDENCE.HIGH": 0.0,
31+
"CONFIDENCE.LOW": 0.0,
32+
"CONFIDENCE.MEDIUM": 0.0,
33+
"CONFIDENCE.UNDEFINED": 0.0,
34+
"SEVERITY.HIGH": 0.0,
35+
"SEVERITY.LOW": 0.0,
36+
"SEVERITY.MEDIUM": 0.0,
37+
"SEVERITY.UNDEFINED": 0.0,
38+
"loc": 973,
39+
"nosec": 0
40+
},
41+
"cogs/plugins.py": {
42+
"CONFIDENCE.HIGH": 1.0,
43+
"CONFIDENCE.LOW": 0.0,
44+
"CONFIDENCE.MEDIUM": 0.0,
45+
"CONFIDENCE.UNDEFINED": 0.0,
46+
"SEVERITY.HIGH": 0.0,
47+
"SEVERITY.LOW": 1.0,
48+
"SEVERITY.MEDIUM": 0.0,
49+
"SEVERITY.UNDEFINED": 0.0,
50+
"loc": 537,
51+
"nosec": 0
52+
},
53+
"cogs/utility.py": {
54+
"CONFIDENCE.HIGH": 1.0,
55+
"CONFIDENCE.LOW": 0.0,
56+
"CONFIDENCE.MEDIUM": 0.0,
57+
"CONFIDENCE.UNDEFINED": 0.0,
58+
"SEVERITY.HIGH": 0.0,
59+
"SEVERITY.LOW": 0.0,
60+
"SEVERITY.MEDIUM": 1.0,
61+
"SEVERITY.UNDEFINED": 0.0,
62+
"loc": 1587,
63+
"nosec": 0
64+
},
65+
"core/_color_data.py": {
66+
"CONFIDENCE.HIGH": 0.0,
67+
"CONFIDENCE.LOW": 0.0,
68+
"CONFIDENCE.MEDIUM": 0.0,
69+
"CONFIDENCE.UNDEFINED": 0.0,
70+
"SEVERITY.HIGH": 0.0,
71+
"SEVERITY.LOW": 0.0,
72+
"SEVERITY.MEDIUM": 0.0,
73+
"SEVERITY.UNDEFINED": 0.0,
74+
"loc": 1168,
75+
"nosec": 0
76+
},
77+
"core/changelog.py": {
78+
"CONFIDENCE.HIGH": 0.0,
79+
"CONFIDENCE.LOW": 0.0,
80+
"CONFIDENCE.MEDIUM": 0.0,
81+
"CONFIDENCE.UNDEFINED": 0.0,
82+
"SEVERITY.HIGH": 0.0,
83+
"SEVERITY.LOW": 0.0,
84+
"SEVERITY.MEDIUM": 0.0,
85+
"SEVERITY.UNDEFINED": 0.0,
86+
"loc": 154,
87+
"nosec": 0
88+
},
89+
"core/checks.py": {
90+
"CONFIDENCE.HIGH": 0.0,
91+
"CONFIDENCE.LOW": 0.0,
92+
"CONFIDENCE.MEDIUM": 0.0,
93+
"CONFIDENCE.UNDEFINED": 0.0,
94+
"SEVERITY.HIGH": 0.0,
95+
"SEVERITY.LOW": 0.0,
96+
"SEVERITY.MEDIUM": 0.0,
97+
"SEVERITY.UNDEFINED": 0.0,
98+
"loc": 75,
99+
"nosec": 0
100+
},
101+
"core/clients.py": {
102+
"CONFIDENCE.HIGH": 0.0,
103+
"CONFIDENCE.LOW": 0.0,
104+
"CONFIDENCE.MEDIUM": 0.0,
105+
"CONFIDENCE.UNDEFINED": 0.0,
106+
"SEVERITY.HIGH": 0.0,
107+
"SEVERITY.LOW": 0.0,
108+
"SEVERITY.MEDIUM": 0.0,
109+
"SEVERITY.UNDEFINED": 0.0,
110+
"loc": 200,
111+
"nosec": 0
112+
},
113+
"core/config.py": {
114+
"CONFIDENCE.HIGH": 0.0,
115+
"CONFIDENCE.LOW": 0.0,
116+
"CONFIDENCE.MEDIUM": 0.0,
117+
"CONFIDENCE.UNDEFINED": 0.0,
118+
"SEVERITY.HIGH": 0.0,
119+
"SEVERITY.LOW": 0.0,
120+
"SEVERITY.MEDIUM": 0.0,
121+
"SEVERITY.UNDEFINED": 0.0,
122+
"loc": 276,
123+
"nosec": 0
124+
},
125+
"core/decorators.py": {
126+
"CONFIDENCE.HIGH": 0.0,
127+
"CONFIDENCE.LOW": 0.0,
128+
"CONFIDENCE.MEDIUM": 0.0,
129+
"CONFIDENCE.UNDEFINED": 0.0,
130+
"SEVERITY.HIGH": 0.0,
131+
"SEVERITY.LOW": 0.0,
132+
"SEVERITY.MEDIUM": 0.0,
133+
"SEVERITY.UNDEFINED": 0.0,
134+
"loc": 7,
135+
"nosec": 0
136+
},
137+
"core/models.py": {
138+
"CONFIDENCE.HIGH": 0.0,
139+
"CONFIDENCE.LOW": 0.0,
140+
"CONFIDENCE.MEDIUM": 0.0,
141+
"CONFIDENCE.UNDEFINED": 0.0,
142+
"SEVERITY.HIGH": 0.0,
143+
"SEVERITY.LOW": 0.0,
144+
"SEVERITY.MEDIUM": 0.0,
145+
"SEVERITY.UNDEFINED": 0.0,
146+
"loc": 91,
147+
"nosec": 0
148+
},
149+
"core/paginator.py": {
150+
"CONFIDENCE.HIGH": 0.0,
151+
"CONFIDENCE.LOW": 0.0,
152+
"CONFIDENCE.MEDIUM": 0.0,
153+
"CONFIDENCE.UNDEFINED": 0.0,
154+
"SEVERITY.HIGH": 0.0,
155+
"SEVERITY.LOW": 0.0,
156+
"SEVERITY.MEDIUM": 0.0,
157+
"SEVERITY.UNDEFINED": 0.0,
158+
"loc": 214,
159+
"nosec": 0
160+
},
161+
"core/thread.py": {
162+
"CONFIDENCE.HIGH": 0.0,
163+
"CONFIDENCE.LOW": 0.0,
164+
"CONFIDENCE.MEDIUM": 0.0,
165+
"CONFIDENCE.UNDEFINED": 0.0,
166+
"SEVERITY.HIGH": 0.0,
167+
"SEVERITY.LOW": 0.0,
168+
"SEVERITY.MEDIUM": 0.0,
169+
"SEVERITY.UNDEFINED": 0.0,
170+
"loc": 716,
171+
"nosec": 0
172+
},
173+
"core/time.py": {
174+
"CONFIDENCE.HIGH": 0.0,
175+
"CONFIDENCE.LOW": 0.0,
176+
"CONFIDENCE.MEDIUM": 0.0,
177+
"CONFIDENCE.UNDEFINED": 0.0,
178+
"SEVERITY.HIGH": 0.0,
179+
"SEVERITY.LOW": 0.0,
180+
"SEVERITY.MEDIUM": 0.0,
181+
"SEVERITY.UNDEFINED": 0.0,
182+
"loc": 169,
183+
"nosec": 0
184+
},
185+
"core/utils.py": {
186+
"CONFIDENCE.HIGH": 0.0,
187+
"CONFIDENCE.LOW": 0.0,
188+
"CONFIDENCE.MEDIUM": 1.0,
189+
"CONFIDENCE.UNDEFINED": 0.0,
190+
"SEVERITY.HIGH": 0.0,
191+
"SEVERITY.LOW": 1.0,
192+
"SEVERITY.MEDIUM": 0.0,
193+
"SEVERITY.UNDEFINED": 0.0,
194+
"loc": 199,
195+
"nosec": 0
196+
}
197+
},
198+
"results": [
199+
{
200+
"code": "14 from site import USER_SITE\n15 from subprocess import PIPE\n16 \n17 import discord\n",
201+
"filename": "cogs/plugins.py",
202+
"issue_confidence": "HIGH",
203+
"issue_severity": "LOW",
204+
"issue_text": "Consider possible security implications associated with PIPE module.",
205+
"line_number": 15,
206+
"line_range": [
207+
15,
208+
16
209+
],
210+
"more_info": "https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess",
211+
"test_id": "B404",
212+
"test_name": "blacklist"
213+
},
214+
{
215+
"code": "1824 try:\n1825 exec(to_compile, env) # pylint: disable=exec-used\n1826 except Exception as exc:\n",
216+
"filename": "cogs/utility.py",
217+
"issue_confidence": "HIGH",
218+
"issue_severity": "MEDIUM",
219+
"issue_text": "Use of exec detected.",
220+
"line_number": 1825,
221+
"line_range": [
222+
1825
223+
],
224+
"more_info": "https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html",
225+
"test_id": "B102",
226+
"test_name": "exec_used"
227+
},
228+
{
229+
"code": "219 for token in shlex.shlex(alias, punctuation_chars=\"&\"):\n220 if token != \"&&\":\n221 buffer += \" \" + token\n",
230+
"filename": "core/utils.py",
231+
"issue_confidence": "MEDIUM",
232+
"issue_severity": "LOW",
233+
"issue_text": "Possible hardcoded password: '&&'",
234+
"line_number": 220,
235+
"line_range": [
236+
220
237+
],
238+
"more_info": "https://bandit.readthedocs.io/en/latest/plugins/b105_hardcoded_password_string.html",
239+
"test_id": "B105",
240+
"test_name": "hardcoded_password_string"
241+
}
242+
]
243+
}

.lint.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import sys
2-
from os import listdir
3-
from os.path import join
1+
if __name__ == "__main__":
2+
import sys
3+
from os import listdir
4+
from os.path import join
45

5-
from pylint.lint import Run
6+
from pylint.lint import Run
67

7-
THRESHOLD = 9.75
8+
THRESHOLD = 9.75
89

9-
cogs = [join("cogs", c) for c in listdir("cogs") if c.endswith(".py")]
10-
core = [join("core", c) for c in listdir("core") if c.endswith(".py")]
10+
cogs = [join("cogs", c) for c in listdir("cogs") if c.endswith(".py")]
11+
core = [join("core", c) for c in listdir("core") if c.endswith(".py")]
1112

12-
results = Run(["bot.py", *cogs, *core], do_exit=False)
13+
results = Run(["bot.py", *cogs, *core], do_exit=False)
1314

14-
score = results.linter.stats["global_note"]
15-
if score <= THRESHOLD:
16-
sys.exit(1)
15+
score = results.linter.stats["global_note"]
16+
if score <= THRESHOLD:
17+
sys.exit(1)

.travis.yml

+18-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,27 @@ language: python
33
matrix:
44
include:
55
- python: '3.7'
6-
dist: xenial
6+
name: "Python 3.7.1 on Xenial Linux"
7+
- python: '3.6'
8+
name: "Python 3.6.7 on Xenial Linux"
9+
- name: "Python 3.7.4 on macOS"
10+
os: osx
11+
osx_image: xcode11.2
12+
language: shell
13+
- name: "Python 3.7.5 on Windows"
14+
os: windows
15+
language: shell
16+
before_install:
17+
- choco install python --version=3.7.5
18+
- python -m pip install --upgrade pip
19+
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
720

821
install:
22+
- pip3 install --upgrade pip
23+
- pip3 install pipenv
924
- pipenv install -d
1025

1126
script:
27+
- pipenv run bandit ./bot.py cogs/*.py core/*.py -b .bandit_baseline.json
1228
- pipenv run python .lint.py
29+
- pipenv run flake8 ./bot.py cogs/*.py core/*.py --ignore=E501,E203,W503 --exit-zero

CHANGELOG.md

+68
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,74 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
77
however, insignificant breaking changes does not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319).
88

9+
10+
# v3.3.0-dev6
11+
12+
13+
### Important
14+
15+
- Recommend all users to unblock and re-block all blocked users upon updating to this release.
16+
17+
### Added
18+
19+
- Three new config vars:
20+
- `enable_plugins` (yes/no default yes)
21+
- When set to no, plugins will not be loaded into the bot.
22+
- `error_color` (color format, defaults discord red)
23+
- The color of error messages.
24+
- `anon_reply_without_command` (yes/no default no) (Thanks to papiersnipper PR#288)
25+
- When set, all non-command messages sent to thread channels are forwarded to the recipient anonymously without the need of `?anonreply`.
26+
- This config takes precedence over `reply_without_command`.
27+
- `?logs responded [user]` command, it will show all logs that the user has sent an reply. (Thanks to papiersnipper PR#288)
28+
- `user` when not provided, defaults to the user who ran the command.
29+
- Open threads in limbo now auto closes if the channel cannot be found. This check is done every time the bot restarts.
30+
- Ability to disable new threads from getting created.
31+
- `?disable`
32+
- Ability to fully disable Modmail DM.
33+
- `?disable all`
34+
- To re-enable DM: `?enable`, and to see the current status: `?isenable`.
35+
- This disabled Modmail interface is customizable with the following config vars:
36+
- `disabled_new_thread_title`
37+
- `disabled_new_thread_response`
38+
- `disabled_new_thread_footer`
39+
- `disabled_current_thread_title`
40+
- `disabled_current_thread_response`
41+
- `disabled_current_thread_footer`
42+
- Ability to delete notes when providing their ID. (Thanks to papiersnipper PR#402)
43+
- Ability to delete log entries. (Thanks to papiersnipper PR#402)
44+
45+
### Changed
46+
47+
- `?contact` no longer send the "thread created" message to where the command is ran, instead, it's now sent to the newly created thread channel. (Thanks to DAzVise)
48+
- Automatically delete notes command `?note` when there's no attachments attached.
49+
- Embed author links used to be inaccessible in many cases, now:
50+
- `?anonreply`, `?reply`, and `?note` in thread channel will link to the sender's profile.
51+
- `?reply` and recipient's DM will also link the sender's profile.
52+
- `?anonreply` in DM channel will link to the first channel of the main guild.
53+
- Plugins update (mostly internal).
54+
- `git` is no longer used to install plugins, it now downloads through zip files.
55+
- `?plugins enabled` renamed to `?plugins loaded` while `enabled` is still an alias to that command.
56+
- Reorganised plugins folder structure.
57+
- Logging / plugin-related messages changes.
58+
- Updating one plugin will not update all other plugins (plugins are no longer separated by repos, but the plugin name itself).
59+
- Help command is in alphabetical order grouped by permissions.
60+
- Notes are no longer always blurple, its set to `MAIN_COLOR` now.
61+
- Added `?plugins update` for updating all installed plugins.
62+
- Reintroduce flake8 and use bandit for security issues detection.
63+
- Add travis checks for 3.6 in Linux and 3.7 for MacOS and Windows.
64+
- Eval commands are logged in debug logs.
65+
- Presence updates 30 minutes instead of 45 now.
66+
- Fixed an assortment of problems to do with block.
67+
- Existing aliases can be used when creating new aliases. (Thanks to papiersnipper PR#402)
68+
69+
### Internal
70+
71+
- Reworked `config.get` and `config.set`, it feeds through the converters before setting/getting.
72+
- To get/set the raw value, access through `config[]`.
73+
- Prerelease naming scheme is now `x.x.x-devN`.
74+
- `trigger_typing` has been moved to `core.utils.trigger_typing`, original location is deprecated.
75+
- Simpler status and activity logic.
76+
977
# v3.2.2
1078

1179
Security update!

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
FROM python:3.7.4-alpine
2-
RUN apk add --no-cache git
32
WORKDIR /modmailbot
43
COPY . /modmailbot
54
RUN pip install --no-cache-dir -r requirements.min.txt

0 commit comments

Comments
 (0)