Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fec405a
Bump https://github.com/psf/black-pre-commit-mirror
dependabot[bot] Mar 10, 2026
73409e6
Remove blank line in requests_get_verify_false.py
ericwb Mar 11, 2026
d90f119
Remove unnecessary blank line in __init__.py
ericwb Mar 11, 2026
def3172
Remove unnecessary blank line in __main__.py
ericwb Mar 11, 2026
043839d
Remove unnecessary blank line in main.py
ericwb Mar 11, 2026
576aa83
Remove unnecessary blank line in run.py
ericwb Mar 11, 2026
e3e24b7
Remove unnecessary blank line in i18n.py
ericwb Mar 11, 2026
42dd9de
Remove blank line in Parser class
ericwb Mar 11, 2026
7fccfbc
Add blank line for improved readability in __init__.py
ericwb Mar 11, 2026
7236116
Refactor rule splitting for clarity
ericwb Mar 11, 2026
dce843a
Remove unnecessary blank line in basic.py
ericwb Mar 11, 2026
e3b676b
Remove unnecessary blank line in python.py
ericwb Mar 11, 2026
6515149
Refactor argument unpacking for get_func_args calls
ericwb Mar 11, 2026
735bca7
Remove unnecessary blank line in json.py
ericwb Mar 11, 2026
164aca2
Remove unnecessary blank line in markdown.py
ericwb Mar 11, 2026
2867e68
Clean up setup.py by removing extra newline
ericwb Mar 11, 2026
9af912d
Remove unnecessary blank line in pypi.py
ericwb Mar 11, 2026
8b7997f
Remove unnecessary blank line in github.py
ericwb Mar 11, 2026
9d77bbb
Fix formatting and remove unnecessary blank lines
ericwb Mar 11, 2026
59f82d5
Add blank line for code style consistency
ericwb Mar 11, 2026
3968ee7
Add missing newline in crypto_weak_hash.py
ericwb Mar 11, 2026
9ccb6b4
Add blank line for code style consistency
ericwb Mar 11, 2026
3c2eb1f
Add missing newline in net_http_no_timeout.py
ericwb Mar 11, 2026
1d5b6db
Add newline to net_unrestricted_bind.py
ericwb Mar 11, 2026
22f8158
Update net_unrestricted_bind.py
ericwb Mar 11, 2026
ddcbf4d
Add missing import statement for Optional
ericwb Mar 11, 2026
028e779
Update java_net_insecure_cookie.py
ericwb Mar 11, 2026
357d747
Add import statement for Optional type
ericwb Mar 11, 2026
e06f2b4
Add import for Optional type in java_security_weak_key.py
ericwb Mar 11, 2026
0cf5062
Add import statement for Optional type
ericwb Mar 11, 2026
60cd313
Add import for Optional type in javax_crypto_weak_cipher.py
ericwb Mar 11, 2026
f28c87d
Add import for Optional type in insecure_cookie.py
ericwb Mar 11, 2026
79d947f
Add a blank line for code style consistency
ericwb Mar 11, 2026
f77a0a7
Fix format
ericwb Mar 11, 2026
4b51f96
remove shitty reorder imports
ericwb Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.16.0
hooks:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py38-plus]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.3.0
hooks:
- id: black
args: [--line-length=79, --target-version=py311]
Expand Down
1 change: 0 additions & 1 deletion custom/python/requests_get_verify_false.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests


requests.get("https://localhost", verify=False)
1 change: 0 additions & 1 deletion precli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from importlib import metadata


__author__ = metadata.metadata("precli")["Author"]
__summary__ = metadata.metadata("precli")["Summary"]
__copyright__ = f"Copyright {datetime.now():%Y} Secure Sauce LLC"
Expand Down
1 change: 0 additions & 1 deletion precli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# SPDX-License-Identifier: BUSL-1.1
from precli.cli import main


main.main()
1 change: 0 additions & 1 deletion precli/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from precli.core.run import Run
from precli.renderers import Renderer


BUSL_URL = "https://spdx.org/licenses/BUSL-1.1.html"
GITHUB_URL = "https://github.com"
PYPI_URL = "https://pypi.org"
Expand Down
1 change: 0 additions & 1 deletion precli/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from precli.parsers.basic import Basic
from precli.rules import Rule


