-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path__init__.py
More file actions
49 lines (43 loc) · 1.69 KB
/
__init__.py
File metadata and controls
49 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from codemodder.codemods.remove_unused_imports import RemoveUnusedImports
from codemodder.codemods.django_debug_flag_on import DjangoDebugFlagOn
from codemodder.codemods.django_session_cookie_secure_off import (
DjangoSessionCookieSecureOff,
)
from codemodder.codemods.harden_pyyaml import HardenPyyaml
from codemodder.codemods.harden_ruamel import HardenRuamel
from codemodder.codemods.limit_readline import LimitReadline
from codemodder.codemods.secure_random import SecureRandom
from codemodder.codemods.upgrade_sslcontext_tls import UpgradeSSLContextTLS
from codemodder.codemods.url_sandbox import UrlSandbox
from codemodder.codemods.process_creation_sandbox import ProcessSandbox
from codemodder.codemods.remove_unnecessary_f_str import RemoveUnnecessaryFStr
DEFAULT_CODEMODS = {
DjangoDebugFlagOn,
DjangoSessionCookieSecureOff,
HardenPyyaml,
HardenRuamel,
LimitReadline,
ProcessSandbox,
RemoveUnnecessaryFStr,
RemoveUnusedImports,
SecureRandom,
UpgradeSSLContextTLS,
UrlSandbox,
}
ALL_CODEMODS = DEFAULT_CODEMODS
def match_codemods(codemod_include: list, codemod_exclude: list) -> dict:
if not codemod_include and not codemod_exclude:
return {codemod.METADATA.NAME: codemod for codemod in DEFAULT_CODEMODS}
# cli should've already prevented both include/exclude from being set.
assert codemod_include or codemod_exclude
if codemod_exclude:
return {
name: codemod
for codemod in DEFAULT_CODEMODS
if (name := codemod.METADATA.NAME) not in codemod_exclude
}
return {
name: codemod
for codemod in DEFAULT_CODEMODS
if (name := codemod.METADATA.NAME) in codemod_include
}