LOG = logging.getLogger(__name__)
PROGRESS_THRESHOLD = 50
parsers = loader.load_extension(group="precli.parsers")
Expand Down
1 change: 0 additions & 1 deletion precli/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import locale
import os


LOCALE_DIR = os.path.join("precli", "locale")


Expand Down
2 changes: 1 addition & 1 deletion precli/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _expand_rule_list(rule_list: list[str]) -> list[str]:
expanded_rules = []
for rule in rule_list:
if "-" in rule:
(rule_start, rule_end) = rule.split("-", maxsplit=1)
rule_start, rule_end = rule.split("-", maxsplit=1)
if rule_start[:-3] == rule_end[:-3]:
try:
start = int(rule_start[-3:])
Expand Down
1 change: 0 additions & 1 deletion precli/parsers/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from precli.parsers import Parser


# Language map to [file extensions, rule prefix]
LANG_MAP = {
"c_sharp": [[".cs"], "CS"],
Expand Down Expand Up @@ -34,7 +33,7 @@
super().__init__(lang)
self.SUPPRESS_COMMENT = re.compile(r"suppress:? (?P<rules>[^#]+)?#?")
self.SUPPRESSED_RULES = re.compile(
rf"(?:({LANG_MAP[self.lexer][1]}\d\d\dC|[a-z_]+),?)+"

Check failure on line 36 in precli/parsers/basic.py

View check run for this annotation

Precaution / Precaution Unsubscribed

PY033: Inefficient Regular Expression Complexity

The call to 're.compile'' with regex pattern 'rf"(?:({LANG_MAP[self.lexer][1]}\d\d\dC|[a-z_]+),?)+"'' is susceptible to catastrophic backtracking and may cause performance degradation.
)

if "skip_tests" in config:
Expand Down
5 changes: 2 additions & 3 deletions precli/parsers/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from precli.parsers import Parser
from precli.parsers.node_types import NodeTypes


Import = namedtuple("Import", "module alias")


Expand All @@ -27,7 +26,7 @@
def __init__(self, **config):
super().__init__("python")
self.SUPPRESS_COMMENT = re.compile(r"suppress:? (?P<rules>[^#]+)?#?")
self.SUPPRESSED_RULES = re.compile(r"(?:(PY\d\d\d|[a-z_]+),?)+")

Check failure on line 29 in precli/parsers/python.py

View check run for this annotation

Precaution / Precaution Unsubscribed

PY033: Inefficient Regular Expression Complexity

The call to 're.compile'' with regex pattern 'r"(?:(PY\d\d\d|[a-z_]+),?)+"'' is susceptible to catastrophic backtracking and may cause performance degradation.

if "skip_tests" in config:
self.skip_tests = config["skip_tests"]
Expand Down Expand Up @@ -217,7 +216,7 @@
)

if nodes[2].type == NodeTypes.CALL:
(call_args, call_kwargs) = self.get_func_args(
call_args, call_kwargs = self.get_func_args(
nodes[2].children[1]
)

Expand Down Expand Up @@ -264,7 +263,7 @@

def visit_call(self, nodes: list[Node]):
func_call_qual = self.resolve(nodes[0])
(func_call_args, func_call_kwargs) = self.get_func_args(nodes[1])
func_call_args, func_call_kwargs = self.get_func_args(nodes[1])

if self.context["node"].children:
# (attribute | identifier) argument_list
Expand Down
1 change: 0 additions & 1 deletion precli/renderers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from precli.renderers import Renderer
from precli.rules import Rule


SCHEMA_URI = "https://json.schemastore.org/sarif-2.1.0.json"
SCHEMA_VER = "2.1.0"
TS_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
Expand Down
1 change: 0 additions & 1 deletion precli/renderers/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from precli.renderers import Renderer
from precli.rules import Rule


logging.getLogger("markdown_it").setLevel(logging.INFO)


Expand Down
2 changes: 1 addition & 1 deletion precli/rules/go/stdlib/crypto_unrestricted_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
_New in version 0.8.1_

""" # noqa: E501

from typing import Optional

from precli.core import utils
Expand All @@ -112,7 +113,6 @@
from precli.i18n import _
from precli.rules import Rule


INADDR_ANY = "0.0.0.0"
IN6ADDR_ANY = "[::]"

Expand Down
1 change: 1 addition & 0 deletions precli/rules/go/stdlib/crypto_weak_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
_New in version 0.2.1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/go/stdlib/crypto_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
_New in version 0.2.1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/go/stdlib/crypto_weak_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
_New in version 0.2.1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/go/stdlib/net_http_no_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
_New in version 0.8.1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/go/stdlib/net_unrestricted_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
_New in version 0.8.1_

""" # noqa: E501

from typing import Optional

from precli.core import utils
Expand All @@ -94,7 +95,6 @@
from precli.i18n import _
from precli.rules import Rule


INADDR_ANY = "0.0.0.0"
IN6ADDR_ANY = "[::]"

Expand Down
1 change: 1 addition & 0 deletions precli/rules/go/stdlib/syscall_setuid_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
_New in version 0.6.6_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/java/stdlib/java_net_insecure_cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
_New in version 0.5.1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/java/stdlib/java_security_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
_New in version 0.5.0_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/java/stdlib/java_security_weak_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
_New in version 0.5.0_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/java/stdlib/java_security_weak_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
_New in version 0.5.0_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/java/stdlib/javax_crypto_weak_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
_New in version 0.5.0_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
_New in version 0.5.1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/argparse_sensitive_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
_Changed in version 0.4.1: --api-key also checked_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def foobar(a: str = None):
_New in version 0.3.8_

""" # noqa: E501

from typing import Optional

from precli.core.location import Location
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/crypt_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
_New in version 0.1.0_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand All @@ -121,7 +122,6 @@
from precli.i18n import _
from precli.rules import Rule


WEAK_CRYPT_HASHES = (
"crypt.METHOD_CRYPT",
"crypt.METHOD_MD5",
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/ftplib_cleartext.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
_New in version 0.1.0_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/ftplib_no_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
_New in version 0.6.7_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/ftplib_unverified_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
_New in version 0.3.14_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand All @@ -81,7 +82,6 @@
from precli.i18n import _
from precli.rules import Rule


CONTEXT_FIX = "ssl.create_default_context()"


Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/hashlib_improper_prng.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
_New in version 0.4.3_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/hashlib_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
_Changed in version 0.4.1: Added md5-sha1_

""" # noqa: E501

from typing import Optional

from precli.core.argument import Argument
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/hmac_timing_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
_New in version 0.1.4_

""" # noqa: E501

from typing import Optional

from precli.core.comparison import Comparison
Expand All @@ -93,7 +94,6 @@
from precli.i18n import _
from precli.rules import Rule


TIMING_VULNERABLE = (
"hmac.digest",
"hmac.new.digest",
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/hmac_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
_Changed in version 0.4.1: Added md5-sha1_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
2 changes: 1 addition & 1 deletion precli/rules/python/stdlib/hmac_weak_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
_New in version 0.4.3_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand All @@ -82,7 +83,6 @@
from precli.i18n import _
from precli.rules import Rule


HASH_NAME_SIZES = {
"blake2s": 32,
"blake2b": 64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def run(server_class: HTTPServer):
_New in version 0.3.14_

""" # noqa: E501

from typing import Optional

from precli.core import utils
Expand All @@ -89,7 +90,6 @@ def run(server_class: HTTPServer):
from precli.i18n import _
from precli.rules import Rule


INADDR_ANY = "0.0.0.0"
IN6ADDR_ANY = "::"

Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/http_url_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
_New in version 0.3.4_

""" # noqa: E501

from typing import Optional
from urllib.parse import parse_qs
from urllib.parse import urlsplit
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/imaplib_cleartext.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
_New in version 0.1.9_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
1 change: 1 addition & 0 deletions precli/rules/python/stdlib/imaplib_no_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
_New in version 0.6.7_

""" # noqa: E501

from typing import Optional

from precli.core.call import Call
Expand Down
Loading